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
package/.agents/README.md CHANGED
@@ -1,58 +1,62 @@
1
- # Mandrel — `.agents/`
2
-
3
- This is the framework payload (`.agents/`) consumed by host repos. It ships
4
- inside the [`mandrel`](https://www.npmjs.com/package/mandrel)
5
- npm package and is materialized into a consumer's `./.agents/` directory by
6
- `mandrel sync`. It carries a system prompt, a baseline rule pack, a
7
- two-tier skill library, a slash-command workflow set, and the
8
- orchestration engine that runs Epic → Feature → Story plans on
9
- GitHub. The framework version is the version of the installed
10
- [`mandrel`](https://www.npmjs.com/package/mandrel) npm
11
- package — run `npm ls mandrel` (or read `package.json`), not a
12
- count here.
1
+ # Mandrel Framework
13
2
 
14
- > **Ticket hierarchy.** Mandrel uses a **3-tier hierarchy**
15
- > (Epic Feature Story) with inline `acceptance[]` / `verify[]` on
16
- > Story bodies. See [`docs/SDLC.md` § Ticket hierarchy](docs/SDLC.md) for the
17
- > diagram and execution-model implications.
3
+ An opinionated workflow framework for AI coding assistants built on
4
+ Epic-centric GitHub orchestration. Planning, execution, and state all live natively in GitHub Issues, Labels, and Projects V2.
18
5
 
19
- This is the only README inside the distributed `.agents/` bundle. It
20
- explains what each part of the bundle is for and captures the
21
- cross-directory authoring conventions. The process narrative for
6
+ This is the consumer README inside the distributed `.agents/` bundle. It explains what each part of the bundle is for and captures the cross-directory authoring conventions. The process narrative for
22
7
  `/epic-plan` and `/epic-deliver` stays in [`docs/SDLC.md`](docs/SDLC.md).
23
8
 
9
+ The framework payload (`.agents/`) is consumed by host repos. It ships inside the [`mandrel`](https://www.npmjs.com/package/mandrel)
10
+ npm package and is materialized into a consumer's `./.agents/` directory by `mandrel sync`. It carries a system prompt, a baseline rule pack, a two-tier skill library, a slash-command workflow set, and the orchestration engine that runs Epic → Feature → Story plans on GitHub.
11
+
12
+ The framework version is the version of the installed [`mandrel`](https://www.npmjs.com/package/mandrel) npm package — run `npm ls mandrel` (or read `package.json`), not a
13
+ count here.
14
+
24
15
  ---
25
16
 
26
17
  ## Activation
27
18
 
28
- ### Cold start — `npx create-mandrel`
19
+ ### All-in-one Install
29
20
 
30
- The canonical cold-start path is a single launcher command, run from the
31
- root of your project (the folder does **not** need to be a git repo yet):
21
+ From an **empty or existing** local directory, run:
32
22
 
33
23
  ```bash
34
- npx create-mandrel # install mandrelmandrel sync bootstrap.js
24
+ npx mandrel init # install (if absent) prompt: configure now, or just the files
35
25
  ```
36
26
 
37
- `create-mandrel` installs `mandrel`, materializes `./.agents/` via
38
- `mandrel sync` (skipping the install when `.agents/` already exists), and
39
- finishes by running `node .agents/scripts/bootstrap.js`, forwarding any flags
40
- you pass. After it completes, run **`/onboard`** inside Claude Code for the
41
- guided first run — stack detection, docs scaffolding, a `mandrel doctor`
42
- readiness gate, and a started `/epic-plan` handoff.
27
+ `mandrel init` first **installs the framework if `./.agents/` is absent** —
28
+ `npm install mandrel --ignore-scripts` followed by an explicit `mandrel sync`,
29
+ so the materialization is a single deterministic step rather than a
30
+ postinstall-then-init double sync. When `./.agents/` already exists from a prior install, it skips straight to the prompt the one subcommand is idempotent across both entry points.
31
+
32
+ It then shows a **two-option prompt**:
33
+
34
+ 1. **Configure now** — runs `node .agents/scripts/bootstrap.js`, forwarding any
35
+ passthrough flags unchanged, to wire the project and GitHub side (creates the
36
+ GitHub repo + Projects board).
37
+ 2. **Just the files** — stops after materialization and prints a re-run hint
38
+ (`mandrel init`) so you can configure later.
43
39
 
44
- The remainder of this section documents the manual steps `create-mandrel`
45
- wraps, for operators who prefer to drive them by hand.
40
+ `--assume-yes` skips the prompt and configures non-interactively (the flag is
41
+ also forwarded to `bootstrap.js`); a non-TTY run without `--assume-yes` defaults
42
+ to **files-only**, so the side-effecting GitHub provisioning never runs
43
+ unattended.
46
44
 
47
- ### Manual cold start install the npm package
45
+ After it completes, run **`/onboard`** inside Claude Code for the guided first
46
+ run — stack detection, docs scaffolding, a `mandrel doctor` readiness gate, and
47
+ a started `/epic-plan` handoff.
48
+
49
+ ### Manual Install
50
+
51
+ This section documents the manual steps `mandrel init` wraps, for operators who prefer to drive them by hand.
52
+
53
+ #### Mandrel Package
48
54
 
49
55
  From an **empty or existing** project that does not yet have `.agents/`,
50
56
  install the package and materialize the framework payload:
51
57
 
52
58
  ```bash
53
59
  npm install mandrel
54
- # pnpm add mandrel
55
- # yarn add mandrel
56
60
  ```
57
61
 
58
62
  Installing `mandrel` pins an exact, provenance-signed version in
@@ -69,13 +73,43 @@ npx mandrel sync --dry-run # preview the planned copies, write nothing
69
73
  npx mandrel doctor # confirm the install is healthy
70
74
  ```
71
75
 
72
- Then run the bootstrap to wire the project and GitHub side:
76
+ #### Bootstrap Config
73
77
 
74
- ```bash
75
- node .agents/scripts/bootstrap.js
76
- ```
78
+ To wire the local directory and GitHub, run `npx mandrel init` again or use the bootstrapper directly: `node .agents/scripts/bootstrap.js`
79
+
80
+ The bootstrap pipeline, in order:
81
+
82
+ 1. **Preflight gate (runs first, before any mutation).** A single
83
+ fail-before-mutate check confirms Node is at the required major
84
+ version, `git` is on `PATH`, the command is running inside a git work
85
+ tree, and — unless `--skip-github` is set — that the `gh` CLI is
86
+ installed and authenticated. If any check fails the bootstrap prints
87
+ each failing check's remedy and halts with exit 1 **before** touching
88
+ a single file or making a GitHub call, so a half-configured repo is
89
+ never left behind.
90
+ 2. **Resolve answers (owner / repo / base branch / operator handle /
91
+ project number).** Defaults are inferred from the local `git remote`
92
+ and config (no network calls). Each value is resolved through a
93
+ priority chain: CLI flag → environment variable
94
+ (`GH_OWNER`, `GH_REPO`, …) → silently-accepted inferred default →
95
+ interactive picker → free-text prompt → `--assume-yes` default.
96
+ 3. **Project-side mutations.** Seeds `.agentrc.json` from
97
+ [`starter-agentrc.json`](starter-agentrc.json), merges the framework's
98
+ runtime dependencies into `package.json`, runs the install, wires the
99
+ command-sync hook (the UserPromptSubmit hook that regenerates the flat
100
+ `.claude/commands/` tree so every `/<command>` loads), wires the system
101
+ prompt (see below), gitignores derived artefacts, and runs the
102
+ quality-gates installer.
103
+ 4. **GitHub-side mutations.** Creates the label taxonomy, Project V2
104
+ fields, branch protection, and merge-method settings. Skipped with
105
+ `--skip-github`.
77
106
 
78
- ### Upgrading and local additions
107
+ The bootstrap is idempotent — safe to re-run; an already-configured
108
+ clone produces zero file mutations.
109
+
110
+ ---
111
+
112
+ ## Upgrading and local additions
79
113
 
80
114
  Once installed, the ongoing upgrade path is **`mandrel update`** — it bumps
81
115
  `mandrel` to the newest non-major version, re-runs `mandrel sync`,
@@ -107,53 +141,9 @@ the consumer-owned space `mandrel sync` never copies into nor prunes and the
107
141
  drift check treats as sanctioned, so keep project-specific skills and local
108
142
  workflow fragments there rather than editing synced files in place.
109
143
 
110
- ### Run the unified bootstrap directly
111
-
112
- When `.agents/` is already materialized, run the bootstrap straight from the
113
- host repo root:
114
-
115
- ```bash
116
- node .agents/scripts/bootstrap.js
117
- # bootstrap also seeds a discoverable npm alias, so after the first run:
118
- npm run bootstrap
119
- ```
120
-
121
- The bootstrap adds an `npm run bootstrap` script to the consumer's
122
- `package.json` (pointing at `node .agents/scripts/bootstrap.js`) the
123
- first time it runs — an operator-defined `bootstrap` script always wins,
124
- so the seed is skipped when the key already exists.
125
-
126
- The bootstrap pipeline, in order:
127
-
128
- 1. **Preflight gate (runs first, before any mutation).** A single
129
- fail-before-mutate check confirms Node is at the required major
130
- version, `git` is on `PATH`, the command is running inside a git work
131
- tree, and — unless `--skip-github` is set — that the `gh` CLI is
132
- installed and authenticated. If any check fails the bootstrap prints
133
- each failing check's remedy and halts with exit 1 **before** touching
134
- a single file or making a GitHub call, so a half-configured repo is
135
- never left behind.
136
- 2. **Resolve answers (owner / repo / base branch / operator handle /
137
- project number).** Defaults are inferred from the local `git remote`
138
- and config (no network calls). Each value is resolved through a
139
- priority chain: CLI flag → environment variable
140
- (`GH_OWNER`, `GH_REPO`, …) → silently-accepted inferred default →
141
- interactive picker → free-text prompt → `--assume-yes` default.
142
- 3. **Project-side mutations.** Seeds `.agentrc.json` from
143
- [`starter-agentrc.json`](starter-agentrc.json), merges the framework's
144
- runtime dependencies into `package.json`, runs the install, wires the
145
- command-sync hook (the UserPromptSubmit hook that regenerates the flat
146
- `.claude/commands/` tree so every `/<command>` loads), wires the system
147
- prompt (see below), gitignores derived artefacts, and runs the
148
- quality-gates installer.
149
- 4. **GitHub-side mutations.** Creates the label taxonomy, Project V2
150
- fields, branch protection, and merge-method settings. Skipped with
151
- `--skip-github`.
152
-
153
- The bootstrap is idempotent — safe to re-run; an already-configured
154
- clone produces zero file mutations.
144
+ ---
155
145
 
156
- ### Automatic system-prompt wiring
146
+ ## Automatic system-prompt wiring
157
147
 
158
148
  The bootstrap wires the framework system prompt into a project-root
159
149
  `CLAUDE.md` automatically, so there is no manual "load the system prompt"
@@ -170,7 +160,9 @@ If your AI tool is not Claude Code, load
170
160
  [`instructions.md`](instructions.md) verbatim through that tool's own
171
161
  system-prompt mechanism (`.cursorrules`, Custom Instructions, etc.).
172
162
 
173
- ### Interactive repo / project pickers
163
+ ---
164
+
165
+ ## Interactive repo / project pickers
174
166
 
175
167
  When the bootstrap runs interactively (a TTY, and `--assume-yes` is not
176
168
  set), the **repo** and **project-number** questions render a live,
@@ -202,7 +194,9 @@ an end-to-end Epic; standalone Stories pair
202
194
  Issue) with [`/story-deliver`](workflows/story-deliver.md) (Story Issue → merged
203
195
  PR).
204
196
 
205
- ### Runtime dependencies
197
+ ---
198
+
199
+ ## Runtime dependencies
206
200
 
207
201
  The framework scripts under `.agents/scripts/` import a small set of
208
202
  third-party npm packages at runtime. The materialized `./.agents/` tree
@@ -237,6 +231,14 @@ in `runtime-deps.json`.
237
231
 
238
232
  ---
239
233
 
234
+ ## Ticket Hierarchy
235
+
236
+ Mandrel uses a **3-tier hierarchy**, (Epic → Feature → Story) with inline `acceptance[]` / `verify[]` on story bodies.
237
+
238
+ See [`docs/SDLC.md` § Ticket hierarchy](docs/SDLC.md) for the diagram and execution-model implications.
239
+
240
+ ---
241
+
240
242
  ## Contents
241
243
 
242
244
  | Path | Purpose |
@@ -225,7 +225,7 @@ graph LR
225
225
 
226
226
  subgraph Phase0 ["Phase 0: Bootstrap"]
227
227
  direction TB
228
- Z["👤 npx create-mandrel<br/>(install → sync → bootstrap.js)"]:::manual
228
+ Z["👤 npx mandrel init<br/>(install → sync → prompt → bootstrap.js)"]:::manual
229
229
  Z2["👤 /onboard (guided first run)"]:::manual
230
230
  Z --> Z2
231
231
  end
@@ -272,15 +272,19 @@ wire the framework system prompt, and create the GitHub labels, Projects V2
272
272
  fields, and (when enabled) main-branch protection the orchestration engine
273
273
  depends on.
274
274
 
275
- The canonical cold-start path is a single launcher command:
275
+ The canonical cold-start path is a single command:
276
276
 
277
277
  ```bash
278
- npx create-mandrel
278
+ npx mandrel init
279
279
  ```
280
280
 
281
- `create-mandrel` installs `mandrel`, materializes `./.agents/` via
282
- `mandrel sync`, and runs `node .agents/scripts/bootstrap.js`, forwarding any
283
- flags you pass. `bootstrap.js`:
281
+ `mandrel init` installs `mandrel` (when `./.agents/` is absent), materializes
282
+ `./.agents/` via `mandrel sync`, then presents a two-option prompt: **configure
283
+ now** (option 1 → runs `node .agents/scripts/bootstrap.js`, forwarding any flags
284
+ you pass) or **just the files** (option 2 → re-run `mandrel init` any time to
285
+ configure later). `--assume-yes` skips the prompt and proceeds straight to
286
+ configure (and is forwarded to bootstrap); a non-TTY run without it defaults to
287
+ files-only so the GitHub provisioning never runs unattended. `bootstrap.js`:
284
288
 
285
289
  1. **Provisions a cold start.** Initializes the local git repo (with a first
286
290
  commit) when absent, creates the GitHub repo (`gh repo create --source=.
@@ -1404,7 +1408,7 @@ For Stories already in flight, use one of the three options above.
1404
1408
 
1405
1409
  | Command | Purpose |
1406
1410
  | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1407
- | `npx create-mandrel` | Cold-start launcher — install `mandrel`, `mandrel sync`, then run `bootstrap.js` (provisions repo + Projects V2 board, labels, branch protection). |
1411
+ | `npx mandrel init` | Cold-start command — install `mandrel` (if absent), `mandrel sync`, then prompt to run `bootstrap.js` (provisions repo + Projects V2 board, labels, branch protection). |
1408
1412
  | `/onboard` | Guided first run after bootstrap — stack detection, docs scaffolding, `mandrel doctor` readiness gate, started `/epic-plan` handoff. |
1409
1413
  | `/epic-plan` | Ideation entry — sharpen idea, search duplicates, open Epic, then PRD + Tech Spec + decomposition. |
1410
1414
  | `/epic-plan --idea "<seed>"` | Same ideation entry with pre-supplied seed. |
@@ -25,7 +25,7 @@ by `node .agents/scripts/generate-workflows-doc.js`; `npm run docs:check`
25
25
  fails when it drifts from the on-disk workflow set. To change a command’s
26
26
  description, edit the workflow file’s front-matter and regenerate.
27
27
 
28
- ## Commands (28)
28
+ ## Commands (29)
29
29
 
30
30
  | Command | Description |
31
31
  | --- | --- |
@@ -34,6 +34,7 @@ description, edit the workflow file’s front-matter and regenerate.
34
34
  | `/audit-clean-code` | Audit code smells, dead code, complexity hotspots, and maintainability-index outliers; emit a structured findings report. |
35
35
  | `/audit-dependencies` | Audit `package.json` for unused, outdated, and major-version-stale dependencies; surface Node-engine drift and propose upgrade batches. |
36
36
  | `/audit-devops` | Audit CI/CD workflows, container images, infrastructure-as-code, and deployment pipelines; surface failure modes and hardening gaps. |
37
+ | `/audit-documentation` | Audit the repository's main documentation for staleness, semantic drift, and completeness; emit a structured High/Medium/Low findings report. |
37
38
  | `/audit-lighthouse` | Run a Lighthouse audit (Performance / Accessibility / Best Practices / SEO) and produce a structured findings report |
38
39
  | `/audit-performance` | Audit hot paths, algorithmic complexity, and I/O bottlenecks in the tooling surface (`epic-close`, dispatcher, gates); propose remediations. |
39
40
  | `/audit-privacy` | Audit logs, telemetry, and persistence paths for PII leakage and retention violations; surface secrets exposure and consent gaps. |
@@ -73,6 +73,26 @@
73
73
  "triggers": { "gates": ["gate4"] },
74
74
  "substitutionKeys": []
75
75
  },
76
+ "audit-documentation": {
77
+ "triggers": {
78
+ "gates": ["gate1", "gate3"],
79
+ "keywords": [
80
+ "documentation",
81
+ "docs",
82
+ "readme",
83
+ "changelog",
84
+ "runbook",
85
+ "stale docs"
86
+ ],
87
+ "filePatterns": [
88
+ "**/*.md",
89
+ "docs/**",
90
+ ".agents/docs/**",
91
+ ".agents/workflows/**"
92
+ ]
93
+ },
94
+ "substitutionKeys": []
95
+ },
76
96
  "audit-dependencies": {
77
97
  "triggers": {
78
98
  "gates": ["gate1", "gate3"],
@@ -61,6 +61,7 @@ import { appendSignal } from './lib/observability/signals-writer.js';
61
61
  import {
62
62
  buildAcceptanceEvalSignal,
63
63
  decideAcceptanceEval,
64
+ deriveAcceptanceEvalRound,
64
65
  } from './lib/orchestration/acceptance-eval-decision.js';
65
66
 
66
67
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -152,17 +153,33 @@ function parseCliArgs(argv) {
152
153
  * @param {object} args.verdict — validated verdict object.
153
154
  * @param {object} args.config — resolved `.agentrc.json`.
154
155
  * @param {boolean} args.emitSignal
156
+ * @param {number} [args.round] — explicit round override (tests). When
157
+ * absent, the round is derived by counting prior `acceptance-eval`
158
+ * signals in the Story's `signals.ndjson` (Story #4019); the verdict's
159
+ * self-reported `round` is never load-bearing for the cap.
155
160
  * @param {object} [deps]
156
161
  * @param {Function} [deps.appendSignalFn]
162
+ * @param {Function} [deps.deriveRoundFn]
157
163
  * @returns {Promise<{ envelope: object, exitCode: number }>}
158
164
  */
159
165
  export async function runAcceptanceEval(
160
- { storyId, epicId, verdict, config, emitSignal },
166
+ { storyId, epicId, verdict, config, emitSignal, round },
161
167
  deps = {},
162
168
  ) {
163
- const { appendSignalFn = appendSignal } = deps;
169
+ const {
170
+ appendSignalFn = appendSignal,
171
+ deriveRoundFn = deriveAcceptanceEvalRound,
172
+ } = deps;
164
173
  const { maxRounds } = getAcceptanceEval(config);
165
- const outcome = decideAcceptanceEval({ verdict, maxRounds });
174
+ const resolvedRound =
175
+ Number.isInteger(round) && round >= 1
176
+ ? round
177
+ : deriveRoundFn({ epicId: epicId ?? null, storyId, config });
178
+ const outcome = decideAcceptanceEval({
179
+ verdict,
180
+ maxRounds,
181
+ round: resolvedRound,
182
+ });
166
183
 
167
184
  let signalEmitted = false;
168
185
  if (emitSignal) {
@@ -20,11 +20,9 @@
20
20
  */
21
21
 
22
22
  import { fileURLToPath } from 'node:url';
23
-
24
- import { PROJECT_ROOT } from './lib/config-resolver.js';
25
23
  import { gitSpawn } from './lib/git-utils.js';
26
-
27
24
  import { Logger } from './lib/Logger.js';
25
+ import { PROJECT_ROOT } from './lib/project-root.js';
28
26
  export function assertBranch(expected, { cwd = PROJECT_ROOT } = {}) {
29
27
  if (!expected || typeof expected !== 'string') {
30
28
  return { ok: false, reason: 'missing --expected <branch>' };
@@ -1353,7 +1353,7 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
1353
1353
  // the failure is surfaced, not silently rolled back), but they MUST NOT
1354
1354
  // exit 0. `executeGithubBootstrap` records `report.github.error` instead
1355
1355
  // of throwing; detect it here and exit non-zero with a distinct final
1356
- // status line so `create-mandrel` and CI see the failure (Story #3898).
1356
+ // status line so `mandrel init` and CI see the failure (Story #3898).
1357
1357
  const githubError = result.state?.report?.github?.error;
1358
1358
  if (githubError) {
1359
1359
  Logger.error(