archgen-mcp 0.0.7 → 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 (42) hide show
  1. package/README.md +2 -6
  2. package/assets/briefs/investigate.md +16 -17
  3. package/assets/briefs/review.md +41 -29
  4. package/assets/briefs/survey.md +17 -20
  5. package/assets/briefs/verifier.md +52 -40
  6. package/assets/harness-mcp.json +6 -6
  7. package/assets/platform-capabilities.json +387 -71
  8. package/assets/references/artifact-templates.md +67 -232
  9. package/assets/references/interview.md +83 -199
  10. package/assets/references/mcp-and-skills.md +35 -125
  11. package/assets/references/orchestration.md +96 -209
  12. package/assets/references/platforms.md +41 -110
  13. package/assets/skill-registry.json +10 -1
  14. package/assets/templates/adr.md +3 -3
  15. package/assets/templates/architecture.yaml +31 -28
  16. package/assets/templates/edge-matrix.md +8 -8
  17. package/assets/templates/mermaid.md +3 -10
  18. package/assets/templates/prd.md +15 -15
  19. package/assets/templates/tasks.yaml +25 -18
  20. package/package.json +2 -2
  21. package/src/cli.mjs +1 -2
  22. package/src/context.mjs +12 -42
  23. package/src/core/brief-context.mjs +106 -0
  24. package/src/core/brief-scope.mjs +218 -0
  25. package/src/core/briefs.mjs +109 -1
  26. package/src/core/codegraph-manager.mjs +12 -0
  27. package/src/core/doc-navigator.mjs +101 -17
  28. package/src/core/errors.mjs +1 -1
  29. package/src/core/harness-wiring.mjs +65 -22
  30. package/src/core/jsonc-config.mjs +706 -0
  31. package/src/core/plan-grapher.mjs +11 -3
  32. package/src/core/skill-manager.mjs +181 -13
  33. package/src/core/skill-roots.mjs +92 -0
  34. package/src/core/tokens.mjs +78 -0
  35. package/src/core/worker-contract.mjs +145 -18
  36. package/src/server.mjs +0 -3
  37. package/src/tools/help.mjs +17 -34
  38. package/src/tools/plan.mjs +36 -22
  39. package/src/tools/skills.mjs +67 -5
  40. package/src/tools/tasks.mjs +44 -18
  41. package/src/core/ui-channel.mjs +0 -222
  42. package/src/tools/ui.mjs +0 -67
@@ -1,262 +1,149 @@
1
1
  # Orchestration playbook — survey, verify, dispatch
2
2
 
3
- Sub-agent briefs and the wave-execution mechanics. The orchestrator (SKILL.md)
4
- calls into these sections; workers never read this file.
3
+ Sub-agent briefs and wave-execution rules for the orchestrator (`SKILL.md`). Workers never read this file.
5
4
 
6
5
  ## §survey — brownfield codebase analysis brief
7
6
 
8
- **The brief is a tool output:** `archgen_plan { action: 'brief', kind: 'survey' }`.
9
- Dispatch 1–2 sub-agents with it verbatim — do not hand-write the prompt.
10
-
11
- Accept the map only if every section is present and non-empty.
7
+ Dispatch 1–2 survey sub-agents with `archgen_plan{action:'brief', kind:'survey'}` verbatim. Accept `.archgen/<slug>/codebase-map.md` only when all required sections (`Structure`, `Modules`, `Conventions`, `Affected`) are present and non-empty.
12
8
 
13
9
  ## §verifier — plan review brief
14
10
 
15
- Dispatch AFTER artifacts exist and `archgen_plan{action:'validate'}` passes.
11
+ Dispatch AFTER artifacts exist and `archgen_plan{action:'validate'}` returns `data.valid:true`.
16
12
 
17
13
  ### Agent tier — EVERY verifier dispatch
14
+ - **SMALL / MEDIUM plan:** 1 strong mid/high-tier reasoning agent.
15
+ - **LARGE plan:** 1 top-tier reasoning agent.
16
+ - **FORBIDDEN:** Never use explore, quick, fast, or cheap/low-tier models—weak verifiers miss defects and cause extra rounds.
18
17
 
19
- Verification is judgment-heavy: a weak verifier misses real defects AND raises
20
- false positives — costing MORE rounds, not fewer. Dispatch on the strongest
21
- reasoning agent the harness offers (best agent present), or a mid/high-tier
22
- sub-agent scaled to plan complexity:
23
-
24
- - SMALL/MEDIUM plan → one strong (mid/high-tier) agent.
25
- - LARGE plan → the stronger/highest tier available.
26
- - NEVER an explore / research / quick / small / cheap / fast sub-agent,
27
- whatever the harness calls its low-end tiers.
18
+ ### ONE agent, the WHOLE plan, ONE pass
19
+ - **Never split verification across concerns.** One holistic verifier detects cross-artifact contradictions that sliced agents miss. (If a plan exceeds context limits, split strictly by artifact volume—e.g., `plans/` vs `docs/`—never by verification dimension).
20
+ - **Exhaustive single pass.** The verifier MUST return a complete `COVERAGE:` table (`PASS` / `FAIL` / `N/A` for every dimension) so all issues surface in Round 1.
28
21
 
29
22
  ### Verification pass — FULL-DEPTH, every run
30
23
 
31
- **The brief is a tool output:** `archgen_plan { action: 'brief', kind: 'verifier' }`.
32
- Dispatch it verbatim — do not hand-write the prompt.
33
-
34
- Each verifier run executes ALL four steps:
35
-
36
- 1. Runs `archgen_plan{action:'verify', tasksYaml, planDir}` — deterministic
37
- floor: cycles, dangling refs, same-wave ownership overlap, missing acceptance
38
- criteria, plan↔task coverage. It returns a verdict of `APPROVE` or `ISSUES`.
39
- 2. When markdown artifacts exist under `.archgen/<slug>/`, runs
40
- `archgen_docs{action:'validate', slugDir}` — must be clean (`ok:true`, zero
41
- broken references) alongside the verifier's APPROVE; broken references block
42
- APPROVAL.
43
- 3. Reads plans + tasks.yaml and judges what the tools cannot (the full
44
- checklist is in the brief):
45
- - Are wave boundaries sensible (no artificial serialization)?
46
- - Do acceptance criteria objectively verify (command or observable)?
47
- - Edge cases covered per SKILL.md right-sizing class?
48
- - Code-standards compliance plausible for the planned structure?
49
- - the CONTRACT-COMPLETENESS sweep (functional coverage, security, data
50
- integrity, state/lifecycle/recovery, resource limits, operational
51
- entrypoints, metric traceability, consistency) — the brief lists every
52
- dimension and says when to apply it. These failure classes are the TOP
53
- cause of multi-round loops: round 1 MUST sweep the applicable dimensions
54
- exhaustively.
55
- 4. Returns EXACTLY one line verdict: `APPROVE` or `ISSUES:` + numbered list.
24
+ Pass the output of `archgen_plan{action:'brief', kind:'verifier'}` verbatim (includes pre-rendered evidence map, Mermaid dependency graph, and `archgen_docs` validation status). The verifier executes all four steps:
25
+ 1. Runs `archgen_plan{action:'verify', tasksYaml, planDir}` $\rightarrow$ requires `APPROVE` (checks cycles, dangling refs, wave ownership overlap, acceptance criteria, bidirectional plan$\leftrightarrow$task coverage).
26
+ 2. Runs `archgen_docs{action:'validate', slugDir}` (if markdown exists) $\rightarrow$ requires `valid:true` (zero broken links/anchors).
27
+ 3. Audits judgment dimensions across `plans/` and `tasks.yaml`:
28
+ - Wave boundary sanity (no artificial serialization).
29
+ - Objectively verifiable acceptance criteria (runnable command or observable output).
30
+ - Scope-appropriate edge-case coverage (`SKILL.md` Hard Rule 3).
31
+ - `references/code-standards.md` compliance.
32
+ - **Contract-completeness sweep** across all applicable dimensions: `functional coverage`, `security & data protection`, `data integrity`, `state, lifecycle & recovery`, `resource limits & abuse`, `operational entrypoints`, `metric traceability`, and `consistency`.
33
+ 4. Outputs the strict deliverable format:
34
+ ```
35
+ VERDICT: APPROVE | ISSUES
36
+ COVERAGE:
37
+ | dimension | status | reason | <- every dimension marked PASS / FAIL / N/A
38
+ FINDINGS: <- present when VERDICT: ISSUES
39
+ 1. file § section — defect — impact — concrete fix
40
+ ```
41
+ *Any report missing the `COVERAGE:` table is incomplete—treat as `ISSUES` and require examination of omitted dimensions.*
56
42
 
57
43
  ### Efficiency — fewer rounds + zero duplicate work, NEVER shallower checks
58
-
59
- Every run stays FULL-DEPTH: both checks run to completion and the full
60
- judgment checklist applies each time. Efficiency comes ONLY from:
61
-
62
- - capping automatic rounds at 2 (gate protocol below);
63
- - batching fixes per file (fix discipline below);
64
- - never re-fixing an already-resolved finding.
65
-
66
- "Efficient" NEVER means skipping or lightening the verifier, the docs
67
- integrity check, or any judgment-checklist item.
44
+ Never weaken or skip checks. Efficiency comes strictly from: (1) the exhaustive coverage table, (2) capping automatic rounds at 2, (3) batching fixes per file, and (4) never re-applying failed edits.
68
45
 
69
46
  ### Fix discipline — batch per file, dedupe repeats
70
-
71
- On `ISSUES:` the orchestrator fixes ALL findings before re-dispatching:
72
-
73
- - Group findings BY FILE; apply each file's fixes in ONE edit pass — open
74
- each file once per round, not once per finding.
75
- - Round N reports the SAME finding as round N-1 (same file + same issue) →
76
- the prior fix did not land: re-read the file and fix it properly — never
77
- re-apply the identical edit.
47
+ When `VERDICT: ISSUES` returns:
48
+ - Group findings by file and apply all fixes to a file in a single edit pass.
49
+ - If Round $N$ reports the identical finding as Round $N-1$, re-read the target file and apply a structural fix rather than repeating the prior edit.
50
+ - If you disagree with a verifier finding, surface it verbatim to the user rather than ignoring or silently overriding it.
78
51
 
79
52
  ### Gate protocol — 2 automatic rounds, then ask the user
80
-
81
- The initial VERIFIER GATE flow (GENERATE step 5). Rounds 1–2 run
82
- automatically; fix ALL findings between rounds (fix discipline above):
83
-
84
- 1. Round 1: dispatch verifier. `APPROVE` → gate passed → §plan-review.
85
- `ISSUES:` → fix ALL findings → round 2.
86
- 2. Round 2: dispatch verifier.
87
- - Clean `APPROVE` → ask the user once more, recommending NO, proceed.
88
- - `ISSUES:` → fix ALL findings → ask the user once more, recommending
89
- YES, one more pass.
90
- Ask recommendation-first per §interview/how-to-ask: "Run the verifier
91
- once more to make sure everything passes?"
92
- 3. On YES → run another round; if it returns `ISSUES:`, fix all and ask again
93
- — every round beyond 2 is user-approved. On NO → proceed to §plan-review.
94
- 4. On NO with findings still outstanding and no verifier `APPROVE` on record:
95
- surface every outstanding finding verbatim and require an EXPLICIT user
96
- waiver — never proceed silently. Hard rule 2 stands: the plan MUST NOT
97
- reach the USER GATE without at least one verifier `APPROVE` (or that
98
- explicit waiver on the record). An earlier `APPROVE` on record → proceed
99
- to §plan-review, noting the latest unverified fixes.
53
+ 1. **Round 1:** Dispatch verifier. `APPROVE` $\rightarrow$ proceed to `§plan-review`. `ISSUES` $\rightarrow$ batch-fix all findings $\rightarrow$ Round 2.
54
+ 2. **Round 2:** Dispatch verifier.
55
+ - `APPROVE` $\rightarrow$ ask user recommendation-first: *"Run the verifier once more? 1. No, proceed (recommended) 2. Yes, run one more pass."*
56
+ - `ISSUES` $\rightarrow$ batch-fix all findings $\rightarrow$ ask user recommendation-first: *"Run the verifier once more to confirm fixes? 1. Yes, one more pass (recommended) 2. Waive remaining findings and proceed."*
57
+ 3. **Round 3+ (user-approved):** Each approval runs 1 pass.
58
+ 4. **Proceeding without `APPROVE`:** If the user declines another pass without a prior `APPROVE` on record, quote all unverified/outstanding findings verbatim and obtain an **explicit user waiver** before entering `§plan-review` (Hard Rule 2). Never cite token/cost numbers when reporting rounds.
100
59
 
101
60
  ## §plan-review — post-plan review stage
102
61
 
103
- Run AFTER the verifier returns APPROVE and BEFORE the user gate. Dispatch
104
- REVIEWER sub-agents sized by the right-sizing class — always ONE holistic
105
- review of the WHOLE plan, never per-concern splits:
106
-
107
- - SMALL: main-agent self-review acceptable if no reviewer mechanism exists.
108
- - MEDIUM: 1 reviewer.
109
- - LARGE: 1 holistic reviewer on the strongest reasoning tier. A 2nd reviewer
110
- ONLY if the plan is genuinely too large for one reviewer's context — split
111
- by ARTIFACT/VOLUME then (e.g. plans vs docs), never by concern.
112
-
113
- One holistic reviewer analyzes ALL issues together: cross-issue reasoning
114
- catches contradictions a narrow per-concern slice misses, and one reviewer
115
- costs far fewer tokens than several. NEVER dispatch one sub-agent per
116
- individual issue/concern.
117
-
118
- **The brief is a tool output:** `archgen_plan { action: 'brief', kind: 'review' }`.
119
- Dispatch it verbatim — it already carries the mermaid graph + docs-validate
120
- context to attach.
121
-
122
- Reviewers are read-only and report-only — they never edit artifacts or code.
123
- The orchestrator fixes the artifacts itself, re-runs validate +
124
- re-dispatches the verifier gate after every change.
125
-
126
- ### Review loop — bounded passes, then ask
127
-
128
- The fix→re-verify cycle stays, but reviewer passes are countable and bounded:
129
-
130
- 1. Pass 1: holistic review. Zero findings → stage done.
131
- 2. Findings → fix ALL (batched per file), re-run validate + the verifier
132
- gate → pass 2.
133
- 3. Pass 2 still yields findings → do NOT spawn more reviewers. Consolidate
134
- the outstanding findings and ask the user once, recommendation-first per
135
- §interview/how-to-ask: "Run one more targeted review pass on the N
136
- open findings? 1. One more pass (recommended) 2. Waive these findings and
137
- proceed."
138
- 4. On YES → run EXACTLY ONE more pass, then consolidate and STOP. Zero
139
- findings → stage done; findings remain → surface them and require an
140
- explicit user waiver before the user gate. On NO → record the explicit
141
- waiver, proceed.
142
-
143
- A "more review" approval authorizes EXACTLY ONE additional pass — never a
144
- fresh loop, never more reviewers. The stage ends ONLY at zero findings or an
145
- explicit user waiver on record.
146
-
147
- ## §investigate — root-cause protocol
148
-
149
- Triggered when the USER reports repetitive/recurring issues AFTER implementation
150
- waves completed. Do NOT patch-fix under this protocol.
151
-
152
- **The brief is a tool output:** `archgen_plan { action: 'brief', kind: 'investigate' }`.
153
- Complexity-sized dispatch:
62
+ Run AFTER Verifier `APPROVE` and BEFORE the User Gate. Dispatch read-only reviewer(s) using `archgen_plan{action:'brief', kind:'review'}` verbatim (pre-renders dependency graph, doc validation, and evidence map; reviewer makes zero `archgen_*` tool calls):
63
+ - **SMALL:** Main-agent self-review permitted if sub-agents are unavailable.
64
+ - **MEDIUM:** 1 holistic reviewer.
65
+ - **LARGE:** 1 top-tier holistic reviewer (2nd allowed ONLY if context size requires splitting `plans/` vs `docs/`; never split by concern).
154
66
 
155
- - SMALL scope: main agent investigates directly.
156
- - MEDIUM/LARGE: 1–3 investigator sub-agents split by suspected subsystem.
67
+ Reviewers are strictly read-only. The orchestrator applies fixes, re-runs `validate` + Verifier Gate, and manages the bounded review loop:
68
+ 1. **Pass 1:** Zero findings $\rightarrow$ stage complete. Findings $\rightarrow$ batch-fix per file, re-run `validate` + Verifier Gate $\rightarrow$ Pass 2.
69
+ 2. **Pass 2:** Zero findings $\rightarrow$ stage complete. Findings remain $\rightarrow$ consolidate and ask user once (`§interview/how-to-ask`): *"Run one more targeted review pass on the N open findings? 1. One more pass (recommended) 2. Waive findings and proceed."*
70
+ 3. **Pass 3 (final):** On `1`, run **EXACTLY ONE** final pass, then stop. If findings remain, require an explicit user waiver before the User Gate.
157
71
 
158
- Investigators produce ALL four:
72
+ ## §investigate — root-cause protocol
159
73
 
160
- 1. Root cause statement — one sentence naming the actual defect.
161
- 2. Evidence — files/lines/repro steps.
162
- 3. Blast radius — which tasks/artifacts are affected
163
- (`archgen_plan{action:'impact', tasksYaml, target}`).
164
- 4. Remediation plan — routed through the normal gates: new fix tasks get fresh
165
- ids inheriting the affected task's ownership globs.
74
+ Triggered when the user reports recurring defects after wave execution. Pass `archgen_plan{action:'brief', kind:'investigate'}` verbatim:
75
+ - **SMALL:** Main agent investigates directly.
76
+ - **MEDIUM / LARGE:** 1–3 read-only investigator sub-agents split by disjoint suspected subsystem.
166
77
 
167
- Token discipline: investigators read narrowly around evidence, not whole-repo
168
- sweeps. Patch-fixes without a root-cause statement are forbidden under this
169
- protocol.
78
+ Mandatory 4-part deliverable (no patch-fixing allowed):
79
+ 1. **Root cause statement:** One sentence identifying the underlying defect.
80
+ 2. **Evidence:** Exact file paths, line numbers, and reproduction steps.
81
+ 3. **Blast radius:** Affected tasks/artifacts via `archgen_plan{action:'impact', tasksYaml, target}`.
82
+ 4. **Remediation plan:** New fix tasks with fresh IDs inheriting affected `file_ownership` globs, routed through normal Verifier/Review/User gates.
170
83
 
171
84
  ## §dispatch — wave execution
172
85
 
173
- Dispatch policy: dispatch each task to the harness's NATIVE sub-agent mechanism
174
- when available AND functional. If sub-agents do not exist on this platform, or
175
- the sub-agent fails, or lacks required tool permissions (read/write/etc.), the
176
- MAIN AGENT executes the task ITSELF — sequentially, respecting waves and
177
- ownership globs. Cross-harness/platform delegation is allowed ONLY through an
178
- explicit user gate (below). There is NO automatic fallback to other harnesses,
179
- platforms, or CLIs — ever.
86
+ Dispatch tasks via the platform's native sub-agent mechanism (`archgen_setup{action:'harness_info'}`). If sub-agents are missing, fail to spawn, or lack file permissions, the **main agent executes tasks sequentially itself**. Never switch harnesses or spawn external CLIs without explicit user approval.
180
87
 
181
- ### Native sub-agents (preferred)
88
+ ### WHEN to dispatch a sub-agent — and when NOT to
182
89
 
183
- - Claude Code: background Agent tool per task; add worktree isolation for
184
- tasks whose ownership might brush shared files.
185
- - Cursor: background subagents; request isolation when >2 parallel workers.
186
- - Antigravity: invoke_subagent async.
187
- - Codex: spawn_agent works but children can't nest — flatten the plan instead.
188
- - Gemini CLI: parallel @agents are hub-and-spoke only AND have no isolation →
189
- use them ONLY for read-only/research waves unless wrapping in worktrees.
90
+ **Sub-agents are for bounded implementation/analysis work, NEVER for state lookups:**
190
91
 
191
- ### When sub-agents are unavailable or fail
92
+ | Operation | Executor |
93
+ |---|---|
94
+ | Wave frontier, task list, task status (`archgen_tasks{next\|list}`) | **MAIN AGENT** (1 tool call; NEVER a sub-agent) |
95
+ | Plan health, graph, coverage, impact (`archgen_plan`, `archgen_docs`) | **MAIN AGENT** (1 tool call; NEVER a sub-agent) |
96
+ | Registry update, resume snapshot, CodeGraph status | **MAIN AGENT** (1 tool call; NEVER a sub-agent) |
97
+ | Single task implementation | **Worker sub-agent** (prompt = `archgen_tasks{action:'contract'}`) |
98
+ | Brownfield codebase survey | **Survey sub-agent** (`brief: 'survey'`, CodeGraph-first) |
99
+ | Verifier / Plan-Review / Investigation | **Gate / Investigator sub-agent** (`brief: 'verifier'\|'review'\|'investigate'`) |
192
100
 
193
- Detect first — one of:
101
+ ### Reuse the agent's session — NEVER re-dispatch for the same context
194
102
 
195
- - mechanism missing on this platform;
196
- - spawn failure (sub-agent never started / crashed at launch);
197
- - tool-permission gaps (sub-agent runs but cannot read/write/edit files).
103
+ Maintain a **dispatch ledger** (`dispatchKey -> agent session` using the `dispatchKey` from `archgen_tasks{action:'contract'}`). If a task requires a follow-up fix, clarification, or re-verification in files the agent already touched, **continue that agent's existing session** rather than spawning a fresh agent.
198
104
 
199
- Then, in order:
105
+ ### Parallel dispatch — no overlap, and never more than three at once
200
106
 
201
- 1. DEFAULT — main agent executes the task itself, sequentially, respecting
202
- waves and file_ownership globs. No user permission needed for this.
203
- 2. USER GATE — cross-harness/platform delegation ONLY. When the sub-agent
204
- problem looks platform-specific, STOP and tell the user the concrete issue,
205
- propose using another platform/harness for that specific task (name the
206
- harness + its command shape), and proceed ONLY after the user explicitly
207
- allows it. Log the user's choice in the final report.
107
+ **HARD CAP: MAX 3 LIVE PARALLEL SUB-AGENTS.** Execute larger waves in batches of $\le 3$. Before parallel dispatch, verify all six invariants:
108
+ 1. **Same wave only:** Dispatch only tasks returned in the current wave by `archgen_tasks{action:'next'}`.
109
+ 2. **Disjoint write globs:** Enforced by `next` (`OWNERSHIP_CONFLICT` blocks overlap).
110
+ 3. **No concurrent gate agents:** Never run Verifier or Reviewer agents while worker waves are executing.
111
+ 4. **Single writer per shared file:** Serialize tasks that touch shared configs, lockfiles, or entrypoints.
112
+ 5. **Ledger pre-registration:** Record `dispatchKey` in the dispatch ledger BEFORE spawning.
113
+ 6. **Live-agent counting:** Completed/paused sessions awaiting follow-up do not count against the 3-agent active cap.
208
114
 
209
- Never silently switch harnesses. Never ask permission to fall back for routine
210
- failures the main agent can simply do itself.
115
+ ### Native sub-agents (preferred)
116
+ - **Claude Code:** Background `Agent` tool per task; use `git worktree` isolation when globs border shared files.
117
+ - **Cursor:** Background subagents; enable isolation when running $>2$ parallel workers.
118
+ - **Antigravity:** Async `invoke_subagent`.
119
+ - **Codex:** `spawn_agent` (children cannot nest—flatten orchestration).
120
+ - **Gemini CLI:** Parallel `@agents` lack write isolation—use only for read-only/survey waves unless wrapped in `git worktree`.
211
121
 
212
- A sub-agent MECHANISM failure (missing/spawn/permissions) is not a TASK
213
- failure — run the diagnose-and-ask flow above first. Mark a task failed only
214
- after execution was actually attempted (by sub-agent or main agent) and did
215
- not complete.
122
+ ### When sub-agents are unavailable or fail
216
123
 
217
- Isolation for native sub-agents when ownership borders are tight:
124
+ If the sub-agent mechanism is missing, crashes at launch, or lacks read/write permissions (a **mechanism failure**, not a task failure):
125
+ 1. **Default:** Main agent executes the task sequentially itself, honoring wave order and `file_ownership`. No user prompt required.
126
+ 2. **Cross-harness fallback (USER GATE):** Only if the issue is platform-blocking, report the exact error, propose a specific alternative harness/CLI command, and wait for explicit user approval. Log the decision in the final report.
218
127
 
128
+ Optional worktree isolation for tight ownership boundaries:
219
129
  ```bash
220
130
  git worktree add ".worktrees/$id" -b "task-$id"
221
- # point the sub-agent's cwd at .worktrees/$id, then merge task-$id on success
131
+ # run sub-agent in .worktrees/$id, then merge task-$id on completion
222
132
  ```
223
- ### Worker prompt contract
224
133
 
225
- **The contract is a tool output — never hand-assemble it:**
134
+ ### Worker prompt contract
226
135
 
136
+ Always generate the worker prompt via:
227
137
  ```
228
138
  archgen_tasks { action: 'contract', tasksYaml: <tasks.yaml>, taskId: <id> }
229
139
  ```
140
+ It bundles: task ID/title, verbatim acceptance criteria, `file_ownership` globs, dependency neighborhood, `references/code-standards.md` path, inline normative rules (`MUST`/`SHOULD`/`NEVER`) + paths/indexes for all matched required skills, pre-located plan sections, `.agent/` workspace paths, completion protocol (`set_status` + `Skill compliance:` line + commit scope), worker prohibitions, CodeGraph usage directive, and `dispatchKey`.
230
141
 
231
- It assembles, from the same sources everything else reads:
232
-
233
- - the task id + title;
234
- - the acceptance criteria **VERBATIM**;
235
- - the `file_ownership` globs ("edit NOTHING outside these");
236
- - the dependency neighbourhood (prerequisites + what depends on this task);
237
- - the code-standards reference path;
238
- - the capability-skill follow-instruction, when the task matched one;
239
- - the **pre-located doc sections** — the sections that mention the task id, never
240
- the whole plan;
241
- - the working-state location;
242
- - the finish procedure (set_status + the `Skill compliance:` line + commit scope).
243
-
244
- **CODEGRAPH:** if `.codegraph/` is present, the worker must navigate with the
245
- CodeGraph MCP tools for anything needing understanding — never guess architecture
246
- from prose.
247
-
248
- **Workers do NOT talk to each other;** coordination happens only through
249
- tasks.yaml state.
250
-
251
- **Before dispatching**, check the contract's `warnings`: a task with no acceptance
252
- criteria or no file ownership is not dispatchable — fix the plan first.
142
+ **Pre-dispatch check:** Inspect `contract.warnings`. Never dispatch a task with missing acceptance criteria, empty `file_ownership`, or an uninstalled required skill.
253
143
 
254
144
  ## Failure policy
255
145
 
256
- - Sub-agent mechanism failure (missing/spawn/permissions) → §dispatch
257
- diagnose-and-ask flow FIRST. It is not yet a task failure.
258
- - Task exit ≠ 0 OR status=failed → leave it failed. NEVER auto-retry.
259
- - Downstream tasks stay blocked by the resolver (blockedByFailure).
260
- - Report to user: failed id, log path, proposed fix-task description.
261
- [wait for user] A fix task gets fresh id, depends_on=[], ownership of the
262
- failed task's globs.
146
+ - **Mechanism failure** (missing/spawn crash/permissions) $\rightarrow$ follow fallback flow above (do not mark task `failed`).
147
+ - **Task execution failure** (non-zero exit or unmet acceptance) $\rightarrow$ mark `failed` via `set_status`. **NEVER auto-retry.**
148
+ - Downstream dependents are automatically held in `blockedByFailure` by the resolver.
149
+ - Report failed task ID, logs, and a proposed fix task (`new ID`, `depends_on: []`, inheriting failed `file_ownership` globs) to the user. `[wait for user]`
@@ -1,142 +1,73 @@
1
1
  # Platform capability matrix (November 2026)
2
2
 
3
- Facts verified against official vendor docs (2026-11); cells marked UNVERIFIED could
4
- not be confirmed. The capability DATA is served by
5
- `archgen_setup{action:'harness_info'}` — this file keeps the narrative.
3
+ Authoritative platform capability data is served dynamically by `archgen_setup{action:'harness_info'}` from `packages/mcp/assets/platform-capabilities.json`.
6
4
 
7
5
  ## Harness capabilities
8
6
 
9
- **The capability data is a tool output — never read a table for it:**
10
-
7
+ Query platform capabilities directly via the tool rather than static tables:
11
8
  ```
12
- archgen_setup { action: 'harness_info' } # detect + return the row
13
- archgen_setup { action: 'harness_info', harness: 'claude' } # one harness
9
+ archgen_setup { action: 'harness_info' } # auto-detect current harness
10
+ archgen_setup { action: 'harness_info', harness: 'claude' } # query specific harness
14
11
  ```
15
-
16
- It returns, per harness: the skill install paths (project + global), the MCP
17
- config file + top-level key + entry shape, the MCP CLI, the restart semantics and
18
- the sub-agent dispatch capability (mechanism, parallelism, isolation). The
19
- canonical data is `packages/mcp/assets/platform-capabilities.json` — the tool
20
- serves it, so it can never drift from reality.
12
+ Returns: project & global skill paths, MCP config path, top-level JSON/TOML key, server entry schema, CLI commands, restart semantics, and sub-agent dispatch mechanics (tool name, parallelism, isolation).
21
13
 
22
14
  ## Platform detection
23
15
 
24
- Probe in order (the same order the tool uses):
25
-
26
- `.claude/` (Claude Code) · `.cursor/` (Cursor) · `.windsurf/` (Windsurf) ·
27
- `.opencode|opencode.json` (OpenCode) · `.github/copilot-instructions.md`
28
- (Copilot) · `~/.codex` (Codex) · `.gemini/` (Gemini CLI/Antigravity) ·
29
- `.kiro/` (Kiro) · `.trae/` (Trae).
30
-
31
- First match wins. `archgen_setup{action:'harness_info'}` does the same detection
32
- and returns the row — prefer it over probing by hand.
16
+ `archgen_setup{action:'harness_info'}` probes in this priority order (first match wins):
17
+ `.claude/` (Claude Code) $\rightarrow$ `.cursor/` (Cursor) $\rightarrow$ `.windsurf/` (Windsurf) $\rightarrow$ `.opencode` / `opencode.json` (OpenCode) $\rightarrow$ `.github/copilot-instructions.md` (Copilot) $\rightarrow$ `~/.codex` (Codex) $\rightarrow$ `.gemini/` (Gemini CLI / Antigravity) $\rightarrow$ `.kiro/` (Kiro) $\rightarrow$ `.trae/` (Trae).
33
18
 
34
19
  ## archgen installed layout
35
20
 
36
- `install.sh` / `npx archgen-skill install` maintain ONE canonical store plus
37
- thin bridges — the skill is never copied twice:
21
+ `npx archgen-skill install` maintains a single canonical store with lightweight bridges:
38
22
 
39
23
  | Path | Role |
40
24
  |---|---|
41
- | `.agents/skills/archgen/` | Canonical store — `SKILL.md` + `references/code-standards.md` (guidance only; the MCP server owns every capability) |
42
- | `.claude/skills/archgen` | Optional symlink → canonical store, for Claude Code discovery |
43
- | `CLAUDE.md` | One-line `@AGENTS.md` bridge only — no content of its own |
44
- | `AGENTS.md` | The hub every harness reads; hosts the features registry between `<!-- archgen:features:start -->` and `<!-- archgen:features:end -->` |
25
+ | `.agents/skills/archgen/` | Canonical store: `SKILL.md` + `references/code-standards.md` |
26
+ | `.claude/skills/archgen` | Optional symlink $\rightarrow$ canonical store for Claude Code discovery |
27
+ | `CLAUDE.md` | Single-line `@AGENTS.md` pointer |
28
+ | `AGENTS.md` | Cross-harness hub hosting the feature registry between `<!-- archgen:features:start -->` and `<!-- archgen:features:end -->` |
45
29
 
46
- The registry table (`| Feature | Status | Updated |`, one row per
47
- `.archgen/<slug>/`) is machine-maintained by `archgen_registry{action:'update'}` after
48
- every generate/plan/wave run — never hand-edit it; edit `.archgen/` state and
49
- re-run the tool instead.
30
+ Never hand-edit the `AGENTS.md` registry table (`| Feature | Status | Updated |`); update it exclusively via `archgen_registry{action:'update'}`.
50
31
 
51
32
  ## MCP configuration
52
33
 
53
- **The per-platform shapes are a tool output:** `archgen_setup{action:'harness_info'}`
54
- returns each harness's config file, top-level key and entry shape.
55
-
56
- Four different top-level keys exist — NEVER assume `mcpServers`:
57
- `mcpServers` (claude, cursor, windsurf, gemini, antigravity, kiro, trae) ·
58
- `servers` (vscode/copilot) · `mcp` (opencode) · `context_servers` (zed). Codex
59
- CLI uses TOML (`[mcp_servers.<id>]`).
60
-
61
- Remote URL fields vary per platform (`url` vs `serverUrl` vs `httpUrl`); the tool
62
- reports the exact field. Uncertainty triggers a web-search of the current
63
- official docs, never invention.
64
-
65
- **Wiring is a tool call:** `archgen_setup{action:'install_mcp', approve:true}`.
66
- Never hand-edit a harness config.
34
+ Query `archgen_setup{action:'harness_info'}` for exact per-platform MCP schemas:
35
+ - **Top-level keys vary:**
36
+ - `mcpServers`: Claude Code, Cursor, Windsurf, Gemini CLI, Antigravity, Kiro, Trae
37
+ - `servers`: VS Code / GitHub Copilot
38
+ - `mcp.servers.<id>`: OpenCode (nested under `mcp.servers`, never flat `mcp.<id>`)
39
+ - `context_servers`: Zed
40
+ - `[mcp_servers.<id>]`: Codex CLI (TOML)
41
+ - **Remote URL keys vary:** `url` vs `serverUrl` vs `httpUrl` (check `harness_info`).
42
+ - **Automated wiring:** Use `archgen_setup{action:'install_mcp', approve:true}` rather than hand-editing config files.
67
43
 
68
44
  ## Sub-agent dispatch capability
69
45
 
70
- **Also a tool output:** `archgen_setup{action:'harness_info'}` returns the
71
- dispatch mechanism, whether it parallelises, its limits and its isolation story.
72
- Use it before dispatching — the fallback (self-execute) and the isolation advice
73
- depend on it.
46
+ Always inspect `archgen_setup{action:'harness_info'}` before wave execution to determine the native sub-agent tool, parallel execution limits, worktree isolation requirements, or whether to fall back to sequential main-agent execution.
74
47
 
75
48
  ## Unknown platform procedure
76
49
 
77
- 1. WEB SEARCH: `<platform> official docs MCP configuration` and
78
- `<platform> agent skills install path`.
79
- 2. Prefer official vendor domains over blog posts; note the date of sources.
80
- 3. Present findings + proposed config diff to the user. [approval gate]
81
- 4. Apply, verify, and offer to append findings to this table upstream.
50
+ 1. **Web search:** `<platform> official docs MCP configuration` and `<platform> agent skills install path` (prioritize official vendor docs; note publication dates).
51
+ 2. **Propose:** Present discovered paths and exact config diff to the user. `[approval gate]`
52
+ 3. **Apply & verify:** Write approved config, verify tool availability, and offer to upstream the platform definition.
82
53
 
83
54
  ## Codegraph indexing scope
84
55
 
85
- Current mainstream codegraph indexers extract SOURCE symbols only
86
- (functions/classes/imports) — they do not index markdown headings, and YAML
87
- support ranges from absent to file-level config tracking; none can graph
88
- tasks.yaml dependencies. Generic code indexers verifiably do not extract
89
- markdown headings or YAML task semantics, so archgen ships its own
90
- deterministic graph tools:
91
-
92
- - Source navigation → codegraph MCP (built automatically by Step 0 / the
93
- the `archgen_codegraph` bootstrap flow).
94
- - YAML plan graphs → exclusively `archgen_plan{action:'graph'}`.
95
- - Markdown artifact navigation → `archgen_docs`.
96
-
97
- If the harness exposes a markdown-heading indexer (e.g. a
98
- `codegraph_index_markdown`-style tool), prefer it for general repo docs but
99
- still use `archgen_docs` inside `.archgen/` — it understands TASK/FR
100
- reference semantics. Brownfield surveys prefer codegraph once present.
56
+ Mainstream codegraph indexers parse **source-code symbols only** (functions, classes, imports)—never Markdown headings or YAML task dependencies. Use the dedicated tool for each artifact class:
57
+ - **Source code navigation:** CodeGraph MCP tools (`.codegraph/`).
58
+ - **YAML task dependency graphs:** `archgen_plan{action:'graph'}`.
59
+ - **`.archgen/` Markdown navigation & FR/TASK link validation:** `archgen_docs`.
101
60
 
102
61
  ### Codegraph bootstrap (official CLI, no command list here)
103
62
 
104
- CodeGraph = `@colbymchenry/codegraph` (npm), CLI `codegraph`, MIT, local-first,
105
- self-contained runtime. It persists a SQLite symbol graph in `.codegraph/`,
106
- serves it over MCP, and indexes SOURCE symbols only (scope above) — pair with
107
- `archgen_docs` / `archgen_plan{action:'graph'}` for markdown/YAML.
108
-
109
- **No version is pinned:** the bootstrap always takes the latest published
110
- release and refreshes it in place. The MCP server exposes its own tool set to
111
- the agent, so the skill does not restate the CLI's command surface — read it
112
- from the installed CLI (`codegraph help`) or the MCP tools themselves.
113
-
114
- > **Entry point — the `archgen_codegraph` tool.** It installs the CLI **if it
115
- > is missing** (an installed CodeGraph is the user's to manage and is never
116
- > upgraded behind their back), wires every DETECTED harness with the correct
117
- > per-platform shape, and builds the project index — idempotently, with an
118
- > approval gate before any config write. It drives the official CLI; it never
119
- > reimplements it.
120
- > ```
121
- > archgen_codegraph { action: 'ensure' } # install if missing + wire + index
122
- > archgen_codegraph { action: 'status' } # what is installed/wired/indexed
123
- > ```
124
-
125
- **Rules that matter to the agent:**
126
- - The index is built ONCE per project; the MCP server's watcher keeps it live,
127
- so **never re-index** — no manual index/sync steps after the bootstrap.
128
- - MCP configs are written only with `approve: true`; the tool returns its plan
129
- otherwise. A config that is not valid JSON (e.g. JSONC) is reported, never
130
- rewritten. Harnesses that are not installed are never touched.
131
- - Only DETECTED harnesses get an entry. The per-platform file path, top-level
132
- key (`mcpServers` / `servers` / `mcp` / `context_servers`) and server entry
133
- live in `packages/mcp/assets/harness-mcp.json` — one source of truth.
134
- - **Telemetry — disclose it, never claim "100% local":** it is enabled by
135
- default on a fresh install and reports a machine ID (`~/.codegraph/`), and the
136
- tool changes it only with an explicit `telemetry: 'off' | 'on'`.
137
-
138
- Agent flow (Step 0): detect `.codegraph/` at the repo root.
139
- - **Absent** → `archgen_codegraph{action:'ensure'}` once
140
- per project (standing approval from the user's install-time consent; show the
141
- printed plan). On decline → grep/Glob.
142
- - **Present** → use the CodeGraph MCP tools for navigation. Never re-index.
63
+ CodeGraph (`@colbymchenry/codegraph`, MIT) maintains a local SQLite symbol graph in `.codegraph/` and serves it via MCP.
64
+ - **Entry point:**
65
+ ```
66
+ archgen_codegraph { action: 'ensure' } # install CLI if missing + wire detected harnesses + index
67
+ archgen_codegraph { action: 'status' } # check install, wiring, and index state
68
+ ```
69
+ - **Operational rules:**
70
+ - **Index once:** Built during bootstrap and kept live by the MCP file watcher—**never re-index manually**.
71
+ - **Safe config writes:** Non-bootstrap config edits require `approve: true`, touch only detected harnesses (`packages/mcp/assets/harness-mcp.json`), and never overwrite invalid JSON/JSONC or upgrade an existing user-installed CLI.
72
+ - **Telemetry disclosure:** CodeGraph enables anonymous machine-ID telemetry (`~/.codegraph/`) by default; disclose this accurately (never claim "100% offline/no telemetry") and pass `telemetry: 'off' | 'on'` only when requested.
73
+ - **Step 0 flow:** If `.codegraph/` is present, use CodeGraph MCP tools. If absent, run `archgen_codegraph{action:'ensure'}` once per project (fallback to grep/glob if declined).