@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,7 @@
1
1
  // spec:tier-guide — docs/ai/specs/kit/tier/tier-guide/index.md and its part guide-stages.md
2
2
  import { lstatSync } from 'node:fs';
3
3
  import { posix, resolve } from 'node:path';
4
+ import { DOCS_TREE } from '../references/scripts/shared/index.mjs';
4
5
  import { readRegularFileNoFollow } from './fs-read-nofollow.mjs';
5
6
  import { resolveGitLocation } from './git-env.mjs';
6
7
  import { EPICS_REL, readEpicStore } from './epic-store.mjs';
@@ -8,7 +9,7 @@ import { checkEpic } from './epic-shape.mjs';
8
9
  import { QUEUE_PATH, checkClaims, judgeClose, sweepSiblings } from './epic-shape-ledger.mjs';
9
10
  import { PLANS_REL, isScratchPlanName, plansInFlight, readPlanEntries } from './plan-files.mjs';
10
11
  import { readStoryLine } from './plan-shape-ownership.mjs';
11
- import { PLAN_HEADINGS, isSweep, parseLedger } from './plan-shape.mjs';
12
+ import { PLAN_HEADINGS, RETIRED_FORM_CODES, checkPlanStructure, isSweep, parseLedger, unique } from './plan-shape.mjs';
12
13
  import { expandSweepPaths } from './plan-shape-facts.mjs';
13
14
  import { withRepository } from './checkpoint-core.mjs';
14
15
  import { escapeForDisplay, isRenderableLine, shellQuoteArg } from './repo-lex.mjs';
@@ -24,7 +25,7 @@ const CR_END = /\r$/;
24
25
  const SPAN = /\{\{([\s\S]*?)\}\}/g;
25
26
  const PLAN_STEM = /^[A-Za-z0-9_-]+$/;
26
27
  const PLAN_TITLE = /^# Plan: (.+)$/;
27
- const DOCS_AI = 'docs/ai/';
28
+ const DOCS_AI = `${DOCS_TREE}/`;
28
29
  const PROMPT_PREFIX = `${PLANS_REL}/EXECUTE-PROMPT-`;
29
30
  const OID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
30
31
  const HEADER_CODES = new Set(['sibling-header', 'sibling-read']);
@@ -109,7 +110,19 @@ const readStore = (cwd) => {
109
110
  states: [...states, ...siblingStates.map((finding) => ({ finding }))] };
110
111
  };
111
112
 
112
- const planShape = (row, epicId) => `The shape: the title # Plan: and a name; the five headings; under Goal and boundary the line Story: ${row.id} of ${epicId} and a governing spec path under docs/ai/specs or the words not adopted; one ledger row per file in six fields (id, verb, path, responsibility, budget, anchor) — a create or modify row an anchor that resolves to one place and, with no declared source-size cap, the budget n/a, a delete row a dash (—) in budget and anchor; the total line last, its before figure the current lines of every deleted file and of every modify row with a numeric budget, so total: 0 → 0 lines when every row is a create or modify with the budget n/a; at least one - bullet under Verification.`;
113
+ const planShape = (row, epicId) => `The shape: the title # Plan: and a name; the five headings; under Goal and boundary the line Story: ${row.id} of ${epicId} and a governing spec path under docs/ai/specs or the words not adopted; one ledger row per file in five fields (id, verb, path, responsibility, anchor) and no total line; a create or modify row an anchor that resolves to one place, a delete row a dash (—) in its anchor; at least one - bullet under Verification.`;
114
+
115
+ const checkPlanPrerequisite = (text, parsed, rows, tools, path) => {
116
+ const retiredCodes = new Set(Object.values(RETIRED_FORM_CODES));
117
+ const retired = unique(checkPlanStructure(text, {}).findings.map(({ code }) => code).filter((code) => retiredCodes.has(code)));
118
+ if (rows.length > 0 && retired.length === 0) return null;
119
+ if (retired.length > 0) return state(READERS.ledger, path, `the Module ledger carries the old form: ${retired.join(', ')}`, tools.planCheck(path));
120
+ const ledger = parsed.document.headings.find(({ text }) => text === PLAN_HEADINGS[1]);
121
+ const verification = parsed.document.headings.find(({ text }) => text === PLAN_HEADINGS[2]);
122
+ const empty = ledger && verification && ledger.index < verification.index && parsed.entries.every(({ raw }) => !raw.trim());
123
+ const next = empty ? tools.planCheck(path, `add a ledger row to ${path}, then check the plan`) : tools.planCheck(path);
124
+ return state(READERS.ledger, path, 'the plan has no valid row in its Module ledger', next);
125
+ };
113
126
 
114
127
  // The Story line is read under Goal and boundary alone, as plan-shape reads it.
115
128
  const storyOf = ({ document }) => {
@@ -131,7 +144,7 @@ const readPlan = (cwd, tools, path) => {
131
144
  const rows = parsed.rows.filter((row) => row.valid);
132
145
  const ledger = rows.filter((row) => !row.path.startsWith(DOCS_AI)).map((row) => ({ ...row, prompt: `${PROMPT_PREFIX}${stem}-${row.id}${MARKDOWN}` }));
133
146
  const title = linesOf(read.text).map((line) => PLAN_TITLE.exec(line)?.[1]).find(Boolean) ?? null;
134
- return { path, story, hasRow: rows.length > 0, ledger, title, failure: null };
147
+ return { path, story, prerequisite: checkPlanPrerequisite(read.text, parsed, rows, tools, path), ledger, title, failure: null };
135
148
  } catch (error) {
136
149
  return refused(READERS.ledger, error.message);
137
150
  }
@@ -170,8 +183,8 @@ const judgeStory = (context, epicPath, epicId, row) => {
170
183
  return stateOf('S1', [tools.review(epicPath), action('write', `author the plan by hand at ${standIn}. ${planShape(row, epicId)}`)]);
171
184
  }
172
185
  const [plan] = own;
186
+ if (plan.prerequisite) return { state: plan.prerequisite };
173
187
  if (plan.shared) return {};
174
- if (!plan.hasRow) return { state: state(READERS.ledger, plan.path, 'the plan has no valid row in its Module ledger', tools.planCheck(plan.path, `add a ledger row to ${plan.path}, then check the plan`)) };
175
188
  const prompts = plan.ledger.map((ledgerRow) => ({ row: ledgerRow, ...readText(cwd, ledgerRow.prompt) }));
176
189
  const refused = prompts.find((prompt) => prompt.text === undefined && !prompt.absent);
177
190
  if (refused) return { state: state(READERS.prompt, refused.row.prompt, refused.cause) };
@@ -222,7 +235,7 @@ const readIndex = (context, held) => {
222
235
  };
223
236
 
224
237
  const leftoverActions = (context, plans) => {
225
- if (!context.index.ok || plans.some((plan) => plan.shared)) return [];
238
+ if (!context.index.ok || plans.some((plan) => plan.shared || plan.prerequisite)) return [];
226
239
  const removals = plans.map((plan) => {
227
240
  const prompts = plan.ledger.map((row) => row.prompt).filter((prompt) => isPresent(context.cwd, prompt));
228
241
  return action('write', `remove the plan ${plan.path} and its prompts (${prompts.length ? prompts.join(', ') : 'none on disk'}): the Cleanup of a landed story`);
@@ -251,12 +264,13 @@ const judgeEntry = (context, judged) => {
251
264
  if (!judged.accepted) return { entry: base, states: [] };
252
265
  const accepted = { ...base, residual: findSpans(path, judged.entry.text) };
253
266
  const leftover = judged.leftover.length ? leftoverActions(context, judged.leftover) : null;
254
- if (epic.fields.state === LANDED) return { entry: { ...accepted, stage: 'E5', actions: leftover ?? [] }, states: [] };
267
+ const states = judged.leftover.map((plan) => plan.prerequisite).filter(Boolean);
268
+ if (epic.fields.state === LANDED) return { entry: { ...accepted, stage: 'E5', actions: leftover ?? [] }, states };
255
269
  const landed = new Set(epic.rows.filter((row) => row.state === LANDED).map((row) => row.id));
256
270
  const inHand = epic.rows.filter((row) => row.state !== LANDED && row.dependsOn.every((dependency) => landed.has(dependency)));
257
- if (inHand.length === 0) return { entry: { ...accepted, stage: 'E4', actions: leftover ?? (context.index === null ? closeActions(context, judged) : []) }, states: [] };
271
+ if (inHand.length === 0) return { entry: { ...accepted, stage: 'E4', actions: leftover ?? (context.index === null ? closeActions(context, judged) : []) }, states };
258
272
  const held = { ...accepted, stage: 'E3', fact: tools.epicCheck(path, 'fact'), actions: leftover ?? [] };
259
- if (context.index !== null) return { entry: held, states: [] };
273
+ if (context.index !== null) return { entry: held, states };
260
274
  const stories = inHand.map((row) => judgeStory(context, path, id, row));
261
275
  return { entry: { ...held, stories: stories.filter((story) => story.story).map((story) => story.story) },
262
276
  states: stories.filter((story) => story.state).map((story) => story.state) };
@@ -6,8 +6,9 @@
6
6
  // never asks; every read and write goes through deps.
7
7
  import { linkSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
8
8
  import { resolve } from 'node:path';
9
+ import { EPIC_STORE, EPIC_STORE_SEED, ORCHESTRATION, PLANS, PROFILE_DECLINES, QUEUE } from '../references/scripts/shared/index.mjs';
9
10
  import { assertDocsAiDeployment, writeDocsAiFileAtomic, writeProjectFileCreateOnly } from './atomic-write.mjs';
10
- import { safeLine } from './carriers.mjs';
11
+ import { safeLine, slotRole } from './carriers.mjs';
11
12
  import { isDirectRun } from './direct-run.mjs';
12
13
  import { tmpNote } from './ensure-ops.mjs';
13
14
  import { CANON_README, applySetOps, refreshReadme } from './orchestration-config.mjs';
@@ -28,14 +29,8 @@ const HELP_FLAGS = new Set(['--help', '-h']);
28
29
  const MODE_FLAGS = new Set([APPLY_FLAG, DECLINE_FLAG]);
29
30
  const SLOTS_ID = 'epic-task-slots';
30
31
  const STORE_ID = 'epic-store-seeded';
31
- const STORE_DIR = 'docs/ai/epics';
32
- const STORE_SEED = 'docs/ai/epics/.gitkeep';
33
32
  const QUEUE_ID = 'named-queue-row-seed';
34
- const PLANS_DIR = 'docs/plans';
35
- const QUEUE_SEED = 'docs/plans/queue.md';
36
33
  const MISSING_CODE = 'ENOENT';
37
- const CONFIG_WRITTEN = 'docs/ai/orchestration.json';
38
- const DECLINES_REL = 'docs/ai/profile-declines.json';
39
34
  const SCHEMA = 1;
40
35
  const INDENT = ' ';
41
36
  const WORDS = Object.freeze({
@@ -100,10 +95,11 @@ const withFs = (deps) => ({
100
95
  // The resolution walk: the first candidate planRecipe reports not degraded wins; every candidate
101
96
  // before it carries that plan's own first degrade reason.
102
97
  // solo, every target's last candidate, is always satisfiable, so the find always answers.
103
- const resolveTarget = ({ candidates }, readiness) => {
98
+ const resolveTarget = ({ activity, slot, candidates }, readiness) => {
104
99
  const skipped = [];
100
+ const role = slotRole(activity, slot);
105
101
  const value = candidates.find((candidate) => {
106
- const plan = planRecipe(candidate, readiness);
102
+ const plan = planRecipe(candidate, readiness, role);
107
103
  if (plan.degraded) skipped.push({ candidate, reason: plan.degradation[0].reason });
108
104
  return !plan.degraded;
109
105
  });
@@ -160,11 +156,11 @@ const missingAt = (root, rel, deps) => {
160
156
  };
161
157
 
162
158
  const writeQueueSeed = (root, deps, bytes, made) => {
163
- const plansMissing = missingAt(root, PLANS_DIR, deps);
159
+ const plansMissing = missingAt(root, PLANS, deps);
164
160
  try {
165
- return { seeded: writeProjectFileCreateOnly(root, QUEUE_SEED, bytes, deps, { noun: 'the queue seed' }) };
161
+ return { seeded: writeProjectFileCreateOnly(root, QUEUE, bytes, deps, { noun: 'the queue seed' }) };
166
162
  } catch (error) {
167
- if (plansMissing && directoryAt(root, PLANS_DIR, deps)) made.push(`${PLANS_DIR} created`);
163
+ if (plansMissing && directoryAt(root, PLANS, deps)) made.push(`${PLANS} created`);
168
164
  return { refusal: refuse('write-failed', [...made, causeOf(error)].join('; ')) };
169
165
  }
170
166
  };
@@ -181,21 +177,21 @@ const runApply = (root, deps, judged, slots, config) => {
181
177
  } catch (error) {
182
178
  return { refusal: refuse('write-failed', causeOf(error)) };
183
179
  }
184
- made.push(`${CONFIG_WRITTEN} written`);
180
+ made.push(`${ORCHESTRATION} written`);
185
181
  byId.set(SLOTS_ID, { ...byId.get(SLOTS_ID), word: WORDS.applied });
186
182
  }
187
183
  if (byId.get(STORE_ID)?.word === GAP_STATES.offered) {
188
184
  let seeded;
189
185
  try {
190
- seeded = writeProjectFileCreateOnly(root, STORE_SEED, '', deps, { noun: 'the epic store seed' });
186
+ seeded = writeProjectFileCreateOnly(root, EPIC_STORE_SEED, '', deps, { noun: 'the epic store seed' });
191
187
  } catch (error) {
192
- if (directoryAt(root, STORE_DIR, deps)) made.push(`${STORE_DIR} created`);
188
+ if (directoryAt(root, EPIC_STORE, deps)) made.push(`${EPIC_STORE} created`);
193
189
  return { refusal: refuse('write-failed', [...made, causeOf(error)].join('; ')) };
194
190
  }
195
191
  byId.set(STORE_ID, { ...byId.get(STORE_ID), word: seeded.created ? WORDS.applied : GAP_STATES.present });
196
- if (seeded.created) made.push(`${STORE_SEED} created`);
192
+ if (seeded.created) made.push(`${EPIC_STORE_SEED} created`);
197
193
  if (seeded.tmpLeftBehind) {
198
- extra.push(OUTCOME_LINES.tmpLeft(STORE_SEED, seeded.tmpLeftBehind));
194
+ extra.push(OUTCOME_LINES.tmpLeft(EPIC_STORE_SEED, seeded.tmpLeftBehind));
199
195
  made.push(`${seeded.tmpLeftBehind} left behind`);
200
196
  }
201
197
  }
@@ -203,7 +199,7 @@ const runApply = (root, deps, judged, slots, config) => {
203
199
  const written = writeQueueSeed(root, deps, seed.bytes, made);
204
200
  if (written.refusal) return written;
205
201
  byId.set(QUEUE_ID, { ...byId.get(QUEUE_ID), word: written.seeded.created ? WORDS.applied : GAP_STATES.present });
206
- if (written.seeded.tmpLeftBehind) extra.push(OUTCOME_LINES.tmpLeft(QUEUE_SEED, written.seeded.tmpLeftBehind));
202
+ if (written.seeded.tmpLeftBehind) extra.push(OUTCOME_LINES.tmpLeft(QUEUE, written.seeded.tmpLeftBehind));
207
203
  }
208
204
  return { judged: judged.map((item) => byId.get(item.entry.id)), extra };
209
205
  };
@@ -219,7 +215,7 @@ const runDecline = (root, deps, judged, profile, declined) => {
219
215
  const merged = { ...(declined ?? {}) };
220
216
  for (const { entry } of offered) merged[entry.id] = profile.lineage;
221
217
  try {
222
- writeDocsAiFileAtomic(root, DECLINES_REL, serializeDeclines(merged), deps, { noun: 'the decline record' });
218
+ writeDocsAiFileAtomic(root, PROFILE_DECLINES, serializeDeclines(merged), deps, { noun: 'the decline record' });
223
219
  } catch (error) {
224
220
  return { refusal: refuse('write-failed', causeOf(error)) };
225
221
  }
@@ -6,17 +6,17 @@
6
6
  // Contract: docs/ai/specs/kit/transition/.
7
7
 
8
8
  import { join, resolve } from 'node:path';
9
- import { tokenizeMarkdown } from '../../references/scripts/shared/index.mjs';
9
+ import { AGENTS_FILE, AGENT_RULES, RULES_EFFECTIVE, tokenizeMarkdown } from '../../references/scripts/shared/index.mjs';
10
10
  import { writeContainedFileAtomic } from '../atomic-write.mjs';
11
11
  import { isDirectRun } from '../direct-run.mjs';
12
12
  import { probeRegularFileNoFollow, readRegularFileNoFollow } from '../fs-read-nofollow.mjs';
13
13
  import { findKitBlock, SKIP_PREFIX } from '../inject-methodology.mjs';
14
+ import { themePaths } from '../project-rules/index.mjs';
15
+ import { escapeRegExp } from '../repo-lex.mjs';
14
16
 
15
17
  const LF = '\n';
16
18
  const BOM = '';
17
- const AGENTS_REL = 'AGENTS.md';
18
- const RULES_REL = 'docs/ai/agent_rules.md';
19
- const LENS_REL = 'docs/ai/rules/lens.md';
19
+ const LENS_REL = themePaths('lens').kit;
20
20
  const USAGE = 'usage: transition/index.mjs --cwd <project>';
21
21
  const UPGRADE_AGAIN = 'run the upgrade again: its step 3 writes the kit block or names its malformed lines';
22
22
  const ENGINE_REFRESH = 'run npx @sabaiway/agent-workflow-engine@latest init, then run the upgrade again';
@@ -25,7 +25,8 @@ const ENGINE_REFRESH = 'run npx @sabaiway/agent-workflow-engine@latest init, the
25
25
  // theme and the line-cap footer in AGENTS.md; the title words of three sections in the rules file.
26
26
  const POINTERS = ['methodology', 'orchestration', 'autonomy'];
27
27
  const MARKER_RE = new RegExp(`^<!-- workflow:(${POINTERS.join('|')}):(start|end) -->$`, 'u');
28
- const THEME_ROW_RE = /^\| \[`docs\/ai\/rules\/effective\/([^`/\s]+)\.md`\]\(\.\/docs\/ai\/rules\/effective\/\1\.md\) \|/u;
28
+ const EFFECTIVE_RULES_PATTERN = escapeRegExp(RULES_EFFECTIVE);
29
+ const THEME_ROW_RE = new RegExp(`^\\| \\[\`${EFFECTIVE_RULES_PATTERN}\\/([^\`/\\s]+)\\.md\`\\]\\(\\.\\/${EFFECTIVE_RULES_PATTERN}\\/\\1\\.md\\) \\|`, 'u');
29
30
  const FOOTER = '**Rule:** This file stays CONCISE (≤100 lines). Details go to `docs/ai/`. Never bloat this file.';
30
31
  const TITLES = ['Communication (user-facing messages)', 'Story sessions', 'Planning, review & process-fidelity'];
31
32
  const HEADING_RE = /^ {0,3}#{1,6}[ \t]+(.*)$/u;
@@ -178,14 +179,14 @@ export const main = async (argv, deps = {}) => {
178
179
  }
179
180
  const cwd = resolve(argv[1]);
180
181
  try {
181
- const agentsFile = readProjectFile(cwd, AGENTS_REL, deps);
182
- const rulesFile = readProjectFile(cwd, RULES_REL, deps);
182
+ const agentsFile = readProjectFile(cwd, AGENTS_FILE, deps);
183
+ const rulesFile = readProjectFile(cwd, AGENT_RULES, deps);
183
184
  const agents = agentsFile && parse(agentsFile);
184
185
  const rules = rulesFile && parse(rulesFile);
185
186
  const block = firstStep(agents, cwd, deps);
186
187
  const judged = [
187
- { rel: AGENTS_REL, doc: agents, spans: keepParseable(agents, agentsSpans(agents, block)) },
188
- { rel: RULES_REL, doc: rules, spans: rules === null ? [] : keepParseable(rules, rulesSpans(rules)) },
188
+ { rel: AGENTS_FILE, doc: agents, spans: keepParseable(agents, agentsSpans(agents, block)) },
189
+ { rel: AGENT_RULES, doc: rules, spans: rules === null ? [] : keepParseable(rules, rulesSpans(rules)) },
189
190
  ];
190
191
  const written = [];
191
192
  for (const { rel, doc, spans } of judged) {
@@ -25,6 +25,7 @@
25
25
  import { existsSync, statSync, lstatSync, readlinkSync, readFileSync, readdirSync, realpathSync } from 'node:fs';
26
26
  import { join, resolve, dirname, basename, isAbsolute } from 'node:path';
27
27
  import os from 'node:os';
28
+ import { AGENTS_FILE, CLAUDE_FILE, DOCS_TREE, GIT_EXCLUDE, PLANS, PRE_COMMIT, SETTINGS, SETTINGS_LOCAL, STAGE_GUARD_HOOK } from '../references/scripts/shared/index.mjs';
28
29
  import { isDirectRun } from './direct-run.mjs';
29
30
  import { surveyFamily, surveyProject, FAMILY_MEMBERS, classifyMember, OK } from './family-registry.mjs';
30
31
  import { assertContainedRealPath, removeTreeManaged, unlinkManaged, MANAGED_LINK_CONFLICT } from './fs-safe.mjs';
@@ -63,7 +64,7 @@ const DEFAULT_BINDIR_REL = '.local/bin';
63
64
  // the name (never remove an unmarked / user-authored hook).
64
65
  const HOOK_MARKER_SUFFIX = ':install-git-hooks.mjs';
65
66
  // User-authored / kit-deployed-but-now-owned-by-the-user surfaces — REPORTED, never deleted.
66
- const REPORT_PATHS = ['docs/ai', 'AGENTS.md', 'CLAUDE.md', 'docs/plans'];
67
+ const REPORT_PATHS = [DOCS_TREE, AGENTS_FILE, CLAUDE_FILE, PLANS];
67
68
 
68
69
  // ── injectable fs ────────────────────────────────────────────────────────────────
69
70
  const fsOf = (deps = {}) => ({
@@ -182,7 +183,7 @@ export const buildPlan = ({ family, project = null, projectDir = null, member =
182
183
 
183
184
  if (project.hiddenFence) {
184
185
  // Display the git-path-resolved exclude file (worktree/submodule-safe), guarded → conventional path.
185
- const fencePath = (() => { try { return excludePath(deps, dir); } catch { return join(dir, '.git/info/exclude'); } })();
186
+ const fencePath = (() => { try { return excludePath(deps, dir); } catch { return join(dir, GIT_EXCLUDE); } })();
186
187
  items.push({ surface: 'fence', path: fencePath, class: MANAGED_MARKER, reason: 'hidden-mode managed block (removed via the existing unhide path; only the fenced lines)' });
187
188
  }
188
189
 
@@ -200,7 +201,7 @@ export const buildPlan = ({ family, project = null, projectDir = null, member =
200
201
  return false;
201
202
  }
202
203
  };
203
- const hookPath = join(dir, '.git/hooks/pre-commit');
204
+ const hookPath = join(dir, PRE_COMMIT);
204
205
  // `reachable` answers for the PARENT CHAIN only (by design — walking the leaf dropped surfaces
205
206
  // from the plan). The leaf therefore needs its own no-follow classification before any read: a
206
207
  // symlinked hook would expose an out-of-tree file, and a FIFO would block planning outright.
@@ -258,7 +259,7 @@ export const buildPlan = ({ family, project = null, projectDir = null, member =
258
259
  }
259
260
  // A settings file the tool will not read is REPORTED rather than dropped: the seams it may hold
260
261
  // are exactly what a teardown owes the maintainer, and silence about them is the worse answer.
261
- const settingsPath = join(dir, '.claude/settings.json');
262
+ const settingsPath = join(dir, SETTINGS);
262
263
  const settingsStat = claudeDirForeign || !reachable(settingsPath) ? null : lstatNoFollow(settingsPath, fs.lstat);
263
264
  const settingsUnread = !claudeDirForeign && reachable(settingsPath) && settingsStat !== null
264
265
  && (settingsStat.isSymbolicLink() || !settingsStat.isFile());
@@ -271,7 +272,7 @@ export const buildPlan = ({ family, project = null, projectDir = null, member =
271
272
  }
272
273
  const settings = claudeDirForeign || !reachable(settingsPath) || settingsUnread ? null : readRaw(settingsPath);
273
274
  const settingsSeams = detectSettingsSeams(settings);
274
- if (settingsSeams.attribution || settingsSeams.permissions || settingsSeams.gateHook || settingsSeams.mcp) {
275
+ if (settingsSeams.attribution || settingsSeams.permissions || settingsSeams.gateHook || settingsSeams.stageGuard || settingsSeams.mcp) {
275
276
  items.push({
276
277
  surface: 'settings',
277
278
  path: settingsPath,
@@ -288,7 +289,7 @@ export const buildPlan = ({ family, project = null, projectDir = null, member =
288
289
  // byte-identical to the current bundle — never create the wired-but-missing state this tool
289
290
  // itself would warn about; while any entry is present, all surfaces are reported as one bundle
290
291
  // (edit settings first, re-run to remove the file).
291
- const localSettingsPath = join(dir, '.claude/settings.local.json');
292
+ const localSettingsPath = join(dir, SETTINGS_LOCAL);
292
293
  // Same leaf discipline as the hook: classified no-follow before any read, so a symlinked local
293
294
  // settings file is not followed out of the tree and a non-regular one is never opened.
294
295
  const localStat = !claudeDirForeign && reachable(localSettingsPath) ? lstatNoFollow(localSettingsPath, fs.lstat) : null;
@@ -303,6 +304,12 @@ export const buildPlan = ({ family, project = null, projectDir = null, member =
303
304
  hand: `edit ${shq(localSettingsPath)} → remove the PreToolUse entry whose command runs ${GATE_HOOK_FILE_REL} (keep the rest of your settings)`,
304
305
  });
305
306
  }
307
+ if (localSeams.stageGuard) {
308
+ items.push({
309
+ surface: 'settings', path: localSettingsPath, class: REPORT_ONLY,
310
+ reason: STAGE_GUARD_SEAM_REASON, hand: `edit ${shq(localSettingsPath)} → ${STAGE_GUARD_SEAM_HAND} (keep the rest of your settings)`,
311
+ });
312
+ }
306
313
  const gateHookPath = join(dir, GATE_HOOK_FILE_REL);
307
314
  // The placed hook lives INSIDE `.claude` too, so a foreign container blinds this probe as well —
308
315
  // its own no-follow lstat guards the leaf, never the path that reaches it.
@@ -699,7 +706,7 @@ const gateHookWiredNow = (projectDir, fs) => {
699
706
  return true;
700
707
  }
701
708
  };
702
- return probe(join(projectDir, '.claude/settings.json')) || probe(join(projectDir, '.claude/settings.local.json'));
709
+ return probe(join(projectDir, SETTINGS)) || probe(join(projectDir, SETTINGS_LOCAL));
703
710
  };
704
711
 
705
712
  // ── report ───────────────────────────────────────────────────────────────────
@@ -725,12 +732,13 @@ const jsonStringContains = (value, needle) => {
725
732
  // substring probe. Deliberately BROADER than the writer's exact-command check (any string mentioning
726
733
  // the placed path counts): over-detection preserves the hook file, under-detection could remove a
727
734
  // still-wired one — so the fallback errs toward wired.
728
- const settingsMentionsGateHook = (settings) => {
735
+ const settingsMentionsPath = (settings, rel) => {
729
736
  const parsed = (() => { try { return JSON.parse(settings); } catch { return null; } })();
730
737
  return parsed !== null && typeof parsed === 'object'
731
- ? jsonStringContains(parsed, GATE_HOOK_FILE_REL)
732
- : settings.includes(GATE_HOOK_FILE_REL);
738
+ ? jsonStringContains(parsed, rel)
739
+ : settings.includes(rel);
733
740
  };
741
+ const settingsMentionsGateHook = (settings) => settingsMentionsPath(settings, GATE_HOOK_FILE_REL);
734
742
 
735
743
  // Detect the three settings.json seams the family may have written: the attribution edit
736
744
  // (`includeCoAuthoredBy`), the velocity profile (`permissions.defaultMode` / `permissions.allow`),
@@ -757,8 +765,9 @@ const settingsMentionsMcp = (settings, parsed) => {
757
765
  };
758
766
 
759
767
  const detectSettingsSeams = (settings) => {
760
- if (settings == null) return { attribution: false, permissions: false, gateHook: false, mcp: false, parsed: true };
768
+ if (settings == null) return { attribution: false, permissions: false, gateHook: false, stageGuard: false, mcp: false, parsed: true };
761
769
  const gateHook = settingsMentionsGateHook(settings);
770
+ const stageGuard = settingsMentionsPath(settings, STAGE_GUARD_HOOK);
762
771
  const parsed = (() => { try { return JSON.parse(settings); } catch { return null; } })();
763
772
  const mcp = settingsMentionsMcp(settings, parsed);
764
773
  if (parsed == null || typeof parsed !== 'object') {
@@ -768,6 +777,7 @@ const detectSettingsSeams = (settings) => {
768
777
  attribution: settings.includes('includeCoAuthoredBy'),
769
778
  permissions: settings.includes('"permissions"') && (settings.includes('"defaultMode"') || settings.includes('"allow"')),
770
779
  gateHook,
780
+ stageGuard,
771
781
  mcp,
772
782
  parsed: false,
773
783
  };
@@ -775,12 +785,14 @@ const detectSettingsSeams = (settings) => {
775
785
  const perms = parsed.permissions;
776
786
  const permissions = perms != null && typeof perms === 'object'
777
787
  && (Object.prototype.hasOwnProperty.call(perms, 'defaultMode') || Object.prototype.hasOwnProperty.call(perms, 'allow'));
778
- return { attribution: Object.prototype.hasOwnProperty.call(parsed, 'includeCoAuthoredBy'), permissions, gateHook, mcp, parsed: true };
788
+ return { attribution: Object.prototype.hasOwnProperty.call(parsed, 'includeCoAuthoredBy'), permissions, gateHook, stageGuard, mcp, parsed: true };
779
789
  };
780
790
 
781
791
  const ATTRIBUTION_REASON = 'we set "includeCoAuthoredBy": false here — review/remove that key by hand (the file may hold your own settings)';
782
792
  const PERMISSIONS_REASON = 'a "permissions.defaultMode" and/or "permissions.allow" key is present in this file — if the velocity profile seeded them, review/remove by hand (no ownership marker is stored); otherwise leave them';
783
793
  const GATE_HOOK_SEAM_REASON = `a PreToolUse entry wiring the kit-placed gate-approval hook (${GATE_HOOK_FILE_REL}) is present — remove that entry by hand to unwire it (the tool never edits settings)`;
794
+ const STAGE_GUARD_SEAM_REASON = `this settings file mentions the kit-placed stage write guard (${STAGE_GUARD_HOOK}) — if a PreToolUse entry runs it, the guard keeps refusing code writes in a stage recorded as writing no code, kit or no kit; verify and remove that entry by hand (the tool never edits settings)`;
795
+ const STAGE_GUARD_SEAM_HAND = `remove the PreToolUse entry whose command runs ${STAGE_GUARD_HOOK}`;
784
796
 
785
797
  const MCP_SEAM_REASON = `the MCP registration keys for "${MCP_SERVER_NAME}" are present in this file ("${MCP_ENABLED_KEY}" and/or the ${MCP_ALLOW_RULES.join(' / ')} allow rules) — remove them by hand to unregister the typed channel (the tool never edits settings)`;
786
798
  // Over a file that could not be PARSED, the same seams are probed by substring — so any string or
@@ -794,6 +806,7 @@ const settingsSeamReason = (seams) =>
794
806
  ...(seams.attribution ? [ATTRIBUTION_REASON] : []),
795
807
  ...(seams.permissions ? [PERMISSIONS_REASON] : []),
796
808
  ...(seams.gateHook ? [GATE_HOOK_SEAM_REASON] : []),
809
+ ...(seams.stageGuard ? [STAGE_GUARD_SEAM_REASON] : []),
797
810
  ...(seams.mcp ? [MCP_SEAM_REASON] : []),
798
811
  ].join('. Also: ');
799
812
 
@@ -806,6 +819,7 @@ const settingsSeamHand = (seams, p) => {
806
819
  : 'if the velocity profile seeded "permissions.defaultMode"/"permissions.allow", review/remove them by hand']
807
820
  : []),
808
821
  ...(seams.gateHook ? [`remove the PreToolUse entry whose command runs ${GATE_HOOK_FILE_REL}`] : []),
822
+ ...(seams.stageGuard ? [STAGE_GUARD_SEAM_HAND] : []),
809
823
  ...(seams.mcp ? [`remove "${MCP_SERVER_NAME}" from "${MCP_ENABLED_KEY}" and the ${MCP_ALLOW_RULES.join(" / ")} allow rules`] : []),
810
824
  ];
811
825
  return `edit ${shq(p)} → ${clauses.join(' and ')} (keep the rest of your settings)`;
@@ -1,7 +1,8 @@
1
1
  import { readFileSync, lstatSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import { VEHICLES } from '../references/scripts/shared/index.mjs';
3
4
 
4
- export const VEHICLES_REL = 'docs/ai/vehicles.json';
5
+ export const VEHICLES_REL = VEHICLES;
5
6
  export const EXECUTOR_DEFAULTS = Object.freeze({ model: 'opus', effort: 'high', fallback: 'sonnet' });
6
7
  export const REVIEW_LENS_DEFAULTS = Object.freeze({ model: 'opus', effort: 'high' });
7
8
 
@@ -2,6 +2,7 @@ import { accessSync, constants, existsSync, lstatSync, mkdirSync, readdirSync, r
2
2
  import { basename, dirname, join, relative, resolve } from 'node:path';
3
3
  import { homedir, tmpdir } from 'node:os';
4
4
  import { fileURLToPath } from 'node:url';
5
+ import { CLAUDE_DIR, PACKAGE_JSON, SETTINGS, SETTINGS_LOCAL, WORKFLOW_STAMP } from '../references/scripts/shared/index.mjs';
5
6
  // The --autonomy render reads the per-project autonomy policy through the read-only autonomy core
6
7
  // (AD-044). This file is the family's one .claude/settings.json writer, so the policy render lives here;
7
8
  // it never imports the policy fs-writer (autonomy-write.mjs) — the render owns the settings file, not
@@ -33,10 +34,9 @@ import { resolveDeclaredDir, dirCovers, isResolvableDeclaredEntry } from './decl
33
34
  // Deployment-lineage head this velocity build targets; bump together with agent-workflow-memory
34
35
  // LINEAGE_HEAD when the deployed docs/ai structure changes.
35
36
  export const EXPECTED_WORKFLOW_VERSION = '5.0.0';
36
- export const SETTINGS_FILE = '.claude/settings.json';
37
- export const SETTINGS_LOCAL_FILE = '.claude/settings.local.json';
38
- export const CLAUDE_DIR = '.claude';
39
- export const WORKFLOW_STAMP = 'docs/ai/.workflow-version';
37
+ export const SETTINGS_FILE = SETTINGS;
38
+ export const SETTINGS_LOCAL_FILE = SETTINGS_LOCAL;
39
+ export { CLAUDE_DIR, WORKFLOW_STAMP } from '../references/scripts/shared/index.mjs';
40
40
  export const SAFE_DEFAULT_MODES = Object.freeze(['default', 'acceptEdits', 'plan']);
41
41
  export const UNSAFE_BYPASS_MODE = 'bypassPermissions';
42
42
  export const ACCEPT_EDITS_MODE = 'acceptEdits';
@@ -285,7 +285,6 @@ const WHITESPACE_PATTERN = /\s+/u;
285
285
  const GIT_COMMAND = 'git';
286
286
  const NPM_COMMAND = 'npm';
287
287
  const NPM_RUN_COMMAND = 'npm run';
288
- const PACKAGE_FILE = 'package.json';
289
288
  const SETTINGS_JSON_INDENT = 2;
290
289
  const EXIT_USAGE = 2;
291
290
  const EXIT_PRECONDITION = 1;
@@ -522,7 +521,7 @@ const readStamp = (absPath, deps = {}) => {
522
521
 
523
522
  const readPackageJson = (cwd, deps = {}) => {
524
523
  const fs = fsDeps(deps);
525
- const absPath = join(cwd, PACKAGE_FILE);
524
+ const absPath = join(cwd, PACKAGE_JSON);
526
525
  if (!fs.exists(absPath)) return null;
527
526
  // package.json feeds ONLY the read-only gate advisory — a malformed one degrades to "no
528
527
  // candidates"; it must NEVER block the settings write.
@@ -9,6 +9,7 @@
9
9
  // Pure, no side effects, Node >= 22.
10
10
 
11
11
  import { STATE_PHRASING, VISIBILITY_PHRASING } from './presentation.mjs';
12
+ import { slotRole } from './carriers.mjs';
12
13
 
13
14
  const memberVm = (m) => {
14
15
  const refresh = m.refresh ?? { behind: false, recommend: null };
@@ -57,7 +58,7 @@ const recipesVm = (r) => {
57
58
  // source + degradedFrom ride along: an effective recipe alone cannot tell a chosen value from a
58
59
  // computed default, nor a degrade from a configuration that really names the resolved recipe.
59
60
  for (const [slot, v] of Object.entries(slots)) {
60
- pairs.push({ key: `${activity}.${slot}`, recipe: v.recipe, source: v.source ?? null, degradedFrom: v.degradedFrom ?? null });
61
+ pairs.push({ key: `${activity}.${slot}`, recipe: v.recipe, source: v.source ?? null, degradedFrom: v.degradedFrom ?? null, role: slotRole(activity, slot) });
61
62
  }
62
63
  }
63
64
  return { pairs, detectError: r.detectError ?? null };
@@ -80,15 +81,17 @@ const velocityVm = (v) => {
80
81
 
81
82
  const agentsVm = (a) => {
82
83
  if (!a) return null;
83
- if (a.error) return { error: a.error, executor: a.executor ?? null, executorReason: a.executorReason ?? null };
84
+ if (a.error) return { error: a.error, author: a.author ?? null, authorReason: a.authorReason ?? null, executor: a.executor ?? null, executorReason: a.executorReason ?? null };
84
85
  const bundled = a.bundled ?? 0;
85
86
  return {
86
87
  bundled,
87
88
  placed: a.placed ?? 0,
88
- // The envelope counts the read-only vehicles; an envelope predating the executor field bundled
89
+ // The envelope counts the read-only vehicles; an envelope predating the author and executor fields bundled
89
90
  // only read-only ones.
90
- readOnly: a.readOnly ?? (a.executor == null ? bundled : Math.max(bundled - 1, 0)),
91
+ readOnly: a.readOnly ?? Math.max(bundled - Number(a.executor != null) - Number(a.author != null), 0),
91
92
  // null = an envelope predating the field (unknown), never a state.
93
+ author: a.author ?? null,
94
+ authorReason: a.authorReason ?? null,
92
95
  executor: a.executor ?? null,
93
96
  executorReason: a.executorReason ?? null,
94
97
  };
@@ -19,7 +19,7 @@ export { WORKTREES_STOP } from './worktrees-record.mjs';
19
19
 
20
20
  // The command grammar. Every command this prompt puts in front of a reader is a marked line naming
21
21
  // WHO runs it — ` MAIN $ …` or ` HERE $ …` — so the runnable set is enumerable AND attributed.
22
- // The actor is not decoration: the one command the prompt carries today runs from MAIN and mutates
22
+ // The actor is not decoration: the landing command the prompt carries runs from MAIN and mutates
23
23
  // MAIN, which is precisely what the satellite is forbidden to do, and an unattributed `$` line reads
24
24
  // as an instruction to whoever is holding the prompt.
25
25
  export const PROMPT_ACTORS = Object.freeze({ main: 'MAIN', here: 'HERE' });
@@ -107,7 +107,8 @@ const MAIN_CAUSE = 'a moved MAIN, or a hand edit';
107
107
  const INSTALL_CAUSE = 'this checkout answers differently now, most often because its dependency declaration or its node_modules changed since provision';
108
108
 
109
109
  // live: { sharedQueue, landingRule, landingCommand, installPosture, installDescription,
110
- // installCommand } — derived by the caller at print time. The landing pair and the checkout identity
110
+ // installCommand } — derived by the caller at print time. `renderCommand` is the stage renderer's
111
+ // command for this checkout's slot file, the one command this session runs first. The landing pair and the checkout identity
111
112
  // have no "cannot answer" state and are REQUIRED; the series index and the install trio may be
112
113
  // absent and then render by omission. The install arrives in THREE parts on purpose: the posture is
113
114
  // the record's field and the divergence key and is never printed, the description is its prose half,
@@ -115,7 +116,7 @@ const INSTALL_CAUSE = 'this checkout answers differently now, most often because
115
116
  // case, and printing it as prose would offer an instruction nothing attributes. `record` is the
116
117
  // parsed provision record and is required too — a caller that could not read it must say so, not
117
118
  // hand in an empty object that renders as "nothing diverged".
118
- export const composeSatellitePrompt = ({ slug, branch, worktreePath, plan, live, record }) => {
119
+ export const composeSatellitePrompt = ({ slug, branch, worktreePath, plan, renderCommand, live, record }) => {
119
120
  if (live == null || typeof live !== 'object') {
120
121
  throw stop('the satellite cold-start prompt cannot be composed: the live orientation is missing — every value the prompt states is derived at print time, so there is nothing to state without it');
121
122
  }
@@ -126,6 +127,7 @@ export const composeSatellitePrompt = ({ slug, branch, worktreePath, plan, live,
126
127
  const safeBranch = promptValue('branch', required('branch', branch));
127
128
  const safePath = promptValue('worktree path', required('worktree path', worktreePath));
128
129
  const safePlan = promptValue('seeded plan', required('seeded plan', plan));
130
+ const render = promptValue('render command', required('render command', renderCommand));
129
131
  const rule = promptValue('live.landingRule', required('live.landingRule', live.landingRule));
130
132
  const command = promptValue('live.landingCommand', required('live.landingCommand', live.landingCommand));
131
133
  const queue = promptValue('live.sharedQueue', live.sharedQueue);
@@ -150,6 +152,8 @@ export const composeSatellitePrompt = ({ slug, branch, worktreePath, plan, live,
150
152
  `- branch: ${safeBranch}`,
151
153
  `- seeded plan: ${PLANS_REL}/${safePlan}`,
152
154
  `- handoff: ${handoffRel}`,
155
+ '- the stage of this session, rendered from the installed kit before any other step:',
156
+ commandLine(PROMPT_ACTORS.here, render),
153
157
  '',
154
158
  '## MAIN orientation — derived LIVE from MAIN, never replayed from the provision record',
155
159
  ];