@lchase/yak 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +82 -0
  3. package/dist/index.js +2771 -0
  4. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lawrence Chase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # yak
2
+
3
+ An agentic workflow engine. *It shaves the yak so you don't.*
4
+
5
+ Reads a YAML DAG, runs steps (shell commands, pure transforms, coding-agent
6
+ invocations, human gates), and journals everything to disk so runs resume
7
+ exactly where they stopped.
8
+
9
+ Status: M0–M5 all done (spec.md §8). The `agent → agent → command →
10
+ transform` reference shape runs deterministically against fixtures
11
+ (`mock` adapter) and for real against an actual bug
12
+ (`claude-code` adapter, `fixtures/todo-app/` — see the tutorial at
13
+ `docs-site/docs/tutorial.md`, live at
14
+ `https://lchase.github.io/yak/docs/tutorial`). `loop`, `map`, `gate`,
15
+ and worktree isolation are all implemented and executable, not just IR
16
+ types. See `spec.md` §8.
17
+
18
+ ## Current capabilities (M0–M5)
19
+
20
+ M0 is zero-AI by design — a boring shell pipeline has to cache, resume, and
21
+ journal correctly before nondeterministic steps go anywhere near it.
22
+
23
+ - **Step kinds:** `command` (streamed shell exec, capture stdout/stderr/
24
+ exitCode, optional `idleTimeoutMs` — SIGTERM then SIGKILL after a grace
25
+ period, `StepFailure.reason: 'timeout'`), `transform` (named pure
26
+ function from `.yak/transforms.ts`), `agent`
27
+ (prompt from `{ file }`/`{ inline }` with `{{placeholder}}` interpolation,
28
+ `context: 'fresh' | { inherit } | { session }`, Zod schema validation via
29
+ `.yak/schemas.ts`, schema repair loop with retries), `loop` (bounded by
30
+ `maxIterations`, plus a `noProgress` signal/rounds exhaustion check),
31
+ `map` (concurrency cap, per-item failure policy, optional
32
+ `isolation: 'worktree'` — each item forks its own worktree off the
33
+ run's `HEAD`, engine auto-commits before fan-out so items see prior
34
+ steps' output), and `gate` (human decision point, `schema`-validated
35
+ answer, optional `skipIf`).
36
+ - **Suspend/resume:** a `gate` or an exhausted budget suspends the run
37
+ (`run.suspended`, reason `gate` | `budget`, `tripped: maxIterations |
38
+ maxTokens | noProgress`) rather than failing it. `yak pending` lists
39
+ every run across the repo awaiting a human answer; `yak resume
40
+ <run-id>` replays and continues; `--interactive` prompts through open
41
+ gates inline instead of exiting to resume later.
42
+ - **Worktree isolation:** `yak run --isolation worktree` runs the whole
43
+ workflow inside a fresh git worktree (`.yak/worktrees/<run-id>/`);
44
+ `map` steps can additionally isolate each item into its own sibling
45
+ worktree.
46
+ - **Introspection:** `yak graph <workflow>` emits a workflow's DAG as
47
+ Mermaid; `yak watch [<run-id>]` live-tails a run's step statuses in a
48
+ terminal UI; `yak artifacts [<run-id>]` lists a `map` step's per-item
49
+ artifact files.
50
+ - **Scheduling:** topological sort, concurrent execution of independent
51
+ steps up to a concurrency cap, artifact-driven eligibility (`needs`/
52
+ `produces`).
53
+ - **Validation:** rejects unknown step kinds, duplicate ids, `needs`
54
+ referencing an artifact nothing produces, cycles, and reading
55
+ `<step>.exitCode` downstream of a step with `failOn: 'exitCode'`.
56
+ - **Caching:** two-tier content-addressed cache key (`semanticKey` over
57
+ step id + input artifact hashes, `definitionKey` over the step's own
58
+ definition). `cache: strict` (default) re-runs on any mismatch;
59
+ `cache: loose` reuses the artifact and marks the step `stale` when only
60
+ the definition moved.
61
+ - **Journal:** append-only JSONL event log of every step's lifecycle.
62
+ - **Resume:** `yak resume <run-id>` replays a run's journal to find what
63
+ already completed (a step left `step.started` with no matching
64
+ `step.completed`/`step.failed` is treated as interrupted), recomputes each
65
+ completed step's cache keys against the frozen workflow, reuses the
66
+ on-disk artifact on a match, and re-runs everything from the first
67
+ mismatch downward.
68
+ - **Status:** `yak status [<run-id>]` replays a run's journal into per-step
69
+ state (`completed`/`cached`/`stale`/`failed`/`pending`), with no db or
70
+ extra durable state beyond the journal. Defaults to the most recent run
71
+ when `<run-id>` is omitted.
72
+ - **Adapters:** `mock` (fixture-driven, deterministic, free) and
73
+ `claude-code` (real, wraps `@anthropic-ai/claude-agent-sdk`). Selected
74
+ with `yak run --adapter mock|claude-code` (default `claude-code`);
75
+ `yak resume` replays the run's original choice and rejects a conflicting
76
+ `--adapter` override. `claude-code.ts`'s own tests stub `query()` at the
77
+ module boundary — CI never calls a real model, per CLAUDE.md.
78
+
79
+ Not yet implemented: eval-corpus export (`yak export --evals`,
80
+ descoped from M4, spec.md §9 decision 10), an API/CLI/YAML reference
81
+ beyond spec.md, and npm publish (`docs-site/`'s quickstart still targets
82
+ a git-clone install for that reason).