cohorte 3.0.0-dev.8 → 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 +316 -62
  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-SJwOIEif.mjs +0 -123
  119. package/dist/chunks/brainstorm-SJwOIEif.mjs.map +0 -1
  120. package/dist/chunks/build-C_-mbZfD.mjs +0 -19
  121. package/dist/chunks/build-C_-mbZfD.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-C9roGiQz.mjs +0 -82
  145. package/dist/chunks/fix-C9roGiQz.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-C1pesxCJ.mjs +0 -12
  155. package/dist/chunks/intake-C1pesxCJ.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-DV3RfGjk.mjs +0 -153
  177. package/dist/chunks/refactor-DV3RfGjk.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-BGabwbDL.mjs +0 -109
  189. package/dist/chunks/run-BGabwbDL.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
package/README.md CHANGED
@@ -1,104 +1,358 @@
1
- # Cohorte
1
+ <div align="center">
2
2
 
3
- Cohorte V3 est un orchestrateur durable de pipelines multi-agents, construit autour de Pi et d'un état SQLite. Il transforme une spécification validée en run observable, reprend les runs interrompus et protège chaque effet par des contrats typés, une politique de sécurité et un journal idempotent.
3
+ <img src="https://raw.githubusercontent.com/TheBidouilleAgency/cohorte/main/assets/cohorte-banner.png" alt="Cohorte — portable multi-agent pipeline for Claude Code" width="720">
4
4
 
5
- [Documentation complète](https://thebidouilleagency.github.io/cohorte/) · [Spécification V3](docs/v3/SPEC.md) · [Design](docs/v3/DESIGN.md) · [Référence CLI](docs/v3/CLI.md)
5
+ [![npm version](https://img.shields.io/npm/v/cohorte?logo=npm&color=cb3837)](https://www.npmjs.com/package/cohorte)
6
+ [![npm downloads](https://img.shields.io/npm/dm/cohorte?logo=npm)](https://www.npmjs.com/package/cohorte)
7
+ [![Publish to npm](https://github.com/TheBidouilleAgency/cohorte/actions/workflows/publish.yml/badge.svg)](https://github.com/TheBidouilleAgency/cohorte/actions/workflows/publish.yml)
8
+ [![node >=18](https://img.shields.io/node/v/cohorte?logo=node.js&logoColor=white)](https://nodejs.org)
9
+ [![license: AGPL-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue)](LICENSE)
10
+ [![docs](https://img.shields.io/badge/docs-thebidouilleagency.github.io%2Fcohorte-6f42c1)](https://thebidouilleagency.github.io/cohorte/)
6
11
 
7
- ## Installation
12
+ **[📖 Full documentation](https://thebidouilleagency.github.io/cohorte/)** — guides (feature cycle, workflows, token economy, parallel features) + complete reference (commands, agents, profile, gate, scripts).
8
13
 
9
- Prérequis : Node `24.16.0` minimum supporté et pnpm `12.4.2` pour contribuer au dépôt. Pour utiliser la CLI publiée :
14
+ </div>
10
15
 
11
- ```sh
12
- npm install -g cohorte
13
- cohorte --version
14
- ```
16
+ A **stack-agnostic multi-agent pipeline for [Claude Code](https://code.claude.com)**. Install it once
17
+ on your machine, then one command per project (`/cohorte-init-pipeline`) adapts it to that project's
18
+ stack — and everything it generates is committed with the project.
19
+
20
+ - **The dev pipeline** — a human **lead** drives feature work through gated commands, dispatching
21
+ **stateless agents** that only communicate through a frozen contract:
22
+
23
+ ```
24
+ /cohorte-brainstorm → /cohorte-spec → (design) → /cohorte-build <id> → /cohorte-review → (/cohorte-fix) → /cohorte-ship
25
+ ```
26
+
27
+ <div align="center">
28
+ <img src="https://raw.githubusercontent.com/TheBidouilleAgency/cohorte/main/assets/demo-cli.gif" alt="cohorte doctor reporting a green pipeline, the spec board, and the gate denying a chained destructive command" width="760">
29
+ <br>
30
+ <sub><code>cohorte doctor</code> · the spec board · the gate refusing a hard-denied command chained behind a benign one.<br>
31
+ Recorded from the real CLI by <code>scripts/demo/record-cli.sh</code> — no output is hand-edited.</sub>
32
+ </div>
33
+
34
+ ## Why a pipeline at all
35
+
36
+ Your coding agent is already good at the first prompt of a feature. It gets worse at every one
37
+ after — because what it knows lives in a conversation, and a conversation gets summarised,
38
+ truncated, and re-sent at input price on every turn. Cohorte is the set of constraints that stop
39
+ that degradation. Each one is a failure you have already had:
40
+
41
+ | The failure | The constraint |
42
+ | --- | --- |
43
+ | *"It forgot what we decided."* | The spec is **frozen to disk** and re-read by every stateless agent. Nothing is remembered, so nothing is forgotten — and `/clear` between stages is always safe. |
44
+ | *"The API and the UI don't fit."* | The **contract is authored before any implementer is dispatched**. Surfaces import it read-only and never talk to each other — which is what makes building them in parallel safe. |
45
+ | *"It edited a file I didn't want it to."* | **One owner per tree**: each surface agent is rendered with its own tree and told it owns nothing else, and the review flags any write outside it. (A convention the agents follow and the review checks — not a sandbox.) |
46
+ | *"It ran something it shouldn't have."* | The **gate** is a real blocking hook committed in the repo, branch-aware, parsing commands (not grepping them) to deny force-pushes, pushes to the default branch and the project's destructive commands — subagents included. It fails closed. It is a strong guard against agent mistakes, not a sandbox: keep GitHub branch protection as the hard boundary for the remote. |
47
+ | *"The review said it was fine."* | Review is a **separate read-only agent** that sees the spec and the diff, never the conversation that produced them. A dead reviewer's zero findings can't read as ship. |
48
+ | *"Four agents just told me it doesn't compile."* | A **deterministic preflight** runs typecheck/lint/tests first. Red ⇒ **zero agents spawned**. |
49
+ | *"We fixed this same thing last week."* | `/cohorte-retro` turns repeated findings into ratified conventions **baked into the implementers**, so the next build never produces them. |
50
+
51
+ None of this is intelligence added to your agent — it's the opposite. It moves the decisions an
52
+ agent makes badly under context pressure into files, hooks and ownership boundaries, where they're
53
+ cheap and don't degrade with conversation length. Which is why it's markdown, shell and one Python
54
+ hook: **your app code never imports anything from Cohorte.**
55
+
56
+ [**The long version — including the four cases where you shouldn't use it →**](https://thebidouilleagency.github.io/cohorte/guide/why-cohorte)
57
+
58
+ ## How it works — one install, everything else in the repo
59
+
60
+ | What | Holds | Lives in |
61
+ | --- | --- | --- |
62
+ | **The machine install** (`cohorte install`, once) | the 16 `/cohorte-*` commands, the `cohorte-review` / `cohorte-release` / `cohorte-profile-reader` agents, the workflow scripts, the generic core (templates, schema, scripts, the gate's source) — zero project facts | `~/.claude/commands/cohorte-*.md`, `~/.claude/agents/cohorte-*.md`, `~/.claude/workflows/cohorte-*.js`, `~/.claude/cohorte/` |
63
+ | **The project** (generated by `/cohorte-init-pipeline`, **committed**) | the profile (stack, surfaces, commands, conventions, gates), one implementer agent per surface, the gate hook and its registration, the version pointer, the specs | `PIPELINE.md`, `.claude/agents/<surface>.md`, `.claude/gate-config.json`, `.claude/hooks/cohorte-gate.py` + `.claude/settings.json`, `.claude/pipeline.json`, `specs/` |
64
+ | **You** | kanban board links + shared Obsidian vault path | `~/.claude/cohorte.config.yaml` |
65
+
66
+ Everything project-specific travels with `git clone` — **including the gate**: a teammate who clones
67
+ is protected before they even install Cohorte, and only needs `npm i -g cohorte && cohorte install`
68
+ to get the commands. Nothing project-specific is ever written under `~/.claude`, so two projects
69
+ with a `frontend` surface never overwrite each other's agent.
70
+
71
+ The core never hardcodes stack facts. Two mechanisms keep it generic:
15
72
 
16
- Dans un projet :
73
+ 1. **Runtime indirection** — commands/agents read project facts from `PIPELINE.md` (dev pipeline) or
74
+ `~/.claude/cohorte.config.yaml` (kanban board links + shared vault) at run time — an agent's
75
+ _first action_ is to read its config.
76
+ 2. **Render-at-init** — things that must be in agent frontmatter (name, `tools:`, surface ownership)
77
+ are rendered per **surface** by `/cohorte-init-pipeline` from `implementer.template.md`.
78
+
79
+ > **Claude Code only.** 3.0.0 dropped Codex, Cursor, Gemini CLI and OpenCode. The last multi-runtime
80
+ > release is `cohorte@2.10.2`; its source is on the
81
+ > [`archive/multi-runtime`](https://github.com/TheBidouilleAgency/cohorte/tree/archive/multi-runtime) branch.
82
+
83
+ ## Prerequisites
84
+
85
+ - **Node ≥ 20 + npm** — for the `cohorte` CLI.
86
+ - **Python ≥ 3.9** as `python3` — the gate hook every project commits runs on it. The hook is
87
+ fail-closed: without Python, Claude Code refuses every Bash call in a Cohorte project.
88
+ **Windows:** the committed hook is `python3 "$CLAUDE_PROJECT_DIR/.claude/hooks/cohorte-gate.py"`, so
89
+ each teammate needs `python3` on `PATH` and Claude Code running hooks through a POSIX shell (Git
90
+ Bash); this setup is not covered by CI yet.
91
+ - **Claude Code** — workflows (the opt-in deterministic runs) need ≥ 2.1.154; the hook's
92
+ fail-closed `onFailure` setting is honoured from 2.1.295 (older clients ignore it and fail open).
93
+ - **[`uv`](https://docs.astral.sh/uv/) + the Serena CLI** — _optional_, the default code-retrieval
94
+ provider (`uv tool install -p 3.13 serena-agent && uv tool update-shell`). Without it agents fall back
95
+ to Grep/Read. Installed before `/cohorte-init-pipeline`, init wires it in one pass.
96
+
97
+ ## Install
17
98
 
18
99
  ```sh
19
- cohorte init
20
- cohorte doctor
21
- cohorte discover --json
22
- cohorte config validate
100
+ npm i -g cohorte
101
+ cohorte install
23
102
  ```
24
103
 
25
- `cohorte init` crée `.cohorte/`. Les fichiers de configuration générés peuvent être réconciliés avec `cohorte reconcile --plan`, puis `cohorte reconcile --apply`. L'état d'exécution reste local et n'a pas vocation à être versionné.
104
+ `cohorte install` writes only into `~/.claude` (or `$CLAUDE_CONFIG_DIR`) and records every file it
105
+ writes in `~/.claude/cohorte/manifest.json`. It never deletes a file it did not write, backs up any
106
+ file of its own you edited before refreshing it, and refuses to run — changing nothing — if
107
+ `~/.claude/settings.json` is not valid JSON. It registers **no** machine-wide hook.
26
108
 
27
- ## Workflow V3
109
+ > **Restart Claude Code** (or start a new session) after installing or updating: commands and agents
110
+ > are scanned at session start.
28
111
 
29
- Le workflow est piloté par la CLI ; il n'exige pas un runtime V2 ni des slash commands :
112
+ Without a global npm install: `npx cohorte@latest install`, or
113
+ `curl -fsSL https://raw.githubusercontent.com/TheBidouilleAgency/cohorte/main/install.sh | sh`
114
+ (Windows: `irm https://raw.githubusercontent.com/TheBidouilleAgency/cohorte/main/install.ps1 | iex`).
115
+ Both scripts still need Node and install the **latest release**, not the tip of `main`.
30
116
 
31
- ```sh
32
- cohorte brainstorm "Ajouter une fonctionnalité"
33
- cohorte spec validate <feature-id>
34
- cohorte spec freeze <feature-id>
35
- cohorte run <feature-id> --detach --json
36
- cohorte status <run-id> --json
37
- cohorte tail <run-id>
38
- cohorte review <run-id>
39
- cohorte fix <run-id>
40
- cohorte ship <run-id>
117
+ Then, in Claude Code, inside each project, once:
118
+
119
+ ```
120
+ /cohorte-init-pipeline
41
121
  ```
42
122
 
43
- Pour un workflow complet borné :
123
+ It **detects** your stack (package manager, workspaces, frameworks, test runners, linters, git remote,
124
+ design system), **interviews** you for the gaps, and **generates**:
125
+
126
+ - `PIPELINE.md` — the project profile (a machine-readable `pipeline-profile` YAML block + prose conventions)
127
+ - one implementer agent per **surface** in `.claude/agents/` (e.g. `backend.md`, `frontend.md`) with its
128
+ own tree and a per-surface `model:` tier
129
+ - `.claude/gate-config.json` + the `.claude/settings.json` permissions — plus an `allow` list of the
130
+ project's read-only commands so agents don't stall on permission prompts
131
+ - the **gate**, via `cohorte sync`: `.claude/hooks/cohorte-gate.py` registered in `.claude/settings.json`,
132
+ the `.claude/pipeline.json` pointer, and the `.gitignore` entries for the local-only artifacts
133
+ - a **code-retrieval provider** wired as a committed project-scope MCP server —
134
+ [Serena](https://github.com/oraios/serena) by default (`graphify` or `none` via `retrieval.provider`)
135
+ - `scripts/new-feature.sh` + `remove-feature.sh` — parallel worktree isolation (if you enable it)
136
+ - `specs/_template.md` (and, on first decision, `specs/_decisions.md` — the project's one-line-per-decision
137
+ journal, read by `/cohorte-brainstorm`, `/cohorte-spec` and `/cohorte-audit`)
138
+
139
+ Sanity-check `PIPELINE.md`, commit what init lists, and run `/cohorte-brainstorm`.
140
+
141
+ ## Update
44
142
 
45
143
  ```sh
46
- cohorte loop <feature-id>
144
+ npm i -g cohorte@latest && cohorte update
47
145
  ```
48
146
 
49
- Les commandes `build`, `audit`, `refactor`, `fleet`, `retro`, `align-ds`, `intake` et `patch` couvrent les variantes de développement. Les commandes `pause`, `resume`, `cancel`, `retry`, `approve`, `deny`, `inspect`, `diff`, `logs`, `shutdown` et `gc` administrent les runs et leur état durable.
147
+ `cohorte update` is the same idempotent operation as `install`: it refreshes the machine install and
148
+ removes files the previous version shipped and this one does not (only when you have not edited them).
149
+ Then, inside each project, run **`/cohorte-update-pipeline`**: it runs `cohorte sync` (refreshes the
150
+ committed gate and the pointer) and **reconciles the repo's generated files to the new core** — new
151
+ profile fields at their defaults, surface agents re-rendered, permissions patched additively, new
152
+ capabilities wired. `/cohorte-init-pipeline` is one-time per project.
153
+
154
+ ### From 2.x
50
155
 
51
- ## Obsidian
156
+ `cohorte update` migrates a 2.x machine: it first removes the 2.x gate registration from
157
+ `~/.claude/settings.json`, then moves the 2.x core (`~/.claude/pipeline/`, `templates/`, `hooks/gate.py`,
158
+ `agents/review.md`…) into `~/.claude/cohorte/legacy-backup/<date>/`. Your own files are never moved.
159
+ Then run `/cohorte-update-pipeline` in each project (or `cohorte sync <project>`): a vendored 2.x core
160
+ in the repo is removed (git keeps it), the pointer loses its `mode`, and surface agents a 2.x global
161
+ init put in `~/.claude/agents` are re-rendered into the project. If you ever tried the discontinued
162
+ Python line (`cohorte@dev` 3.0.0-dev.*, `cohorte-engine` on PyPI): `uv tool uninstall cohorte-engine`
163
+ (or `pipx uninstall cohorte-engine`) so its `cohorte` binary cannot shadow this one, and delete
164
+ `~/.cohorte/` and any `.cohorte/` directory it left in your repos.
52
165
 
53
- Le tableau Kanban Obsidian est optionnel et se connecte explicitement au projet :
166
+ ## Uninstall
54
167
 
55
168
  ```sh
56
- cohorte obsidian create <vault-root> <board-path>
57
- cohorte obsidian connect <vault-root> <board-path>
58
- cohorte obsidian status
59
- cohorte obsidian move <feature-id> <column>
169
+ cohorte uninstall # everything install wrote (your edits are kept and listed)
170
+ cohorte uninstall --purge # …and ~/.claude/cohorte.config.yaml
171
+ cohorte uninstall --project [path] # the gate wiring of one repo (PIPELINE.md, agents, specs stay)
60
172
  ```
61
173
 
62
- La connexion déplace les cartes lors des transitions prévues du workflow ; elle ne copie pas le vault dans le dépôt et ne lit que le fichier de tableau configuré.
174
+ ## Reading a project without an agent
63
175
 
64
- ## Providers, modèles et sécurité
176
+ The two read-only halves of the pipeline, in the shell:
65
177
 
66
178
  ```sh
67
- cohorte auth login
68
- cohorte auth status
69
- cohorte providers list
70
- cohorte providers test
71
- cohorte models list
72
- cohorte policy explain -- <argv>
73
- cohorte doctor --json
179
+ cohorte specs # the board: id · status · branch · title, from specs/*.md
180
+ cohorte doctor # the /cohorte-doctor checks — exits 1 when any check is bad
181
+ cohorte metrics --days=30 # cost + runtime per command, from Claude Code's transcripts
74
182
  ```
75
183
 
76
- Pi est le runtime de référence de V3. Le runtime fake reste disponible pour les tests hors ligne et les smoke tests. Aucun fallback automatique ne change de provider pendant un run : le snapshot épingle le bundle, les prompts, la configuration et le runtime utilisés.
184
+ `doctor`'s exit code is what makes it a CI step, and the three of them are what the Francois
185
+ extension below renders.
77
186
 
78
- Chaque erreur affiche un code stable, son impact et l'action corrective. Les codes de contrôle sont `0` (terminé), `2` (usage), `3` (rejeté), `4` (accepté mais encore en attente) et `16` (annulé) ; les erreurs de run utilisent les classes documentées dans [`docs/v3/reference/exit-codes.md`](docs/v3/reference/exit-codes.md).
187
+ `doctor`'s exit code makes it a CI step as-is. Add `--porcelain` for one record per line with
188
+ `U+001F` between fields (a spec title with a space in it never misaligns a column), or `--json`
189
+ for the native document. Both read through `lib/`, so every consumer — the CLI, a Francois
190
+ panel — answers from one implementation and the repo never gets two verdicts.
79
191
 
80
- ## Migration depuis V2
192
+ `--panel` — on `specs`, `doctor` and `metrics` — emits the payload shape a
193
+ [Francois](https://github.com/antoine-gmnz/francois) extension panel expects. It is the one
194
+ Francois-aware surface in the package, and it exists for
195
+ [**francois-plugin-cohorte**](https://github.com/TheBidouilleAgency/francois-plugin-cohorte): a
196
+ manifest-only extension that renders the spec board, the doctor report and the 30-day cost as
197
+ three panels beside your sessions.
81
198
 
82
- Le runtime et les fichiers V2 ne sont plus présents dans le dépôt. La compatibilité fonctionnelle est couverte par les tests V3 ; l'importeur reste disponible pour convertir un ancien projet :
199
+ A Francois extension may only spawn a **bare binary name resolved on `PATH`** — never `npx`,
200
+ never a shell, never an absolute path. So this one needs the global install, and nothing else
201
+ will do:
83
202
 
84
203
  ```sh
85
- cohorte init --export-v2 <bundle-dir>
86
- cohorte init --from-v2 <bundle-dir> --yes
87
- cohorte migrate --rollback <report-id>
204
+ npm i -g cohorte
205
+ francois ext install TheBidouilleAgency/francois-plugin-cohorte
88
206
  ```
89
207
 
90
- Voir [`docs/v3/MIGRATION.md`](docs/v3/MIGRATION.md) pour les garanties, les sauvegardes et le rollback. Cette procédure ne transforme jamais un ancien run en run V3 : un run V3 démarre avec son propre snapshot et son propre état SQLite.
208
+ ## Releasing (maintainers)
91
209
 
92
- ## Contribuer
210
+ Bump `"version"` in `package.json` and add its `## X.Y.Z — YYYY-MM-DD` section to `CHANGELOG.md`, then
211
+ merge to `main`. [`publish.yml`](.github/workflows/publish.yml) starts only **after CI succeeded** on
212
+ that commit, re-runs the suites, and waits for a maintainer's approval (the `npm-publish` environment)
213
+ before publishing with provenance, tagging `vX.Y.Z` and creating the GitHub release. A pre-release
214
+ version (`3.1.0-rc.1`) is published under the `next` dist-tag, never `latest`. `npm test` runs every
215
+ suite locally.
93
216
 
94
- ```sh
95
- pnpm install --frozen-lockfile
96
- pnpm ci:typecheck
97
- pnpm ci:unit
98
- pnpm ci:integration
99
- pnpm ci:acceptance
217
+ ## The commands
218
+
219
+ | Command | Role |
220
+ | -------------------- | ------------------------------------------------------------------------------------- |
221
+ | `/cohorte-init-pipeline` | Detect stack → interview → generate the profile + agents. Run once per project. |
222
+ | `/cohorte-intake [paste]` | Triage anything that arrives (ticket, email, trace, thread) into a `/cohorte-patch` handoff or a brainstorm seed — staged to disk, carded in Ideas. |
223
+ | `/cohorte-brainstorm` | Interactive persona panel that pressure-tests a feature idea. |
224
+ | `/cohorte-spec` | Freeze the feature spec + contract into `specs/<id>.md` (UI features also get a standalone design brief at `specs/design/<id>.md`). Also applies review returns. |
225
+ | `/cohorte-patch [bug]` | Bug-fix entry: triage a bug and freeze a ~60-line patch spec (`specs/patch-<slug>.md`) whose regression test replaces the contract. Then the normal `/cohorte-build → review → ship`. |
226
+ | `/cohorte-build <id>` | Readiness gate on the frozen spec, then the lead authors the contract and dispatches one implementer per surface in parallel. |
227
+ | `/cohorte-review <id>` | Read-only review agents (one per touched surface, parallel) audit the diff vs the spec; out-of-scope findings go to the refactor backlog. `--pr <num>` reviews an **incoming** GitHub PR in a throwaway worktree and offers to post the report as a comment. |
228
+ | `/cohorte-fix <id>` | Apply a review report: remediation into the spec, re-dispatch only the surfaces with findings. |
229
+ | `/cohorte-fleet plan\|status\|sync` | Fly several features in parallel: overlap matrix + merge order, one worktree per feature, live status, post-merge rebase sweep. Coordination only — never headless execution. |
230
+ | `/cohorte-ship <id>` | Release agent commits, pushes, opens the PR; watches CI; proposes worktree teardown. |
231
+ | `/cohorte-audit [path]` | Prioritized refactor backlog for existing code. |
232
+ | `/cohorte-refactor <domain>` | Apply the backlog for one surface, TDD-first. |
233
+ | `/cohorte-retro [last n]` | Mine the accumulated review findings for patterns; ratified ones become §Conventions rules and the surface agents are re-rendered — the next build never produces the finding. |
234
+ | `/cohorte-align-ds` | Align the code UI kit to the design system (no-op if none configured). |
235
+ | `/cohorte-update-pipeline` | Refresh the machine install, re-wire this repo (`cohorte sync`) and reconcile its generated files. |
236
+ | `/cohorte-doctor` | Diagnose the installation (core, agents↔surfaces, hooks, gate, retrieval, worktrees). |
237
+
238
+ ### Run the loop cheaply — `/clear` between stages
239
+
240
+ Every command reloads all the state it needs **from disk** — the frozen spec, the contract, the diff, the
241
+ Remediation checkboxes, the freshness stamp, and the last `/cohorte-review` report (staged to a gitignored
242
+ `specs/reports/<id>.md`). Nothing essential lives in the conversation. So the loop is **`/clear`-safe at
243
+ every boundary**:
244
+
245
+ ```
246
+ /cohorte-spec → /clear → /cohorte-build → /clear → /cohorte-review → /clear → /cohorte-fix → /clear → /cohorte-review → /cohorte-ship
247
+ ```
248
+
249
+ `/clear`-ing between stages sheds the accumulated main-thread context, which is the single biggest token
250
+ lever: long sessions (>150k) are expensive even when cached. Each command tells you when its handoff is
251
+ safe to clear. If you'd rather stay in one session, `/compact` mid-task does the lighter version. (Claude
252
+ can't fire `/clear` itself — it's a client-side command; the pipeline just makes it always safe to type.)
253
+
254
+
255
+ ### Run features in parallel — one session per feature
256
+
257
+ With `isolation.enabled`, every feature already gets its own worktree, ports, and database
258
+ (`scripts/new-feature.sh <id>` — slots tracked in `.worktrees/slots.tsv`). That isolation is exactly
259
+ what makes **parallel features** safe, and it's the real throughput multiplier when you're rate-limited:
260
+ while feature A's `/cohorte-build` runs its agents (minutes of wall-clock you'd otherwise spend waiting), a
261
+ second Claude Code session can `/cohorte-spec` or `/cohorte-review` feature B.
262
+
263
+ The pattern:
264
+
265
+ ```
266
+ session 1 (main checkout): /cohorte-spec feat-a → /cohorte-build feat-a (agents run…)
267
+ session 2 (main checkout): /cohorte-spec feat-b → /cohorte-build feat-b (agents run…)
268
+ session 1: /cohorte-review feat-a → /cohorte-ship feat-a
269
+ session 2: /cohorte-review feat-b → …
100
270
  ```
101
271
 
102
- La suite complète locale est `pnpm ci:local`. La CI vérifie lint, types, unités, intégration, schémas, migrations, packaging, sécurité, crash recovery, dogfood, acceptance et compatibilité Pi. Consultez [`docs/guide/maintainers.md`](docs/guide/maintainers.md) et [`docs/v3/workspace.md`](docs/v3/workspace.md) pour l'architecture et les procédures de release.
272
+ Rules that make it safe:
273
+
274
+ - **One feature per session.** All lead-side state is keyed by feature id on disk
275
+ (`specs/<id>.md`, `<contract.path>/<id>.*`, `specs/reports/<id>*`), so sessions never share state —
276
+ but a single session interleaving two features accumulates both in its context, paying for both.
277
+ - **Disjoint surfaces per feature are guaranteed** (each worktree is a full checkout), and each
278
+ feature's DB/ports come from its slot — two features' dev servers collide on neither.
279
+ - **The contract package is the one shared tree.** Two features editing
280
+ `<contract.path>/<their-own-id>.<ext>` never conflict (one file per feature); merge order only
281
+ matters if a later feature *imports* an earlier one's contract — ship the dependency first.
282
+ - `/cohorte-ship` one at a time: it commits from the feature's branch and the freshness gate keeps a stale
283
+ verdict from shipping; after each merge, rebase the other live worktrees (`git rebase main`) so
284
+ their eventual reviews diff against reality.
285
+ - `/cohorte-doctor` check 6 shows the live slot table (feature ↔ worktree ↔ ports) when you lose track.
286
+
287
+ ### Workflows — deterministic multi-agent runs (opt-in)
288
+
289
+ Four **workflow scripts** ship for the Claude Code Workflow runtime — the same fan-out the
290
+ commands orchestrate, but driven by a deterministic script instead of the lead reasoning it out
291
+ turn by turn. They are installed in `~/.claude/workflows/`. Three are opt-in variants of their
292
+ same-named commands; the fourth, `cohorte-loop.js`, exists **only** as a workflow:
103
293
 
104
- Licence AGPL-3.0.
294
+ | Script | What it runs |
295
+ | ----------------------- | ----------------------------------------------------------------------------------------- |
296
+ | `cohorte-review.js` | Preflight gate (aborts while red — zero agents), one reviewer per touched surface, adversarial cross-check of CRITICAL/security findings, merged verdict only. |
297
+ | `cohorte-audit.js` | One auditor per domain (every surface + shared) concurrently, prioritized `specs/refactor-backlog.md`. |
298
+ | `cohorte-refactor.js` | Big domains only: `shared` first and alone, then parallel surface implementers, per-domain verify + one retry. |
299
+ | `cohorte-loop.js` | The loop workflow — build → review → [fix → review]* for one feature, unattended and resumable; exits on zero blocking findings, treading water, maxRounds, or anything that needs a human (contract change, unreviewed surface). No conversational fallback, on purpose. |
300
+
301
+ The essentials:
302
+
303
+ - **The conversational commands stay the default path** — and the fallback when workflows are
304
+ disabled or the client is too old. A workflow runs only when you explicitly ask for it
305
+ ("run the review workflow").
306
+ - **Prerequisite: Claude Code ≥ 2.1.154** with workflows enabled. `/cohorte-doctor` (check 8) tells you
307
+ which path your session will take and why.
308
+ - **No input mid-run — questions at the edges.** A workflow runs to completion without asking
309
+ anything: whatever would have been a mid-run question lands in the result at the end. The
310
+ destructive-command gate still fires inside workflow subagents; in unattended runs its confirms
311
+ become denies.
312
+ - Phase 0 of every script is the `cohorte-profile-reader` agent (haiku) — it reads `PIPELINE.md` and hands
313
+ the script the profile as JSON, since workflow scripts have no filesystem access. Mechanical
314
+ phases run on haiku; judgment phases use the same pinned agents as the commands.
315
+
316
+ Details: `profile/SCHEMA.md` §Workflows.
317
+
318
+ ## Privacy
319
+
320
+ Cohorte sends nothing, anywhere. There is no telemetry, no usage pings, no collector — the
321
+ opt-in stats that shipped through 2.2.0 were removed in 2.3.0, sender included. Everything the
322
+ pipeline records (`pipeline-metrics.jsonl`, `specs/reports/`) stays in your repo. The network calls
323
+ are the ones you can see — `git`, `gh`, whatever MCP providers you wired — plus one read-only lookup
324
+ of the latest published version on `registry.npmjs.org` by `cohorte install/update/sync/doctor`
325
+ (`COHORTE_NO_VERSION_CHECK=1` turns it off).
326
+
327
+ ## License
328
+
329
+ [AGPL-3.0](LICENSE). Free to use, including commercially — but if you modify it and distribute it
330
+ or offer it as a network service, you must publish your modifications under the same license.
331
+
332
+ ## Profile reference
333
+
334
+ See `profile/SCHEMA.md` for every field in `PIPELINE.md` and how the pipeline uses it.
335
+
336
+ ## Layout of this repo
337
+
338
+ ```
339
+ package.json # npm package (cohorte) — semver source of truth; `npm test` runs every suite
340
+ bin/cli.js # the CLI: install / update / sync / uninstall / doctor / specs / metrics / version
341
+ bin/report.js # the four renderings of `specs` / `doctor` (human, porcelain, json, panel)
342
+ lib/install.js # the machine install: manifest, ownership rules, 2.x migration, uninstall
343
+ lib/project.js # `cohorte sync`: wires one repo (self-contained; also copied into the core)
344
+ lib/render.js # renders core/commands + core/agents for Claude Code (one preamble of path tokens)
345
+ lib/doctor.js # the JS port of /cohorte-doctor, + versions.js / yaml.js. No dependencies.
346
+ install.sh, install.ps1 # thin wrappers around bin/cli.js for installs without a global npm
347
+ core/
348
+ agents/ # implementer.template.md (rendered per surface) + cohorte-review / -release / -profile-reader
349
+ commands/ # the 16 /cohorte-* commands
350
+ hooks/gate.py # the gate (copied into each project as .claude/hooks/cohorte-gate.py)
351
+ templates/ # handoff / brainstorm-return / design-brief / review-feedback / pr-body / spec + step files
352
+ workflows/ # Workflow-runtime scripts: review / audit / refactor (opt-in variants) + loop (workflow-only)
353
+ profile/
354
+ PIPELINE.template.md # the profile skeleton /cohorte-init-pipeline fills
355
+ SCHEMA.md # field reference
356
+ cohorte.config.template.yaml # seeds ~/.claude/cohorte.config.yaml (kanban)
357
+ scripts/ # shipped preflight/kanban scripts, worktree-isolation templates, metrics, the test suites
358
+ ```
package/bin/cli.js ADDED
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env node
2
+ // cohorte — CLI for the multi-agent dev pipeline for Claude Code.
3
+ //
4
+ // npm i -g cohorte # the CLI, and the `cohorte` binary on PATH
5
+ // cohorte install # once per machine: commands, agents, workflows, core → ~/.claude
6
+ // cohorte sync [project] # wire one repo: gate hook, pointer, .gitignore (init/update run it)
7
+ // cohorte update # refresh the machine-wide install (same as install, idempotent)
8
+ // cohorte uninstall # remove exactly what install wrote
9
+ //
10
+ // One mode since 3.0.0: the machine gets the commands and the generic core; everything that
11
+ // describes a project (PIPELINE.md, surface agents, gate config, the gate hook) lives in that
12
+ // project and is committed with it.
13
+
14
+ 'use strict';
15
+
16
+ const fs = require('fs');
17
+ const os = require('os');
18
+ const path = require('path');
19
+ const { spawnSync } = require('child_process');
20
+
21
+ const pkgRoot = path.resolve(__dirname, '..');
22
+ const pkg = JSON.parse(fs.readFileSync(path.join(pkgRoot, 'package.json'), 'utf8'));
23
+ const VERSION = pkg.version;
24
+ const globalDir = process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude');
25
+
26
+ function usage(code) {
27
+ console.log(`cohorte v${VERSION}
28
+
29
+ Usage:
30
+ cohorte install Install (or refresh) cohorte on this machine
31
+ cohorte update Same as install — idempotent, migrates a 2.x install
32
+ cohorte sync [project] Wire one repo (run by /cohorte-init-pipeline and /cohorte-update-pipeline)
33
+ cohorte uninstall [--purge] Remove what install wrote (--purge also removes your config)
34
+ cohorte uninstall --project [project] Remove what sync wrote in one repo
35
+ cohorte doctor [project] [--porcelain | --json | --panel]
36
+ cohorte specs [project] [--porcelain | --json | --panel]
37
+ cohorte metrics [project] [--days=N] [--since=ISO] [--runs] [--json]
38
+ cohorte version
39
+
40
+ Where things go:
41
+ This machine (${displayHome(globalDir)}):
42
+ commands/cohorte-*.md, agents/cohorte-*.md, workflows/cohorte-*.js, cohorte/ (core + manifest),
43
+ cohorte.config.yaml (your kanban/vault config — seeded once, never overwritten).
44
+ Each project (committed):
45
+ PIPELINE.md, .claude/agents/<surface>.md, .claude/gate-config.json,
46
+ .claude/hooks/cohorte-gate.py + its registration in .claude/settings.json, .claude/pipeline.json.
47
+
48
+ install never deletes a file it did not write, backs up any file of ours you modified, and
49
+ refuses to run if ~/.claude/settings.json is not valid JSON.
50
+
51
+ doctor runs the same checks as /cohorte-doctor without a coding agent; exits 1 when any check
52
+ is bad (CI-friendly). --panel emits the payload the Francois extension panel expects.
53
+ CLAUDE_CONFIG_DIR moves ${displayHome(path.join(os.homedir(), '.claude'))}; COHORTE_NO_VERSION_CHECK=1 skips the npm lookup.`);
54
+ process.exit(code);
55
+ }
56
+
57
+ function displayHome(p) {
58
+ const home = os.homedir();
59
+ return p.startsWith(home + path.sep) ? '~/' + path.relative(home, p) : p;
60
+ }
61
+
62
+ // --- arg parsing -------------------------------------------------------------
63
+ const args = process.argv.slice(2);
64
+ let mode = null;
65
+ let target = null;
66
+ let format = 'human';
67
+ let purge = false;
68
+ let projectScope = false;
69
+ const metricsFlags = [];
70
+ const isMetricsFlag = (a) =>
71
+ a === '--json' || a === '--runs' || a.startsWith('--days=') || a.startsWith('--since=');
72
+ const VERBS = ['install', 'update', 'sync', 'uninstall', 'metrics', 'specs', 'doctor'];
73
+
74
+ for (const a of args) {
75
+ if (!mode && VERBS.includes(a)) mode = a;
76
+ else if (a === '--porcelain' || a === '--panel') format = a.slice(2);
77
+ else if (isMetricsFlag(a)) { if (a === '--json') format = 'json'; metricsFlags.push(a); }
78
+ else if (a === 'version' || a === '--version' || a === '-v') { console.log(VERSION); process.exit(0); }
79
+ else if (a === 'help' || a === '--help' || a === '-h') usage(0);
80
+ else if (a === '--purge') purge = true;
81
+ else if (a === '--project') projectScope = true;
82
+ // 2.x flags. --global is what 3.x always does; --runtime=claude is the only runtime left.
83
+ else if (a === '--global' || a === '-g') { /* the only mode */ }
84
+ else if (a === '--runtime=claude' || a === '--runtimes=claude') { /* the only runtime */ }
85
+ else if (a.startsWith('--runtime') || a === '--all-runtimes') {
86
+ console.error('error: cohorte 3.x supports Claude Code only. The multi-runtime installer (Codex, Cursor,\n'
87
+ + ' Gemini, OpenCode) is archived: npx cohorte@2.10.2, or the archive/multi-runtime branch.');
88
+ process.exit(2);
89
+ }
90
+ else if (a.startsWith('-')) { console.error(`error: unknown flag: ${a}`); usage(2); }
91
+ else if (target === null) target = path.resolve(a);
92
+ else { console.error(`error: unexpected argument: ${a}`); usage(2); }
93
+ }
94
+ if (!mode) usage(args.length ? 2 : 0);
95
+ if ((mode === 'install' || mode === 'update') && target) {
96
+ console.error(`error: \`cohorte ${mode}\` installs on this machine and takes no project path.\n`
97
+ + ` To wire a project, run \`cohorte sync ${path.relative(process.cwd(), target) || '.'}\` (or /cohorte-init-pipeline inside it).\n`
98
+ + ' 2.x "bundled" installs (a core copied into the repo) no longer exist.');
99
+ process.exit(2);
100
+ }
101
+ const project = target || process.cwd();
102
+
103
+ // --- read-only reports -------------------------------------------------------
104
+ if (mode === 'specs' || mode === 'doctor') {
105
+ const report = require('./report.js');
106
+ const { state, scanSpecs } = require('../lib/doctor.js');
107
+ if (mode === 'specs') {
108
+ const records = report.specRecords(project, scanSpecs);
109
+ if (format === 'json') console.log(JSON.stringify({ project, specs: records }, null, 2));
110
+ else if (format === 'porcelain') { if (records.length) console.log(report.specsPorcelain(records)); }
111
+ else if (format === 'panel') console.log(report.specsPanel(records));
112
+ else console.log(report.specsHuman(records));
113
+ process.exit(0);
114
+ }
115
+ state({ projectRoot: project, globalDir, cliVersion: VERSION }).then((s) => {
116
+ const records = report.checkRecords(s);
117
+ if (format === 'json') console.log(JSON.stringify(s, null, 2));
118
+ else if (format === 'porcelain') { if (records.length) console.log(report.doctorPorcelain(records)); }
119
+ else if (format === 'panel') console.log(report.doctorPanel(records));
120
+ else console.log(report.doctorHuman(s, records));
121
+ process.exit(s.summary.bad > 0 && format !== 'panel' ? 1 : 0);
122
+ }).catch((e) => {
123
+ console.error(`error: ${e && e.message ? e.message : e}`);
124
+ process.exit(1);
125
+ });
126
+ return;
127
+ }
128
+
129
+ if (mode === 'metrics') {
130
+ if (format === 'panel') metricsFlags.push('--panel');
131
+ const script = path.join(pkgRoot, 'scripts', 'metrics', 'collect.mjs');
132
+ const r = spawnSync(process.execPath, [script, project, ...metricsFlags], { stdio: 'inherit' });
133
+ process.exit(r.status == null ? 1 : r.status);
134
+ }
135
+
136
+ // --- writers -----------------------------------------------------------------
137
+ function ask(question) {
138
+ const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
139
+ return new Promise((res) => rl.question(question, (a) => { rl.close(); res((a || '').trim()); }));
140
+ }
141
+
142
+ function printList(lines, bullet = '·') { for (const l of lines) console.log(` ${bullet} ${l}`); }
143
+
144
+ // The committed project hook runs `python3 …` on every platform, so that is the name to probe.
145
+ function python3Present() {
146
+ const r = spawnSync('python3', ['-c', 'import sys; sys.exit(0 if sys.version_info >= (3, 9) else 1)'], { stdio: 'ignore' });
147
+ return r.status === 0;
148
+ }
149
+
150
+ async function staleVersionNotice() {
151
+ if (process.env.CI) return;
152
+ try {
153
+ const v = require('../lib/versions.js');
154
+ const latest = await v.latestNpm({ timeoutMs: 2500, fallback: false });
155
+ if (!latest || v.cmpSemver(VERSION, latest) >= 0) return;
156
+ const viaNpx = /[\\/]_npx[\\/]/.test(pkgRoot);
157
+ console.log(`\n! You ran cohorte ${VERSION}, but ${latest} is published.\n `
158
+ + (viaNpx ? 'Re-run as npx cohorte@latest <same command>.' : 'Upgrade with npm i -g cohorte@latest and re-run the same command.'));
159
+ } catch { /* never fatal */ }
160
+ }
161
+
162
+ (async () => {
163
+ try {
164
+ if (mode === 'install' || mode === 'update') {
165
+ const { install } = require('../lib/install.js');
166
+ const interactive = process.stdin.isTTY && process.stdout.isTTY;
167
+ console.log(`→ ${mode === 'update' ? 'updating' : 'installing'} cohorte ${VERSION} in ${displayHome(globalDir)}`);
168
+ const r = await install(globalDir, { ask: interactive ? ask : null });
169
+ printList(r.report);
170
+ if (r.warnings.length) { console.log('\n Heads-up:'); printList(r.warnings, '!'); }
171
+ if (!python3Present()) {
172
+ console.log('\n ! python3 ≥ 3.9 was not found. The gate hook each project runs needs it — without it,'
173
+ + '\n every Bash call in a cohorte project is refused (the hook is fail-closed).');
174
+ }
175
+ console.log(`
176
+ ✓ cohorte ${VERSION} is installed for Claude Code on this machine.
177
+
178
+ Next, in each project:
179
+ 1. Open it in Claude Code and run /cohorte-init-pipeline (once) — it writes PIPELINE.md, renders the
180
+ surface agents into .claude/agents and runs cohorte sync to wire the gate.
181
+ 2. Commit what it lists, then /cohorte-brainstorm to start a feature.
182
+ Already-wired projects: run /cohorte-update-pipeline inside each to pick up this version.`);
183
+ } else if (mode === 'sync') {
184
+ const { sync } = require('../lib/project.js');
185
+ const r = sync(project);
186
+ console.log(`cohorte sync — ${r.root} (core ${r.version})`);
187
+ if (r.changes.length) printList(r.changes); else console.log(' · already in sync');
188
+ if (!fs.existsSync(path.join(globalDir, 'cohorte', 'pipeline', 'VERSION'))) {
189
+ console.log(' ! cohorte is not installed on this machine — run `cohorte install` for the commands.');
190
+ }
191
+ if (r.changes.length) console.log(' Commit .claude/settings.json, .claude/hooks/cohorte-gate.py, .claude/pipeline.json and .gitignore.');
192
+ } else if (mode === 'uninstall') {
193
+ if (projectScope) {
194
+ const { unsync } = require('../lib/project.js');
195
+ const r = unsync(project);
196
+ if (r.changes.length) printList(r.changes); else console.log(' · nothing of cohorte\'s to remove here');
197
+ if (r.left.length) console.log(` Project files kept (yours to delete): ${r.left.join(', ')}`);
198
+ } else {
199
+ const { uninstall } = require('../lib/install.js');
200
+ const r = uninstall(globalDir, { purge });
201
+ printList(r.report.length ? r.report : ['nothing installed']);
202
+ if (r.warnings.length) { console.log('\n Heads-up:'); printList(r.warnings, '!'); }
203
+ console.log('\n Projects keep their own files (PIPELINE.md, .claude/…): `cohorte uninstall --project <path>` removes the gate wiring.');
204
+ }
205
+ return;
206
+ }
207
+ await staleVersionNotice();
208
+ } catch (e) {
209
+ console.error(`error: ${e && e.message ? e.message : e}`);
210
+ process.exit(1);
211
+ }
212
+ })();