cohorte 3.0.0-dev.7 → 3.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 (229) hide show
  1. package/CHANGELOG.md +1532 -0
  2. package/README.md +106 -185
  3. package/bin/cli.js +212 -0
  4. package/bin/report.js +141 -0
  5. package/core/agents/cohorte-profile-reader.md +50 -0
  6. package/core/agents/cohorte-release.md +58 -0
  7. package/core/agents/cohorte-review.md +174 -0
  8. package/core/agents/implementer.template.md +146 -0
  9. package/core/commands/cohorte-align-ds.md +33 -0
  10. package/core/commands/cohorte-audit.md +67 -0
  11. package/core/commands/cohorte-brainstorm.md +73 -0
  12. package/core/commands/cohorte-build.md +241 -0
  13. package/core/commands/cohorte-doctor.md +133 -0
  14. package/core/commands/cohorte-fix.md +80 -0
  15. package/core/commands/cohorte-fleet.md +111 -0
  16. package/core/commands/cohorte-init-pipeline.md +30 -0
  17. package/core/commands/cohorte-intake.md +92 -0
  18. package/core/commands/cohorte-patch.md +118 -0
  19. package/core/commands/cohorte-refactor.md +57 -0
  20. package/core/commands/cohorte-retro.md +85 -0
  21. package/core/commands/cohorte-review.md +224 -0
  22. package/core/commands/cohorte-ship.md +155 -0
  23. package/core/commands/cohorte-spec.md +105 -0
  24. package/core/commands/cohorte-update-pipeline.md +115 -0
  25. package/core/hooks/gate.py +2931 -0
  26. package/core/templates/agent-handoff.md +34 -0
  27. package/core/templates/brainstorm-return.md +42 -0
  28. package/core/templates/decisions.template.md +42 -0
  29. package/core/templates/design-brief.md +37 -0
  30. package/core/templates/patch.template.md +86 -0
  31. package/core/templates/pr-body.md +25 -0
  32. package/core/templates/review-feedback.md +46 -0
  33. package/core/templates/spec.template.md +88 -0
  34. package/core/templates/steps/init-pipeline/01-detect-stack.md +44 -0
  35. package/core/templates/steps/init-pipeline/02-interview-gaps.md +55 -0
  36. package/core/templates/steps/init-pipeline/03-draft-profile.md +9 -0
  37. package/core/templates/steps/init-pipeline/04-write-render.md +91 -0
  38. package/core/templates/steps/init-pipeline/05-report.md +11 -0
  39. package/core/templates/steps/review-pr/01-pr-mode.md +54 -0
  40. package/core/workflows/audit.js +306 -0
  41. package/core/workflows/loop.js +687 -0
  42. package/core/workflows/refactor.js +291 -0
  43. package/core/workflows/review.js +491 -0
  44. package/install.ps1 +72 -0
  45. package/install.sh +69 -0
  46. package/lib/doctor.js +472 -0
  47. package/lib/install.js +377 -0
  48. package/lib/project.js +322 -0
  49. package/lib/render.js +121 -0
  50. package/lib/versions.js +145 -0
  51. package/lib/yaml.js +174 -0
  52. package/package.json +36 -17
  53. package/profile/PIPELINE.template.md +250 -0
  54. package/profile/SCHEMA.md +749 -0
  55. package/profile/cohorte.config.template.yaml +43 -0
  56. package/scripts/feature-diff.sh +118 -0
  57. package/scripts/kanban-move.sh +307 -0
  58. package/scripts/metrics/collect.mjs +542 -0
  59. package/scripts/metrics/prices.json +42 -0
  60. package/scripts/new-feature.sh.template +122 -0
  61. package/scripts/preflight.sh +114 -0
  62. package/scripts/remove-feature.sh.template +56 -0
  63. package/assets/manifest.json +0 -203
  64. package/assets/migrations/config/README.md +0 -12
  65. package/assets/migrations/state/0001_init.sql +0 -154
  66. package/assets/prompts/README.md +0 -11
  67. package/assets/prompts/agents/brainstormer.md +0 -3
  68. package/assets/prompts/agents/fixer.md +0 -7
  69. package/assets/prompts/agents/implementer.md +0 -12
  70. package/assets/prompts/agents/reviewer.md +0 -8
  71. package/assets/prompts/agents/security-reviewer.md +0 -7
  72. package/assets/prompts/agents/spec-author.md +0 -3
  73. package/assets/prompts/phases/build.md +0 -5
  74. package/assets/prompts/phases/review.md +0 -5
  75. package/assets/prompts/phases/test.md +0 -5
  76. package/assets/prompts/system.md +0 -11
  77. package/assets/schemas/agent-output.schema.json +0 -225
  78. package/assets/schemas/auth-status.schema.json +0 -87
  79. package/assets/schemas/command-result.schema.json +0 -192
  80. package/assets/schemas/commands.schema.json +0 -959
  81. package/assets/schemas/config.schema.json +0 -2281
  82. package/assets/schemas/doctor-report.schema.json +0 -104
  83. package/assets/schemas/events.schema.json +0 -8514
  84. package/assets/schemas/fake-script.schema.json +0 -549
  85. package/assets/schemas/inspect.schema.json +0 -3133
  86. package/assets/schemas/manifest.schema.json +0 -79
  87. package/assets/schemas/ownership.schema.json +0 -52
  88. package/assets/schemas/policy-verdict.schema.json +0 -282
  89. package/assets/schemas/project-model.schema.json +0 -783
  90. package/assets/schemas/project-status.schema.json +0 -217
  91. package/assets/schemas/reconcile-plan.schema.json +0 -154
  92. package/assets/schemas/run-diff.schema.json +0 -177
  93. package/assets/schemas/run-snapshot-manifest.schema.json +0 -2104
  94. package/assets/schemas/run-state.schema.json +0 -1755
  95. package/assets/schemas/runtime-capabilities.schema.json +0 -1545
  96. package/assets/schemas/sandbox-capabilities.schema.json +0 -116
  97. package/assets/schemas/skill.schema.json +0 -87
  98. package/assets/schemas/spec.schema.json +0 -202
  99. package/assets/schemas/tool-catalogue.schema.json +0 -655
  100. package/assets/schemas/trust-record.schema.json +0 -38
  101. package/assets/skills/README.md +0 -9
  102. package/assets/skills/inspect-surface.md +0 -4
  103. package/dist/agent-host.mjs +0 -2187
  104. package/dist/agent-host.mjs.map +0 -1
  105. package/dist/bundle-manifest.json +0 -128
  106. package/dist/chunks/__host-DgGPyco9.mjs +0 -18
  107. package/dist/chunks/__host-DgGPyco9.mjs.map +0 -1
  108. package/dist/chunks/align-ds-r_X_1aQ_.mjs +0 -93
  109. package/dist/chunks/align-ds-r_X_1aQ_.mjs.map +0 -1
  110. package/dist/chunks/approve-Cv135UqI.mjs +0 -19
  111. package/dist/chunks/approve-Cv135UqI.mjs.map +0 -1
  112. package/dist/chunks/audit-B4ZWQ_DI.mjs +0 -179
  113. package/dist/chunks/audit-B4ZWQ_DI.mjs.map +0 -1
  114. package/dist/chunks/auth-BT5oVp76.mjs +0 -132
  115. package/dist/chunks/auth-BT5oVp76.mjs.map +0 -1
  116. package/dist/chunks/auth-Dnlksuo5.mjs +0 -141
  117. package/dist/chunks/auth-Dnlksuo5.mjs.map +0 -1
  118. package/dist/chunks/brainstorm-DasVwI1D.mjs +0 -123
  119. package/dist/chunks/brainstorm-DasVwI1D.mjs.map +0 -1
  120. package/dist/chunks/build-crOld8gE.mjs +0 -19
  121. package/dist/chunks/build-crOld8gE.mjs.map +0 -1
  122. package/dist/chunks/cancel-KV_cpsqS.mjs +0 -15
  123. package/dist/chunks/cancel-KV_cpsqS.mjs.map +0 -1
  124. package/dist/chunks/canonical-C8UxeEmB.mjs +0 -57
  125. package/dist/chunks/canonical-C8UxeEmB.mjs.map +0 -1
  126. package/dist/chunks/catalogue-IaCJdfB8.mjs +0 -1549
  127. package/dist/chunks/catalogue-IaCJdfB8.mjs.map +0 -1
  128. package/dist/chunks/compose-DRKjQcn0.mjs +0 -7333
  129. package/dist/chunks/compose-DRKjQcn0.mjs.map +0 -1
  130. package/dist/chunks/config-Cqu5XQoP.mjs +0 -96
  131. package/dist/chunks/config-Cqu5XQoP.mjs.map +0 -1
  132. package/dist/chunks/contract-DjssDPpS.mjs +0 -335
  133. package/dist/chunks/contract-DjssDPpS.mjs.map +0 -1
  134. package/dist/chunks/contract-bQ9FJl4N.mjs +0 -123
  135. package/dist/chunks/contract-bQ9FJl4N.mjs.map +0 -1
  136. package/dist/chunks/deny-ClTxSvHJ.mjs +0 -15
  137. package/dist/chunks/deny-ClTxSvHJ.mjs.map +0 -1
  138. package/dist/chunks/diff-Qw0II0sj.mjs +0 -101
  139. package/dist/chunks/diff-Qw0II0sj.mjs.map +0 -1
  140. package/dist/chunks/discover-BZPolSZG.mjs +0 -21
  141. package/dist/chunks/discover-BZPolSZG.mjs.map +0 -1
  142. package/dist/chunks/doctor-DcDFPvQM.mjs +0 -222
  143. package/dist/chunks/doctor-DcDFPvQM.mjs.map +0 -1
  144. package/dist/chunks/fix-B_oGzGVn.mjs +0 -82
  145. package/dist/chunks/fix-B_oGzGVn.mjs.map +0 -1
  146. package/dist/chunks/fleet-yWHQY2ya.mjs +0 -297
  147. package/dist/chunks/fleet-yWHQY2ya.mjs.map +0 -1
  148. package/dist/chunks/gc-BBXlBF5w.mjs +0 -161
  149. package/dist/chunks/gc-BBXlBF5w.mjs.map +0 -1
  150. package/dist/chunks/init--FxxkrcT.mjs +0 -63
  151. package/dist/chunks/init--FxxkrcT.mjs.map +0 -1
  152. package/dist/chunks/inspect-Buby4cQD.mjs +0 -22
  153. package/dist/chunks/inspect-Buby4cQD.mjs.map +0 -1
  154. package/dist/chunks/intake-Dd1KVXnO.mjs +0 -12
  155. package/dist/chunks/intake-Dd1KVXnO.mjs.map +0 -1
  156. package/dist/chunks/logs-Giq5sUau.mjs +0 -25
  157. package/dist/chunks/logs-Giq5sUau.mjs.map +0 -1
  158. package/dist/chunks/loop-BWsUpyus.mjs +0 -212
  159. package/dist/chunks/loop-BWsUpyus.mjs.map +0 -1
  160. package/dist/chunks/migrate-DuYCAbE3.mjs +0 -33
  161. package/dist/chunks/migrate-DuYCAbE3.mjs.map +0 -1
  162. package/dist/chunks/models-Btp6X2YZ.mjs +0 -24
  163. package/dist/chunks/models-Btp6X2YZ.mjs.map +0 -1
  164. package/dist/chunks/obsidian-BHLkXx_H.mjs +0 -235
  165. package/dist/chunks/obsidian-BHLkXx_H.mjs.map +0 -1
  166. package/dist/chunks/patch-sAgVqjpx.mjs +0 -50
  167. package/dist/chunks/patch-sAgVqjpx.mjs.map +0 -1
  168. package/dist/chunks/pause-BASBfKLO.mjs +0 -16
  169. package/dist/chunks/pause-BASBfKLO.mjs.map +0 -1
  170. package/dist/chunks/policy-Du7WVBFX.mjs +0 -139
  171. package/dist/chunks/policy-Du7WVBFX.mjs.map +0 -1
  172. package/dist/chunks/providers-Dx78imKj.mjs +0 -19
  173. package/dist/chunks/providers-Dx78imKj.mjs.map +0 -1
  174. package/dist/chunks/reconcile-BHn66X3C.mjs +0 -50
  175. package/dist/chunks/reconcile-BHn66X3C.mjs.map +0 -1
  176. package/dist/chunks/refactor-CoNoqLZr.mjs +0 -153
  177. package/dist/chunks/refactor-CoNoqLZr.mjs.map +0 -1
  178. package/dist/chunks/render-DyZr5Lgi.mjs +0 -53
  179. package/dist/chunks/render-DyZr5Lgi.mjs.map +0 -1
  180. package/dist/chunks/resume-GJQRb2Eb.mjs +0 -15
  181. package/dist/chunks/resume-GJQRb2Eb.mjs.map +0 -1
  182. package/dist/chunks/retro-Dr-2RTNN.mjs +0 -78
  183. package/dist/chunks/retro-Dr-2RTNN.mjs.map +0 -1
  184. package/dist/chunks/retry-CLrUem1H.mjs +0 -15
  185. package/dist/chunks/retry-CLrUem1H.mjs.map +0 -1
  186. package/dist/chunks/review-ZsBqp3vZ.mjs +0 -35
  187. package/dist/chunks/review-ZsBqp3vZ.mjs.map +0 -1
  188. package/dist/chunks/run-NGAxdsIX.mjs +0 -105
  189. package/dist/chunks/run-NGAxdsIX.mjs.map +0 -1
  190. package/dist/chunks/run-tool-C3rAv4XF.mjs +0 -26
  191. package/dist/chunks/run-tool-C3rAv4XF.mjs.map +0 -1
  192. package/dist/chunks/scan-C5uDr7Yq.mjs +0 -167
  193. package/dist/chunks/scan-C5uDr7Yq.mjs.map +0 -1
  194. package/dist/chunks/schema-Bq9qtgsd.mjs +0 -583
  195. package/dist/chunks/schema-Bq9qtgsd.mjs.map +0 -1
  196. package/dist/chunks/send-BdnJ85Nz.mjs +0 -19
  197. package/dist/chunks/send-BdnJ85Nz.mjs.map +0 -1
  198. package/dist/chunks/ship-BizfUe62.mjs +0 -140
  199. package/dist/chunks/ship-BizfUe62.mjs.map +0 -1
  200. package/dist/chunks/shutdown-BM92Iyv2.mjs +0 -15
  201. package/dist/chunks/shutdown-BM92Iyv2.mjs.map +0 -1
  202. package/dist/chunks/skip-DZG5kpcH.mjs +0 -18
  203. package/dist/chunks/skip-DZG5kpcH.mjs.map +0 -1
  204. package/dist/chunks/spec-C2h3U64g.mjs +0 -65
  205. package/dist/chunks/spec-C2h3U64g.mjs.map +0 -1
  206. package/dist/chunks/spec-path-tptqR7W8.mjs +0 -10
  207. package/dist/chunks/spec-path-tptqR7W8.mjs.map +0 -1
  208. package/dist/chunks/src-Bfr1yzsn.mjs +0 -1689
  209. package/dist/chunks/src-Bfr1yzsn.mjs.map +0 -1
  210. package/dist/chunks/src-CPW2_Ons.mjs +0 -5487
  211. package/dist/chunks/src-CPW2_Ons.mjs.map +0 -1
  212. package/dist/chunks/src-Cu3TxNob.mjs +0 -783
  213. package/dist/chunks/src-Cu3TxNob.mjs.map +0 -1
  214. package/dist/chunks/src-DNsLSxgm.mjs +0 -928
  215. package/dist/chunks/src-DNsLSxgm.mjs.map +0 -1
  216. package/dist/chunks/src-DbS9gkJy.mjs +0 -117
  217. package/dist/chunks/src-DbS9gkJy.mjs.map +0 -1
  218. package/dist/chunks/src-yi5whv3n.mjs +0 -2118
  219. package/dist/chunks/src-yi5whv3n.mjs.map +0 -1
  220. package/dist/chunks/status-SMjiOMYy.mjs +0 -29
  221. package/dist/chunks/status-SMjiOMYy.mjs.map +0 -1
  222. package/dist/chunks/tail-BuhT-2PH.mjs +0 -25
  223. package/dist/chunks/tail-BuhT-2PH.mjs.map +0 -1
  224. package/dist/chunks/update-BXIppsbi.mjs +0 -16
  225. package/dist/chunks/update-BXIppsbi.mjs.map +0 -1
  226. package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs +0 -56
  227. package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs.map +0 -1
  228. package/dist/cli.mjs +0 -186
  229. package/dist/cli.mjs.map +0 -1
@@ -0,0 +1,224 @@
1
+ ---
2
+ model: sonnet
3
+ description: Dispatch the read-only review agent to audit the feature against its frozen spec.
4
+ argument-hint: <feature_id> | --pr <num>
5
+ ---
6
+
7
+ You are the **lead**. Dispatch the review for feature **$ARGUMENTS**.
8
+
9
+ > Read `PIPELINE.md` §`vcs.default_branch` (diff base) and the `surfaces`/`contract`/`commands` fields.
10
+ > _Skip the re-read if it's already in your context this session and unmodified since._
11
+ >
12
+ > **Kanban** (SCHEMA.md §Kanban): run
13
+ > `<core>/pipeline/scripts/kanban-move.sh auto $ARGUMENTS review`. `auto` resolves the board from the config itself and
14
+ > exits 0 with a `kanban: <reason>` line when there is none — so **never decide "no board is
15
+ > configured" without running it**. _(PR mode — `--pr` below — skips this entirely: an incoming
16
+ > PR is not a pipeline feature and has no card.)_
17
+ >
18
+ > **Workflow variant** (opt-in — SCHEMA.md §Workflows): on Claude Code ≥ 2.1.154 with workflows
19
+ > enabled, the human can ask to "run the review workflow" (`<core>/workflows/review.js`) instead.
20
+ > This conversational path stays the default and the fallback; `/cohorte-doctor` shows which is available.
21
+
22
+ ## PR mode (`--pr <num>` or a PR URL) — load its step file, only then
23
+
24
+ If `$ARGUMENTS` carries `--pr <num>` (or a GitHub PR URL), this is an **incoming** pull request, not
25
+ a pipeline feature: read `<core>/templates/steps/review-pr/01-pr-mode.md` and follow it **instead of**
26
+ §0–§3.5 below (it reuses §1's staging and §2/§3's dispatch and roll call, and says where). It decides
27
+ whether the PR's code may run on this machine before anything executes. No `--pr` ⇒ never read it.
28
+
29
+ Everything below this line is the normal pipeline-feature flow.
30
+
31
+ ## 0. Deterministic pre-flight — no agents while red
32
+
33
+ Run the profile's mechanical gates in ONE Bash call via the shipped script
34
+ (`<core>/pipeline/scripts/preflight.sh`); note the epoch (`date +%s`) in the same call — §3's
35
+ metrics line needs it:
36
+
37
+ ```
38
+ <core>/pipeline/scripts/preflight.sh specs/reports/$ARGUMENTS.preflight.txt \
39
+ "<commands.typecheck>" "<commands.lint_quiet, else lint>" "<commands.test_quiet, else test>"
40
+ ```
41
+
42
+ - **Non-zero exit** ⇒ the script already printed the raw last-40 lines. **STOP: relay them verbatim
43
+ and spawn NO agent** — a compiler/test failure needs `/cohorte-fix` (or the human), not a review that
44
+ rediscovers it at agent prices. This abort is the whole point of the step. Before stopping, write
45
+ the **aborted verdict** (§3's contract, degraded form) so an automated driver gets a diagnosis
46
+ rather than silence:
47
+ `{"id":"$ARGUMENTS","phase":"review","ts":"<ISO>","aborted":"preflight","verdict":"BLOCK","blocking":null}`
48
+ → `specs/reports/$ARGUMENTS.verdict.json`. One `printf`, in the same Bash call.
49
+ - **Zero exit** ⇒ it stamped `<state>/preflight.ok`, which the gate hook checks before letting
50
+ `cohorte-review` dispatches through (SCHEMA.md §Preflight). Continue.
51
+ - Script absent (older core) ⇒ run the three commands yourself, each redirected into
52
+ `specs/reports/$ARGUMENTS.preflight.txt`, aborting on the first failure the same way.
53
+
54
+ ## 1. Gather the inputs for stateless reviewers
55
+
56
+ - Confirm `specs/$ARGUMENTS.md` exists.
57
+ - **Every diff comes from `<core>/pipeline/scripts/feature-diff.sh`, never a bare `git diff`**
58
+ (SCHEMA.md §Feature diff): feature work is uncommitted until ship, and `git diff <ref>` drops
59
+ every untracked file and diffs against the branch tip, not the merge-base. Non-zero exit ⇒ **stop
60
+ and relay it** (exit 3 = base unresolvable); script absent ⇒ stop (`cohorte update`). Never fall
61
+ back to `git diff`.
62
+ - **List the changed paths ONCE, patches only for retained surfaces.** One call:
63
+ `<core>/pipeline/scripts/feature-diff.sh --default <default_branch> --numstat > specs/reports/$ARGUMENTS.stat.txt`
64
+ (`added<TAB>deleted<TAB>path`, full paths), then group the paths by `surfaces[].path` prefix with
65
+ one `awk` over that file — deterministic, never file by file. Paths under no surface (contract
66
+ file, root config) are the **`shared` remainder**: attach them to the most relevant surface's
67
+ reviewer and say so in its dispatch. A surface with no changed paths gets no reviewer and no
68
+ `.diff`. **An empty list is not a SHIP:** nothing was reviewed, so nothing is certified — write the
69
+ aborted verdict `{"id":"$ARGUMENTS","phase":"review","ts":"<ISO>","aborted":"empty-diff","verdict":"BLOCK","blocking":null}`
70
+ to `specs/reports/$ARGUMENTS.verdict.json` (it overwrites a stale one), say the diff is empty
71
+ (unbuilt feature? wrong branch?), and stop.
72
+ - **Stage the hunks once per touched surface** (reviewers have no Bash — the staged file is the
73
+ only way they read hunks instead of whole files). Regenerated every round:
74
+ `<core>/pipeline/scripts/feature-diff.sh --default <default_branch> --patch -- <surface.path> [<remainder paths>] > specs/reports/$ARGUMENTS.<surface.key>.diff`.
75
+ Never print a diff into your own context.
76
+
77
+ ## 2. Dispatch review agents — one per touched surface, IN PARALLEL
78
+
79
+ Spawn ONE `cohorte-review` agent per surface that has changed files, in a **single message** (one dispatch
80
+ each, like `/cohorte-build`) so they run concurrently — NEVER serially: review wall-clock must be the
81
+ slowest surface, not the sum. A diff touching a single surface ⇒ a single reviewer.
82
+
83
+ **Small-diff fast path (re-reviews only):** if a surface's staged diff is tiny (≤2 files and ≤~40
84
+ changed lines), touches no contract file, and every open finding it addresses is non-security
85
+ LOW/MEDIUM, skip the dispatch: verify the hunks yourself against the open Remediation items (did the
86
+ prescribed fixes land? — NOT a de-novo audit) and write the same REVIEW REPORT into the §3 flow.
87
+ First-round reviews, contract changes, and security findings always get a full reviewer. For each
88
+ reviewed surface:
89
+
90
+ Keep the dispatch prompt **byte-identical across features and rounds** except the variable block,
91
+ which sits at the END so every repeat hits the prompt-cache prefix:
92
+
93
+ > `subagent_type: cohorte-review` — "Review one feature surface against its frozen spec. Read `PIPELINE.md`
94
+ > first (flags + the §Conventions/§Testing slice for your scope). Check spec conformance first, then
95
+ > correctness, security, conventions, RBAC/mobile-first _if the profile enables them_, and TDD
96
+ > coverage. Your dispatch names a staged diff file — read it FIRST; open a full source file only when
97
+ > a finding demands it. Emit the REVIEW REPORT in the capped format your agent instructions define —
98
+ > every finding self-sufficient (`file:line` · severity · type · one-line concrete fix), no code
99
+ > excerpts. — Variable slots: feature `$ARGUMENTS` · scope: the `<surface.key>` surface only · spec:
100
+ > `specs/$ARGUMENTS.md` (source of truth) · contract: `<contract.path>/$ARGUMENTS.<ext>` · staged
101
+ > diff: `specs/reports/$ARGUMENTS.<surface.key>.diff` · changed files: <list>."
102
+
103
+ ## 3. Merge & relay the verdict
104
+
105
+ **Roll call FIRST — a dead reviewer is not a clean surface** (SCHEMA.md §Dead agents: its zero
106
+ findings are byte-identical to a clean surface's). Every surface dispatched in §2 must come back
107
+ with a REVIEW REPORT:
108
+
109
+ - **Retry a silent surface ONCE**, byte-identical dispatch. Most deaths are transient, and the staged
110
+ diff is already on disk — the retry costs one agent, not a re-review.
111
+ - **Silent twice ⇒ that surface is `unreviewed`.** Name it in the report under
112
+ `## NOT reviewed (no verdict on these)`, list it in the verdict JSON's `unreviewed`, and **refuse to
113
+ score `SHIP`** — the merged verdict is at least `REVISE`. Absence of evidence is not evidence of
114
+ absence, and it must never reach `/cohorte-ship` or tick a DoD box.
115
+ - **Never re-review the other surfaces** to compensate: their reports are valid and already on disk.
116
+
117
+ Then merge the returned reports into **one** REVIEW REPORT (same template): findings concatenated and
118
+ re-ordered by severity, counts summed, duplicates collapsed, and the verdict **recomputed from the
119
+ merged findings** by the one verdict rule (`cohorte-review` agent §Severity & verdict: any security ⇒
120
+ `BLOCK`, else any CRITICAL ⇒ `REVISE`, else `SHIP`; plus the roll call's "never `SHIP` with a surface
121
+ unreviewed") — never "the worst verdict a reviewer returned", which can disagree with the counts.
122
+ Each surface's verdict in the JSON is the same rule over that surface's findings. The `## Deferred` sections merge the same way (dedupe by
123
+ `file` + problem) and stay **out of the severity table and out of the verdict** — see §3.5, which
124
+ routes them. Append ONE metrics line for the batch to the **main checkout's**
125
+ `$(dirname "$(git rev-parse --git-common-dir)")/<state>/pipeline-metrics.jsonl` (rules in
126
+ `/cohorte-build` §4; never a bare relative path — from a worktree that strands the lines): `{"ts":"<ISO>","feature":"$ARGUMENTS","phase":"review","seconds":<wall-clock>,"surfaces":{"<key>":"<verdict>:<finding count>",…}}`.
127
+ **Stage the full report to `specs/reports/$ARGUMENTS.md`** (overwrite) — a gitignored buffer so a
128
+ `/cohorte-fix` after a `/clear` can still read the findings; the `specs/reports/` subfolder is skipped by the
129
+ non-recursive `specs/*.md` glob, so it's never mistaken for a spec (no phantom card, no bogus stage).
130
+ **Write the machine-readable verdict** to `specs/reports/$ARGUMENTS.verdict.json` (overwrite) — on
131
+ **every** run, including the small-diff fast path of §2 and a `SHIP`. This file is the ONLY contract
132
+ between the pipeline and any automated driver, which parses no prose:
133
+
134
+ ```json
135
+ { "id": "$ARGUMENTS", "phase": "review", "ts": "<ISO>", "verdict": "REVISE",
136
+ "findings": 7, "blocking": 2, "security": 1, "deferred": 3, "unreviewed": [],
137
+ "severity": {"CRITICAL": 1, "HIGH": 2, "MEDIUM": 3, "LOW": 1},
138
+ "surfaces": {"backend": {"verdict":"BLOCK","findings":4,"blocking":2}},
139
+ "blocking_items": ["backend|apps/api/src/routes/order.ts|missing authz on post"],
140
+ "fingerprint": "b3f1c2a90d4e5f67" }
141
+ ```
142
+
143
+ - **`blocking` = CRITICAL findings + `security` findings, deduplicated** (a finding that is both
144
+ counts once) — the verdict rule restated as a number, so with `unreviewed` empty,
145
+ `blocking == 0` ⟺ `verdict == SHIP`. HIGH/MEDIUM/LOW quality findings are **not** blocking and
146
+ never cost a driver an iteration — a *human* routes them (the table below); a driver ignores them.
147
+ - **`blocking_items`** — one normalized string per **distinct** blocking finding (deduplicated —
148
+ two findings sharing surface, file and problem head are one identity), `<surface>|<file>|<problem>`:
149
+ the file path **without the `:line`** (a fix that inserts lines shifts every line below it — a
150
+ line-bearing identity would change every pass and the drift detection would never fire), and the
151
+ **problem**, not the fix, cut to its first 8 words, lowercased, every run of non-alphanumerics
152
+ collapsed to one space. Identity of a finding, not its wording.
153
+ - **`fingerprint`** — computed in the same Bash call, never by hand:
154
+ `printf '%s\n' "<item>" … | LC_ALL=C sort | sha256sum | cut -c1-16` (`shasum -a 256` where there
155
+ is no `sha256sum`). Empty list ⇒ `""`. A driver comparing two consecutive fingerprints detects a
156
+ fix loop that is treading water.
157
+ - **`deferred`** — the count of merged `## Deferred` items §3.5 parked in the backlog. Informational:
158
+ it never enters `blocking`, so it can never cost a driver an iteration.
159
+ - **`unreviewed`** — the surface keys whose reviewer died twice, `[]` on a complete run. It is
160
+ **separate from `blocking` on purpose**: `blocking` counts real findings (CRITICAL + security), and
161
+ faking a number there to force a driver's hand would corrupt the one field the whole contract rests
162
+ on. A non-empty `unreviewed` means "this run does not cover everything" — a driver treats it as no
163
+ usable verdict, never as clean, whatever `blocking` says.
164
+
165
+ ## 3.5 Route the deferred findings — the backlog, not the fix loop
166
+
167
+ Do this on **every** run, before the verdict branch below, and whatever the verdict — a deferred
168
+ finding that is only routed on a `SHIP` is a deferred finding lost on every other verdict, which is
169
+ exactly the leak this step closes. Append each merged `## Deferred` item to
170
+ **`specs/refactor-backlog.md`**, under the `## <domain>` heading of the surface that owns its
171
+ `file:line` (create the file and/or heading if absent — same grouping `/cohorte-audit` writes, so
172
+ `/cohorte-refactor <domain>` picks them up with no extra plumbing):
173
+
174
+ ```
175
+ - [ ] <SEVERITY> · <file:line> · <quality|security|rule|complexity> · <concrete fix> · deferred:$ARGUMENTS
176
+ ```
177
+
178
+ - **Never into the spec's `## Remediation`** — that list is what `/cohorte-fix` re-dispatches, so a
179
+ deferred item there would re-trigger the very fix round it was deferred out of.
180
+ - **Dedupe before appending:** `grep -F` the backlog for the item's `<file>` + the first words of its
181
+ problem; already there (from a prior round or an `/cohorte-audit`) ⇒ skip it, don't stack duplicates round
182
+ after round.
183
+ - Write in ONE Bash call: insert each line directly under its `## <domain>` heading with one `awk`
184
+ pass (heading absent ⇒ append a new `## <domain>` block with `>>` — a bare `>>` lands under
185
+ whichever domain happens to be last). Never read the whole backlog into context to rewrite it.
186
+ - Report it as **one line** in chat: `deferred: <n> parked in specs/refactor-backlog.md (<domains>)`.
187
+
188
+ In chat print ONLY: the verdict, the severity-count table, a one-line digest of each CRITICAL/security
189
+ finding, and `Full report: specs/reports/$ARGUMENTS.md` — never echo the findings body into chat (it
190
+ would sit in this session's history, re-sent every turn). Then route on **the verdict and the worst
191
+ surviving severity** — exactly one row applies:
192
+
193
+ | verdict | worst surviving finding | DoD tick + freshness stamp | next |
194
+ | --- | --- | --- | --- |
195
+ | `REVISE` / `BLOCK` | any | no | `/cohorte-fix $ARGUMENTS` |
196
+ | `SHIP` | `HIGH` or `MEDIUM` | **no** — not a clean bill | `/cohorte-fix $ARGUMENTS`, or park MEDIUMs (below) |
197
+ | `SHIP` | `LOW` or none | **yes** — the clean bill | `/cohorte-ship $ARGUMENTS` |
198
+
199
+ (`SHIP` is only reachable with `unreviewed` empty — the roll call forbids it otherwise.)
200
+
201
+ - **`/cohorte-fix` route** — it appends the report to the spec's `## Remediation` and re-dispatches
202
+ ONLY the surfaces with findings. The full path (`/cohorte-spec` Mode B then `/cohorte-build`) remains
203
+ for findings that change the contract in ways that ripple into clean surfaces. The report is
204
+ staged, so you can `/clear` first — `/cohorte-fix` reads the findings back from disk.
205
+ - **Parking MEDIUMs** — only MEDIUMs the human *explicitly* chooses to live with (never a HIGH, never
206
+ CRITICAL/security): route each through §3.5 (the backlog, `deferred:$ARGUMENTS`), then **rewrite
207
+ `verdict.json` to match** — subtract them from `findings` and `severity.MEDIUM`, add them to
208
+ `deferred`, add `"parked": <n>` — so `/cohorte-ship`, which reads that file, sees what you decided.
209
+ Once nothing above LOW is left, apply the clean bill below.
210
+ - **The clean bill** (the pipeline certifying what ships — never written over a known HIGH/MEDIUM):
211
+ - **Tick the DoD**: in `specs/$ARGUMENTS.md` §`Acceptance criteria / DoD`, flip `- [ ]` → `- [x]`
212
+ for the criteria the pipeline actually verified — spec conformance + `ui_language` copy (this
213
+ review), tests · lint · typecheck (a green `/cohorte-build`), mobile-first as far as the code
214
+ shows it. **Leave `- [ ]` (and say which) any item no stage verified** — nothing in the pipeline
215
+ *runs* the feature, so a criterion that needs the app up stays open unless the human says they
216
+ exercised it by hand. Ticking is the lead's job (the reviewer is read-only).
217
+ - **Stamp the freshness gate** so `/cohorte-ship` can refuse code edited after this verdict:
218
+ `BASE=$(<core>/pipeline/scripts/feature-diff.sh --default <default_branch> --base-only)`, then
219
+ write into the spec front-matter `reviewed_base: $BASE` and
220
+ `reviewed_digest: $(<core>/pipeline/scripts/feature-diff.sh --base $BASE --digest)` — the
221
+ fingerprint of exactly the source you reviewed, untracked files included (`specs/` and
222
+ `.claude/` excluded, so DoD ticks and the ship status flip don't trip it).
223
+ - Park the leftover LOWs through §3.5 (never as `## Remediation` items — those re-trigger the fix
224
+ loop), then tell the human they can `/cohorte-ship` — **recommend a `/clear` first**.
@@ -0,0 +1,155 @@
1
+ ---
2
+ model: sonnet
3
+ description: At a SHIP verdict, dispatch the release agent to commit, push, and open the PR (with your confirmation).
4
+ argument-hint: <feature_id>
5
+ ---
6
+
7
+ You are the **lead**. Ship feature **$ARGUMENTS**. This is the outward-facing gate.
8
+
9
+ > Read `PIPELINE.md` §`vcs` (host, remote, default_branch, feature_branch_prefix) **and
10
+ > §`release_notes`** — §2b below is skipped or required based on it, and skipping it when it is
11
+ > required opens a PR that CI fails on arrival.
12
+ >
13
+ > **Kanban** (SCHEMA.md §Kanban) is mirrored in **explicit steps** below, not as an afterthought:
14
+ > §1 moves the card → **Ship**; §4 moves it → **Shipped** and writes the PR number. Both are one
15
+ > call to `<core>/pipeline/scripts/kanban-move.sh auto …`, which resolves the board from the config itself and exits 0 with a
16
+ > `kanban: <reason>` line when there is none. **Never decide "no board is configured" without running
17
+ > it** — a ship session that inferred that, having opened neither the config nor `PIPELINE.md`, is
18
+ > exactly how a merged feature's card stayed in "Ready to build". Do not skip §4's move either.
19
+
20
+ ## 0. Re-entry — a spec already past this command
21
+
22
+ `grep '^status:' specs/$ARGUMENTS.md` first. `shipped` means a PR is (or was) open — reconcile it
23
+ instead of shipping twice: `gh pr view <the branch §1 resolves> --json state,mergedAt,url` (no `gh` /
24
+ not github ⇒ ask the human what happened to the PR):
25
+ - `MERGED` ⇒ set `status: merged` (SCHEMA.md §Spec status) and say so; go straight to §5's teardown.
26
+ - `OPEN` ⇒ nothing to ship again: go to §5's CI watch (a red check routes per §5).
27
+ - `CLOSED` (not merged) ⇒ ask the human: reopen and continue (`/cohorte-fix` on what killed it), or
28
+ drop it — then set `status: abandoned`. Never decide that alone.
29
+ - **No PR for the branch** — §2 flipped the status but the release never completed (the release
30
+ agent died, or the human stopped it): go to **§3** (the review gate passed before the flip, and
31
+ the §2b release note is now in the tree, so re-running §1's freshness check would call the
32
+ verdict stale for a file this command wrote). Confirm with the human first.
33
+
34
+ `merged` / `abandoned` ⇒ done already: say so and stop. Anything else ⇒ §1.
35
+
36
+ ## 1. Pre-flight (confirm before doing anything irreversible)
37
+
38
+ - **The review gate — read `specs/reports/$ARGUMENTS.verdict.json`, never the chat.** It is the review's
39
+ machine contract (`/cohorte-review` §3). Ship only when ALL hold, and name the first that fails:
40
+ - `verdict` is `SHIP` and there is no `aborted` key (a preflight-red or empty-diff run certifies
41
+ nothing);
42
+ - `unreviewed` is `[]` (a dead reviewer read nothing);
43
+ - `severity.HIGH` and `severity.MEDIUM` are both `0` — a SHIP that still carries them is not a
44
+ clean bill (route: `/cohorte-fix $ARGUMENTS`, or the human explicitly parks MEDIUMs through
45
+ `/cohorte-review`'s park step, which rewrites this file);
46
+ - the spec front-matter carries `reviewed_base` **and** `reviewed_digest` — the review writes the
47
+ stamp only on a clean bill, so a SHIP without it is a review that did not certify this code.
48
+ File absent ⇒ no review ran on this checkout: stop, `/cohorte-review $ARGUMENTS`. **Only when
49
+ `verdict.json` is absent AND the spec carries no stamp AND predates the gate** (a legacy spec from
50
+ before the verdict file existed) may the human confirm shipping on their own word — ask, and say
51
+ that nothing certified it.
52
+ - **Freshness gate** — the reviewed code must be exactly what ships. Recompute
53
+ `<core>/pipeline/scripts/feature-diff.sh --base <reviewed_base> --digest` (the same script that
54
+ wrote the stamp — untracked files included, `specs/` + `.claude/` excluded; a bare `git diff`
55
+ would miss every new file) and compare to `reviewed_digest`. **Match** ⇒ source unchanged since
56
+ the SHIP verdict, proceed. **Mismatch** (or a non-zero exit) ⇒ source (or the contract) was edited
57
+ after review — the verdict is **stale**: stop and tell the human to re-run
58
+ `/cohorte-review $ARGUMENTS`. A stamp written before `feature-diff.sh` existed was computed without
59
+ untracked files and will mismatch once — the re-review re-stamps it.
60
+ - **DoD gate (verify, don't tick — `/cohorte-review` owns the ticking).** Read `specs/$ARGUMENTS.md`
61
+ §`Acceptance criteria / DoD`; if any item is still `- [ ]`, list the open ones and ask the human to
62
+ confirm shipping anyway (they may be deferred on purpose — e.g. a UI item on a backend-only feature).
63
+ All `- [x]` ⇒ proceed silently.
64
+ - Show `git status` + `<core>/pipeline/scripts/feature-diff.sh --default <default_branch> --numstat`
65
+ (what ships, new files included); confirm the branch is `<prefix>$ARGUMENTS`, where `<prefix>`
66
+ is `vcs.patch_branch_prefix` (falling back to `fix/` on a profile that predates the key) when the
67
+ spec front-matter carries `kind: patch`, and `vcs.feature_branch_prefix` otherwise. Resolve it once
68
+ here and pass the **literal** branch to §3's dispatch — the release agent must not re-derive it.
69
+ - **Ask the human to confirm** they want to commit, push, and open the PR. Wait for yes.
70
+ - After the yes: `<core>/pipeline/scripts/kanban-move.sh auto $ARGUMENTS ship`. Report what it
71
+ printed — `moved #…` or `kanban: <reason>` — never a guess about which happened.
72
+
73
+ ## 2. Mark the spec shipped (BEFORE dispatch, so it ships in the same commit)
74
+
75
+ Once the human confirms, edit `specs/$ARGUMENTS.md` front-matter `status: → shipped` — **before**
76
+ dispatching the release agent, so the status flip is part of the tree it commits (otherwise it lands
77
+ uncommitted after the PR opens). Only flip after the human's "yes"; if they decline, leave it.
78
+
79
+ ## 2b. Write the release note (only if `release_notes.enabled` — same reason: it must ship in the commit)
80
+
81
+ `release_notes.enabled: false` (or `tool: none`) ⇒ skip this section entirely, silently.
82
+
83
+ Otherwise **you** write it — never the release agent, never the implementers. Picking the bump is
84
+ project policy and the prose is outward-facing copy; both are the lead's, exactly like the contract.
85
+ See SCHEMA.md §Release notes.
86
+
87
+ - Write `<release_notes.dir>/<release_notes.filename>` (`<feature_id>` substituted), front-matter
88
+ carrying the **single** key `release_notes.anchor_package` and the chosen level, then the prose body
89
+ in `release_notes.language`.
90
+ - **Choose the level** against `release_notes.guidance`, and refuse any level in
91
+ `release_notes.forbid_levels` (a `0.x` repo forbidding `major` declares the rupture `minor`).
92
+ - **Ambiguous between two defensible levels?** State your reading in one line and **ask the human to
93
+ pick** before writing. A wrong bump becomes a published version number.
94
+ - A `kind: patch` spec is a `patch` bump by default — that is what the level means. It is a default,
95
+ not a rule: a bug fix that changes documented behaviour is still a `minor`, and one that removes it
96
+ is still breaking. Say which you chose when it isn't `patch`.
97
+ - The body describes what changed **for the user**, from the spec §1/§2 — no client names, no internal
98
+ paths, no exploitable attack vector, no file lists.
99
+ - If the feature genuinely must move no version, use `release_notes.empty_cmd` instead. Prefer that to
100
+ skipping: the CI job wants a file, not a version.
101
+ - Then say in one line which level you chose and why — this is the human's last chance to correct it
102
+ before it is committed.
103
+
104
+ > **Why this is its own gate.** The requirement usually lives in the project's `<memory>`, which this
105
+ > flow never reads. Skip it and everything below still "succeeds": commit, push, PR opened, kanban card
106
+ > moved to **Shipped** — and CI red on a job nobody watched. The feature reads as shipped while being
107
+ > unmergeable.
108
+
109
+ ## 3. Dispatch the `cohorte-release` agent
110
+
111
+ Spawn one agent (`subagent_type: cohorte-release`):
112
+ "Release feature `$ARGUMENTS` on branch
113
+ `<the branch §1 resolved>`. Read `PIPELINE.md` §vcs first. Spec: `specs/$ARGUMENTS.md` (already
114
+ `status: shipped` — stage it). Write conventional commit(s), push (no force), open the PR (use `gh` if
115
+ `host: github` + available; else emit the compare URL + drafted PR body from `<core>/templates/pr-body.md`).
116
+ Stage **all** the feature's changes including `specs/$ARGUMENTS.md` and, if `release_notes.enabled`, the
117
+ release note at `<release_notes.dir>/<release_notes.filename>` — it is already written, stage it as-is and
118
+ never author or edit one yourself. Never edit source, never force-push, never run migrations."
119
+
120
+ ## 4. Relay + move the card to Shipped (do not skip)
121
+
122
+ Print the release agent's report: commit SHA(s), pushed branch, PR URL (or compare URL + drafted body).
123
+ Confirm `specs/$ARGUMENTS.md` was committed as `status: shipped` (part of the release commit), and — if
124
+ `release_notes.enabled` — that the release note is in that same commit
125
+ (`git show <sha> --stat | grep <release_notes.dir>`). Missing ⇒ commit and push it now, before §5's CI
126
+ watch, rather than letting the job go red.
127
+
128
+ **Move the card to Shipped — required, and verify it actually moved.** Run
129
+ `<core>/pipeline/scripts/kanban-move.sh auto $ARGUMENTS shipped --pr <num>`, which **appends the PR
130
+ number** so the line reads `- [ ] <title> #$ARGUMENTS — PR #<num>`. Take `<num>` from the PR URL
131
+ (`…/pull/13` ⇒ `13`); **always pass it when a PR was created** (the `gh` path) — it is what a
132
+ board reader turns into a PR link. If only a compare URL was emitted (no PR yet), drop `--pr`.
133
+
134
+ Then **read the script's own output**, which is the verification: `moved #$ARGUMENTS -> Shipped
135
+ (PR #<num>)` means done, and a `kanban: <reason>` line means the mirror is off and says why. Both are
136
+ exit 0 and they are not interchangeable — say which one you got. Only if it moved, confirm placement
137
+ with a **grep for `#$ARGUMENTS`** on the board it named (with surrounding heading context —
138
+ `grep -B20 '#$ARGUMENTS' | grep '^##'`, or an offset-limited Read around the match): exactly one card,
139
+ under the `shipped` heading — never re-read the whole board into context.
140
+
141
+ ## 5. After the PR — CI gate + teardown
142
+
143
+ - If `host: github` and `gh` is available, watch the PR's checks (`gh pr checks <url> --watch`) and
144
+ report the result — the human merges only on green. A red check ⇒ back to `/cohorte-fix $ARGUMENTS`,
145
+ **except** a red `release_notes.ci_job`: that one is this command's own miss, not a code finding —
146
+ write the note per §2b, commit, push, and re-watch. Never send a missing release note through `/cohorte-fix`.
147
+ - Once the PR is **merged** (the human says so, or §0's `gh pr view` shows `MERGED`): set the spec's
148
+ `status: merged` and commit that one line on the default branch when the human next commits there
149
+ (or leave it to `/cohorte-doctor`'s reconcile — it does the same check). If `isolation.enabled`, propose the teardown —
150
+ `scripts/remove-feature.sh $ARGUMENTS` (add `--drop-db` to also drop the feature db; kept by
151
+ default). It removes the worktree, deletes the merged branch, frees the slot. Never run it before
152
+ the merge is confirmed, and only with the human's go-ahead (the gate will ask anyway).
153
+ - Feature closed — **recommend a `/clear`** before starting the next one; nothing from this session
154
+ is needed again (spec `merged`, board updated). `specs/reports/$ARGUMENTS.*` is a gitignored
155
+ buffer and can be deleted now.
@@ -0,0 +1,105 @@
1
+ ---
2
+ description: Interactively capture a frozen feature spec (or apply a review return) into specs/<id>.md.
3
+ argument-hint: [paste brainstorm return OR review report]
4
+ ---
5
+
6
+ You run the **spec** step in the main thread — interactive, with the human. Pasted input below:
7
+
8
+ **$ARGUMENTS**
9
+
10
+ > Read `PIPELINE.md` first: `contract` (mechanism/path — so §5 names the right schema types),
11
+ > `design.enabled` (whether §8 matters), and §Conventions. Use `specs/_template.md` as the section list.
12
+ >
13
+ > **Decision journal** (SCHEMA.md §Decisions): read `specs/_decisions.md` §Live if it exists — one
14
+ > line per standing decision, so it is cheap. It is the ONLY place the project's transverse rules
15
+ > live; a spec that contradicts one silently un-decides it. Absent ⇒ nothing to honour yet.
16
+ >
17
+ > **Kanban** (SCHEMA.md §Kanban): when the spec opens, run
18
+ > `<core>/pipeline/scripts/kanban-move.sh auto <feature_id> spec --title "<human title>"`; on freeze
19
+ > (`status: frozen`, Mode A), the same call with `ready`. `auto` resolves the board from the config itself and exits 0 with a
20
+ > `kanban: <reason>` line when there is none — so **never decide "no board is configured" without
21
+ > running it**.
22
+
23
+ Detect the mode from the pasted content:
24
+
25
+ ## Mode A — new spec (input is a brainstorm return, or empty)
26
+
27
+ 1. If empty, look for a staged brainstorm return first — `specs/reports/*-brainstorm.md` (where
28
+ `/cohorte-brainstorm` stages its output); one match ⇒ read it and confirm, several ⇒ ask which. None ⇒
29
+ ask the human to paste the return (or describe the feature) and wait.
30
+ 2. **Take the `feature_id` from the return's front-matter** (or its staged filename,
31
+ `<feature_id>-brainstorm.md`) — **never re-derive it**: the brainstorm (or `/cohorte-intake`
32
+ before it) already created the kanban card `#<feature_id>`, and a new slug forks a second card
33
+ and strands the first. Only when there is no return (a described feature, or a return predating
34
+ the front-matter) derive a kebab-case slug, and confirm it.
35
+ 2b. **Size budget — a spec is a contract, not a novel.** Target ≤ ~300 lines; hard-think at 500.
36
+ Every implementer re-reads the whole spec on every first build, so each extra line is paid
37
+ `surfaces × dispatches` times. If the feature genuinely needs more, that's the signal it is TWO
38
+ features: propose a split (e.g. `<id>-core` + `<id>-admin`, each independently shippable, the
39
+ second consuming the first's contract) and let the human pick. Trim the usual bloat before
40
+ writing: exhaustive UI walkthroughs (the design brief carries those), restated conventions
41
+ (PIPELINE.md carries those), speculative edge cases nobody asked for.
42
+ 3. Walk the human through each section of `specs/_template.md`, **section by section**, with focused
43
+ questions. The critical one is **§5 API CONTRACT** — pin down every endpoint/interface (method, path,
44
+ auth/role, request fields with types/validation, success envelope + data shape, and every error case),
45
+ and name the exact schema/types that will live in the contract file (`contract.path/<id>.<ext>` in the
46
+ profile's `mechanism`). Don't move on until frontend and backend could each build from it with zero
47
+ further questions. _If `contract.enabled` is false, capture the interface precisely in prose instead._
48
+ 4. Capture the **design brief** content (only if `design.enabled` / the feature has UI): screens,
49
+ states, components, responsive notes — it will be authored to `specs/design/<id>.md` in step 6;
50
+ spec §8 carries only a short summary + the pointer `> full brief: specs/design/<id>.md` (so
51
+ non-design surfaces never re-read the full brief on every dispatch).
52
+ 4b. **New-surface heads-up.** If the feature clearly introduces an area no existing `surfaces[].path`
53
+ owns (a new service/app/top-level module), note it in the spec (a line in the relevant task section:
54
+ `> needs new surface: <proposed key/path>`). Don't render agents here — `/cohorte-build` §1.5 auto-reconciles
55
+ it. This is just so the human isn't surprised when `/cohorte-build` proposes a new agent.
56
+ 5. When the human validates, **freeze**: write `specs/<id>.md` (`status: frozen`, front-matter filled).
57
+ Create the file — do not ask the human to. **Postcondition:** `grep -q '^status: frozen' specs/<id>.md`
58
+ — if it fails the freeze didn't land; fix it before pointing the human at `/cohorte-build`.
59
+ 5b. **Record the transverse decisions — the journal, not a summary.** Walk what the interview settled
60
+ and keep ONLY the decisions that **outlive this feature**: a rule the next spec would otherwise
61
+ re-litigate or contradict (auth model, id/naming scheme, where a kind of state lives, an error
62
+ convention, a deliberate non-goal that binds future features). Typical yield: **0–3 lines**; zero
63
+ is a normal, healthy outcome for a feature that decided nothing new — never invent lines to fill
64
+ the section. Append them to `specs/_decisions.md` §Live (create the file from
65
+ `<core>/templates/decisions.template.md` on first use), each exactly:
66
+ `- <YYYY-MM-DD> · <area> · <decision> — because <reason> · <feature_id>`
67
+ - **Never** duplicate what §5, `PIPELINE.md` §Conventions or the code already states — the journal
68
+ carries the *non-obvious rule*, not the feature's content. A line that restates a spec section is
69
+ a line every future `/cohorte-spec` pays for and learns nothing from.
70
+ - **Contradicting an existing line** is allowed but never silent: tell the human which line this
71
+ feature overrides, get their go-ahead, then append the new line with
72
+ `· supersedes <YYYY-MM-DD> <area>` and move the old one to `## Superseded`.
73
+ - Append with one `>>` Bash call, not a full-file rewrite (the file is append-only, and reading it
74
+ back to re-write it is the one way to make a bounded file expensive).
75
+ 6. Author the **design brief** — `specs/design/<id>.md`, rendered via
76
+ `<core>/templates/design-brief.md`.
77
+ _Only if `design.enabled` / the feature has UI; skip entirely for a backend-only feature._
78
+ - **Write it to `specs/design/<id>.md`** (the authored artifact, versioned with the spec; spec §8
79
+ holds the summary + pointer). Create the file — do not ask the human to. Keep it in the
80
+ `specs/design/` subfolder, **not** `specs/<id>....md`: the `specs/*.md` glob that drives the
81
+ kanban backfill and `/cohorte-doctor` is non-recursive, so a brief in the subfolder never gets mistaken
82
+ for a spec (no phantom card, no bogus stage). Overwrite it on every freeze.
83
+ - Print ONLY the path + a one-line summary — never echo the brief into chat (it would sit in this
84
+ session's history; echo it only if the human asks). Tell the human: copy it from
85
+ `specs/design/<id>.md` into the design tool (if any — typically a fresh design project for this
86
+ feature), then run `/cohorte-build <id>` and hand its design gate the resulting page link(s) — a full
87
+ `https://claude.ai/design/p/<projectId>?file=<file>` link carries its own project + page, no
88
+ profile change needed. (They can also paste the links into the spec's `design_files` themselves.)
89
+ **Recommend a `/clear` before `/cohorte-build`** — the frozen spec + `specs/design/<id>.md` are the whole
90
+ handoff.
91
+
92
+ ## Mode B — review return (input is a REVIEW REPORT)
93
+
94
+ 1. Read the report — pasted as input, or (whenever nothing is pasted) read from
95
+ `specs/reports/<id>.md`, where `/cohorte-review` stages its last report. Identify `feature_id` from its
96
+ header; open `specs/<id>.md`.
97
+ 2. Append each finding to the spec's **`## Remediation`**, one per line:
98
+ `- [ ] <severity> · <file:line> · <spec-violation|quality|security|complexity> · <concrete fix>`
99
+ (Keep prior items; add the new round under a dated/numbered subheading.)
100
+ 3. If a finding implies the **contract** must change, update §5 and flag it so the lead re-authors the
101
+ contract file.
102
+ 4. Set `status: in-review`. Tell the human to run `/cohorte-build <id>` to re-dispatch fresh agents.
103
+ **Recommend a `/clear` before `/cohorte-build`** — the spec is the whole handoff.
104
+
105
+ In both modes the spec is the single source of truth; agents are stateless and read only it + the diff.
@@ -0,0 +1,115 @@
1
+ ---
2
+ model: sonnet
3
+ description: Refresh the machine-wide pipeline core, re-wire this repo (gate, pointer) and reconcile its generated files — /cohorte-init-pipeline stays one-time.
4
+ argument-hint: [path-to-local-checkout]
5
+ ---
6
+
7
+ You are the **pipeline updater**. Refresh the machine-wide core to the latest published version, re-wire
8
+ this repo against it, then bring the repo's generated files up to the new core (§3.5) — additively, never
9
+ clobbering the human's choices — so `/cohorte-init-pipeline` never needs re-running for an upgrade.
10
+ The installer never touches `PIPELINE.md`, the surface agents, `gate-config.json` or the filled `<config>`.
11
+
12
+ ## 1. Current version
13
+
14
+ Read `<core>/pipeline/VERSION` (a semver) and this repo's `<state>/pipeline.json` `core_version`. Note
15
+ both. A pointer that still carries `"mode": "bundled"` or `"mode": "global"` is a **2.x repo**: §2b
16
+ migrates it.
17
+
18
+ ## 2. Run the update
19
+
20
+ ```sh
21
+ npm i -g cohorte@latest && cohorte update # refresh the CLI, then the machine-wide core
22
+ ```
23
+
24
+ If `cohorte` is not on PATH, `npx cohorte@latest update` does the same. If `$ARGUMENTS` is a path to a
25
+ local checkout of the cohorte repo (it contains `bin/cli.js`), run `node <path>/bin/cli.js update`
26
+ instead — useful when iterating on the pipeline itself. `cohorte update` exits non-zero and changes
27
+ nothing if `~/.claude/settings.json` is not valid JSON: show the error and stop.
28
+
29
+ ## 2b. Re-wire this repo — run `<sync>`
30
+
31
+ Always, from the repo root (one Bash call), and show its output. It refreshes the committed gate
32
+ (`.claude/hooks/cohorte-gate.py`) and its registration, bumps the `<state>/pipeline.json` pointer, and
33
+ keeps the `.gitignore` entries. On a **2.x repo** it also removes the vendored core (`.claude/pipeline/`,
34
+ `.claude/templates/`, `.claude/workflows/`, `.claude/commands/cohorte-*.md`, `.claude/agents/{review,release,profile-reader}.md`,
35
+ `.claude/hooks/gate.py`): files git tracks unmodified are deleted (git keeps them), anything else is moved
36
+ to `.claude/cohorte-legacy-backup/`. Tell the human to commit the result.
37
+
38
+ If this repo's surface agents are missing from `<agents>/` but exist in `~/.claude/agents/` (a 2.x
39
+ "global" repo rendered them there), re-render them into `<agents>/` in §3.5 — do not copy the global
40
+ files, render from the current template — and tell the human the global copies can be deleted once no
41
+ other repo uses them.
42
+
43
+ ## 3. Report old → new
44
+
45
+ Re-read the VERSION file(s) and print `old → new`. If unchanged, say the core was already up to date.
46
+
47
+ Then print **What's new**: read the installed `<core>/pipeline/CHANGELOG.md` and show the entries
48
+ between the old and new versions (most recent first). File absent ⇒ the old core predates 0.1.14 —
49
+ skip silently.
50
+
51
+ ## 3.5 Reconcile this repo's generated files
52
+
53
+ Only when the current repo has a `PIPELINE.md`: run the **Reconcile procedure** from the installed
54
+ `pipeline/SCHEMA.md` §Reconcile — top up the profile's machine block with new fields at their defaults
55
+ (one batched question set for any genuinely new human decision — e.g. choosing a `retrieval` provider,
56
+ or the **quiet command variants**: `test_quiet_cmd`/`lint_quiet_cmd` + `commands.test_quiet`/
57
+ `lint_quiet`, proposing the detected bridled forms per §Output discipline; `gate.preflight` tops up
58
+ silently at its defaults), re-render the surface agents from the current `implementer.template.md`
59
+ (this refreshes each agent's **baked §Conventions slice** — required after any hand-edit of the
60
+ profile's prose).
61
+ Additively patch the `settings.json` permissions and `gate-config.json` (including the `preflight`
62
+ block and the workflow-agent `allow` entries from init step 5) — never the gate hook entries, `<sync>`
63
+ owns those — and run any newly-added capability's wiring (e.g. Serena's project-scope `claude mcp add`).
64
+ Verify the refreshed core actually carries `<workflows>/cohorte-review.js` + `<fixed-agents>/cohorte-profile-reader.md`
65
+ — missing means the update half-ran: re-run `cohorte update`. Even when no capability is new, **re-run the retrieval provider's
66
+ health check** (SCHEMA.md §Code retrieval: CLI resolvable from PATH, `.mcp.json` entry present —
67
+ upgrading a bare `serena` entry to the PATH-proof launcher form, `.serena/` gitignored, server
68
+ actually connected) and repair whatever fails — wiring that worked at
69
+ init can rot (PATH changes, uninstalls, hand-edits). Report what was reconciled; if nothing was
70
+ missing, say so. This is why `/cohorte-init-pipeline` never needs re-running for a core upgrade.
71
+
72
+ Four of the §Reconcile steps matter specifically here:
73
+
74
+ - **Local-artifact hygiene** (§Reconcile step 8): gitignore + untrack the pipeline's runtime files
75
+ (`<state>/preflight.ok`, `<state>/pipeline-metrics.jsonl`, `specs/reports/`). A tracked
76
+ `preflight.ok` — what every pre-2.0.0 install ends up with once a release agent stages `.claude/` —
77
+ makes the phase gate ask on every single review dispatch, so fix it here and say so.
78
+
79
+ - **Spec-template top-up** (§Reconcile step 7): `specs/_template.md` was seeded at install and never
80
+ refreshed since, so add the front-matter fields the current `templates/spec.template.md` has and the
81
+ repo's copy lacks — and drop `loop_pass`/`loop_phase`, retired with the 2.2.0 conversational loop driver —
82
+ front-matter only, never the body.
83
+
84
+ - **Global config seed** (§Reconcile step 5): if `<config>` is absent, seed it
85
+ from the template so the kanban + shared-vault config has a home. Never clobber an existing filled
86
+ file. Report what was seeded. Then **scrub the retired `telemetry:` block** if the existing file
87
+ still has one (every install seeded before 2.3.0 does) — one targeted Edit deleting the block and
88
+ its comment header, nothing else touched. That capability was removed in 2.3.0, sender included,
89
+ so the block is dead config: nothing reads it, and an `enabled: true` left sitting in a file the
90
+ human may open reads as though data were still leaving the machine. Say you removed it.
91
+ - **Kanban sync** (§Reconcile step 6): resolve this project's board with
92
+ `<core>/pipeline/scripts/kanban-move.sh --check` — it prints either the board path or the exact
93
+ missing link. **Not linked** → offer to link/create a board (confirm the vault + `<folder>/Tasks.md`,
94
+ write the `boards` entry, create the board file per §Kanban). **Linked** → verify the board file
95
+ exists (recreate if the human confirms) and its columns match `kanban.columns` (repair drift). Either
96
+ way, run the §Kanban **full sync/backfill** from `specs/*.md` — one
97
+ `kanban-move.sh auto <id> <stage>` per spec, `<stage>` from the status mapping — this is what adds
98
+ every already-developed feature to the board and repositions cards to match each spec's `status`.
99
+ Report cards added / moved / already-correct. Skip silently if `kanban.enabled` is false and the
100
+ human doesn't want to turn it on.
101
+ - **A project renamed since its last update loses its board silently** — `boards` is keyed by the
102
+ profile `name`, so a `name:` edit orphans the old entry and no lookup matches the new one. When
103
+ `--check` finds no entry for `<name>` but `boards` holds exactly one other key whose board file
104
+ exists, say so and offer to re-key it rather than creating a second board.
105
+
106
+ ## 4. Tell the human the follow-ups
107
+
108
+ - **Restart / reload the coding-agent session** so it picks up updated commands, agents, and any
109
+ newly-registered MCP server.
110
+ - **Other repos using the global core:** their core is already fresh, but reconcile is per-repo — run
111
+ `/cohorte-update-pipeline` inside each (it will skip the already-done core update and just reconcile).
112
+ - **Commit** the reconciled files (`PIPELINE.md`, `.claude/`, `.mcp.json` if added) so teammates get them.
113
+ - The kanban config is global and user-scoped
114
+ (`<config>`) — never committed. The core update never touches it; only the
115
+ reconcile above seeds the file and writes kanban board links (into that global file, not the repo).