cadre-ai 2.1.0 → 3.0.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 (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 +348 -107
  7. package/agents/cadre-phase-worker.md +17 -0
  8. package/agents/cadre-task-worker.md +16 -0
  9. package/dist/cadre-cli.mjs +2756 -0
  10. package/dist/cadre-mcp.mjs +33680 -0
  11. package/marketplace/claude.json +16 -0
  12. package/marketplace/codex.json +20 -0
  13. package/package.json +36 -34
  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/guidelines.md +25 -0
  36. package/templates/v1/init/operations/.gitkeep +1 -0
  37. package/templates/v1/init/patterns/index.md +6 -0
  38. package/templates/v1/init/product.md +30 -0
  39. package/templates/v1/init/project.json +26 -0
  40. package/templates/v1/init/refreshes/.gitkeep +1 -0
  41. package/templates/v1/init/styleguides/general.md +14 -0
  42. package/templates/v1/init/styleguides/language.md +21 -0
  43. package/templates/v1/init/tech-stack.md +21 -0
  44. package/templates/v1/init/tracks/.gitkeep +1 -0
  45. package/templates/v1/init/tracks.md +6 -0
  46. package/templates/v1/init/workflow.md +163 -0
  47. package/templates/v1/project/archive-operation.json +15 -0
  48. package/templates/v1/project/pattern.md +20 -0
  49. package/templates/v1/project/refresh-operation.json +14 -0
  50. package/templates/v1/project/refresh.md +21 -0
  51. package/templates/v1/styleguides/dart.md +27 -0
  52. package/templates/v1/styleguides/flutter.md +27 -0
  53. package/templates/v1/styleguides/go.md +29 -0
  54. package/templates/v1/styleguides/gradle.md +28 -0
  55. package/templates/v1/styleguides/html-css.md +39 -0
  56. package/templates/v1/styleguides/index.md +27 -0
  57. package/templates/v1/styleguides/java.md +27 -0
  58. package/templates/v1/styleguides/javascript.md +27 -0
  59. package/templates/v1/styleguides/kotlin.md +26 -0
  60. package/templates/v1/styleguides/maven.md +28 -0
  61. package/templates/v1/styleguides/python.md +27 -0
  62. package/templates/v1/styleguides/react.md +28 -0
  63. package/templates/v1/styleguides/swift.md +27 -0
  64. package/templates/v1/styleguides/swiftui.md +27 -0
  65. package/templates/v1/styleguides/typescript.md +26 -0
  66. package/templates/v1/track/bug.md +14 -0
  67. package/templates/v1/track/execution.json +18 -0
  68. package/templates/v1/track/learning.md +39 -0
  69. package/templates/v1/track/plan.md +39 -0
  70. package/templates/v1/track/revert-operation.json +13 -0
  71. package/templates/v1/track/revise-operation.json +14 -0
  72. package/templates/v1/track/revision.md +36 -0
  73. package/templates/v1/track/spec.md +38 -0
  74. package/templates/v1/track/state.json +25 -0
  75. package/scripts/cadre-cli.js +0 -869
  76. package/scripts/cadre-core.js +0 -14031
  77. package/scripts/cadre-job-runner.js +0 -3365
  78. package/scripts/cadre-lsp-daemon.js +0 -1212
  79. package/scripts/cadre-lsp-review.js +0 -1067
  80. package/scripts/cadre-lsp-setup.js +0 -470
  81. package/scripts/mcp/cadre-server.js +0 -16837
package/README.md CHANGED
@@ -1,128 +1,369 @@
1
1
  # Cadre
2
2
 
3
- ![Cadre logo](../docs/public/cadre-logo.png)
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
4
 
5
- **Measure twice, code once.**
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
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.
7
+ ## Capabilities
11
8
 
12
- Public docs: [https://cadre-docs.pages.dev/](https://cadre-docs.pages.dev/)
9
+ - Greenfield and brownfield project onboarding, with an explicit classification gate when the repository is ambiguous.
10
+ - Human approval of every generated artifact and lifecycle state transition.
11
+ - Resumable create, specification, planning, implementation, review, revision, refresh, revert, and archive flows.
12
+ - Parallel-by-default implementation of dependency DAGs, with an explicit sequential mode.
13
+ - Isolated phase and task workers in Cadre-managed Git worktrees, coordinated and integrated only by the main agent.
14
+ - Feature and bug tracks with functional requirements, non-functional requirements, acceptance criteria, dependencies, phased tasks, and manual-verification gates.
15
+ - Dependency enforcement before implementation and cascading-impact analysis after specification, workflow, stack, styleguide, or pattern changes.
16
+ - Incremental learning in each track's `learning.md`; every phase reads the previous phase's learning before work starts.
17
+ - Review → remediation → implementation cycles until the human accepts a clean review.
18
+ - Single-track or multi-track archival with consolidated pattern distillation and relevant reseeding of active tracks.
19
+ - Git-aware task, phase, setup, review, revision, refresh, revert, and archive provenance using Conventional Commits.
20
+ - Read-before-edit enforcement: existing files and directly relevant context must be inspected before modification.
21
+ - Stateless exploration through `wisp`, without mutating Cadre lifecycle state.
13
22
 
14
- ## What Cadre Provides
23
+ 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.
15
24
 
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 the skill contract, protocols, references, templates, and packet
27
- tools.
25
+ ## Requirements
26
+
27
+ - Node.js 18 or newer
28
+ - Git
29
+ - The `codex` CLI, the `claude` CLI, or both
28
30
 
29
31
  ## Install
30
32
 
31
- Install Cadre from npm and let the CLI wire detected clients:
33
+ Install the published CLI:
32
34
 
33
- ```bash
35
+ ```sh
34
36
  npm install -g cadre-ai
35
- cadre install
36
- cadre doctor
37
+ cadre-ai doctor
38
+ ```
39
+
40
+ Install for every detected client:
41
+
42
+ ```sh
43
+ cadre-ai install
44
+ ```
45
+
46
+ Install for only one agent:
47
+
48
+ ```sh
49
+ # Codex only
50
+ cadre-ai install --target codex
51
+
52
+ # Claude Code only
53
+ cadre-ai install --target claude
37
54
  ```
38
55
 
39
- ## Use
56
+ The installer:
57
+
58
+ 1. Packages the skills, MCP configuration, self-contained runtime, and
59
+ templates into a local marketplace.
60
+ 2. Registers the marketplace and installs `cadre@cadre` at user scope.
61
+ 3. Verifies that the selected agent reports the plugin as installed and enabled.
62
+ 4. Pre-approves only Cadre MCP tools so normal Cadre commands do not produce an
63
+ extra permission prompt.
64
+
65
+ The marketplace is stored at `~/.cadre/marketplaces/cadre`. When it is updated, the prior generated payload is retained as a timestamped backup.
66
+
67
+ ### MCP permission behavior
68
+
69
+ By default, installation applies these narrowly scoped rules:
70
+
71
+ - Codex: `default_tools_approval_mode = "approve"` under `plugins."cadre@cadre".mcp_servers.cadre` in the user Codex configuration.
72
+ - Claude Code: `cadre` in `enabledMcpjsonServers` and `mcp__cadre__*` in the
73
+ user permission allowlist.
74
+
75
+ 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.
76
+
77
+ 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.
78
+
79
+ To retain per-call MCP permission prompts:
80
+
81
+ ```sh
82
+ cadre-ai install --target codex --prompt-mcp-tools
83
+ ```
84
+
85
+ ### Other installer options
86
+
87
+ | Option | Effect |
88
+ | --- | --- |
89
+ | `--target auto\|all\|codex\|claude` | Select the target client; defaults to `auto`. |
90
+ | `--scope user` | Explicitly select the only supported installation scope. |
91
+ | `--replace-marketplace` | Replace another configured marketplace named `cadre` after the installer detects the path mismatch. |
92
+ | `--prompt-mcp-tools` | Do not add the Cadre MCP pre-approval rule. |
93
+ | `--prepare-only` | Build the marketplace without registering, installing, or changing permission configuration. |
94
+ | `--marketplace-root PATH` | Override the generated marketplace location; the path must end in `cadre`. |
95
+ | `--cachebuster TOKEN` | Supply an explicit package cachebuster instead of the generated timestamp. |
96
+ | `--dry-run` | Report the intended marketplace and client operations without applying them. |
97
+
98
+ Package-only example:
99
+
100
+ ```sh
101
+ cadre-ai install \
102
+ --target all \
103
+ --prepare-only \
104
+ --marketplace-root /tmp/cadre
105
+ ```
106
+
107
+ ### Update an existing installation
108
+
109
+ Install the desired package version and rerun the installer. It produces a new
110
+ cache-busted marketplace payload and updates the installed plugin:
111
+
112
+ ```sh
113
+ npm install -g cadre-ai@latest
114
+ cadre-ai doctor
115
+ cadre-ai install
116
+ ```
40
117
 
41
- In a target project, activate the Cadre skill and ask for the workflow you need:
118
+ `--replace-marketplace` is needed only when a client already has a marketplace
119
+ named `cadre` pointing somewhere else.
120
+
121
+ After installation or update:
122
+
123
+ - Start a new Codex conversation so the new skills and MCP tools are loaded.
124
+ - In Claude Code, run `/reload-plugins` or start a new session.
125
+
126
+ You can inspect installation state with:
127
+
128
+ ```sh
129
+ codex plugin list --json
130
+ claude plugin list --json
131
+ ```
132
+
133
+ ## Quick start
134
+
135
+ Cadre commands are agent skills, not shell commands. Invoke them in the Codex or Claude Code conversation.
136
+
137
+ ### 1. Initialize a project
138
+
139
+ From the project repository, invoke:
42
140
 
43
141
  ```text
44
- $cadre
45
- cadre-setup
46
- cadre-newtrack "Add OAuth login"
47
- cadre-implement
48
- cadre-review
49
- cadre-ship
50
- ```
51
-
52
- Cadre workflows are packet-owned. The agent verifies Cadre MCP, passes a
53
- per-call `root`, and lets the runtime perform state reads/writes, formula work,
54
- parallel worker state, provider evidence write-back, and shared sync. Do not
55
- maintain Cadre state by hand.
56
-
57
- ## Setup Outputs
58
-
59
- `cadre-setup` writes the project control plane:
60
-
61
- - `cadre/product.json` plus generated `cadre/product.md`
62
- - `cadre/product_guidelines.json` plus generated `cadre/product_guidelines.md`
63
- - `cadre/tech-stack.json`
64
- - `cadre/workflow.json` plus generated `cadre/workflow.md`
65
- - `cadre/tracks.json` as the generated track index
66
- - `cadre/patterns.jsonl` plus generated `cadre/patterns.md`
67
- - `cadre/config.json`
68
- - `cadre/events.jsonl`
69
- - `cadre/messages/outbox.jsonl` and `cadre/messages/inbox.jsonl`
70
- - `cadre/formulas/*.json` when formulas are added
71
- - git-ignored `cadre/local/wisps/*.json` for local ephemeral formula runs
72
- - `cadre/styleguides/*.json` plus generated `cadre/code_styleguides/*.md`
73
- - optional `cadre/repos.json` for polyrepo topology
74
- - optional `cadre/lsp.json` for LSP recommendations
75
- - repository-authored `cadre/skills/<skill-id>/skill.json` rule manifests with optional `SKILL.md` human projections
76
-
77
- Setup also initializes native Cadre state, can configure shared-sync merge
78
- attributes, and can scaffold hosted CI checks when requested.
79
-
80
- ## Team And Repo Modes
81
-
82
- Cadre supports monorepos and polyrepo control repos. For teams, use shared sync
83
- so ownership, leases, review state, blockers, and available work are visible to
84
- everyone. Product code publication still happens through ship/land workflows;
85
- shared sync is for the Cadre control plane.
86
-
87
- Project skills are local to the active repository. Maintainers add them through
88
- normal reviewed Git changes; Cadre selects them by workflow and optional
89
- polyrepo `repos` targeting, returns bounded instructions in workflow packets,
90
- and exposes references lazily through MCP resources. Project skills never fall
91
- back to a global catalog and never execute scripts automatically.
92
-
93
- Compact MCP resources provide bounded views for larger teams:
94
-
95
- - team board and next actions
96
- - review queue and handoff inbox
97
- - quality gate and parallel worker state
98
- - repo topology, repo map, workspace diagnostics, test impact, and LSP status
99
- - provider action plans and async job results
100
-
101
- ## Harness Development
102
-
103
- This repository is the Cadre harness/package repo. Runtime sources live in
104
- `src/`, master skill/protocol sources live in `skills/cadre/`, references live
105
- in `scripts/agent-refs/`, and templates live in `templates/`.
106
-
107
- Run package commands from the repository root:
108
-
109
- ```bash
110
- pnpm --filter cadre-ai generate
111
- pnpm --filter cadre-ai check
142
+ Codex: $cadre:create
143
+ Claude Code: /cadre:create
144
+ ```
145
+
146
+ Cadre will:
147
+
148
+ 1. Inspect the repository and Git state.
149
+ 2. Classify it as greenfield or brownfield, asking when the evidence is unclear.
150
+ 3. Propose product, engineering, tech-stack, workflow, and applicable styleguide artifacts.
151
+ 4. Ask for separate approval of the default or amended workflow and styleguides.
152
+ 5. Preview the exact `.cadre` file set before applying it.
153
+ 6. Initialize Git when the approved project root is not already in a worktree.
154
+ 7. Validate and commit the approved setup with resumable checkpoints.
155
+
156
+ ### 2. Create a feature or bug track
157
+
158
+ ```text
159
+ Codex: $cadre:track Add passwordless login as a feature
160
+ Claude Code: /cadre:track Fix duplicate invoice creation as a bug
161
+ ```
162
+
163
+ Cadre proposes and separately approves:
164
+
165
+ - `spec.md`, containing functional requirements, non-functional requirements, acceptance criteria, dependencies, additional information, and dependent-track impact;
166
+ - `plan.md`, defining an acyclic phase/task dependency graph with derived manual-verification barriers;
167
+ - `learning.md`, whose marked Pattern Seed contains only patterns relevant to the approved track.
168
+
169
+ Every delivery phase ends with `User Manual Verification`. The final phase is always `Track-level User Manual Verification`.
170
+
171
+ ### 3. Implement the approved plan
172
+
173
+ ```text
174
+ Codex: $cadre:implement passwordless-login
175
+ Claude Code: /cadre:implement passwordless-login
176
+ ```
177
+
178
+ Parallel mode is the default. Request sequential execution explicitly when needed:
179
+
180
+ ```text
181
+ Codex: $cadre:implement passwordless-login sequentially
182
+ Claude Code: /cadre:implement passwordless-login sequentially
183
+ ```
184
+
185
+ 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.
186
+
187
+ 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.
188
+
189
+ ### 4. Review and complete the track
190
+
191
+ ```text
192
+ Codex: $cadre:review passwordless-login
193
+ Claude Code: /cadre:review passwordless-login
112
194
  ```
113
195
 
114
- Generated plugin bundles under `.agents/`, `.claude/`, and `plugins/` are
115
- rebuilt from master sources. They contain only platform manifests, MCP config,
116
- and `SKILL.md`; the embedded MCP runtime is built under `scripts/`.
196
+ 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`.
197
+
198
+ ### 5. Archive completed work
199
+
200
+ ```text
201
+ Codex: $cadre:archive passwordless-login account-lockout
202
+ Claude Code: /cadre:archive all completed
203
+ ```
204
+
205
+ 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.
206
+
207
+ ## Command reference
208
+
209
+ | Command | Purpose |
210
+ | --- | --- |
211
+ | `create` | Initialize or resume Cadre, classify project context, initialize Git when needed, and establish approved project artifacts. |
212
+ | `track` | Create or resume a feature/bug specification, phased plan, dependency set, and learning seed. |
213
+ | `implement` | Execute or resume the approved phase/task DAG in parallel by default or explicitly sequentially, with worktrees, tests, learning, approvals, and commit provenance. |
214
+ | `review` | Review a ready track, record approved findings, add remediation phases, or complete an approved clean cycle. |
215
+ | `revise` | Route a requested change by lifecycle state, revise an approved active baseline, or propose a successor for completed history. |
216
+ | `archive` | Archive one or more completed tracks, distill patterns, and reseed active tracks by relevance. |
217
+ | `refresh` | Refresh project context from user input, repository changes, and completed-track outcomes. |
218
+ | `revert` | Prepare and execute a human-approved additive Git revert for a task, phase, or track. |
219
+ | `status` | Validate and summarize project, operation, track, dependency, review, and archive state without mutation. |
220
+ | `wisp` | Explore or investigate without creating or changing Cadre lifecycle state. |
221
+
222
+ ## Lifecycle
223
+
224
+ ```text
225
+ drafting-spec → drafting-plan → planned → in_progress → ready_for_review
226
+ │ │ ├─ revise → in_progress/planned
227
+ └─ revise ──┴───────────────┼─ approved bugs → in_progress
228
+ └─ approved clean review → completed → archived
229
+
230
+ completed/archived ── changed intent → successor track
231
+ ```
232
+
233
+ 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:
234
+
235
+ - `drafting-spec` changes continue the track draft without creating a revision.
236
+ - In `drafting-plan`, an approved-spec change is a revision while an unapproved-plan change remains drafting.
237
+ - `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.
238
+ - A revision that adds an incomplete dependency returns the track to `planned` so implementation remains blocked.
239
+ - `completed` and `archived` tracks remain immutable; Cadre proposes a successor feature or bug track referencing the original.
240
+
241
+ Defects found against the already approved specification belong to `review`. Use `revise` when the desired behavior, scope, requirement, or acceptance criterion itself changes.
242
+
243
+ ## Project state
244
+
245
+ An initialized project has this shape:
246
+
247
+ ```text
248
+ .cadre/
249
+ ├── .gitignore
250
+ ├── project.json
251
+ ├── product.md
252
+ ├── guidelines.md
253
+ ├── tech-stack.md
254
+ ├── workflow.md
255
+ ├── tracks.md
256
+ ├── styleguides/
257
+ ├── patterns/
258
+ ├── operations/
259
+ ├── refreshes/
260
+ ├── tracks/
261
+ │ └── <track-id>/
262
+ │ ├── state.json
263
+ │ ├── spec.md
264
+ │ ├── plan.md
265
+ │ ├── learning.md
266
+ │ ├── executions/
267
+ │ ├── bugs/
268
+ │ └── revisions/
269
+ ├── archive/
270
+ ├── .worktrees/ # ignored, temporary execution worktrees
271
+ └── wisps/ # ignored, disposable exploration output
272
+ ```
117
273
 
118
- Public documentation lives in the repo-root `docs/` Next.js app. Markdown page
119
- source is in `docs/content/`:
274
+ Important sources of truth:
120
275
 
121
- - [Documentation Home](../docs/content/overview.md)
122
- - [Getting Started](../docs/content/getting-started.md)
123
- - [How Cadre Works](../docs/content/how-cadre-works.md)
124
- - [Workflows](../docs/content/workflows.md)
125
- - [Architecture](../docs/content/architecture.md)
126
- - [Team And Polyrepo](../docs/content/team-and-polyrepo.md)
127
- - [Parallel Execution](../docs/content/parallel-execution.md)
128
- - [Troubleshooting](../docs/content/troubleshooting.md)
276
+ - `spec.md` defines track scope and acceptance.
277
+ - `plan.md` defines the phase/task dependency DAG, task state, manual barriers, and commit provenance.
278
+ - `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.
279
+ - Track-local `state.json` defines identity, type, lifecycle status, track dependencies, revision, checkpoints, operation history, and the last completed execution reference.
280
+ - `project.json` contains project setup and refresh history; it does not duplicate track records.
281
+ - `.cadre/operations/refresh-<id>.json` and archive operation files preserve project-wide mutation checkpoints.
282
+ - `tracks.md` is generated from track-local state and is never hand-edited.
283
+ - Track directory paths are derived from status and ID. A path is never persisted in track state.
284
+
285
+ ## MCP capabilities
286
+
287
+ The `cadre` stdio server exposes immutable resources at `cadre://templates/v1/...` and these tools:
288
+
289
+ | Tool | Mutation | Purpose |
290
+ | --- | --- | --- |
291
+ | `template_catalog` | No | List template IDs, resource URIs, media types, and content hashes. |
292
+ | `template_get` | No | Read one versioned template by logical ID. |
293
+ | `template_get_many` | No | Read an ordered template bundle in one call; immutable catalog contents are cached for the server lifetime. |
294
+ | `styleguide_resolve` | No | Resolve default styleguides for an approved technology list. |
295
+ | `project_status` | No | Summarize project and track checkpoints, including resumable operations. |
296
+ | `state_validate` | No | Validate project, track, plan, learning, dependency, review, and archive invariants. |
297
+ | `execution_graph_validate` | No | Parse and validate phase/task dependencies, cycles, and derived manual-verification barriers. |
298
+ | `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. |
299
+ | `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. |
300
+ | `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. |
301
+ | `execution_start_preview` / `execution_start_apply` | Preview/apply | Create an approved, digest-gated execution journal and enter `in_progress`. |
302
+ | `execution_node_preview` / `execution_node_apply` | Preview/apply | Persist one legal, dependency-gated execution-node transition and return its derived execution status. |
303
+ | `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. |
304
+ | `execution_status` | No | Derive ready phases, ready tasks within running phases, active nodes, and blockers. |
305
+ | `execution_finish_preview` / `execution_finish_apply` | Preview/apply | Require completed nodes, current plan evidence, and removed worktrees before `ready_for_review`. |
306
+ | `worktree_create_preview` / `worktree_create_apply` | Preview/apply | Create or reconcile one derived phase/task worktree and branch. |
307
+ | `integration_preview` / `integration_apply` | Preview/apply | Inspect and merge a clean worker branch into its derived parent, reporting conflicts without resolving them. |
308
+ | `worktree_cleanup_preview` / `worktree_cleanup_apply` | Preview/apply | Remove only a clean worker whose branch is proven integrated into its parent. |
309
+ | `worktree_status` | No | Report Cadre-managed worktrees and orphaned runtime directories. |
310
+ | `project_init_preview` | No | Return the complete proposed initialization file set and digest. |
311
+ | `project_init_apply` | Yes | Atomically create `.cadre` only when inputs match the approved preview digest. |
312
+ | `setup_record_git_initialized` | Yes | Record the verified Git-initialization checkpoint. |
313
+ | `setup_record_commit` | Yes | Record the already-created setup commit SHA and complete setup state. |
314
+ | `tracks_render_preview` | No | Preview the derived `tracks.md` content and digest. |
315
+ | `tracks_render_apply` | Yes | Write `tracks.md` only when current state matches the approved preview digest. |
316
+
317
+ 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.
318
+
319
+ 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.
320
+
321
+ ### Worktree layout and worker model
322
+
323
+ Phase and task worktrees are siblings because Git worktrees cannot be physically nested safely:
324
+
325
+ ```text
326
+ .cadre/.worktrees/<track-id>/<execution-id>/
327
+ ├── phases/P1
328
+ └── tasks/P1--t1-1
329
+ ```
330
+
331
+ 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.
332
+
333
+ 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.
334
+
335
+ ## Resumability and safety
336
+
337
+ 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:
338
+
339
+ - matching dirty work resumes at the first incomplete checkpoint;
340
+ - a clean tree with the expected commit records the commit instead of repeating work;
341
+ - completed artifact work with pending bookkeeping finishes only the state-record commit;
342
+ - refresh and revert resumes reuse the approved artifact set and never repeat a recorded Git commit;
343
+ - committed or integrated DAG nodes are not repeated, and newly ready nodes are scheduled immediately after durable transitions;
344
+ - any mismatch stops and is presented to the human rather than guessed, discarded, reset, or restarted.
345
+
346
+ 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.
347
+
348
+ 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.
349
+
350
+ Product work uses Conventional Commits. Cadre-only state commits use `cadre(<command>): <description>`. Reverts prefer additive `git revert` commits over destructive history rewriting.
351
+
352
+ ## Development
353
+
354
+ Useful commands:
355
+
356
+ ```sh
357
+ pnpm --filter cadre-ai check # TypeScript type checking
358
+ pnpm --filter cadre-ai test # Build and run integration tests
359
+ pnpm --filter cadre-ai validate # Build and validate skills, templates, runtime, and manifests
360
+ pnpm --filter cadre-ai build # Build dist/cadre-cli.mjs and dist/cadre-mcp.mjs
361
+ ```
362
+
363
+ 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:
364
+
365
+ ```sh
366
+ pnpm --filter cadre-ai check
367
+ pnpm --filter cadre-ai test
368
+ pnpm --filter cadre-ai validate
369
+ ```
@@ -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.