Documentation
¶
Overview ¶
Package workflowkit holds the engine-agnostic workflow IR helpers: the lobster expression grammar (expr-lang plus a grammar-enforcing AST patcher), the `${arg}` template expansion, task-arg resolution, the dependency closure, pipeline validation, the charly.yml / .lobster LOWERING, the cron→OnCalendar conversion, and the workflow graph renderers.
It is a MECHANISM library (kind-blind, capability-free): nothing here dials a provider or knows a plugin word. The lobster engine (plugin-lobster) and any future engine (github-actions, …) share ONE lowering + ONE validator.
Index ¶
- func CronToOnCalendar(expr string) (string, error)
- func Eval(expression string, scope Scope) (bool, error)
- func ExpandVars(s string, env map[string]string) string
- func HasRef(s string) bool
- func PlanRefs(plan *yaml.Node) []string
- func RefIDs(refs []string) []string
- func RefNames(expression string) []string
- func ResolveTaskDir(projDir, dir string, env map[string]string) string
- func RewritePlanRefs(plan *yaml.Node, refs []string)
- func RewriteRefs(s string) string
- func Validate(expression string) error
- type Scope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CronToOnCalendar ¶
CronToOnCalendar converts a 5-field cron expression (or an @-macro) into a systemd `OnCalendar=` value. It validates through robfig/cron's standard parser — the SAME grammar the rest of charly accepts — and renders the parsed bit-set, so lists, ranges, steps and names all lower correctly:
"0 3 * * *" -> "*-*-* 03:00:00" "*/15 9-17 * * Mon-Fri" -> "Mon,Tue,Wed,Thu,Fri *-*-* 09..17:00/15:00" "0 0 1 * *" -> "*-*-01 00:00:00"
ONE cron form is REJECTED rather than lowered: a restricted day-of-month AND a restricted day-of-week in the same expression (`0 3 1 * 1`). cron fires when EITHER of those two fields matches; systemd's calendar spec requires BOTH. A single `OnCalendar=` line cannot express that OR, and GenerateSystemdTimer writes exactly one — so the conversion returns an error naming the cause instead of a schedule that fires on the wrong days. Either field restricted ALONE (`0 3 1 * *`, `0 3 * * 1`) is unaffected: an unrestricted field is not a restriction.
The result is a valid OnCalendar expression; a caller may assert it with `systemd-analyze calendar`.
func Eval ¶
Eval compiles and runs a lobster boolean expression against scope. `true`/`false` literals must be lowercase (lobster's spelling). The result must be a bool.
func ExpandVars ¶
ExpandVars substitutes ${VAR} and $VAR using env first, then the process environment — so a task's dir/command can reference HOME, the project vars, and resolved params uniformly. Moved VERBATIM from plugin-task's expandVars (R3: one implementation, its callers repointed).
func PlanRefs ¶ added in v0.2026316.1524
PlanRefs returns the distinct `$step.path` references in a plan, in document order.
func RefIDs ¶
RefIDs reduces a list of `$<id>.<path>` references to their distinct step ids, in order. It is the seam the validator uses on a plan's collected references.
func RefNames ¶
RefNames returns the distinct step ids referenced by expression, in first-seen order. It is the seam the validator/lowering uses to know which earlier steps a `when:`/`stdin:`/plan consumes (refs to earlier steps only).
func ResolveTaskDir ¶
ResolveTaskDir resolves a task's dir against the project root, expanding ${VAR} / $VAR references against the merged task env (so `dir: "$HOME/src"` and `dir: "${WORKDIR}/src"` both work). An empty dir is the project root.
func RewritePlanRefs ¶ added in v0.2026316.1524
RewritePlanRefs rewrites every `$step.path` in a plan to `${REF_<n>}`, the env var the lobster step sets (index i → REF_(i+1), matching PlanRefs' order). The BRACE form is mandatory: the expander that runs the plan (kit.ExpandOpVars, kit.TestVarRefPattern) is brace-only, so a bare `$REF_<n>` would reach a plugin-verb input as literal text.
func RewriteRefs ¶
RewriteRefs rewrites every `$<id>.<path>` step reference in s into a `ref("<id>", "<path>")` call. Exported so the migration hook (plugin-migrate) can reuse the ONE ref grammar (R3).
Types ¶
type Scope ¶
Scope is the set of per-step result envelopes an expression evaluates against: step id -> the step's raw output, a JSON envelope such as `{"json":{...},"stdout":"..."}`. `$fetch.json.name` looks up `json.name` in the `fetch` entry with gjson (a `.json` accessor is the author's, not the engine's: the whole envelope is the lookup root, matching upstream lobster).