Documentation
¶
Overview ¶
Package workflow loads YAML workflow templates and turns them into concrete issue/dep/label plans.
A template is a declarative description of a multi-step process. `Load` parses YAML; `MakePlan` produces an instantiation plan from a template and a set of variable bindings; the CLI layer writes the plan to the store.
Index ¶
Constants ¶
const TemplatesSubdir = "templates"
TemplatesSubdir is the directory name under a clu project dir where workflow YAML files live. The CLI and HTTP servers both resolve their templates dir via TemplatesPath so a future move (e.g. to .clu/workflows/) only changes one constant.
Variables ¶
This section is empty.
Functions ¶
func Interpolate ¶
Interpolate substitutes {{var}} placeholders in s. An unknown var name is an error.
func TemplatesPath ¶
TemplatesPath returns the templates directory for a project at `projectDir`. Centralises the join so call sites stop hardcoding the literal.
Types ¶
type LoadError ¶
LoadError pairs a template file that failed to load with the underlying error. LoadDir returns these alongside the healthy templates so one bad file doesn't block listing or running the rest.
func LoadDir ¶
LoadDir loads all *.yaml/*.yml files from dir, keyed by template name. Missing dir returns an empty map (no error). Per-file failures (parse errors, missing @-referenced spec files, duplicate names) are returned as a separate []LoadError — the caller decides whether to surface them; the healthy templates are still usable for `template ls`, `template show <other>`, `run <other>`.
This shape exists because a single broken template used to abort every template command. With a checked-in workflow dir shared across a team that meant one person's bad commit broke the tool for everyone.
type ParentSpec ¶
ParentSpec describes the root issue of a run.
type Plan ¶
type Plan struct {
TemplateName string
Vars map[string]string
Spec string // interpolated; the shared-context block (may be empty)
Parent ParentSpec
Steps []StepSpec
}
Plan is the abstract result of applying a Template to a set of vars. It is pure — no IDs allocated, no DB writes performed. The CLI layer walks the plan, calls store.Create per step, and writes deps/labels/KV.
type Step ¶
type Step struct {
ID string `yaml:"id"`
Title string `yaml:"title"`
// Description is per-step instructions — acceptance criteria, the
// specific job, any references downstream agents will need.
// {{var}} interpolation applies. The template's spec is prepended
// at instantiation so each step issue is self-contained.
Description string `yaml:"description,omitempty"`
Type string `yaml:"type,omitempty"`
Priority *int `yaml:"priority,omitempty"`
Needs []string `yaml:"needs,omitempty"`
Agent string `yaml:"agent,omitempty"` // pre-assigns the step to an agent lane
Wait *Wait `yaml:"wait,omitempty"`
}
Step is one step in a workflow.
type StepSpec ¶
type StepSpec struct {
StepID string // template step id (e.g. "build")
Title string // interpolated
Description string // interpolated; spec + "\n\n---\n\n" + per-step desc, when set
Type string // "task" or "checkpoint"
Priority int
Needs []string // step ids, not issue ids
Agent string // pre-assigned agent lane; "" = unassigned
Wait *Wait // checkpoint config; nil for tasks
IsLeaf bool // no other step needs this one — parent depends on it
}
StepSpec describes one step in a Plan.
type Template ¶
type Template struct {
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
// Spec is shared context prepended to every step's description on
// instantiation. Inline string, or @<path> to load from a file
// relative to the template (so a 50-line scaffold-spec.md can live
// next to the template). {{var}} placeholders interpolate.
Spec string `yaml:"spec,omitempty"`
Vars map[string]Var `yaml:"vars,omitempty"`
Steps []Step `yaml:"steps"`
}
Template is a parsed workflow definition.
func Load ¶
Load reads and parses a template file. If `spec:` starts with @, the rest is treated as a path (resolved relative to the template file) and its contents replace the @-string. Useful for keeping long shared-context blocks in a sibling markdown file.
func (Template) ResolveVars ¶
ResolveVars validates caller-supplied values against the template's declared vars. Returns the merged map (defaults applied).
type Var ¶
type Var struct {
Required bool `yaml:"required,omitempty"`
Default string `yaml:"default,omitempty"`
Pattern string `yaml:"pattern,omitempty"`
// Label is a short human-readable name for the variable. Used by
// the interactive prompt today; future surfaces (docs, GUI, JSON
// schemas) will reuse the same string. Defaults to the var name
// when empty.
Label string `yaml:"label,omitempty"`
}
Var is a single variable declaration.