cadre-ai 2.2.0 → 3.0.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.
Files changed (81) hide show
  1. package/.claude-plugin/plugin.json +10 -0
  2. package/.codex-plugin/plugin.json +19 -0
  3. package/.mcp.codex.json +9 -0
  4. package/.mcp.json +8 -0
  5. package/LICENSE +21 -202
  6. package/README.md +357 -134
  7. package/agents/cadre-phase-worker.md +17 -0
  8. package/agents/cadre-task-worker.md +16 -0
  9. package/dist/cadre-cli.mjs +2883 -0
  10. package/dist/cadre-mcp.mjs +33736 -0
  11. package/marketplace/claude.json +16 -0
  12. package/marketplace/codex.json +20 -0
  13. package/package.json +36 -32
  14. package/skills/archive/SKILL.md +28 -0
  15. package/skills/archive/agents/openai.yaml +4 -0
  16. package/skills/create/SKILL.md +33 -0
  17. package/skills/create/agents/openai.yaml +4 -0
  18. package/skills/implement/SKILL.md +91 -0
  19. package/skills/implement/agents/openai.yaml +4 -0
  20. package/skills/refresh/SKILL.md +18 -0
  21. package/skills/refresh/agents/openai.yaml +4 -0
  22. package/skills/revert/SKILL.md +20 -0
  23. package/skills/revert/agents/openai.yaml +4 -0
  24. package/skills/review/SKILL.md +32 -0
  25. package/skills/review/agents/openai.yaml +4 -0
  26. package/skills/revise/SKILL.md +32 -0
  27. package/skills/revise/agents/openai.yaml +4 -0
  28. package/skills/status/SKILL.md +21 -0
  29. package/skills/status/agents/openai.yaml +4 -0
  30. package/skills/track/SKILL.md +33 -0
  31. package/skills/track/agents/openai.yaml +4 -0
  32. package/skills/wisp/SKILL.md +16 -0
  33. package/skills/wisp/agents/openai.yaml +4 -0
  34. package/templates/v1/init/archive/.gitkeep +1 -0
  35. package/templates/v1/init/gitignore.template +5 -0
  36. package/templates/v1/init/guidelines.md +25 -0
  37. package/templates/v1/init/operations/.gitkeep +1 -0
  38. package/templates/v1/init/patterns/index.md +6 -0
  39. package/templates/v1/init/product.md +30 -0
  40. package/templates/v1/init/project.json +26 -0
  41. package/templates/v1/init/refreshes/.gitkeep +1 -0
  42. package/templates/v1/init/styleguides/general.md +14 -0
  43. package/templates/v1/init/styleguides/language.md +21 -0
  44. package/templates/v1/init/tech-stack.md +21 -0
  45. package/templates/v1/init/tracks/.gitkeep +1 -0
  46. package/templates/v1/init/tracks.md +6 -0
  47. package/templates/v1/init/wisps/.gitkeep +1 -0
  48. package/templates/v1/init/workflow.md +163 -0
  49. package/templates/v1/project/archive-operation.json +15 -0
  50. package/templates/v1/project/pattern.md +20 -0
  51. package/templates/v1/project/refresh-operation.json +14 -0
  52. package/templates/v1/project/refresh.md +21 -0
  53. package/templates/v1/styleguides/dart.md +27 -0
  54. package/templates/v1/styleguides/flutter.md +27 -0
  55. package/templates/v1/styleguides/go.md +29 -0
  56. package/templates/v1/styleguides/gradle.md +28 -0
  57. package/templates/v1/styleguides/html-css.md +39 -0
  58. package/templates/v1/styleguides/index.md +27 -0
  59. package/templates/v1/styleguides/java.md +27 -0
  60. package/templates/v1/styleguides/javascript.md +27 -0
  61. package/templates/v1/styleguides/kotlin.md +26 -0
  62. package/templates/v1/styleguides/maven.md +28 -0
  63. package/templates/v1/styleguides/python.md +27 -0
  64. package/templates/v1/styleguides/react.md +28 -0
  65. package/templates/v1/styleguides/swift.md +27 -0
  66. package/templates/v1/styleguides/swiftui.md +27 -0
  67. package/templates/v1/styleguides/typescript.md +26 -0
  68. package/templates/v1/track/bug.md +14 -0
  69. package/templates/v1/track/execution.json +18 -0
  70. package/templates/v1/track/learning.md +39 -0
  71. package/templates/v1/track/plan.md +39 -0
  72. package/templates/v1/track/revert-operation.json +13 -0
  73. package/templates/v1/track/revise-operation.json +14 -0
  74. package/templates/v1/track/revision.md +36 -0
  75. package/templates/v1/track/spec.md +38 -0
  76. package/templates/v1/track/state.json +25 -0
  77. package/scripts/cadre-cli.js +0 -1076
  78. package/scripts/cadre-core.js +0 -15240
  79. package/scripts/cadre-lsp-review.js +0 -1194
  80. package/scripts/cadre-lsp-setup.js +0 -599
  81. package/scripts/mcp/cadre-server.js +0 -19013
package/README.md CHANGED
@@ -1,150 +1,373 @@
1
1
  # Cadre
2
2
 
3
- ![Cadre logo](../docs/public/cadre-logo.png)
4
-
5
- **Measure twice, code once.**
6
-
7
- Cadre is a context-driven development harness for AI coding agents. It combines
8
- spec-first tracks, native durable task memory, review gates, team boards,
9
- parallel worker orchestration, and mono/polyrepo delivery into one packet-owned
10
- workflow.
11
-
12
- Public docs: [https://cadre-docs.pages.dev/](https://cadre-docs.pages.dev/)
13
-
14
- ## What Cadre Provides
15
-
16
- - **Structured work:** setup, new track, implementation, review, ship/land,
17
- archive, release, handoff, refresh, revise, validate, flag, and formula flows.
18
- - **Persistent memory:** Cadre stores task graph state, dependencies, notes,
19
- handoffs, events, and resume evidence through native packet-owned files.
20
- - **Team safety:** ownership, advisory leases, collision scans, review queues,
21
- shared sync, and compact MCP dashboard resources.
22
- - **Polyglot intelligence:** repo maps, dependency graphs, test impact,
23
- workspace diagnostics, LSP setup, warm LSP review, and async job artifacts.
24
- - **Four agent surfaces:** Claude Code, OpenAI Codex, GitHub Copilot, and
25
- Google Antigravity plugins are thin MCP entrypoints. The global `cadre-mcp`
26
- runtime owns three public packet tools, the validated resource registry, and
27
- the setup templates needed at runtime.
28
- - **Codex and Claude workflow pickers:** explicit `$cadre:*` and `/cadre:*`
29
- entries make every registered workflow discoverable without adding MCP
30
- tools.
3
+ Cadre is a human-governed, Git-aware delivery harness for Codex and Claude Code. It turns project context into resumable feature and bug tracks, carries learning forward between phases, and records implementation provenance in Git.
4
+
5
+ Cadre is installed as a user plugin. Its bundled TypeScript MCP server provides deterministic state operations and immutable, versioned templates. A project keeps only approved, mutable delivery state under `.cadre/`; runtime code and template catalogs are not copied into the project.
6
+
7
+ **Documentation:** [cadre-docs.pages.dev](https://cadre-docs.pages.dev/) ·
8
+ [Quickstart](https://cadre-docs.pages.dev/quickstart/) ·
9
+ [Release notes](https://cadre-docs.pages.dev/release-notes/)
10
+
11
+ ## Capabilities
12
+
13
+ - Greenfield and brownfield project onboarding, with an explicit classification gate when the repository is ambiguous.
14
+ - Human approval of every generated artifact and lifecycle state transition.
15
+ - Resumable create, specification, planning, implementation, review, revision, refresh, revert, and archive flows.
16
+ - Parallel-by-default implementation of dependency DAGs, with an explicit sequential mode.
17
+ - Isolated phase and task workers in Cadre-managed Git worktrees, coordinated and integrated only by the main agent.
18
+ - Feature and bug tracks with functional requirements, non-functional requirements, acceptance criteria, dependencies, phased tasks, and manual-verification gates.
19
+ - Dependency enforcement before implementation and cascading-impact analysis after specification, workflow, stack, styleguide, or pattern changes.
20
+ - Incremental learning in each track's `learning.md`; every phase reads the previous phase's learning before work starts.
21
+ - Review → remediation → implementation cycles until the human accepts a clean review.
22
+ - Single-track or multi-track archival with consolidated pattern distillation and relevant reseeding of active tracks.
23
+ - Git-aware task, phase, setup, review, revision, refresh, revert, and archive provenance using Conventional Commits.
24
+ - Read-before-edit enforcement: existing files and directly relevant context must be inspected before modification.
25
+ - Stateless exploration through `wisp`, without mutating Cadre lifecycle state.
26
+
27
+ Default idiomatic styleguides are included for Go, Java, Kotlin, Maven, Gradle, HTML/CSS, JavaScript, TypeScript, React, Dart, Flutter, Swift, SwiftUI, and Python. During project creation, each applicable guide can be accepted, amended, or replaced.
28
+
29
+ ## Requirements
30
+
31
+ - Node.js 18 or newer
32
+ - Git
33
+ - The `codex` CLI, the `claude` CLI, or both
31
34
 
32
35
  ## Install
33
36
 
34
- Install Cadre from npm and let the CLI wire detected clients:
37
+ Install the published CLI:
35
38
 
36
- ```bash
39
+ ```sh
37
40
  npm install -g cadre-ai
38
- cadre install
39
- cadre doctor
41
+ cadre-ai doctor
42
+ ```
43
+
44
+ Install for every detected client:
45
+
46
+ ```sh
47
+ cadre-ai install
48
+ ```
49
+
50
+ Install for only one agent:
51
+
52
+ ```sh
53
+ # Codex only
54
+ cadre-ai install --target codex
55
+
56
+ # Claude Code only
57
+ cadre-ai install --target claude
58
+ ```
59
+
60
+ The installer:
61
+
62
+ 1. Packages the skills, MCP configuration, self-contained runtime, and
63
+ templates into a local marketplace.
64
+ 2. Registers the marketplace and installs `cadre@cadre` at user scope.
65
+ 3. Verifies that the selected agent reports the plugin as installed and enabled.
66
+ 4. Pre-approves only Cadre MCP tools so normal Cadre commands do not produce an
67
+ extra permission prompt.
68
+
69
+ The marketplace is stored at `~/.cadre/marketplaces/cadre`. When it is updated, the prior generated payload is retained as a timestamped backup.
70
+
71
+ ### MCP permission behavior
72
+
73
+ By default, installation applies these narrowly scoped rules:
74
+
75
+ - Codex: `default_tools_approval_mode = "approve"` under `plugins."cadre@cadre".mcp_servers.cadre` in the user Codex configuration.
76
+ - Claude Code: `cadre` in `enabledMcpjsonServers` and `mcp__cadre__*` in the
77
+ user permission allowlist.
78
+
79
+ Existing configuration, comments, and unrelated permission rules are preserved. A Claude deny rule is never removed or overridden. These rules suppress the host application's per-tool prompt; they do not bypass Cadre's requirement to present artifacts and lifecycle mutations to the human for approval.
80
+
81
+ Implementation may still need host permission for network access, dependency installation, container images, local listeners, or filesystem writes outside the workspace. Cadre preflights those operations before workers start, centralizes shared downloads, reuses existing narrow approvals, and asks only for an exact necessary command when no suitable permission exists. These host prompts are operational security gates, not lifecycle approvals.
82
+
83
+ To retain per-call MCP permission prompts:
84
+
85
+ ```sh
86
+ cadre-ai install --target codex --prompt-mcp-tools
87
+ ```
88
+
89
+ ### Other installer options
90
+
91
+ | Option | Effect |
92
+ | --- | --- |
93
+ | `--target auto\|all\|codex\|claude` | Select the target client; defaults to `auto`. |
94
+ | `--scope user` | Explicitly select the only supported installation scope. |
95
+ | `--replace-marketplace` | Replace another configured marketplace named `cadre` after the installer detects the path mismatch. |
96
+ | `--prompt-mcp-tools` | Do not add the Cadre MCP pre-approval rule. |
97
+ | `--prepare-only` | Build the marketplace without registering, installing, or changing permission configuration. |
98
+ | `--marketplace-root PATH` | Override the generated marketplace location; the path must end in `cadre`. |
99
+ | `--cachebuster TOKEN` | Supply an explicit package cachebuster instead of the generated timestamp. |
100
+ | `--dry-run` | Report the intended marketplace and client operations without applying them. |
101
+
102
+ Package-only example:
103
+
104
+ ```sh
105
+ cadre-ai install \
106
+ --target all \
107
+ --prepare-only \
108
+ --marketplace-root /tmp/cadre
109
+ ```
110
+
111
+ ### Update an existing installation
112
+
113
+ Install the desired package version and rerun the installer. It produces a new
114
+ cache-busted marketplace payload and updates the installed plugin:
115
+
116
+ ```sh
117
+ npm install -g cadre-ai@latest
118
+ cadre-ai doctor
119
+ cadre-ai install
120
+ ```
121
+
122
+ `--replace-marketplace` is needed only when a client already has a marketplace
123
+ named `cadre` pointing somewhere else.
124
+
125
+ After installation or update:
126
+
127
+ - Start a new Codex conversation so the new skills and MCP tools are loaded.
128
+ - In Claude Code, run `/reload-plugins` or start a new session.
129
+
130
+ You can inspect installation state with:
131
+
132
+ ```sh
133
+ codex plugin list --json
134
+ claude plugin list --json
135
+ ```
136
+
137
+ ## Quick start
138
+
139
+ Cadre commands are agent skills, not shell commands. Invoke them in the Codex or Claude Code conversation.
140
+
141
+ ### 1. Initialize a project
142
+
143
+ From the project repository, invoke:
144
+
145
+ ```text
146
+ Codex: $cadre:create
147
+ Claude Code: /cadre:create
40
148
  ```
41
149
 
42
- ## Use
150
+ Cadre will:
151
+
152
+ 1. Inspect the repository and Git state.
153
+ 2. Classify it as greenfield or brownfield, asking when the evidence is unclear.
154
+ 3. Propose product, engineering, tech-stack, workflow, and applicable styleguide artifacts.
155
+ 4. Ask for separate approval of the default or amended workflow and styleguides.
156
+ 5. Preview the exact `.cadre` file set before applying it.
157
+ 6. Initialize Git when the approved project root is not already in a worktree.
158
+ 7. Validate and commit the approved setup with resumable checkpoints.
43
159
 
44
- In Codex, type `$cadre:`; in Claude Code, type `/cadre:`:
160
+ ### 2. Create a feature or bug track
45
161
 
46
162
  ```text
47
- # Codex
48
- $cadre:setup
49
- $cadre:newtrack Add OAuth login
50
- $cadre:implement
51
- $cadre:review
52
- $cadre:ship
53
-
54
- # Claude Code
55
- /cadre:setup
56
- /cadre:newtrack Add OAuth login
57
- /cadre:implement
58
- /cadre:review
59
- /cadre:ship
60
- ```
61
-
62
- Both clients expose the same 19 registered workflows: `setup`, `newtrack`,
63
- `implement`, `debug`, `status`, `validate`, `flag`, `revise`, `review`, `ship`,
64
- `land`, `handoff`, `archive`, `release`, `refresh`, `revert`, `formula`,
65
- `artifacts`, and `skill`. Neither exposes a redundant `$cadre:cadre` or
66
- `/cadre:cadre` option. After an upgrade, restart Codex or open a new task; in
67
- Claude Code, run `/reload-plugins` or restart. Copilot and Antigravity retain
68
- the single Cadre skill and accept the same `cadre-*` workflow names as
69
- requests.
70
-
71
- Cadre workflows are packet-owned. The agent verifies Cadre MCP, passes a
72
- per-call `root`, and lets the runtime perform state reads/writes, formula work,
73
- parallel worker state, provider evidence write-back, and shared sync. Do not
74
- maintain Cadre state by hand.
75
-
76
- ## Setup Outputs
77
-
78
- `cadre-setup` writes the project control plane:
79
-
80
- - `cadre/product.json` plus generated `cadre/product.md`
81
- - `cadre/product_guidelines.json` plus generated `cadre/product_guidelines.md`
82
- - `cadre/tech-stack.json` plus generated `cadre/tech-stack.md`
83
- - `cadre/workflow.json` plus generated `cadre/workflow.md`
84
- - `cadre/tracks.json` as the generated track index
85
- - `cadre/patterns.jsonl` plus generated `cadre/patterns.md`
86
- - `cadre/config.json`
87
- - `cadre/events.jsonl`
88
- - `cadre/messages/outbox.jsonl` and `cadre/messages/inbox.jsonl`
89
- - `cadre/formulas/*.json` when formulas are added
90
- - git-ignored `cadre/local/wisps/*.json` for local ephemeral formula runs
91
- - `cadre/styleguides/index.json` plus generated `cadre/styleguides/README.md`
92
- - `cadre/styleguides/<id>.json` plus generated `cadre/styleguides/<id>.md`
93
- - optional `cadre/repos.json` plus generated `cadre/repos.md` for polyrepo topology
94
- - optional `cadre/lsp.json` for LSP recommendations
95
- - repository-authored `cadre/skills/<skill-id>/skill.json` rule manifests with generated `SKILL.md` human projections
96
-
97
- Setup also initializes native Cadre state, can configure shared-sync merge
98
- attributes, and can scaffold hosted CI checks when requested.
99
-
100
- ## Team And Repo Modes
101
-
102
- Cadre supports monorepos and polyrepo control repos. For teams, use shared sync
103
- so ownership, leases, review state, blockers, and available work are visible to
104
- everyone. Product code publication still happens through ship/land workflows;
105
- shared sync is for the Cadre control plane.
106
-
107
- Project skills are local to the active repository. Maintainers add them through
108
- normal reviewed Git changes; Cadre selects them by workflow and optional
109
- polyrepo `repos` targeting, returns bounded instructions in workflow packets,
110
- and exposes references lazily through MCP resources. Project skills never fall
111
- back to a global catalog and never execute scripts automatically.
112
-
113
- Compact MCP resources provide bounded views for larger teams:
114
-
115
- - team board and next actions
116
- - review queue and handoff inbox
117
- - quality gate and parallel worker state
118
- - repo topology, repo map, workspace diagnostics, test impact, and LSP status
119
- - provider action plans and async job results
120
-
121
- ## Harness Development
122
-
123
- This repository is the Cadre harness/package repo. Runtime sources live in
124
- `src/`, master skill/protocol sources live in `skills/cadre/`, references live
125
- in `scripts/agent-refs/`, and templates live in `templates/`.
126
-
127
- Run package commands from the repository root:
128
-
129
- ```bash
130
- pnpm --filter cadre-ai generate
131
- pnpm --filter cadre-ai check
163
+ Codex: $cadre:track Add passwordless login as a feature
164
+ Claude Code: /cadre:track Fix duplicate invoice creation as a bug
165
+ ```
166
+
167
+ Cadre proposes and separately approves:
168
+
169
+ - `spec.md`, containing functional requirements, non-functional requirements, acceptance criteria, dependencies, additional information, and dependent-track impact;
170
+ - `plan.md`, defining an acyclic phase/task dependency graph with derived manual-verification barriers;
171
+ - `learning.md`, whose marked Pattern Seed contains only patterns relevant to the approved track.
172
+
173
+ Every delivery phase ends with `User Manual Verification`. The final phase is always `Track-level User Manual Verification`.
174
+
175
+ ### 3. Implement the approved plan
176
+
177
+ ```text
178
+ Codex: $cadre:implement passwordless-login
179
+ Claude Code: /cadre:implement passwordless-login
132
180
  ```
133
181
 
134
- Generated plugin bundles under `.agents/`, `.claude/`, and `plugins/` are
135
- rebuilt from master sources. They contain platform manifests, MCP config, and
136
- thin skill shims; the Codex and Claude plugin fixtures also contain the same 19
137
- explicit workflow-picker skills. The embedded MCP runtime is built under
138
- `scripts/`.
182
+ Parallel mode is the default. Request sequential execution explicitly when needed:
139
183
 
140
- Public documentation lives in the repo-root `docs/` Next.js app. Markdown page
141
- source is in `docs/content/`:
184
+ ```text
185
+ Codex: $cadre:implement passwordless-login sequentially
186
+ Claude Code: /cadre:implement passwordless-login sequentially
187
+ ```
188
+
189
+ Implementation starts only after declared track dependencies are completed. Phase and task dependencies form a hierarchical DAG: phase dependencies activate phases, task dependencies expose phase-local work, and main allocates one global worker bound across every ready task. The generated workflow defaults to three delegated workers, the execution runtime accepts `maxWorkers` from 1 through 32, and effective concurrency is clamped by safe ready nodes and available host worker slots. Different phases can use direct execution, a sequential phase worker, or task-worker fan-out concurrently. Within one phase, execution can switch between sequential and fan-out modes only at a clean, journaled checkpoint. The main agent remains the only scheduler, operational owner of phase integration worktrees, state owner, merger, conflict resolver, worktree cleaner, and recorder of human approval.
190
+
191
+ Every delivery phase ends with a derived manual-verification barrier over its tasks. The final track-level manual verification depends on every delivery phase and always runs in the main agent against the canonical worktree. Cadre resumes from its execution journal, reads dependency-phase learning, verifies and presents each change before commit, records task and phase provenance, and advances the track to `ready_for_review` only after all barriers pass.
192
+
193
+ ### 4. Review and complete the track
194
+
195
+ ```text
196
+ Codex: $cadre:review passwordless-login
197
+ Claude Code: /cadre:review passwordless-login
198
+ ```
199
+
200
+ Findings are presented before they become Cadre state. Approved bugs create a timestamped bug artifact and add remediation phases to the plan. A human-approved clean review marks the track `completed`.
201
+
202
+ ### 5. Archive completed work
203
+
204
+ ```text
205
+ Codex: $cadre:archive passwordless-login account-lockout
206
+ Claude Code: /cadre:archive all completed
207
+ ```
208
+
209
+ Archive accepts one or more completed tracks in one resumable batch. It distills their durable learning into the project pattern catalog, updates relevant seeds for active tracks, preserves the full track history, and moves each selected track to its derived archive location.
210
+
211
+ ## Command reference
212
+
213
+ | Command | Purpose |
214
+ | --- | --- |
215
+ | `create` | Initialize or resume Cadre, classify project context, initialize Git when needed, and establish approved project artifacts. |
216
+ | `track` | Create or resume a feature/bug specification, phased plan, dependency set, and learning seed. |
217
+ | `implement` | Execute or resume the approved phase/task DAG in parallel by default or explicitly sequentially, with worktrees, tests, learning, approvals, and commit provenance. |
218
+ | `review` | Review a ready track, record approved findings, add remediation phases, or complete an approved clean cycle. |
219
+ | `revise` | Route a requested change by lifecycle state, revise an approved active baseline, or propose a successor for completed history. |
220
+ | `archive` | Archive one or more completed tracks, distill patterns, and reseed active tracks by relevance. |
221
+ | `refresh` | Refresh project context from user input, repository changes, and completed-track outcomes. |
222
+ | `revert` | Prepare and execute a human-approved additive Git revert for a task, phase, or track. |
223
+ | `status` | Validate and summarize project, operation, track, dependency, review, and archive state without mutation. |
224
+ | `wisp` | Explore or investigate without creating or changing Cadre lifecycle state. |
225
+
226
+ ## Lifecycle
227
+
228
+ ```text
229
+ drafting-spec → drafting-plan → planned → in_progress → ready_for_review
230
+ │ │ ├─ revise → in_progress/planned
231
+ └─ revise ──┴───────────────┼─ approved bugs → in_progress
232
+ └─ approved clean review → completed → archived
233
+
234
+ completed/archived ── changed intent → successor track
235
+ ```
236
+
237
+ Only `review` can mark a track completed. Only `archive` can mark it archived. The `revise` command is callable in every state, but its behavior preserves approved history:
238
+
239
+ - `drafting-spec` changes continue the track draft without creating a revision.
240
+ - In `drafting-plan`, an approved-spec change is a revision while an unapproved-plan change remains drafting.
241
+ - `planned`, `in_progress`, and `ready_for_review` tracks can revise their approved baseline. Active work is reconciled first, completed commits are preserved, and changed scope at review time returns the track to implementation and manual verification.
242
+ - A revision that adds an incomplete dependency returns the track to `planned` so implementation remains blocked.
243
+ - `completed` and `archived` tracks remain immutable; Cadre proposes a successor feature or bug track referencing the original.
244
+
245
+ Defects found against the already approved specification belong to `review`. Use `revise` when the desired behavior, scope, requirement, or acceptance criterion itself changes.
246
+
247
+ ## Project state
248
+
249
+ An initialized project has this shape:
250
+
251
+ ```text
252
+ .cadre/
253
+ ├── .gitignore
254
+ ├── project.json
255
+ ├── product.md
256
+ ├── guidelines.md
257
+ ├── tech-stack.md
258
+ ├── workflow.md
259
+ ├── tracks.md
260
+ ├── styleguides/
261
+ ├── patterns/
262
+ ├── operations/
263
+ ├── refreshes/
264
+ ├── tracks/
265
+ │ └── <track-id>/
266
+ │ ├── state.json
267
+ │ ├── spec.md
268
+ │ ├── plan.md
269
+ │ ├── learning.md
270
+ │ ├── executions/
271
+ │ ├── bugs/
272
+ │ └── revisions/
273
+ ├── archive/
274
+ ├── .worktrees/ # ignored, temporary execution worktrees
275
+ └── wisps/ # ignored, disposable exploration output
276
+ ```
277
+
278
+ Important sources of truth:
279
+
280
+ - `spec.md` defines track scope and acceptance.
281
+ - `plan.md` defines the phase/task dependency DAG, task state, manual barriers, and commit provenance.
282
+ - `executions/execution-<id>.json` is the resumable runtime journal. Ready and active nodes are derived from it; track state does not duplicate an active phase or task.
283
+ - Track-local `state.json` defines identity, type, lifecycle status, track dependencies, revision, checkpoints, operation history, and the last completed execution reference.
284
+ - `project.json` contains project setup and refresh history; it does not duplicate track records.
285
+ - `.cadre/operations/refresh-<id>.json` and archive operation files preserve project-wide mutation checkpoints.
286
+ - `tracks.md` is generated from track-local state and is never hand-edited.
287
+ - Track directory paths are derived from status and ID. A path is never persisted in track state.
288
+
289
+ ## MCP capabilities
290
+
291
+ The `cadre` stdio server exposes immutable resources at `cadre://templates/v1/...` and these tools:
292
+
293
+ | Tool | Mutation | Purpose |
294
+ | --- | --- | --- |
295
+ | `template_catalog` | No | List template IDs, resource URIs, media types, and content hashes. |
296
+ | `template_get` | No | Read one versioned template by logical ID. |
297
+ | `template_get_many` | No | Read an ordered template bundle in one call; immutable catalog contents are cached for the server lifetime. |
298
+ | `styleguide_resolve` | No | Resolve default styleguides for an approved technology list. |
299
+ | `project_status` | No | Summarize project and track checkpoints, including resumable operations. |
300
+ | `state_validate` | No | Validate project, track, plan, learning, dependency, review, and archive invariants. |
301
+ | `execution_graph_validate` | No | Parse and validate phase/task dependencies, cycles, and derived manual-verification barriers. |
302
+ | `review_complete_preview` / `review_complete_apply` | Preview/apply | Bind a clean review and accepted risks to the current execution, then write completed state and the exact derived index together. |
303
+ | `archive_batch_preview` / `archive_batch_apply` | Preview/apply | Preview and apply selected moves, lifecycle states, patterns, seeds, journal, and post-archive index as one approved batch. |
304
+ | `archive_batch_record_preview` / `archive_batch_record_apply` | Preview/apply | Record the resulting archive commit in track, project, and batch provenance without a second batch decision. |
305
+ | `execution_start_preview` / `execution_start_apply` | Preview/apply | Create an approved, digest-gated execution journal and enter `in_progress`. |
306
+ | `execution_node_preview` / `execution_node_apply` | Preview/apply | Persist one legal, dependency-gated execution-node transition and return its derived execution status. |
307
+ | `execution_nodes_preview` / `execution_nodes_apply` | Preview/apply | Atomically persist an ordered batch of legal transitions behind one stale-state digest without crossing evidence or approval boundaries. |
308
+ | `execution_status` | No | Derive ready phases, ready tasks within running phases, active nodes, and blockers. |
309
+ | `execution_finish_preview` / `execution_finish_apply` | Preview/apply | Require completed nodes, current plan evidence, and removed worktrees before `ready_for_review`. |
310
+ | `worktree_create_preview` / `worktree_create_apply` | Preview/apply | Create or reconcile one derived phase/task worktree and branch. |
311
+ | `integration_preview` / `integration_apply` | Preview/apply | Inspect and merge a clean worker branch into its derived parent, reporting conflicts without resolving them. |
312
+ | `worktree_cleanup_preview` / `worktree_cleanup_apply` | Preview/apply | Remove only a clean worker whose branch is proven integrated into its parent. |
313
+ | `worktree_status` | No | Report Cadre-managed worktrees and orphaned runtime directories. |
314
+ | `project_init_preview` | No | Return the complete proposed initialization file set and digest. |
315
+ | `project_init_apply` | Yes | Atomically create `.cadre` only when inputs match the approved preview digest. |
316
+ | `setup_record_git_initialized` | Yes | Record the verified Git-initialization checkpoint. |
317
+ | `setup_record_commit` | Yes | Record the already-created setup commit SHA and complete setup state. |
318
+ | `tracks_render_preview` | No | Preview the derived `tracks.md` content and digest. |
319
+ | `tracks_render_apply` | Yes | Write `tracks.md` only when current state matches the approved preview digest. |
320
+
321
+ The MCP server cannot approve its own proposals or run arbitrary shell commands. Its Git surface is limited to derived Cadre worktree creation, non-squash integration, status, and verified cleanup. It never force-deletes a branch, resolves a conflict, edits product files, or commits on behalf of a worker. Deterministic writes and Git mutations use preview/apply digests to reject stale proposals.
322
+
323
+ Review and archive minimize approval fragmentation without weakening governance. A finding disposition and its exact remediation artifacts may share one approval; explicit reject-and-complete records accepted risks in the clean review; and a uniquely eligible archive target is included directly in the full batch proposal. The archive preview computes the post-move `tracks.md` before approval, including archived rows. Any changed content, selection, digest, or consequence requires a corrected proposal and renewed approval.
324
+
325
+ ### Worktree layout and worker model
326
+
327
+ Phase and task worktrees are siblings because Git worktrees cannot be physically nested safely:
328
+
329
+ ```text
330
+ .cadre/.worktrees/<track-id>/<execution-id>/
331
+ ├── phases/P1
332
+ └── tasks/P1--t1-1
333
+ ```
334
+
335
+ Task branches in one dependency wave start from the same clean phase HEAD and merge into the registered phase integration branch one at a time. The next wave starts from the updated phase HEAD. Direct canonical integration is reserved for an explicitly main-coordinated single-task phase; multi-task and phase-verified delivery uses a phase integration branch. Phase branches merge into the canonical branch. Cleanup prunes the worktree and branch only after ancestry proves the integration is present in the derived parent.
142
336
 
143
- - [Documentation Home](../docs/content/overview.md)
144
- - [Getting Started](../docs/content/getting-started.md)
145
- - [How Cadre Works](../docs/content/how-cadre-works.md)
146
- - [Workflows](../docs/content/workflows.md)
147
- - [Architecture](../docs/content/architecture.md)
148
- - [Team And Polyrepo](../docs/content/team-and-polyrepo.md)
149
- - [Parallel Execution](../docs/content/parallel-execution.md)
150
- - [Troubleshooting](../docs/content/troubleshooting.md)
337
+ Codex uses implementation subagents when parallel nodes are available. Claude Code uses the packaged `cadre-phase-worker` and `cadre-task-worker` definitions. Both follow the same contract: workers stay in their assigned worktree, read before editing, modify product files only, run focused verification, never spawn nested workers, and stop uncommitted until the main agent presents their work and obtains human approval. A phase worker holds only a temporary execution lease: it checkpoints one regular task at a time, creates a distinct approved commit for each task, and must report a clean committed HEAD and remain inactive before task-worker fan-out. The journal retains worker history across later reassignment. Manual-verification evidence does not require an empty commit. Claude agent teams are intentionally not required.
338
+
339
+ ## Resumability and safety
340
+
341
+ Multi-step state changes—including revisions, refreshes, reverts, archive batches, and implementation executions—write an operation or execution journal before artifact or Git mutation. On the next invocation, Cadre reconciles that journal with files, worker identities, registered worktrees, branches, dirty state, commits, and merges:
342
+
343
+ - matching dirty work resumes at the first incomplete checkpoint;
344
+ - a clean tree with the expected commit records the commit instead of repeating work;
345
+ - completed artifact work with pending bookkeeping finishes only the state-record commit;
346
+ - refresh and revert resumes reuse the approved artifact set and never repeat a recorded Git commit;
347
+ - committed or integrated DAG nodes are not repeated, and newly ready nodes are scheduled immediately after durable transitions;
348
+ - any mismatch stops and is presented to the human rather than guessed, discarded, reset, or restarted.
349
+
350
+ Task conflicts are resolved and reverified in the owning phase worktree. Phase conflicts are resolved and reverified in the canonical worktree. The main agent presents every resolution before recording its merge commit. A revision or refresh that changes execution-governing context first quiesces active workers and reconciles their work; a changed plan graph creates a new execution identity rather than rewriting the old journal.
351
+
352
+ Archive remains deliberately small: it accepts only tracks that centralized state validation already proves are `completed` with a clean review bound to the current execution, plan revision, graph digest, and reviewed head. It does not rerun implementation barriers or review logic.
353
+
354
+ Product work uses Conventional Commits. Cadre-only state commits use `cadre(<command>): <description>`. Reverts prefer additive `git revert` commits over destructive history rewriting.
355
+
356
+ ## Development
357
+
358
+ Useful commands:
359
+
360
+ ```sh
361
+ pnpm --filter cadre-ai check # TypeScript type checking
362
+ pnpm --filter cadre-ai test # Build and run integration tests
363
+ pnpm --filter cadre-ai validate # Build and validate skills, templates, runtime, and manifests
364
+ pnpm --filter cadre-ai build # Build dist/cadre-cli.mjs and dist/cadre-mcp.mjs
365
+ ```
366
+
367
+ The test suite exercises state validation, interrupted operations, DAG invariants, execution gating, nested task-to-phase and phase-to-main worktree integration, safe cleanup, marketplace packaging, MCP discovery and initialization, multi-track archival, and permission configuration. Before publishing a change, run:
368
+
369
+ ```sh
370
+ pnpm --filter cadre-ai check
371
+ pnpm --filter cadre-ai test
372
+ pnpm --filter cadre-ai validate
373
+ ```
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: cadre-phase-worker
3
+ description: Execute one internally sequential Cadre phase in an already-created assigned worktree and return a bounded implementation result to the main scheduler.
4
+ tools: Read, Edit, Write, Bash, Glob, Grep
5
+ ---
6
+
7
+ You are a Cadre phase implementation worker holding a temporary execution lease. The main agent owns the phase integration worktree operationally and remains the only scheduler and state owner.
8
+
9
+ - Operate only in the absolute worktree supplied by the main agent.
10
+ - Read the approved task context, dependency learning, relevant files, callers, tests, types, and configuration before editing.
11
+ - Edit product files only. Never edit `.cadre/**`.
12
+ - Do not spawn agents, merge, rebase, reset, clean up worktrees, delete branches, or use force operations.
13
+ - Never edit concurrently with task workers for this phase. When main requests a mode handoff, finish only the approved current-task checkpoint, verify the worktree is clean, report its committed HEAD, release the lease, and remain inactive until main explicitly reassigns you.
14
+ - Execute the assigned non-manual phase tasks in dependency order, with focused tests and checks, but checkpoint one regular task at a time.
15
+ - Do not claim or perform human approval. After each regular task, stop with only that task's proposed diff uncommitted and report changed files, verification, risks, learning candidates, and one Conventional Commit message.
16
+ - After the main agent reports explicit human approval, commit only that task, return its distinct SHA, and wait for confirmation that main recorded the checkpoint before starting the next task.
17
+ - Use available approved commands without prompting again. If an unexpected host permission is required, stop and report the exact command and reason to main instead of retrying variants.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: cadre-task-worker
3
+ description: Execute one ready Cadre task in an already-created assigned worktree and return a bounded implementation result to the main scheduler.
4
+ tools: Read, Edit, Write, Bash, Glob, Grep
5
+ ---
6
+
7
+ You are a Cadre task implementation worker. The main agent is the only scheduler and state owner.
8
+
9
+ - Operate only in the absolute worktree supplied by the main agent.
10
+ - Read the task, its dependency evidence, relevant files, callers, tests, types, and configuration before editing.
11
+ - Edit product files only. Never edit `.cadre/**`.
12
+ - Do not spawn agents, merge, rebase, reset, clean up worktrees, delete branches, or use force operations.
13
+ - Implement only the assigned task and run focused verification.
14
+ - Stop with the proposed diff uncommitted and report changed files, checks, risks, learning candidates, and the proposed Conventional Commit message.
15
+ - Commit only after the main agent reports explicit human approval, then return the commit SHA.
16
+ - Use available approved commands without prompting again. If an unexpected host permission is required, stop and report the exact command and reason to main instead of retrying variants.