mandrel 1.57.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.agents/README.md +89 -87
  2. package/.agents/docs/SDLC.md +11 -7
  3. package/.agents/docs/workflows.md +2 -1
  4. package/.agents/schemas/audit-rules.json +20 -0
  5. package/.agents/scripts/acceptance-eval.js +20 -3
  6. package/.agents/scripts/assert-branch.js +1 -3
  7. package/.agents/scripts/bootstrap.js +1 -1
  8. package/.agents/scripts/check-arch-cycles.js +360 -0
  9. package/.agents/scripts/coverage-capture.js +24 -3
  10. package/.agents/scripts/epic-deliver-preflight.js +5 -3
  11. package/.agents/scripts/epic-deliver-prepare.js +12 -4
  12. package/.agents/scripts/epic-execute-record-wave.js +1 -1
  13. package/.agents/scripts/evidence-gate.js +1 -1
  14. package/.agents/scripts/git-rebase-and-resolve.js +1 -1
  15. package/.agents/scripts/hierarchy-gate.js +34 -14
  16. package/.agents/scripts/lib/baselines/kinds/coverage.js +33 -149
  17. package/.agents/scripts/lib/baselines/kinds/duplication.js +27 -116
  18. package/.agents/scripts/lib/baselines/kinds/kind-factory.js +192 -0
  19. package/.agents/scripts/lib/baselines/kinds/lighthouse.js +34 -133
  20. package/.agents/scripts/lib/baselines/kinds/maintainability.js +31 -124
  21. package/.agents/scripts/lib/baselines/kinds/mutation.js +25 -111
  22. package/.agents/scripts/lib/baselines/maintainability-baseline-io.js +59 -0
  23. package/.agents/scripts/lib/baselines/maintainability-baseline-save.js +37 -0
  24. package/.agents/scripts/lib/baselines/writer.js +1 -1
  25. package/.agents/scripts/lib/close-validation/commands.js +188 -0
  26. package/.agents/scripts/lib/close-validation/gates.js +235 -0
  27. package/.agents/scripts/lib/close-validation/process.js +101 -0
  28. package/.agents/scripts/lib/close-validation/projections/maintainability.js +1 -1
  29. package/.agents/scripts/lib/close-validation/runner.js +325 -0
  30. package/.agents/scripts/lib/close-validation/telemetry.js +70 -0
  31. package/.agents/scripts/lib/config/quality.js +6 -6
  32. package/.agents/scripts/lib/config-resolver.js +2 -5
  33. package/.agents/scripts/lib/coverage-capture.js +147 -4
  34. package/.agents/scripts/lib/cpu-pool.js +14 -0
  35. package/.agents/scripts/lib/crap-utils.js +6 -11
  36. package/.agents/scripts/lib/dynamic-workflow/documentation-report-contract.js +87 -0
  37. package/.agents/scripts/lib/git-utils.js +24 -22
  38. package/.agents/scripts/lib/maintainability-engine.js +1 -1
  39. package/.agents/scripts/lib/maintainability-utils.js +4 -187
  40. package/.agents/scripts/lib/observability/perf-report-readers.js +32 -23
  41. package/.agents/scripts/lib/orchestration/acceptance-eval-decision.js +80 -6
  42. package/.agents/scripts/lib/orchestration/code-review.js +90 -77
  43. package/.agents/scripts/lib/orchestration/dispatch-pipeline.js +5 -12
  44. package/.agents/scripts/lib/orchestration/epic-deliver-lease-guard.js +14 -14
  45. package/.agents/scripts/lib/orchestration/epic-plan-decompose/phases/planning-artifacts.js +2 -2
  46. package/.agents/scripts/lib/orchestration/epic-plan-lease-guard.js +184 -49
  47. package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/drain.js +1 -1
  48. package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/plan-epic.js +26 -2
  49. package/.agents/scripts/lib/orchestration/epic-plan-spec/phases/run-spec-phase.js +26 -6
  50. package/.agents/scripts/lib/orchestration/epic-runner/phases/build-wave-dag.js +7 -20
  51. package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter/composition.js +1 -2
  52. package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter/signals.js +0 -6
  53. package/.agents/scripts/lib/orchestration/epic-runner/progress-signals/component-drift.js +103 -0
  54. package/.agents/scripts/lib/orchestration/epic-runner/progress-signals/crap-drift.js +22 -64
  55. package/.agents/scripts/lib/orchestration/epic-runner/progress-signals/maintainability-drift.js +38 -76
  56. package/.agents/scripts/lib/orchestration/epic-runner/story-run-progress-writer.js +2 -2
  57. package/.agents/scripts/lib/orchestration/epic-runner/sub-agent-return.js +4 -16
  58. package/.agents/scripts/lib/orchestration/file-assumptions.js +4 -3
  59. package/.agents/scripts/lib/orchestration/lease-guard-shared.js +144 -0
  60. package/.agents/scripts/lib/orchestration/lifecycle/emit-story-heartbeat.js +2 -2
  61. package/.agents/scripts/lib/orchestration/lifecycle/listeners/watcher.js +7 -7
  62. package/.agents/scripts/lib/orchestration/post-merge/phases/notification.js +3 -3
  63. package/.agents/scripts/lib/orchestration/post-merge/phases/worktree-reap.js +7 -7
  64. package/.agents/scripts/lib/orchestration/preflight-cache.js +35 -12
  65. package/.agents/scripts/lib/orchestration/review-providers/codex.js +5 -60
  66. package/.agents/scripts/lib/orchestration/review-providers/native.js +7 -6
  67. package/.agents/scripts/lib/orchestration/review-providers/parse-findings.js +105 -0
  68. package/.agents/scripts/lib/orchestration/review-providers/security-review.js +7 -59
  69. package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +2 -4
  70. package/.agents/scripts/lib/orchestration/single-story-close/phases/normalize-pr-title.js +241 -0
  71. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +1 -1
  72. package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +16 -3
  73. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +2 -4
  74. package/.agents/scripts/lib/orchestration/single-story-lease-guard.js +32 -35
  75. package/.agents/scripts/lib/orchestration/skill-capsule-loader.js +1 -2
  76. package/.agents/scripts/lib/orchestration/story-close/auto-refresh-runner.js +451 -503
  77. package/.agents/scripts/lib/orchestration/story-close/baseline-attribution/phases/pre-merge-attribution.js +8 -2
  78. package/.agents/scripts/lib/orchestration/story-close/baseline-attribution/phases/refresh-commit.js +47 -2
  79. package/.agents/scripts/lib/orchestration/story-close/baseline-attribution/phases/regression-projection.js +2 -2
  80. package/.agents/scripts/lib/orchestration/story-close/format-autofix.js +358 -54
  81. package/.agents/scripts/lib/orchestration/story-close/phases/close.js +1 -1
  82. package/.agents/scripts/lib/orchestration/story-close/phases/gates.js +3 -2
  83. package/.agents/scripts/lib/orchestration/story-close/phases/locked-pipeline.js +30 -3
  84. package/.agents/scripts/lib/orchestration/story-close/post-merge-close.js +5 -18
  85. package/.agents/scripts/lib/orchestration/story-close/pre-merge-validation.js +3 -3
  86. package/.agents/scripts/lib/orchestration/story-close-recovery.js +33 -16
  87. package/.agents/scripts/lib/orchestration/story-reachability.js +47 -0
  88. package/.agents/scripts/lib/orchestration/ticket-validator-conflicts.js +2 -33
  89. package/.agents/scripts/lib/orchestration/ticketing/bulk.js +42 -64
  90. package/.agents/scripts/lib/orchestration/ticketing/reads.js +9 -0
  91. package/.agents/scripts/lib/orchestration/ticketing/state.js +50 -436
  92. package/.agents/scripts/lib/orchestration/ticketing/transition.js +471 -0
  93. package/.agents/scripts/lib/orchestration/ticketing.js +0 -1
  94. package/.agents/scripts/lib/orchestration/wave-record-notifications.js +1 -1
  95. package/.agents/scripts/lib/orchestration/wave-record-projection.js +1 -7
  96. package/.agents/scripts/lib/project-root.js +17 -0
  97. package/.agents/scripts/lib/story-adjacency.js +76 -0
  98. package/.agents/scripts/lib/story-lifecycle.js +1 -1
  99. package/.agents/scripts/lib/transpile.js +93 -0
  100. package/.agents/scripts/lib/wave-runner/tick.js +4 -153
  101. package/.agents/scripts/lib/workers/crap-worker.js +1 -1
  102. package/.agents/scripts/lib/workers/maintainability-report-worker.js +1 -1
  103. package/.agents/scripts/lib/worktree/lifecycle/creation.js +20 -2
  104. package/.agents/scripts/lib/worktree/lifecycle/force-drain.js +90 -0
  105. package/.agents/scripts/lib/worktree/lifecycle/reap.js +26 -8
  106. package/.agents/scripts/lib/worktree/node-modules-strategy.js +74 -0
  107. package/.agents/scripts/providers/github/tickets.js +110 -6
  108. package/.agents/scripts/run-lint.js +9 -0
  109. package/.agents/scripts/run-tests.js +24 -4
  110. package/.agents/scripts/stories-wave-tick.js +8 -5
  111. package/.agents/scripts/story-init.js +149 -10
  112. package/.agents/scripts/sync-branch-from-base.js +1 -1
  113. package/.agents/skills/stack/qa/lighthouse-baseline/SKILL.md +1 -1
  114. package/.agents/workflows/audit-documentation.md +226 -0
  115. package/.agents/workflows/epic-deliver.md +16 -23
  116. package/.agents/workflows/epic-plan.md +1 -1
  117. package/.agents/workflows/helpers/epic-deliver-story.md +17 -28
  118. package/.agents/workflows/helpers/single-story-deliver.md +2 -1
  119. package/.agents/workflows/onboard.md +4 -3
  120. package/.agents/workflows/story-deliver.md +1 -1
  121. package/README.md +21 -8
  122. package/lib/cli/init.js +336 -0
  123. package/package.json +2 -1
  124. package/.agents/scripts/lib/auto-refresh-baselines.js +0 -308
  125. package/.agents/scripts/lib/close-validation.js +0 -897
  126. package/.agents/scripts/lib/orchestration/cascade-grouping.js +0 -275
  127. package/.agents/scripts/lib/orchestration/epic-runner/progress-reporter.js +0 -69
  128. package/.agents/scripts/lib/orchestration/story-close/format-autofix-scoped.js +0 -221
  129. package/.agents/scripts/lib/orchestration/story-close/format-autofix-shared.js +0 -123
  130. package/.agents/scripts/lib/task-utils.js +0 -26
  131. package/.agents/scripts/story-deliver-prepare.js +0 -267
@@ -0,0 +1,226 @@
1
+ ---
2
+ description: Audit the repository's main documentation for staleness, semantic drift, and completeness; emit a structured High/Medium/Low findings report.
3
+ ---
4
+
5
+ # Documentation Staleness & Completeness Audit
6
+
7
+ ## Role
8
+
9
+ Staff Engineer & Documentation Steward
10
+
11
+ ## Context & Objective
12
+
13
+ You are auditing the repository's primary prose documentation to verify it
14
+ is **up to date and complete**. Prose docs rot silently: commands get
15
+ renamed, scripts move, described workflows change shape, and
16
+ version/topology claims go stale. The deterministic gates
17
+ (`check-doc-links.js`, `check-lifecycle-doc-drift.js`,
18
+ `validate-docs-freshness.js`) catch broken links, drift against generators,
19
+ and Epic-scoped freshness — they cannot tell whether the prose still
20
+ describes how the code actually behaves. That semantic verification is this
21
+ lens's job.
22
+
23
+ ## Target set (config-driven union)
24
+
25
+ The audit target set is **not** "all markdown in the repo". Build it as the
26
+ union of:
27
+
28
+ 1. **`project.docsContextFiles`** from `.agentrc.json` (each entry resolved
29
+ against `project.paths.docsRoot`, default `docs/`; skip absent files
30
+ silently).
31
+ 2. **`delivery.docsFreshness.paths`** from `.agentrc.json`.
32
+ 3. **Conventional anchors:** the root `README.md`, `AGENTS.md` /
33
+ `CLAUDE.md`, `CONTRIBUTING.md` (when present), and top-level `docs/*.md`
34
+ (non-recursive).
35
+ 4. **An explicit `--paths` override** — when the operator invokes the lens
36
+ with `--paths <file ...>`, add those files to the union. This is the
37
+ escape hatch for everything outside 1–3; there is no dedicated config
38
+ key for it.
39
+
40
+ **Generated docs are excluded from per-doc semantic review.** The output of
41
+ `generate-config-docs.js`, `generate-lifecycle-docs.js`, and
42
+ `generate-workflows-doc.js`, and the synced `.claude/commands/` mirrors, are
43
+ generator-owned: hand-editing them is never the remediation. Instead, Step 1
44
+ runs the generators' `--check` mode and emits a **single** "generator output
45
+ dirty" finding when their output is stale — the remediation is "rerun the
46
+ generator", not "edit the doc". Auto-generated changelog files
47
+ (`docs/CHANGELOG.md`, release-please-owned) are likewise excluded from
48
+ semantic review beyond Step 1's deterministic checks.
49
+
50
+ ## Scope (Epic mode)
51
+
52
+ When this lens is invoked from `/epic-deliver` Phase 4 (epic-audit), the
53
+ following block is populated with the Epic's change-set file list.
54
+ Otherwise — for any manual `/audit-<dimension>` invocation — the block
55
+ renders the literal substitution token and you MUST treat it as **no
56
+ scope filter — run the lens codebase-wide** exactly as you would have
57
+ before this section existed.
58
+
59
+ ```text
60
+ {{changedFiles}}
61
+ ```
62
+
63
+ - If the block above contains a newline-delimited list of file paths,
64
+ restrict your analysis to the intersection of the target-set union and
65
+ those files — plus any target-set doc whose claims describe code in the
66
+ change set (a renamed script invalidates every doc that references it).
67
+ - If the block above renders as the literal string `{{changedFiles}}`
68
+ (i.e. no substitution was supplied), ignore this section entirely and
69
+ proceed with the full target-set audit defined in the remaining steps.
70
+
71
+ ## Execution strategy (dual-path)
72
+
73
+ This lens runs along one of two execution paths. Both emit the **identical**
74
+ report contract (Step 3); downstream consumers (`/epic-deliver` Phase 4
75
+ epic-audit, `audit-to-stories`) are agnostic to which path produced it.
76
+
77
+ - **Orchestrated (dynamic-workflow) path.** When Claude Code's
78
+ [dynamic workflows](https://code.claude.com/docs/en/workflows) are
79
+ available, the saved project workflow
80
+ `.claude/workflows/audit-documentation.workflow.js` fans the semantic
81
+ dimensions below out as parallel read-only subagents — each agent walks
82
+ the full target set per doc for its dimension — runs an **adversarial
83
+ verify** stage (an independent agent re-checks every stale-claim finding
84
+ against the current code and drops claims it cannot reproduce — doc
85
+ staleness is notoriously false-positive-prone), then synthesises the
86
+ Step 3 report. The orchestrator derives its per-dimension prompts from
87
+ *this* markdown at run time — the lens stays the single source of truth;
88
+ the script does not fork a second copy of the spec. Step 1's
89
+ deterministic checkers still run in the calling session (the analysis
90
+ subagents are read-only and cannot execute them); their results are
91
+ passed to the workflow as the `deterministicFindings` input and folded
92
+ into the synthesis.
93
+ - **Sequential (single-pass) path.** When dynamic workflows are unavailable,
94
+ follow Steps 1–3 below turn-by-turn exactly as before. This is the default
95
+ fallback and changes nothing about the existing behaviour.
96
+
97
+ **Strategy selection** is computed by
98
+ [`lib/dynamic-workflow/capability.js`](../scripts/lib/dynamic-workflow/capability.js)
99
+ (`selectAuditStrategy`). The orchestrated path is chosen only when the runtime
100
+ is Claude Code, `disableWorkflows` is not set (settings.json **or**
101
+ `CLAUDE_CODE_DISABLE_WORKFLOWS`), and the Claude Code version meets the
102
+ research-preview floor (`>= 2.1.154`). Any other runtime, a disabled setting,
103
+ or an older version degrades gracefully to the sequential path.
104
+
105
+ > **Capability degradation, not a contract shim.** This dual path is **not**
106
+ > covered by the No-Shim / hard-cutover rule in
107
+ > [`git-conventions.md`](../rules/git-conventions.md). That rule forbids
108
+ > running two shapes of the *same contract* side by side. Here there is **one**
109
+ > report contract; only the *execution strategy* is selected from a runtime
110
+ > capability — the same pattern the protocol already endorses for live-docs
111
+ > fallback in [`instructions.md` §1.C/§1.D](../instructions.md). The full
112
+ > capability-degradation rationale lives in the
113
+ > [`capability.js`](../scripts/lib/dynamic-workflow/capability.js) module
114
+ > docstring; the orchestrated-run evidence and per-lens cost/precision gate
115
+ > verdicts live in [`docs/roadmap.md`](../../docs/roadmap.md) (Part 3 —
116
+ > Dynamic-Workflow Orchestration).
117
+
118
+ **Forcing a path (for testing).** Set `MANDREL_AUDIT_STRATEGY=sequential` to
119
+ verify the fallback path with the feature notionally disabled, or
120
+ `MANDREL_AUDIT_STRATEGY=orchestrated` to pin the dynamic path. To exercise the
121
+ real disable signals instead, set `CLAUDE_CODE_DISABLE_WORKFLOWS=1` (env) or
122
+ `disableWorkflows: true` in `.claude/settings.json` and re-run the lens — both
123
+ degrade to the sequential path.
124
+
125
+ ## Step 1: Deterministic Signal First
126
+
127
+ > Apply [`helpers/parallel-tooling.md`](helpers/parallel-tooling.md) when batching the scan below — independent reads belong in one turn, long shells run via `run_in_background` + `Monitor`.
128
+
129
+ Run the existing deterministic checkers before any semantic reading — they
130
+ are cheap, exact, and de-duplicate the easy findings:
131
+
132
+ ```bash
133
+ node .agents/scripts/check-doc-links.js
134
+ node .agents/scripts/check-lifecycle-doc-drift.js
135
+ node .agents/scripts/generate-config-docs.js --check
136
+ node .agents/scripts/generate-lifecycle-docs.js --check
137
+ node .agents/scripts/generate-workflows-doc.js --check
138
+ ```
139
+
140
+ Fold the results in as findings:
141
+
142
+ - **Checker failures** (broken links, lifecycle drift) become individual
143
+ findings with `Category: Link Integrity` (or `Generator Drift` for the
144
+ lifecycle gate), citing the checker output verbatim.
145
+ - **Generator dirtiness** (any `--check` reporting stale output, including
146
+ a stale `.claude/commands/` mirror) becomes **one single finding** with
147
+ `Category: Generator Drift` — never per-line findings — whose
148
+ remediation is "rerun `npm run docs:gen` / `npm run sync:commands` and
149
+ commit the regenerated output".
150
+
151
+ This lens orchestrates the existing checkers only; it does not add new
152
+ deterministic checker scripts.
153
+
154
+ ## Step 2: Semantic Claim Verification & Completeness
155
+
156
+ For every doc in the target set (minus the generated exclusions), verify
157
+ its claims against the code — read the doc, extract its testable claims,
158
+ and check each one:
159
+
160
+ 1. **Command & Script References:** Every referenced npm script exists in
161
+ `package.json`; every referenced CLI command and
162
+ `node .agents/scripts/<name>.js` invocation resolves to a real script
163
+ with the documented flags.
164
+ 2. **Path & Module References:** Every referenced file path, directory, and
165
+ module name exists at the stated location (account for moves and
166
+ renames).
167
+ 3. **Workflow & Contract Descriptions:** Described workflows, label
168
+ taxonomies (`agent::*`, `type::*`, `meta::*`), branch shapes
169
+ (`story-<id>`, `epic/<id>`), and artifact contracts match how the
170
+ current scripts actually behave — read the implementation when the
171
+ prose makes a behavioural claim.
172
+ 4. **Version & Topology Claims:** Version numbers, package names, release
173
+ topology, CI gate names, and tool-matrix claims are current.
174
+ 5. **Completeness:** Major surfaces with no documentation coverage in the
175
+ target set — workflows under `.agents/workflows/`, operator-facing
176
+ scripts under `.agents/scripts/`, and config keys in
177
+ `.agents/schemas/agentrc.schema.json` that no target-set doc mentions.
178
+ Report material gaps, not an exhaustive index.
179
+
180
+ Severity guidance: **High** = the doc instructs something that no longer
181
+ works (wrong command, deleted script, contract mismatch); **Medium** =
182
+ materially outdated description or missing coverage of a major surface;
183
+ **Low** = cosmetic drift, stale examples, tone/format inconsistencies.
184
+
185
+ ## Step 3: Output Requirements
186
+
187
+ Generate and save a highly structured Markdown audit report to
188
+ `{{auditOutputDir}}/audit-documentation-results.md`, using the exact
189
+ template below.
190
+
191
+ ```markdown
192
+ # Documentation Audit Report
193
+
194
+ ## Executive Summary
195
+
196
+ [Overview of documentation health (High/Medium/Low confidence that the docs
197
+ match the code), the deterministic-gate verdicts, and primary drift themes.]
198
+
199
+ ## Target Set Coverage
200
+
201
+ | Doc | Source | Verdict |
202
+ | ------ | --------------------------------------------------------------------- | ------------------------------- |
203
+ | [path] | [docsContextFiles · docsFreshness · anchor · --paths] | [Current · Drifted · Excluded (generated)] |
204
+
205
+ ## Detailed Findings
206
+
207
+ [For every gap identified, use the following strict structure:]
208
+
209
+ ### [Short Title of the Issue]
210
+
211
+ - **Category:** [Broken Instruction | Stale Description | Missing Coverage | Generator Drift | Link Integrity]
212
+ - **Impact:** [High | Medium | Low]
213
+ - **Current State:** [The doc, the exact claim, and what the code actually
214
+ does — cite file paths and lines on both sides]
215
+ - **Recommendation & Rationale:** [The specific doc edit (or generator
216
+ rerun) and why it restores accuracy]
217
+ - **Agent Prompt:**
218
+ `[A copy-pasteable, highly specific prompt to execute this doc fix independently]`
219
+ ```
220
+
221
+ ## Constraint
222
+
223
+ This workflow is **read-only** with respect to the repository: run the
224
+ deterministic checkers in `--check` mode only, and do not edit any
225
+ documentation or code. The single write is the report artifact. Provide the
226
+ analysis and remediation prompts; do not apply changes.
@@ -297,32 +297,25 @@ NDJSON line to `temp/epic-<epicId>/lifecycle.ndjson`; the matching
297
297
  after the Agent return is recorded in § 2c.
298
298
 
299
299
  Each Agent call's prompt must (1) name the Story + Epic ids, (2)
300
- instruct the child to invoke `helpers/epic-deliver-story <storyId>`, (3) state the
301
- **return contract** below, (4) remind the child of the
302
- **non-interactive contract** (no clarifying questions; transition to
303
- `agent::blocked` and exit if stuck), (5) ask the child to suppress
304
- per-Story chat relay and include its **terminal** `renderedBody` in the
305
- JSON return, and (6) require the child to emit a `story.heartbeat`
306
- lifecycle event at least once per Story-level phase transition via
307
- `node .agents/scripts/story-phase.js` (or whenever it stalls on a
308
- long-running step), and if it cannot make progress to transition
309
- to `agent::blocked` rather than fall silent. The pairing of
300
+ instruct the child to invoke `helpers/epic-deliver-story <storyId>`
301
+ (whose Step 4 defines the child's return shape), (3) remind the child
302
+ of the **non-interactive contract** (no clarifying questions;
303
+ transition to `agent::blocked` and exit if stuck), (4) ask the child to
304
+ suppress per-Story chat relay, and (5) require the child to emit a
305
+ `story.heartbeat` lifecycle event at least once per Story-level phase
306
+ transition via `node .agents/scripts/story-phase.js` (or whenever it
307
+ stalls on a long-running step), and if it cannot make progress to
308
+ transition to `agent::blocked` rather than fall silent. The pairing of
310
309
  `story.heartbeat` and `agent::blocked` is what lets the §2e Idle
311
310
  Watchdog distinguish a working child from a dead one; a silent child
312
311
  with no recent heartbeat and no blocker label is the failure mode the
313
312
  watchdog is built to catch.
314
313
 
315
- ```json
316
- {
317
- "storyId": <number>,
318
- "status": "done" | "blocked" | "failed",
319
- "phase": "init|implementing|closing|blocked|done",
320
- "branchDeleted": <boolean>,
321
- "blockerCommentId": <string|null>,
322
- "detail": <string|undefined>,
323
- "renderedBody": <string|undefined>
324
- }
325
- ```
314
+ There is **no per-child JSON return-parsing ceremony** for the parent
315
+ to enforce. GitHub state is the contract: `epic-execute-record-wave.js`
316
+ 2c, mode B) treats each child's raw return text as a best-effort
317
+ hint and reconciles any unparseable, empty, or missing return directly
318
+ from the Story's live labels and comments (Story #3907).
326
319
 
327
320
  **Sub-agent dispatch.** `Agent` calls emit no `model:` argument by
328
321
  default — children inherit from the `general-purpose` sub-agent
@@ -349,8 +342,8 @@ node .agents/scripts/epic-execute-record-wave.js \
349
342
  # `<inline-json>` shape: [{ "storyId": <n>, "returnText": "<raw text>" }]
350
343
  ```
351
344
 
352
- **Prefer mode B** when the host LLM can't fully verify every child's
353
- return is a parseable envelope. The CLI reconciles parse failures from
345
+ **Mode B is the default path** pipe the raw return texts through
346
+ without inspecting them. The CLI reconciles parse failures from
354
347
  GitHub, aggregates terminal status, appends to `state.waves[]`,
355
348
  re-renders `epic-run-progress`, and prints
356
349
  `{ status, nextAction, renderedBody, ... }`. Print `renderedBody`
@@ -14,7 +14,7 @@ Director / Architect
14
14
 
15
15
  You are the master orchestrator for the v5 Epic-Centric ticketing pipeline. Your
16
16
  goal is to transform a high-level Epic into a fully decomposed, ready-to-execute
17
- backlog of Features, Stories, and Tasks.
17
+ backlog of Features and Stories.
18
18
 
19
19
  `/epic-plan` is the unified planning entry point. It delegates to the two
20
20
  phase helpers — [`helpers/epic-plan-spec.md`](helpers/epic-plan-spec.md) and
@@ -120,21 +120,17 @@ tri-state carries one of three values:
120
120
 
121
121
  ### Step 0.6 — Initial `story-run-progress` snapshot
122
122
 
123
- Re-read the `story-init` comment, apply the install tri-state, and upsert
124
- the initial snapshot (`phase: "init"`):
125
-
126
- ```bash
127
- node .agents/scripts/story-deliver-prepare.js --story <storyId> --cwd .
128
- ```
129
-
130
- The CLI runs the install command when `dependenciesInstalled === 'false'`
131
- (default `npm ci`; override with `--install-cmd "<cmd>"`).
132
-
133
- The CLI's stdout JSON envelope carries a `renderedBody` field — the markdown
134
- body that was upserted onto the Story ticket. **Relay it verbatim to chat**
135
- so operators see the initial progress block before the first commit lands.
136
- Do the same after every transition in Step 1 / Step 3 (the body is the
137
- Story-level rollup the parent `/epic-deliver` aggregator reads).
123
+ Story #4017 inlined the former standalone prepare CLI into
124
+ `story-init.js`: Step 0's init run already applied the install tri-state
125
+ in-process (retrying the install command when
126
+ `dependenciesInstalled === 'false'`, default `npm ci`) and rendered the
127
+ initial snapshot (`phase: "init"`). There is no separate command to run.
128
+
129
+ The Step 0 result envelope carries a `prepare.renderedBody` field — the
130
+ markdown body for the initial Story-phase table. **Relay it verbatim to
131
+ chat** so operators see the initial progress block before the first commit
132
+ lands. Do the same after every transition in Step 1 / Step 3 (the body is
133
+ the Story-level rollup the parent `/epic-deliver` aggregator reads).
138
134
 
139
135
  ---
140
136
 
@@ -301,19 +297,12 @@ When run as a sub-agent, return one JSON object:
301
297
  > (`delivery.maxTokenBudget` elision).
302
298
 
303
299
  `branchDeleted` is sourced from the `branchDeleted` field of the
304
- `story-close.js` result envelope, which is `branchCleanup.localDeleted &&
305
- branchCleanup.remoteDeleted`. It is **independent** of `worktreeReap.status`.
306
- Specifically, when `worktreeReap.status === 'stale-registry-entry'` a
307
- Windows-only outcome where the worktree directory was removed and the local
308
- branch was deleted but `git worktree list` still shows the entry — the
309
- close still reports `branchDeleted: true` because the branch was honestly
310
- deleted; a pending-cleanup entry is recorded so the next post-close drain
311
- (or the next plan-time sweep) clears the stale `.git/worktrees/<name>/`
312
- registry entry. Treat `stale-registry-entry` as operationally complete
313
- when computing your return contract: `status: 'done'` is appropriate when
314
- all Tasks are closed and `branchDeleted: true`, regardless of whether
315
- `worktreeReap.status` is `'removed'`, `'removed-after-drain'`, or
316
- `'stale-registry-entry'`.
300
+ `story-close.js` result envelope. It is **independent** of
301
+ `worktreeReap.status` every reap outcome the close reports (including
302
+ the Windows-only `stale-registry-entry`, which queues a pending-cleanup
303
+ entry for the next drain) is operationally complete. `status: 'done'` is
304
+ appropriate when the Story is closed and `branchDeleted: true`,
305
+ regardless of the reap status.
317
306
 
318
307
  `renderedBody` is the **most recent** `renderedBody` returned by
319
308
  `story-phase.js` (typically the `phase: 'done'` snapshot at close,
@@ -632,5 +632,6 @@ safe.
632
632
 
633
633
  ## See also
634
634
 
635
- - [`/story-deliver`](../story-deliver.md) — Epic-attached Story execution.
635
+ - [`/story-deliver`](../story-deliver.md) — several standalone Stories at
636
+ once (dependency-aware waves).
636
637
  - [`/epic-deliver`](../epic-deliver.md) — full Epic wave loop.
@@ -46,9 +46,10 @@ genuinely missing, and `mandrel doctor` is read-only).
46
46
  ## Prerequisites
47
47
 
48
48
  1. Mandrel installed and bootstrapped into the project. The zero-to-installed
49
- path is `npx create-mandrel`, which installs the `mandrel`
50
- package, runs `mandrel sync` to materialize the `.agents/` bundle, and then
51
- execs `.agents/scripts/bootstrap.js` to provision the project (labels,
49
+ path is `npx mandrel init`, which installs the `mandrel`
50
+ package (when absent), runs `mandrel sync` to materialize the `.agents/`
51
+ bundle, and then on the **configure now** prompt option — execs
52
+ `.agents/scripts/bootstrap.js` to provision the project (labels,
52
53
  board, `.agentrc.json` seed). `/onboard` runs **after** that bootstrap
53
54
  completes — it does not invoke `bootstrap.js` itself, so the coupling is
54
55
  indirect: bootstrap owns first-time provisioning, `/onboard` owns the
@@ -277,7 +277,7 @@ duplication on the files the Story already touched:
277
277
  must be reverted.
278
278
  - **Advisory, not a gate.** This stage does **not** introduce a new
279
279
  close-validation gate and does **not** change the semantics of the existing
280
- [close-validation](../scripts/lib/close-validation.js) chain (typecheck,
280
+ [close-validation](../scripts/lib/close-validation/runner.js) chain (typecheck,
281
281
  lint, test, format, maintainability, coverage, crap). The canonical gates
282
282
  remain the single source of pass/fail at close; the refactor stage only adds
283
283
  an extra behaviour-preserving cleanup commit when enabled.
package/README.md CHANGED
@@ -31,11 +31,11 @@ package-manager combinations.
31
31
 
32
32
  ## Quickstart
33
33
 
34
- The canonical cold-start path is one launcher command, then two slash
34
+ The canonical cold-start path is one command, then two slash
35
35
  commands inside Claude Code:
36
36
 
37
37
  ```bash
38
- npx create-mandrel # install mandrel → sync → bootstrap
38
+ npx mandrel init # install mandrel → sync → prompt → bootstrap
39
39
  ```
40
40
 
41
41
  ```text
@@ -44,18 +44,23 @@ npx create-mandrel # install mandrel → sync → bootstrap
44
44
  /epic-plan # ideation -> PRD/Tech Spec -> Epic/Feature/Story hierarchy
45
45
  ```
46
46
 
47
- `create-mandrel` installs `mandrel`, materializes `./.agents/` via
48
- `mandrel sync`, and runs `node .agents/scripts/bootstrap.js` for you,
49
- forwarding any flags you pass. `/onboard` then walks you from a clean
50
- checkout to a planned Epic (stack detection, docs scaffolding, a
47
+ `npx mandrel init` installs `mandrel` (when `./.agents/` is absent),
48
+ materializes it via `mandrel sync`, then asks whether to **configure now**
49
+ (option 1 runs `node .agents/scripts/bootstrap.js`, forwarding any flags you
50
+ pass) or stop at **just the files** (option 2 re-run `mandrel init` any time
51
+ to configure). Pass `--assume-yes` for a non-interactive run that proceeds
52
+ straight to configure (and forwards the flag to bootstrap). When `./.agents/`
53
+ is already present (you ran `npm install mandrel` first), `init` skips the
54
+ install/sync and goes straight to the prompt. `/onboard` then walks you from a
55
+ clean checkout to a planned Epic (stack detection, docs scaffolding, a
51
56
  `mandrel doctor` readiness gate, and a started `/epic-plan`). Once you have a
52
57
  planned Epic, deliver it with `/epic-deliver <id>` (wave loop → validation →
53
58
  review → retro → open PR).
54
59
 
55
60
  ### Manual equivalent
56
61
 
57
- If you prefer to drive the three steps `create-mandrel` wraps by hand, run
58
- them from your project root:
62
+ If you prefer to drive the steps `mandrel init` wraps by hand, run them from
63
+ your project root:
59
64
 
60
65
  ```bash
61
66
  npm install mandrel # pin an exact, provenance-signed version
@@ -145,6 +150,14 @@ npx mandrel sync # re-materialize ./.agents/
145
150
  npx mandrel doctor # verify the install
146
151
  ```
147
152
 
153
+ ### Migrating from `@mandrelai/agents`
154
+
155
+ The framework package was renamed from the scoped `@mandrelai/agents` to the
156
+ unscoped `mandrel`. Already on the old name? `mandrel update` does **not**
157
+ auto-migrate (it resolves the package by name), so make the one-time manual
158
+ hop documented in
159
+ [`docs/migrate-mandrelai-to-mandrel.md`](docs/migrate-mandrelai-to-mandrel.md).
160
+
148
161
  ## Contributors
149
162
 
150
163
  Only `.agents/` is distributed to consumers — it ships inside the