cohorte 4.0.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ 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.0 — 2026-11-20
11
+
12
+ - **New project, from `cohorte ui`.** Start a project that does not exist yet — no terminal, no
13
+ `/cohorte-init-pipeline` by hand. **From an idea**: the product owner (`/cohorte-vision`) shapes the vision
14
+ and the first version's tickets, and the person with the idea validates it (→ `PRODUCT.md`). **From a
15
+ stack**: straight to the lead (`/cohorte-foundation`), who chooses the surfaces and the stack with the
16
+ developer — defaulting to what their other projects use, or following one of them (structure, tooling,
17
+ conventions; never its code) — and posts a foundations plan to approve.
18
+ - **The walking skeleton** (`/cohorte-scaffold`): every surface from its framework's official generator, one
19
+ trivial path through all of them, tests/lint/build green, compose, CI, README — committed. No feature: the
20
+ first version's tickets go through the normal flow. It may run the tools the approved plan names without
21
+ asking; anything else asks in the page. A failed skeleton is retried one model up.
22
+ - **The pipeline sets itself up**: `/cohorte-init-pipeline` runs right after, its interview answered by the
23
+ approved plan, and the result is committed. The first version's tickets land in the backlog.
24
+ - **A repository without cohorte** can now be set up from the dashboard too — the sidebar offers it instead of
25
+ refusing the folder.
26
+ - **The code host, when you want one**: Settings (and the Overview, until there is one) creates a GitHub
27
+ repository with `gh` or connects any empty repository by URL, points `PIPELINE.md`'s `vcs` at it, commits
28
+ and pushes. Never required.
29
+
10
30
  ## 4.0.0 — 2026-11-20
11
31
 
12
32
  - **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.
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.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"
@@ -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;