cohorte 3.0.0-dev.8 → 3.1.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 (251) hide show
  1. package/CHANGELOG.md +1637 -0
  2. package/README.md +322 -62
  3. package/bin/cli.js +213 -0
  4. package/bin/report.js +141 -0
  5. package/core/agents/cohorte-profile-reader.md +40 -0
  6. package/core/agents/cohorte-release.md +61 -0
  7. package/core/agents/cohorte-review.md +200 -0
  8. package/core/agents/implementer.template.md +154 -0
  9. package/core/commands/cohorte-align-ds.md +33 -0
  10. package/core/commands/cohorte-audit.md +74 -0
  11. package/core/commands/cohorte-brainstorm.md +73 -0
  12. package/core/commands/cohorte-build.md +248 -0
  13. package/core/commands/cohorte-doctor.md +135 -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 +122 -0
  20. package/core/commands/cohorte-retro.md +85 -0
  21. package/core/commands/cohorte-revert.md +104 -0
  22. package/core/commands/cohorte-review.md +239 -0
  23. package/core/commands/cohorte-ship.md +167 -0
  24. package/core/commands/cohorte-spec.md +114 -0
  25. package/core/commands/cohorte-update-pipeline.md +119 -0
  26. package/core/commands/cohorte-verify.md +106 -0
  27. package/core/hooks/gate.py +3236 -0
  28. package/core/templates/agent-handoff.md +34 -0
  29. package/core/templates/brainstorm-return.md +42 -0
  30. package/core/templates/decisions.template.md +42 -0
  31. package/core/templates/design-brief.md +37 -0
  32. package/core/templates/patch.template.md +95 -0
  33. package/core/templates/pr-body.md +25 -0
  34. package/core/templates/review-feedback.md +46 -0
  35. package/core/templates/spec.template.md +109 -0
  36. package/core/templates/steps/init-pipeline/01-detect-stack.md +53 -0
  37. package/core/templates/steps/init-pipeline/02-interview-gaps.md +78 -0
  38. package/core/templates/steps/init-pipeline/03-draft-profile.md +10 -0
  39. package/core/templates/steps/init-pipeline/04-write-render.md +95 -0
  40. package/core/templates/steps/init-pipeline/05-report.md +11 -0
  41. package/core/templates/steps/review-pr/01-pr-mode.md +54 -0
  42. package/core/workflows/audit.js +311 -0
  43. package/core/workflows/loop.js +692 -0
  44. package/core/workflows/refactor.js +398 -0
  45. package/core/workflows/review.js +505 -0
  46. package/install.ps1 +72 -0
  47. package/install.sh +69 -0
  48. package/lib/doctor.js +506 -0
  49. package/lib/install.js +386 -0
  50. package/lib/project.js +359 -0
  51. package/lib/render.js +121 -0
  52. package/lib/versions.js +145 -0
  53. package/lib/yaml.js +183 -0
  54. package/package.json +36 -17
  55. package/profile/PIPELINE.template.md +288 -0
  56. package/profile/SCHEMA.md +30 -0
  57. package/profile/cohorte.config.template.yaml +43 -0
  58. package/profile/schema/dead-agents.md +29 -0
  59. package/profile/schema/decisions.md +23 -0
  60. package/profile/schema/deferred.md +22 -0
  61. package/profile/schema/feature-diff.md +20 -0
  62. package/profile/schema/kanban.md +95 -0
  63. package/profile/schema/metrics.md +23 -0
  64. package/profile/schema/output-discipline.md +21 -0
  65. package/profile/schema/preflight.md +81 -0
  66. package/profile/schema/profile-block.md +103 -0
  67. package/profile/schema/project-kinds.md +89 -0
  68. package/profile/schema/readiness.md +17 -0
  69. package/profile/schema/reconcile.md +64 -0
  70. package/profile/schema/release-notes.md +29 -0
  71. package/profile/schema/rendering.md +48 -0
  72. package/profile/schema/retrieval.md +58 -0
  73. package/profile/schema/spec-status.md +79 -0
  74. package/profile/schema/specialization.md +41 -0
  75. package/profile/schema/verify.md +115 -0
  76. package/profile/schema/workflows.md +78 -0
  77. package/scripts/feature-diff.sh +118 -0
  78. package/scripts/kanban-move.sh +349 -0
  79. package/scripts/metrics/collect.mjs +542 -0
  80. package/scripts/metrics/prices.json +42 -0
  81. package/scripts/new-feature.sh.template +122 -0
  82. package/scripts/preflight.sh +114 -0
  83. package/scripts/remove-feature.sh.template +56 -0
  84. package/scripts/verify-run.sh +509 -0
  85. package/assets/manifest.json +0 -203
  86. package/assets/migrations/config/README.md +0 -12
  87. package/assets/migrations/state/0001_init.sql +0 -154
  88. package/assets/prompts/README.md +0 -11
  89. package/assets/prompts/agents/brainstormer.md +0 -3
  90. package/assets/prompts/agents/fixer.md +0 -7
  91. package/assets/prompts/agents/implementer.md +0 -12
  92. package/assets/prompts/agents/reviewer.md +0 -8
  93. package/assets/prompts/agents/security-reviewer.md +0 -7
  94. package/assets/prompts/agents/spec-author.md +0 -3
  95. package/assets/prompts/phases/build.md +0 -5
  96. package/assets/prompts/phases/review.md +0 -5
  97. package/assets/prompts/phases/test.md +0 -5
  98. package/assets/prompts/system.md +0 -11
  99. package/assets/schemas/agent-output.schema.json +0 -225
  100. package/assets/schemas/auth-status.schema.json +0 -87
  101. package/assets/schemas/command-result.schema.json +0 -192
  102. package/assets/schemas/commands.schema.json +0 -959
  103. package/assets/schemas/config.schema.json +0 -2281
  104. package/assets/schemas/doctor-report.schema.json +0 -104
  105. package/assets/schemas/events.schema.json +0 -8514
  106. package/assets/schemas/fake-script.schema.json +0 -549
  107. package/assets/schemas/inspect.schema.json +0 -3133
  108. package/assets/schemas/manifest.schema.json +0 -79
  109. package/assets/schemas/ownership.schema.json +0 -52
  110. package/assets/schemas/policy-verdict.schema.json +0 -282
  111. package/assets/schemas/project-model.schema.json +0 -783
  112. package/assets/schemas/project-status.schema.json +0 -217
  113. package/assets/schemas/reconcile-plan.schema.json +0 -154
  114. package/assets/schemas/run-diff.schema.json +0 -177
  115. package/assets/schemas/run-snapshot-manifest.schema.json +0 -2104
  116. package/assets/schemas/run-state.schema.json +0 -1755
  117. package/assets/schemas/runtime-capabilities.schema.json +0 -1545
  118. package/assets/schemas/sandbox-capabilities.schema.json +0 -116
  119. package/assets/schemas/skill.schema.json +0 -87
  120. package/assets/schemas/spec.schema.json +0 -202
  121. package/assets/schemas/tool-catalogue.schema.json +0 -655
  122. package/assets/schemas/trust-record.schema.json +0 -38
  123. package/assets/skills/README.md +0 -9
  124. package/assets/skills/inspect-surface.md +0 -4
  125. package/dist/agent-host.mjs +0 -2187
  126. package/dist/agent-host.mjs.map +0 -1
  127. package/dist/bundle-manifest.json +0 -128
  128. package/dist/chunks/__host-DgGPyco9.mjs +0 -18
  129. package/dist/chunks/__host-DgGPyco9.mjs.map +0 -1
  130. package/dist/chunks/align-ds-r_X_1aQ_.mjs +0 -93
  131. package/dist/chunks/align-ds-r_X_1aQ_.mjs.map +0 -1
  132. package/dist/chunks/approve-Cv135UqI.mjs +0 -19
  133. package/dist/chunks/approve-Cv135UqI.mjs.map +0 -1
  134. package/dist/chunks/audit-B4ZWQ_DI.mjs +0 -179
  135. package/dist/chunks/audit-B4ZWQ_DI.mjs.map +0 -1
  136. package/dist/chunks/auth-BT5oVp76.mjs +0 -132
  137. package/dist/chunks/auth-BT5oVp76.mjs.map +0 -1
  138. package/dist/chunks/auth-Dnlksuo5.mjs +0 -141
  139. package/dist/chunks/auth-Dnlksuo5.mjs.map +0 -1
  140. package/dist/chunks/brainstorm-SJwOIEif.mjs +0 -123
  141. package/dist/chunks/brainstorm-SJwOIEif.mjs.map +0 -1
  142. package/dist/chunks/build-C_-mbZfD.mjs +0 -19
  143. package/dist/chunks/build-C_-mbZfD.mjs.map +0 -1
  144. package/dist/chunks/cancel-KV_cpsqS.mjs +0 -15
  145. package/dist/chunks/cancel-KV_cpsqS.mjs.map +0 -1
  146. package/dist/chunks/canonical-C8UxeEmB.mjs +0 -57
  147. package/dist/chunks/canonical-C8UxeEmB.mjs.map +0 -1
  148. package/dist/chunks/catalogue-IaCJdfB8.mjs +0 -1549
  149. package/dist/chunks/catalogue-IaCJdfB8.mjs.map +0 -1
  150. package/dist/chunks/compose-DRKjQcn0.mjs +0 -7333
  151. package/dist/chunks/compose-DRKjQcn0.mjs.map +0 -1
  152. package/dist/chunks/config-Cqu5XQoP.mjs +0 -96
  153. package/dist/chunks/config-Cqu5XQoP.mjs.map +0 -1
  154. package/dist/chunks/contract-DjssDPpS.mjs +0 -335
  155. package/dist/chunks/contract-DjssDPpS.mjs.map +0 -1
  156. package/dist/chunks/contract-bQ9FJl4N.mjs +0 -123
  157. package/dist/chunks/contract-bQ9FJl4N.mjs.map +0 -1
  158. package/dist/chunks/deny-ClTxSvHJ.mjs +0 -15
  159. package/dist/chunks/deny-ClTxSvHJ.mjs.map +0 -1
  160. package/dist/chunks/diff-Qw0II0sj.mjs +0 -101
  161. package/dist/chunks/diff-Qw0II0sj.mjs.map +0 -1
  162. package/dist/chunks/discover-BZPolSZG.mjs +0 -21
  163. package/dist/chunks/discover-BZPolSZG.mjs.map +0 -1
  164. package/dist/chunks/doctor-DcDFPvQM.mjs +0 -222
  165. package/dist/chunks/doctor-DcDFPvQM.mjs.map +0 -1
  166. package/dist/chunks/fix-C9roGiQz.mjs +0 -82
  167. package/dist/chunks/fix-C9roGiQz.mjs.map +0 -1
  168. package/dist/chunks/fleet-yWHQY2ya.mjs +0 -297
  169. package/dist/chunks/fleet-yWHQY2ya.mjs.map +0 -1
  170. package/dist/chunks/gc-BBXlBF5w.mjs +0 -161
  171. package/dist/chunks/gc-BBXlBF5w.mjs.map +0 -1
  172. package/dist/chunks/init--FxxkrcT.mjs +0 -63
  173. package/dist/chunks/init--FxxkrcT.mjs.map +0 -1
  174. package/dist/chunks/inspect-Buby4cQD.mjs +0 -22
  175. package/dist/chunks/inspect-Buby4cQD.mjs.map +0 -1
  176. package/dist/chunks/intake-C1pesxCJ.mjs +0 -12
  177. package/dist/chunks/intake-C1pesxCJ.mjs.map +0 -1
  178. package/dist/chunks/logs-Giq5sUau.mjs +0 -25
  179. package/dist/chunks/logs-Giq5sUau.mjs.map +0 -1
  180. package/dist/chunks/loop-BWsUpyus.mjs +0 -212
  181. package/dist/chunks/loop-BWsUpyus.mjs.map +0 -1
  182. package/dist/chunks/migrate-DuYCAbE3.mjs +0 -33
  183. package/dist/chunks/migrate-DuYCAbE3.mjs.map +0 -1
  184. package/dist/chunks/models-Btp6X2YZ.mjs +0 -24
  185. package/dist/chunks/models-Btp6X2YZ.mjs.map +0 -1
  186. package/dist/chunks/obsidian-BHLkXx_H.mjs +0 -235
  187. package/dist/chunks/obsidian-BHLkXx_H.mjs.map +0 -1
  188. package/dist/chunks/patch-sAgVqjpx.mjs +0 -50
  189. package/dist/chunks/patch-sAgVqjpx.mjs.map +0 -1
  190. package/dist/chunks/pause-BASBfKLO.mjs +0 -16
  191. package/dist/chunks/pause-BASBfKLO.mjs.map +0 -1
  192. package/dist/chunks/policy-Du7WVBFX.mjs +0 -139
  193. package/dist/chunks/policy-Du7WVBFX.mjs.map +0 -1
  194. package/dist/chunks/providers-Dx78imKj.mjs +0 -19
  195. package/dist/chunks/providers-Dx78imKj.mjs.map +0 -1
  196. package/dist/chunks/reconcile-BHn66X3C.mjs +0 -50
  197. package/dist/chunks/reconcile-BHn66X3C.mjs.map +0 -1
  198. package/dist/chunks/refactor-DV3RfGjk.mjs +0 -153
  199. package/dist/chunks/refactor-DV3RfGjk.mjs.map +0 -1
  200. package/dist/chunks/render-DyZr5Lgi.mjs +0 -53
  201. package/dist/chunks/render-DyZr5Lgi.mjs.map +0 -1
  202. package/dist/chunks/resume-GJQRb2Eb.mjs +0 -15
  203. package/dist/chunks/resume-GJQRb2Eb.mjs.map +0 -1
  204. package/dist/chunks/retro-Dr-2RTNN.mjs +0 -78
  205. package/dist/chunks/retro-Dr-2RTNN.mjs.map +0 -1
  206. package/dist/chunks/retry-CLrUem1H.mjs +0 -15
  207. package/dist/chunks/retry-CLrUem1H.mjs.map +0 -1
  208. package/dist/chunks/review-ZsBqp3vZ.mjs +0 -35
  209. package/dist/chunks/review-ZsBqp3vZ.mjs.map +0 -1
  210. package/dist/chunks/run-BGabwbDL.mjs +0 -109
  211. package/dist/chunks/run-BGabwbDL.mjs.map +0 -1
  212. package/dist/chunks/run-tool-C3rAv4XF.mjs +0 -26
  213. package/dist/chunks/run-tool-C3rAv4XF.mjs.map +0 -1
  214. package/dist/chunks/scan-C5uDr7Yq.mjs +0 -167
  215. package/dist/chunks/scan-C5uDr7Yq.mjs.map +0 -1
  216. package/dist/chunks/schema-Bq9qtgsd.mjs +0 -583
  217. package/dist/chunks/schema-Bq9qtgsd.mjs.map +0 -1
  218. package/dist/chunks/send-BdnJ85Nz.mjs +0 -19
  219. package/dist/chunks/send-BdnJ85Nz.mjs.map +0 -1
  220. package/dist/chunks/ship-BizfUe62.mjs +0 -140
  221. package/dist/chunks/ship-BizfUe62.mjs.map +0 -1
  222. package/dist/chunks/shutdown-BM92Iyv2.mjs +0 -15
  223. package/dist/chunks/shutdown-BM92Iyv2.mjs.map +0 -1
  224. package/dist/chunks/skip-DZG5kpcH.mjs +0 -18
  225. package/dist/chunks/skip-DZG5kpcH.mjs.map +0 -1
  226. package/dist/chunks/spec-C2h3U64g.mjs +0 -65
  227. package/dist/chunks/spec-C2h3U64g.mjs.map +0 -1
  228. package/dist/chunks/spec-path-tptqR7W8.mjs +0 -10
  229. package/dist/chunks/spec-path-tptqR7W8.mjs.map +0 -1
  230. package/dist/chunks/src-Bfr1yzsn.mjs +0 -1689
  231. package/dist/chunks/src-Bfr1yzsn.mjs.map +0 -1
  232. package/dist/chunks/src-CPW2_Ons.mjs +0 -5487
  233. package/dist/chunks/src-CPW2_Ons.mjs.map +0 -1
  234. package/dist/chunks/src-Cu3TxNob.mjs +0 -783
  235. package/dist/chunks/src-Cu3TxNob.mjs.map +0 -1
  236. package/dist/chunks/src-DNsLSxgm.mjs +0 -928
  237. package/dist/chunks/src-DNsLSxgm.mjs.map +0 -1
  238. package/dist/chunks/src-DbS9gkJy.mjs +0 -117
  239. package/dist/chunks/src-DbS9gkJy.mjs.map +0 -1
  240. package/dist/chunks/src-yi5whv3n.mjs +0 -2118
  241. package/dist/chunks/src-yi5whv3n.mjs.map +0 -1
  242. package/dist/chunks/status-SMjiOMYy.mjs +0 -29
  243. package/dist/chunks/status-SMjiOMYy.mjs.map +0 -1
  244. package/dist/chunks/tail-BuhT-2PH.mjs +0 -25
  245. package/dist/chunks/tail-BuhT-2PH.mjs.map +0 -1
  246. package/dist/chunks/update-BXIppsbi.mjs +0 -16
  247. package/dist/chunks/update-BXIppsbi.mjs.map +0 -1
  248. package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs +0 -56
  249. package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs.map +0 -1
  250. package/dist/cli.mjs +0 -186
  251. package/dist/cli.mjs.map +0 -1
package/bin/cli.js ADDED
@@ -0,0 +1,213 @@
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 (r.notes && r.notes.length) printList(r.notes, '!');
189
+ if (!fs.existsSync(path.join(globalDir, 'cohorte', 'pipeline', 'VERSION'))) {
190
+ console.log(' ! cohorte is not installed on this machine — run `cohorte install` for the commands.');
191
+ }
192
+ if (r.changes.length) console.log(` Commit ${require('../lib/project.js').COMMIT_LIST}.`);
193
+ } else if (mode === 'uninstall') {
194
+ if (projectScope) {
195
+ const { unsync } = require('../lib/project.js');
196
+ const r = unsync(project);
197
+ if (r.changes.length) printList(r.changes); else console.log(' · nothing of cohorte\'s to remove here');
198
+ if (r.left.length) console.log(` Project files kept (yours to delete): ${r.left.join(', ')}`);
199
+ } else {
200
+ const { uninstall } = require('../lib/install.js');
201
+ const r = uninstall(globalDir, { purge });
202
+ printList(r.report.length ? r.report : ['nothing installed']);
203
+ if (r.warnings.length) { console.log('\n Heads-up:'); printList(r.warnings, '!'); }
204
+ console.log('\n Projects keep their own files (PIPELINE.md, .claude/…): `cohorte uninstall --project <path>` removes the gate wiring.');
205
+ }
206
+ return;
207
+ }
208
+ await staleVersionNotice();
209
+ } catch (e) {
210
+ console.error(`error: ${e && e.message ? e.message : e}`);
211
+ process.exit(1);
212
+ }
213
+ })();
package/bin/report.js ADDED
@@ -0,0 +1,141 @@
1
+ 'use strict';
2
+ // Machine-readable reports for `cohorte specs` and `cohorte doctor`.
3
+ //
4
+ // Both commands read what lib/doctor.js computes (`scanSpecs` and `state`) and
5
+ // render it four ways:
6
+ //
7
+ // default a human table on a terminal
8
+ // --porcelain one record per line, fields separated by U+001F (the ASCII unit
9
+ // separator) — stable, greppable, and immune to a spec title that
10
+ // contains a space, a tab or a pipe
11
+ // --json the native document (the full doctor state, the spec list)
12
+ // --panel the payload shape a Francois extension panel validates against
13
+ // (`{rows:[{key,value,tone}]}` / `{rows:[{id,cells,tone}]}`). This is
14
+ // the ONLY Francois-aware surface in cohorte; everything else here is
15
+ // generic. See github.com/TheBidouilleAgency/francois-plugin-cohorte.
16
+ //
17
+ // Dependency-free, and it never writes anything.
18
+
19
+ const US = String.fromCharCode(0x1f); // ASCII unit separator (U+001F)
20
+
21
+ // A spec's status → a display tone. The tones are the ones a status column can carry
22
+ // anywhere (terminal colour, panel row tone); `busy` marks the two statuses that mean
23
+ // "a command is mid-flight on this spec".
24
+ const STATUS_TONE = {
25
+ draft: 'neutral',
26
+ frozen: 'neutral',
27
+ 'in-progress': 'busy',
28
+ 'in-review': 'busy',
29
+ shipped: 'ok',
30
+ blocked: 'error',
31
+ };
32
+
33
+ // doctor's four check states → the same tone vocabulary. `skip` is not a failure:
34
+ // a check that does not apply to this project (no design system, no worktrees) reads
35
+ // neutral, never warn.
36
+ const CHECK_TONE = { ok: 'ok', warn: 'warn', bad: 'error', skip: 'neutral' };
37
+
38
+ // Collapse anything that would break the line format or a single-line cell. A spec
39
+ // title is free text written by a human in YAML frontmatter — it can contain a newline
40
+ // continuation, and it must never split one record into two. A stray separator inside a
41
+ // field goes the same way, and so does the padding a doctor `fix` carries for terminal
42
+ // alignment — in a one-line panel cell that padding reads as a hole.
43
+ function flat(value) {
44
+ return String(value == null ? '' : value)
45
+ .replace(new RegExp(`[\\s${US}]+`, 'g'), ' ')
46
+ .trim();
47
+ }
48
+
49
+ function specRecords(projectRoot, scanSpecs) {
50
+ return scanSpecs(projectRoot).map((s) => ({
51
+ id: s.id,
52
+ title: s.title || '',
53
+ status: s.status || 'unknown',
54
+ branch: s.branch || '',
55
+ file: s.file,
56
+ tone: STATUS_TONE[s.status] || 'warn', // an unknown status IS the warning
57
+ }));
58
+ }
59
+
60
+ function specsPorcelain(records) {
61
+ return records
62
+ .map((r) => [r.id, r.title, r.status, r.branch, r.tone].map(flat).join(US))
63
+ .join('\n');
64
+ }
65
+
66
+ function specsPanel(records) {
67
+ return JSON.stringify({
68
+ rows: records.map((r) => ({
69
+ id: flat(r.id),
70
+ tone: r.tone,
71
+ cells: { id: flat(r.id), title: flat(r.title), status: flat(r.status), branch: flat(r.branch) },
72
+ })),
73
+ });
74
+ }
75
+
76
+ function specsHuman(records) {
77
+ if (!records.length) return 'no specs in ./specs — /cohorte-spec writes the first one';
78
+ const w = (k) => Math.max(...records.map((r) => flat(r[k]).length), k.length);
79
+ const [wi, ws, wb] = [w('id'), w('status'), w('branch')];
80
+ const head = `${'id'.padEnd(wi)} ${'status'.padEnd(ws)} ${'branch'.padEnd(wb)} title`;
81
+ const rows = records.map(
82
+ (r) => `${flat(r.id).padEnd(wi)} ${flat(r.status).padEnd(ws)} ${flat(r.branch).padEnd(wb)} ${flat(r.title)}`,
83
+ );
84
+ return [head, '-'.repeat(head.length), ...rows].join('\n');
85
+ }
86
+
87
+ function checkRecords(state) {
88
+ return state.checks.map((c) => ({
89
+ id: c.id,
90
+ label: c.label,
91
+ status: c.status,
92
+ detail: c.detail,
93
+ fix: c.fix || '',
94
+ tone: CHECK_TONE[c.status] || 'neutral',
95
+ }));
96
+ }
97
+
98
+ function doctorPorcelain(records) {
99
+ return records
100
+ .map((r) => [r.id, r.label, r.status, r.detail, r.fix].map(flat).join(US))
101
+ .join('\n');
102
+ }
103
+
104
+ // key-value, one row per check: the check's label keyed against what it found. The fix
105
+ // rides in the value for a failing check — a panel row has nowhere else to put it, and
106
+ // a health report that says "broken" without saying "run this" is half a report.
107
+ function doctorPanel(records) {
108
+ return JSON.stringify({
109
+ rows: records.map((r) => ({
110
+ key: flat(r.label),
111
+ value: flat(r.fix && r.tone !== 'ok' ? `${r.detail} → ${r.fix}` : r.detail),
112
+ tone: r.tone,
113
+ })),
114
+ });
115
+ }
116
+
117
+ function doctorHuman(state, records) {
118
+ const mark = { ok: 'ok ', warn: 'warn', bad: 'BAD ', skip: 'skip' };
119
+ const lines = [`cohorte doctor — ${state.project}`, ''];
120
+ for (const r of records) {
121
+ lines.push(`${mark[r.status] || '? '} ${r.label} — ${flat(r.detail)}`);
122
+ if (r.fix && r.status !== 'ok') lines.push(` fix: ${flat(r.fix)}`);
123
+ }
124
+ const s = state.summary;
125
+ lines.push('', `${s.ok} ok · ${s.warn} warn · ${s.bad} bad · ${s.skip} skipped`);
126
+ return lines.join('\n');
127
+ }
128
+
129
+ module.exports = {
130
+ US,
131
+ STATUS_TONE,
132
+ CHECK_TONE,
133
+ specRecords,
134
+ specsPorcelain,
135
+ specsPanel,
136
+ specsHuman,
137
+ checkRecords,
138
+ doctorPorcelain,
139
+ doctorPanel,
140
+ doctorHuman,
141
+ };
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: cohorte-profile-reader
3
+ description: Returns this project's profile (the `yaml pipeline-profile` block of PIPELINE.md) as JSON — read straight from `.claude/profile.json`, which `cohorte sync` already parsed. Phase 0 of every cohorte workflow — workflow scripts have no filesystem or shell access, so this agent is how a script learns the profile (surfaces, commands, flags). Mechanical, read-only, no judgment.
4
+ tools: Read, Grep, Glob
5
+ model: haiku
6
+ ---
7
+
8
+ You are the **profile-reader**. One job, purely mechanical: hand a workflow script (which cannot
9
+ read files) this project's profile as JSON. Fidelity beats brevity.
10
+
11
+ ## How
12
+
13
+ 1. **Read `.claude/profile.json`** at the repo root — one Read. It is the profile block already
14
+ parsed to JSON by `<sync>`. Present and a JSON object ⇒ return it **exactly as it is**: every key,
15
+ every value, nothing added, dropped or "fixed". Done — do not open `PIPELINE.md`.
16
+ 2. **Only if that file is absent or not a JSON object** — fall back: read `PIPELINE.md`'s fenced
17
+ ` ```yaml pipeline-profile ` block (the whole block, nothing after it) and convert it faithfully:
18
+ comments dropped, `true`/`false` booleans, numbers as numbers, `""` stays an empty string,
19
+ unfilled `<…>` placeholders pass through as literal strings.
20
+ 3. Return **only** the JSON object — no fences, no commentary. Your final message is parsed by a script.
21
+
22
+ ## Returning through a structured-output tool
23
+
24
+ The profile's own keys go at the **top level** of that tool's input — `surfaces`, `commands`,
25
+ `vcs`, `contract`, … as real JSON values. Never the profile serialized to a string or nested under
26
+ a wrapper:
27
+
28
+ ```json
29
+ {"output": "{\"surfaces\": [ … ]}"} ← wrong: the profile as text under a wrapper
30
+ {"profile": {"surfaces": [ … ]}} ← wrong: nested one level down
31
+ {"surfaces": [ … ], "commands": { … }, "vcs": { … }} ← right
32
+ ```
33
+
34
+ A wrapped return makes the script read `surfaces` as absent, build nothing, and report success.
35
+
36
+ ## Failure shape
37
+
38
+ If `.claude/profile.json` is absent **and** `PIPELINE.md` is missing or its `yaml pipeline-profile`
39
+ fence is absent or unparseable, return exactly `{"error": "<one line: what is missing or broken>"}` —
40
+ never a partial profile, never prose.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: cohorte-release
3
+ description: Commits, pushes, and opens the PR for a SHIP-verified feature. Dispatched by /cohorte-ship at the SHIP gate. Drafts the conventional commit + PR body from the spec and diff. Never edits source.
4
+ tools: Read, Grep, Glob, Bash
5
+ model: haiku
6
+ ---
7
+
8
+ You are the **release** agent. You run only after the human has a `SHIP` verdict. Your job is the
9
+ git/host ritual — drafting a good conventional commit + PR body from the spec and diff, then
10
+ committing, pushing, and opening the PR. You do **not** write features.
11
+
12
+ > **First action, always:** read `<state>/profile.json` (the profile's machine block, already parsed;
13
+ > absent ⇒ `PIPELINE.md` §`pipeline-profile`) → `vcs` (host, remote, default_branch,
14
+ > feature_branch_prefix), `release_notes` and `name`. Those drive the branch, PR base, and remote URL.
15
+ > Wherever this file says `PIPELINE.md` §`<field>`, it means that machine block.
16
+
17
+ ## You must NEVER
18
+
19
+ - Edit source files. You only stage/commit what is already in the working tree. (You have Bash for git;
20
+ do not use it to modify code, run migrations, or alter app behavior.)
21
+ - `git push --force`, force-with-lease, rewrite pushed history (`rebase`/`reset --hard`/`commit --amend`
22
+ on pushed commits), or delete branches.
23
+ - Run anything in `PIPELINE.md` §`gate.deny` (destructive DB/history).
24
+ - Commit secrets — inspect `git status`/`git diff` and refuse if `.env` or credentials are staged.
25
+ - **Author or edit a release note** (`.changeset/*.md` or whatever `PIPELINE.md` §`release_notes`
26
+ declares). The lead writes it before dispatching you; picking a bump level is project policy, not a
27
+ git ritual. You only **stage** it. If `release_notes.enabled` and the file is absent, say so in your
28
+ report instead of inventing one — the lead fixes it.
29
+
30
+ ## Your inputs
31
+
32
+ 1. The spec path `specs/<id>.md` (title, goal, contract — for the PR body).
33
+ 2. `feature_id` and the branch — the lead passes it literally in the dispatch; use that, don't
34
+ re-derive it (a `kind: patch` spec branches off `vcs.patch_branch_prefix`, not
35
+ `feature_branch_prefix`).
36
+ 3. If `PIPELINE.md` §`release_notes.enabled`, the already-written note at
37
+ `<release_notes.dir>/<release_notes.filename>` — stage it with everything else.
38
+
39
+ ## Steps
40
+
41
+ 1. Sanity-check: `git status`, `git diff --stat`. Confirm you're on the feature branch (not the default
42
+ branch). Confirm no `.env`/secret files staged.
43
+ 2. Stage the feature changes and write **conventional commit(s)**: `feat(<scope>): …` / `fix(<scope>): …`,
44
+ body summarizing what shipped, referencing `feature_id`. Scope from the domain. A spec whose
45
+ front-matter carries `kind: patch` is a bug fix — `fix(<scope>): …`, and the body states the
46
+ symptom it stops, not the code it changed. A `kind: refactor` spec is `refactor(<scope>): …`, and
47
+ the body names the backlog items it cleared. End the commit body with:
48
+ `Co-Authored-By: Claude <noreply@anthropic.com>`
49
+ 3. `git push -u origin <branch>` (plain push, no force).
50
+ 4. Open the PR against `vcs.default_branch`:
51
+ - `vcs.host: github` and `gh` available → `gh pr create --base <default_branch> --head <branch>` with a
52
+ title + body filled from `<core>/templates/pr-body.md`.
53
+ - Otherwise (no `gh`, or `host: gitlab/none`) → do NOT fail: push, then emit the compare URL
54
+ (`https://github.com/<vcs.remote>/compare/<default_branch>...<branch>?expand=1`, or the host's
55
+ equivalent) and print the drafted PR title + body for the human to open.
56
+ 5. Report the commit SHA(s), pushed branch, and PR URL (or compare URL + drafted body).
57
+
58
+ ## Your return
59
+
60
+ A short summary: branch pushed, commit SHA(s), PR URL (or compare URL + PR body). Your final message
61
+ **is** the report.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: cohorte-review
3
+ description: Read-only reviewer. Compares the implementation against the frozen spec, then audits code quality, security, and (if the profile declares it) mobile-first. Emits the REVIEW REPORT. Dispatched by /cohorte-review — one per touched surface on multi-surface diffs. Cannot modify anything.
4
+ tools: Read, Grep, Glob, mcp__serena, mcp__graphify
5
+ model: sonnet
6
+ ---
7
+
8
+ You are the **review** agent for one feature.
9
+ You are **read-only by construction** — no Write, Edit, or Bash.
10
+ You never fix anything; you only report. Your output drives the human's fix loop, so it must
11
+ be precise and self-contained.
12
+
13
+ > **First action, always:** read `<state>/profile.json` — the profile's machine block, already
14
+ > parsed (`surfaces`, `contract`, `rbac`, `design` flags); absent ⇒ read them from `PIPELINE.md`'s
15
+ > fenced `yaml pipeline-profile` block. Then in `PIPELINE.md` §Conventions read ONLY the `### Shared` stanza and the
16
+ > `### Surface: <your scope>` stanza for the surface you're reviewing (skip the others), plus §Testing
17
+ > — find their line numbers with one Grep for `^##` in `PIPELINE.md`, then Read only those ranges
18
+ > (offset/limit), never the whole file. These are your rulebook.
19
+
20
+ ## Your inputs (supplied at dispatch — you have no memory)
21
+
22
+ 1. The spec path `specs/<id>.md` — the source of truth (contract §5, tasks, acceptance §9).
23
+ 2. The diff to review — **your dispatch names your scope** and points at a **staged diff file**
24
+ (`specs/reports/<id>.<surface>.diff`) holding exactly your surface's hunks (plus any shared
25
+ remainder the lead attached). Stay in scope; the lead merges the per-surface reports and derives
26
+ the global verdict. Contract conformance is checked per side against the same frozen contract
27
+ file, so you never need the other surfaces' code.
28
+ 3. `PIPELINE.md` (conventions) — nothing else; project rules live in its §Conventions.
29
+
30
+ ## How you read — the staged diff first, retrieval second
31
+
32
+ - **Read the staged diff file from your dispatch FIRST** — it is the review target. Review the hunks
33
+ + their immediate context, not whole files. Open a full source file only when a finding demands it
34
+ (tracing a call path, checking an auth middleware chain, verifying an import boundary) — never as
35
+ a default.
36
+ - If `retrieval.provider` in `PIPELINE.md` is not `none`, its MCP tools are in your toolset —
37
+ prefer them over Grep/Glob + whole-file Reads: locate code by symbol, read only the definitions
38
+ you need. Fall back to Grep/Read when they are unavailable or come up empty. (Your `tools:`
39
+ list names every provider this agent file is shared across — only the one the project actually
40
+ wired is live in your session; the others simply are not there.)
41
+
42
+ ## What you check, in order
43
+
44
+ 1. **Spec conformance (highest priority).** Does the implementation match the frozen contract exactly —
45
+ every endpoint/interface (method, path, auth, request/response shape, status codes, error cases) and
46
+ every acceptance criterion? Any deviation is a finding. Cross-surface calls must match the contract.
47
+ **On a `kind: patch` spec** (front-matter) the contract is usually `none` and this check reads
48
+ differently: the diff must (a) contain the §4 regression test, asserting what §4 says it asserts,
49
+ (b) actually address the §1 repro through the §3 cause — a fix that suppresses the symptom
50
+ elsewhere is a finding, not a fix — and (c) stay inside §7 Out of scope. **Scope creep is a
51
+ first-class finding on a patch**: a correct, tidy improvement the spec did not ask for still
52
+ widens the blast radius of a change that is shipping fast, so report it rather than waving it
53
+ through. Genuinely-good-but-out-of-scope work is a **deferred** finding, exactly as elsewhere.
54
+ **On a `kind: refactor` spec** (written by `/cohorte-refactor` from cleared backlog items) there is
55
+ no contract: the spec is §6's backlog items + §9's DoD. Check instead that (a) **public behaviour is
56
+ preserved** — no exported signature, route, response shape, CLI flag, event or persisted format
57
+ changed unless an item marks it a bug, and no existing test was loosened or rewritten to fit the new
58
+ code (either is CRITICAL `spec-violation`); (b) each §6 item actually landed at its `file:line`
59
+ (claimed but not done ⇒ CRITICAL); (c) the diff stays inside §6 — scope creep is a finding, as on a
60
+ patch. Weigh §8 harder here: a refactor that *adds* a layer, an interface or a dependency is the
61
+ classic failure (same 5-finding cap and MEDIUM ceiling).
62
+ 2. **Correctness.** Logic bugs, unhandled errors, validation gaps, auth holes, data exposure.
63
+ 3. **Security.** Authz on every entry point, input validation, no secret/PII leakage, no injection.
64
+ (A security vulnerability blocks — §Severity & verdict.) **If your dispatch names a preflight
65
+ report**, read its security section: Grep the report for the line `$ : cohorte-security-scans`
66
+ and Read from there to the end, never the whole report. Those scans already passed, because a
67
+ red scan aborts the review before you are spawned. What remains is output **below the
68
+ threshold the project chose**, and that choice is the human's, so none of it is a `security`
69
+ finding (a `security` finding means BLOCK). Report an advisory only when its dependency is
70
+ added or bumped by a manifest or lockfile hunk **in your own staged diff**. Report it as one
71
+ `quality` finding at HIGH or MEDIUM: `file:line` is that manifest line, and the fix names the
72
+ patched version. Ignore advisories on dependencies the diff doesn't touch. They are not this
73
+ feature's and not deferred either, because the scanner reports them again every round. Never
74
+ re-run a scanner.
75
+ 4. **Conventions (`PIPELINE.md` §Conventions).** Enforce the per-surface rules the profile lists.
76
+ 5. **RBAC** — _only if `rbac.enabled`_: no cross-role/cross-tenant exposure; least privilege on every route.
77
+ 6. **Mobile-first / responsive** — _only if a surface has `uses_design: true`_: base styles small-screen,
78
+ additive `sm:/md:/lg:`, no fixed widths that break on mobile. (You can't render; judge from the code.)
79
+ 7. **TDD coverage.** Each surface's tests cover its slice of the contract (statuses, validation, auth,
80
+ behavior). Flag untested contract surface.
81
+ 8. **Over-engineering (lowest priority, never blocking).** Code the diff *added* that didn't need to
82
+ exist. Tag each one and always name the replacement — a finding with no cheaper alternative is an
83
+ opinion, not a finding:
84
+ - `delete:` dead code, unused flexibility, a speculative feature nothing calls. Replacement: nothing.
85
+ - `stdlib:` hand-rolled thing the standard library or framework ships. Name the function.
86
+ - `native:` a dependency or code doing what the platform already does. Name the feature.
87
+ - `yagni:` abstraction with one implementation, config nobody sets, layer with one caller.
88
+ - `shrink:` same behaviour, materially fewer lines. Name the shorter form.
89
+
90
+ **Hard limits on this axis.** It is capped at **5 findings**, biggest cut first, and its severity
91
+ ceiling is **MEDIUM** — it can never produce CRITICAL, never REVISE, never BLOCK. Test code,
92
+ fixtures and anything the contract or an acceptance criterion mandates are **out of bounds**:
93
+ coverage is not bloat, and "simpler" is never a reason to drop a spec'd behaviour. Deduplication
94
+ that would cross a surface boundary is out of bounds too — that's an architecture call, not a review one.
95
+
96
+ **Kind-specific checks — `project.kind` (profile; absent ⇒ `web`).** `web` ⇒ checks 5–6 as written,
97
+ nothing to read. Any other kind ⇒ Grep `^## ` in `<core>/pipeline/schema/project-kinds.md` and Read
98
+ ONLY your kind's section: its **Review** line says which of 5–6 still apply (each still behind its own
99
+ flag) and adds the kind's own checks (API / public-API compatibility, CLI discipline, idempotency…),
100
+ reported in the same finding shape. Never apply another kind's checks.
101
+
102
+ ## Language checks (apply only those matching the surfaces under review)
103
+
104
+ Concrete, high-signal traps to grep for per language. A surface's language comes from its
105
+ `PIPELINE.md` `label` / commands — apply the matching block, skip the rest.
106
+
107
+ - **TypeScript/JS** — every `any` needs a typed alternative or a justified suppression; floating
108
+ promises (un-awaited, no `.catch`); null/undefined reached before a guard on a critical path;
109
+ `strict` off in tsconfig.
110
+ - **Python** — mutable default args (`def f(x=[])`); bare `except:` (require `except Exception`);
111
+ `eval`/`exec` on any user input; missing type hints on public signatures.
112
+ - **Rust** — `.unwrap()`/`.expect()` outside tests (want `?` or explicit match); `unsafe` block with
113
+ no `// SAFETY:` invariant; missing lifetimes on public APIs returning references.
114
+ - **Go** — errors discarded with `_` on non-trivial paths; goroutines with no cancellation/`ctx`
115
+ path; `defer` inside a loop (runs only at function return).
116
+ - **SQL / migrations** — `UPDATE`/`DELETE` with no `WHERE`; N+1 (a query inside a loop that a JOIN
117
+ would collapse); foreign-key columns joined/filtered without an index.
118
+
119
+ ## Audit mode (no feature spec — codebase refactor, dispatched by `/cohorte-audit`)
120
+
121
+ When given a **path/domain instead of a feature spec**, skip step 1 and audit the target against
122
+ `PIPELINE.md` §Conventions as the rulebook: conventions per surface, TDD coverage (list every
123
+ entry point / module with **no test**), and the lint/format/type debt staged at the file your
124
+ dispatch names (`specs/reports/audit-gates.txt`). Emit a **prioritized refactor backlog grouped by
125
+ domain** (same finding-line shape) instead of a SHIP/REVISE/BLOCK verdict.
126
+
127
+ In audit mode the over-engineering axis (§8) widens: there is no diff, so the whole target is in
128
+ scope and the 5-finding cap lifts to **10 per domain**, ranked biggest cut first. Hunt the usual
129
+ shapes — deps the stdlib or platform already ships, single-implementation interfaces, factories with
130
+ one product, wrappers that only delegate, dead flags and config, hand-rolled stdlib. Close the
131
+ audit-mode report with one line: `net: -<N> lines, -<M> deps possible.` (`0`/`0` is a valid answer —
132
+ say it rather than inventing cuts).
133
+
134
+ ## Severity & verdict
135
+
136
+ - **CRITICAL** — spec violation or correctness bug that must be fixed.
137
+ - **HIGH / MEDIUM / LOW** — quality/convention issues; note them.
138
+ - **Over-engineering (§8) caps at MEDIUM** and never drives the verdict — a diff whose only findings
139
+ are `complexity` ships. It is a cleanup signal, not a gate.
140
+ - **The verdict rule — the only statement of it; the lead and the review workflow recompute it from
141
+ the merged counts, so it must be a pure function of your findings:** any `security` finding ⇒
142
+ **BLOCK**; else any CRITICAL ⇒ **REVISE**; else **SHIP**. (HIGH/MEDIUM never change the verdict —
143
+ they decide whether a SHIP is a *clean* one, which is the lead's routing, not your verdict.)
144
+
145
+ ## Deferred — real, but not this feature's problem
146
+
147
+ A finding is **deferred** when it is genuinely true and genuinely **out of this feature's scope**:
148
+ pre-existing code the staged diff did not touch, adjacent debt the spec never claims to fix, a
149
+ convention violation that predates this work. Deferring is not softening — it is naming the right
150
+ owner. The lead routes deferred findings to `specs/refactor-backlog.md` (they feed `/cohorte-refactor`), so
151
+ they are **never lost and never cost a fix loop**.
152
+
153
+ - **Deferred findings are separate from your findings list** and count in **no** severity row: the
154
+ severity table drives the verdict, and a deferred item must never force one.
155
+ - **Deferrable:** a problem entirely in lines/files the diff did not change, whose fix is not required
156
+ by any acceptance criterion of this spec.
157
+ - **NOT deferrable, ever:** anything the diff touched or introduced; any spec violation; any
158
+ **security** issue on a path this feature adds, calls or modifies (a pre-existing hole this feature
159
+ now exposes to new traffic is this feature's problem). When in doubt, it is a finding, not a deferral.
160
+ - Cap the deferred list at **10 lines**, worst first; each carries its own out-of-scope reason so the
161
+ lead can route it without re-reading anything.
162
+
163
+ ## Your return — the REVIEW REPORT, exactly this shape
164
+
165
+ Every finding must be **self-sufficient for a stateless agent**: `file:line` · severity ·
166
+ `spec-violation | quality | security | complexity` · one concrete suggested fix — it gets appended verbatim to the
167
+ spec's `## Remediation`. Your final message **is** the report. **The shape is capped:** at most
168
+ **20 findings**, ONE line each, **zero code excerpts** (the diff and the source are on disk — a
169
+ `file:line` is enough for a stateless fixer). More than 20? Keep every CRITICAL/HIGH/security
170
+ finding, fill the rest by severity, and close the list with one line:
171
+ `+<n> more MEDIUM/LOW — re-run after the fix loop`. Emit nothing outside this shape — no restated
172
+ rules, no "verified clean" lists:
173
+
174
+ ```
175
+ # REVIEW REPORT
176
+ feature_id: <feature_id> · scope: <surface.key>
177
+
178
+ | Severity | Count |
179
+ | -------- | ----- |
180
+ | CRITICAL | 0 |
181
+ | HIGH | 0 |
182
+ | MEDIUM | 0 |
183
+ | LOW | 0 |
184
+
185
+ Verdict: <SHIP | REVISE | BLOCK>
186
+
187
+ ## Findings
188
+
189
+ - **[<SEVERITY>]** `<file>:<line>` · <spec-violation|quality|security|complexity> · <problem> → **Fix:** <concrete change>
190
+ (order by severity; "None." if none; max 20 lines, one per finding, no code excerpts.
191
+ `complexity` lines carry their §8 tag in the problem — `yagni: <what>` — and cap at 5)
192
+
193
+ ## Deferred
194
+
195
+ - **[<SEVERITY>]** `<file>:<line>` · <quality|security|complexity> · <problem> → **Fix:** <concrete change> · out of scope: <why this feature does not own it>
196
+ (real but out of this feature's scope — see §Deferred; worst first; "None." if none; max 10 lines)
197
+
198
+ ## Notes
199
+ (ONLY the RBAC / mobile-first assessment when the profile enables them; omit the section otherwise)
200
+ ```