@hecer/yoke 1.10.0 → 1.11.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 (131) hide show
  1. package/.claude-plugin/plugin.json +13 -13
  2. package/.codex-plugin/plugin.json +7 -7
  3. package/CHANGELOG.md +398 -379
  4. package/README.md +915 -915
  5. package/TODOS.md +5 -5
  6. package/agents/docs.toml +6 -6
  7. package/agents/implementer.toml +6 -6
  8. package/agents/reviewer.toml +6 -6
  9. package/agents/security.toml +6 -6
  10. package/bench/README.md +86 -86
  11. package/bench/RESULTS.md +35 -35
  12. package/bench/output-compaction.mjs +65 -65
  13. package/bench/result-schema.mjs +12 -12
  14. package/bench/results/claude-2026-07-27T18-03-26.json +50 -50
  15. package/bench/results/codex-unavailable-1785175418318.json +15 -15
  16. package/bench/results/gemini-2026-07-27T18-03-44.json +46 -46
  17. package/bench/run-matrix.mjs +26 -26
  18. package/bench/run.mjs +106 -106
  19. package/canon/AGENTS.md +30 -30
  20. package/canon/context/DECISIONS.md +4 -4
  21. package/canon/context/GLOSSARY.md +11 -11
  22. package/canon/context/KNOWLEDGE.md +4 -4
  23. package/canon/context/PROJECT.md +15 -15
  24. package/canon/loop/loop-spec.md +65 -65
  25. package/canon/loop/prd.schema.md +41 -41
  26. package/canon/manifest.yaml +59 -59
  27. package/canon/policy/gates.md +7 -7
  28. package/canon/policy/roles.md +9 -9
  29. package/canon/skills/ATTRIBUTION.md +99 -99
  30. package/canon/skills/authoring-prd/SKILL.md +56 -56
  31. package/canon/skills/brainstorming/SKILL.md +164 -164
  32. package/canon/skills/codebase-design/DEEPENING.md +15 -15
  33. package/canon/skills/codebase-design/DESIGN-IT-TWICE.md +12 -12
  34. package/canon/skills/codebase-design/SKILL.md +39 -39
  35. package/canon/skills/dispatching-parallel-agents/SKILL.md +182 -182
  36. package/canon/skills/document-release/SKILL.md +302 -302
  37. package/canon/skills/domain-modeling/ADR-FORMAT.md +19 -19
  38. package/canon/skills/domain-modeling/CONTEXT-FORMAT.md +39 -39
  39. package/canon/skills/domain-modeling/SKILL.md +35 -35
  40. package/canon/skills/executing-plans/SKILL.md +70 -70
  41. package/canon/skills/finishing-a-development-branch/SKILL.md +200 -200
  42. package/canon/skills/health/SKILL.md +177 -177
  43. package/canon/skills/maintaining-context/SKILL.md +34 -34
  44. package/canon/skills/minimal-code/SKILL.md +21 -21
  45. package/canon/skills/no-ai-slop/SKILL.md +103 -103
  46. package/canon/skills/no-ai-slop/eval.md +43 -43
  47. package/canon/skills/plan-ceo-review/SKILL.md +541 -541
  48. package/canon/skills/plan-eng-review/SKILL.md +362 -362
  49. package/canon/skills/receiving-code-review/SKILL.md +213 -213
  50. package/canon/skills/requesting-code-review/SKILL.md +105 -105
  51. package/canon/skills/resolving-merge-conflicts/SKILL.md +18 -18
  52. package/canon/skills/retro/SKILL.md +397 -397
  53. package/canon/skills/review/SKILL.md +246 -246
  54. package/canon/skills/ship/SKILL.md +691 -691
  55. package/canon/skills/subagent-driven-development/SKILL.md +277 -277
  56. package/canon/skills/systematic-debugging/SKILL.md +296 -296
  57. package/canon/skills/tdd/SKILL.md +371 -371
  58. package/canon/skills/unslop-ui/SKILL.md +34 -34
  59. package/canon/skills/using-git-worktrees/SKILL.md +218 -218
  60. package/canon/skills/verification-before-completion/SKILL.md +139 -139
  61. package/canon/skills/visual-verification/SKILL.md +54 -54
  62. package/canon/skills/workflow/SKILL.md +22 -22
  63. package/canon/skills/writing-for-agents/SKILL-MECHANICS.md +27 -27
  64. package/canon/skills/writing-for-agents/SKILL.md +42 -42
  65. package/canon/skills/writing-plans/SKILL.md +152 -152
  66. package/canon/skills/writing-skills/SKILL.md +655 -655
  67. package/canon/skills/yoke-retrofit/SKILL.md +26 -26
  68. package/canon/skills/yoke-workflow/SKILL.md +20 -20
  69. package/canon/tools/codex-rtk-hook.mjs +35 -35
  70. package/canon/tools/gemini-rtk-hook.mjs +25 -25
  71. package/canon/tools/graphify.md +3 -3
  72. package/canon/tools/playwright-mcp.md +3 -3
  73. package/canon/tools/rtk.md +7 -7
  74. package/canon/tools/serena.md +6 -6
  75. package/dist/agents/contracts.js +1 -1
  76. package/dist/agents/host.js +4 -0
  77. package/dist/agents/providers.js +13 -0
  78. package/dist/agents/telemetry.js +33 -0
  79. package/dist/canon/manifest.js +1 -1
  80. package/dist/cli.js +9 -9
  81. package/dist/dashboard/discovery.js +73 -0
  82. package/dist/dashboard/page.js +122 -122
  83. package/dist/dashboard/panels.js +91 -91
  84. package/dist/goals/command.js +2 -2
  85. package/dist/loop/claims.js +1 -1
  86. package/dist/loop/decision.js +2 -2
  87. package/dist/loop/prd.js +1 -1
  88. package/dist/prd/command.js +17 -17
  89. package/dist/quality/types.js +1 -1
  90. package/dist/retrofit/plan.js +2 -0
  91. package/dist/retrofit/planners/claude.js +14 -14
  92. package/dist/retrofit/planners/qwen.js +73 -0
  93. package/dist/retrofit/preserve.js +2 -2
  94. package/dist/retrofit/skill-actions.js +1 -0
  95. package/dist/review/command.js +1 -1
  96. package/dist/routing/capability.js +1 -1
  97. package/dist/routing/router.js +1 -1
  98. package/dist/setup/command.js +9 -3
  99. package/docs/CAPABILITY-ROUTING.md +51 -51
  100. package/docs/DASHBOARD-EVOLUTION.md +33 -33
  101. package/docs/MIGRATING-TO-1.0.md +33 -33
  102. package/docs/MIGRATING-TO-1.1.md +27 -27
  103. package/docs/MIGRATING-TO-1.4.md +70 -70
  104. package/docs/PRODUCT-DIRECTION-2026-09-05.md +210 -210
  105. package/docs/PUBLISHING.md +114 -114
  106. package/docs/VERIFIED-PROJECTS-VALIDATION.md +29 -29
  107. package/docs/VERIFIED-PROJECTS.md +167 -167
  108. package/docs/community-outreach-2026-08-20.md +85 -0
  109. package/docs/launch-copy-2026-08-21.md +193 -0
  110. package/docs/superpowers/plans/2026-06-28-baustein-e-context-layer.md +981 -981
  111. package/docs/superpowers/plans/2026-06-29-baustein-f-routing.md +258 -258
  112. package/docs/superpowers/plans/2026-06-29-baustein-g-loop-observability.md +1006 -1006
  113. package/docs/superpowers/plans/2026-06-29-baustein-h-loop-robustness.md +374 -374
  114. package/docs/superpowers/plans/2026-06-30-baustein-i-visual-design-verification.md +450 -450
  115. package/docs/superpowers/plans/2026-07-02-baustein-k-zero-to-100-bootstrap.md +1024 -1024
  116. package/docs/superpowers/plans/2026-07-02-baustein-m-flow-smoke-proofs.md +574 -574
  117. package/docs/superpowers/plans/2026-08-13-gauntlet-quality-loop.md +537 -537
  118. package/docs/superpowers/plans/2026-08-16-artifact-backed-output-compaction.md +329 -329
  119. package/docs/superpowers/plans/2026-09-05-verified-projects.md +83 -83
  120. package/docs/superpowers/specs/2026-06-28-baustein-e-context-layer-design.md +146 -146
  121. package/docs/superpowers/specs/2026-06-29-baustein-f-routing-design.md +106 -106
  122. package/docs/superpowers/specs/2026-06-29-baustein-g-loop-observability-design.md +186 -186
  123. package/docs/superpowers/specs/2026-06-29-baustein-h-loop-robustness-design.md +113 -113
  124. package/docs/superpowers/specs/2026-06-30-baustein-i-visual-design-verification-design.md +98 -98
  125. package/docs/superpowers/specs/2026-07-02-baustein-k-zero-to-100-bootstrap-design.md +200 -200
  126. package/docs/superpowers/specs/2026-07-02-baustein-m-flow-smoke-proofs-design.md +155 -155
  127. package/docs/superpowers/specs/2026-08-13-gauntlet-quality-loop-design.md +422 -422
  128. package/docs/superpowers/specs/2026-08-16-artifact-backed-output-compaction-design.md +166 -166
  129. package/gemini-extension.json +6 -6
  130. package/hooks/hooks.json +19 -19
  131. package/package.json +87 -87
@@ -1,83 +1,83 @@
1
- # Verified projects implementation plan
2
-
3
- > **For agentic workers:** Use superpowers:subagent-driven-development for bounded implementation and independent spec and quality reviews. User authorized implementation on 2026-09-05; no additional planning approval is required.
4
-
5
- **Goal:** Deliver reliable cross-provider acceptance and continuation, measured execution with useful time estimates, efficient routing, and a local dashboard over a shared project state.
6
-
7
- **Architecture:** Preserve existing CLI behavior unless a safety defect requires correction. Add small services for checks, goals, events, estimates, project registration and dashboard presentation. Provider capabilities stay in adapters; dashboard calls the same services as the CLI. Unknown measurements remain unknown.
8
-
9
- **Tech Stack:** Existing TypeScript, Node built-ins, Zod, YAML and Vitest. Local HTTP dashboard with no runtime UI dependency. Existing CLI processes remain the coding executors.
10
-
11
- ## Scope and acceptance
12
-
13
- The user approved the saved product direction. Implementation includes the concrete developer-tool capabilities; market validation with ten external users, commercial pricing, cloud hosting, promises of model equivalence and guaranteed time/cost savings are not software deliverables. Provider-native features must use verified supported interfaces; no invented goal protocol or provider prices.
14
-
15
- ## Task 1: Provider contracts and hooks
16
-
17
- Files: src/agents/providers.ts, contracts/types/telemetry as necessary, src/retrofit/planners/gemini.ts, canon/tools/gemini-rtk-hook.mjs, focused provider/retrofit tests.
18
-
19
- - [x] Write failing tests for Gemini streaming and model telemetry, unsupported selection handling, and BeforeTool command rewriting.
20
- - [x] Run the focused tests and inspect the expected failures.
21
- - [x] Add capability-aware invocation, reliable Gemini stream output and hook wiring. Retain safe/read-only profiles, validate native structured-output options where supported.
22
- - [x] Run provider, process and retrofit tests plus TypeScript checks.
23
- - [x] Independent spec review, then quality review; address findings.
24
-
25
- ## Task 2: Durable recovery and acceptance
26
-
27
- Files: src/loop/loop.ts, src/loop/runner.ts, new src/check/ and src/goals/ modules, src/cli.ts, focused tests.
28
-
29
- - [x] Reproduce lost failed worktrees and untracked reviewer mutations before changing production code.
30
- - [x] Retain failed isolated work; allow intentional resume with branch/PRD identity validation. Fingerprint file content and fail closed on read failures.
31
- - [x] Add yoke check that runs configured or detected verification without retrofit, reports passed/failed/unverified criteria and binds evidence to checked content.
32
- - [x] Add protected-file verification and bounded repair/continuation with explicit provider selection; never silently accept changed acceptance infrastructure.
33
- - [x] Add durable goals and handoff state, exposing native-agent-readable instructions instead of assuming unsupported APIs.
34
- - [x] Test dirty trees, failed commands, stale evidence, missing configuration, changed protected files and recovery.
35
-
36
- ## Task 3: Measurement and estimates
37
-
38
- Files: new src/observability/events.ts, src/estimation/, src/loop/reporter.ts, focused tests.
39
-
40
- - [x] Test event validation, partial history, failed attempts, phase accounting and low-sample estimates.
41
- - [x] Persist bounded versioned local events and preserve explicit measurement availability.
42
- - [x] Combine historical and current durations robustly; expose empirical bounds and sample count.
43
- - [x] Estimate dependency-constrained schedules and active work without naive division by concurrency.
44
- - [x] Connect serial/parallel status to a common read model and expose estimate accuracy records.
45
-
46
- ## Task 4: Efficient execution
47
-
48
- Files: src/routing/, src/context/, src/loop/scheduler.ts, configuration/schema and focused tests.
49
-
50
- - [x] Test explicit deterministic routes, safe fallback and gate-driven escalation.
51
- - [x] Add explicit rule-based routing to bypass unnecessary controller calls; support bounded configured tool actions and worker escalation.
52
- - [x] Select relevant context within a stable prefix and content budget with source references.
53
- - [x] Respect task write scopes, dependency priority and configured concurrency constraints.
54
- - [x] Keep mandatory final checks; reuse only evidence with matching inputs and surface cache/usage gaps.
55
-
56
- ## Task 5: Project dashboard and shared commands
57
-
58
- Files: new src/projects/, src/dashboard/, src/cli.ts, tests/projects/, tests/dashboard/.
59
-
60
- - [x] Test project registration, corrupt/missing projects, task views and HTTP boundaries.
61
- - [x] Add local project register/list/remove and shared state snapshots for goals, criteria, workers, events, estimates and consumption.
62
- - [x] Serve a responsive dashboard on loopback only with escaped text, restrictive CSP, validated Host/Origin and opaque project IDs. Never expose arbitrary file paths as HTTP reads.
63
- - [x] Provide overview, project and task details, blockers, evidence and time/cost uncertainty. Mutating controls reuse existing command boundaries and require local-session protection.
64
- - [x] Verify actual HTTP responses and browser rendering, empty/error states and navigation.
65
-
66
- ## Task 6: Integration and documentation
67
-
68
- - [x] Reconcile README claims with activation and evidence requirements; document migration and all new commands.
69
- - [x] Update release metadata through the repository script.
70
- - [x] Run lint, build, full tests, canon validation, docs checks and package dry run.
71
- - [x] Perform independent spec and code-quality review and fix material findings.
72
- - [x] Preserve original working-tree changes; provide concrete commands and remaining external verification limits.
73
-
74
- ## Verification commands
75
-
76
- All shell calls use RTK per user instruction. Focused checks use `rtk proxy npx vitest run <test files>`. Final checks use npm scripts from package.json and `rtk proxy npx tsx src/cli.ts validate canon`. Behavioral tests must fail for the intended missing behavior before implementation. Do not call live models across user repositories for a synthetic dashboard demo.
77
-
78
- ## Execution record
79
-
80
- - Baseline was audited earlier in this session: 1018 passed, 2 skipped, one 5-second integration-test timeout; isolated rerun passed. TypeScript and docs check passed. Work continues under the user's explicit instruction to implement and fix the recorded issues.
81
- - Worktree: .worktrees/yoke-next, branch feature/verified-projects. Existing dependencies reused via junction; original user changes remain outside this worktree.
82
- - Final verification: 122 files passed, 1098 tests passed and 2 platform skips. Build, typecheck, canon, docs metadata and package contents passed. Independent reviews and desktop/mobile browser inspection completed within the limits recorded in docs/VERIFIED-PROJECTS-VALIDATION.md.
83
- - Scope clarification: mandatory final checks always rerun; no selective-result cache was added. Dashboard mutations are limited to shared-service pause; run/resume/budget stay CLI actions. Native provider goal integration is a supported handoff, not an invented API. Empirical prediction errors are recorded; live model/competition benchmarks and calibrated deadlines remain external validation.
1
+ # Verified projects implementation plan
2
+
3
+ > **For agentic workers:** Use superpowers:subagent-driven-development for bounded implementation and independent spec and quality reviews. User authorized implementation on 2026-09-05; no additional planning approval is required.
4
+
5
+ **Goal:** Deliver reliable cross-provider acceptance and continuation, measured execution with useful time estimates, efficient routing, and a local dashboard over a shared project state.
6
+
7
+ **Architecture:** Preserve existing CLI behavior unless a safety defect requires correction. Add small services for checks, goals, events, estimates, project registration and dashboard presentation. Provider capabilities stay in adapters; dashboard calls the same services as the CLI. Unknown measurements remain unknown.
8
+
9
+ **Tech Stack:** Existing TypeScript, Node built-ins, Zod, YAML and Vitest. Local HTTP dashboard with no runtime UI dependency. Existing CLI processes remain the coding executors.
10
+
11
+ ## Scope and acceptance
12
+
13
+ The user approved the saved product direction. Implementation includes the concrete developer-tool capabilities; market validation with ten external users, commercial pricing, cloud hosting, promises of model equivalence and guaranteed time/cost savings are not software deliverables. Provider-native features must use verified supported interfaces; no invented goal protocol or provider prices.
14
+
15
+ ## Task 1: Provider contracts and hooks
16
+
17
+ Files: src/agents/providers.ts, contracts/types/telemetry as necessary, src/retrofit/planners/gemini.ts, canon/tools/gemini-rtk-hook.mjs, focused provider/retrofit tests.
18
+
19
+ - [x] Write failing tests for Gemini streaming and model telemetry, unsupported selection handling, and BeforeTool command rewriting.
20
+ - [x] Run the focused tests and inspect the expected failures.
21
+ - [x] Add capability-aware invocation, reliable Gemini stream output and hook wiring. Retain safe/read-only profiles, validate native structured-output options where supported.
22
+ - [x] Run provider, process and retrofit tests plus TypeScript checks.
23
+ - [x] Independent spec review, then quality review; address findings.
24
+
25
+ ## Task 2: Durable recovery and acceptance
26
+
27
+ Files: src/loop/loop.ts, src/loop/runner.ts, new src/check/ and src/goals/ modules, src/cli.ts, focused tests.
28
+
29
+ - [x] Reproduce lost failed worktrees and untracked reviewer mutations before changing production code.
30
+ - [x] Retain failed isolated work; allow intentional resume with branch/PRD identity validation. Fingerprint file content and fail closed on read failures.
31
+ - [x] Add yoke check that runs configured or detected verification without retrofit, reports passed/failed/unverified criteria and binds evidence to checked content.
32
+ - [x] Add protected-file verification and bounded repair/continuation with explicit provider selection; never silently accept changed acceptance infrastructure.
33
+ - [x] Add durable goals and handoff state, exposing native-agent-readable instructions instead of assuming unsupported APIs.
34
+ - [x] Test dirty trees, failed commands, stale evidence, missing configuration, changed protected files and recovery.
35
+
36
+ ## Task 3: Measurement and estimates
37
+
38
+ Files: new src/observability/events.ts, src/estimation/, src/loop/reporter.ts, focused tests.
39
+
40
+ - [x] Test event validation, partial history, failed attempts, phase accounting and low-sample estimates.
41
+ - [x] Persist bounded versioned local events and preserve explicit measurement availability.
42
+ - [x] Combine historical and current durations robustly; expose empirical bounds and sample count.
43
+ - [x] Estimate dependency-constrained schedules and active work without naive division by concurrency.
44
+ - [x] Connect serial/parallel status to a common read model and expose estimate accuracy records.
45
+
46
+ ## Task 4: Efficient execution
47
+
48
+ Files: src/routing/, src/context/, src/loop/scheduler.ts, configuration/schema and focused tests.
49
+
50
+ - [x] Test explicit deterministic routes, safe fallback and gate-driven escalation.
51
+ - [x] Add explicit rule-based routing to bypass unnecessary controller calls; support bounded configured tool actions and worker escalation.
52
+ - [x] Select relevant context within a stable prefix and content budget with source references.
53
+ - [x] Respect task write scopes, dependency priority and configured concurrency constraints.
54
+ - [x] Keep mandatory final checks; reuse only evidence with matching inputs and surface cache/usage gaps.
55
+
56
+ ## Task 5: Project dashboard and shared commands
57
+
58
+ Files: new src/projects/, src/dashboard/, src/cli.ts, tests/projects/, tests/dashboard/.
59
+
60
+ - [x] Test project registration, corrupt/missing projects, task views and HTTP boundaries.
61
+ - [x] Add local project register/list/remove and shared state snapshots for goals, criteria, workers, events, estimates and consumption.
62
+ - [x] Serve a responsive dashboard on loopback only with escaped text, restrictive CSP, validated Host/Origin and opaque project IDs. Never expose arbitrary file paths as HTTP reads.
63
+ - [x] Provide overview, project and task details, blockers, evidence and time/cost uncertainty. Mutating controls reuse existing command boundaries and require local-session protection.
64
+ - [x] Verify actual HTTP responses and browser rendering, empty/error states and navigation.
65
+
66
+ ## Task 6: Integration and documentation
67
+
68
+ - [x] Reconcile README claims with activation and evidence requirements; document migration and all new commands.
69
+ - [x] Update release metadata through the repository script.
70
+ - [x] Run lint, build, full tests, canon validation, docs checks and package dry run.
71
+ - [x] Perform independent spec and code-quality review and fix material findings.
72
+ - [x] Preserve original working-tree changes; provide concrete commands and remaining external verification limits.
73
+
74
+ ## Verification commands
75
+
76
+ All shell calls use RTK per user instruction. Focused checks use `rtk proxy npx vitest run <test files>`. Final checks use npm scripts from package.json and `rtk proxy npx tsx src/cli.ts validate canon`. Behavioral tests must fail for the intended missing behavior before implementation. Do not call live models across user repositories for a synthetic dashboard demo.
77
+
78
+ ## Execution record
79
+
80
+ - Baseline was audited earlier in this session: 1018 passed, 2 skipped, one 5-second integration-test timeout; isolated rerun passed. TypeScript and docs check passed. Work continues under the user's explicit instruction to implement and fix the recorded issues.
81
+ - Worktree: .worktrees/yoke-next, branch feature/verified-projects. Existing dependencies reused via junction; original user changes remain outside this worktree.
82
+ - Final verification: 122 files passed, 1098 tests passed and 2 platform skips. Build, typecheck, canon, docs metadata and package contents passed. Independent reviews and desktop/mobile browser inspection completed within the limits recorded in docs/VERIFIED-PROJECTS-VALIDATION.md.
83
+ - Scope clarification: mandatory final checks always rerun; no selective-result cache was added. Dashboard mutations are limited to shared-service pause; run/resume/budget stay CLI actions. Native provider goal integration is a supported handoff, not an invented API. Empirical prediction errors are recorded; live model/competition benchmarks and calibrated deadlines remain external validation.
@@ -1,146 +1,146 @@
1
- # Baustein E — Context Layer (durable cross-session context)
2
-
3
- **Status:** Design approved 2026-06-28
4
- **Component:** Yoke (🐂)
5
- **Relates to:** [[harness-project-goal]], [[harness-stack-decisions]], [[harness-loop-technique]]
6
-
7
- ## Problem & Goal
8
-
9
- The dev.to article ("A Claude Code Skills Stack") frames a three-layer division of labor:
10
- **gstack decides → GSD stabilizes context → Superpowers executes.** Yoke today has the
11
- Decision layer (ported gstack roles) and a strong Execution layer (superpowers methodology +
12
- the Ralph loop), but it never built the **Context layer** — GSD's actual contribution:
13
- durable, cross-session artifacts that prevent specification drift.
14
-
15
- Concretely, the loop's [`buildClaudePrompt`](../../../src/loop/runner.ts) injects **only the
16
- current story + its acceptance criteria**. Every fresh-context iteration starts blind to the
17
- project's overall goal, the decisions already made, and the gotchas already learned. Over many
18
- iterations this is exactly where drift leaks in. The user's own auto-memory does this job by
19
- hand; the harness should give its users the same thing.
20
-
21
- **Goal:** a durable Context layer — three markdown files under `.yoke/context/` that the loop
22
- **reads before each iteration** and **writes decisions back to**, plus a skill so interactive
23
- (non-loop) sessions honor the same files. This closes the spec-drift hole and completes the
24
- third leg of the article's model.
25
-
26
- ## Key Decisions (locked)
27
-
28
- | Decision | Choice |
29
- |---|---|
30
- | Scope | Loop **and** interactive sessions (retrofit scaffolds for all 3 agents) |
31
- | Write-back | **Hybrid**: loop deterministically auto-logs decisions; agents enrich `DECISIONS`/`KNOWLEDGE` via the skill |
32
- | Files location | `.yoke/context/` (agent-agnostic shared state, like `.yoke/prd.yaml`) |
33
- | Config | None new — injection auto-on when files present; prompt bound is a constant |
34
- | Backwards-compat | No `.yoke/context/` → loop prompt is byte-identical to today |
35
- | Out of scope | Routing/priority fix (separate Baustein F), structured decision schema, cross-file linking |
36
-
37
- ## The three files — `.yoke/context/`
38
-
39
- | File | Role | Writer |
40
- |------|------|--------|
41
- | `PROJECT.md` | North star: goal, constraints, **non-goals**, success criteria | Human/brainstorm authored; retrofit scaffolds a template. Read-only input. |
42
- | `DECISIONS.md` | Append-only ADR ledger | Loop auto-appends per completed+verified story; agents append in interactive work. |
43
- | `KNOWLEDGE.md` | Gotchas, conventions, reusable learnings | Agent/human maintained via the skill. |
44
-
45
- The files are plain markdown — no schema, no required structure beyond `DECISIONS.md`'s
46
- append format (so the loop can append unambiguously). Missing or partial files are valid:
47
- the layer degrades gracefully (an absent file contributes nothing to the prompt).
48
-
49
- ## Architecture
50
-
51
- ### New module — `src/context/context.ts`
52
- Pure and unit-testable, structured like `src/loop/prd.ts`:
53
-
54
- - `loadContext(dir): ProjectContext` — read the three files if present; missing → empty strings. Never throws on absence.
55
- - `formatForPrompt(ctx, maxChars): string` — render a "Project context" block, **tail-bounding** each file to `maxChars` (constant, ~2 KB) so a large ledger can't blow up the prompt. Returns `''` when all three are empty.
56
- - `appendDecision(dir, entry): { rollback: () => void }` — append a `DECISIONS.md` entry and return a rollback that restores the prior file content (captured before the write). Creates the file if absent.
57
-
58
- `ProjectContext = { project: string; decisions: string; knowledge: string }`.
59
-
60
- A decision entry is formatted as:
61
- ```
62
- ## <YYYY-MM-DD> — <story-id>: <title>
63
- <one-line summary>
64
- ```
65
- The date comes from the Node runtime at loop time (the loop is normal Node, not a Workflow
66
- script — `Date` is available).
67
-
68
- ### Loop read — `src/loop/runner.ts`
69
- `buildClaudePrompt(story, context?)` and `buildReviewPrompt(story, context?)` gain an optional
70
- pre-formatted `context` string. When present, a "Project context" section is inserted **ahead
71
- of** the story block. The reviewer gets the north star too (so it reviews against goals, not
72
- just acceptance criteria). When `context` is undefined/empty, the prompts are unchanged.
73
-
74
- The loop loads + formats context once per iteration (`.yoke/context/` resolved relative to
75
- `targetDir`) and threads it through the runner/review call.
76
-
77
- ### Loop write-back — `src/loop/loop.ts`
78
- After verify (and optional review) passes, **before the commit**:
79
-
80
- 1. `appendDecision(contextDir, { storyId, title, summary })` → keep the returned `rollback`.
81
- 2. `savePrd(passes:true)`.
82
- 3. `commitAll(...)` — now also stages `DECISIONS.md`, so the decision and the `passes:true`
83
- flip land in the **same atomic commit**.
84
-
85
- If the commit throws, revert **both**: `savePrd(prior stories)` *and* `rollback()` for the
86
- decision file. This preserves the existing invariant — *`passes:true` never persists without a
87
- commit* — and extends it to the decision ledger (no orphan decision without a commit).
88
-
89
- In `--isolate` mode the append happens inside the worktree before the worktree commit, so
90
- `integrate` fast-forwards the decision back into the main tree along with the code.
91
-
92
- ### Retrofit scaffolding — `src/retrofit/`
93
- A retrofit action writes `.yoke/context/{PROJECT,DECISIONS,KNOWLEDGE}.md` from
94
- `canon/context/*.md` templates **only if absent** (non-destructive + idempotent, the same rule
95
- as every other artifact). Agent-agnostic — one set under `.yoke/` serves claude/codex/gemini,
96
- so it is emitted once regardless of `--agent`. The report lists the scaffolded files.
97
-
98
- ### Skill — `canon/skills/maintaining-context/SKILL.md`
99
- Agent-facing, flows to all three agents via the existing planners + `manifest.yaml`:
100
- > Before substantial work, read `.yoke/context/PROJECT.md` for the north star and
101
- > `KNOWLEDGE.md` for known gotchas. When you make a non-obvious decision, append it to
102
- > `DECISIONS.md`. When you learn a reusable fact or gotcha, append it to `KNOWLEDGE.md`.
103
-
104
- This is what extends drift-protection from the loop to interactive sessions.
105
-
106
- ### CLI — `src/cli.ts`
107
- - `yoke context init` — scaffold the three files standalone (idempotent, non-destructive).
108
- - `yoke context status` — show presence, byte sizes, and the last decision heading.
109
-
110
- ## Data flow (loop iteration)
111
-
112
- ```
113
- load PRD ─► pick story ─► load+format .yoke/context ─► runner(prompt + context)
114
- ─► verify ─► [review] ─► appendDecision() ─► savePrd(passes:true) ─► commitAll(+DECISIONS.md)
115
- └── on commit failure: rollback() + savePrd(prior) ──► blocked
116
- ```
117
-
118
- ## Error handling
119
-
120
- - Missing/partial context files: treated as empty; no error, prompt simply omits that part.
121
- - Oversized files: tail-bounded to a constant per file; never unbounded.
122
- - `appendDecision` before commit + rollback on commit failure: no orphan decisions.
123
- - Isolate mode: decision written in the worktree, carried back only on successful integrate.
124
- - `yoke context init` over existing files: skips them (reports "exists"), never overwrites.
125
-
126
- ## Testing (subagent-driven TDD, like A–D)
127
-
128
- **context.ts units:** load with all/none/partial files present; `formatForPrompt` bounding +
129
- empty-returns-`''`; `appendDecision` format correctness + rollback restores prior content +
130
- creates file when absent.
131
-
132
- **loop:** prompt includes the context block when `.yoke/context/` present; prompt unchanged
133
- when absent; decision appended on success; **not** appended on a blocked story; both PRD and
134
- decision reverted on commit failure; isolate path carries the decision back via integrate.
135
-
136
- **retrofit:** scaffolds the three files; idempotent on re-run; non-destructive over existing
137
- files; emitted once for `--agent=all`.
138
-
139
- **canon:** `maintaining-context` present in `manifest.yaml`; `yoke validate canon` stays green.
140
-
141
- ## Non-goals (YAGNI)
142
-
143
- - No new config keys (injection is automatic; bound is a constant).
144
- - No structured/parsed decision schema — markdown append only.
145
- - No cross-file linking or decision superseding.
146
- - Routing/priority arbitration is **Baustein F**, not this spec.
1
+ # Baustein E — Context Layer (durable cross-session context)
2
+
3
+ **Status:** Design approved 2026-06-28
4
+ **Component:** Yoke (🐂)
5
+ **Relates to:** [[harness-project-goal]], [[harness-stack-decisions]], [[harness-loop-technique]]
6
+
7
+ ## Problem & Goal
8
+
9
+ The dev.to article ("A Claude Code Skills Stack") frames a three-layer division of labor:
10
+ **gstack decides → GSD stabilizes context → Superpowers executes.** Yoke today has the
11
+ Decision layer (ported gstack roles) and a strong Execution layer (superpowers methodology +
12
+ the Ralph loop), but it never built the **Context layer** — GSD's actual contribution:
13
+ durable, cross-session artifacts that prevent specification drift.
14
+
15
+ Concretely, the loop's [`buildClaudePrompt`](../../../src/loop/runner.ts) injects **only the
16
+ current story + its acceptance criteria**. Every fresh-context iteration starts blind to the
17
+ project's overall goal, the decisions already made, and the gotchas already learned. Over many
18
+ iterations this is exactly where drift leaks in. The user's own auto-memory does this job by
19
+ hand; the harness should give its users the same thing.
20
+
21
+ **Goal:** a durable Context layer — three markdown files under `.yoke/context/` that the loop
22
+ **reads before each iteration** and **writes decisions back to**, plus a skill so interactive
23
+ (non-loop) sessions honor the same files. This closes the spec-drift hole and completes the
24
+ third leg of the article's model.
25
+
26
+ ## Key Decisions (locked)
27
+
28
+ | Decision | Choice |
29
+ |---|---|
30
+ | Scope | Loop **and** interactive sessions (retrofit scaffolds for all 3 agents) |
31
+ | Write-back | **Hybrid**: loop deterministically auto-logs decisions; agents enrich `DECISIONS`/`KNOWLEDGE` via the skill |
32
+ | Files location | `.yoke/context/` (agent-agnostic shared state, like `.yoke/prd.yaml`) |
33
+ | Config | None new — injection auto-on when files present; prompt bound is a constant |
34
+ | Backwards-compat | No `.yoke/context/` → loop prompt is byte-identical to today |
35
+ | Out of scope | Routing/priority fix (separate Baustein F), structured decision schema, cross-file linking |
36
+
37
+ ## The three files — `.yoke/context/`
38
+
39
+ | File | Role | Writer |
40
+ |------|------|--------|
41
+ | `PROJECT.md` | North star: goal, constraints, **non-goals**, success criteria | Human/brainstorm authored; retrofit scaffolds a template. Read-only input. |
42
+ | `DECISIONS.md` | Append-only ADR ledger | Loop auto-appends per completed+verified story; agents append in interactive work. |
43
+ | `KNOWLEDGE.md` | Gotchas, conventions, reusable learnings | Agent/human maintained via the skill. |
44
+
45
+ The files are plain markdown — no schema, no required structure beyond `DECISIONS.md`'s
46
+ append format (so the loop can append unambiguously). Missing or partial files are valid:
47
+ the layer degrades gracefully (an absent file contributes nothing to the prompt).
48
+
49
+ ## Architecture
50
+
51
+ ### New module — `src/context/context.ts`
52
+ Pure and unit-testable, structured like `src/loop/prd.ts`:
53
+
54
+ - `loadContext(dir): ProjectContext` — read the three files if present; missing → empty strings. Never throws on absence.
55
+ - `formatForPrompt(ctx, maxChars): string` — render a "Project context" block, **tail-bounding** each file to `maxChars` (constant, ~2 KB) so a large ledger can't blow up the prompt. Returns `''` when all three are empty.
56
+ - `appendDecision(dir, entry): { rollback: () => void }` — append a `DECISIONS.md` entry and return a rollback that restores the prior file content (captured before the write). Creates the file if absent.
57
+
58
+ `ProjectContext = { project: string; decisions: string; knowledge: string }`.
59
+
60
+ A decision entry is formatted as:
61
+ ```
62
+ ## <YYYY-MM-DD> — <story-id>: <title>
63
+ <one-line summary>
64
+ ```
65
+ The date comes from the Node runtime at loop time (the loop is normal Node, not a Workflow
66
+ script — `Date` is available).
67
+
68
+ ### Loop read — `src/loop/runner.ts`
69
+ `buildClaudePrompt(story, context?)` and `buildReviewPrompt(story, context?)` gain an optional
70
+ pre-formatted `context` string. When present, a "Project context" section is inserted **ahead
71
+ of** the story block. The reviewer gets the north star too (so it reviews against goals, not
72
+ just acceptance criteria). When `context` is undefined/empty, the prompts are unchanged.
73
+
74
+ The loop loads + formats context once per iteration (`.yoke/context/` resolved relative to
75
+ `targetDir`) and threads it through the runner/review call.
76
+
77
+ ### Loop write-back — `src/loop/loop.ts`
78
+ After verify (and optional review) passes, **before the commit**:
79
+
80
+ 1. `appendDecision(contextDir, { storyId, title, summary })` → keep the returned `rollback`.
81
+ 2. `savePrd(passes:true)`.
82
+ 3. `commitAll(...)` — now also stages `DECISIONS.md`, so the decision and the `passes:true`
83
+ flip land in the **same atomic commit**.
84
+
85
+ If the commit throws, revert **both**: `savePrd(prior stories)` *and* `rollback()` for the
86
+ decision file. This preserves the existing invariant — *`passes:true` never persists without a
87
+ commit* — and extends it to the decision ledger (no orphan decision without a commit).
88
+
89
+ In `--isolate` mode the append happens inside the worktree before the worktree commit, so
90
+ `integrate` fast-forwards the decision back into the main tree along with the code.
91
+
92
+ ### Retrofit scaffolding — `src/retrofit/`
93
+ A retrofit action writes `.yoke/context/{PROJECT,DECISIONS,KNOWLEDGE}.md` from
94
+ `canon/context/*.md` templates **only if absent** (non-destructive + idempotent, the same rule
95
+ as every other artifact). Agent-agnostic — one set under `.yoke/` serves claude/codex/gemini,
96
+ so it is emitted once regardless of `--agent`. The report lists the scaffolded files.
97
+
98
+ ### Skill — `canon/skills/maintaining-context/SKILL.md`
99
+ Agent-facing, flows to all three agents via the existing planners + `manifest.yaml`:
100
+ > Before substantial work, read `.yoke/context/PROJECT.md` for the north star and
101
+ > `KNOWLEDGE.md` for known gotchas. When you make a non-obvious decision, append it to
102
+ > `DECISIONS.md`. When you learn a reusable fact or gotcha, append it to `KNOWLEDGE.md`.
103
+
104
+ This is what extends drift-protection from the loop to interactive sessions.
105
+
106
+ ### CLI — `src/cli.ts`
107
+ - `yoke context init` — scaffold the three files standalone (idempotent, non-destructive).
108
+ - `yoke context status` — show presence, byte sizes, and the last decision heading.
109
+
110
+ ## Data flow (loop iteration)
111
+
112
+ ```
113
+ load PRD ─► pick story ─► load+format .yoke/context ─► runner(prompt + context)
114
+ ─► verify ─► [review] ─► appendDecision() ─► savePrd(passes:true) ─► commitAll(+DECISIONS.md)
115
+ └── on commit failure: rollback() + savePrd(prior) ──► blocked
116
+ ```
117
+
118
+ ## Error handling
119
+
120
+ - Missing/partial context files: treated as empty; no error, prompt simply omits that part.
121
+ - Oversized files: tail-bounded to a constant per file; never unbounded.
122
+ - `appendDecision` before commit + rollback on commit failure: no orphan decisions.
123
+ - Isolate mode: decision written in the worktree, carried back only on successful integrate.
124
+ - `yoke context init` over existing files: skips them (reports "exists"), never overwrites.
125
+
126
+ ## Testing (subagent-driven TDD, like A–D)
127
+
128
+ **context.ts units:** load with all/none/partial files present; `formatForPrompt` bounding +
129
+ empty-returns-`''`; `appendDecision` format correctness + rollback restores prior content +
130
+ creates file when absent.
131
+
132
+ **loop:** prompt includes the context block when `.yoke/context/` present; prompt unchanged
133
+ when absent; decision appended on success; **not** appended on a blocked story; both PRD and
134
+ decision reverted on commit failure; isolate path carries the decision back via integrate.
135
+
136
+ **retrofit:** scaffolds the three files; idempotent on re-run; non-destructive over existing
137
+ files; emitted once for `--agent=all`.
138
+
139
+ **canon:** `maintaining-context` present in `manifest.yaml`; `yoke validate canon` stays green.
140
+
141
+ ## Non-goals (YAGNI)
142
+
143
+ - No new config keys (injection is automatic; bound is a constant).
144
+ - No structured/parsed decision schema — markdown append only.
145
+ - No cross-file linking or decision superseding.
146
+ - Routing/priority arbitration is **Baustein F**, not this spec.