cohorte 4.0.0 → 4.1.1

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 CHANGED
@@ -7,6 +7,35 @@ short, user-facing, most recent first. One `## <version> — <YYYY-MM-DD>` secti
7
7
  > They are history and are deliberately not rewritten — every command gained a `cohorte-` prefix
8
8
  > in 2.0.0.
9
9
 
10
+ ## 4.1.1 — 2026-11-24
11
+
12
+ - **A malformed profile no longer switches checks off.** When the profile reader returned each nested
13
+ field as a JSON string, `/cohorte-review`, `/cohorte-loop`, `/cohorte-audit` and `/cohorte-refactor` read
14
+ `commands` and `contract` as plain text: preflight ran no check and the contract gate was off, with no
15
+ error. Those fields are now decoded.
16
+ - **No more gate denials on `<core>` scripts.** Workflow agents now resolve the core path once and write it
17
+ out literally, instead of running a command name held in a shell expression, which the gate refuses.
18
+
19
+ ## 4.1.0 — 2026-11-20
20
+
21
+ - **New project, from `cohorte ui`.** Start a project that does not exist yet — no terminal, no
22
+ `/cohorte-init-pipeline` by hand. **From an idea**: the product owner (`/cohorte-vision`) shapes the vision
23
+ and the first version's tickets, and the person with the idea validates it (→ `PRODUCT.md`). **From a
24
+ stack**: straight to the lead (`/cohorte-foundation`), who chooses the surfaces and the stack with the
25
+ developer — defaulting to what their other projects use, or following one of them (structure, tooling,
26
+ conventions; never its code) — and posts a foundations plan to approve.
27
+ - **The walking skeleton** (`/cohorte-scaffold`): every surface from its framework's official generator, one
28
+ trivial path through all of them, tests/lint/build green, compose, CI, README — committed. No feature: the
29
+ first version's tickets go through the normal flow. It may run the tools the approved plan names without
30
+ asking; anything else asks in the page. A failed skeleton is retried one model up.
31
+ - **The pipeline sets itself up**: `/cohorte-init-pipeline` runs right after, its interview answered by the
32
+ approved plan, and the result is committed. The first version's tickets land in the backlog.
33
+ - **A repository without cohorte** can now be set up from the dashboard too — the sidebar offers it instead of
34
+ refusing the folder.
35
+ - **The code host, when you want one**: Settings (and the Overview, until there is one) creates a GitHub
36
+ repository with `gh` or connects any empty repository by URL, points `PIPELINE.md`'s `vcs` at it, commits
37
+ and pushes. Never required.
38
+
10
39
  ## 4.0.0 — 2026-11-20
11
40
 
12
41
  - **The company flow, in `cohorte ui`.** The pipeline now runs the way a company runs work — the business
package/README.md CHANGED
@@ -59,7 +59,7 @@ hook: **your app code never imports anything from Cohorte.**
59
59
 
60
60
  | What | Holds | Lives in |
61
61
  | --- | --- | --- |
62
- | **The machine install** (`cohorte install`, once) | the 16 `/cohorte-*` commands, the `cohorte-review` / `cohorte-release` / `cohorte-profile-reader` agents, the workflow scripts, the generic core (templates, schema, scripts, the gate's source) — zero project facts | `~/.claude/commands/cohorte-*.md`, `~/.claude/agents/cohorte-*.md`, `~/.claude/workflows/cohorte-*.js`, `~/.claude/cohorte/` |
62
+ | **The machine install** (`cohorte install`, once) | the 26 `/cohorte-*` commands, the `cohorte-review` / `cohorte-release` / `cohorte-profile-reader` agents, the workflow scripts, the generic core (templates, schema, scripts, the gate's source) — zero project facts | `~/.claude/commands/cohorte-*.md`, `~/.claude/agents/cohorte-*.md`, `~/.claude/workflows/cohorte-*.js`, `~/.claude/cohorte/` |
63
63
  | **The project** (generated by `/cohorte-init-pipeline`, **committed**) | the profile (stack, surfaces, commands, conventions, gates), one implementer agent per surface, the gate hook and its registration, the version pointer, the specs | `PIPELINE.md`, `.claude/agents/<surface>.md`, `.claude/gate-config.json`, `.claude/hooks/cohorte-gate.py` + `.claude/settings.json`, `.claude/pipeline.json`, `.claude/profile.json`, `specs/` |
64
64
  | **You** | kanban board links + shared Obsidian vault path | `~/.claude/cohorte.config.yaml` |
65
65
 
@@ -241,6 +241,9 @@ suite locally.
241
241
  | `/cohorte-learn <id>` | Write the feature's journal entries — findings, red checks, corrections, contested decisions — for the retro to count. |
242
242
  | `/cohorte-acceptance <ticket>` | The acceptance note of a merged ticket, in the business's words (CP4). |
243
243
  | `/cohorte-product-map` | Write `PRODUCT.md` — what the product does, in business language — for the product owner. |
244
+ | `/cohorte-vision [idea]` | New project (company flow): the PO turns an idea into a vision and the first version's tickets. |
245
+ | `/cohorte-foundation [brief]` | New project: the lead chooses the stack with the developer — or follows one of their projects. |
246
+ | `/cohorte-scaffold` | New project: the walking skeleton from the approved plan — official generators, checks green, committed. |
244
247
  | `/cohorte-align-ds` | Align the code UI kit to the design system (no-op if none configured). |
245
248
  | `/cohorte-update-pipeline` | Refresh the machine install, re-wire this repo (`cohorte sync`) and reconcile its generated files. |
246
249
  | `/cohorte-doctor` | Diagnose the installation (core, agents↔surfaces, hooks, gate, retrieval, worktrees). |
@@ -369,7 +372,7 @@ lib/doctor.js # the JS port of /cohorte-doctor, + versions.js / yaml.j
369
372
  install.sh, install.ps1 # thin wrappers around bin/cli.js for installs without a global npm
370
373
  core/
371
374
  agents/ # implementer.template.md (rendered per surface) + cohorte-review / -release / -profile-reader
372
- commands/ # the 16 /cohorte-* commands
375
+ commands/ # the 26 /cohorte-* commands
373
376
  hooks/gate.py # the gate (copied into each project as .claude/hooks/cohorte-gate.py)
374
377
  hooks/gate/ # its source modules — gate.py is built from them (scripts/build-gate.mjs)
375
378
  templates/ # handoff / brainstorm-return / design-brief / review-feedback / pr-body / spec + step files
@@ -0,0 +1,90 @@
1
+ ---
2
+ description: The lead developer for a project that does not exist yet — chooses the stack with the developer and posts the foundations plan they approve before the skeleton is generated.
3
+ argument-hint: [what the developer wants to build, when there is no vision]
4
+ ---
5
+
6
+ You are the **lead developer** of a project that **does not exist yet**, talking with the developer who
7
+ starts it. The folder is empty (or holds only `PRODUCT.md`). With them you settle **how it will be
8
+ built** — the surfaces, the stack, the data, where it runs — so that once they approve your plan, an
9
+ agent can generate a working skeleton **without asking anything**. The developer's brief, when they
10
+ wrote one:
11
+
12
+ **$ARGUMENTS**
13
+
14
+ > You normally run inside `cohorte ui` ("New project"). A context block at the end of this prompt gives
15
+ > the vision the business validated (when there is one — else the brief above is all there is), the
16
+ > tools installed on this machine, the stacks of the developer's other projects, and — when they asked
17
+ > to start from one of them — that project's structure and conventions. Read `PRODUCT.md` if it exists.
18
+ > Do not explore the rest of the disk.
19
+
20
+ ## 1. Open with a proposal — not a questionnaire
21
+
22
+ In your first turn:
23
+
24
+ 1. what you understood must be built, in two lines — and anything in the vision that weighs on the stack
25
+ (offline use, phone first, payments, health data, real time, many languages, a hard deadline);
26
+ 2. **your proposed foundations**, as a short list with your reasoning where it is not obvious:
27
+ - the **surfaces** — the independently built parts (a web app, an API, a mobile app, a worker, a
28
+ shared contract package…), each with its folder, language, framework and test runner. As few as the
29
+ first version needs: one surface is a fine answer;
30
+ - **how each one is generated**: the framework's **official generator** (`npm create vite@latest`,
31
+ `npx create-next-app@latest`, `npx @nestjs/cli new`, `uv init`, `cargo new`, `go mod init`,
32
+ `flutter create`…), never a hand-written framework setup;
33
+ - the **data**: database (or none), how it runs in development (`docker compose`), the migration tool;
34
+ - **auth** when the vision needs accounts; **hosting** as a recommendation only (nothing is deployed);
35
+ - the **checks**: lint, format, type check, test runner, a CI workflow on GitHub Actions (it runs
36
+ wherever the repo is pushed later; harmless locally);
37
+ 3. **the decisions the developer must own**, each a concrete choice with your recommendation. Use
38
+ **AskUserQuestion** (recommended option first, labelled `(Recommended)`, `header` = its class:
39
+ `visible`, `cost`, `security`, `irreversible`…), a few per turn.
40
+
41
+ **Default to what the developer already uses.** The context lists the stacks of their other projects:
42
+ the same language, framework, package manager and test runner as their recent projects is the
43
+ recommendation unless the vision needs something else — say which project you followed. When they
44
+ asked to **start from one of their projects**, follow its structure, its surfaces' layout, its tooling
45
+ and its conventions (they are listed) — **never its business code**: nothing from that project is
46
+ copied except the shape.
47
+
48
+ Prefer boring, current, widely used choices. Pin nothing by hand: the generators install their own
49
+ current versions. Say when a choice costs money (a paid service) or is hard to undo (a database
50
+ engine): those are the developer's, explicitly.
51
+
52
+ ## 2. The skeleton — what "done" means
53
+
54
+ The plan you post is executed by `/cohorte-scaffold`, which builds a **walking skeleton**: every surface
55
+ generated and wired, one trivial path through all of them (the web page calls the API, which reads the
56
+ database, and shows the answer), each surface's tests and lint passing, `docker compose` for what runs
57
+ locally, a CI workflow, a README that says how to run it. **No feature of the vision** — the tickets do
58
+ that, one at a time, through the normal flow.
59
+
60
+ ## 3. Post the plan
61
+
62
+ When nothing the scaffold would have to ask remains open, end your turn with a short summary and exactly
63
+ one block — the dashboard renders it as the plan the developer approves:
64
+
65
+ ```cohorte-foundation
66
+ {"summary": "What the project will be made of, in 3–5 lines",
67
+ "surfaces": [{"key": "web", "path": "web", "stack": "React + TypeScript (Vite), Vitest",
68
+ "generate": "npm create vite@latest web -- --template react-ts",
69
+ "packageManager": "npm", "test": "npm test", "lint": "npm run lint", "build": "npm run build"}],
70
+ "data": "PostgreSQL 16 in docker compose, Prisma migrations — or 'none'",
71
+ "auth": "What and how — or 'none in the first version'",
72
+ "hosting": "A recommendation, nothing is deployed",
73
+ "devCommand": "The one command that starts everything locally, e.g. 'docker compose up -d && npm run dev'",
74
+ "ci": "GitHub Actions: lint + test + build per surface",
75
+ "basedOn": "The project it follows (structure, tooling, conventions), or null",
76
+ "conventions": ["Rules to carry into PIPELINE.md §Conventions from day one"],
77
+ "skeleton": "The one trivial path the skeleton proves end to end",
78
+ "decisions": ["What the developer chose in this conversation"],
79
+ "assumptions": ["What you assumed without asking, so they can veto it"],
80
+ "questions": []}
81
+ ```
82
+
83
+ - `questions` must be empty when you post it for approval — a non-empty list means you are still asking.
84
+ - `generate` is the exact command (run from the project root) — it must be non-interactive (pass the
85
+ flags that skip prompts: `--template`, `--yes`, `--skip-git`, `--package-manager`…). `null` when the
86
+ surface is a plain folder (a contract package, say).
87
+ - The JSON must parse: double quotes, no trailing commas, no comments.
88
+
89
+ If the developer replies instead of approving, revise and post a new block. When they approve, the
90
+ dashboard starts the scaffold itself: end your turn, write nothing, and never tell anyone to run a command.
@@ -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.
@@ -71,17 +71,24 @@ const PROFILE = {
71
71
  // return, or nested under a single wrapper field. Anything already shaped like a profile
72
72
  // (has `surfaces`, or is the documented `{error}` failure shape) passes through untouched.
73
73
  const unwrapProfile = p => {
74
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
75
- if (!p || typeof p !== 'object') return null
76
- if (Array.isArray(p.surfaces) || p.error) return p
77
- for (const v of Object.values(p)) {
78
- if (typeof v !== 'string') continue
74
+ // The reader may also serialize each nested value while keeping the top level.
75
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
76
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
79
77
  try {
80
- const inner = JSON.parse(v)
81
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
82
- } catch {}
78
+ const parsed = JSON.parse(v)
79
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
80
+ } catch { return [k, v] }
81
+ }))
82
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
83
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
84
+ const flat = decode(p)
85
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
86
+ for (const v of Object.values(flat)) {
87
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
88
+ const inner = decode(v)
89
+ if (Array.isArray(inner.surfaces)) return inner
83
90
  }
84
- return p
91
+ return flat
85
92
  }
86
93
 
87
94
  const GATES = {
@@ -152,17 +152,24 @@ const PROFILE = {
152
152
  },
153
153
  }
154
154
  const unwrapProfile = p => {
155
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
156
- if (!p || typeof p !== 'object') return null
157
- if (Array.isArray(p.surfaces) || p.error) return p
158
- for (const v of Object.values(p)) {
159
- if (typeof v !== 'string') continue
155
+ // The reader may also serialize each nested value while keeping the top level.
156
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
157
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
160
158
  try {
161
- const inner = JSON.parse(v)
162
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
163
- } catch {}
159
+ const parsed = JSON.parse(v)
160
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
161
+ } catch { return [k, v] }
162
+ }))
163
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
164
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
165
+ const flat = decode(p)
166
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
167
+ for (const v of Object.values(flat)) {
168
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
169
+ const inner = decode(v)
170
+ if (Array.isArray(inner.surfaces)) return inner
164
171
  }
165
- return p
172
+ return flat
166
173
  }
167
174
 
168
175
  // The precondition agent returns RAW FACTS (existence, mtimes, front-matter fields,
@@ -248,7 +255,7 @@ const spent = () => {
248
255
 
249
256
  // kanban-move.sh is optional infrastructure — every prompt that runs it defines <core>
250
257
  // and tolerates its absence, per profile/schema/kanban.md.
251
- const CORE_DEF = '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte" — ' +
258
+ const CORE_DEF = '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable — ' +
252
259
  'script absent ⇒ skip the kanban step, the board is optional.)'
253
260
  const METRICS_PATH = '$(dirname "$(git rev-parse --git-common-dir)")/.claude/pipeline-metrics.jsonl'
254
261
 
@@ -87,17 +87,24 @@ const PROFILE = {
87
87
  // return, or nested under a single wrapper field. Anything already shaped like a profile
88
88
  // (has `surfaces`, or is the documented `{error}` failure shape) passes through untouched.
89
89
  const unwrapProfile = p => {
90
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
91
- if (!p || typeof p !== 'object') return null
92
- if (Array.isArray(p.surfaces) || p.error) return p
93
- for (const v of Object.values(p)) {
94
- if (typeof v !== 'string') continue
90
+ // The reader may also serialize each nested value while keeping the top level.
91
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
92
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
95
93
  try {
96
- const inner = JSON.parse(v)
97
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
98
- } catch {}
94
+ const parsed = JSON.parse(v)
95
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
96
+ } catch { return [k, v] }
97
+ }))
98
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
99
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
100
+ const flat = decode(p)
101
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
102
+ for (const v of Object.values(flat)) {
103
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
104
+ const inner = decode(v)
105
+ if (Array.isArray(inner.surfaces)) return inner
99
106
  }
100
- return p
107
+ return flat
101
108
  }
102
109
 
103
110
  const OPEN = {
@@ -195,7 +202,7 @@ const implementPrompt = d =>
195
202
  'FIRST (pin current behavior / cover the entry points), watch them pass, THEN refactor to clear each ' +
196
203
  'item. Preserve current public behavior unless an item marks it a bug. Migrations stay additive. ' +
197
204
  `Need the current state of your tree? Compute it yourself: <core>/pipeline/scripts/feature-diff.sh --default ${base} --patch -- <your surface path> ` +
198
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"; never a bare git diff — it hides files you created). ' +
205
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable; never a bare git diff — it hides files you created). ' +
199
206
  'Lint + format before handoff; return the handoff in the format your agent instructions define. ' +
200
207
  'Backlog items for YOUR surface (self-contained — clear exactly these, reading only the files they name):\n' +
201
208
  d.items.join('\n')
@@ -351,7 +358,7 @@ if (wantSpec) {
351
358
  `3. \`git rev-parse --abbrev-ref HEAD\`: on ${base} ⇒ \`git switch -c ${prefix}ID\` (uncommitted work carries over); ` +
352
359
  `already on ${prefix}ID ⇒ keep it; any other branch ⇒ leave it and report it. ` +
353
360
  `4. \`<core>/pipeline/scripts/kanban-move.sh auto ID ready --title "[refactor] ${slug}"\` ` +
354
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"). ' +
361
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable). ' +
355
362
  'Return id (ID), branch (checked out now) and kanban (the line the script printed).\n' +
356
363
  `<<<SPEC\n${specText}SPEC`,
357
364
  { model: 'haiku', label: 'write-spec', schema: SPEC, effort: 'low' },
@@ -92,17 +92,24 @@ const PROFILE = {
92
92
  // return, or nested under a single wrapper field. Anything already shaped like a profile
93
93
  // (has `surfaces`, or is the documented `{error}` failure shape) passes through untouched.
94
94
  const unwrapProfile = p => {
95
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
96
- if (!p || typeof p !== 'object') return null
97
- if (Array.isArray(p.surfaces) || p.error) return p
98
- for (const v of Object.values(p)) {
99
- if (typeof v !== 'string') continue
95
+ // The reader may also serialize each nested value while keeping the top level.
96
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
97
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
100
98
  try {
101
- const inner = JSON.parse(v)
102
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
103
- } catch {}
99
+ const parsed = JSON.parse(v)
100
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
101
+ } catch { return [k, v] }
102
+ }))
103
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
104
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
105
+ const flat = decode(p)
106
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
107
+ for (const v of Object.values(flat)) {
108
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
109
+ const inner = decode(v)
110
+ if (Array.isArray(inner.surfaces)) return inner
104
111
  }
105
- return p
112
+ return flat
106
113
  }
107
114
 
108
115
  const PREFLIGHT = {
@@ -221,7 +228,7 @@ const pre = await agent(
221
228
  '`date +%s` (return that number as `epoch` — the run\'s wall-clock origin for the metrics line):\n' +
222
229
  `<core>/pipeline/scripts/preflight.sh ${preflightReport} ` +
223
230
  checks.map(shq).join(' ') + '\n' +
224
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte". ' +
231
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable. ' +
225
232
  'Script absent: run the quoted commands yourself, each appended to the same report file, stopping at the first failure.) ' +
226
233
  'Return pass=true only on a fully green run. On failure set pass=false, put the raw last 40 lines of the report ' +
227
234
  'in `tail` — verbatim, no summarizing — and in the same Bash call write the degraded machine verdict the ' +
@@ -250,7 +257,7 @@ const surfaceList = surfaces.map(s => `${s.key} → ${s.path}`).join(' · ') ||
250
257
  const FD = `<core>/pipeline/scripts/feature-diff.sh --default ${base}`
251
258
  const staged = await agent(
252
259
  `Stage the review inputs for cohorte feature ${feature}. Surfaces: ${surfaceList}. ` +
253
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte".) Never use a bare `git diff` — it misses untracked files.\n' +
260
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable.) Never use a bare `git diff` — it misses untracked files.\n' +
254
261
  `1. ONE call: ${FD} --numstat > specs/reports/${feature}.stat.txt — never print it. Non-zero exit or script ` +
255
262
  'absent ⇒ return `error` with its stderr line and an empty surfaces array, and do nothing else.\n' +
256
263
  '2. Group the changed paths (3rd tab-separated column) by surface path prefix with one awk; paths under no surface are the `shared` remainder — attach them to the most relevant surface.\n' +
@@ -426,7 +433,7 @@ const verdictJson = JSON.stringify({
426
433
  })
427
434
  const staging = await agent(
428
435
  `Stage a cohorte review report and its metrics, mechanically ` +
429
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"):\n' +
436
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable):\n' +
430
437
  `1. Write EXACTLY this content to specs/reports/${feature}.md (overwrite):\n<<<REPORT\n${reportBody}\nREPORT\n` +
431
438
  `2. Write EXACTLY this to specs/reports/${feature}.verdict.json (overwrite), substituting <ISO now> with ` +
432
439
  '`date -u +%Y-%m-%dT%H:%M:%SZ` and <FP> with the fingerprint — computed in Bash, never by hand: ' +
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/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": "4.0.0",
3
+ "version": "4.1.1",
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"