@smartmemory/compose 0.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 (181) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1014 -0
  3. package/bin/compose.js +1515 -0
  4. package/dist/assets/_baseUniq-CQwX6VLz.js +1 -0
  5. package/dist/assets/arc-SxJ2J1sh.js +1 -0
  6. package/dist/assets/architectureDiagram-Q4EWVU46-BykunY1F.js +36 -0
  7. package/dist/assets/blockDiagram-DXYQGD6D-ohAKBOUw.js +132 -0
  8. package/dist/assets/c4Diagram-AHTNJAMY-DBDC3ENB.js +10 -0
  9. package/dist/assets/channel-DGElom1e.js +1 -0
  10. package/dist/assets/chunk-4BX2VUAB-Cv93Z7uM.js +1 -0
  11. package/dist/assets/chunk-4TB4RGXK-DE0WBDkj.js +206 -0
  12. package/dist/assets/chunk-55IACEB6-CE1EXenG.js +1 -0
  13. package/dist/assets/chunk-EDXVE4YY-DA7Ana6H.js +1 -0
  14. package/dist/assets/chunk-FMBD7UC4-CTDIPA3p.js +15 -0
  15. package/dist/assets/chunk-OYMX7WX6-uGBaPaTX.js +231 -0
  16. package/dist/assets/chunk-QZHKN3VN-CYlnXuUO.js +1 -0
  17. package/dist/assets/chunk-YZCP3GAM-ojGkzcZK.js +1 -0
  18. package/dist/assets/classDiagram-6PBFFD2Q-KqWP9wWZ.js +1 -0
  19. package/dist/assets/classDiagram-v2-HSJHXN6E-KqWP9wWZ.js +1 -0
  20. package/dist/assets/clone-DUJKJXd7.js +1 -0
  21. package/dist/assets/cose-bilkent-S5V4N54A-Bktn9hL-.js +1 -0
  22. package/dist/assets/dagre-KV5264BT-DFaSzuRF.js +4 -0
  23. package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  24. package/dist/assets/diagram-5BDNPKRD-DnfmDzEm.js +10 -0
  25. package/dist/assets/diagram-G4DWMVQ6-Bm8W9YnG.js +24 -0
  26. package/dist/assets/diagram-MMDJMWI5-B5-TSKvp.js +43 -0
  27. package/dist/assets/diagram-TYMM5635-ls4rqlky.js +24 -0
  28. package/dist/assets/erDiagram-SMLLAGMA-giG6WO-r.js +85 -0
  29. package/dist/assets/flowDiagram-DWJPFMVM-XvlUuz-7.js +162 -0
  30. package/dist/assets/ganttDiagram-T4ZO3ILL-hLBV57oV.js +292 -0
  31. package/dist/assets/gitGraphDiagram-UUTBAWPF-BHu3s_Gn.js +106 -0
  32. package/dist/assets/graph-D0Cfv00Y.js +1 -0
  33. package/dist/assets/index-CUd6pFGF.css +1 -0
  34. package/dist/assets/index-DReRlzZI.js +1144 -0
  35. package/dist/assets/infoDiagram-42DDH7IO-DbqRsOo3.js +2 -0
  36. package/dist/assets/init-Gi6I4Gst.js +1 -0
  37. package/dist/assets/ishikawaDiagram-UXIWVN3A-DnCdx7zb.js +70 -0
  38. package/dist/assets/journeyDiagram-VCZTEJTY-CfD7eNcP.js +139 -0
  39. package/dist/assets/kanban-definition-6JOO6SKY-BYaO9-mK.js +89 -0
  40. package/dist/assets/katex-DkKDou_j.js +257 -0
  41. package/dist/assets/layout-Bj72wOEB.js +1 -0
  42. package/dist/assets/linear-BRFo114D.js +1 -0
  43. package/dist/assets/min-GCHnKlJS.js +1 -0
  44. package/dist/assets/mindmap-definition-QFDTVHPH-n0PMebY4.js +96 -0
  45. package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  46. package/dist/assets/pieDiagram-DEJITSTG-pN4CljHF.js +30 -0
  47. package/dist/assets/quadrantDiagram-34T5L4WZ-DNoAy8-D.js +7 -0
  48. package/dist/assets/requirementDiagram-MS252O5E-BhtY05PT.js +84 -0
  49. package/dist/assets/sankeyDiagram-XADWPNL6-B6AD-16A.js +10 -0
  50. package/dist/assets/sequenceDiagram-FGHM5R23-DShHM-uk.js +157 -0
  51. package/dist/assets/stateDiagram-FHFEXIEX-DMxn7HTo.js +1 -0
  52. package/dist/assets/stateDiagram-v2-QKLJ7IA2-o6PnCs4e.js +1 -0
  53. package/dist/assets/timeline-definition-GMOUNBTQ-Cdu6uq52.js +120 -0
  54. package/dist/assets/vennDiagram-DHZGUBPP-CpK29iRe.js +34 -0
  55. package/dist/assets/wardley-RL74JXVD-BQgSkdcO.js +162 -0
  56. package/dist/assets/wardleyDiagram-NUSXRM2D-DJHYev6O.js +20 -0
  57. package/dist/assets/xychartDiagram-5P7HB3ND-1d75pbaO.js +7 -0
  58. package/dist/index.html +30 -0
  59. package/lib/agent-chains.js +65 -0
  60. package/lib/agent-string.js +86 -0
  61. package/lib/budget-ledger.js +86 -0
  62. package/lib/build-all.js +162 -0
  63. package/lib/build-dag.js +120 -0
  64. package/lib/build-stream-writer.js +190 -0
  65. package/lib/build.js +2997 -0
  66. package/lib/capability-checker.js +53 -0
  67. package/lib/cert-inject.js +38 -0
  68. package/lib/cli-progress.js +483 -0
  69. package/lib/constants.js +69 -0
  70. package/lib/cross-layer-audit.js +84 -0
  71. package/lib/debug-discipline.js +173 -0
  72. package/lib/feature-json.js +106 -0
  73. package/lib/gate-prompt.js +291 -0
  74. package/lib/gate-tiers.js +194 -0
  75. package/lib/health-history.js +119 -0
  76. package/lib/health-score.js +227 -0
  77. package/lib/ideabox.js +570 -0
  78. package/lib/import.js +244 -0
  79. package/lib/migrate-roadmap.js +94 -0
  80. package/lib/model-pricing.js +67 -0
  81. package/lib/new.js +413 -0
  82. package/lib/pipeline-cli.js +489 -0
  83. package/lib/plan-parser.js +103 -0
  84. package/lib/qa-scoping.js +474 -0
  85. package/lib/questionnaire.js +200 -0
  86. package/lib/resolve-port.js +7 -0
  87. package/lib/result-normalizer.js +349 -0
  88. package/lib/review-lenses.js +166 -0
  89. package/lib/roadmap-gen.js +210 -0
  90. package/lib/roadmap-parser.js +176 -0
  91. package/lib/server-probe.js +23 -0
  92. package/lib/staleness.js +87 -0
  93. package/lib/step-prompt.js +260 -0
  94. package/lib/step-validator.js +49 -0
  95. package/lib/stratum-mcp-client.js +365 -0
  96. package/lib/team-flag.js +46 -0
  97. package/lib/test-bootstrap.js +401 -0
  98. package/lib/triage.js +274 -0
  99. package/lib/vision-writer.js +391 -0
  100. package/package.json +111 -0
  101. package/pipelines/bug-fix.stratum.yaml +230 -0
  102. package/pipelines/build.stratum.yaml +498 -0
  103. package/pipelines/content.stratum.yaml +112 -0
  104. package/pipelines/coverage-sweep.stratum.yaml +52 -0
  105. package/pipelines/refactor.stratum.yaml +169 -0
  106. package/pipelines/research.stratum.yaml +88 -0
  107. package/pipelines/review-fix.stratum.yaml +109 -0
  108. package/presets/team-feature.stratum.yaml +105 -0
  109. package/presets/team-research.stratum.yaml +108 -0
  110. package/presets/team-review.stratum.yaml +106 -0
  111. package/scripts/agent-activity-hook.sh +31 -0
  112. package/scripts/agent-error-hook.sh +28 -0
  113. package/scripts/analyze-orphans.mjs +50 -0
  114. package/scripts/find-orphans.mjs +26 -0
  115. package/scripts/fix-phases.mjs +49 -0
  116. package/scripts/generate-stratum-spec.mjs +137 -0
  117. package/scripts/import-roadmap.mjs +116 -0
  118. package/scripts/phase-audit.mjs +33 -0
  119. package/scripts/run-pipeline.mjs +314 -0
  120. package/scripts/session-end-hook.sh +18 -0
  121. package/scripts/session-start-hook.sh +38 -0
  122. package/scripts/vision-hook.sh +104 -0
  123. package/scripts/vision-track.mjs +554 -0
  124. package/scripts/wire-all-orphans.mjs +108 -0
  125. package/scripts/wire-orphans.mjs +164 -0
  126. package/server/activity-routes.js +123 -0
  127. package/server/agent-health.js +197 -0
  128. package/server/agent-hooks.js +102 -0
  129. package/server/agent-mcp.js +10 -0
  130. package/server/agent-registry.js +95 -0
  131. package/server/agent-server.js +290 -0
  132. package/server/agent-spawn.js +251 -0
  133. package/server/agent-templates.js +77 -0
  134. package/server/artifact-manager.js +247 -0
  135. package/server/artifact-templates/architecture.md +28 -0
  136. package/server/artifact-templates/blueprint.md +21 -0
  137. package/server/artifact-templates/design.md +36 -0
  138. package/server/artifact-templates/plan.md +25 -0
  139. package/server/artifact-templates/prd.md +43 -0
  140. package/server/artifact-templates/report.md +40 -0
  141. package/server/block-tracker.js +90 -0
  142. package/server/build-stream-bridge.js +502 -0
  143. package/server/coalescing-buffer.js +46 -0
  144. package/server/compose-mcp-tools.js +479 -0
  145. package/server/compose-mcp.js +324 -0
  146. package/server/connectors/agent-connector.js +78 -0
  147. package/server/connectors/claude-sdk-connector.js +198 -0
  148. package/server/connectors/codex-connector.js +240 -0
  149. package/server/connectors/connector-discovery.js +18 -0
  150. package/server/connectors/connector-runtime.js +13 -0
  151. package/server/connectors/opencode-connector.js +200 -0
  152. package/server/design-routes.js +540 -0
  153. package/server/design-session.js +161 -0
  154. package/server/feature-scan.js +593 -0
  155. package/server/file-watcher.js +284 -0
  156. package/server/find-root.js +29 -0
  157. package/server/graph-export.js +343 -0
  158. package/server/ideabox-cache.js +77 -0
  159. package/server/ideabox-routes.js +294 -0
  160. package/server/index.js +156 -0
  161. package/server/model-tiers.js +49 -0
  162. package/server/pipeline-routes.js +288 -0
  163. package/server/policy-evaluator.js +36 -0
  164. package/server/project-root.js +122 -0
  165. package/server/security.js +23 -0
  166. package/server/session-manager.js +403 -0
  167. package/server/session-routes.js +190 -0
  168. package/server/session-store.js +107 -0
  169. package/server/settings-routes.js +35 -0
  170. package/server/settings-store.js +234 -0
  171. package/server/stratum-api.js +102 -0
  172. package/server/stratum-client.js +192 -0
  173. package/server/stratum-sync.js +193 -0
  174. package/server/summarizer.js +139 -0
  175. package/server/supervisor.js +196 -0
  176. package/server/vision-routes.js +668 -0
  177. package/server/vision-server.js +393 -0
  178. package/server/vision-store.js +360 -0
  179. package/server/vision-utils.js +179 -0
  180. package/server/worktree-gc.js +137 -0
  181. package/templates/ROADMAP.md +46 -0
package/README.md ADDED
@@ -0,0 +1,1014 @@
1
+ # Compose
2
+
3
+ AI-powered product lifecycle orchestrator. Compose takes a product idea from intent to shipped code through structured, agent-driven pipelines with human gates at every critical decision point.
4
+
5
+ Compose coordinates multiple AI agents (Claude, Codex) through YAML-defined workflows powered by [Stratum](https://github.com/regression-io/stratum), enforcing postconditions, retrying on failure, and producing auditable execution traces.
6
+
7
+ ## Table of Contents
8
+
9
+ - [How It Works](#how-it-works)
10
+ - [Installation and Setup](#installation-and-setup)
11
+ - [CLI Commands](#cli-commands)
12
+ - [Web UI — Cockpit Shell](#web-ui--cockpit-shell)
13
+ - [The Kickoff Pipeline (new)](#the-kickoff-pipeline)
14
+ - [The Build Pipeline (build)](#the-build-pipeline)
15
+ - [Agent Connectors](#agent-connectors)
16
+ - [Questionnaire System](#questionnaire-system)
17
+ - [Gate System](#gate-system)
18
+ - [Validation System](#validation-system)
19
+ - [Pipeline CLI](#pipeline-cli)
20
+ - [Recovery Logic](#recovery-logic)
21
+ - [Progress Logging](#progress-logging)
22
+ - [Result Normalization and JSON Extraction](#result-normalization-and-json-extraction)
23
+ - [Vision Writer Integration](#vision-writer-integration)
24
+ - [Configuration Files](#configuration-files)
25
+ - [MCP Server](#mcp-server)
26
+ - [Pipeline Specs](#pipeline-specs)
27
+ - [Examples and Workflows](#examples-and-workflows)
28
+
29
+ ---
30
+
31
+ ## How It Works
32
+
33
+ Compose is a CLI that orchestrates AI agents through multi-step workflows defined in `.stratum.yaml` pipeline specs. Each step dispatches a prompt to an agent (Claude or Codex), collects the result, validates postconditions, and advances to the next step. Human gates pause the pipeline for approve/revise/kill decisions. If postconditions fail, Compose runs a fix pass with a different agent and retries.
34
+
35
+ ![Compose Cockpit Shell](Screenshot.png)
36
+
37
+ ```
38
+ compose new "REST API for todo lists"
39
+ -> questionnaire (interactive)
40
+ -> research (claude)
41
+ -> brainstorm (claude)
42
+ -> [human gate] approve/revise/kill
43
+ -> roadmap (claude)
44
+ -> [human gate]
45
+ -> scaffold (claude)
46
+ -> done: feature folders + ROADMAP.md ready
47
+
48
+ compose build FEAT-1
49
+ -> explore & design (claude)
50
+ -> [human gate]
51
+ -> blueprint (claude)
52
+ -> verification (claude)
53
+ -> plan (claude)
54
+ -> [human gate]
55
+ -> decompose + parallel execute (claude, worktree isolation)
56
+ -> parallel review (claude lenses: diff-quality, contract, security, framework)
57
+ -> codex review (codex) + fix loop
58
+ -> coverage sweep (claude) + fix loop
59
+ -> docs update (claude)
60
+ -> ship (claude)
61
+ -> [human gate]
62
+ -> done: feature implemented, reviewed, tested, documented
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Installation and Setup
68
+
69
+ ### Prerequisites
70
+
71
+ - Node.js 18+
72
+ - `stratum-mcp` on PATH (`pip install stratum`)
73
+ - For Codex steps: the official OpenAI `codex` CLI (`npm i -g @openai/codex` or `brew install codex`), authenticated via `codex login` (ChatGPT OAuth) or `OPENAI_API_KEY`. Optional: install the Claude Code plugin for interactive slash commands: `/plugin marketplace add openai/codex-plugin-cc` then `/plugin install codex@openai-codex`.
74
+
75
+ ### Install Compose
76
+
77
+ ```bash
78
+ git clone https://github.com/regression-io/compose.git
79
+ cd compose
80
+ npm install
81
+ ```
82
+
83
+ ### Project-local setup (`compose init`)
84
+
85
+ Run from inside your project directory:
86
+
87
+ ```bash
88
+ cd /path/to/your/project
89
+ npx compose init
90
+ ```
91
+
92
+ This:
93
+ 1. Creates `.compose/` directory with `compose.json` config
94
+ 2. Creates `.compose/data/` for vision state
95
+ 3. Detects installed agents (Claude, Codex, Gemini)
96
+ 4. Registers `compose-mcp` in `.mcp.json`
97
+ 5. Scaffolds `ROADMAP.md` from template (if absent)
98
+ 6. Copies default pipeline specs to `pipelines/`
99
+ 7. Installs the Stratum skill to detected agents
100
+
101
+ Flags:
102
+ - `--no-stratum` -- disable Stratum integration
103
+ - `--no-lifecycle` -- disable lifecycle tracking
104
+
105
+ ### Global setup (`compose setup`)
106
+
107
+ Installs the `/compose` skill globally and registers `stratum-mcp`:
108
+
109
+ ```bash
110
+ npx compose setup
111
+ ```
112
+
113
+ This:
114
+ 1. Copies the `/compose` skill to `~/.claude/skills/compose/`
115
+ 2. Installs the Stratum skill to all detected agents
116
+ 3. Registers `stratum-mcp` with Claude Code (if available)
117
+
118
+ ### Global CLI via ~/bin
119
+
120
+ To use `compose` as a global command:
121
+
122
+ ```bash
123
+ ln -s /path/to/compose/bin/compose.js ~/bin/compose
124
+ chmod +x ~/bin/compose
125
+ ```
126
+
127
+ ### Backwards compatibility
128
+
129
+ `compose install` runs both `init` and `setup` in sequence.
130
+
131
+ ---
132
+
133
+ ## CLI Commands
134
+
135
+ ### `compose new`
136
+
137
+ Kickoff a new product. Runs the full kickoff pipeline: research, brainstorm, roadmap, and scaffold.
138
+
139
+ ```bash
140
+ compose new "Structured log analyzer CLI for JSON-lines files"
141
+ compose new "REST API for managing team todo lists" --auto
142
+ compose new "OAuth2 provider library" --ask
143
+ ```
144
+
145
+ **Arguments:**
146
+ - First argument: product description (quoted string)
147
+ - `--auto` -- skip the questionnaire entirely
148
+ - `--ask` -- re-run the questionnaire (uses previous answers as defaults)
149
+
150
+ Auto-initializes the project if `.compose/` doesn't exist. Reads existing context from `README.md`, `package.json`, `pyproject.toml`, `Cargo.toml`, and any prior `project-analysis.md` from `compose import`.
151
+
152
+ ### `compose import`
153
+
154
+ Scan an existing project and generate a structured analysis at `docs/discovery/project-analysis.md`.
155
+
156
+ ```bash
157
+ cd existing-project
158
+ compose import
159
+ ```
160
+
161
+ Walks the file tree (max depth 4, ignoring `node_modules`, `.git`, etc.), reads key files (`README.md`, `package.json`, config files, top-level source files), and dispatches Claude to produce:
162
+ - Project overview (what it does, language, maturity)
163
+ - Architecture map
164
+ - Feature inventory with suggested codes
165
+ - Patterns and conventions
166
+ - Gaps and opportunities
167
+ - Suggested roadmap
168
+
169
+ The generated analysis is automatically consumed by `compose new` and `compose build` as context.
170
+
171
+ ### `compose feature`
172
+
173
+ Add a single feature to the project with a folder structure, seed design doc, and ROADMAP entry.
174
+
175
+ ```bash
176
+ compose feature LOG-1 "CLI tool for parsing JSON-lines log files"
177
+ compose feature AUTH-2 "Add OAuth2 login flow with PKCE"
178
+ ```
179
+
180
+ Creates:
181
+ - `docs/features/<CODE>/design.md` -- seed design doc with status, date, intent
182
+ - Appends a row to `ROADMAP.md` with the feature code and PLANNED status
183
+ - Updates the project description in ROADMAP if still placeholder
184
+
185
+ ### `compose build`
186
+
187
+ Run a feature through the headless build lifecycle. This is the main execution command.
188
+
189
+ ```bash
190
+ compose build FEAT-1
191
+ compose build --abort # abort the active build
192
+ compose build FEAT-1 --abort # abort a specific feature's build
193
+ ```
194
+
195
+ Loads `pipelines/build.stratum.yaml`, starts a Stratum flow, and dispatches each step to the appropriate agent. Tracks active build state in `.compose/data/active-build.json` for resume/abort support. Only one build can be active at a time.
196
+
197
+ ### `compose pipeline`
198
+
199
+ View and edit the build pipeline spec (`pipelines/build.stratum.yaml`).
200
+
201
+ ```bash
202
+ compose pipeline show
203
+ compose pipeline set <step> --agent codex
204
+ compose pipeline set <step> --mode gate
205
+ compose pipeline set <step> --mode review
206
+ compose pipeline set <step> --retries 5
207
+ compose pipeline add --id lint --after execute --agent claude --intent "Run linter"
208
+ compose pipeline remove <step>
209
+ compose pipeline enable <step> [step...]
210
+ compose pipeline disable <step> [step...]
211
+ ```
212
+
213
+ See [Pipeline CLI](#pipeline-cli) for full details.
214
+
215
+ ### `compose init`
216
+
217
+ Project-local initialization. Creates `.compose/`, detects agents, registers MCP server, scaffolds ROADMAP and pipeline specs.
218
+
219
+ ```bash
220
+ compose init
221
+ compose init --no-stratum
222
+ compose init --no-lifecycle
223
+ ```
224
+
225
+ ### `compose setup`
226
+
227
+ Global skill and MCP registration. Installs the `/compose` skill and Stratum skill to all detected agents.
228
+
229
+ ```bash
230
+ compose setup
231
+ ```
232
+
233
+ ### `compose start`
234
+
235
+ Start the Compose app (supervisor with web UI, terminal, and API server).
236
+
237
+ ```bash
238
+ compose start
239
+ COMPOSE_TARGET=/path/to/project compose start
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Web UI — Cockpit Shell
245
+
246
+ `compose start` opens a browser-based cockpit at `http://localhost:3001`. The layout is organized around three zoom levels: Graph (macro), Tree (meso), and Detail (micro).
247
+
248
+ ```
249
+ ┌──────────────────────────────────────────────────────────────┐
250
+ │ Header │ [Graph | Tree | Docs | Gates | Pipeline | Sessions] │
251
+ ├─────────┬──────────────────────────┬─────────────────────────┤
252
+ │ │ │ │
253
+ │ Sidebar │ MAIN AREA │ CONTEXT PANEL │
254
+ │ (~200px)│ (graph / tree / docs) │ (resizable, ~420px) │
255
+ │ │ │ │
256
+ ├─────────┴──────────────────────────┴─────────────────────────┤
257
+ │ OPS STRIP (active builds · pending gates · errors) │
258
+ ├──────────────────────────────────────────────────────────────┤
259
+ │ AGENT BAR (collapsed | expanded | maximized) │
260
+ ├──────────────────────────────────────────────────────────────┤
261
+ │ GATE NOTIFICATION BAR (hidden when no pending gates) │
262
+ └──────────────────────────────────────────────────────────────┘
263
+ ```
264
+
265
+ ### Zones
266
+
267
+ | Zone | Component | Description |
268
+ |------|-----------|-------------|
269
+ | **Header** | `ViewTabs` | Tab switcher for Graph, Tree, Docs, Gates, Pipeline, Sessions. Font/theme controls. |
270
+ | **Sidebar** | `AttentionQueueSidebar` | Build status, attention queue (blocked/gate items), search, group filters by feature code prefix. |
271
+ | **Main Area** | driven by active tab | Graph (fcose layout with compound grouping), Tree (search + filters), Docs (file browser + preview), and ops views. |
272
+ | **Context Panel** | `ContextPanel` | Resizable right panel with tabbed detail: Overview, Pipeline dots, Sessions, Errors, Files. Project summary when nothing selected. |
273
+ | **Ops Strip** | `OpsStrip` | Persistent 36px bar with scrollable pills for active builds, pending gates (inline approve), and recent errors. Hidden in Docs view. |
274
+ | **Agent Bar** | `AgentBar` | Always-present bottom panel for the agent stream. Collapsed/expanded/maximized. |
275
+ | **Gate Notification** | `GateNotificationBar` | Carousel of pending gates with Approve/Revise/Kill. |
276
+
277
+ ### Graph View
278
+
279
+ Uses `cytoscape-fcose` (force-directed with compound node support):
280
+
281
+ - **Compound grouping** by feature code prefix (COMP-UX, STRAT-ENG, etc.). Groups sorted by active item count.
282
+ - **Status filters**: All, Active (default), Done, Blocked.
283
+ - **Group filters** in sidebar — click to hide/show per feature group.
284
+ - **Build state overlays**: building (blue pulse), gate-pending (amber), blocked-downstream (dimmed 35%), error (red).
285
+ - **Badge overlays**: gate badge with approve/revise/kill popover, error badge, agent badge.
286
+ - **Selection**: click to highlight dependency chain. Cross-view navigation via context panel links.
287
+
288
+ ### Context Panel
289
+
290
+ Tabbed detail surface (5 tabs: Overview, Pipeline, Sessions, Errors, Files). Resizable via drag handle (min 280px, max 60% viewport), persisted in `localStorage`. Shows project summary when nothing selected.
291
+
292
+ ### Ops Strip
293
+
294
+ Persistent 36px bar with three entry types (blue build pills, amber gate pills with inline approve, red error pills). Completed builds flash green 2s. Hidden in Docs view.
295
+
296
+ ### Sidebar
297
+
298
+ Build status, attention queue (blocked + pending gates), search, and group filters (feature code prefix groups sorted by active count, click to toggle).
299
+
300
+ ### Agent Bar
301
+
302
+ Three states: collapsed (~36px status line), expanded (message stream + chat), maximized (fills main area). Sending a message with a feature code auto-selects that feature.
303
+
304
+ ### Cross-View Navigation
305
+
306
+ Selection persists across view switches. Graph pans to selected node, Tree scrolls to selected row. "View in Graph" / "View in Tree" links in context panel. File click opens DocsView with back button.
307
+
308
+ ### State Persistence
309
+
310
+ | `localStorage` key | Default |
311
+ |--------------------|---------|
312
+ | `compose:activeView` | `'graph'` |
313
+ | `compose:agentBarState` | `'collapsed'` |
314
+ | `compose:contextPanel` | `'open'` |
315
+ | `compose:contextWidthPx` | `420` |
316
+ | `compose:fontSize` | `13` |
317
+ | `compose:theme` | system |
318
+
319
+ ### Error Boundaries
320
+
321
+ `SafeModeBoundary` wraps the full shell. Each zone has a `PanelErrorBoundary` — a crash in one zone does not take down the rest.
322
+
323
+ ---
324
+
325
+ ## The Kickoff Pipeline
326
+
327
+ Defined in `pipelines/new.stratum.yaml`. Orchestrates product creation from intent to scaffolded feature folders.
328
+
329
+ ### Steps
330
+
331
+ | # | Step | Agent | What It Does |
332
+ |---|------|-------|-------------|
333
+ | 1 | `research` | claude | Searches for prior art, existing tools, architectural patterns, risks. Writes to `docs/discovery/research.md`. Validated against criteria (>= 2 prior art entries, patterns, risks). |
334
+ | 2 | `brainstorm` | claude | Generates feature list with codes, user stories, 2-3 architecture options with trade-offs. Writes to `docs/discovery/brainstorm.md`. Validated (>= 3 features, user stories, architecture options). |
335
+ | 3 | `review_gate` | human | Gate: approve brainstorm, revise (loop back to brainstorm), or kill. Displays the brainstorm artifact for review. Timeout: 2 hours. |
336
+ | 4 | `roadmap` | claude | Structures brainstorm into phased ROADMAP.md with feature table. Validated (markdown table, phased features, PLANNED status). |
337
+ | 5 | `roadmap_gate` | human | Gate: approve roadmap, revise, or kill. Timeout: 1 hour. |
338
+ | 6 | `scaffold` | claude | Creates `docs/features/<CODE>/design.md` for each ROADMAP feature with seed content. |
339
+
340
+ ### Contracts
341
+
342
+ - `ResearchResult`: `{ priorArt, patterns, risks, summary }`
343
+ - `BrainstormResult`: `{ features, userStories, archOptions, summary }`
344
+ - `RoadmapResult`: `{ phases, features, summary, artifact }`
345
+ - `ScaffoldResult`: `{ created, summary }`
346
+
347
+ ### Skipping Research
348
+
349
+ The questionnaire can disable research. When skipped, the `research` step gets `skip_if: "true"` injected into the spec before planning.
350
+
351
+ ---
352
+
353
+ ## The Build Pipeline
354
+
355
+ Defined in `pipelines/build.stratum.yaml`. Executes a feature through the full development lifecycle.
356
+
357
+ ### Steps
358
+
359
+ | # | Step | Agent | What It Does |
360
+ |---|------|-------|-------------|
361
+ | 1 | `explore_design` | claude | Explores codebase, writes design doc to `docs/features/{code}/design.md` |
362
+ | 2 | `scope` | claude | Scope the feature, identify boundaries |
363
+ | 3 | `design_gate` | human | Approve design, revise (loop to explore_design), or kill |
364
+ | 4 | `prd` | claude | Write PRD. **Skipped by default** -- enable via `compose pipeline enable prd` |
365
+ | 5 | `architecture` | claude | Architecture doc with competing proposals. **Skipped by default** |
366
+ | 6 | `blueprint` | claude | Implementation blueprint with file:line references. Retries: 3 |
367
+ | 7 | `verification` | claude | Verify all blueprint references against actual code. `on_fail: blueprint` loops back if stale |
368
+ | 8 | `plan_gate` | human | Approve plan, revise (loop to plan), or kill |
369
+ | 9 | `decompose` | claude | Decompose plan into independent subtasks with `files_owned`/`files_read` |
370
+ | 10 | `execute` | claude | Parallel dispatch: TDD implementation in isolated git worktrees per subtask |
371
+ | 11 | `review` | claude (sub-flow) | Parallel multi-lens review: triage → 2-4 specialized lenses → merge/dedup. Retries: 5 |
372
+ | 12 | `codex_review` | codex (sub-flow) | Independent cross-model review after Claude lenses + fixes. Retries: 3 |
373
+ | 13 | `coverage` | claude (sub-flow) | Run tests, fix failures, re-run. Retries: 15 |
374
+ | 14 | `report` | claude | Post-implementation report. **Skipped by default** |
375
+ | 15 | `docs` | claude | Update CHANGELOG, ROADMAP, README, CLAUDE.md, and public docs |
376
+ | 16 | `ship` | claude | Run tests, run build, verify docs, stage, commit, push |
377
+ | 17 | `ship_gate` | human | Final approval |
378
+
379
+ ### Sub-flows
380
+
381
+ **`parallel_review`** (STRAT-REV): Multi-lens review with three steps:
382
+ 1. **triage** (claude) — reads file list, activates relevant lenses (always: diff-quality + contract-compliance; conditional: security, framework). On retry, reads `.compose/prior_dirty_lenses.json` for selective re-review.
383
+ 2. **review_lenses** (parallel_dispatch, isolation: none) — fans out 2-4 lens agents concurrently. Each lens returns `LensFinding[]` with severity, file, line, confidence. Confidence gates and false-positive exclusion lists reduce noise.
384
+ 3. **merge** (claude) — deduplicates findings by file+issue, assigns severity (must-fix/should-fix/nit), classifies as auto-fix vs ask.
385
+
386
+ **`review_check`** (fallback): Single-step codex review. Returns `{ clean, summary, findings }`. Retries until `clean == true` (max 5). Cross-agent fix: claude fixes, codex re-reviews. Used by `codex_review` step.
387
+
388
+ **`coverage_check`**: Single-step test runner. Returns `{ passing, summary, failures }`. Retries until `passing == true` (max 15). Fix pass dispatched on failure.
389
+
390
+ ### Contracts
391
+
392
+ - `PhaseResult`: `{ phase, artifact, outcome, summary }` -- `outcome` is one of `complete`, `skipped`, `failed`
393
+ - `ReviewResult`: `{ clean, summary, findings }`
394
+ - `TestResult`: `{ passing, summary, failures }`
395
+ - `LensFinding`: `{ lens, file, line, severity, finding, confidence }` -- per-finding from a review lens
396
+ - `LensTask`: `{ id, lens_name, lens_focus, confidence_gate, exclusions }` -- triage output for lens dispatch
397
+ - `LensResult`: `{ clean, findings[] }` -- single lens output
398
+ - `TriageResult`: `{ tasks[] }` -- triage step output
399
+ - `MergedReviewResult`: `{ clean, summary, findings[], lenses_run[], auto_fixes[], asks[] }` -- merged review output
400
+ - `TaskGraph`: `{ tasks[] }` -- decompose output for parallel dispatch
401
+
402
+ ### on_fail Routing
403
+
404
+ The `verification` step has `on_fail: blueprint` -- when retries are exhausted without valid references, the pipeline routes back to the blueprint step for a rewrite.
405
+
406
+ ---
407
+
408
+ ## Agent Connectors
409
+
410
+ Compose dispatches work to AI agents through a connector abstraction. All connectors implement the same async generator interface yielding typed message envelopes.
411
+
412
+ ### Message Envelope
413
+
414
+ ```js
415
+ { type: 'system', subtype: 'init' | 'complete', agent: string, model?: string }
416
+ { type: 'assistant', content: string }
417
+ { type: 'tool_use', tool: string, input: object }
418
+ { type: 'tool_use_summary', summary: string }
419
+ { type: 'tool_progress', tool: string, elapsed: number }
420
+ { type: 'result', content: string }
421
+ { type: 'error', message: string }
422
+ ```
423
+
424
+ ### ClaudeSDKConnector
425
+
426
+ Wraps `@anthropic-ai/claude-agent-sdk`'s `query()` function. Default model: `claude-sonnet-4-6` (override via `CLAUDE_MODEL` env var). Runs in `acceptEdits` permission mode with full `claude_code` tool access.
427
+
428
+ Key behaviors:
429
+ - Strips `CLAUDECODE` env var to allow spawning nested Claude Code sessions
430
+ - Normalizes SDK messages (assistant content blocks, tool_use, deltas) into the shared envelope
431
+ - Supports `interrupt()` to abort the active query
432
+ - Schema injection via `injectSchema()` for structured output
433
+
434
+ ### CodexConnector
435
+
436
+ Spawns the official OpenAI `codex` CLI (`codex exec --json --skip-git-repo-check --sandbox read-only`), locked to OpenAI Codex models. Install via `npm i -g @openai/codex` (or `brew install codex`). Auth via `codex login` (ChatGPT OAuth) or `OPENAI_API_KEY` env var. Reasoning effort is passed via `-c model_reasoning_effort=<effort>` when the model ID carries a `/low|medium|high|xhigh` suffix.
437
+
438
+ Supported models: `gpt-5.4`, `gpt-5.2-codex`, `gpt-5.1-codex-max`, `gpt-5.1-codex`, `gpt-5.1-codex-mini` (with `/low`, `/medium`, `/high`, `/xhigh` effort suffixes). Default: `gpt-5.4` (override via `CODEX_MODEL` env var).
439
+
440
+ ### OpencodeConnector
441
+
442
+ Model-agnostic base for any non-Anthropic agent running through the OpenCode SDK. Manages a singleton `opencode serve` subprocess (one per process, shared across instances). Creates sessions, sends prompts, and streams SSE events.
443
+
444
+ ### AgentConnector (base class)
445
+
446
+ Abstract base with `run()`, `interrupt()`, and `isRunning`. Subclasses must implement `run()` as an async generator. Also exports `injectSchema(prompt, schema)` which appends JSON Schema instructions to prompts.
447
+
448
+ ### Agent Registry
449
+
450
+ The build runner maps agent names to connector factories:
451
+
452
+ ```
453
+ claude -> ClaudeSDKConnector
454
+ codex -> CodexConnector
455
+ ```
456
+
457
+ The connector factory is injectable for testing via `opts.connectorFactory`.
458
+
459
+ ---
460
+
461
+ ## Questionnaire System
462
+
463
+ Interactive pre-flight for `compose new`. Runs automatically on first invocation, then only with `--ask`. Skip entirely with `--auto`.
464
+
465
+ ### Questions Asked
466
+
467
+ 1. **Refine description** -- text input with previous answer as default
468
+ 2. **Project type** -- CLI tool, Web API, Library/SDK, Full-stack app, Other
469
+ 3. **Language/runtime** -- Node.js (JS), Node.js (TS), Python, Go, Rust, Other
470
+ 4. **Scope** -- Small (1-3 features), Medium (3-8), Large (8+)
471
+ 5. **Research** -- yes/no: research prior art before brainstorming?
472
+ 6. **Additional context** -- multiline free-form notes
473
+ 7. **Review agent** -- Human (gate prompt), Codex (automated review), Skip review
474
+ 8. **Confirm** -- summary + launch confirmation
475
+
476
+ ### Answer Persistence
477
+
478
+ Answers are saved to `.compose/questionnaire.json`. On subsequent runs:
479
+ - Without `--ask`: saved answers are loaded silently to enrich the intent
480
+ - With `--ask`: saved answers appear as defaults (press Enter to keep)
481
+
482
+ ### Pipeline Customization
483
+
484
+ The review agent choice modifies the pipeline:
485
+ - "Codex (automated review)" sets the `review_gate` to `--mode review`
486
+ - "Skip review" disables the `review_gate` step
487
+
488
+ ### Enriched Intent
489
+
490
+ The questionnaire output is an enriched intent string combining:
491
+ - Refined description
492
+ - Project constraints (type, language, scope)
493
+ - Additional context notes
494
+ - Any existing project context (README, package.json, project-analysis.md)
495
+
496
+ ---
497
+
498
+ ## Gate System
499
+
500
+ Gates pause the pipeline for human decisions. Three outcomes:
501
+
502
+ | Key | Outcome | Effect |
503
+ |-----|---------|--------|
504
+ | `a` | **approve** | Proceed to `on_approve` step |
505
+ | `r` | **revise** | Loop back to `on_revise` step |
506
+ | `k` | **kill** | Terminate the flow |
507
+
508
+ ### Conversation Mode
509
+
510
+ If the user types anything other than `a`/`r`/`k`, it's collected as a note/question. The user can ask questions or provide feedback before making their decision. Notes are included in the rationale sent to Stratum.
511
+
512
+ ```
513
+ Gate: review_gate
514
+ [a]pprove -> roadmap
515
+ [r]evise -> brainstorm
516
+ [k]ill -> (terminate)
517
+ Or type a question/comment to discuss before deciding.
518
+
519
+ > What about error handling for edge cases?
520
+ (noted -- enter a/r/k when ready to decide)
521
+ > The feature list looks comprehensive
522
+ (noted -- enter a/r/k when ready to decide)
523
+ > a
524
+ Notes collected: 2
525
+ Additional rationale (or Enter to use notes):
526
+ ```
527
+
528
+ ### Rationale
529
+
530
+ A rationale is always required. If notes were collected during conversation mode, they serve as the rationale. Otherwise, the user is prompted explicitly.
531
+
532
+ ### Gate Definitions in Specs
533
+
534
+ ```yaml
535
+ functions:
536
+ design_gate:
537
+ mode: gate
538
+ timeout: 3600 # seconds
539
+
540
+ steps:
541
+ - id: design_gate
542
+ function: design_gate
543
+ on_approve: plan # proceed to this step
544
+ on_revise: explore_design # loop back
545
+ on_kill: null # null = terminate flow
546
+ ```
547
+
548
+ ### Artifact Display
549
+
550
+ Before gate prompts in the `new` pipeline, the artifact produced by the prior step is displayed so the user can make an informed decision. For short documents (<= 80 lines), the full content is shown; for longer ones, the first 60 lines plus a truncation notice.
551
+
552
+ ---
553
+
554
+ ## Validation System
555
+
556
+ Agent-as-validator: after a step writes its artifact, a separate lightweight agent call reads the artifact and checks it against criteria defined in the pipeline spec.
557
+
558
+ ### How It Works
559
+
560
+ 1. The pipeline spec defines `validate` on a step:
561
+ ```yaml
562
+ - id: brainstorm
563
+ validate:
564
+ artifact: docs/discovery/brainstorm.md
565
+ criteria:
566
+ - "Contains at least 3 features with short codes"
567
+ - "Contains user stories in 'As a...' format"
568
+ - "Contains at least 2 architecture options"
569
+ ```
570
+ 2. After the step completes, the validator dispatches a fresh Claude call with a prompt asking it to read the artifact and check each criterion.
571
+ 3. The validator returns `{ valid: boolean, issues: string[] }`.
572
+ 4. If `valid` is false, a fix agent (claude) is dispatched to fix all issues, then the pipeline continues.
573
+ 5. If the validator can't extract structured JSON, it optimistically assumes valid (no crash).
574
+
575
+ ### Criteria
576
+
577
+ Criteria are human-readable strings. The validator agent interprets them and returns a boolean judgment per criterion. This means validation is semantic, not syntactic -- "Contains at least 3 features" is checked by an agent reading the document, not by a regex.
578
+
579
+ ---
580
+
581
+ ## Pipeline CLI
582
+
583
+ `compose pipeline` provides full control over `pipelines/build.stratum.yaml`.
584
+
585
+ ### `show`
586
+
587
+ Pretty-prints the pipeline with color-coded step types:
588
+ - Green: agent steps (with ensure count, retries, on_fail)
589
+ - Yellow: gate steps (with timeout)
590
+ - Cyan: flow steps (sub-flow name, inner steps, agent)
591
+ - Gray: skipped steps (with reason)
592
+
593
+ Also shows sub-flow details and contracts.
594
+
595
+ ### `set`
596
+
597
+ Modify step properties:
598
+
599
+ ```bash
600
+ # Change which agent executes a step
601
+ compose pipeline set execute --agent codex
602
+
603
+ # Convert a step to a human gate
604
+ compose pipeline set review --mode gate
605
+
606
+ # Convert a step to a codex review sub-flow
607
+ compose pipeline set review --mode review
608
+ # Creates a review_check sub-flow with codex agent, ReviewResult contract,
609
+ # ensure "result.clean == True", retries 10
610
+
611
+ # Convert back to a regular agent step
612
+ compose pipeline set review --mode agent
613
+
614
+ # Set retry count
615
+ compose pipeline set blueprint --retries 5
616
+ ```
617
+
618
+ ### `add`
619
+
620
+ Insert a new step after an existing one:
621
+
622
+ ```bash
623
+ compose pipeline add --id lint --after execute --agent claude --intent "Run linter and fix issues"
624
+ ```
625
+
626
+ Creates a step with default `PhaseResult` output contract, 2 retries, and `depends_on: [<after>]`. Rewires the next step's dependencies.
627
+
628
+ ### `remove`
629
+
630
+ Remove a step and rewire dependencies:
631
+
632
+ ```bash
633
+ compose pipeline remove prd
634
+ ```
635
+
636
+ Steps that depended on the removed step inherit its dependencies. Gate references (`on_approve`, `on_revise`, `on_fail`) are also rewired.
637
+
638
+ ### `enable` / `disable`
639
+
640
+ ```bash
641
+ compose pipeline enable prd architecture report # remove skip_if
642
+ compose pipeline disable prd # set skip_if: "true"
643
+ ```
644
+
645
+ ---
646
+
647
+ ## Recovery Logic
648
+
649
+ When a step's postconditions fail (`ensure_failed` or `schema_failed`), Compose runs a two-phase recovery:
650
+
651
+ ### 1. Fix Pass
652
+
653
+ A fix agent is dispatched with the violations:
654
+
655
+ ```
656
+ Fix step "review" -- postconditions failed:
657
+ - result.clean == True
658
+ Fix every issue. Do not skip any.
659
+ ```
660
+
661
+ For codex steps, the fix pass goes to **claude** (cross-agent fix). For claude steps, the fix is same-agent but with a distinct prompt focused on fixing.
662
+
663
+ ### 2. Retry
664
+
665
+ After the fix pass, the original step is retried with a retry prompt that includes both the original intent and the violations:
666
+
667
+ ```
668
+ RETRY -- Previous attempt failed postconditions:
669
+ - result.clean == True
670
+ Fix these issues and try again.
671
+ [original step prompt]
672
+ ```
673
+
674
+ ### Retry Limits
675
+
676
+ Each step has a `retries` count (set in the pipeline spec). The review sub-flow defaults to 10 retries; coverage defaults to 15. When retries are exhausted, `on_fail` routing kicks in (if configured), or the step fails.
677
+
678
+ ### on_fail Routing
679
+
680
+ Steps can specify `on_fail: <step-id>` to route to a different step when retries are exhausted. The `verification` step uses `on_fail: blueprint` to loop back for a blueprint rewrite.
681
+
682
+ ---
683
+
684
+ ## Progress Logging
685
+
686
+ During agent execution, Compose renders a live progress display to stderr with two modes:
687
+
688
+ **Collapsed (default):** Shows the last 5 tool events, a status line with elapsed time and tool count, and a key hints bar. Redraws in-place every 5 seconds (heartbeat).
689
+
690
+ ```
691
+ ● explore ─ ● scope ─ ◉ blueprint ─ ○ plan ─ ○ execute ─ ○ review ─ ○ codex
692
+ [3/17] blueprint...
693
+ ↳ Read: lib/build.js
694
+ ↳ Grep: pattern match in server/
695
+ ↳ Read: docs/features/FEAT-1/design.md
696
+ ↳ Edit: src/App.jsx
697
+ ↳ Bash: npm test
698
+ blueprint · 45s · 5 calls
699
+ keys: t=toggle s=skip r=retry Ctrl+C=abort
700
+ ```
701
+
702
+ **Expanded:** Shows all tool events as they arrive, plus elapsed time heartbeat every 5 seconds.
703
+
704
+ ### Key commands during build
705
+
706
+ | Key | Action |
707
+ |-----|--------|
708
+ | `t` | Toggle between collapsed and expanded view |
709
+ | `s` | Skip the current step (interrupts agent, moves to next) |
710
+ | `r` | Retry the current step (interrupts agent, re-runs same step) |
711
+ | `Ctrl+C` | Abort the build |
712
+
713
+ ### Pipeline bar
714
+
715
+ The pipeline bar shows all build steps with status indicators:
716
+ - `●` (green) — completed steps
717
+ - `◉` (cyan, bold) — current active step
718
+ - `○` (dim) — pending steps
719
+
720
+ Adapts to terminal width with a sliding window for narrow terminals.
721
+
722
+ ### Findings table
723
+
724
+ When the review step returns violations, they're rendered as a formatted table with severity coloring (must-fix=red, should-fix=yellow, nit=gray).
725
+
726
+ ### Gate panel
727
+
728
+ Gate prompts render as a boxed panel showing the artifact path, phase transition, and color-coded action options instead of raw readline text.
729
+
730
+ Enable verbose event logging with `COMPOSE_DEBUG=1`.
731
+
732
+ ---
733
+
734
+ ## Result Normalization and JSON Extraction
735
+
736
+ The result normalizer (`lib/result-normalizer.js`) bridges the gap between streaming agent text and structured step results.
737
+
738
+ ### Schema Injection
739
+
740
+ When a step has `output_fields`, the normalizer:
741
+ 1. Converts Stratum's flat type map (`{ clean: "boolean", findings: "array" }`) to JSON Schema
742
+ 2. Injects schema instructions into the prompt via `injectSchema()`
743
+ 3. The agent sees: "include a JSON code block at the very end of your response matching this schema"
744
+
745
+ ### JSON Extraction
746
+
747
+ After the agent completes, the normalizer tries three extraction strategies in order:
748
+
749
+ 1. **Full text parse** -- the entire output is valid JSON
750
+ 2. **Fenced block** -- extract from ` ```json ... ``` `
751
+ 3. **Balanced braces** -- find the first `{` and its matching `}`, parse the substring
752
+
753
+ If all strategies fail, a warning is logged and a fallback `{ summary: "..." }` is returned (first 200 chars of output). The pipeline does not crash.
754
+
755
+ ### Error Handling
756
+
757
+ - `AgentError` -- thrown when the agent yields an error event
758
+ - `ResultParseError` -- thrown when JSON extraction fails (includes raw text for debugging)
759
+
760
+ ---
761
+
762
+ ## Vision Writer Integration
763
+
764
+ The `VisionWriter` (`lib/vision-writer.js`) maintains `.compose/data/vision-state.json` with atomic read-modify-write operations (POSIX rename).
765
+
766
+ ### What It Tracks
767
+
768
+ - **Feature items**: Each feature gets a vision item with id, type, title, status, phase, featureCode, slug, confidence, timestamps
769
+ - **Phase updates**: As each step executes, the item's `lifecycle.currentPhase` is updated
770
+ - **Gate entries**: Each gate creates a record with flowId, stepId, itemId, status, timestamps
771
+ - **Gate resolutions**: Outcome (approve/revise/kill) and resolution timestamp
772
+
773
+ ### Lookup Conventions
774
+
775
+ Supports both `feature:CODE` (seed convention) and `lifecycle.featureCode` (lifecycle-manager convention) for feature item lookup.
776
+
777
+ ### Status Transitions
778
+
779
+ ```
780
+ planned -> in_progress -> complete
781
+ planned -> in_progress -> killed
782
+ ```
783
+
784
+ ---
785
+
786
+ ## Configuration Files
787
+
788
+ ### `.compose/compose.json`
789
+
790
+ Project-level configuration. Created by `compose init`.
791
+
792
+ ```json
793
+ {
794
+ "version": 2,
795
+ "capabilities": {
796
+ "stratum": true,
797
+ "lifecycle": true
798
+ },
799
+ "agents": {
800
+ "claude": { "detected": true, "skillInstalled": true },
801
+ "codex": { "detected": true, "skillInstalled": true },
802
+ "gemini": { "detected": false }
803
+ },
804
+ "paths": {
805
+ "docs": "docs",
806
+ "features": "docs/features",
807
+ "journal": "docs/journal"
808
+ }
809
+ }
810
+ ```
811
+
812
+ ### `.compose/questionnaire.json`
813
+
814
+ Saved questionnaire answers (enriched intent, project type, language, scope, research preference, notes, review agent choice).
815
+
816
+ ### `.compose/data/vision-state.json`
817
+
818
+ Vision tracker state: items, connections, gates. Managed by `VisionWriter`. Atomic writes via temp file + rename.
819
+
820
+ ### `.compose/data/active-build.json`
821
+
822
+ Active build state for resume/abort:
823
+
824
+ ```json
825
+ {
826
+ "featureCode": "FEAT-1",
827
+ "flowId": "uuid",
828
+ "startedAt": "2026-03-11T...",
829
+ "currentStepId": "blueprint",
830
+ "specPath": "pipelines/build.stratum.yaml"
831
+ }
832
+ ```
833
+
834
+ ### `pipelines/build.stratum.yaml`
835
+
836
+ The build pipeline spec. Editable via `compose pipeline` or by hand. See [The Build Pipeline](#the-build-pipeline).
837
+
838
+ ### `pipelines/new.stratum.yaml`
839
+
840
+ The kickoff pipeline spec. See [The Kickoff Pipeline](#the-kickoff-pipeline).
841
+
842
+ ### `.mcp.json`
843
+
844
+ MCP server registration. `compose init` adds:
845
+
846
+ ```json
847
+ {
848
+ "mcpServers": {
849
+ "compose": {
850
+ "command": "node",
851
+ "args": ["<compose-root>/server/compose-mcp.js"]
852
+ }
853
+ }
854
+ }
855
+ ```
856
+
857
+ ### `ROADMAP.md`
858
+
859
+ Scaffolded from `templates/ROADMAP.md` with project name, date, and placeholder phases. Updated by `compose feature` and the build pipeline.
860
+
861
+ ---
862
+
863
+ ## MCP Server
864
+
865
+ Compose exposes project state as MCP tools via `server/compose-mcp.js` (stdio transport). Registered in `.mcp.json` by `compose init`. Available tools:
866
+
867
+ | Tool | Description |
868
+ |------|-------------|
869
+ | `get_vision_items` | Query items by phase, status, type, keyword |
870
+ | `get_item_detail` | Full item detail with connections |
871
+ | `get_phase_summary` | Status/type distribution per phase |
872
+ | `get_blocked_items` | Items blocked by non-complete dependencies |
873
+ | `get_current_session` | Active session context (tool count, items touched) |
874
+ | `bind_session` | Bind agent session to a lifecycle feature |
875
+ | `get_feature_lifecycle` | Feature lifecycle state, phase history, artifacts |
876
+ | `kill_feature` | Kill a feature with reason |
877
+ | `complete_feature` | Mark feature complete (ship phase only) |
878
+ | `assess_feature_artifacts` | Quality signals for feature artifacts |
879
+ | `scaffold_feature` | Create feature folder with template stubs |
880
+ | `approve_gate` | Resolve a pending gate (approved/revised/killed) |
881
+ | `get_pending_gates` | List pending gates |
882
+ | `agent_run` | Run a prompt against an AI agent (claude or codex) with optional JSON schema |
883
+ | `start_iteration_loop` | Start an iteration loop on a feature |
884
+ | `report_iteration_result` | Report iteration outcome (clean/dirty/max_reached) |
885
+ | `abort_iteration_loop` | Abort an active iteration loop |
886
+
887
+ ---
888
+
889
+ ## Pipeline Specs
890
+
891
+ Compose ships with five pipeline specs in `pipelines/`:
892
+
893
+ | Spec | Flow | Purpose |
894
+ |------|------|---------|
895
+ | `new.stratum.yaml` | `new` | Product kickoff: research, brainstorm, roadmap, scaffold |
896
+ | `build.stratum.yaml` | `build` | Feature lifecycle: design through ship |
897
+ | `review-fix.stratum.yaml` | `review_fix` | Two-phase loop: implement then review/fix until clean |
898
+ | `coverage-sweep.stratum.yaml` | `coverage_sweep` | Test loop: run tests, fix failures until passing |
899
+ | `compose_feature.stratum.yaml` | `compose_feature` | Legacy function-based lifecycle spec |
900
+
901
+ ### Stratum IR v0.3
902
+
903
+ Specs use Stratum IR v0.3 format (backward-compatible superset of v0.2). All existing v0.2 specs run unchanged. Specs that use v0.3 features declare `ir_version: "0.3"` at the top level.
904
+
905
+ **v0.2 primitives (all retained):**
906
+ - **contracts**: Output shape definitions with typed fields
907
+ - **functions**: Reusable compute/gate definitions with retries and postconditions
908
+ - **flows**: Step graphs with dependencies, routing, sub-flows
909
+ - **ensure expressions**: Python-like postconditions (`result.clean == True`, `file_exists(path)`)
910
+ - **input expressions**: Data flow between steps (`$.input.x`, `$.steps.prev.output.y`)
911
+ - **skip_if / skip_reason**: Conditional step skipping
912
+
913
+ **v0.3 additions (STRAT-PAR, STRAT-REV):**
914
+ - **`decompose` step type**: the agent emits a **TaskGraph** — an array of tasks, each with `files_owned` (write set), `files_read` (read set), and `depends_on` (dependency list). Used to break a sequential step into independent subtasks before parallel execution.
915
+ - **`parallel_dispatch` step type**: consumes a TaskGraph and coordinates concurrent agent runs. Fields: `source` (JSON pointer to task array, e.g. `$.steps.decompose.output.tasks`), `max_concurrent` (concurrency cap, default 3), `isolation` (`worktree` for write isolation, `branch`, or `none` for read-only tasks), `merge` (`sequential_apply` | `manual`), `require` (`all` | `any` | integer N), and `intent_template` (per-task prompt template with `{field}` interpolation).
916
+ - **`no_file_conflicts` ensure**: validates that no two independent tasks share `files_owned` entries.
917
+ - **`isolation: none`**: allows read-only parallel tasks (e.g. review lenses) to run without git worktree overhead.
918
+
919
+ ---
920
+
921
+ ## Examples and Workflows
922
+
923
+ ### Start a new project from scratch
924
+
925
+ ```bash
926
+ mkdir my-cli-tool && cd my-cli-tool
927
+ compose new "CLI tool that converts CSV files to JSON with filtering and validation"
928
+ # Answer questionnaire questions
929
+ # Approve brainstorm at gate
930
+ # Approve roadmap at gate
931
+ # Feature folders scaffolded
932
+
933
+ compose build CSV-1 # build the first feature
934
+ ```
935
+
936
+ ### Add a feature to an existing project
937
+
938
+ ```bash
939
+ cd existing-project
940
+ compose import # scan and analyze
941
+ compose feature AUTH-1 "JWT auth middleware with refresh tokens"
942
+ compose build AUTH-1
943
+ ```
944
+
945
+ ### Customize the pipeline before building
946
+
947
+ ```bash
948
+ compose init
949
+ compose pipeline show # see default pipeline
950
+ compose pipeline enable prd architecture # enable optional phases
951
+ compose pipeline set review --agent codex --retries 5
952
+ compose pipeline add --id lint --after execute --agent claude --intent "Run ESLint and fix issues"
953
+ compose build FEAT-1
954
+ ```
955
+
956
+ ### Skip research for a well-understood project
957
+
958
+ ```bash
959
+ compose new "Internal admin dashboard for existing API" --ask
960
+ # At "Research prior art?" question, answer: n
961
+ ```
962
+
963
+ ### Use automated review instead of human gates
964
+
965
+ ```bash
966
+ compose new "microservice template" --ask
967
+ # At "Who should review?" question, choose: Codex (automated review)
968
+ ```
969
+
970
+ ### Abort a stuck build
971
+
972
+ ```bash
973
+ compose build --abort
974
+ ```
975
+
976
+ ### View pipeline state
977
+
978
+ ```bash
979
+ compose pipeline show
980
+ ```
981
+
982
+ Output:
983
+ ```
984
+ Pipeline: build (17 steps)
985
+
986
+ 1. explore_design agent agent: claude [2 ensures] (retries: 2)
987
+ 2. scope agent agent: claude (retries: 2)
988
+ 3. design_gate gate human gate (timeout: 3600s)
989
+ 4. prd skip PRD skipped by default
990
+ 5. architecture skip Architecture skipped by default
991
+ 6. blueprint agent agent: claude [2 ensures] (retries: 3)
992
+ 7. verification agent agent: claude [1 ensures] (retries: 2) -> on_fail: blueprint
993
+ 8. plan_gate gate human gate (timeout: 3600s)
994
+ 9. decompose agent agent: claude [2 ensures] (retries: 2)
995
+ 10. execute par parallel_dispatch (worktree isolation)
996
+ 11. review flow parallel_review: triage → lenses → merge (retries: 5)
997
+ 12. codex_review flow review_check: review (agent: codex, retries: 3)
998
+ 13. coverage flow coverage_check: run_tests (agent: claude, retries: 15)
999
+ 14. report skip Report skipped by default
1000
+ 15. docs agent agent: claude (retries: 2)
1001
+ 16. ship agent agent: claude (retries: 2)
1002
+ 17. ship_gate gate human gate (timeout: 1800s)
1003
+ ```
1004
+
1005
+ ### Environment Variables
1006
+
1007
+ | Variable | Default | Purpose |
1008
+ |----------|---------|---------|
1009
+ | `CLAUDE_MODEL` | `claude-sonnet-4-6` | Default model for ClaudeSDKConnector |
1010
+ | `CODEX_MODEL` | `gpt-5.4` | Default model for CodexConnector |
1011
+ | `COMPOSE_DEBUG` | (unset) | Enable verbose event logging to stderr |
1012
+ | `COMPOSE_TARGET` | (unset) | Override project root for `compose start` |
1013
+ | `COMPOSE_SERVER_DISPATCH` | unset | Set to `1` to route `parallel_dispatch` steps through Stratum's server-side executor. Covers `isolation: "none"` unconditionally, and `isolation: "worktree"` steps that declare `capture_diff: true` (Compose consumes diffs from poll response and merges them client-side). When the step also declares `defer_advance: true`, Compose reports merge_status back via `stratum_parallel_advance` — client-side merge conflicts surface as `{status: 'complete', output: {merge_status: 'conflict'}}` and Compose sets `buildStatus='failed'` (non-zero CI exit). Worktree steps without `defer_advance` use the legacy throw-on-conflict path. |
1014
+ | `COMPOSE_SERVER_DISPATCH_POLL_MS` | `500` | Poll interval (ms) against `stratum_parallel_poll`. Lower = faster task-transition event propagation; higher = less MCP load. |