@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
@@ -34,6 +34,7 @@ import { readFileSync, readdirSync, lstatSync, existsSync, statSync } from 'node
34
34
  import { homedir, hostname } from 'node:os';
35
35
  import { dirname, join, resolve, sep } from 'node:path';
36
36
  import { fileURLToPath } from 'node:url';
37
+ import { DOCS_TREE, GATES, LANES, STAGE_GUARD_HOOK } from '../references/scripts/shared/index.mjs';
37
38
  import {
38
39
  preflightVelocityProfile,
39
40
  planVelocityProfile,
@@ -49,9 +50,11 @@ import { deriveDoctorPlan, TRUSTED_DIRS } from './autonomy-doctor.mjs';
49
50
  import { LANE_KIT, laneOf, applySlot, consoleArgv } from './write-lanes.mjs';
50
51
  import { STATE_BLOCK_HOOK_COMMAND, STATE_BLOCK_HOOK_FILE_REL, STATE_BLOCK_HOOK_RUNTIME, isStopHookWired, writeStateBlockHook } from './state-block-hook.mjs';
51
52
  import { HOOK_FILE_REL, HOOKS_DIR, writeGateHook } from './gate-hook.mjs';
53
+ import { isStageGuardWired, writeStageGuard } from './stage-write-guard/index.mjs';
52
54
  import { detectBackends } from './detect-backends.mjs';
53
55
  import { isDirectRun } from './direct-run.mjs';
54
56
  import { ACTIVITIES, resolveActivityRecipe, composeReadiness, safeLine } from './recipes.mjs';
57
+ import { AUTHOR_ROLE, CARRY_ROLE, slotRole } from './carriers.mjs';
55
58
  import { surveyFamily, surveyGateHook } from './family-registry.mjs';
56
59
  import { probeSandboxMasks, needsMasksApply, patternToRel } from './sandbox-masks.mjs';
57
60
  import { SKIP_REASON_CAP, composeSkip, renderSkip } from './advisor-skip/index.mjs';
@@ -88,7 +91,7 @@ import { ATTRIBUTION_KEY, LEGACY_ATTRIBUTION_KEY, attributionHidesText, effectiv
88
91
  import { planGlobalRemoval } from './hide-footprint.mjs';
89
92
  import { readDeployedScripts, INSTALLER_REL, NODE_EVIDENCE, probeNodeEvidence } from './node-evidence.mjs';
90
93
  // The vehicle READINESS comes from the read-only half — the same survey `recipes` and `status` read.
91
- import { surveyExecutorVehicle, readExecutorPosture, agentsAccepted, readStamp, readFsDeps, AGENTS_DIR, WORKFLOW_STAMP, EXPECTED_WORKFLOW_VERSION } from './cheap-agents-read.mjs';
94
+ import { surveyExecutorVehicle, surveyAuthorVehicle, readExecutorPosture, agentsAccepted, readStamp, readFsDeps, AGENTS_DIR, AUTHOR_VEHICLE, WORKFLOW_STAMP, EXPECTED_WORKFLOW_VERSION } from './cheap-agents-read.mjs';
92
95
  // The ack store's path, keys, lane registry, fingerprint and guarded reader live in their own leaf
93
96
  // (contract: kit/ack-store) — `status` reads the same store, and a second copy is what drifts.
94
97
  import {
@@ -137,7 +140,7 @@ const LAYOUT_RECORD_RECIPE = 'the hook is per clone and the config per branch: a
137
140
  const REASON_AUTHOR_RECIPE = 'the reason is yours to write, with no question to the user: where you made the growth, say why this size is accepted; where an entry grew before this write (a raise after the schema move, a teammate\'s growth), write that it grew before this write and its cause was not recorded';
138
141
  const SOURCE_SIZE_KEPT_WHAT = 'no source-size gate is declared — the size record is kept as it is; declaring the gate adds the size check to the gate matrix';
139
142
  const LAYOUT_HELD = {
140
- stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014 record that growth first with the reasoned --write-baseline its stop names, then re-run',
143
+ stops: () => 'the source-size check stops on this tree, so a layout record or layout line not yet in place waits \u2014 answer the size stop first, then re-run',
141
144
  'store-root': ({ root }) => `the source-size config declares the root "${root}" at or inside the spec store docs/ai/specs \u2014 the layout record starts once that root is declared outside it`,
142
145
  };
143
146
  // ── the section contract tokens (doc-parity-bound in upgrade.md + the mode doc) ────────────────
@@ -206,6 +209,8 @@ export const SEVERITIES = Object.freeze({
206
209
  'read-lane': SEVERITY_OPTIONAL,
207
210
  'state-block': SEVERITY_OPTIONAL,
208
211
  'state-block.not-current': SEVERITY_OPTIONAL,
212
+ 'stage-guard': SEVERITY_OPTIONAL,
213
+ 'stage-guard.not-current': SEVERITY_OPTIONAL,
209
214
  'mcp-channel': SEVERITY_OPTIONAL,
210
215
  'mcp-channel.differing': SEVERITY_ATTENTION,
211
216
  agents: SEVERITY_OPTIONAL,
@@ -302,9 +307,11 @@ export const WHATS = Object.freeze({
302
307
  'read-lane': 'the gate hook is wired but the read-only compound lane is off — pipes/chains of seeded reads still prompt one by one',
303
308
  'state-block': 'nothing checks the closing state block — a turn that ends on «nothing needed from you», or on a promise it never started, passes unseen',
304
309
  'state-block.not-current': `${STATE_BLOCK_HOOK_FILE_REL} is absent or differs from the body the kit writes for it — written with that body, with no question`,
310
+ 'stage-guard': 'refuse a code or test write through the edit tools while the recorded stage writes no code',
311
+ 'stage-guard.not-current': `${STAGE_GUARD_HOOK} is absent or differs from the body the kit writes for it — written with that body, with no question`,
305
312
  'mcp-channel': "the kit's read-only MCP server is not registered here — path questions and literal searches stay shell strings",
306
313
  'mcp-channel.differing': 'an "{server}" MCP entry is already declared here and DIFFERS from the registration this kit copy would write',
307
- agents: '{n} bundled subagent vehicle(s) not placed (Claude Code) — {ro} read-only, {ex} the full-tool executor; the apply PREVIEWS first',
314
+ agents: '{n} bundled subagent vehicle(s) not current (Claude Code) — {ro} read-only, {au} author, {ex} full-tool executor; the apply PREVIEWS first',
308
315
  'agents.not-current': '{n} kit agent file(s) in .claude/agents/ not current — each is written with the body the kit writes for it, with no question',
309
316
  'executor-vehicle': '{n} slot(s) configured subagent but the executor vehicle is {state}{reason} — every such slot runs solo until it is usable',
310
317
  attribution: 'AGENTS.md says attribution off but .claude/settings.json does not hide the harness trailer and PR text',
@@ -364,15 +371,16 @@ export const BENEFITS = Object.freeze({
364
371
  'review-recipe': 'recipe coverage — the review AND execution recipes you configured actually run instead of silently degrading',
365
372
  'gates-declaration': 'velocity — your project’s gates run as ONE declared batch with a PASS/FAIL table',
366
373
  'gates-inert': 'honest gates — the declared matrix verifies your project instead of reporting green over a check that ran nothing',
367
- 'source-size': 'maintainability — a module you can hold whole stays reviewable, and size drift becomes recorded, reasoned debt',
374
+ 'source-size': 'maintainability — a module you can hold whole stays reviewable, and a justified size becomes a recorded exception with its reason',
368
375
  'gate-hook': 'velocity — your own declared gate commands auto-approve byte-exactly (opt-in PreToolUse hook)',
369
376
  'commit-guard': 'integrity — commits require the ONE green --final receipt at the exact staged fingerprint (consented pre-commit arm)',
370
377
  'hook-checks': 'enforcement — every commit runs the checks armed here, so their findings stop the commit',
371
378
  enforcement: 'enforcement — bundled checks and the pre-commit hook keep caps, archives, and the generated index current',
372
379
  'read-lane': 'velocity — pipes/chains of your seeded read-only commands auto-approve instead of prompting (opt-in, conservatively classified)',
373
380
  'state-block': 'no silent stalls — a turn ending on «you are not needed», or on work it never started, warns at once instead of waiting to be spotted',
381
+ 'stage-guard': 'prevention — a stage that writes no code cannot write it through the edit tools',
374
382
  'mcp-channel': 'velocity — path facts and literal searches arrive as typed tool calls whose arguments are JSON fields, never a shell string',
375
- agents: 'cost and quiet — cheap-model mechanical work, no shell on a read-only vehicle (no prompt flood); the executor carries slices you verify',
383
+ agents: 'cost and quiet — cheap-model mechanical work, no shell on a read-only vehicle or the author; the executor carries slices you verify',
376
384
  'executor-vehicle': 'carrier readiness — a slot you configured subagent dispatches the subagent it names instead of silently running solo',
377
385
  attribution: 'attribution — the harness adds no Co-Authored-By trailer, PR text or session link, as your AGENTS.md block requires',
378
386
  'footprint-global': 'hygiene — the legacy machine-global excludes stop ignoring kit paths in every other repository on this host',
@@ -390,8 +398,9 @@ export const VARIANT_BENEFITS = Object.freeze({
390
398
  'agents.not-current': 'currency — each kit agent file carries the body the kit writes for it today, model and effort where docs/ai/vehicles.json names them',
391
399
  'gate-hook.not-current': HOOK_CURRENCY_BENEFIT,
392
400
  'state-block.not-current': HOOK_CURRENCY_BENEFIT,
401
+ 'stage-guard.not-current': HOOK_CURRENCY_BENEFIT,
393
402
  'jev-skill.not-current': "currency — every agent skill root the kit fills holds the vendor skill at the kit's pin once a copy is placed",
394
- 'source-size.layout': 'layout — piles past the layout limits become recorded, reasoned debt, so the commit hook can judge new ones once its layout line is armed',
403
+ 'source-size.layout': 'layout — justified piles past the layout limits become recorded exceptions with their reasons, so the commit hook can judge new ones once its layout line is armed',
395
404
  'source-size.piles': 'layout — each recorded pile gets a queue row that plans its cleanup, so the debt is ordered work in the queue, not only a record',
396
405
  });
397
406
 
@@ -434,6 +443,7 @@ export const OPT_IN_CAPABILITIES = Object.freeze([
434
443
  { id: 'attribution', mode: 'bootstrap', advisorKey: 'attribution' },
435
444
  { id: 'footprint-global', mode: 'bootstrap', advisorKey: 'footprint-global' },
436
445
  { id: 'state-block', mode: 'state-block-guard', advisorKey: 'state-block' },
446
+ { id: 'stage-guard', mode: 'hook', advisorKey: 'stage-guard' },
437
447
  { id: 'sandbox-masks', mode: 'sandbox-masks', advisorKey: 'sandbox-masks' },
438
448
  { id: 'mcp-channel', mode: 'mcp', advisorKey: 'mcp-channel' },
439
449
  { id: 'worktrees-dir', mode: 'worktrees', advisorKey: 'worktrees-dir' },
@@ -606,7 +616,7 @@ const probeReviewRecipe = ({ root, deps, add, skip }) => {
606
616
  const degraded = [];
607
617
  for (const [activity, def] of Object.entries(ACTIVITIES)) {
608
618
  for (const slot of Object.keys(def.slots)) {
609
- if (config?.[activity]?.[slot] === 'subagent') continue; // the executor vehicle has its own probe
619
+ if (config?.[activity]?.[slot] === 'subagent') continue; // the subagent vehicles have their own probe
610
620
  const r = resolveActivityRecipe({ config, readiness, activity, slot });
611
621
  if (r.degradedFrom) degraded.push(`${activity}.${slot}: configured ${r.degradedFrom} degrades to ${r.recipe} (${r.reason})`);
612
622
  }
@@ -982,7 +992,7 @@ const probeCommitGuard = ({ root, deps, add, skip }) => {
982
992
  const read = deps.readFile ?? readFileSync;
983
993
  const gatesRaw = (() => {
984
994
  try {
985
- return String(read(join(root, 'docs', 'ai', 'gates.json'), 'utf8'));
995
+ return String(read(join(root, GATES), 'utf8'));
986
996
  } catch {
987
997
  return null;
988
998
  }
@@ -1010,7 +1020,7 @@ const probeCommitGuard = ({ root, deps, add, skip }) => {
1010
1020
  const HOOK_CHECK_NAMES = { rules: 'project-rules check', layout: 'layout check', both: 'project-rules and layout checks' };
1011
1021
  const probeHookChecks = ({ root, deps, add, skip, shared }) => {
1012
1022
  try {
1013
- if (!(deps.exists ?? existsSync)(join(root, 'docs', 'ai'))) return;
1023
+ if (!(deps.exists ?? existsSync)(join(root, DOCS_TREE))) return;
1014
1024
  const unsafe = unsafeToolsPath(HERE);
1015
1025
  if (unsafe !== null) throw new Error(unsafe);
1016
1026
  const hook = readHookState(root, deps);
@@ -1046,7 +1056,7 @@ const readEnforcementNode = (path, lstat) => {
1046
1056
  // a throw names the skip.
1047
1057
  const enforcementOffer = (root, deps) => {
1048
1058
  const lstat = deps.lstat ?? lstatSync;
1049
- const docsAi = join(root, 'docs', 'ai');
1059
+ const docsAi = join(root, DOCS_TREE);
1050
1060
  const docsAiNode = readEnforcementNode(docsAi, lstat);
1051
1061
  if (docsAiNode === null) return false;
1052
1062
  if (!docsAiNode.isDirectory()) throw new Error(`${docsAi} is not a plain directory`);
@@ -1116,16 +1126,31 @@ const probeStateBlockHook = ({ root, deps, add, skip }) => {
1116
1126
  const local = readSettingsFile(join(root, SETTINGS_LOCAL_FILE), { ...deps, cwd: root });
1117
1127
  if (isStopHookWired(project.data) || isStopHookWired(local.data)) {
1118
1128
  probeKitHook({ key: 'state-block', write: writeStateBlockHook, rel: STATE_BLOCK_HOOK_FILE_REL, root, deps, add });
1119
- return;
1129
+ } else {
1130
+ add(
1131
+ 'state-block',
1132
+ fillTemplate(WHATS['state-block'], {}),
1133
+ `node ${q(toolPath('state-block-hook.mjs'))} --apply --cwd ${q(root)}`,
1134
+ );
1120
1135
  }
1121
- add(
1122
- 'state-block',
1123
- fillTemplate(WHATS['state-block'], {}),
1124
- `node ${q(toolPath('state-block-hook.mjs'))} --apply --cwd ${q(root)}`,
1125
- );
1126
1136
  } catch (err) {
1127
1137
  skip('state-block', err);
1128
1138
  }
1139
+ offerStageGuard({ root, deps, add, skip });
1140
+ };
1141
+
1142
+ const offerStageGuard = ({ root, deps, add, skip }) => {
1143
+ try {
1144
+ const project = readSettingsFile(join(root, SETTINGS_FILE), { ...deps, cwd: root });
1145
+ const local = readSettingsFile(join(root, SETTINGS_LOCAL_FILE), { ...deps, cwd: root });
1146
+ if (isStageGuardWired(project.data) || isStageGuardWired(local.data)) {
1147
+ probeKitHook({ key: 'stage-guard', write: writeStageGuard, rel: STAGE_GUARD_HOOK, root, deps, add });
1148
+ return;
1149
+ }
1150
+ add('stage-guard', fillTemplate(WHATS['stage-guard'], {}), formsApply('stage-guard', root));
1151
+ } catch (err) {
1152
+ skip('stage-guard', err);
1153
+ }
1129
1154
  };
1130
1155
 
1131
1156
  // The cheap-agents offer (OPT-IN-SHIPS-INVISIBLE). This item exists because the coverage registry
@@ -1160,7 +1185,8 @@ const probeCheapAgents = ({ root, deps, add, skip, shared }) => {
1160
1185
  const bundled = new Set(readBundledAgents(deps).map((template) => template.name));
1161
1186
  const toPlace = planned.filter((item) => bundled.has(item.name));
1162
1187
  const executors = toPlace.filter((item) => item.name === EXECUTOR_VEHICLE).length;
1163
- add('agents', fillTemplate(WHATS.agents, { n: toPlace.length, ex: executors, ro: toPlace.length - executors }),
1188
+ const authors = toPlace.filter((item) => item.name === AUTHOR_VEHICLE).length;
1189
+ add('agents', fillTemplate(WHATS.agents, { n: toPlace.length, ex: executors, au: authors, ro: toPlace.length - executors - authors }),
1164
1190
  `node ${q(toolPath('cheap-agents.mjs'))} --cwd ${q(root)}`, 'agents',
1165
1191
  `hidden-mode deployments only: after the --apply the preview prints, run node ${q(toolPath('hide-footprint.mjs'))} --dir ${q(root)} --reconcile so the placed .claude/agents/ stays invisible to git status`,
1166
1192
  );
@@ -1169,11 +1195,32 @@ const probeCheapAgents = ({ root, deps, add, skip, shared }) => {
1169
1195
  }
1170
1196
  };
1171
1197
 
1172
- // The subagent carrier's ONE instrument (contract: kit/carriers). Neither neighbour can report this
1198
+ // The subagent carrier's instrument per role (contract: kit/carriers). Neither neighbour can report this
1173
1199
  // state: `probeReviewRecipe` skips a slot configured `subagent` by construction, and the `agents` key
1174
1200
  // above names files to place or write, never a configured slot that runs solo. It yields to
1175
- // `agents.not-current`, whose apply writes the executor (the frozen order runs `agents` first).
1201
+ // `agents.not-current`, whose apply writes the vehicles (the frozen order runs `agents` first).
1176
1202
  const VEHICLE_BROKEN_STATES = Object.freeze(['missing', 'unusable']);
1203
+ const VEHICLES_SOLO_LEAD = 'slot(s) configured subagent run solo — ';
1204
+
1205
+ const formatVehicleWhat = (broken) => {
1206
+ const count = broken.reduce((total, vehicle) => total + vehicle.count, 0);
1207
+ if (broken.every((vehicle) => vehicle.role === CARRY_ROLE)) {
1208
+ const { state, reason } = broken[0];
1209
+ const room = templateBudget(WHATS['executor-vehicle']) - String(count).length - state.length - 2;
1210
+ return fillTemplate(WHATS['executor-vehicle'], {
1211
+ n: count,
1212
+ state,
1213
+ reason: reason && room > 0 ? `: ${truncatedTo(reason, room)}` : '',
1214
+ });
1215
+ }
1216
+ const prefix = `${count} ${VEHICLES_SOLO_LEAD}`;
1217
+ const labels = broken.map(({ role, state }) => `${role === AUTHOR_ROLE ? 'author' : 'executor'} vehicle is ${state}`);
1218
+ const reasons = broken.filter(({ reason }) => reason).length;
1219
+ const room = ITEM_LINE_CAP - prefix.length - labels.join('; ').length - 2 * reasons;
1220
+ const reasonBudget = reasons ? Math.floor(room / reasons) : 0;
1221
+ return prefix + broken.map(({ reason }, index) =>
1222
+ labels[index] + (reason && reasonBudget > 0 ? `: ${truncatedTo(reason, reasonBudget)}` : '')).join('; ');
1223
+ };
1177
1224
 
1178
1225
  // The writer's plain dry run, the call the `agents` key makes: its refusal is the last precondition.
1179
1226
  const writerBlock = (root, deps) => {
@@ -1193,11 +1240,20 @@ const probeExecutorVehicle = ({ root, deps, add, skip, shared }) => {
1193
1240
  // never an item computed over a shape nothing accepted.
1194
1241
  const { config } = loadConfig(root, deps.readFile ?? readFileSync, deps.lstat ?? lstatSync);
1195
1242
  const configured = Object.entries(ACTIVITIES).flatMap(([activity, def]) =>
1196
- Object.keys(def.slots).filter((slot) => config?.[activity]?.[slot] === 'subagent'));
1197
- if (configured.length === 0) return;
1198
- const survey = (deps.surveyVehicle ?? surveyExecutorVehicle)(root, deps);
1199
- if (!VEHICLE_BROKEN_STATES.includes(survey.state) || shared?.agentsNotCurrent) return;
1200
- const reason = safeLine(survey.reason ?? '');
1243
+ Object.keys(def.slots).filter((slot) => config?.[activity]?.[slot] === 'subagent').map((slot) => slotRole(activity, slot)));
1244
+ if (configured.length === 0 || shared?.agentsNotCurrent) return;
1245
+ const broken = [];
1246
+ const authorCount = configured.filter((role) => role === AUTHOR_ROLE).length;
1247
+ if (authorCount > 0) {
1248
+ const survey = (deps.surveyAuthorVehicle ?? surveyAuthorVehicle)(root, deps);
1249
+ if (survey.state !== 'placed') broken.push({ role: AUTHOR_ROLE, count: authorCount, state: survey.state, reason: safeLine(survey.reason ?? '') });
1250
+ }
1251
+ const carryCount = configured.filter((role) => role === CARRY_ROLE).length;
1252
+ if (carryCount > 0) {
1253
+ const survey = (deps.surveyVehicle ?? surveyExecutorVehicle)(root, deps);
1254
+ if (VEHICLE_BROKEN_STATES.includes(survey.state)) broken.push({ role: CARRY_ROLE, count: carryCount, state: survey.state, reason: safeLine(survey.reason ?? '') });
1255
+ }
1256
+ if (broken.length === 0) return;
1201
1257
  const { posture, reason: settingsReason } = readExecutorPosture(root, deps);
1202
1258
  const stamp = readStamp(join(root, WORKFLOW_STAMP), readFsDeps(deps));
1203
1259
  const preconditions = [
@@ -1209,15 +1265,10 @@ const probeExecutorVehicle = ({ root, deps, add, skip, shared }) => {
1209
1265
  // the posture is already unreadable so that reason is named once.
1210
1266
  const blocked = posture === null ? null : writerBlock(root, deps);
1211
1267
  if (blocked) preconditions.push(`${blocked} — fix that`);
1212
- const room = templateBudget(WHATS['executor-vehicle']) - String(configured.length).length - survey.state.length - 2;
1213
1268
  add(
1214
1269
  'executor-vehicle',
1215
- fillTemplate(WHATS['executor-vehicle'], {
1216
- n: configured.length,
1217
- state: survey.state,
1218
- reason: reason && room > 0 ? `: ${truncatedTo(reason, room)}` : '',
1219
- }),
1220
- // The writer places a missing vehicle and writes a placed executor whose bytes differ from the derived body (an invalid
1270
+ formatVehicleWhat(broken),
1271
+ // The writer places a missing vehicle and writes a placed author or executor whose bytes differ from the kit's body (an invalid
1221
1272
  // frontmatter or read-only tools included), so those states need no precondition; every precondition above is a refusal the apply would meet.
1222
1273
  `node ${q(toolPath('cheap-agents.mjs'))} --apply --cwd ${q(root)}`,
1223
1274
  'executor-vehicle',
@@ -1295,7 +1346,7 @@ export const recipeFingerprint = ({ hosts, dirs, home }) => {
1295
1346
 
1296
1347
  // The opt-in read-lane toggle file (AD-055 Part II) — the SAME kit-owned docs/ai/lanes.json the
1297
1348
  // placed hook reads live. The read-lane item offers to enable it once the hook is wired.
1298
- export const LANES_FILE = 'docs/ai/lanes.json';
1349
+ export const LANES_FILE = LANES;
1299
1350
  export const READ_LANE_KEY = 'readLane';
1300
1351
 
1301
1352
  // The state-block-guard wiring the advisor looks for is the writer leaf's own rule (any Stop entry of
@@ -1332,7 +1383,7 @@ const readReadLaneToggle = (root, deps) => {
1332
1383
  // D3: the risk-marked keys — every key here has a per-item posture note in the mode doc, surfaced
1333
1384
  // at the consent moment; the static contract test asserts EXACT bidirectional coverage
1334
1385
  // (risk-marked keys == mode-doc note keys — a dropped note goes red, not silent).
1335
- export const RISK_NOTED_KEYS = Object.freeze(['bridge-tier', 'read-lane', 'worktrees-dir', 'gates-inert', 'source-size', 'gate-hook', 'mcp-channel', 'spec-adoption', 'enforcement', 'hook-checks', 'profile-gap', 'jev-connect', 'jev-skill', 'attribution', 'footprint-global']);
1386
+ export const RISK_NOTED_KEYS = Object.freeze(['bridge-tier', 'read-lane', 'worktrees-dir', 'gates-inert', 'source-size', 'gate-hook', 'stage-guard', 'mcp-channel', 'spec-adoption', 'enforcement', 'hook-checks', 'profile-gap', 'jev-connect', 'jev-skill', 'attribution', 'footprint-global']);
1336
1387
 
1337
1388
  // The feature-spec layer's adoption state (contract: kit/spec-adoption). The canon lets a plan cite
1338
1389
  // zero governing specs while a project adopts the layer, and nothing ever said whether adoption had
@@ -4,11 +4,11 @@
4
4
  // No CLI (refuseDirectRun); every read goes through injected deps; nothing here writes.
5
5
  import { join } from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
+ import { PROFILE_DECLINES } from '../references/scripts/shared/index.mjs';
7
8
  import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
8
9
  import { refuseDirectRun } from './direct-run.mjs';
9
10
 
10
11
  const PROFILE_PATH = fileURLToPath(new URL('../references/reference-profile.json', import.meta.url));
11
- const DECLINES_REL = 'docs/ai/profile-declines.json';
12
12
  const PROFILE_KEYS = ['items', 'lineage', 'name', 'schema'];
13
13
  const ITEM_KEYS = ['has', 'id', 'story'];
14
14
  const RECORD_KEYS = ['declined', 'schema'];
@@ -53,7 +53,7 @@ export const readShippedProfile = (deps = {}) => {
53
53
  };
54
54
 
55
55
  export const readDeclines = (root, deps = {}) => {
56
- const read = readRegularFileNoFollow(join(root, DECLINES_REL), deps);
56
+ const read = readRegularFileNoFollow(join(root, PROFILE_DECLINES), deps);
57
57
  if (read.outcome === ABSENT) return { absent: true };
58
58
  if (read.outcome !== OK) {
59
59
  return { refusal: read.className === SYMLINK_CLASS ? 'declines-symlink' : 'declines-unreadable' };
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { BLOCK_TITLES, SETTINGS_LABELS, glyphsFor, NO_DEPLOYMENT } from './presentation.mjs';
11
11
  import { describeAdoption } from './spec-adoption.mjs';
12
+ import { AUTHOR_ROLE } from './carriers.mjs';
12
13
 
13
14
  const MEMBER_COL = 20;
14
15
  const VERSION_COL = 12;
@@ -22,7 +23,7 @@ const ACTIONABLE_ADR_LAYOUTS = Object.freeze(['old', 'old-unrotated']);
22
23
 
23
24
  const DEGRADE_ARROW = '←';
24
25
  const EMPTY_CELL = '—';
25
- const UNKNOWN_EXECUTOR = 'unknown';
26
+ const UNKNOWN_VEHICLE = 'unknown (the installed kit predates the field)';
26
27
 
27
28
  const SGR = Object.freeze({ bold: '\x1b[1m', reset: '\x1b[0m' });
28
29
  const ANSI_RE = /\x1b\[[0-9;]*m/g;
@@ -127,7 +128,7 @@ const renderSettings = (vm, { color, glyph }) => {
127
128
  else if (s.recipes) {
128
129
  const rows = s.recipes.pairs.map((p) => {
129
130
  const source = p.source ? ` (${p.source})` : '';
130
- const recovery = p.degradedFrom === 'subagent' ? ' — runs solo until the executor vehicle is usable (/agent-workflow-kit agents)' : '';
131
+ const recovery = p.degradedFrom === 'subagent' ? ` — runs solo until the ${p.role === AUTHOR_ROLE ? 'author' : 'executor'} vehicle is usable (/agent-workflow-kit agents)` : '';
131
132
  const degraded = p.degradedFrom ? ` ${DEGRADE_ARROW} degraded from ${p.degradedFrom}${recovery}` : '';
132
133
  return `${p.key}: ${p.recipe}${source}${degraded}`;
133
134
  });
@@ -150,16 +151,21 @@ const renderSettings = (vm, { color, glyph }) => {
150
151
  lines.push(` ${pad(SETTINGS_LABELS.velocity, SETTINGS_COL)}defaultMode=${String(s.velocity.defaultMode)} · allow project/local=${s.velocity.allow.project}/${s.velocity.allow.local}`);
151
152
  }
152
153
  // cheap agents — the kit-placed .claude/agents/ vehicles: placed count vs the bundle, then the
153
- // split the subagent carrier turns on — the read-only vehicles and the ONE executor, whose state
154
- // decides whether a slot configured `subagent` can ride it (an unusable one carries its reason).
154
+ // split the subagent carrier turns on — the read-only vehicles, the author and the executor, whose states
155
+ // decide whether a slot configured `subagent` can ride its role's vehicle (an unusable one carries its reason).
155
156
  if (s.agents?.error) {
156
- const partial = s.agents.executor ? ` — executor ${s.agents.executor}${s.agents.executorReason ? ` (${s.agents.executorReason})` : ''}` : '';
157
- lines.push(` ${pad(SETTINGS_LABELS.agents, SETTINGS_COL)}error: ${s.agents.error}${partial}`);
157
+ const partial = [
158
+ s.agents.author ? `author ${s.agents.author}${s.agents.authorReason ? ` (${s.agents.authorReason})` : ''}` : '',
159
+ s.agents.executor ? `executor ${s.agents.executor}${s.agents.executorReason ? ` (${s.agents.executorReason})` : ''}` : '',
160
+ ].filter(Boolean).join(', ');
161
+ lines.push(` ${pad(SETTINGS_LABELS.agents, SETTINGS_COL)}error: ${s.agents.error}${partial ? ` — ${partial}` : ''}`);
158
162
  }
159
163
  else if (s.agents) {
164
+ const authorReason = s.agents.authorReason ? ` (${s.agents.authorReason})` : '';
160
165
  const reason = s.agents.executorReason ? ` (${s.agents.executorReason})` : '';
161
- const executor = s.agents.executor == null ? `${UNKNOWN_EXECUTOR} (the installed kit predates the field)` : `${s.agents.executor}${reason}`;
162
- lines.push(` ${pad(SETTINGS_LABELS.agents, SETTINGS_COL)}${s.agents.placed}/${s.agents.bundled} placed — ${s.agents.readOnly} read-only, executor ${executor}`);
166
+ const author = s.agents.author == null ? UNKNOWN_VEHICLE : `${s.agents.author}${authorReason}`;
167
+ const executor = s.agents.executor == null ? UNKNOWN_VEHICLE : `${s.agents.executor}${reason}`;
168
+ lines.push(` ${pad(SETTINGS_LABELS.agents, SETTINGS_COL)}${s.agents.placed}/${s.agents.bundled} placed — ${s.agents.readOnly} read-only, author ${author}, executor ${executor}`);
163
169
  }
164
170
  // gate hook — the opt-in PreToolUse gate-approval hook: wired / file placed / declaration present /
165
171
  // declared gate count (null → '?' — unknown is shown as unknown, never as a number).
@@ -22,6 +22,8 @@ export const lexicalRepoRelative = (rel) => {
22
22
  export const RESERVED_DIR = '.agent-workflow';
23
23
  export const NEVER_WALKED = Object.freeze(['.git', 'node_modules', RESERVED_DIR]);
24
24
 
25
+ export const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\/]/gu, '\\$&');
26
+
25
27
  // POSIX single-quote for pasteable command rendering (display only — never an execution boundary).
26
28
  export const shellQuoteArg = (s) => (/^[A-Za-z0-9_/.\-]+$/.test(s) ? s : `'${s.replace(/'/g, `'\\''`)}'`);
27
29
 
@@ -93,3 +95,85 @@ export const isSeedablePathToken = (token) =>
93
95
  !/\s/u.test(token) &&
94
96
  !hasShellMetacharacter(token) &&
95
97
  !PATH_BREAKING_CHARACTERS.some((ch) => token.includes(ch));
98
+
99
+ export const parseStrictJson = (text) => {
100
+ const source = String(text);
101
+ const cursor = { index: 0 };
102
+ const skipWhitespace = () => {
103
+ while (/\s/.test(source[cursor.index] ?? '')) cursor.index += 1;
104
+ };
105
+ const readString = () => {
106
+ const start = cursor.index;
107
+ cursor.index += 1;
108
+ while (cursor.index < source.length) {
109
+ if (source[cursor.index] === '\\') {
110
+ cursor.index += 2;
111
+ } else if (source[cursor.index] === '"') {
112
+ cursor.index += 1;
113
+ return JSON.parse(source.slice(start, cursor.index));
114
+ } else {
115
+ cursor.index += 1;
116
+ }
117
+ }
118
+ return null;
119
+ };
120
+ const childPath = (path, key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)
121
+ ? `${path}.${key}`
122
+ : `${path}[${JSON.stringify(key)}]`;
123
+ const scanValue = (path) => {
124
+ skipWhitespace();
125
+ if (source[cursor.index] === '{') {
126
+ cursor.index += 1;
127
+ skipWhitespace();
128
+ const seen = new Set();
129
+ if (source[cursor.index] === '}') {
130
+ cursor.index += 1;
131
+ return;
132
+ }
133
+ while (cursor.index < source.length) {
134
+ const key = readString();
135
+ if (seen.has(key)) throw new SyntaxError(`duplicate JSON key ${JSON.stringify(key)} at ${path}`);
136
+ seen.add(key);
137
+ skipWhitespace();
138
+ cursor.index += 1;
139
+ scanValue(childPath(path, key));
140
+ skipWhitespace();
141
+ if (source[cursor.index] === '}') {
142
+ cursor.index += 1;
143
+ return;
144
+ }
145
+ cursor.index += 1;
146
+ skipWhitespace();
147
+ }
148
+ return;
149
+ }
150
+ if (source[cursor.index] === '[') {
151
+ cursor.index += 1;
152
+ skipWhitespace();
153
+ if (source[cursor.index] === ']') {
154
+ cursor.index += 1;
155
+ return;
156
+ }
157
+ const position = { item: 0 };
158
+ while (cursor.index < source.length) {
159
+ scanValue(`${path}[${position.item}]`);
160
+ position.item += 1;
161
+ skipWhitespace();
162
+ if (source[cursor.index] === ']') {
163
+ cursor.index += 1;
164
+ return;
165
+ }
166
+ cursor.index += 1;
167
+ }
168
+ return;
169
+ }
170
+ if (source[cursor.index] === '"') {
171
+ readString();
172
+ return;
173
+ }
174
+ while (cursor.index < source.length && !/[\s,}\]]/.test(source[cursor.index])) cursor.index += 1;
175
+ };
176
+ // the duplicate scan tolerates malformed tails (EOF-safe returns); JSON.parse then rejects them
177
+ scanValue('$');
178
+ return JSON.parse(source);
179
+ };
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { realpathSync } from 'node:fs';
4
4
  import { isAbsolute, resolve, sep } from 'node:path';
5
- import { readShippedRobustnessLiterals, parseRobustTag } from './robustness-literals.mjs';
5
+ import { classIds, readShippedRobustnessLiterals, parseRobustTag } from './robustness-literals.mjs';
6
6
  import { checkPlanStructure, formatFindings, isSweep } from './plan-shape.mjs';
7
7
  import { expandSweepPaths } from './plan-shape-facts.mjs';
8
8
  import { readFileBytesNoFollowCapped } from './fs-read-nofollow.mjs';
@@ -13,6 +13,7 @@ const PLAN_READ_CAP = 1_048_576;
13
13
  const ROW_ID = /^[A-Za-z0-9._-]+$/u;
14
14
  const SEARCHABLE_KINDS = new Set(['env', 'flag', 'ref', 'syscall', 'errno', 'argv']);
15
15
  const SHIPPED_LIST_PATH = 'agent-workflow-kit/references/robustness-literals.json';
16
+ export const ROBUST_CLASS_CODE = 'robust-class';
16
17
  const USAGE = 'Usage: node robustness-brief.mjs --plan <plan> [--row <id>] [--coverage]';
17
18
  const usage = (message) => Object.assign(new Error(message), { usage: true });
18
19
  const isInside = (root, path) => path === root || path.startsWith(`${root}${sep}`);
@@ -123,19 +124,19 @@ export const renderCoverage = (rows, displayPath) => [
123
124
  : `| ${row.id} | ${renderCell(row.path)} | ${row.tagged.join(',') || '—'} | ${row.present.join(',') || '—'} | ${row.uncovered.join(',') || '—'} |`),
124
125
  ];
125
126
 
127
+ const renderStructuralRefusal = (shape, displayPath) => ({
128
+ code: 1,
129
+ lines: formatFindings(shape, escapeForDisplay(displayPath)).split('\n').map(escapeForDisplay),
130
+ });
131
+
126
132
  export const renderBrief = (planText, list, { row, displayPath }) => {
127
- const shape = checkPlanStructure(planText, {});
128
- if (shape.findings.length > 0) return { code: 1, lines: formatFindings(shape, escapeForDisplay(displayPath)).split('\n').map(escapeForDisplay) };
133
+ const shape = checkPlanStructure(planText, { robustClasses: classIds(list) });
134
+ if (shape.findings.length > 0) return renderStructuralRefusal(shape, displayPath);
129
135
  const classes = new Map(list.classes.map((entry) => [entry.id, entry]));
130
136
  const rows = shape.parsed.rows.filter((entry) => entry.valid).map((entry) => ({
131
137
  ...entry,
132
138
  robust: parseRobustTag(entry.responsibility),
133
139
  }));
134
- const refused = rows.find((entry) => entry.robust.refusal || entry.robust.classes.some((classId) => !classes.has(classId)));
135
- if (refused) {
136
- const reason = refused.robust.refusal ?? `unknown class ${refused.robust.classes.find((classId) => !classes.has(classId))}`;
137
- return { code: 1, lines: [`robustness-brief: ${refused.id}: robust-class — ${reason}`] };
138
- }
139
140
  const selected = row === null ? rows.filter((entry) => entry.robust.classes.length > 0) : rows.filter((entry) => entry.id === row);
140
141
  if (row !== null && selected.length === 0) return { code: 1, lines: [`robustness-brief: ${row}: row is absent`] };
141
142
  if (row !== null && selected[0].robust.classes.length === 0) return { code: 1, lines: [`robustness-brief: ${row}: row is untagged`] };
@@ -181,8 +182,10 @@ export const main = (argv = process.argv.slice(2), deps = {}) => {
181
182
  throw usage(`malformed-utf8 --plan ${parsed.plan}`);
182
183
  }
183
184
  const list = (deps.readList ?? readShippedRobustnessLiterals)();
184
- const brief = renderBrief(planText, list, { row: parsed.row, displayPath: parsed.plan });
185
- if (!parsed.coverage || checkPlanStructure(planText, {}).findings.length > 0) return brief;
185
+ if (!parsed.coverage) return renderBrief(planText, list, { row: parsed.row, displayPath: parsed.plan });
186
+ const shape = checkPlanStructure(planText, { robustClasses: classIds(list) });
187
+ const findings = shape.findings.filter(({ code }) => code !== ROBUST_CLASS_CODE);
188
+ if (findings.length > 0) return renderStructuralRefusal({ ...shape, findings }, parsed.plan);
186
189
  const sweepPaths = checkPlanStructure(planText, {}).parsed.rows
187
190
  .filter((entry) => entry.valid && isSweep(entry.path) && !isCoverageDocument(entry.path))
188
191
  .map((entry) => entry.path);
@@ -193,7 +196,7 @@ export const main = (argv = process.argv.slice(2), deps = {}) => {
193
196
  });
194
197
  if (coverage.refusal) {
195
198
  const { id, path, outcome, reason } = coverage.refusal;
196
- throw usage(reason === undefined ? `${id}: ${escapeForDisplay(path)} — ${outcome}` : `${id}: robust-class — ${reason}`);
199
+ throw usage(reason === undefined ? `${id}: ${escapeForDisplay(path)} — ${outcome}` : `${id}: ${ROBUST_CLASS_CODE} — ${reason}`);
197
200
  }
198
201
  const lines = [...renderCoverage(coverage.rows, parsed.plan), ...coverage.evidence.map(({ id, classId, literal }) => `${id}:${classId}:${literal}`)];
199
202
  return { code: coverage.evidence.length > 0 ? 1 : 0, lines };
@@ -14,9 +14,10 @@
14
14
  // second body here would be exactly the duplication that pin exists to prevent. `fs` is the shape
15
15
  // worktrees.mjs builds: { lstat, readdir, realpath, readFileNoFollow }.
16
16
  //
17
- // Node built-ins plus two pure leaves. No side effects on import; no CLI. Dependency-free, Node >= 22.
17
+ // Node built-ins, shared locations and two pure leaves. No side effects on import; no CLI. Dependency-free, Node >= 22.
18
18
 
19
19
  import { join } from 'node:path';
20
+ import { DOCS } from '../references/scripts/shared/index.mjs';
20
21
  import { PLANS_REL } from './plan-files.mjs';
21
22
  import { stop, handoffBasename, parseProvisionRecord, displayValue } from './worktrees-record.mjs';
22
23
 
@@ -100,7 +101,7 @@ export const classifyNodeNoFollow = (path, fs) => {
100
101
  // ANY stat failure (not just readdir) renders honestly — list must never crash on a bad node.
101
102
  export const scanPlansDir = ({ wtRoot, fs }) => {
102
103
  if (classifyNodeNoFollow(wtRoot, fs).kind !== 'plain-directory') return { state: 'unreadable' };
103
- const docs = classifyNodeNoFollow(join(wtRoot, 'docs'), fs);
104
+ const docs = classifyNodeNoFollow(join(wtRoot, DOCS), fs);
104
105
  if (docs.kind === 'absent') return { state: 'absent' };
105
106
  if (docs.kind !== 'plain-directory') return { state: 'unreadable' };
106
107
  const plans = classifyNodeNoFollow(join(wtRoot, PLANS_REL), fs);
@@ -32,8 +32,8 @@ export const PRIOR_FILES = Object.freeze([
32
32
  export const READER_PAIR = Object.freeze(['spec-schema.mjs', 'spec-schema.test.mjs']);
33
33
  export const CHECKER_PAIR = Object.freeze(['check-docs-size.mjs', 'check-docs-size.test.mjs']);
34
34
 
35
- // The hook installer and the two suites that test it beside it — written first, installer first, so a
36
- // stop partway never leaves a bundled suite beside a prior installer.
35
+ // The hook installer and the two suites that test it beside it form one set because a bundled suite
36
+ // fails inside the hook when paired with a prior installer.
37
37
  export const INSTALLER_SET = Object.freeze(['install-git-hooks.mjs', 'install-git-hooks.test.mjs', 'install-git-hooks-repo-exec.test.mjs']);
38
38
 
39
39
  const prior = (file, firstShipped, lastShipped, digest) => Object.freeze({ file, firstShipped, lastShipped, digest });
@@ -89,6 +89,7 @@ export const SCRIPT_PRIORS = Object.freeze([
89
89
  prior('migrate-gates.test.mjs', '8.1.5', '9.0.0', '8f99a2f65f1f3db0eb3464a0382c208ca5076388b6df0596cf099d53ab2a1f86'),
90
90
  prior('spec-schema.test.mjs', '8.7.0', '9.0.0', '6a602a93e9f9f21f0bc10c50e356de693936d3e204987efbab1a1d7674030498'),
91
91
  prior('markdown-blocks.mjs', '4.0.0', '9.0.0', '5a9fb45d4248c53dee9694b2d95c1cf98fe08a55c41429cf72826aa218f0ad2d'),
92
+ prior('spec-schema.mjs', '8.7.0', '9.0.0', 'ddc14a4c79498913977d6494f84e4b48348d0d2d7a415d84bb24334e24d3538f'),
92
93
  ]);
93
94
 
94
95
  export const digestOf = (bytes) => createHash('sha256').update(bytes).digest('hex');