archgen-skill 0.0.3 → 0.0.5

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 (33) hide show
  1. package/README.md +31 -33
  2. package/bin/archgen.mjs +31 -1
  3. package/lib/block.js +147 -16
  4. package/lib/config.js +96 -0
  5. package/lib/doctor.js +144 -28
  6. package/lib/init.js +14 -3
  7. package/lib/install.js +124 -16
  8. package/lib/migrate.js +88 -0
  9. package/lib/migrations/001-stamp-provenance.mjs +77 -0
  10. package/lib/migrations/index.mjs +170 -0
  11. package/lib/restore.js +239 -0
  12. package/lib/store.js +125 -15
  13. package/lib/uninstall-project.js +6 -3
  14. package/lib/version-stamp.js +49 -0
  15. package/package.json +39 -10
  16. package/vendor/skills/archgen/SKILL.md +218 -145
  17. package/vendor/skills/archgen/archgen.config.json +16 -0
  18. package/vendor/skills/archgen/assets/skill-registry.json +4 -3
  19. package/vendor/skills/archgen/references/artifact-templates.md +308 -7
  20. package/vendor/skills/archgen/references/interview.md +226 -17
  21. package/vendor/skills/archgen/references/mcp-and-skills.md +88 -17
  22. package/vendor/skills/archgen/references/orchestration.md +230 -44
  23. package/vendor/skills/archgen/references/platforms.md +56 -14
  24. package/vendor/skills/archgen/scripts/doc-index.mjs +457 -0
  25. package/vendor/skills/archgen/scripts/impact.mjs +14 -1
  26. package/vendor/skills/archgen/scripts/lib/graph.mjs +99 -5
  27. package/vendor/skills/archgen/scripts/lib/scope.mjs +65 -0
  28. package/vendor/skills/archgen/scripts/lib/yaml.mjs +19 -3
  29. package/vendor/skills/archgen/scripts/plan-graph.mjs +329 -0
  30. package/vendor/skills/archgen/scripts/set-status.mjs +51 -9
  31. package/vendor/skills/archgen/scripts/update-agents.mjs +16 -5
  32. package/vendor/skills/archgen/scripts/validate.mjs +18 -1
  33. package/vendor/skills/archgen/scripts/verify-plan.mjs +8 -3
@@ -4,43 +4,114 @@
4
4
 
5
5
  1. **Identify** the platform (SKILL.md Step 0), load its row from
6
6
  references/platforms.md section MCP: config file, top-level key, quirks.
7
- 2. **Prefer the platform CLI** where the table lists one. It handles scope and
8
- file selection correctly:
7
+ 2. **Discover** — when the correct installation method or config shape for
8
+ the detected harness is not confidently known, web-search the CURRENT
9
+ official installation docs/command FIRST. Never trust potentially-stale
10
+ memorized commands or invented config shapes; uncertainty triggers search,
11
+ not guessing.
12
+ 3. **Scope** — choose and state the install scope explicitly:
13
+ - **GLOBAL** — server types that are global entries (npx/npm-based MCP
14
+ servers usable across harnesses). Recommended for universally-useful
15
+ servers (codegraph is the canonical example) unless the user prefers
16
+ project-local.
17
+ - **HARNESS-SPECIFIC** — write into the detected platform's config only.
18
+ Recommended when the server only matters to that platform.
19
+ The user's approval covers the stated scope.
20
+ 4. **Prefer the platform CLI** where the table lists one, passing the scope
21
+ flag that matches the chosen scope:
9
22
  - `claude mcp add --scope project --transport http <name> <url>`
10
23
  - `codex mcp add <name> --url <url>` or `codex mcp add <n> -- cmd args`
11
24
  - `gemini mcp add -s project -t http <name> <url>`
12
- 3. No CLI available: draft the exact config diff against the platform's real
25
+ 5. No CLI available: draft the exact config diff against the platform's real
13
26
  shape (see assets/mcp-template.json for annotated canonical forms) and SHOW
14
27
  it to the user. **USER APPROVAL GATE** — wait for an explicit yes before any
15
28
  write; approval is never inferred from earlier steps.
16
- 4. Apply, then apply the restart semantics from the platforms table.
17
- 5. Verify the tool is visible after reload; report failure modes honestly.
29
+ 6. Apply, then apply the restart semantics from the platforms table.
30
+ 7. Verify the tool is visible after reload; report failure modes honestly.
18
31
 
19
32
  Never write MCP configs silently. Never invent config shapes — the four known
20
33
  top-level keys are mcpServers / servers / mcp / context_servers; remote URL
21
- fields vary (url vs serverUrl vs httpUrl) per the platforms table.
34
+ fields vary (url vs serverUrl vs httpUrl) per the platforms table. Uncertainty
35
+ triggers web-search of current official docs, never invention.
22
36
 
23
37
  ## FETCH-SKILL procedure
24
38
 
25
- 1. Read assets/skill-registry.json. Match the current task domain against
26
- entry `matches` patterns (e.g. frontend/UI work matches ui-skills).
27
- 2. Install into the CURRENT platform's skill dir (platforms.md paths):
28
- - Generic: `npx skills add <owner>/<repo>` (writes correct path for 75+
29
- harnesses; `-g` for global).
30
- - Entry-specific command when present (e.g. `npx ui-skills get baseline-ui`).
31
- 3. Confirm files landed where expected; then FOLLOW the fetched skill's own
32
- instructions for the task domain.
33
- 4. Missing capability: web-search reputable skill repos, propose to user,
34
- on approval append an entry to the registry (PR or local edit).
39
+ Capability-skill loading is **REQUIRED, not opportunistic**. Whenever planned
40
+ work touches a registry `matches` domain, the matching skill MUST be loaded —
41
+ during planning (GENERATE / BROWNFIELD / UPDATE) AND re-verified during
42
+ execution (worker dispatch). UI/design/frontend/animation/component/
43
+ landing-page work REQUIRES the design skills (`ui-skills`, `policy:
44
+ "required"`) loaded first. Referenced from elsewhere as:
45
+ *see references/mcp-and-skills.md § FETCH-SKILL procedure*.
46
+
47
+ 0. **WHEN** — mandatory, twice per matched task:
48
+ - **Pre-planning scan**: while planning, check every task's title, summary,
49
+ and `file_ownership` against the registry BEFORE the plan is finalized;
50
+ fetch any matched skill at that point.
51
+ - **Pre-dispatch verification**: immediately before dispatching each worker,
52
+ re-verify its match; if the skill is missing from the platform skill dir,
53
+ install it before dispatch proceeds.
54
+ 1. **MATCH** — read assets/skill-registry.json. Test every task's title,
55
+ summary, and file_ownership globs against each entry's `matches` patterns
56
+ using case-insensitive substring matching (e.g. a task titled "polish
57
+ landing page hero" matches ui-skills via `"landing page"`). One hit = this
58
+ procedure is mandatory for that task.
59
+ 2. **RESOLVE** — determine the CURRENT platform's skill dir from
60
+ references/platforms.md § Skill install paths. That table owns the paths;
61
+ never duplicate them here.
62
+ 3. **INSTALL once if absent** — cached check first: if the skill is already
63
+ present in the resolved platform skill dir, skip reinstall and go to step 4.
64
+ Otherwise run the entry's `install` command (generic fallback:
65
+ `npx skills add <owner>/<repo>`; `-g` for global; entry-specific commands
66
+ like `npx ui-skills get baseline-ui` when present). Then VERIFY presence:
67
+ confirm the skill directory/SKILL.md landed where platforms.md says it
68
+ should. Fetch happens ONCE per project; later runs are cache hits.
69
+ 4. **INTEGRATE** — inject the follow-instruction into (a) the planning context
70
+ so tasks reference the skill's standards, and (b) EVERY affected worker
71
+ prompt, using this sentence template:
72
+
73
+ > `<Domain> work: follow <skill-dir>/SKILL.md (installed via FETCH-SKILL) — apply its standards to every relevant decision.`
74
+
75
+ Concrete design instantiation for ui-skills:
76
+
77
+ > `Design work: follow <skill-dir>/SKILL.md (installed via FETCH-SKILL) — apply its component/motion/baseline standards to every visual decision.`
78
+
79
+ 5. **AUDIT** — workers MUST state in their completion report whether they
80
+ followed the injected skill, one auditable line, e.g.:
81
+ `Skill compliance: followed ui-skills (<skill-dir>/SKILL.md)` or
82
+ `Skill compliance: NOT followed — <reason>`.
83
+ 6. **MISSING CAPABILITY** — unmatched-but-obvious domain (user says "make it
84
+ pretty" with no registry entry): web-search reputable skill repos, propose
85
+ to user, on approval append an entry to the registry (PR or local edit).
86
+ Never add registry entries without explicit user approval.
35
87
 
36
88
  ## Registry entry shape
37
89
 
90
+ Canonical keys, in order — there are no others. Notably there is NO
91
+ `npxCommand` field anywhere in the registry; the executable command lives in
92
+ `install` (with optional `direct_fetch`):
93
+
38
94
  ```json
39
95
  {
40
96
  "name": "short-name",
41
97
  "purpose": "when to reach for it",
42
98
  "repo": "owner/repo",
43
99
  "install": "npx skills add owner/repo",
44
- "matches": ["frontend", "ui", "design"]
100
+ "direct_fetch": "optional per-skill fetch command",
101
+ "browse": "optional listing command",
102
+ "mcp_endpoint": "optional MCP URL",
103
+ "matches": ["frontend", "ui", "design"],
104
+ "policy": "required"
45
105
  }
46
106
  ```
107
+
108
+ - `matches[]`: case-insensitive substrings tested against task titles,
109
+ summaries, and file_ownership during the FETCH-SKILL domain scan (step 1).
110
+ - `policy` (`required` | `on-demand`) — how mandatory loading is:
111
+ - `"required"`: loading is MANDATORY whenever work touches any of the
112
+ entry's `matches` domains — pre-planning fetch plus pre-dispatch
113
+ verification (FETCH-SKILL steps 0–5 all apply). Currently only ui-skills
114
+ carries this; design/UI/frontend work must not proceed without it.
115
+ - `"on-demand"`: fetched only when a task explicitly names the installer or
116
+ another registry entry lacks a usable command (e.g.
117
+ vercel-skills-installer).
@@ -24,24 +24,196 @@ Accept the map only if every section is present and non-empty.
24
24
 
25
25
  ## §verifier — plan review brief
26
26
 
27
- Dispatch AFTER artifacts exist and validate.mjs passes. The verifier:
27
+ Dispatch AFTER artifacts exist and validate.mjs passes.
28
+
29
+ ### Agent tier — EVERY verifier dispatch
30
+
31
+ Verification is judgment-heavy: a weak verifier misses real defects AND raises
32
+ false positives — costing MORE rounds, not fewer. Dispatch on the strongest
33
+ reasoning agent the harness offers (best agent present), or a mid/high-tier
34
+ sub-agent scaled to plan complexity:
35
+
36
+ - SMALL/MEDIUM plan → one strong (mid/high-tier) agent.
37
+ - LARGE plan → the stronger/highest tier available.
38
+ - NEVER an explore / research / quick / small / cheap / fast sub-agent,
39
+ whatever the harness calls its low-end tiers.
40
+
41
+ ### Verification pass — FULL-DEPTH, every run
42
+
43
+ Each verifier run executes ALL four steps:
28
44
 
29
45
  1. Runs `node <skill>/scripts/verify-plan.mjs .archgen/<slug>/tasks.yaml --plan .archgen/<slug>/plans`
30
46
  — deterministic floor: cycles, dangling refs, same-wave ownership overlap,
31
47
  missing acceptance criteria, plan↔task coverage.
32
- 2. Reads plans + tasks.yaml and judges what scripts cannot:
48
+ 2. When markdown artifacts exist under `.archgen/<slug>/`, runs
49
+ `node <skill>/scripts/doc-index.mjs .archgen/<slug> --validate` — must be
50
+ clean (zero broken references, exit 0) alongside verify-plan APPROVE;
51
+ broken references block APPROVAL.
52
+ 3. Reads plans + tasks.yaml and judges what scripts cannot:
33
53
  - Are wave boundaries sensible (no artificial serialization)?
34
54
  - Do acceptance criteria objectively verify (command or observable)?
35
55
  - Edge cases covered per SKILL.md right-sizing class?
36
56
  - Code-standards compliance plausible for the planned structure?
37
- 3. Returns EXACTLY one line verdict: `APPROVE` or `ISSUES:` + numbered list.
57
+ - CONTRACT-COMPLETENESS sweep — round 1 must confirm OR flag-as-missing
58
+ every APPLICABLE dimension (later discovery = the round-1 sweep failed,
59
+ not a gap). Apply a dimension only where the system actually has that
60
+ concern — skip what genuinely doesn't apply, but NEVER skip a dimension
61
+ the system touches:
62
+ - **Functional coverage**: every stated requirement/feature has tasks +
63
+ objectively verifiable acceptance.
64
+ - **Security & data protection** (if it authenticates, authorizes,
65
+ encrypts, or handles sensitive data): authn/authz flows, session &
66
+ credential lifecycle, replay/CSRF protection, encryption & privacy
67
+ boundaries, input validation — each fully specified, not named-and-
68
+ skipped.
69
+ - **Data integrity**: schemas, relationships, validation, and migration /
70
+ back-compat for any persisted state.
71
+ - **State, lifecycle & recovery** (if any operation is stateful,
72
+ long-running, or multi-step): checkpointing/resume, idempotency,
73
+ cleanup, expiry, compensation/rollback semantics.
74
+ - **Resource limits & abuse** (if it exposes shared or anonymous
75
+ resources): quotas, rate limits, retention/deletion, anonymous-abuse
76
+ controls.
77
+ - **Operational entrypoints**: every stack-required build/deploy/test/
78
+ bootstrap entrypoint is OWNED by some task (no orphan entrypoint).
79
+ - **Metric traceability**: every PRD success metric maps to a task
80
+ acceptance criterion with a reproducible command / sample size / data
81
+ source.
82
+ - **Consistency**: actively check cross-contract claims for internal
83
+ contradiction (a claim in one artifact that another artifact violates).
84
+ These failure classes are the TOP cause of multi-round loops — round 1
85
+ MUST sweep the applicable dimensions exhaustively.
86
+ 4. Returns EXACTLY one line verdict: `APPROVE` or `ISSUES:` + numbered list.
87
+
88
+ ### Efficiency — fewer rounds + zero duplicate work, NEVER shallower checks
89
+
90
+ Every run stays FULL-DEPTH: both scripts run to completion and the full
91
+ judgment checklist applies each time. Efficiency comes ONLY from:
92
+
93
+ - capping automatic rounds at 2 (gate protocol below);
94
+ - batching fixes per file (fix discipline below);
95
+ - never re-fixing an already-resolved finding.
96
+
97
+ "Efficient" NEVER means skipping or lightening verify-plan.mjs, doc-index.mjs,
98
+ or any judgment-checklist item.
99
+
100
+ ### Fix discipline — batch per file, dedupe repeats
101
+
102
+ On `ISSUES:` the orchestrator fixes ALL findings before re-dispatching:
103
+
104
+ - Group findings BY FILE; apply each file's fixes in ONE edit pass — open
105
+ each file once per round, not once per finding.
106
+ - Round N reports the SAME finding as round N-1 (same file + same issue) →
107
+ the prior fix did not land: re-read the file and fix it properly — never
108
+ re-apply the identical edit.
109
+
110
+ ### Gate protocol — 2 automatic rounds, then ask the user
111
+
112
+ The initial VERIFIER GATE flow (GENERATE step 5). Rounds 1–2 run
113
+ automatically; fix ALL findings between rounds (fix discipline above):
114
+
115
+ 1. Round 1: dispatch verifier. `APPROVE` → gate passed → §plan-review.
116
+ `ISSUES:` → fix ALL findings → round 2.
117
+ 2. Round 2: dispatch verifier.
118
+ - Clean `APPROVE` → ask the user once more, recommending NO, proceed.
119
+ - `ISSUES:` → fix ALL findings → ask the user once more, recommending
120
+ YES, one more pass.
121
+ Ask recommendation-first per interview.md § How to ask: "Run the verifier
122
+ once more to make sure everything passes?"
123
+ 3. On YES → run another round; if it returns `ISSUES:`, fix all and ask again
124
+ — every round beyond 2 is user-approved. On NO → proceed to §plan-review.
125
+ 4. On NO with findings still outstanding and no verifier `APPROVE` on record:
126
+ surface every outstanding finding verbatim and require an EXPLICIT user
127
+ waiver — never proceed silently. Hard rule 2 stands: the plan MUST NOT
128
+ reach the USER GATE without at least one verifier `APPROVE` (or that
129
+ explicit waiver on the record). An earlier `APPROVE` on record → proceed
130
+ to §plan-review, noting the latest unverified fixes.
131
+
132
+ ## §plan-review — post-plan review stage
133
+
134
+ Run AFTER verify-plan returns APPROVE and BEFORE the user gate. Dispatch
135
+ REVIEWER sub-agents sized by the right-sizing class — always ONE holistic
136
+ review of the WHOLE plan, never per-concern splits:
137
+
138
+ - SMALL: main-agent self-review acceptable if no reviewer mechanism exists.
139
+ - MEDIUM: 1 reviewer.
140
+ - LARGE: 1 holistic reviewer on the strongest reasoning tier. A 2nd reviewer
141
+ ONLY if the plan is genuinely too large for one reviewer's context — split
142
+ by ARTIFACT/VOLUME then (e.g. plans vs docs), never by concern.
143
+
144
+ One holistic reviewer analyzes ALL issues together: cross-issue reasoning
145
+ catches contradictions a narrow per-concern slice misses, and one reviewer
146
+ costs far fewer tokens than several. NEVER dispatch one sub-agent per
147
+ individual issue/concern.
148
+
149
+ ```
150
+ TASK: Review the plan in .archgen/<slug>/ READ-ONLY.
151
+ EXAMINE:
152
+ - edge cases per module
153
+ - task ordering / parallelization sanity (waves vs real dependencies)
154
+ - cross-module contract mismatches (interfaces, paths, naming)
155
+ - enhancement recommendations
156
+ - documentation completeness
157
+ DELIVERABLE: numbered findings list; each finding = what + where + why.
158
+ You NEVER edit files. Report only.
159
+ ```
160
+
161
+ Reviewers are read-only and report-only — they never edit artifacts or code.
162
+ The orchestrator fixes the artifacts itself, re-runs validate.mjs +
163
+ re-dispatches the verifier gate after every change.
164
+
165
+ ### Review loop — bounded passes, then ask
166
+
167
+ The fix→re-verify cycle stays, but reviewer passes are countable and bounded:
168
+
169
+ 1. Pass 1: holistic review. Zero findings → stage done.
170
+ 2. Findings → fix ALL (batched per file), re-run validate.mjs + the verifier
171
+ gate → pass 2.
172
+ 3. Pass 2 still yields findings → do NOT spawn more reviewers. Consolidate
173
+ the outstanding findings and ask the user once, recommendation-first per
174
+ interview.md § How to ask: "Run one more targeted review pass on the N
175
+ open findings? 1. One more pass (recommended) 2. Waive these findings and
176
+ proceed."
177
+ 4. On YES → run EXACTLY ONE more pass, then consolidate and STOP. Zero
178
+ findings → stage done; findings remain → surface them and require an
179
+ explicit user waiver before the user gate. On NO → record the explicit
180
+ waiver, proceed.
181
+
182
+ A "more review" approval authorizes EXACTLY ONE additional pass — never a
183
+ fresh loop, never more reviewers. The stage ends ONLY at zero findings or an
184
+ explicit user waiver on record.
185
+
186
+ ## §investigate — root-cause protocol
187
+
188
+ Triggered when the USER reports repetitive/recurring issues AFTER implementation
189
+ waves completed. Do NOT patch-fix under this protocol. Complexity-sized dispatch:
190
+
191
+ - SMALL scope: main agent investigates directly.
192
+ - MEDIUM/LARGE: 1–3 investigator sub-agents split by suspected subsystem.
193
+
194
+ Investigators produce ALL four:
195
+
196
+ 1. Root cause statement — one sentence naming the actual defect.
197
+ 2. Evidence — files/lines/repro steps.
198
+ 3. Blast radius — which tasks/artifacts are affected.
199
+ 4. Remediation plan — routed through the normal gates: new fix tasks get fresh
200
+ ids inheriting the affected task's ownership globs.
38
201
 
39
- Orchestrator fixes issues (edits artifacts) and re-dispatches. Loop until
40
- APPROVE — never present to the user before verifier approval.
202
+ Token discipline: investigators read narrowly around evidence, not whole-repo
203
+ sweeps. Patch-fixes without a root-cause statement are forbidden under this
204
+ protocol.
41
205
 
42
206
  ## §dispatch — wave execution
43
207
 
44
- ### Tier 1: native sub-agents (preferred where strong)
208
+ Dispatch policy: dispatch each task to the harness's NATIVE sub-agent mechanism
209
+ when available AND functional. If sub-agents do not exist on this platform, or
210
+ the sub-agent fails, or lacks required tool permissions (read/write/etc.), the
211
+ MAIN AGENT executes the task ITSELF — sequentially, respecting waves and
212
+ ownership globs. Cross-harness/platform delegation is allowed ONLY through an
213
+ explicit user gate (below). There is NO automatic fallback to other harnesses,
214
+ platforms, or CLIs — ever.
215
+
216
+ ### Native sub-agents (preferred)
45
217
 
46
218
  - Claude Code: background Agent tool per task; add worktree isolation for
47
219
  tasks whose ownership might brush shared files.
@@ -51,55 +223,69 @@ APPROVE — never present to the user before verifier approval.
51
223
  - Gemini CLI: parallel @agents are hub-and-spoke only AND have no isolation →
52
224
  use them ONLY for read-only/research waves unless wrapping in worktrees.
53
225
 
54
- ### Tier 2: bash fallback workers (universal floor)
226
+ ### When sub-agents are unavailable or fail
55
227
 
56
- ```bash
57
- #!/usr/bin/env bash
58
- set -uo pipefail
59
- SLUG="<slug>"; ROOT="$(pwd)"; SKILL="<abs-path-to-skills/archgen>"
60
- run_task() { # $1=id $2=prompt-file
61
- local id="$1" pf="$2" log=".archgen/$SLUG/results/$id.log"
62
- mkdir -p "$(dirname "$log")"
63
- local body; body="$(cat "$pf")
64
-
65
- You own exactly the file_ownership globs listed for this task in tasks.yaml. Follow archgen code-standards. On success run: node \"$SKILL/scripts/set-status.mjs\" .archgen/$SLUG/tasks.yaml \"$id\" done ; on failure set-status failed."
66
- case "$ARCHGEN_HARNESS" in
67
- claude) claude -p "$body" --output-format json --permission-mode acceptEdits > "$log" 2>&1 ;;
68
- opencode) opencode run "$body" --auto --format json > "$log" 2>&1 ;;
69
- codex) codex exec --sandbox workspace-write --json -o "$log.final" "$body" > "$log" 2>&1 ;;
70
- gemini) gemini --output-format json "$body" > "$log" 2>&1 ;;
71
- agy) agy -p --output-format json --print-timeout 15m "$body" > "$log" 2>&1 ;;
72
- *) echo "unknown harness: $ARCHGEN_HARNESS" >&2; return 9 ;;
73
- esac
74
-
75
- You own exactly: $(node "$SKILL/scripts/impact.mjs" .archgen/$SLUG/tasks.yaml "$id" >/dev/null 2>&1 && echo 'see tasks.yaml file_ownership'). Follow archgen code-standards. On success run: node "$SKILL/scripts/set-status.mjs" .archgen/$SLUG/tasks.yaml "$id" done ; on failure set-status failed." \
76
- }
77
- # Wave N: launch all frontier tasks in parallel…
78
- for t in $(node "$SKILL/scripts/next-tasks.mjs" .archgen/$SLUG/tasks.yaml \
79
- | node -e 'let d="";process.stdin.on("data",c=>d+=c).on("end",()=>console.log(JSON.parse(d).waves[0].map(t=>t.id).join(" ")))'); do
80
- run_task "$t" ".archgen/$SLUG/results/$t.prompt" & pids="$pids $!"
81
- done
82
- fail=0; for p in $pids; do wait "$p" || fail=1; done
83
- exit $fail # orchestrator inspects statuses before next wave
84
- ```
228
+ Detect first — one of:
229
+
230
+ - mechanism missing on this platform;
231
+ - spawn failure (sub-agent never started / crashed at launch);
232
+ - tool-permission gaps (sub-agent runs but cannot read/write/edit files).
233
+
234
+ Then, in order:
85
235
 
86
- Isolation upgrade for Tier 2 when ownership borders are tight:
236
+ 1. DEFAULT — main agent executes the task itself, sequentially, respecting
237
+ waves and file_ownership globs. No user permission needed for this.
238
+ 2. USER GATE — cross-harness/platform delegation ONLY. When the sub-agent
239
+ problem looks platform-specific, STOP and tell the user the concrete issue,
240
+ propose using another platform/harness for that specific task (name the
241
+ harness + its command shape), and proceed ONLY after the user explicitly
242
+ allows it. Log the user's choice in the final report.
243
+
244
+ Never silently switch harnesses. Never ask permission to fall back for routine
245
+ failures the main agent can simply do itself.
246
+
247
+ A sub-agent MECHANISM failure (missing/spawn/permissions) is not a TASK
248
+ failure — run the diagnose-and-ask flow above first. Mark a task failed only
249
+ after execution was actually attempted (by sub-agent or main agent) and did
250
+ not complete.
251
+
252
+ Isolation for native sub-agents when ownership borders are tight:
87
253
 
88
254
  ```bash
89
255
  git worktree add ".worktrees/$id" -b "task-$id"
90
- # run worker with cwd=.worktrees/$id, then merge task-$id on success
256
+ # point the sub-agent's cwd at .worktrees/$id, then merge task-$id on success
91
257
  ```
92
258
 
93
- ### Worker prompt contract (both tiers)
259
+ ### Worker prompt contract
260
+
261
+ Every worker receives ALL of:
262
+
263
+ - task id + title;
264
+ - its acceptance criteria VERBATIM;
265
+ - its file_ownership globs ("edit NOTHING outside these");
266
+ - the code-standards reference (`references/code-standards.md`);
267
+ - instruction to run set-status done/failed immediately upon finishing:
268
+ `node <skill>/scripts/set-status.mjs .archgen/<slug>/tasks.yaml <id> done|failed`;
269
+ - commit guidance: commit completed work scoped to the owned files;
270
+ - BEFORE writing code run
271
+ `node <skill>/scripts/plan-graph.mjs <slug-dir-or-tasks.yaml> --node <task-id>`
272
+ and honor every connected dependency shown;
273
+ - all file paths come from tasks.yaml/architecture.yaml VERBATIM — never
274
+ reconstruct paths from memory.
275
+ - working state goes under `.archgen/<slug>/.agent/` — execution decisions to
276
+ `.agent/decisions/`, notes to `.agent/notes/<id>.md` (see
277
+ references/artifact-templates.md § Agent workspace & artifact location).
278
+ NEVER create ad-hoc note/context/decision folders at the repo root or
279
+ anywhere outside `.archgen/`.
94
280
 
95
- Every worker receives: task id+title, its acceptance criteria verbatim, its
96
- file_ownership globs ("edit NOTHING outside these"), the code-standards
97
- reference, and the done/failed status-update command. Workers do NOT talk to
98
- each other; coordination happens only through tasks.yaml state.
281
+ Workers do NOT talk to each other; coordination happens only through
282
+ tasks.yaml state.
99
283
 
100
284
  ## Failure policy
101
285
 
102
- - Worker exit ≠ 0 OR status=failed → leave it failed. NEVER auto-retry.
286
+ - Sub-agent mechanism failure (missing/spawn/permissions) → §dispatch
287
+ diagnose-and-ask flow FIRST. It is not yet a task failure.
288
+ - Task exit ≠ 0 OR status=failed → leave it failed. NEVER auto-retry.
103
289
  - Downstream tasks stay blocked by the resolver (blockedByFailure).
104
290
  - Report to user: failed id, log path, proposed fix-task description.
105
291
  [wait for user] A fix task gets fresh id, depends_on=[], ownership of the
@@ -69,24 +69,11 @@ Claude Code project-scope servers.
69
69
  |---|---|---|---|
70
70
  | Claude Code | `Agent` tool + subagent_type; `.claude/agents/*.md` | Yes (default since v2.1.198; cap ~20) | BEST: `isolation: worktree` frontmatter; `/batch` |
71
71
  | OpenCode | task/subagent tool + subagent_type | Yes (fg + background) | None in core → use file-ownership discipline or team-mode plugin worktrees |
72
- | Codex CLI | model-mediated `spawn_agent`; max_depth=1 | Yes but children can't nest | None → prefer top-level parallel `codex exec` + manual git worktrees |
72
+ | Codex CLI | model-mediated `spawn_agent`; max_depth=1 | Yes but children can't nest | None built-in → flatten plans into top-level `spawn_agent` calls (children cannot nest); add manual git worktrees if edits collide |
73
73
  | Gemini CLI | subagents-as-tools; `@agent-name` | Yes BUT strictly hub-and-spoke (no nested calls) | None → restrict parallel workers to read-only roles unless given external worktrees |
74
74
  | Cursor | Subagents w/ `is_background` frontmatter; `/multitask` | Yes | Opt-in per-subagent worktree or cloud VM |
75
75
  | Antigravity | `invoke_subagent` (async by design); `/fork` | Yes | `/fork` workspace separation; per-subagent worktrees UNVERIFIED |
76
76
 
77
- ## Headless invocation templates (fallback workers)
78
-
79
- ```
80
- claude claude -p "<prompt>" --output-format json --permission-mode acceptEdits
81
- opencode opencode run "<prompt>" --auto --format json
82
- codex codex exec --sandbox workspace-write --json -o <out-file> "<prompt>"
83
- gemini gemini --output-format json "<prompt>"
84
- agy agy -p --output-format json --print-timeout 15m "<prompt>"
85
- ```
86
-
87
- Completion signal = process exit (Claude documents 0/non-zero contract).
88
- NEVER pass secrets as arguments. Feature-detect old binaries via `--version`.
89
-
90
77
  ## Unknown platform procedure
91
78
 
92
79
  1. WEB SEARCH: `<platform> official docs MCP configuration` and
@@ -94,3 +81,58 @@ NEVER pass secrets as arguments. Feature-detect old binaries via `--version`.
94
81
  2. Prefer official vendor domains over blog posts; note the date of sources.
95
82
  3. Present findings + proposed config diff to the user. [approval gate]
96
83
  4. Apply, verify, and offer to append findings to this table upstream.
84
+
85
+ ## Codegraph indexing scope
86
+
87
+ Current mainstream codegraph indexers extract SOURCE symbols only
88
+ (functions/classes/imports) — they do not index markdown headings, and YAML
89
+ support ranges from absent to file-level config tracking; none can graph
90
+ tasks.yaml dependencies (audited 8 codegraph-family tools Aug 2026; local
91
+ binary v1.0.1 empirically confirms). Generic code indexers verifiably do not
92
+ extract markdown headings or YAML task semantics, so archgen ships its own
93
+ deterministic graph tools:
94
+
95
+ - Source navigation → codegraph MCP when configured (offered at Step 0).
96
+ - YAML plan graphs → exclusively `scripts/plan-graph.mjs`.
97
+ - Markdown artifact navigation → `scripts/doc-index.mjs`.
98
+
99
+ If the harness exposes a markdown-heading indexer (e.g. a
100
+ `codegraph_index_markdown`-style tool), prefer it for general repo docs but
101
+ still use `doc-index.mjs` inside `.archgen/` — it understands TASK/FR
102
+ reference semantics. Brownfield surveys prefer codegraph once present.
103
+
104
+ ### Codegraph install & index (concrete — researched Aug 2026, v1.0.1)
105
+
106
+ CodeGraph = `@colbymchenry/codegraph` (npm), CLI `codegraph`, MIT, 100% local.
107
+ It persists a SQLite symbol graph in `.codegraph/` and serves it over MCP. It
108
+ indexes SOURCE symbols only (scope above) — pair with `doc-index.mjs` /
109
+ `plan-graph.mjs` for markdown/YAML. Requires Node 22 or 24 (native SQLite
110
+ bindings; other versions fall back to a 5–10x-slower WASM backend).
111
+
112
+ Install the CLI (one-time, global):
113
+ - `npm i -g @colbymchenry/codegraph` (any OS with Node), or
114
+ - `curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh` (macOS/Linux), or
115
+ - zero-install: `npx @colbymchenry/codegraph`.
116
+
117
+ Wire the harness (writes MCP config + instructions — INSTALL-MCP approval gate):
118
+ - `codegraph install --yes` (auto-detect agents, global)
119
+ - `codegraph install --target=<agent> --yes` (explicit harness)
120
+ - `codegraph install --target=auto --location=local --yes` (project-local)
121
+ - `codegraph install --print-config <agent>` (preview snippet, no writes)
122
+ - Manual config shape: assets/mcp-template.json (stdio `codegraph serve --mcp`
123
+ or npx `-y @colbymchenry/codegraph mcp`).
124
+
125
+ Index the project (per project; creates `.codegraph/` + builds the graph):
126
+ - `codegraph init` (add `--yes` to skip prompts); one-shot bootstrap:
127
+ `codegraph install --yes --init`. Auto-syncs on file change thereafter.
128
+ - `codegraph status` to verify; `codegraph uninit` removes the index;
129
+ `codegraph uninstall` de-wires the agents; `codegraph upgrade` updates.
130
+
131
+ `.codegraph/` is deterministic and small — committing it gives teammates the
132
+ index on first checkout (team recommendation); git-ignore it for solo repos.
133
+ Never point two OSes (Windows + WSL) at one `.codegraph/`.
134
+
135
+ Agent flow: detect `.codegraph/` at repo root. Present → use `codegraph_explore`
136
+ for source navigation. Absent → offer once (INSTALL-MCP approval pattern,
137
+ recommendation-first), run the commands above on approval; on decline use
138
+ Glob+Grep.