cohorte 3.0.0 → 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.
- package/CHANGELOG.md +105 -0
- package/README.md +16 -10
- package/bin/cli.js +2 -1
- package/core/agents/cohorte-profile-reader.md +21 -31
- package/core/agents/cohorte-release.md +6 -3
- package/core/agents/cohorte-review.md +31 -5
- package/core/agents/implementer.template.md +13 -5
- package/core/commands/cohorte-audit.md +10 -3
- package/core/commands/cohorte-brainstorm.md +2 -2
- package/core/commands/cohorte-build.md +17 -10
- package/core/commands/cohorte-doctor.md +11 -9
- package/core/commands/cohorte-fix.md +2 -2
- package/core/commands/cohorte-fleet.md +1 -1
- package/core/commands/cohorte-init-pipeline.md +2 -2
- package/core/commands/cohorte-intake.md +3 -3
- package/core/commands/cohorte-patch.md +1 -1
- package/core/commands/cohorte-refactor.md +73 -8
- package/core/commands/cohorte-retro.md +2 -2
- package/core/commands/cohorte-revert.md +104 -0
- package/core/commands/cohorte-review.md +29 -14
- package/core/commands/cohorte-ship.md +17 -5
- package/core/commands/cohorte-spec.md +11 -2
- package/core/commands/cohorte-update-pipeline.md +12 -8
- package/core/commands/cohorte-verify.md +106 -0
- package/core/hooks/gate.py +326 -21
- package/core/templates/patch.template.md +11 -2
- package/core/templates/spec.template.md +23 -2
- package/core/templates/steps/init-pipeline/01-detect-stack.md +14 -5
- package/core/templates/steps/init-pipeline/02-interview-gaps.md +26 -3
- package/core/templates/steps/init-pipeline/03-draft-profile.md +2 -1
- package/core/templates/steps/init-pipeline/04-write-render.md +16 -12
- package/core/templates/steps/init-pipeline/05-report.md +1 -1
- package/core/workflows/audit.js +9 -4
- package/core/workflows/loop.js +15 -10
- package/core/workflows/refactor.js +116 -9
- package/core/workflows/review.js +24 -10
- package/lib/doctor.js +37 -3
- package/lib/install.js +11 -2
- package/lib/project.js +45 -8
- package/lib/render.js +3 -3
- package/lib/yaml.js +10 -1
- package/package.json +2 -2
- package/profile/PIPELINE.template.md +39 -1
- package/profile/SCHEMA.md +27 -746
- package/profile/cohorte.config.template.yaml +1 -1
- package/profile/schema/dead-agents.md +29 -0
- package/profile/schema/decisions.md +23 -0
- package/profile/schema/deferred.md +22 -0
- package/profile/schema/feature-diff.md +20 -0
- package/profile/schema/kanban.md +95 -0
- package/profile/schema/metrics.md +23 -0
- package/profile/schema/output-discipline.md +21 -0
- package/profile/schema/preflight.md +81 -0
- package/profile/schema/profile-block.md +103 -0
- package/profile/schema/project-kinds.md +89 -0
- package/profile/schema/readiness.md +17 -0
- package/profile/schema/reconcile.md +64 -0
- package/profile/schema/release-notes.md +29 -0
- package/profile/schema/rendering.md +48 -0
- package/profile/schema/retrieval.md +58 -0
- package/profile/schema/spec-status.md +79 -0
- package/profile/schema/specialization.md +41 -0
- package/profile/schema/verify.md +115 -0
- package/profile/schema/workflows.md +78 -0
- package/scripts/kanban-move.sh +45 -3
- package/scripts/verify-run.sh +509 -0
package/core/workflows/review.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Invoke with args = {feature: "<feature_id>"} (or the bare feature id string).
|
|
5
5
|
// Requires Claude Code >= 2.1.154 with workflows enabled — /cohorte-doctor reports this.
|
|
6
6
|
//
|
|
7
|
-
// Shape (
|
|
7
|
+
// Shape (profile/schema/workflows.md): phase 0 reads the profile through the
|
|
8
8
|
// profile-reader agent (scripts have no filesystem or shell), the deterministic
|
|
9
9
|
// preflight aborts while red (zero reviewers spawned), the diff is staged ONCE
|
|
10
10
|
// per touched surface, one reviewer runs per surface in parallel, an adversarial
|
|
@@ -44,7 +44,7 @@ const ARGS = (() => {
|
|
|
44
44
|
})()
|
|
45
45
|
// Approximate cost of this run from the runtime's own output-token counter — the one
|
|
46
46
|
// figure the conversational path cannot record (a lead cannot read a subagent's token
|
|
47
|
-
// count;
|
|
47
|
+
// count; profile/schema/metrics.md). Sampled at start, delta stamped into the metrics line.
|
|
48
48
|
const spentNow = () => {
|
|
49
49
|
try {
|
|
50
50
|
const v = (budget && typeof budget.spent === 'function') ? budget.spent() : 0
|
|
@@ -183,7 +183,7 @@ const VERDICT = {
|
|
|
183
183
|
// ── Phase 0 — profile ────────────────────────────────────────────────────────
|
|
184
184
|
phase('Profile')
|
|
185
185
|
const profile = unwrapProfile(await agent(
|
|
186
|
-
'Return this project\'s
|
|
186
|
+
'Return this project\'s profile (the `yaml pipeline-profile` block — `.claude/profile.json`, else PIPELINE.md) as JSON, per your instructions.',
|
|
187
187
|
{ agentType: 'cohorte-profile-reader', label: 'profile', schema: PROFILE, effort: 'low' },
|
|
188
188
|
))
|
|
189
189
|
if (!profile || profile.error) {
|
|
@@ -199,16 +199,28 @@ if (!surfaces.length) {
|
|
|
199
199
|
return { verdict: 'ABORTED', aborted: 'profile', reason: 'profile has no surfaces — nothing would be reviewed. the `yaml pipeline-profile` block in PIPELINE.md is empty or unparseable, or the profile-reader mis-returned; run /cohorte-doctor' }
|
|
200
200
|
}
|
|
201
201
|
const quiet = (q, full) => (q && !String(q).startsWith('<') ? q : full ? `${full} 2>&1 | tail -40` : '')
|
|
202
|
+
// commands.security (profile/schema/preflight.md): dependency audits and a secret scan of the
|
|
203
|
+
// feature's own diff, run AFTER typecheck/lint/tests by the same script, into the same report.
|
|
204
|
+
// A no-op marker opens their section so a reviewer (no Bash) can Grep for it and Read from there.
|
|
205
|
+
const SECURITY_MARKER = ': cohorte-security-scans'
|
|
206
|
+
const security = (Array.isArray(cmds.security) ? cmds.security : [cmds.security])
|
|
207
|
+
.filter(c => typeof c === 'string' && c.trim() && !c.trim().startsWith('<'))
|
|
202
208
|
const checks = [cmds.typecheck, quiet(cmds.lint_quiet, cmds.lint), quiet(cmds.test_quiet, cmds.test)]
|
|
203
209
|
.filter(c => c && !String(c).startsWith('<'))
|
|
210
|
+
.concat(security.length ? [SECURITY_MARKER, ...security] : [])
|
|
211
|
+
// Each check is one argument of the preflight call. Double quotes would let the CALLING shell
|
|
212
|
+
// expand a `$VAR` meant for the check's own `sh -c` (the secret-scan recipe sets and reads one),
|
|
213
|
+
// so a command with shell syntax in it is single-quoted instead.
|
|
214
|
+
const shq = c => /[$`\\]/.test(c) ? `'${String(c).replace(/'/g, "'\\''")}'` : JSON.stringify(c)
|
|
215
|
+
const preflightReport = `specs/reports/${feature}.preflight.txt`
|
|
204
216
|
|
|
205
217
|
// ── Phase 1 — deterministic preflight (abort while red, zero reviewers) ─────
|
|
206
218
|
phase('Preflight')
|
|
207
219
|
const pre = await agent(
|
|
208
220
|
`Run the cohorte deterministic pre-flight for feature ${feature} in ONE Bash call, starting it with ` +
|
|
209
221
|
'`date +%s` (return that number as `epoch` — the run\'s wall-clock origin for the metrics line):\n' +
|
|
210
|
-
`<core>/pipeline/scripts/preflight.sh
|
|
211
|
-
checks.map(
|
|
222
|
+
`<core>/pipeline/scripts/preflight.sh ${preflightReport} ` +
|
|
223
|
+
checks.map(shq).join(' ') + '\n' +
|
|
212
224
|
'(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte". ' +
|
|
213
225
|
'Script absent: run the quoted commands yourself, each appended to the same report file, stopping at the first failure.) ' +
|
|
214
226
|
'Return pass=true only on a fully green run. On failure set pass=false, put the raw last 40 lines of the report ' +
|
|
@@ -221,7 +233,8 @@ const pre = await agent(
|
|
|
221
233
|
if (!pre || !pre.pass) {
|
|
222
234
|
return {
|
|
223
235
|
verdict: 'ABORTED', aborted: 'preflight',
|
|
224
|
-
reason: 'preflight red — fix the mechanical failures (or run /cohorte-fix) before any review; no reviewer was spawned'
|
|
236
|
+
reason: 'preflight red — fix the mechanical failures (or run /cohorte-fix) before any review; no reviewer was spawned' +
|
|
237
|
+
(security.length ? ' (commands.security counts: a dependency advisory at its threshold, or a secret in the feature diff, is red too)' : ''),
|
|
225
238
|
failures: (pre && pre.tail) || 'preflight agent returned nothing',
|
|
226
239
|
}
|
|
227
240
|
}
|
|
@@ -229,7 +242,7 @@ if (!pre || !pre.pass) {
|
|
|
229
242
|
// ── Phase 2 — stage the diff once ────────────────────────────────────────────
|
|
230
243
|
phase('Stage')
|
|
231
244
|
const surfaceList = surfaces.map(s => `${s.key} → ${s.path}`).join(' · ') || '(none declared)'
|
|
232
|
-
// Every diff goes through feature-diff.sh (
|
|
245
|
+
// Every diff goes through feature-diff.sh (profile/schema/feature-diff.md): a throwaway index so
|
|
233
246
|
// UNTRACKED files are reviewed (feature work is uncommitted until ship — a bare `git diff`
|
|
234
247
|
// dropped every new module, and an adds-only feature staged an empty diff that scored SHIP),
|
|
235
248
|
// against the MERGE-BASE with the default branch (its tip blamed the feature for every file
|
|
@@ -293,8 +306,9 @@ const reviewPrompt = s =>
|
|
|
293
306
|
'one line each, no code excerpts). Put anything real but OUT of this feature\'s scope in `deferred` ' +
|
|
294
307
|
'(max 10, each with its out-of-scope reason) per your §Deferred rules — never in `findings`. — Variable slots: ' +
|
|
295
308
|
`feature ${feature} · scope: the ${s.key} surface only · spec: specs/${feature}.md · ` +
|
|
296
|
-
`staged diff: ${s.diff} · changed files: ${s.files.join(', ')}`
|
|
297
|
-
|
|
309
|
+
`staged diff: ${s.diff} · changed files: ${s.files.join(', ')}` +
|
|
310
|
+
(security.length ? ` · preflight report: ${preflightReport} (security section from the line \`$ ${SECURITY_MARKER}\`)` : '')
|
|
311
|
+
// profile/schema/dead-agents.md, the same rule as the build: a silent reviewer is retried ONCE,
|
|
298
312
|
// byte-identical (the staged diff is already on disk — the retry costs one agent); only a
|
|
299
313
|
// surface silent twice is `unreviewed`.
|
|
300
314
|
const reviewOnce = (s, label) =>
|
|
@@ -426,7 +440,7 @@ const staging = await agent(
|
|
|
426
440
|
`${verdictJson}\n` +
|
|
427
441
|
// Per-surface verdicts (not the merged one stamped on every row — one BLOCK used to
|
|
428
442
|
// mark ALL surfaces failed), and dead reviewers logged as "dead"
|
|
429
|
-
// per
|
|
443
|
+
// per profile/schema/dead-agents.md — an incomplete batch is the batch worth recording.
|
|
430
444
|
`3. Append one line to $(dirname "$(git rev-parse --git-common-dir)")/.claude/pipeline-metrics.jsonl: ` +
|
|
431
445
|
// seconds: the clock lives in Bash (scripts have none) — elapsed since the preflight's
|
|
432
446
|
// `date +%s`. No epoch came back ⇒ the field is OMITTED, never a made-up 0.
|
package/lib/doctor.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const { spawnSync } = require('child_process');
|
|
11
|
-
const { parseProfileBlock } = require('./yaml');
|
|
11
|
+
const { parseProfileBlock, profileJsonText } = require('./yaml');
|
|
12
12
|
const { versions } = require('./versions');
|
|
13
13
|
|
|
14
14
|
// Shipped (non-surface) agent names. 3.x installs them machine-wide; a 2.x bundled repo has
|
|
@@ -19,8 +19,9 @@ const FIXED_AGENTS = new Set([
|
|
|
19
19
|
]);
|
|
20
20
|
const WORKFLOWS = ['cohorte-review.js', 'cohorte-audit.js', 'cohorte-refactor.js', 'cohorte-loop.js'];
|
|
21
21
|
const GATE_FILE = path.join('.claude', 'hooks', 'cohorte-gate.py');
|
|
22
|
+
const PROFILE_JSON = path.join('.claude', 'profile.json');
|
|
22
23
|
|
|
23
|
-
// The spec lifecycle (
|
|
24
|
+
// The spec lifecycle (profile/schema/spec-status.md). `in-progress` and `blocked` stay valid after
|
|
24
25
|
// /cohorte-loop was retired in 2.2.0: specs in existing repos carry them, and an external driver
|
|
25
26
|
// still needs somewhere to record "a round is under way" / "a round gave up".
|
|
26
27
|
const VALID_STATUS = ['draft', 'frozen', 'in-progress', 'in-review', 'shipped', 'merged', 'blocked', 'abandoned'];
|
|
@@ -105,6 +106,38 @@ function checkProfile(profile, hasPipelineMd) {
|
|
|
105
106
|
n ? undefined : 'add at least one surface to §surfaces');
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
// `.claude/profile.json` is the parsed machine block agents read instead of the whole PIPELINE.md.
|
|
110
|
+
// The CONTENT decides freshness — compared byte for byte with what `cohorte sync` would write now,
|
|
111
|
+
// through the same serializer. Modification times alone cannot: git does not preserve them (a fresh
|
|
112
|
+
// clone can show the JSON "older" than PIPELINE.md while identical), and sync rightly leaves an
|
|
113
|
+
// identical file alone after a prose-only edit. mtime only names the likely cause of a mismatch.
|
|
114
|
+
function checkProfileJson(pipelineMd, projectRoot) {
|
|
115
|
+
const want = pipelineMd != null ? profileJsonText(pipelineMd) : null;
|
|
116
|
+
if (!want) return mk('profile-json', 'Profile cache (.claude/profile.json)', 'skip', 'no parseable profile block to cache');
|
|
117
|
+
const file = path.join(projectRoot, PROFILE_JSON);
|
|
118
|
+
const have = readText(file);
|
|
119
|
+
if (have == null) {
|
|
120
|
+
return mk('profile-json', 'Profile cache (.claude/profile.json)', 'warn',
|
|
121
|
+
'missing — agents fall back to parsing PIPELINE.md themselves (slower, costlier)',
|
|
122
|
+
'cohorte sync (writes .claude/profile.json — commit it)');
|
|
123
|
+
}
|
|
124
|
+
// A Windows checkout with core.autocrlf rewrites line endings: that is not staleness.
|
|
125
|
+
if (have.replace(/\r\n/g, '\n') !== want) {
|
|
126
|
+
let older = false;
|
|
127
|
+
try { older = fs.statSync(file).mtimeMs < fs.statSync(path.join(projectRoot, 'PIPELINE.md')).mtimeMs; } catch { /* unknown */ }
|
|
128
|
+
return mk('profile-json', 'Profile cache (.claude/profile.json)', 'warn',
|
|
129
|
+
older ? 'stale — PIPELINE.md was edited after the last sync; agents read the old machine block'
|
|
130
|
+
: 'differs from a fresh parse of PIPELINE.md (hand-edited?) — agents read the wrong machine block',
|
|
131
|
+
'cohorte sync (regenerates .claude/profile.json — commit it)');
|
|
132
|
+
}
|
|
133
|
+
if (isTracked(projectRoot, PROFILE_JSON) === false) {
|
|
134
|
+
return mk('profile-json', 'Profile cache (.claude/profile.json)', 'warn',
|
|
135
|
+
'fresh, but not committed — teammates\' agents fall back to parsing PIPELINE.md',
|
|
136
|
+
'git add .claude/profile.json && git commit');
|
|
137
|
+
}
|
|
138
|
+
return mk('profile-json', 'Profile cache (.claude/profile.json)', 'ok', 'matches PIPELINE.md');
|
|
139
|
+
}
|
|
140
|
+
|
|
108
141
|
function checkAgents(profile, projectRoot, globalDir) {
|
|
109
142
|
if (!profile || !(profile.surfaces || []).length) {
|
|
110
143
|
return mk('agents', 'Surfaces ↔ agents', 'skip', 'no surfaces to reconcile');
|
|
@@ -309,7 +342,7 @@ function checkHooks(projectRoot, globalDir) {
|
|
|
309
342
|
: 'cohorte sync (copies and registers the project gate — then commit .claude/)';
|
|
310
343
|
return mk('hooks', 'Gate hook', status, problems.join(' · '), fix);
|
|
311
344
|
}
|
|
312
|
-
return mk('hooks', 'Gate hook', 'ok', `registered once (${shell[0].matcher} + Write|Edit|MultiEdit), committed`);
|
|
345
|
+
return mk('hooks', 'Gate hook', 'ok', `registered once (${shell[0].matcher} + Write|Edit|MultiEdit|NotebookEdit), committed`);
|
|
313
346
|
}
|
|
314
347
|
|
|
315
348
|
function checkRetrieval(profile, projectRoot) {
|
|
@@ -435,6 +468,7 @@ async function state({ projectRoot, globalDir, cliVersion, offline }) {
|
|
|
435
468
|
const checks = [
|
|
436
469
|
checkCore(v, isProject),
|
|
437
470
|
checkProfile(profile, pipelineMd != null),
|
|
471
|
+
checkProfileJson(pipelineMd, projectRoot),
|
|
438
472
|
checkAgents(profile, projectRoot, globalDir),
|
|
439
473
|
checkGate(profile, projectRoot),
|
|
440
474
|
checkLocalArtifacts(projectRoot, ['.claude']),
|
package/lib/install.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// commands/cohorte-*.md the 16 slash commands
|
|
6
6
|
// agents/cohorte-*.md cohorte-review, cohorte-release, cohorte-profile-reader
|
|
7
7
|
// workflows/cohorte-*.js review / audit / refactor / loop
|
|
8
|
-
// cohorte/ the generic core: pipeline/, templates/, hooks/gate.py, lib/project.js
|
|
8
|
+
// cohorte/ the generic core: pipeline/, templates/, hooks/gate.py, lib/{project,yaml}.js
|
|
9
9
|
// cohorte/manifest.json every file above, with the hash it was written with
|
|
10
10
|
// cohorte.config.yaml YOUR config (seeded once, never in the manifest)
|
|
11
11
|
//
|
|
@@ -81,6 +81,11 @@ function desiredFiles(globalDir) {
|
|
|
81
81
|
for (const f of ['PIPELINE.template.md', 'SCHEMA.md', 'cohorte.config.template.yaml']) {
|
|
82
82
|
put(path.join('cohorte', 'pipeline', f), fs.readFileSync(path.join(pkgRoot, 'profile', f)));
|
|
83
83
|
}
|
|
84
|
+
// The rulebook, one file per topic: SCHEMA.md is only its index, and each prompt cites the
|
|
85
|
+
// exact `<core>/pipeline/schema/<file>.md` it needs — so no command loads all of it.
|
|
86
|
+
for (const f of fs.readdirSync(path.join(pkgRoot, 'profile', 'schema')).sort()) {
|
|
87
|
+
if (f.endsWith('.md')) put(path.join('cohorte', 'pipeline', 'schema', f), fs.readFileSync(path.join(pkgRoot, 'profile', 'schema', f)));
|
|
88
|
+
}
|
|
84
89
|
// A `<x>.sh` with an `<x>.sh.template` sibling is rendered per project by
|
|
85
90
|
// /cohorte-init-pipeline, so only the template ships; every other `.sh` is executable.
|
|
86
91
|
const scripts = fs.readdirSync(path.join(pkgRoot, 'scripts'));
|
|
@@ -94,6 +99,8 @@ function desiredFiles(globalDir) {
|
|
|
94
99
|
put(path.join('cohorte', 'pipeline', 'CHANGELOG.md'), fs.readFileSync(path.join(pkgRoot, 'CHANGELOG.md')));
|
|
95
100
|
put(path.join('cohorte', 'pipeline', 'VERSION'), VERSION + '\n');
|
|
96
101
|
put(path.join('cohorte', 'lib', 'project.js'), fs.readFileSync(path.join(pkgRoot, 'lib', 'project.js')));
|
|
102
|
+
// project.js requires its sibling yaml.js (lazily) to write .claude/profile.json.
|
|
103
|
+
put(path.join('cohorte', 'lib', 'yaml.js'), fs.readFileSync(path.join(pkgRoot, 'lib', 'yaml.js')));
|
|
97
104
|
return files;
|
|
98
105
|
}
|
|
99
106
|
|
|
@@ -357,7 +364,9 @@ function uninstall(globalDir, { purge = false } = {}) {
|
|
|
357
364
|
}
|
|
358
365
|
fs.rmSync(path.join(globalDir, MANIFEST), { force: true });
|
|
359
366
|
pruneEmpty(path.join(globalDir, 'cohorte'));
|
|
360
|
-
|
|
367
|
+
// Empty dirs install created (commands/, agents/, workflows/): harmless to remove, and left
|
|
368
|
+
// behind they make an uninstall look incomplete.
|
|
369
|
+
for (const d of ['workflows', 'commands', 'agents']) pruneEmpty(path.join(globalDir, d));
|
|
361
370
|
if (removed) report.push(`removed ${removed} installed file(s)`);
|
|
362
371
|
const leftovers = legacyGlobalCandidates(globalDir);
|
|
363
372
|
if (leftovers.length) warnings.push(`2.x files still present (run \`cohorte update\` first to migrate them, then uninstall): ${leftovers.slice(0, 5).join(', ')}${leftovers.length > 5 ? '…' : ''}`);
|
package/lib/project.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
// cohorte — wire ONE project, deterministically.
|
|
4
4
|
//
|
|
5
|
-
// node <core>/lib/project.js sync [root] # copy the gate, register its hook, pointer, .gitignore
|
|
5
|
+
// node <core>/lib/project.js sync [root] # copy the gate, register its hook, pointer, .gitignore,
|
|
6
|
+
// # and .claude/profile.json (the parsed profile block)
|
|
6
7
|
// node <core>/lib/project.js unsync [root] # undo exactly what sync wrote
|
|
7
8
|
//
|
|
8
9
|
// Everything that describes a project lives in that project and is committed with it:
|
|
@@ -13,20 +14,25 @@
|
|
|
13
14
|
//
|
|
14
15
|
// This file is SELF-CONTAINED on purpose: the installer copies it to
|
|
15
16
|
// `~/.claude/cohorte/lib/project.js`, and `/cohorte-init-pipeline` runs it from there, so it
|
|
16
|
-
// must work without the `cohorte` binary on PATH (npx users)
|
|
17
|
+
// must work without the `cohorte` binary on PATH (npx users). Its one sibling is `yaml.js` (the
|
|
18
|
+
// installer ships it next to this file), the same parser `cohorte doctor` uses — so sync and
|
|
19
|
+
// doctor cannot disagree about the profile. It is required lazily: a core missing it still wires
|
|
20
|
+
// the gate, and only `.claude/profile.json` is skipped, with a note saying why.
|
|
17
21
|
|
|
18
22
|
const fs = require('fs');
|
|
19
23
|
const path = require('path');
|
|
20
24
|
const { spawnSync } = require('child_process');
|
|
21
25
|
|
|
22
26
|
const GATE_FILE = path.join('.claude', 'hooks', 'cohorte-gate.py');
|
|
27
|
+
const PROFILE_FILE = path.join('.claude', 'profile.json');
|
|
23
28
|
const GATE_COMMAND = 'python3 "$CLAUDE_PROJECT_DIR/.claude/hooks/cohorte-gate.py"';
|
|
24
29
|
const GATE_MATCHER = 'Bash|Task|Agent';
|
|
25
|
-
const EDIT_MATCHER = 'Write|Edit|MultiEdit';
|
|
30
|
+
const EDIT_MATCHER = 'Write|Edit|MultiEdit|NotebookEdit';
|
|
26
31
|
const INSTALL_HINT = 'npm i -g cohorte && cohorte install';
|
|
27
32
|
const IGNORE_LINES = ['.claude/preflight.ok', '.claude/pipeline-metrics.jsonl', 'specs/reports/'];
|
|
28
33
|
const IGNORE_HEADER = '# cohorte — local-only pipeline artifacts (never commit these)';
|
|
29
34
|
const MARKERS = ['Generated by the cohorte adapter', 'Generated by the cohorte installer'];
|
|
35
|
+
const COMMIT_LIST = '.claude/settings.json, .claude/hooks/cohorte-gate.py, .claude/pipeline.json, .claude/profile.json and .gitignore';
|
|
30
36
|
|
|
31
37
|
// --- where the shipped assets are -------------------------------------------
|
|
32
38
|
// Installed: <core>/lib/project.js, <core>/hooks/gate.py, <core>/pipeline/VERSION
|
|
@@ -223,6 +229,29 @@ function ensureIgnored(root, changes) {
|
|
|
223
229
|
changes.push(`added ${missing.join(', ')} to .gitignore`);
|
|
224
230
|
}
|
|
225
231
|
|
|
232
|
+
// --- .claude/profile.json ----------------------------------------------------------
|
|
233
|
+
// The `yaml pipeline-profile` block of PIPELINE.md, parsed once here so every agent that needs only
|
|
234
|
+
// the machine block (implementers, the reviewer, the release agent, the workflows' profile-reader)
|
|
235
|
+
// reads a small JSON file instead of the whole profile. Committed, regenerated by every sync.
|
|
236
|
+
// Returns { text } to write, or { note } saying why nothing was written.
|
|
237
|
+
function profileJson(root) {
|
|
238
|
+
let md;
|
|
239
|
+
try { md = fs.readFileSync(path.join(root, 'PIPELINE.md'), 'utf8'); } catch {
|
|
240
|
+
return { note: 'PIPELINE.md not found — .claude/profile.json not written (run /cohorte-init-pipeline)' };
|
|
241
|
+
}
|
|
242
|
+
let yaml;
|
|
243
|
+
try { yaml = require('./yaml.js'); } catch {
|
|
244
|
+
return { note: `yaml.js missing next to ${__filename} — .claude/profile.json not written (reinstall cohorte)` };
|
|
245
|
+
}
|
|
246
|
+
let text = null;
|
|
247
|
+
try { text = yaml.profileJsonText(md); } catch { /* reported below */ }
|
|
248
|
+
if (!text) {
|
|
249
|
+
return { note: 'PIPELINE.md has no parseable `yaml pipeline-profile` block — .claude/profile.json not written'
|
|
250
|
+
+ (fs.existsSync(path.join(root, PROFILE_FILE)) ? ' (the existing one was left as is and may be stale)' : '') };
|
|
251
|
+
}
|
|
252
|
+
return { text };
|
|
253
|
+
}
|
|
254
|
+
|
|
226
255
|
// --- sync / unsync -----------------------------------------------------------------
|
|
227
256
|
function sync(rootArg) {
|
|
228
257
|
const root = path.resolve(rootArg || process.cwd());
|
|
@@ -230,6 +259,7 @@ function sync(rootArg) {
|
|
|
230
259
|
const A = assets();
|
|
231
260
|
if (!fs.existsSync(A.gate)) throw new ProjectError(`gate hook not found at ${A.gate} — reinstall cohorte`);
|
|
232
261
|
const changes = [];
|
|
262
|
+
const notes = [];
|
|
233
263
|
|
|
234
264
|
// Parse everything we will touch BEFORE writing anything: an invalid file aborts the
|
|
235
265
|
// whole sync rather than leaving the project half-wired.
|
|
@@ -268,7 +298,13 @@ function sync(rootArg) {
|
|
|
268
298
|
fs.copyFileSync(A.specTemplate, specTpl);
|
|
269
299
|
changes.push('created specs/_template.md');
|
|
270
300
|
}
|
|
271
|
-
|
|
301
|
+
|
|
302
|
+
// 6. The parsed profile block, for agents that need only the machine block. Written AFTER
|
|
303
|
+
// PIPELINE.md: every command that edits the block re-runs sync so this file follows it.
|
|
304
|
+
const pj = profileJson(root);
|
|
305
|
+
if (pj.text) writeIfChanged(path.join(root, PROFILE_FILE), pj.text, changes, '.claude/profile.json');
|
|
306
|
+
else notes.push(pj.note);
|
|
307
|
+
return { root, version: A.version, changes, notes };
|
|
272
308
|
}
|
|
273
309
|
|
|
274
310
|
function unsync(rootArg) {
|
|
@@ -285,7 +321,7 @@ function unsync(rootArg) {
|
|
|
285
321
|
changes.push(`removed ${removed} gate hook registration(s) from .claude/settings.json`);
|
|
286
322
|
}
|
|
287
323
|
}
|
|
288
|
-
for (const rel of [GATE_FILE, path.join('.claude', 'pipeline.json')]) {
|
|
324
|
+
for (const rel of [GATE_FILE, path.join('.claude', 'pipeline.json'), PROFILE_FILE]) {
|
|
289
325
|
if (fs.existsSync(path.join(root, rel))) { fs.rmSync(path.join(root, rel)); changes.push(`removed ${rel}`); }
|
|
290
326
|
}
|
|
291
327
|
pruneEmpty(path.join(root, '.claude', 'hooks'));
|
|
@@ -294,8 +330,8 @@ function unsync(rootArg) {
|
|
|
294
330
|
return { root, changes, left };
|
|
295
331
|
}
|
|
296
332
|
|
|
297
|
-
module.exports = { sync, unsync, readJsonObject, stripOurHooks, isOurCommand, ProjectError,
|
|
298
|
-
GATE_COMMAND, GATE_MATCHER, EDIT_MATCHER, GATE_FILE, IGNORE_LINES };
|
|
333
|
+
module.exports = { sync, unsync, readJsonObject, stripOurHooks, isOurCommand, ProjectError, profileJson,
|
|
334
|
+
GATE_COMMAND, GATE_MATCHER, EDIT_MATCHER, GATE_FILE, PROFILE_FILE, IGNORE_LINES, COMMIT_LIST };
|
|
299
335
|
|
|
300
336
|
// --- CLI -----------------------------------------------------------------------------
|
|
301
337
|
if (require.main === module) {
|
|
@@ -306,7 +342,8 @@ if (require.main === module) {
|
|
|
306
342
|
console.log(`cohorte sync — ${r.root} (core ${r.version})`);
|
|
307
343
|
for (const c of r.changes) console.log(` · ${c}`);
|
|
308
344
|
if (!r.changes.length) console.log(' · already in sync');
|
|
309
|
-
|
|
345
|
+
for (const n of r.notes) console.log(` ! ${n}`);
|
|
346
|
+
if (r.changes.length) console.log(` Commit ${COMMIT_LIST}.`);
|
|
310
347
|
} else if (verb === 'unsync') {
|
|
311
348
|
const r = unsync(root);
|
|
312
349
|
for (const c of r.changes) console.log(` · ${c}`);
|
package/lib/render.js
CHANGED
|
@@ -62,8 +62,8 @@ function preamble(L, { kind = 'command' } = {}) {
|
|
|
62
62
|
out.push(`> **Cohorte — Claude Code.** Generated by the cohorte installer — do not edit this file;`);
|
|
63
63
|
out.push(`> edit \`core/${kind === 'agent' ? 'agents' : 'commands'}/\` in the cohorte source and re-install.`);
|
|
64
64
|
out.push('>');
|
|
65
|
-
out.push(`> - \`<core>\` = \`${core}\` — the pipeline's shared, machine-wide assets (\`pipeline/scripts/\`, \`pipeline/
|
|
66
|
-
out.push('> - `<state>` = `.claude/` in **this repo** — what the pipeline generates for this project (`gate-config.json`, `preflight.ok`, `pipeline-metrics.jsonl`, `pipeline.json`).');
|
|
65
|
+
out.push(`> - \`<core>\` = \`${core}\` — the pipeline's shared, machine-wide assets (\`pipeline/scripts/\`, \`pipeline/schema/<topic>.md\` — read only the one a step cites, \`templates/\`). Every \`<core>/…\` path below resolves there, and nowhere else.`);
|
|
66
|
+
out.push('> - `<state>` = `.claude/` in **this repo** — what the pipeline generates for this project (`gate-config.json`, `preflight.ok`, `pipeline-metrics.jsonl`, `pipeline.json`, `profile.json` — the parsed `PIPELINE.md` machine block).');
|
|
67
67
|
out.push('> - `<memory>` = `CLAUDE.md` — the project-instructions file at the repo root, loaded into every session here.');
|
|
68
68
|
out.push(`> - \`<config>\` = \`${displayPath(L.config)}\` — your user-level config (kanban boards, shared vault). One per human, never committed.`);
|
|
69
69
|
out.push('> - `<agents>` = `.claude/agents` in **this repo** — the surface agents rendered from `PIPELINE.md`, committed with the code. Never write a surface agent anywhere else.');
|
|
@@ -71,7 +71,7 @@ function preamble(L, { kind = 'command' } = {}) {
|
|
|
71
71
|
out.push(`> - \`<workflows>\` = \`${displayPath(L.workflows)}\` — the shipped workflow scripts (\`cohorte-review.js\`, \`cohorte-audit.js\`, \`cohorte-refactor.js\`, \`cohorte-loop.js\`).`);
|
|
72
72
|
out.push('> - Dispatch: the `Agent` tool (formerly `Task`), `subagent_type: <name>`.');
|
|
73
73
|
out.push('> - **Gate** — `.claude/hooks/cohorte-gate.py` is committed in this repo and registered as a blocking `PreToolUse` hook in `.claude/settings.json`, reading `<state>/gate-config.json`. It fires whether or not you cooperate, and can deny outright or ask the human to confirm.');
|
|
74
|
-
out.push(`> - \`<sync>\` = \`${sync}\` — wires THIS repo deterministically: copies the gate, registers its hook, writes the \`<state>/pipeline.json\` pointer and the \`.gitignore\` entries. Run it from the repo root; never hand-write those files.`);
|
|
74
|
+
out.push(`> - \`<sync>\` = \`${sync}\` — wires THIS repo deterministically: copies the gate, registers its hook, writes the \`<state>/pipeline.json\` pointer, \`<state>/profile.json\` and the \`.gitignore\` entries. Re-run it after any edit to \`PIPELINE.md\`'s machine block. Run it from the repo root; never hand-write those files.`);
|
|
75
75
|
return out.join('\n') + '\n';
|
|
76
76
|
}
|
|
77
77
|
|
package/lib/yaml.js
CHANGED
|
@@ -171,4 +171,13 @@ function parseProfileBlock(md) {
|
|
|
171
171
|
return parse(m[1]);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
// The exact bytes `cohorte sync` writes to `.claude/profile.json` for a PIPELINE.md string, or null
|
|
175
|
+
// when there is no block / it parses to nothing. One serializer, shared by sync (the writer) and
|
|
176
|
+
// doctor (the freshness check), so the two can never disagree about what "fresh" means.
|
|
177
|
+
function profileJsonText(md) {
|
|
178
|
+
const profile = typeof md === 'string' ? parseProfileBlock(md) : null;
|
|
179
|
+
if (!profile || typeof profile !== 'object' || Array.isArray(profile) || !Object.keys(profile).length) return null;
|
|
180
|
+
return JSON.stringify(profile, null, 2) + '\n';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module.exports = { parse, parseProfileBlock, profileJsonText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cohorte",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Multi-agent development pipeline for Claude Code — install it once, run /cohorte-init-pipeline in a repo, and it adapts to that project's stack.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"cohorte": "bin/cli.js"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"CHANGELOG.md"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"test": "node scripts/validate-core.mjs && node scripts/test-install.mjs && node scripts/test-gate.mjs && node scripts/test-lib.mjs && node scripts/test-workflows.mjs && node scripts/test-kanban.mjs && node scripts/test-metrics.mjs"
|
|
26
|
+
"test": "node scripts/validate-core.mjs && node scripts/test-install.mjs && node scripts/test-gate.mjs && node scripts/test-lib.mjs && node scripts/test-workflows.mjs && node scripts/test-kanban.mjs && node scripts/test-metrics.mjs && node scripts/test-e2e.mjs && node scripts/test-verify.mjs"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=20"
|
|
@@ -19,6 +19,12 @@ one_liner: <one sentence: what this product is>
|
|
|
19
19
|
ui_language: <English | French | …> # language of ALL user-facing copy
|
|
20
20
|
package_manager: <pnpm | npm | yarn | bun | pip | cargo | go>
|
|
21
21
|
|
|
22
|
+
# ── project kind (what the repo delivers) ───────────────────────────────────
|
|
23
|
+
# Selects the spec DoD defaults, the review's kind-specific checks and whether
|
|
24
|
+
# the design step applies — see <core>/pipeline/schema/project-kinds.md.
|
|
25
|
+
project:
|
|
26
|
+
kind: <web | api | cli | library | mobile | data | other> # absent ⇒ web
|
|
27
|
+
|
|
22
28
|
# ── vcs ─────────────────────────────────────────────────────────────────────
|
|
23
29
|
vcs:
|
|
24
30
|
host: <github | gitlab | none>
|
|
@@ -48,7 +54,7 @@ retrieval:
|
|
|
48
54
|
# This list GROWS automatically: /cohorte-build §1.5 adds a surface (and renders its
|
|
49
55
|
# agent) when a spec touches a tree no surface owns, or splits a bottleneck
|
|
50
56
|
# surface into specialized sub-surfaces. Keep one owner per tree; shared code
|
|
51
|
-
# (routing/state/DS) is its own single-owner surface. See
|
|
57
|
+
# (routing/state/DS) is its own single-owner surface. See `<core>/pipeline/schema/specialization.md`.
|
|
52
58
|
surfaces:
|
|
53
59
|
- key: backend # short id, used as agent name + scope
|
|
54
60
|
path: apps/api # the ONLY tree this surface's agent may touch
|
|
@@ -98,6 +104,14 @@ contract:
|
|
|
98
104
|
index: packages/shared-types/src/index.ts # barrel to export from, or "" if none
|
|
99
105
|
authored_by: lead # NEVER the implementer agents
|
|
100
106
|
|
|
107
|
+
# ── surface ownership (enforced by the gate hook) ──────────────────────────
|
|
108
|
+
# A surface agent may write only under its surfaces[].path (+ an optional per-surface
|
|
109
|
+
# `owns_also: [db/migrations]`, + shared_writable below); contract.path is read-only to it.
|
|
110
|
+
# Write/Edit outside ⇒ denied; Bash writes ⇒ best effort. The lead is never restricted.
|
|
111
|
+
ownership:
|
|
112
|
+
enforce: true # false ⇒ back to convention + review only
|
|
113
|
+
shared_writable: [] # e.g. [pnpm-lock.yaml] — files every surface may touch
|
|
114
|
+
|
|
101
115
|
# ── release notes (optional) ────────────────────────────────────────────────
|
|
102
116
|
# A per-feature release note the project's versioning tool consumes. When
|
|
103
117
|
# enabled, /cohorte-ship authors it BEFORE dispatching the release agent, so it
|
|
@@ -128,9 +142,33 @@ commands:
|
|
|
128
142
|
typecheck: pnpm check-types
|
|
129
143
|
test: pnpm test
|
|
130
144
|
test_quiet: pnpm test --reporter=dot # bridled variant — what the /cohorte-review preflight runs
|
|
145
|
+
security: [] # dependency audit / feature-diff secret scan commands, run after tests (schema/preflight.md)
|
|
131
146
|
# migration commands — omit / leave "" if the project has no DB migrations
|
|
132
147
|
migrate: "cd apps/api && node ace migration:run"
|
|
133
148
|
make_migration: "cd apps/api && node ace make:migration"
|
|
149
|
+
# undo the last migration on the DEV db — /cohorte-verify checks down-then-up, /cohorte-revert
|
|
150
|
+
# runs it. A command in gate.deny is never run (e.g. migration:rollback below): move it to
|
|
151
|
+
# gate.ask to let the pipeline verify rollbacks. "" ⇒ rollback is not verified.
|
|
152
|
+
migrate_down: ""
|
|
153
|
+
# runtime verification (/cohorte-verify, <core>/pipeline/schema/verify.md) — `dev` counts only
|
|
154
|
+
# with a `dev_ready` probe; all "" ⇒ verify is skipped silently
|
|
155
|
+
dev_ready: "" # URL answering 2xx/3xx once `dev` is up, or a shell probe exiting 0 — e.g. "http://localhost:3333/health"
|
|
156
|
+
smoke: "" # quick checks against the running app, e.g. "curl -sf http://localhost:3333/health"
|
|
157
|
+
e2e: "" # e.g. "pnpm exec playwright test --reporter=line"
|
|
158
|
+
|
|
159
|
+
# ── runtime verification (optional — /cohorte-verify) ───────────────────────
|
|
160
|
+
# Runs the app between /cohorte-review and /cohorte-ship, through
|
|
161
|
+
# pipeline/scripts/verify-run.sh. See `<core>/pipeline/schema/verify.md`.
|
|
162
|
+
verify:
|
|
163
|
+
enabled: true # false ⇒ /cohorte-verify is a no-op and /cohorte-ship never asks
|
|
164
|
+
db: local # local = the dev DB is yours to migrate and roll back;
|
|
165
|
+
# shared = others use it ⇒ migrations refused unless
|
|
166
|
+
# isolation.db_per_worktree and run in a feature worktree
|
|
167
|
+
ready_timeout_seconds: 90
|
|
168
|
+
check_timeout_seconds: 600
|
|
169
|
+
screenshots: auto # auto = with a local Playwright CLI (node_modules/.bin/playwright) · off
|
|
170
|
+
surfaces: {} # per-surface hints, keyed by surfaces[].key, e.g.
|
|
171
|
+
# frontend: { base_url: "http://localhost:5173", paths: [/, /settings], smoke: "" }
|
|
134
172
|
|
|
135
173
|
# ── rbac (optional) ─────────────────────────────────────────────────────────
|
|
136
174
|
rbac:
|