workflowkit

package
v0.2026318.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 12 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CronToOnCalendar

func CronToOnCalendar(expr string) (string, error)

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

func Eval(expression string, scope Scope) (bool, error)

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

func ExpandVars(s string, env map[string]string) string

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 HasRef

func HasRef(s string) bool

HasRef reports whether s contains any `$<id>.<path>` step reference.

func PlanRefs added in v0.2026316.1524

func PlanRefs(plan *yaml.Node) []string

PlanRefs returns the distinct `$step.path` references in a plan, in document order.

func RefIDs

func RefIDs(refs []string) []string

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

func RefNames(expression string) []string

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

func ResolveTaskDir(projDir, dir string, env map[string]string) string

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

func RewritePlanRefs(plan *yaml.Node, refs []string)

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

func RewriteRefs(s string) string

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).

func Validate

func Validate(expression string) error

Validate compiles expression under the lobster grammar with a stub reference resolver and reports the first grammar/type error. It never evaluates.

Types

type Scope

type Scope map[string]string

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL