@sabaiway/agent-workflow-kit 23.12.0 → 24.0.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 (150) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +4 -4
  3. package/SKILL.md +1 -1
  4. package/bridges/codex-cli-bridge/SKILL.md +7 -2
  5. package/bridges/codex-cli-bridge/bin/codex-exec-jev.test.mjs +11 -6
  6. package/bridges/codex-cli-bridge/bin/codex-exec.sh +72 -33
  7. package/bridges/codex-cli-bridge/bin/codex-exec.test.mjs +111 -3
  8. package/bridges/codex-cli-bridge/bin/codex-fixtures-harness.test.mjs +16 -1
  9. package/bridges/codex-cli-bridge/bin/codex-model-posture.test.mjs +5 -3
  10. package/bridges/codex-cli-bridge/bin/codex-review.sh +1 -1
  11. package/bridges/codex-cli-bridge/capability.json +2 -2
  12. package/capability.json +1 -1
  13. package/package.json +1 -1
  14. package/references/advisor-writers.md +2 -0
  15. package/references/agents/author.md +21 -0
  16. package/references/agents/executor.md +12 -6
  17. package/references/contracts.md +4 -4
  18. package/references/hooks/gate-approve.mjs +7 -8
  19. package/references/hooks/stage-write-guard.mjs +314 -0
  20. package/references/modes/agents.md +6 -4
  21. package/references/modes/bootstrap.md +1 -1
  22. package/references/modes/flow-writer.md +10 -2
  23. package/references/modes/hook.md +4 -1
  24. package/references/modes/now.md +1 -1
  25. package/references/modes/procedures.md +49 -10
  26. package/references/modes/recipes.md +7 -7
  27. package/references/modes/recommendations.md +4 -3
  28. package/references/modes/robustness-brief.md +9 -8
  29. package/references/modes/set-recipe.md +1 -1
  30. package/references/modes/state-block-guard.md +4 -3
  31. package/references/modes/status.md +1 -1
  32. package/references/modes/upgrade.md +1 -1
  33. package/references/modes/worktrees.md +28 -5
  34. package/references/rules/story-sessions.md +2 -2
  35. package/references/scripts/archives/archive-caps.mjs +1 -1
  36. package/references/scripts/archives/archive-changelog.mjs +8 -8
  37. package/references/scripts/archives/archive-decisions.mjs +7 -7
  38. package/references/scripts/archives/archive-issues.mjs +5 -5
  39. package/references/scripts/archives/rotation-conservation.mjs +2 -1
  40. package/references/scripts/docs-size/check-docs-size.mjs +15 -15
  41. package/references/scripts/family.json +2 -0
  42. package/references/scripts/gates/kit-command-gates.mjs +7 -8
  43. package/references/scripts/gates/migrate-gates.mjs +10 -10
  44. package/references/scripts/git-hooks/install-git-hooks.mjs +13 -13
  45. package/references/scripts/run.mjs +1 -2
  46. package/references/scripts/shared/index.mjs +2 -0
  47. package/references/scripts/shared/locations.mjs +103 -0
  48. package/references/scripts/spec-schema/spec-schema.mjs +2 -1
  49. package/references/templates/orchestration.json +1 -1
  50. package/tools/ack-store.mjs +2 -1
  51. package/tools/apply-danger-check.mjs +20 -6
  52. package/tools/atomic-write.mjs +3 -2
  53. package/tools/attribution.mjs +2 -1
  54. package/tools/autonomy-config.mjs +2 -1
  55. package/tools/bridge-wiring.mjs +13 -11
  56. package/tools/carriers.mjs +54 -14
  57. package/tools/cheap-agents-read.mjs +28 -7
  58. package/tools/cheap-agents.mjs +15 -10
  59. package/tools/checker-gates-read.mjs +6 -5
  60. package/tools/commands.mjs +2 -2
  61. package/tools/coverage-declared/config.mjs +2 -1
  62. package/tools/coverage-producer.mjs +10 -9
  63. package/tools/delegation.mjs +7 -6
  64. package/tools/detect-backends.mjs +1 -1
  65. package/tools/dispatch-baseline.mjs +2 -1
  66. package/tools/distribution-files/scripts.mjs +4 -4
  67. package/tools/ensure-configs.mjs +2 -2
  68. package/tools/ensure-ops.mjs +24 -24
  69. package/tools/ensure-specs.mjs +7 -7
  70. package/tools/epic-shape-cli.mjs +2 -2
  71. package/tools/epic-shape-ledger.mjs +5 -5
  72. package/tools/epic-shape.mjs +5 -3
  73. package/tools/epic-store.mjs +2 -1
  74. package/tools/family-members.mjs +7 -5
  75. package/tools/family-registry.mjs +36 -30
  76. package/tools/feedback-record-cli.mjs +4 -5
  77. package/tools/flow-writer.mjs +26 -15
  78. package/tools/gate-hook.mjs +33 -28
  79. package/tools/gates-declaration.mjs +2 -1
  80. package/tools/gates-init.mjs +6 -5
  81. package/tools/git-hooks.mjs +64 -41
  82. package/tools/grounding.mjs +3 -2
  83. package/tools/hide-footprint.mjs +2 -1
  84. package/tools/hook-writer/index.mjs +147 -0
  85. package/tools/init-preflight.mjs +5 -4
  86. package/tools/init-project.mjs +12 -11
  87. package/tools/inject-methodology.mjs +3 -2
  88. package/tools/jev-guide.mjs +2 -2
  89. package/tools/known-footprint.mjs +27 -25
  90. package/tools/mcp-registration.mjs +6 -5
  91. package/tools/migration-blocks.mjs +2 -1
  92. package/tools/migration-notes.mjs +2 -2
  93. package/tools/node-evidence.mjs +4 -4
  94. package/tools/now-facts.mjs +5 -5
  95. package/tools/now-status.mjs +1 -5
  96. package/tools/orchestration-config.mjs +2 -1
  97. package/tools/orchestration-readme.mjs +7 -2
  98. package/tools/plan-approval/cli.mjs +45 -0
  99. package/tools/plan-approval/entries.mjs +109 -0
  100. package/tools/plan-approval/index.mjs +2 -0
  101. package/tools/plan-approval/record.mjs +198 -0
  102. package/tools/plan-files.mjs +6 -4
  103. package/tools/plan-shape-cli.mjs +10 -64
  104. package/tools/plan-shape-facts.mjs +240 -83
  105. package/tools/plan-shape.mjs +173 -160
  106. package/tools/plan-structure/cli.mjs +79 -0
  107. package/tools/plan-structure/index.mjs +67 -0
  108. package/tools/procedures.mjs +21 -17
  109. package/tools/profile-gaps.mjs +4 -6
  110. package/tools/project-rules/rules-priors.mjs +2 -0
  111. package/tools/project-rules/themes.mjs +6 -4
  112. package/tools/recipes.mjs +44 -29
  113. package/tools/recommendations.mjs +84 -33
  114. package/tools/reference-profile.mjs +2 -2
  115. package/tools/renderers.mjs +14 -8
  116. package/tools/repo-lex.mjs +84 -0
  117. package/tools/robustness-brief.mjs +14 -11
  118. package/tools/satellite-locator.mjs +3 -2
  119. package/tools/script-priors.mjs +3 -2
  120. package/tools/session-close-check.mjs +71 -15
  121. package/tools/set-flow.mjs +2 -2
  122. package/tools/set-recipe.mjs +17 -9
  123. package/tools/source-size/help.mjs +4 -4
  124. package/tools/source-size/layout.mjs +2 -1
  125. package/tools/source-size/piles.mjs +2 -2
  126. package/tools/source-size-config.mjs +3 -3
  127. package/tools/source-size-refusal.mjs +4 -3
  128. package/tools/source-size-report.mjs +41 -13
  129. package/tools/spec-check-cli.mjs +159 -21
  130. package/tools/spec-check-ops.mjs +74 -5
  131. package/tools/spec-check.mjs +54 -45
  132. package/tools/spec-coverage-cli.mjs +3 -2
  133. package/tools/stage-render/cli.mjs +231 -0
  134. package/tools/stage-render/index.mjs +340 -0
  135. package/tools/stage-render/stages.json +115 -0
  136. package/tools/stage-write-guard/cli.mjs +64 -0
  137. package/tools/stage-write-guard/index.mjs +56 -0
  138. package/tools/state-block-hook.mjs +38 -163
  139. package/tools/task-brief.mjs +8 -13
  140. package/tools/task-thread.mjs +3 -1
  141. package/tools/tier-guide-facts.mjs +23 -9
  142. package/tools/tier-preview.mjs +15 -19
  143. package/tools/transition/index.mjs +10 -9
  144. package/tools/uninstall.mjs +26 -12
  145. package/tools/vehicle-settings.mjs +2 -1
  146. package/tools/velocity-profile.mjs +5 -6
  147. package/tools/view-model.mjs +7 -4
  148. package/tools/worktree-prompt.mjs +7 -3
  149. package/tools/worktrees.mjs +235 -159
  150. package/tools/write-lanes.mjs +20 -14
@@ -1,6 +1,6 @@
1
1
  import { after } from 'node:test';
2
2
  import { spawnSync } from 'node:child_process';
3
- import { existsSync, lstatSync, mkdirSync, mkdtempSync, realpathSync, rmSync } from 'node:fs';
3
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { dirname, isAbsolute, join, relative, sep } from 'node:path';
6
6
  import { fileURLToPath, pathToFileURL } from 'node:url';
@@ -16,6 +16,21 @@ const isInside = (parent, path) => {
16
16
  };
17
17
  const runGit = (args, cwd, env) => spawnSync('git', args, { cwd, env: stripGitEnv(env), encoding: 'utf8' });
18
18
 
19
+ export const writeStubCheck = (dir, { status = 0 } = {}) => {
20
+ const folder = join(dir, 'tools', 'plan-approval');
21
+ mkdirSync(folder, { recursive: true });
22
+ const check = join(folder, 'cli.mjs');
23
+ writeFileSync(check, [
24
+ "import { appendFileSync } from 'node:fs';",
25
+ `appendFileSync(${JSON.stringify(join(dir, 'check-calls.jsonl'))}, JSON.stringify(process.argv.slice(2)) + '\\n');`,
26
+ `process.exit(${JSON.stringify(status)});`,
27
+ '',
28
+ ].join('\n'));
29
+ return check;
30
+ };
31
+
32
+ export const composeApprovalBlock = ({ plan, approval, check }) => ['```aw-plan-approval', JSON.stringify({ plan, approval, check }), '```', ''].join('\n');
33
+
19
34
  export const makeFixtureRepo = (run, dir, initArgs = []) => {
20
35
  run(['init', ...initArgs, dir]);
21
36
  run(['-C', dir, 'config', 'maintenance.auto', 'false']);
@@ -4,7 +4,7 @@ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, cpSync
4
4
  import { join, dirname, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { spawnSync } from 'node:child_process';
7
- import { makeFixtureRepo, openSuiteScopes } from './codex-fixtures-harness.test.mjs';
7
+ import { composeApprovalBlock, makeFixtureRepo, openSuiteScopes, writeStubCheck } from './codex-fixtures-harness.test.mjs';
8
8
 
9
9
  const HERE = dirname(fileURLToPath(import.meta.url));
10
10
  const EXEC = join(HERE, 'codex-exec.sh');
@@ -212,6 +212,8 @@ describe('a one-off is refused pre-spend unless it is a probe — spec:bridge-mo
212
212
  });
213
213
 
214
214
  const CONTRACT = '# dispatch\n\n```aw-dispatch-contract\n{"nonce":"n1","scope":"probe"}\n```\n';
215
+ const writeApprovedTask = (sb) => writeFileSync(join(sb.repo, 'task.md'), CONTRACT
216
+ + composeApprovalBlock({ plan: 'docs/plans/approved-plan.md', approval: 'c'.repeat(64), check: writeStubCheck(sb.home) }));
215
217
  describe('a nonced probe one-off is refused; a probe review keeps its nonce — spec:bridge-model/S6', () => {
216
218
  const nonced = [
217
219
  ['AW_DISPATCH_NONCE', ['task.md'], { AW_DISPATCH_NONCE: 'n1' }],
@@ -221,7 +223,7 @@ describe('a nonced probe one-off is refused; a probe review keeps its nonce —
221
223
  for (const [label, args, env] of nonced) {
222
224
  it(`${label}: a probe one-off is refused before any reservation`, () => {
223
225
  const sb = sandbox({ settings: HOST_SETTING });
224
- writeFileSync(join(sb.repo, 'task.md'), CONTRACT);
226
+ writeApprovedTask(sb);
225
227
  const r = drive(sb, [EXEC, args], { ...env, CODEX_PROBE: '1', CODEX_MODEL: MANIFEST.posture.model });
226
228
  assertRefusedUnspent(r);
227
229
  assert.match(r.stderr, /cannot carry a dispatch nonce/);
@@ -230,7 +232,7 @@ describe('a nonced probe one-off is refused; a probe review keeps its nonce —
230
232
  }
231
233
  it('a nonced probe on the host posture runs and mints its receipt', () => {
232
234
  const sb = sandbox({ settings: HOST_SETTING });
233
- writeFileSync(join(sb.repo, 'task.md'), CONTRACT);
235
+ writeApprovedTask(sb);
234
236
  const r = drive(sb, [EXEC, ['--nonce', 'n1', 'task.md']], { CODEX_PROBE: '1' });
235
237
  assertRan(r, 'gpt-6-luna', 'medium');
236
238
  const receipt = JSON.parse(readFileSync(join(sb.repo, '.git', 'agent-workflow-exec-receipt-5-codex-n1.json'), 'utf8'));
@@ -416,7 +416,7 @@ aw_scrub_billing_keys() {
416
416
  # Review-receipt identity (AD-038). AW_BRIDGE_VERSION mirrors this bridge's SKILL.md/capability.json
417
417
  # version (drift-guarded by codex-review.test.mjs against capability.json).
418
418
  AW_RECEIPT_BACKEND="codex"
419
- AW_BRIDGE_VERSION="6.1.0" # aw-version-anchor
419
+ AW_BRIDGE_VERSION="7.0.0" # aw-version-anchor
420
420
  # Generous hard cap for a slow review at the host posture's effort (subscription latency varies).
421
421
  CODEX_HARD_TIMEOUT="${CODEX_HARD_TIMEOUT:-1800}"
422
422
  # Above this assembled-payload size (bytes), the diff goes via a git-dir-local temp
@@ -3,7 +3,7 @@
3
3
  "schema": 1,
4
4
  "name": "codex-cli-bridge",
5
5
  "kind": "execution-backend",
6
- "version": "6.1.0",
6
+ "version": "7.0.0",
7
7
  "posture": { "model": "gpt-6.2-sol", "effort": "high", "tier": null },
8
8
  "provides": ["execute", "review"],
9
9
  "roles": {
@@ -21,7 +21,7 @@
21
21
  "codex-exec --resume-last [--nonce <n>] <plan-file|->",
22
22
  "codex-exec --resume <session-id> [--nonce <n>] <plan-file|->"
23
23
  ],
24
- "receipt": "side effect — a NONCED run mints ONE exec receipt beside the delegation store: the dispatch nonce seam is the AW_DISPATCH_NONCE environment value or its plain-argument equivalent --nonce <n>, recognised ONLY before the prompt operand (after the operand or a literal '--' it is passthrough payload, never a flag), under the safe grammar [A-Za-z0-9._-]{1,64} — anything else, a duplicate, or a flag disagreeing with a non-empty env value refuses PRE-SPEND. The store directory resolves exactly as the kit's delegation store does: the dirname of an ABSOLUTE AW_DELEGATION_STORE (a relative one, or one ending in a path separator, refuses), else the git common dir. The artifact is agent-workflow-exec-receipt-<backendLength>-<backend>-<nonce>.json in two states: 'reserved' is written atomically and NO-CLOBBER immediately before the CLI runs — that write IS the nonce reservation, so a second dispatch on the same nonce, or an already-taken report name, refuses BEFORE any spend — and 'terminal' replaces it in place at exit. A nonced run also refuses pre-spend when no timeout/gtimeout binary can cap it (an accounted dispatch that cannot be capped can never honour the terminal-exit rule; a nonce-LESS run still warns and runs uncapped), when node is missing (the mint core), and when the prompt rides on stdin instead of a contract FILE — contractDigest is computed BY THIS WRAPPER from the dispatch file it was actually handed, so the kit can refuse a run that executed a different contract than the one it opened. That digest is taken from the SAME bytes already read as the prompt, never a second open of the path: two reads leave a window in which the file can be swapped, and the run would then execute one contract while its receipt claimed the digest of another. The header's own nonce must EQUAL the dispatch nonce — 'dispatch open' copies the nonce FROM the header, so a disagreeing --nonce could only reserve an identity no return would ever absorb, and it refuses pre-spend. A contract file edited BETWEEN 'dispatch open' and the run is caught at ABSORB by the contractDigest comparison, not pre-spend: the wrapper never reads the ledger, and that boundary is what the whole lane rests on. At exit the wrapper FIRST re-reads its reservation and verifies its own opaque owner token — a foreign owner refuses having published NOTHING, neither report nor receipt — THEN writes the delegate's final message atomically to agent-workflow-exec-report-<backendLength>-<backend>-<nonce>.txt, THEN re-verifies the owner and REPLACES the reservation with the terminal receipt {schema, kind, state, backend, nonce, owner, contractDigest, wrapperVersion, posture {model, effort, tier}, capS, killGraceS, sessionId, exitStatus, outcome, reportDigest, reportLength, timestamp}: the report is complete on disk before any artifact says the run arrived. capS and killGraceS are the cap the run ACTUALLY applied. outcome is the wrapper's own SUBSET of the ledger's vocabulary — exit 0 with a session id -> success, exit 0 without one -> missing-identity, ANY nonzero exit including the timeout codes 124 and 137 -> transport-failure; every orchestrator judgment is recorded at absorb time, never claimed here. The session id is captured BEFORE outcome branching, so a FAILED run records one too; in resume mode it is the validated resume id. FAIL-CLOSED, deliberately NOT the review lane's warn-only receipt: a publication that cannot complete exits nonzero with a DISTINCT status, and the message states only what the run can still prove. 70: the reservation could not be verified BEFORE any publication — NOTHING was published, not the report and not the receipt, and because the artifact found there belongs to another run it is never a '--no-receipt' source. 71: a publication stopped after that point — either the report write failed (nothing beyond the reservation was published; the '--no-receipt' absorb then records reportLength 0, ineligible by the name empty-report) or the report IS on disk and the terminal receipt was not completed (the absorb reads it, report-if-present). The post-report lane never claims the reservation still stands, because after that point its fate is no longer something this run observed. Every lane names the tree as partial/dirtied rather than untouched. A nonce-LESS invocation is byte-unchanged: no reservation, no receipt, no artifact, and it needs no node.",
24
+ "receipt": "side effect — a NONCED run mints ONE exec receipt beside the delegation store: the dispatch nonce seam is the AW_DISPATCH_NONCE environment value or its plain-argument equivalent --nonce <n>, recognised ONLY before the prompt operand (after the operand or a literal '--' it is passthrough payload, never a flag), under the safe grammar [A-Za-z0-9._-]{1,64} — anything else, a duplicate, or a flag disagreeing with a non-empty env value refuses PRE-SPEND. The store directory resolves exactly as the kit's delegation store does: the dirname of an ABSOLUTE AW_DELEGATION_STORE (a relative one, or one ending in a path separator, refuses), else the git common dir. The artifact is agent-workflow-exec-receipt-<backendLength>-<backend>-<nonce>.json in two states: 'reserved' is written atomically and NO-CLOBBER immediately before the CLI runs — that write IS the nonce reservation, so a second dispatch on the same nonce, or an already-taken report name, refuses BEFORE any spend — and 'terminal' replaces it in place at exit. A nonced run also refuses pre-spend when no timeout/gtimeout binary can cap it (an accounted dispatch that cannot be capped can never honour the terminal-exit rule; a nonce-LESS run still warns and runs uncapped), when node is missing (the mint core), and when the prompt rides on stdin instead of a contract FILE — contractDigest is computed BY THIS WRAPPER from the dispatch file it was actually handed, so the kit can refuse a run that executed a different contract than the one it opened. That digest is taken from the SAME bytes already read as the prompt, never a second open of the path: two reads leave a window in which the file can be swapped, and the run would then execute one contract while its receipt claimed the digest of another. The header's own nonce must EQUAL the dispatch nonce — 'dispatch open' copies the nonce FROM the header, so a disagreeing --nonce could only reserve an identity no return would ever absorb, and it refuses pre-spend. A contract file edited BETWEEN 'dispatch open' and the run is caught at ABSORB by the contractDigest comparison, not pre-spend: the wrapper never reads the ledger, and that boundary is what the whole lane rests on. At exit the wrapper FIRST re-reads its reservation and verifies its own opaque owner token — a foreign owner refuses having published NOTHING, neither report nor receipt — THEN writes the delegate's final message atomically to agent-workflow-exec-report-<backendLength>-<backend>-<nonce>.txt, THEN re-verifies the owner and REPLACES the reservation with the terminal receipt {schema, kind, state, backend, nonce, owner, contractDigest, wrapperVersion, posture {model, effort, tier}, capS, killGraceS, sessionId, exitStatus, outcome, reportDigest, reportLength, timestamp}: the report is complete on disk before any artifact says the run arrived. capS and killGraceS are the cap the run ACTUALLY applied. outcome is the wrapper's own SUBSET of the ledger's vocabulary — exit 0 with a session id -> success, exit 0 without one -> missing-identity, ANY nonzero exit including the timeout codes 124 and 137 -> transport-failure; every orchestrator judgment is recorded at absorb time, never claimed here. The session id is captured BEFORE outcome branching, so a FAILED run records one too; in resume mode it is the validated resume id. FAIL-CLOSED, deliberately NOT the review lane's warn-only receipt: a publication that cannot complete exits nonzero with a DISTINCT status, and the message states only what the run can still prove. 70: the reservation could not be verified BEFORE any publication — NOTHING was published, not the report and not the receipt, and because the artifact found there belongs to another run it is never a '--no-receipt' source. 71: a publication stopped after that point — either the report write failed (nothing beyond the reservation was published; the '--no-receipt' absorb then records reportLength 0, ineligible by the name empty-report) or the report IS on disk and the terminal receipt was not completed (the absorb reads it, report-if-present). The post-report lane never claims the reservation still stands, because after that point its fate is no longer something this run observed. Every lane names the tree as partial/dirtied rather than untouched. A nonced run also refuses pre-spend, reserving nothing, unless its contract file carries exactly one top-level aw-plan-approval block of exactly plan, approval and check whose check (the kit's tools/plan-approval/cli.mjs check <plan> --digest <approval>) exits 0, so a nonced run never starts unless the approval record matches the block's own plan and approval; the kit's tools/stage-render/cli.mjs --dispatch <plan> prints that block. A nonce-LESS invocation is byte-unchanged: no reservation, no receipt, no artifact, and it needs no node.",
25
25
  "passthrough": {
26
26
  "policy": "guarded",
27
27
  "blocked": ["-c*", "--config*", "-s*", "--sandbox*", "--dangerously-bypass-approvals-and-sandbox", "--dangerously-bypass-hook-trust", "--full-auto", "--oss", "--local-provider*", "-p*", "--profile*", "-m*", "--model*", "-o*", "--output-last-message*", "--json*", "--color*", "--output-schema*", "--ephemeral*"],
package/capability.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "schema": 1,
4
4
  "name": "agent-workflow-kit",
5
5
  "kind": "composition-root",
6
- "version": "23.12.0",
6
+ "version": "24.0.0",
7
7
  "provides": [],
8
8
  "roles": {},
9
9
  "detect": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sabaiway/agent-workflow-kit",
3
- "version": "23.12.0",
3
+ "version": "24.0.0",
4
4
  "description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -33,6 +33,8 @@
33
33
  | read-lane | chat | gate-hook.mjs |
34
34
  | state-block | harness | state-block-hook.mjs |
35
35
  | state-block.not-current | kit | state-block-hook.mjs |
36
+ | stage-guard | harness | stage-write-guard/cli.mjs |
37
+ | stage-guard.not-current | kit | stage-write-guard/cli.mjs |
36
38
  | mcp-channel | harness | mcp.mjs |
37
39
  | mcp-channel.differing | harness | mcp.mjs |
38
40
  | agents | harness | cheap-agents.mjs |
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: author
3
+ description: Drafts ONE bounded authoring slice on behalf of the orchestrator — a plan, a contract, an epic or a fold of a round's findings; only the files the brief names, with no shell.
4
+ model: opus
5
+ effort: high
6
+ tools: Read, Grep, Glob, Write, Edit
7
+ ---
8
+
9
+ You are the AUTHOR vehicle. The orchestrator owns the review and the commit; you own
10
+ one authoring slice and nothing else.
11
+
12
+ - **One slice, the named files only.** Draft a plan, a contract, an epic or a fold of a round's
13
+ findings. Write only the files the brief names. You write no code file and no test file.
14
+ - **Read before you edit.** Read the plan, the governing contracts and the project rules the brief
15
+ names first.
16
+ - **You never commit.** You run no git command. You have no shell, so you run no command at all.
17
+ - **A red line STOPS you.** An approval ask, a need for the network or a credential, a file outside
18
+ your slice, or a finding that the brief itself is wrong: you stop and report it. You never
19
+ improvise around it and never widen your own scope to repair it.
20
+ - **Your final message IS the return value.** The exact paths you wrote and anything left undone
21
+ with the reason. The orchestrator reviews every returned draft as its own.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: executor
3
- description: Executes ONE bounded slice — an execution, authoring, or write-capable routine slice — on behalf of the orchestrator; only the files the brief names, their suites, and a return block. Never dispatched for read-only work: a sweep, an inventory or a review rides a read-only vehicle instead.
3
+ description: Executes ONE bounded slice — an execution or write-capable routine slice — on behalf of the orchestrator; only the files the brief names, their suites, and a return block. Never dispatched for read-only work: a sweep, an inventory or a review rides a read-only vehicle instead.
4
4
  model: opus
5
5
  effort: high
6
6
  ---
@@ -14,12 +14,19 @@ plan, the review and the commit; you own ONE slice of it, end to end, and nothin
14
14
  not a decision you get to make.
15
15
  - **Read before you edit.** The plan, the governing contract and the project rules the brief names
16
16
  are read first. An edit written before them is guesswork wearing the shape of work.
17
+ - **A code or test slice runs only on an approved plan.** It runs only from a brief carrying the
18
+ dispatch part the renderer printed (`tools/stage-render/cli.mjs --dispatch <plan>`, its
19
+ ` ```aw-plan-approval ` block). Before any write you run that part's check command for the
20
+ block's `plan` and `approval`, and you stop on any exit but 0, on a brief whose plan is not the
21
+ block's `plan`, and on a file to write that neither an approved row nor a valid amendment entry
22
+ of that plan covers, a sweep's concrete paths included. A routine or task slice that names the
23
+ kit command generating each file and hand-writes no source or test file is outside this stop.
17
24
  - **You never commit, and you never touch what governs you.** No git write at all: no `add`,
18
- `commit`, `push`, `stash`, `reset`, `checkout`, `tag`, no history rewrite. You never edit the plan
25
+ `commit`, `push`, `stash`, `reset`, `checkout`, `tag`, `worktree`, no history rewrite. You never edit the plan
19
26
  or the contract under `docs/ai/specs/` that governs YOUR OWN slice, the ADR, the changelog, the
20
27
  handover documents or `docs/ai/source-size.json` — those are the orchestrator's, and the
21
- orchestrator is the only one who commits. A plan draft, a contract draft or a regenerated document
22
- that the brief names as your DELIVERABLE (an authoring or a routine slice) is a named file like
28
+ orchestrator is the only one who commits. A regenerated document
29
+ that the brief names as your DELIVERABLE (a routine slice) is a named file like
23
30
  any other.
24
31
  - **You run the suites and report what they printed.** The brief maps every file you touch to the
25
32
  exact test files and commands to run; where it does not, run the paired `<name>.test.mjs` when one
@@ -28,8 +35,7 @@ plan, the review and the commit; you own ONE slice of it, end to end, and nothin
28
35
  return block. A failing
29
36
  test is reported as failing; papering over it, skipping it, or weakening an assertion to reach
30
37
  green is the worst thing you can do here.
31
- - **You stay inside the budget the brief states.** Every file keeps to the line cap it names. A
32
- comment exists only where the code truly cannot carry the fact. No attribution of any kind — to
38
+ - A comment exists only where the code truly cannot carry the fact. No attribution of any kind — to
33
39
  an agent, a model or a tool — anywhere: code, comments, messages, documents. The project's
34
40
  language and encoding rules come from its `AGENTS.md` and the brief — never assume English or ASCII.
35
41
  - **A red line STOPS you.** An approval ask, a need for the network or a credential, a file outside
@@ -96,12 +96,12 @@ On `upgrade`, a pre-1.2.0 deployment with no block gets one (the agent asks, def
96
96
  Every name the kit bundles and writes over on an upgrade is the kit's, and an edit there is never a
97
97
  customization: every kit script, the kit folder `scripts/agent-workflow/` whole, the spec layer's
98
98
  files and the command `scripts/agent-workflow/run.mjs` in it, the hook installer set, the kit rules
99
- files `docs/ai/rules/<theme>.md` and the kit agent files (the five the kit bundles for
100
- `.claude/agents/` — `changelog-skeleton.md`, `executor.md`,
99
+ files `docs/ai/rules/<theme>.md` and the kit agent files (the names the kit bundles for
100
+ `.claude/agents/` — `author.md`, `changelog-skeleton.md`, `executor.md`,
101
101
  `gate-triage.md`, `mechanical-sweep.md`, `review-lens.md` — and each configured
102
102
  `review-lens-<model>-<effort>.md`) and, within a hook you wired, the kit hook files
103
- `.claude/hooks/agent-workflow-gates.mjs` and `.claude/hooks/state-block-guard.mjs` are written over
104
- by the next upgrade with no question and no copy kept.
103
+ `.claude/hooks/agent-workflow-gates.mjs`, `.claude/hooks/state-block-guard.mjs` and
104
+ `.claude/hooks/stage-write-guard.mjs` are written over by the next upgrade with no question and no copy kept.
105
105
  Also the kit's: the vendor skill copy the kit installs into the three agent skill roots
106
106
  when it matches a pin the kit shipped, written with no question beside a copy at a kit pin;
107
107
  a copy matching none is the user's, left and named. Also the kit's: the kit block of `AGENTS.md`, between its two
@@ -4,9 +4,8 @@
4
4
  // <project>/.claude/hooks/agent-workflow-gates.mjs and wired as a `PreToolUse` "Bash" hook in
5
5
  // .claude/settings.json.
6
6
  //
7
- // SELF-CONTAINED by contract: the placed copy must run on machines without the kit — no kit
8
- // imports, dependency-free, Node >= 22, no side effects on import.
9
- // SEEDED_READONLY_CORE and RESIDUAL_FORMS are the generated region scripts/sync-mirrors.mjs writes from velocity-profile.mjs.
7
+ // SELF-CONTAINED by contract: no kit imports, dependency-free, Node >= 22, no side effects on import.
8
+ // GATES_REL, LANES_REL, SEEDED_READONLY_CORE and RESIDUAL_FORMS are generated by scripts/sync-mirrors.mjs from velocity-profile.mjs and shared/locations.mjs.
10
9
  //
11
10
  // It reads <project root>/docs/ai/gates.json LIVE on every invocation (AD-035: one declaration,
12
11
  // two consumers — editing gates.json never requires re-wiring) and, for the opt-in read-lane
@@ -87,10 +86,6 @@ import { fileURLToPath } from 'node:url';
87
86
 
88
87
  export const HOOK_EVENT_NAME = 'PreToolUse';
89
88
  export const BASH_TOOL_NAME = 'Bash';
90
- export const GATES_REL = 'docs/ai/gates.json';
91
- // The opt-in read-lane toggle (rung c) — a SEPARATE kit-owned strict-JSON file (AD-055 Part II);
92
- // gates.json's schema/validators/template are untouched by design.
93
- export const LANES_REL = 'docs/ai/lanes.json';
94
89
  export const READ_LANE_KEY = 'readLane';
95
90
  export const PROJECT_DIR_ENV = 'CLAUDE_PROJECT_DIR';
96
91
  export const DECISION_ALLOW = 'allow';
@@ -99,7 +94,11 @@ export const DECISION_ASK = 'ask';
99
94
  // fenced closed by default. The residual guard (b) is NOT mode-fenced: an `ask` never loosens.
100
95
  export const ALLOW_PERMISSION_MODES = Object.freeze(['default', 'acceptEdits']);
101
96
 
102
- // generated from agent-workflow-kit/tools/velocity-profile.mjs by scripts/sync-mirrors.mjs; do not edit
97
+ // The opt-in read-lane toggle (rung c) — a SEPARATE kit-owned strict-JSON file (AD-055 Part II);
98
+ // gates.json's schema/validators/template are untouched by design.
99
+ // generated from agent-workflow-kit/tools/velocity-profile.mjs and agent-workflow-memory/references/scripts/shared/locations.mjs by scripts/sync-mirrors.mjs; do not edit
100
+ export const GATES_REL = "docs/ai/gates.json";
101
+ export const LANES_REL = "docs/ai/lanes.json";
103
102
  export const SEEDED_READONLY_CORE = Object.freeze([
104
103
  "Bash(git status:*)",
105
104
  "Bash(git diff:*)",
@@ -0,0 +1,314 @@
1
+ #!/usr/bin/env node
2
+ // stage-write-guard.mjs — the kit's PreToolUse stage write guard, placed at .claude/hooks/stage-write-guard.mjs
3
+ // (docs/ai/specs/kit/stage-write-guard.md). Self-contained: node: modules only, no effect unless run as the hook.
4
+
5
+ import { spawnSync } from 'node:child_process';
6
+ import { closeSync, constants as fsConstants, fstatSync, lstatSync, openSync, readFileSync, readlinkSync, realpathSync } from 'node:fs';
7
+ import { homedir } from 'node:os';
8
+ import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+
11
+ // generated from agent-workflow-memory/references/scripts/shared/locations.mjs and agent-workflow-kit/tools/stage-render/ (index.mjs, stages.json) by scripts/sync-mirrors.mjs; do not edit
12
+ const DOCS = "docs";
13
+ const DOCS_TREE = "docs/ai";
14
+ const PLANS = "docs/plans";
15
+ const ORCHESTRATION = "docs/ai/orchestration.json";
16
+ const STAGE_GUARD_HOOK = ".claude/hooks/stage-write-guard.mjs";
17
+ const STAGE_RECORD_BASENAME = "agent-workflow-stage.json";
18
+ const SLOT_FILE_NAME = "next-session.json";
19
+ const RENDER_LINE = "node <kit>/tools/stage-render/cli.mjs docs/plans/next-session.json";
20
+ const STAGE_IDS = ["epic","design-consult","spec-and-plan","waiting-on-approval","tests","code","diff-review","split-modules","split-edits","pause","empty-queue"];
21
+ // end of the generated locations
22
+
23
+ const PATH_FIELDS = Object.freeze({ Write: 'file_path', Edit: 'file_path', MultiEdit: 'file_path', NotebookEdit: 'notebook_path' });
24
+ const HOOK_EVENT_NAME = 'PreToolUse';
25
+ const DENY = 'deny';
26
+ const UTF8 = 'utf8';
27
+
28
+ const GIT = 'git';
29
+ const GIT_ARGS = Object.freeze(['rev-parse', '--show-toplevel', '--absolute-git-dir']);
30
+ const GIT_COMMAND = [GIT, ...GIT_ARGS].join(' ');
31
+ const GIT_VARIABLE = /^git_/iu;
32
+ const GIT_ANSWERED_EXIT = 128;
33
+ const NOT_A_REPOSITORY = /^fatal: not a git repository\b/mu;
34
+ const NO_WORK_TREE = /^fatal: this operation must be run in a work tree\b/mu;
35
+ const GIT_OUTPUT_CEILING = 1024 * 1024;
36
+ const GIT_TIMEOUT_MS = 10_000;
37
+ const GIT_ANSWER_LINES = 3;
38
+ const STDERR_SHOWN = 200;
39
+
40
+ const RUN_TREE = 'tree';
41
+ const RUN_NONE = 'none';
42
+ const RUN_FAILED = 'failed';
43
+
44
+ const RECORD_SCHEMA = 1;
45
+ const RECORD_KEYS = Object.freeze(['schema', 'slotFile', 'stage', 'writes']);
46
+ const WRITES_ANY = 'any';
47
+ const WRITES_AUTHORING = 'authoring';
48
+ const JSON_STRING = /"(?:[^"\\]|\\.)*"/gu;
49
+ const FOLLOWED_BY_COLON = /^\s*:/u;
50
+ const READ_FLAGS = fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0) | (fsConstants.O_NONBLOCK ?? 0);
51
+
52
+ const MARKDOWN = '.md';
53
+ const JSON_FILE = '.json';
54
+ const TEXT_FILE = '.txt';
55
+ const DOT_DOT = '..';
56
+ const RAW_SEGMENT_SEPARATOR = /[\\/]/u;
57
+ const CONFIG_HOME = '.claude';
58
+ const MEMORY_PROJECTS = 'projects';
59
+ const MEMORY_DIR = 'memory';
60
+ const HOST_PLANS = 'plans';
61
+ const MEMORY_NOTE_DEPTH = 4;
62
+ const HOST_PLAN_DEPTH = 2;
63
+
64
+ const GUARD_PREFIX = `stage guard (${STAGE_GUARD_HOOK})`;
65
+ const RENDER_SENTENCE = `code and tests are written only after the render of an approved plan's tests, code, split-edits or diff-review stage: ${RENDER_LINE}`;
66
+
67
+ const isPlainObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
68
+ const failed = (failure) => ({ kind: RUN_FAILED, failure });
69
+ const codeOf = (error) => error?.code ?? error?.message ?? String(error);
70
+
71
+ const lstatOrNull = (path) => {
72
+ try {
73
+ return lstatSync(path);
74
+ } catch (error) {
75
+ if (error?.code === 'ENOENT') return null;
76
+ throw error;
77
+ }
78
+ };
79
+
80
+ const realPathOf = (path) => {
81
+ try {
82
+ return realpathSync(path);
83
+ } catch (error) {
84
+ if (error?.code !== 'ENOENT') throw error;
85
+ }
86
+ const entry = lstatOrNull(path);
87
+ if (entry?.isSymbolicLink()) return realPathOf(resolve(dirname(path), readlinkSync(path)));
88
+ if (entry !== null) throw new Error(`${path}: present but without a real path`);
89
+ const parent = dirname(path);
90
+ if (parent === path) throw new Error(`${path}: no existing ancestor`);
91
+ return join(realPathOf(parent), basename(path));
92
+ };
93
+
94
+ const realOrNull = (path) => {
95
+ try {
96
+ return realpathSync(path);
97
+ } catch {
98
+ return null;
99
+ }
100
+ };
101
+
102
+ const deepestExisting = (path) => {
103
+ if (lstatOrNull(path) !== null) return path;
104
+ const parent = dirname(path);
105
+ if (parent === path) throw new Error(`${path}: no existing ancestor`);
106
+ return deepestExisting(parent);
107
+ };
108
+
109
+ const readNoFollow = (path) => {
110
+ const descriptor = openSync(path, READ_FLAGS);
111
+ try {
112
+ if (!fstatSync(descriptor).isFile()) throw new Error('not a regular file');
113
+ return new TextDecoder(UTF8, { fatal: true, ignoreBOM: true }).decode(readFileSync(descriptor));
114
+ } finally {
115
+ closeSync(descriptor);
116
+ }
117
+ };
118
+
119
+ const gitEnvOf = (env) => ({ ...Object.fromEntries(Object.entries(env).filter(([key]) => !GIT_VARIABLE.test(key))), LC_ALL: 'C' });
120
+
121
+ const readGitAnswer = (dir, stdout) => {
122
+ const lines = stdout.split('\n');
123
+ if (lines.length !== GIT_ANSWER_LINES || lines[2] !== '' || !lines.slice(0, 2).every((line) => isAbsolute(line))) {
124
+ return failed(`${GIT_COMMAND} in ${dir} answered no work tree and git directory`);
125
+ }
126
+ try {
127
+ const gitDir = realpathSync(lines[1]);
128
+ return { kind: RUN_TREE, root: realpathSync(lines[0]), gitDir, recordPath: join(gitDir, STAGE_RECORD_BASENAME) };
129
+ } catch (error) {
130
+ return failed(`${GIT_COMMAND} in ${dir} answered a path without a real path (${codeOf(error)})`);
131
+ }
132
+ };
133
+
134
+ const runGit = (dir, env) => {
135
+ const result = spawnSync(GIT, GIT_ARGS, {
136
+ cwd: dir, env: gitEnvOf(env), encoding: UTF8, maxBuffer: GIT_OUTPUT_CEILING, timeout: GIT_TIMEOUT_MS,
137
+ stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true,
138
+ });
139
+ if (result.error) return failed(`${GIT_COMMAND} in ${dir} could not run (${codeOf(result.error)})`);
140
+ if (result.signal) return failed(`${GIT_COMMAND} in ${dir} was killed by ${result.signal}`);
141
+ if (result.status === 0) return readGitAnswer(dir, result.stdout);
142
+ const stderr = result.stderr ?? '';
143
+ if (result.status === GIT_ANSWERED_EXIT && (NOT_A_REPOSITORY.test(stderr) || NO_WORK_TREE.test(stderr))) return { kind: RUN_NONE };
144
+ return failed(`${GIT_COMMAND} in ${dir} exited ${result.status}: ${stderr.trim().slice(0, STDERR_SHOWN)}`);
145
+ };
146
+
147
+ const runsFor = (cwd, realTarget, env) => {
148
+ const targetDir = deepestExisting(dirname(realTarget));
149
+ const cwdRun = runGit(cwd, env);
150
+ return realOrNull(cwd) === targetDir ? [cwdRun] : [cwdRun, runGit(targetDir, env)];
151
+ };
152
+
153
+ const holdsDotDot = (rawPath) => rawPath.split(RAW_SEGMENT_SEPARATOR).includes(DOT_DOT);
154
+ const segmentsUnder = (base, path) => {
155
+ const rel = relative(base, path);
156
+ if (rel === '' || isAbsolute(rel)) return null;
157
+ const segments = rel.split(sep);
158
+ return segments[0] === DOT_DOT ? null : segments;
159
+ };
160
+
161
+ const configDirOf = (env) => {
162
+ const configured = env.CLAUDE_CONFIG_DIR;
163
+ if (typeof configured === 'string' && isAbsolute(configured)) return configured;
164
+ return join(typeof env.HOME === 'string' && isAbsolute(env.HOME) ? env.HOME : homedir(), CONFIG_HOME);
165
+ };
166
+
167
+ const isHarnessDocument = (rawPath, target, env) => {
168
+ try {
169
+ const realTarget = realPathOf(target);
170
+ if (holdsDotDot(rawPath) || extname(realTarget) !== MARKDOWN) return false;
171
+ const segments = segmentsUnder(realPathOf(configDirOf(env)), realTarget);
172
+ if (segments === null) return false;
173
+ return (segments.length === MEMORY_NOTE_DEPTH && segments[0] === MEMORY_PROJECTS && segments[2] === MEMORY_DIR)
174
+ || (segments.length === HOST_PLAN_DEPTH && segments[0] === HOST_PLANS);
175
+ } catch {
176
+ return false;
177
+ }
178
+ };
179
+
180
+ const isUnder = (rel, dir) => rel.startsWith(`${dir}/`);
181
+ const isCanonicalRel = (value) => value.split('/').every((segment) => segment !== '' && segment !== '.' && segment !== DOT_DOT);
182
+
183
+ const configuredPaths = (root) => {
184
+ try {
185
+ const flow = JSON.parse(readNoFollow(join(root, ORCHESTRATION)))?.flow;
186
+ if (!isPlainObject(flow)) return [];
187
+ return [flow.debtQueue, flow.convergenceSummary].filter((value) => typeof value === 'string' && !value.includes('\\')
188
+ && isCanonicalRel(value) && isUnder(value, DOCS) && extname(value) === MARKDOWN);
189
+ } catch {
190
+ return [];
191
+ }
192
+ };
193
+
194
+ const isProjectAuthoring = (root, realTarget) => {
195
+ const segments = segmentsUnder(root, realTarget);
196
+ if (segments === null) return false;
197
+ const rel = segments.join('/');
198
+ const extension = extname(rel);
199
+ if (isUnder(rel, DOCS_TREE) && (extension === MARKDOWN || extension === JSON_FILE)) return true;
200
+ if (isUnder(rel, PLANS) && (extension === MARKDOWN || extension === TEXT_FILE)) return true;
201
+ if (rel === `${PLANS}/${SLOT_FILE_NAME}`) return true;
202
+ return configuredPaths(root).includes(rel);
203
+ };
204
+
205
+ const memberNamesOf = (text) => [...text.matchAll(JSON_STRING)]
206
+ .filter((token) => FOLLOWED_BY_COLON.test(text.slice(token.index + token[0].length)))
207
+ .map((token) => JSON.parse(token[0]));
208
+
209
+ const isRecordShape = (record, text) => isPlainObject(record)
210
+ && memberNamesOf(text).sort().join() === RECORD_KEYS.join()
211
+ && record.schema === RECORD_SCHEMA
212
+ && (record.stage === null || STAGE_IDS.includes(record.stage))
213
+ && record.slotFile === `${PLANS}/${SLOT_FILE_NAME}`
214
+ && (record.writes === WRITES_ANY || record.writes === WRITES_AUTHORING);
215
+
216
+ const readRecord = (recordPath, entry) => {
217
+ if (!entry.isFile()) return { unreadable: entry.isSymbolicLink() ? 'a link' : 'not a regular file' };
218
+ try {
219
+ const text = readNoFollow(recordPath);
220
+ const record = JSON.parse(text);
221
+ return isRecordShape(record, text) ? { record } : { unreadable: 'not a stage record of schema 1' };
222
+ } catch (error) {
223
+ return { unreadable: codeOf(error) };
224
+ }
225
+ };
226
+
227
+ const presentRecords = (runs) => {
228
+ const trees = runs.filter(({ kind }) => kind === RUN_TREE);
229
+ return trees.filter((tree, index) => trees.findIndex(({ gitDir }) => gitDir === tree.gitDir) === index)
230
+ .flatMap((tree) => {
231
+ try {
232
+ const entry = lstatOrNull(tree.recordPath);
233
+ return entry === null ? [] : [{ tree, ...readRecord(tree.recordPath, entry) }];
234
+ } catch (error) {
235
+ return [{ tree, unreadable: codeOf(error) }];
236
+ }
237
+ });
238
+ };
239
+
240
+ const denial = (target, cause) => `${GUARD_PREFIX}: ${target} is refused: ${cause}; ${RENDER_SENTENCE}`;
241
+ const stageCause = ({ stage, slotFile }) => (stage === null
242
+ ? `the last render recorded no stage for slot file ${slotFile}, which writes only authoring documents`
243
+ : `the recorded stage ${stage} (slot file ${slotFile}) writes only authoring documents`);
244
+
245
+ const judgeRecord = (target, present, isAuthoring) => {
246
+ if (present.unreadable !== undefined) {
247
+ return isAuthoring() ? null : denial(target, `the stage record ${present.tree.recordPath} cannot be read (${present.unreadable})`);
248
+ }
249
+ if (present.record.writes === WRITES_ANY || isAuthoring()) return null;
250
+ return denial(target, stageCause(present.record));
251
+ };
252
+
253
+ const judgeWrite = ({ rawPath, cwd }, target, harnessDocument, env) => {
254
+ const realTarget = realPathOf(target);
255
+ const runs = runsFor(cwd, realTarget, env);
256
+ const failure = runs.find(({ kind }) => kind === RUN_FAILED);
257
+ if (failure !== undefined) return harnessDocument ? null : denial(target, failure.failure);
258
+ const present = presentRecords(runs);
259
+ const landing = runs.at(-1);
260
+ const isAuthoring = () => harnessDocument
261
+ || (!holdsDotDot(rawPath) && landing.kind === RUN_TREE && isProjectAuthoring(landing.root, realTarget));
262
+ return present.map((record) => judgeRecord(target, record, isAuthoring)).find((reason) => reason !== null) ?? null;
263
+ };
264
+
265
+ const decideWrite = (request, env) => {
266
+ const validCwd = typeof request.cwd === 'string' && isAbsolute(request.cwd);
267
+ const target = isAbsolute(request.rawPath) ? resolve(request.rawPath) : validCwd ? resolve(request.cwd, request.rawPath) : null;
268
+ const harnessDocument = target !== null && isHarnessDocument(request.rawPath, target, env);
269
+ try {
270
+ if (target === null || !validCwd) throw new Error('the payload names no absolute cwd');
271
+ return judgeWrite(request, target, harnessDocument, env);
272
+ } catch (error) {
273
+ return harnessDocument ? null : denial(target ?? request.rawPath, `the guard could not judge the write (${codeOf(error)})`);
274
+ }
275
+ };
276
+
277
+ const readWriteRequest = (text) => {
278
+ try {
279
+ const payload = JSON.parse(text);
280
+ if (!isPlainObject(payload) || !Object.hasOwn(PATH_FIELDS, payload.tool_name) || !isPlainObject(payload.tool_input)) return null;
281
+ const rawPath = payload.tool_input[PATH_FIELDS[payload.tool_name]];
282
+ return typeof rawPath === 'string' && rawPath !== '' ? { rawPath, cwd: payload.cwd } : null;
283
+ } catch {
284
+ return null;
285
+ }
286
+ };
287
+
288
+ const formatDeny = (reason) => JSON.stringify({
289
+ hookSpecificOutput: { hookEventName: HOOK_EVENT_NAME, permissionDecision: DENY, permissionDecisionReason: reason },
290
+ });
291
+
292
+ const readStdin = async () => {
293
+ const chunks = [];
294
+ for await (const chunk of process.stdin) chunks.push(chunk);
295
+ return Buffer.concat(chunks).toString(UTF8);
296
+ };
297
+
298
+ const main = async () => {
299
+ const request = readWriteRequest(await readStdin().catch(() => ''));
300
+ if (request === null) return;
301
+ const reason = decideWrite(request, process.env);
302
+ if (reason !== null) process.stdout.write(`${formatDeny(reason)}\n`);
303
+ };
304
+
305
+ const isDirectRun = (() => {
306
+ const invoked = process.argv[1];
307
+ if (!invoked) return false;
308
+ try {
309
+ return realpathSync(invoked) === realpathSync(fileURLToPath(import.meta.url));
310
+ } catch {
311
+ return false;
312
+ }
313
+ })();
314
+ if (isDirectRun) main().catch(() => {});
@@ -3,7 +3,7 @@
3
3
  <!-- opt-in-capability: agents -->
4
4
  <!-- opt-in-capability: executor-vehicle -->
5
5
 
6
- The opt-in **subagent-vehicle writer** — the family's second `.claude/` writer, on the velocity discipline. It places the **five** bundled subagent definitions (`references/agents/*.md`) into the project's `.claude/agents/`: **four read-only vehicles** and **one** full-tool `executor`. **Claude-Code-specific** (like velocity): other agent hosts ignore `.claude/agents/`.
6
+ The opt-in **subagent-vehicle writer** — the family's second `.claude/` writer, on the velocity discipline. It places the bundled subagent definitions (`references/agents/*.md`) into the project's `.claude/agents/`: **four read-only vehicles**, the no-shell `author` and **one** full-tool `executor`. **Claude-Code-specific** (like velocity): other agent hosts ignore `.claude/agents/`.
7
7
 
8
8
  **Every READ-ONLY vehicle grants READ-ONLY tools and NO `Bash`** — that is the load-bearing property, not a detail. A read-only fan-out on a full-tool vehicle shells out for facts it could have read, and each shelled command is an approval prompt the maintainer never needed to see; a vehicle with no shell structurally cannot do that. Two lanes ride on it:
9
9
 
@@ -12,11 +12,13 @@ The opt-in **subagent-vehicle writer** — the family's second `.claude/` writer
12
12
 
13
13
  Writing code, running gates, and user-facing copy never move to these four vehicles.
14
14
 
15
- **The fifth vehicle, `executor`, is the ONE full-tool one** (model and effort from `docs/ai/vehicles.json` — `opus` / `high` by default — and every tool, a shell included). It is the instrument behind the **Subagent** recipe, dispatched ONLY for a **bounded, file-disjoint slice** the orchestrator verifies afterwards by running its suites: a slice of execution (`plan-execution.execute`), a plan/contract authoring brief (`plan-authoring.author`), an authoring-round fold (`plan-authoring.fold`), a bounded chore (`routine.carrier`), an epic brief (`epic.author`), or one prompt the orchestrator wrote from one ledger row, run inside its Files (`task.execute`); `task.author` dispatches no slice, since the orchestrator writes each row's prompt itself. It **never commits** (no git write at all), is **never a review backend**, is **never a bridge substitute**, and is **never dispatched for read-only work** — a sweep, an inventory or a review rides a read-only vehicle instead.
15
+ **The `executor` is the ONE full-tool vehicle** (model and effort from `docs/ai/vehicles.json` — `opus` / `high` by default — and every tool, a shell included). It is the instrument behind the **Subagent** recipe for carry slots, dispatched ONLY for a **bounded, file-disjoint slice** the orchestrator verifies afterwards by running its suites: a slice of execution (`plan-execution.execute`), a write-capable chore (`routine.carrier`), or one prompt the orchestrator wrote from one ledger row, run inside its Files (`task.execute`); `task.author` dispatches no slice, since the orchestrator writes each row's prompt itself. It **never commits** (no git write at all), is **never a review backend**, is **never a bridge substitute**, and is **never dispatched for read-only work** — a sweep, an inventory or a review rides a read-only vehicle instead.
16
16
 
17
- **Its readiness is the vehicle FILE.** `surveyExecutorVehicle` answers exactly one of four states: **`placed`** (bytes equal to the body derived from `docs/ai/vehicles.json` at `.claude/agents/executor.md`), **`customized`** (a readable regular file whose frontmatter names `executor` and whose tools are not read-only), **`unusable`** (a symlink, a non-regular or unreadable file, one failing that check, or an unreadable `docs/ai/vehicles.json` — with the reason), **`missing`**. `placed` and `customized` are dispatchable; on `unusable` or `missing` a `subagent` slot **degrades to Solo** with a reason naming this mode's apply command (and `docs/ai/vehicles.json` when that file is unreadable). `/agent-workflow-kit status` shows the state in its `agents` block and the deployment advisor raises it when a configured slot names `subagent` and the vehicle is `unusable` or `missing` — that item is **`executor-vehicle`** (attention-class: a configured declaration that is broken). It yields to the `agents` key's `agents.not-current`, which writes the executor in a placed component — a regular executor whose bytes differ, the check failing or not — so the two never render for one tree; over a component not placed the `agents` offer places the executor and `executor-vehicle` names the solo degrade beside it. It is a claim about the FILE, never about the host: a Claude Code lane, like this mode itself.
17
+ **The author vehicle** (`author`, `opus` / `high`) has `Read, Grep, Glob, Write, Edit` and no shell. It drafts a plan or a contract from the orchestrator's brief (`plan-authoring.author`), folds a round's findings into that plan or contract (`plan-authoring.fold`) or drafts the epic file from its brief (`epic.author`); the orchestrator reviews the returned draft as its own. It never runs commands, writes code or tests, serves as a reviewer or commits.
18
18
 
19
- **Every kit agent file is written current with no question.** The kit agent files are the five bundled names and every configured roster-derived lens `review-lens-<model>-<effort>.md`; an absent one is placed, one whose bytes differ is written with the body the kit writes for it, no copy kept, and a current one is left. Every other file under `.claude/agents/` is yours and no kit tool writes it: a vehicle of your own goes in `.claude/agents/<name>.local.md` with a `name:` of its own (Claude Code knows a subagent by its `name:` alone).
19
+ **Readiness is the vehicle FILE.** `surveyExecutorVehicle` answers exactly one of four states: **`placed`** (bytes equal to the body derived from `docs/ai/vehicles.json` at `.claude/agents/executor.md`), **`customized`** (a readable regular file whose frontmatter names `executor` and whose tools are not read-only), **`unusable`** (a symlink, a non-regular or unreadable file, one failing that check, or an unreadable `docs/ai/vehicles.json` — with the reason), **`missing`**. `placed` and `customized` are dispatchable; on `unusable` or `missing` a carry slot set to `subagent` **degrades to Solo** with a reason naming this mode's apply command (and `docs/ai/vehicles.json` when that file is unreadable). `surveyAuthorVehicle` answers `placed` (bytes at `.claude/agents/author.md` equal to the bundled template), `stale` (differing bytes with one tools line naming only the five tools), `widened` (other differing bytes, naming the tool or the absent, empty or repeated tools line), `unusable` (a link, non-regular or unreadable path or missing bundle template, with the reason), or `missing`. Only `placed` is ready; otherwise the author slot resolves to Solo naming the author vehicle and this mode's apply command. `/agent-workflow-kit status` shows both states in its `agents` block; the deployment advisor raises **`executor-vehicle`** (attention: a configured declaration that is broken) when a slot names `subagent` and its role's vehicle is not ready. It yields to `agents.not-current`, which writes missing or differing regular kit agent files in a placed component, including a regular executor whose bytes differ, the check failing or not. Over a component not placed, the `agents` offer places the vehicles and `executor-vehicle` names the solo degrade beside it. Readiness is a claim about the FILE, never the host: Claude Code loads agent files at session start, so a placed or rewritten author vehicle acts from the next session. Dispatch only when this session's agent list shows `author` with exactly the five tools; otherwise carry the slice solo and say so, never on another subagent.
20
+
21
+ **Every kit agent file is written current with no question.** The kit agent files are the bundled names and every configured roster-derived lens `review-lens-<model>-<effort>.md`; an absent one is placed, one whose bytes differ is written with the body the kit writes for it, no copy kept, and a current one is left. Every other file under `.claude/agents/` is yours and no kit tool writes it: a vehicle of your own goes in `.claude/agents/<name>.local.md` with a `name:` of its own (Claude Code knows a subagent by its `name:` alone).
20
22
 
21
23
  Run `node ${CLAUDE_SKILL_DIR}/tools/cheap-agents.mjs [--dry-run | --apply] [--cwd <dir>]`:
22
24