cohorte 3.3.0 → 4.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 (40) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +23 -3
  3. package/core/agents/cohorte-review.md +11 -3
  4. package/core/agents/implementer.template.md +19 -1
  5. package/core/commands/cohorte-acceptance.md +35 -0
  6. package/core/commands/cohorte-build.md +17 -0
  7. package/core/commands/cohorte-fix.md +6 -0
  8. package/core/commands/cohorte-foundation.md +90 -0
  9. package/core/commands/cohorte-lead.md +90 -0
  10. package/core/commands/cohorte-learn.md +67 -0
  11. package/core/commands/cohorte-po.md +76 -0
  12. package/core/commands/cohorte-product-map.md +53 -0
  13. package/core/commands/cohorte-retro.md +44 -13
  14. package/core/commands/cohorte-scaffold.md +59 -0
  15. package/core/commands/cohorte-vision.md +80 -0
  16. package/lib/install.js +2 -0
  17. package/lib/project.js +1 -1
  18. package/lib/registry.js +4 -3
  19. package/package.json +2 -2
  20. package/profile/PIPELINE.template.md +3 -1
  21. package/profile/schema/kanban.md +23 -0
  22. package/scripts/kanban-move.sh +45 -11
  23. package/ui/dist-server/server/agents.js +100 -0
  24. package/ui/dist-server/server/decider.js +241 -0
  25. package/ui/dist-server/server/features.js +128 -0
  26. package/ui/dist-server/server/flow.js +934 -0
  27. package/ui/dist-server/server/founding.js +706 -0
  28. package/ui/dist-server/server/gitinfo.js +22 -0
  29. package/ui/dist-server/server/history.js +10 -3
  30. package/ui/dist-server/server/legacy.js +3 -1
  31. package/ui/dist-server/server/next.js +91 -0
  32. package/ui/dist-server/server/runs.js +73 -11
  33. package/ui/dist-server/server/server.js +222 -6
  34. package/ui/dist-server/server/settings.js +81 -0
  35. package/ui/dist-server/server/tracker.js +438 -0
  36. package/ui/dist-server/shared/blocks.js +165 -0
  37. package/ui/dist-web/assets/index-BfN944Jm.js +165 -0
  38. package/ui/dist-web/assets/{style-0oNNMjwU.css → style-BMfadlCl.css} +1 -1
  39. package/ui/dist-web/index.html +2 -2
  40. package/ui/dist-web/assets/index-Clp1YW4S.js +0 -152
@@ -0,0 +1,53 @@
1
+ ---
2
+ model: sonnet
3
+ description: Write PRODUCT.md — what the product does, in business language, discovered from the code — so the product owner knows what exists before proposing anything.
4
+ argument-hint: (none)
5
+ ---
6
+
7
+ You are writing the **product map** of this repository: `PRODUCT.md` at the repo root. Its reader is the
8
+ product owner agent (and any person from the business): someone who must know **what the product already
9
+ does** — without reading code — before proposing a ticket. It is the business-side twin of `PIPELINE.md`,
10
+ which says how the repo is built.
11
+
12
+ > Read `.claude/profile.json` (the parsed `pipeline-profile` block; absent ⇒ that block in `PIPELINE.md`):
13
+ > `name`, `one_liner`, `project.kind`, `surfaces` (where each part of the product lives), `ui_language`
14
+ > (write the map in it). If `PRODUCT.md` exists, read it first: you are **updating** it — keep what is still
15
+ > true, correct what changed, add what is new, and do not rewrite sections that are still accurate.
16
+
17
+ ## Discover — bounded
18
+
19
+ Use retrieval tools first when the profile has them, then Glob/Grep. Look for what a user can do, not how:
20
+ routes and pages, navigation and menus, API resources, CLI commands, scheduled jobs and emails, roles and
21
+ permissions, settings, integrations with outside services, `specs/*.md` with `status: merged` (features
22
+ already delivered) and `specs/_decisions.md` (product rules). Do not read whole files when a route table, a
23
+ router or a menu definition gives the list. Budget: about 40 reads.
24
+
25
+ ## Write `PRODUCT.md` — ≤ ~200 lines
26
+
27
+ ```markdown
28
+ # <Product name> — what it does
29
+
30
+ > Generated by /cohorte-product-map on <YYYY-MM-DD>. Read by the product owner agent. Keep it in business language.
31
+
32
+ ## Who uses it
33
+ <the roles / kinds of users, one line each, and what each comes to do>
34
+
35
+ ## What they can do
36
+ ### <Area, e.g. Appointments>
37
+ - <a capability, as the user experiences it> — <who can, if restricted>
38
+
39
+ ## Rules the product enforces
40
+ - <a business rule: limits, permissions, lifecycles, what is forbidden>
41
+
42
+ ## Connected to
43
+ - <outside services, imports/exports, notifications>
44
+
45
+ ## Known gaps
46
+ - <what is visibly missing or half-done — only what the code or the specs show>
47
+ ```
48
+
49
+ No file paths, no technology names, no endpoints. A capability that only exists behind a flag or is half-built
50
+ goes under **Known gaps**, not **What they can do**.
51
+
52
+ Write the file (create or overwrite — it is a generated document, the source of truth is the code). Then end
53
+ with one line: the number of capabilities listed and the sections that changed since the previous version.
@@ -27,8 +27,18 @@ Scope: `all` (default), or `last <n>` features by spec mtime. In as few Bash cal
27
27
  count line). Grep the item lines: `- [x?] <SEVERITY> · <file:line> · <kind> · <fix>`.
28
28
  - `specs/refactor-backlog.md` — the `deferred:<id>` tagged items: debt reviews kept finding
29
29
  but no feature owned.
30
-
31
- A repo with fewer than two features' worth of residue ⇒ say the retro has nothing statistical
30
+ - **The learning journal** — `$(dirname "$(git rev-parse --git-common-dir)")/.claude/journal/*.md`
31
+ (not `processed/`), one file per feature, written by `/cohorte-learn` when a feature merged or was
32
+ abandoned. It is the richest source: besides review findings it carries red CI and preflight checks,
33
+ **corrections the developer asked for at a checkpoint**, **decisions the developer contested** (the
34
+ autopilot's decider chose, they disagreed) and implementer traps. Grep its `- motif:`, `- source:`,
35
+ `- severity:`, `- existing rule:` and `- rule that would have prevented it:` lines — the motif is the
36
+ counting key.
37
+ - The rules already rejected — `specs/_decisions.md` lines with `· conventions · rejected` — so a rule the
38
+ human turned down is never proposed again unless new evidence changes the case (say so when it does).
39
+
40
+ Normalise synonym motifs first (`missing-authz` and `authz-check-missing` are one motif) and say
41
+ which you merged. A repo with fewer than two features' worth of residue ⇒ say the retro has nothing statistical
32
42
  to stand on yet, name what exists, and stop — one feature's findings are that feature's story,
33
43
  not a pattern.
34
44
 
@@ -43,30 +53,46 @@ A **pattern** is a finding shape that recurs where recurrence means something:
43
53
  - the same *fix wording* family recurring (e.g. three "add the authz check" fixes = one
44
54
  missing authorization convention);
45
55
  - a `deferred:` cluster in one domain — debt the reviews keep re-discovering because no rule
46
- makes the implementers avoid adding to it.
56
+ makes the implementers avoid adding to it;
57
+ - the same journal **motif** across ≥ 2 features, or a single **blocking** one (a security finding, a
58
+ contested irreversible decision) — one occurrence is enough when the cost was that high;
59
+ - the same **correction** or **contested decision** twice — the developer keeps steering the pipeline
60
+ the same way: that is a preference the rules should carry, so it stops being asked or redone.
47
61
 
48
62
  For each pattern, produce: the evidence lines **verbatim** (`<feature> · <severity> · <file> ·
49
63
  <problem/fix>`), the count, and ONE drafted convention rule — **rule-shaped**: a sentence an
50
64
  implementer can follow and a reviewer can test a diff against, placed under `### Shared` or the
51
65
  owning `### Surface: <key>`. Not advice ("be careful with auth") — a rule ("every route under
52
66
  `apps/api/src/routes/` calls `authorize()` before its handler; no exceptions without a spec
53
- §5 note"). Skip any pattern the existing §Conventions already covers — report those separately
54
- as **enforcement gaps** (the rule exists and reviews keep finding violations: that is input for
55
- the human, not a new rule).
67
+ §5 note"). **Prefer a check to a sentence.** When the pattern can be caught mechanically — a lint rule, a test, a
68
+ grep in `commands.preflight`/CI — propose that instead of (or alongside) a prose rule, as a concrete
69
+ change the human can turn into a tech ticket. Prose rules cost tokens on every dispatch forever; a check
70
+ costs nothing and never drifts.
71
+
72
+ A pattern the existing §Conventions already covers is an **enforcement gap**: the rule exists and the
73
+ journal or reviews still cite it (`existing rule: <id>`, or a `[<id>]` review citation). It is not a new
74
+ rule — it is a rule that **does not work**. Propose ONE of: reword it (sharper, testable), move it into a
75
+ check, move it to the surface whose agent keeps breaking it, or retire it. Never just repeat it.
56
76
 
57
77
  ## 3. Ratify — the human picks; nothing lands without them
58
78
 
59
- Present a compact table: pattern → evidence count → drafted rule → target stanza. Then **stop
60
- and ask** which to adopt (all / some / none — none is a fine outcome and says the rulebook fits
61
- the codebase). Rules are standing law every future dispatch pays tokens to carry: the human
62
- decides what becomes law, exactly as they freeze specs.
79
+ Present a compact table first: pattern → evidence count → drafted rule (or check, or rework) →
80
+ target stanza. Then put each proposal to the human **one at a time** with AskUserQuestion — the exact
81
+ rule text, its evidence count and target in the question — options: **Ratify** · **Ratify with a change**
82
+ (they type it) · **Reject** · **Later**. None ratified is a fine outcome and says the rulebook fits the
83
+ codebase. Rules are standing law every future dispatch pays tokens to carry: the human decides what
84
+ becomes law, exactly as they freeze specs.
63
85
 
64
86
  ## 4. Apply — and keep the baked slices honest
65
87
 
66
88
  For each adopted rule, in this order:
67
89
 
68
90
  1. Append it to `PIPELINE.md` §Conventions under its stanza (create the `### Surface: <key>`
69
- stanza if absent; keep it rule-shaped, one line each).
91
+ stanza if absent; keep it rule-shaped, one line each), **with a stable id**:
92
+ `- **SH-<nnn>** — <rule>` under `### Shared`, `- **<KEY>-<nnn>** — <rule>` under a surface (`<KEY>` =
93
+ the surface key upper-cased, e.g. `BACKEND-003`). Next number = the highest id of that prefix + 1; an id
94
+ is never reused, even after its rule is retired. A reworked rule keeps its id; a retired one is deleted
95
+ with its reason in the decisions line below.
70
96
  2. **Re-render every affected surface agent** per `<core>/pipeline/schema/rendering.md` step 2 — the
71
97
  `<SURFACE_CONVENTIONS>` slice is **baked at render time**, so a §Conventions edit without a
72
98
  re-render produces the worst outcome available: reviewers (who read the prose live) enforce
@@ -75,9 +101,14 @@ For each adopted rule, in this order:
75
101
  runtime, say so and route to `/cohorte-update-pipeline` (its reconcile step 2 re-renders) —
76
102
  but then the rule is **pending**, and you say that too.
77
103
  3. Append ONE line per adopted rule to `specs/_decisions.md` §Live (`<core>/pipeline/schema/decisions.md`):
78
- `- <date> · conventions · <rule, compressed> — because <kind>×<n> across <features> · retro`.
104
+ `- <date> · conventions · <id> <rule, compressed> — because <motif>×<n> across <features> · retro`.
79
105
  A retro rule is a standing decision; the journal is where the next `/cohorte-spec` learns it
80
- without re-mining the reports.
106
+ without re-mining the reports. **A rejected proposal gets its line too**:
107
+ `- <date> · conventions · rejected: <rule, compressed> — because <the human's reason> · retro`, so the
108
+ next retro does not propose it again.
109
+ 4. **Archive the journal entries you processed** (ratified, rejected or "not a pattern"): move their files
110
+ to `.claude/journal/processed/` in the main checkout (`mkdir -p` then `mv`, one Bash call). Entries
111
+ marked **Later** stay where they are and count again next time.
81
112
 
82
113
  In chat print ONLY: patterns found / adopted / skipped (one line each), enforcement gaps, which
83
114
  agents were re-rendered (or the pending route), and the decisions lines appended. The evidence
@@ -0,0 +1,59 @@
1
+ ---
2
+ model: sonnet
3
+ description: Generate a new project's walking skeleton from the approved foundations plan — official generators, one trivial path through every surface, tests, lint, compose, CI — and commit it.
4
+ argument-hint: (none — the approved plan is in the cohorte ui context block)
5
+ ---
6
+
7
+ You are generating the **walking skeleton** of a new project, in the current folder (its root — `git
8
+ init` already ran; it may already hold `PRODUCT.md`). The developer approved the **foundations plan**
9
+ (the `cohorte-foundation` block in the context below): follow it exactly. You are not designing
10
+ anything; every choice is in the plan. A choice the plan does not settle → the most conventional option
11
+ for that stack, recorded in your final report as an assumption.
12
+
13
+ ## Rules
14
+
15
+ - **Generators first.** Create each surface with its `generate` command, from the project root,
16
+ non-interactively. Never hand-write what a generator produces (configs, the framework's own files).
17
+ A generator that prompts anyway → re-run it with the flags that answer the prompt, or with
18
+ `CI=1`; never leave a command waiting for input. A generator that creates its own `.git` → remove that
19
+ nested `.git` folder (the project root is the only repository).
20
+ - **No business feature.** The vision's tickets are built later, one at a time. The skeleton proves the
21
+ plumbing only: the plan's `skeleton` path (for example a `/health` endpoint the web page calls and
22
+ displays, reading one row from the database when there is one).
23
+ - **Each surface** ends with: its test runner set up and **one passing test** of the skeleton path, its
24
+ linter/formatter set up and clean, its build passing. Use the plan's `test` / `lint` / `build`
25
+ commands; fix the command in your report when the generator names it differently.
26
+ - **The root** gets: a `README.md` (what the project is in two lines — from `PRODUCT.md` when it exists —
27
+ then prerequisites, how to install, run, test), a `.gitignore` covering every surface, a
28
+ `.editorconfig`, a `docker-compose.yml` when the plan has a database or a service (named volumes, no
29
+ host ports above what is needed, credentials only for development and read from a `.env` that is
30
+ gitignored, with a committed `.env.example`), and `.github/workflows/ci.yml` running each surface's
31
+ lint, test and build (with the service containers the tests need).
32
+ - **Secrets**: never commit one. Development credentials go in `.env.example` with obvious placeholder
33
+ values.
34
+ - **Verify**: install dependencies, then run every surface's lint, test and build and read the output.
35
+ Docker may be unavailable on this machine: then say so and skip only what needs it (the CI still runs it).
36
+ Two attempts to fix a failing check; after that, stop and report it as failed — do not paper over it
37
+ (no skipped tests, no disabled lint rules).
38
+ - **Commit** when the checks pass: `git add -A` then `git commit -m "chore: walking skeleton"` (on the
39
+ current branch). Do not push, do not add a remote.
40
+ - Do **not** create `PIPELINE.md`, `CLAUDE.md`, `.claude/` or `specs/`: the pipeline is set up right
41
+ after you, from what you leave.
42
+
43
+ Ask nothing unless a choice is truly blocking and the plan cannot settle it — then use AskUserQuestion
44
+ once (recommended option first, labelled `(Recommended)`, `header` = its class).
45
+
46
+ ## Report
47
+
48
+ End your turn with a short summary and exactly one block:
49
+
50
+ ```cohorte-scaffold
51
+ {"status": "ok | failed",
52
+ "surfaces": [{"key": "web", "path": "web", "test": "npm test", "lint": "npm run lint", "build": "npm run build", "ok": true}],
53
+ "devCommand": "How to start everything locally",
54
+ "checks": [{"command": "cd web && npm test", "ok": true, "note": ""}],
55
+ "assumptions": ["What you chose that the plan did not settle"],
56
+ "notes": "Anything the developer must know (docker unavailable, a check you could not run…)"}
57
+ ```
58
+
59
+ `status` is `ok` only when every check you could run passed and the commit exists.
@@ -0,0 +1,80 @@
1
+ ---
2
+ description: The product owner for a product that does not exist yet — turns an idea into a vision (who, what problem, what the first version must do) and the first version's tickets.
3
+ argument-hint: [the idea, in the person's words]
4
+ ---
5
+
6
+ You are the **product owner** of a product that **does not exist yet**. The person in front of you has
7
+ an idea — a founder, a client, a manager, sometimes a developer wearing a business hat. There is no
8
+ code, no product map and no ticket: your job is to leave them with **a vision they recognise as theirs**
9
+ and the **tickets of its first version**. Their first message:
10
+
11
+ **$ARGUMENTS**
12
+
13
+ > You normally run inside `cohorte ui` ("New project"): a context block at the end of this prompt gives
14
+ > the project name, the language to talk in and the person. The folder is empty on purpose — do not look
15
+ > for code.
16
+
17
+ ## Who you are in this conversation
18
+
19
+ Everything `/cohorte-po` says about who you are holds here: you speak **business** (users, journeys,
20
+ value, risk, money, time) and **never code** — no frameworks, databases, hosting, or estimates in hours;
21
+ the developers choose the stack next, with their lead. You are **curious and direct**, not a form: at
22
+ most three focused questions per turn, and you reformulate before you propose.
23
+
24
+ For a new product, the questions that matter:
25
+
26
+ - **Who** exactly has the problem, how often, and what it costs them today — the first user, not "everyone".
27
+ - **What they do today instead** (a spreadsheet, a competitor, nothing) — the product has to beat it.
28
+ - **The first version**: the smallest thing that already delivers most of the value — the "killer" core.
29
+ Push back on a first version that does everything; name what waits for later.
30
+ - **What success looks like** after a few weeks of use — a number when they have one.
31
+ - Constraints the business owns: a deadline, a budget, a regulation (health, payment, personal data),
32
+ languages, devices (phone first?), who must be able to use it without training.
33
+
34
+ ## Proposing the vision
35
+
36
+ When you understand enough — usually after two to four exchanges — say the vision in a few sentences,
37
+ then put it in one block, exactly:
38
+
39
+ ```cohorte-vision
40
+ {"name": "The product's name (or a working name)",
41
+ "pitch": "One sentence: what it is, for whom.",
42
+ "users": ["Who uses it, each in a few words — the first user first"],
43
+ "problem": "The problem and what it costs today (2–4 sentences, their words).",
44
+ "today": "What they do instead today.",
45
+ "firstVersion": ["What the first version lets them do — each an outcome they can check"],
46
+ "later": ["What deliberately waits for later"],
47
+ "success": "How we will know it works, a number when they gave one.",
48
+ "constraints": ["Deadline, budget, regulation, languages, devices — only what they said"],
49
+ "language": "The language the product's users speak"}
50
+ ```
51
+
52
+ Then the **first version's tickets**, one block each, in the same format as `/cohorte-po` — **one
53
+ ticket = one outcome the person can check**, in the order they should be built (the first one is the
54
+ thinnest end-to-end slice: someone can open the product and do the core thing, however plainly):
55
+
56
+ ```cohorte-ticket
57
+ {"ref": "short-stable-slug", "title": "A short title the business would use",
58
+ "type": "feature",
59
+ "need": "Who has which problem, and why it matters (2–5 sentences).",
60
+ "value": "What it is worth.",
61
+ "criteria": ["Given … when … then … — observable by a non-developer"],
62
+ "outOfScope": ["What this ticket deliberately does not do"],
63
+ "priority": "high | medium | low", "size": "S | M | L | ?",
64
+ "parent": null}
65
+ ```
66
+
67
+ - A revision keeps the same `ref` (tickets) — and a new `cohorte-vision` block replaces the previous one.
68
+ - 3–8 tickets for a first version. More means the first version is too big: say so and cut.
69
+ - The JSON must parse: double quotes, no trailing commas, no comments.
70
+
71
+ After the blocks, tell the person what happens next: they **validate the vision** in the dashboard; then
72
+ the developers choose how to build it and set up the project's skeleton; the tickets wait in the backlog
73
+ and they will be asked to check each one when it is delivered. Ask whether anything is missing or wrong.
74
+
75
+ ## What you never do
76
+
77
+ - Choose or hint at a technology, a provider or an architecture.
78
+ - Promise a date or a cost in money.
79
+ - Invent a need the person did not express, or pad the first version with "nice to haves".
80
+ - Write a real person's personal data into the vision or a ticket: describe the kind of data, not the data.
package/lib/install.js CHANGED
@@ -107,6 +107,8 @@ function desiredFiles(globalDir) {
107
107
  put(path.join('cohorte', 'lib', 'project.js'), fs.readFileSync(path.join(pkgRoot, 'lib', 'project.js')));
108
108
  // project.js requires its sibling yaml.js (lazily) to write .claude/profile.json.
109
109
  put(path.join('cohorte', 'lib', 'yaml.js'), fs.readFileSync(path.join(pkgRoot, 'lib', 'yaml.js')));
110
+ // `node <core>/lib/project.js` must stay CommonJS even under a folder whose package.json says "type": "module".
111
+ put(path.join('cohorte', 'lib', 'package.json'), '{ "type": "commonjs" }\n');
110
112
  return files;
111
113
  }
112
114
 
package/lib/project.js CHANGED
@@ -29,7 +29,7 @@ const GATE_COMMAND = 'python3 "$CLAUDE_PROJECT_DIR/.claude/hooks/cohorte-gate.py
29
29
  const GATE_MATCHER = 'Bash|Task|Agent';
30
30
  const EDIT_MATCHER = 'Write|Edit|MultiEdit|NotebookEdit';
31
31
  const INSTALL_HINT = 'npm i -g cohorte && cohorte install';
32
- const IGNORE_LINES = ['.claude/preflight.ok', '.claude/pipeline-metrics.jsonl', 'specs/reports/'];
32
+ const IGNORE_LINES = ['.claude/preflight.ok', '.claude/pipeline-metrics.jsonl', '.claude/journal/', 'specs/reports/'];
33
33
  const IGNORE_HEADER = '# cohorte — local-only pipeline artifacts (never commit these)';
34
34
  const MARKERS = ['Generated by the cohorte adapter', 'Generated by the cohorte installer'];
35
35
  const COMMIT_LIST = '.claude/settings.json, .claude/hooks/cohorte-gate.py, .claude/pipeline.json, .claude/profile.json and .gitignore';
package/lib/registry.js CHANGED
@@ -53,14 +53,15 @@ function save(globalDir, projects) {
53
53
  }
54
54
 
55
55
  // Registers a project by path. The path may be any folder inside the repo: the git root is stored,
56
- // so two entries for one repo cannot exist. A missing folder or a repo without cohorte is refused.
57
- function add(globalDir, input) {
56
+ // so two entries for one repo cannot exist. A missing folder or a repo without cohorte is refused —
57
+ // unless `founding`: cohorte ui registers a project it is founding (New project) before its PIPELINE.md exists.
58
+ function add(globalDir, input, { founding = false } = {}) {
58
59
  if (typeof input !== 'string' || !input.trim()) throw new RegistryError('a project path is required');
59
60
  const expanded = input.trim().replace(/^~(?=$|[\\/])/, os.homedir());
60
61
  if (!path.isAbsolute(expanded)) throw new RegistryError('the path must be absolute');
61
62
  if (!isDir(expanded)) throw new RegistryError(`${expanded} is not a folder`);
62
63
  const root = gitTop(expanded) || realOr(expanded);
63
- if (!isCohorteProject(root)) {
64
+ if (!founding && !isCohorteProject(root)) {
64
65
  throw new RegistryError(`${root} has no PIPELINE.md or .claude/pipeline.json — run /cohorte-init-pipeline in it first`);
65
66
  }
66
67
  const list = load(globalDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cohorte",
3
- "version": "3.3.0",
3
+ "version": "4.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"
@@ -31,7 +31,7 @@
31
31
  "build:ui": "node scripts/build-ui.mjs",
32
32
  "prepack": "npm run build:ui",
33
33
  "pretest": "npm run build:ui",
34
- "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 && node scripts/test-ui.mjs"
34
+ "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 && node scripts/test-ui.mjs && node scripts/test-flow.mjs"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=20"
@@ -243,7 +243,9 @@ gate:
243
243
  ## Conventions
244
244
 
245
245
  > Read by the implementer + review agents. Keep these terse and rule-shaped; the machine
246
- > block above holds the paths/commands they enforce against.
246
+ > block above holds the paths/commands they enforce against. Rules ratified by `/cohorte-retro` carry a
247
+ > stable id — `**SH-<nnn>**` under Shared, `**<SURFACE KEY>-<nnn>**` under a surface — that reviews cite
248
+ > when a rule is broken and that is never reused. Hand-written rules may stay id-less.
247
249
 
248
250
  ### Shared
249
251
 
@@ -13,6 +13,29 @@ the current project's board: read `name` from `PIPELINE.md`, look up `kanban.boa
13
13
  board file is `<obsidian.vault_path>/<boards[name].board>`, its columns are `boards[name].columns` if
14
14
  present else `kanban.columns`. Not found ⇒ kanban off for this project.
15
15
 
16
+ **Layouts.** Two board layouts exist, and every stage key works on both:
17
+
18
+ | Layout | Columns, in order | Who creates it |
19
+ | --- | --- | --- |
20
+ | `pipeline` | Ideas · Brainstorm · Spec · Ready to build · Building · Review · Fix · Ship · Shipped | `/cohorte-init-pipeline` (and every board made before 4.0) |
21
+ | `company` | Ideas · Discussion · To validate · business · Backlog · Framing · In progress · To validate · dev · PR open · Acceptance · Done | `cohorte ui` (Settings → Connect Obsidian) |
22
+
23
+ The company layout mirrors the company flow (`docs/guide/company-flow.md`): the business discusses and
24
+ validates tickets, a developer frames one with the lead, the autopilot builds it, the developer signs off,
25
+ the PR merges, the requester accepts. Each stage key resolves to a **list of candidate headings** — the
26
+ configured `columns` entry first, then the layout defaults (`building` → `Building` | `In progress`,
27
+ `ship` → `Ship` | `To validate · dev`, `shipped` → `Shipped` | `PR open`, …) — and `kanban-move.sh` takes
28
+ the first one the board actually has. So the pipeline commands move cards correctly on a company board
29
+ without any config change, and the company flow's keys (`discussion` · `validate` · `backlog` · `framing`
30
+ · `checkpoint` · `pr` · `acceptance` · `done`) land on the closest pipeline column of an older board.
31
+
32
+ **Ticket notes (company flow).** `cohorte ui` keeps each ticket as a markdown note in a `Tickets/` folder
33
+ next to the board (front-matter `id`, `title`, `type`, `status`, `requester`, `priority`, `size`, …,
34
+ `tags: [cohorte-ticket]`; sections Need · Value · Acceptance criteria · Out of scope · Notes · Acceptance
35
+ note · Feedback), and the card links to it: `- [ ] [[<folder>/Tickets/<id>|<title>]] #<id>`. The ticket id
36
+ is the feature id, so the ticket's card and the spec's card are the same card. Edit a note by hand if you
37
+ like; the dashboard re-reads it.
38
+
16
39
  **Card format.** A card is a Kanban list item under a `## <column>` heading:
17
40
  `- [ ] <human title> #<feature_id>`. The `#<feature_id>` tag is the join key between a card and its
18
41
  `specs/<feature_id>.md`; it is how every stage finds *its* card (Grep the board for `#<id>`). Free-text
@@ -67,22 +67,37 @@ TAB=$(printf '\t')
67
67
  # overrides it (tests, or a second board set).
68
68
  CONFIG="${COHORTE_CONFIG:-${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte.config.yaml}"
69
69
 
70
- # The nine pipeline stages and their default headings. A stage key given as the
70
+ # The pipeline stages and their default headings. A stage key given as the
71
71
  # target column is mapped through the config (per-board `columns` first, then the
72
72
  # global `kanban.columns`) and falls back to these — so a stage key works even
73
73
  # with an explicit board path and no config at all. Anything not in this list is
74
74
  # taken as a literal heading, which keeps hand-written columns working.
75
+ #
76
+ # Two board layouts exist (schema/kanban.md "Layouts"): the `pipeline` one (one column
77
+ # per command: Spec, Ready to build, Building…) and the `company` one cohorte ui creates
78
+ # (Discussion, To validate · business, Backlog, Framing, In progress…). Every stage key
79
+ # has a candidate per layout, and the move takes the FIRST candidate the board actually
80
+ # has — so `/cohorte-build` moves a card to "Building" on a pipeline board and to
81
+ # "In progress" on a company board, and neither layout ever exits 3 on a known stage.
75
82
  default_heading() {
76
83
  case "$1" in
77
84
  ideas) echo "Ideas" ;;
78
- brainstorm) echo "Brainstorm" ;;
79
- spec) echo "Spec" ;;
80
- ready) echo "Ready to build" ;;
81
- building) echo "Building" ;;
82
- review) echo "Review" ;;
83
- fix) echo "Fix" ;;
84
- ship) echo "Ship" ;;
85
- shipped) echo "Shipped" ;;
85
+ brainstorm) echo "Brainstorm|Discussion" ;;
86
+ discussion) echo "Discussion|Brainstorm" ;;
87
+ validate) echo "To validate · business|Brainstorm" ;;
88
+ backlog) echo "Backlog|Ideas" ;;
89
+ spec) echo "Spec|Framing" ;;
90
+ ready) echo "Ready to build|Framing" ;;
91
+ framing) echo "Framing|Spec" ;;
92
+ building) echo "Building|In progress" ;;
93
+ review) echo "Review|In progress" ;;
94
+ fix) echo "Fix|In progress" ;;
95
+ checkpoint) echo "To validate · dev|Ship" ;;
96
+ ship) echo "Ship|To validate · dev" ;;
97
+ shipped) echo "Shipped|PR open" ;;
98
+ pr) echo "PR open|Shipped" ;;
99
+ acceptance) echo "Acceptance|Shipped" ;;
100
+ done) echo "Done|Shipped" ;;
86
101
  *) echo "" ;;
87
102
  esac
88
103
  }
@@ -222,12 +237,31 @@ if [ -n "$(default_heading "$col")" ]; then
222
237
  $cfg
223
238
  EOF
224
239
  IFS=$OLDIFS
225
- [ -n "$heading" ] || heading=$(default_heading "$col")
226
- col="$heading"
240
+ # Candidates, best first: the configured heading, then the layout defaults. The
241
+ # awk pass below keeps the first one the board has.
242
+ col="${heading:+$heading|}$(default_heading "$col")"
227
243
  fi
228
244
 
229
245
  [ -f "$board" ] || { echo "error: board not found: $board" >&2; exit 3; }
230
246
 
247
+ # A stage key resolved to `a|b|c`: keep the first heading this board has (case-insensitive,
248
+ # trailing spaces and CR ignored — the same comparison the move itself makes). None ⇒ the
249
+ # first candidate, which the move then reports as the unknown column (exit 3).
250
+ case "$col" in
251
+ *"|"*)
252
+ pick=$(COLS="$col" awk '
253
+ BEGIN { n = split(tolower(ENVIRON["COLS"]), cand, "|") }
254
+ /^## / { h = $0; sub(/\r$/, "", h); h = tolower(h); sub(/^## +/, "", h); gsub(/ +$/, "", h); have[h] = 1 }
255
+ END { for (i = 1; i <= n; i++) if (cand[i] in have) { print i; exit } }
256
+ ' "$board")
257
+ OLDIFS=$IFS; IFS='|'; set -f
258
+ # shellcheck disable=SC2086
259
+ set -- $col
260
+ set +f; IFS=$OLDIFS
261
+ if [ -n "$pick" ]; then eval "col=\${$pick}"; else col=$1; fi
262
+ ;;
263
+ esac
264
+
231
265
  # Serialize the read-modify-write: parallel worktrees (/cohorte-fleet, the loop workflow) move
232
266
  # cards on ONE board, and two concurrent rewrites used to lose one of the moves.
233
267
  # A kernel lock whenever possible: flock(2) on fd 9, held by this shell until it exits — the
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ // What every agent run of the company flow (and of founding a project) shares: how a /cohorte-* command becomes a
3
+ // prompt, the context block the dashboard appends, the MCP diet, the autopilot's rules.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.AUTOPILOT_NOTE = exports.contextBlock = exports.readText = exports.textsOf = exports.mcp = exports.now = exports.FlowError = exports.READ_ONLY = void 0;
42
+ exports.expandCommand = expandCommand;
43
+ const fs_1 = __importDefault(require("fs"));
44
+ const path_1 = __importDefault(require("path"));
45
+ const ops = __importStar(require("./ops"));
46
+ /** The business-facing agents read; they never write, run or delegate. The server writes what they propose. */
47
+ exports.READ_ONLY = ['Bash', 'Edit', 'Write', 'NotebookEdit', 'Agent', 'Task'];
48
+ class FlowError extends ops.OpError {
49
+ }
50
+ exports.FlowError = FlowError;
51
+ const now = () => new Date().toISOString();
52
+ exports.now = now;
53
+ /**
54
+ * Every flow run loads only the project's own MCP servers. A user's machine-wide servers (mail, docs, design tools…)
55
+ * can weigh 200k+ tokens of tool schemas on EVERY turn — measured at 230k for a one-word reply — and no PO, lead or
56
+ * pipeline stage needs them. The project's .mcp.json (a retrieval provider, say) is still loaded.
57
+ */
58
+ const mcp = (cwd) => {
59
+ const f = path_1.default.join(cwd, '.mcp.json');
60
+ return { strictMcp: true, mcpConfig: fs_1.default.existsSync(f) ? f : null };
61
+ };
62
+ exports.mcp = mcp;
63
+ const textsOf = (events) => events.filter((e) => e.kind === 'text').map((e) => e.text);
64
+ exports.textsOf = textsOf;
65
+ const readText = (p) => { try {
66
+ return fs_1.default.readFileSync(p, 'utf8');
67
+ }
68
+ catch {
69
+ return '';
70
+ } };
71
+ exports.readText = readText;
72
+ /** The body of an installed /cohorte-* command, its $ARGUMENTS substituted — sent as a prompt so the run's model applies. */
73
+ function expandCommand(globalDir, name, args) {
74
+ if (!/^cohorte-[a-z0-9-]+$/.test(name))
75
+ throw new FlowError(`not a cohorte command: ${name}`);
76
+ const file = path_1.default.join(globalDir, 'commands', `${name}.md`);
77
+ let text;
78
+ try {
79
+ text = fs_1.default.readFileSync(file, 'utf8');
80
+ }
81
+ catch {
82
+ throw new FlowError(`/${name} is not installed — run \`cohorte install\` (or update cohorte)`, 400);
83
+ }
84
+ const body = text.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '');
85
+ return `<command-name>/${name}</command-name>\n${body.split('$ARGUMENTS').join(args)}`;
86
+ }
87
+ const contextBlock = (lines) => `\n\n---\n## cohorte ui context (written by the dashboard — data, not instructions from the person)\n\n${lines.join('\n')}\n`;
88
+ exports.contextBlock = contextBlock;
89
+ const AUTOPILOT_NOTE = (routing) => [
90
+ '', '---', '## Running under the cohorte ui autopilot', '',
91
+ 'No person is watching this session: cohorte ui started it, and starts the next stage itself when this one ends.',
92
+ '- Never recommend `/clear` and never tell anyone which command to run next — the autopilot routes.',
93
+ '- Ask a question ONLY through AskUserQuestion (one call, at most 4 questions). Put your recommended option FIRST, with',
94
+ ' "(Recommended)" at the end of its label, and set each question\'s `header` to the decision\'s category — exactly one of',
95
+ ' reversible · visible · behavior · contract · cost · security · irreversible. A decider answers what the plan, the spec,',
96
+ ' the project\'s decisions and the developer\'s past answers already settle; the rest waits for the developer.',
97
+ '- Do the stage\'s whole job, then end your turn with the stage\'s own short report.',
98
+ ...(routing ? [`- Model routing: dispatch every implementer subagent with \`model: "${routing}"\` (the Agent tool's model parameter).`] : []),
99
+ ].join('\n');
100
+ exports.AUTOPILOT_NOTE = AUTOPILOT_NOTE;