azclaude-copilot 0.7.2 → 0.7.4

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.
@@ -9,7 +9,7 @@
9
9
  {
10
10
  "name": "azclaude",
11
11
  "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 40 commands, 10 auto-invoked skills, 15 specialized agents, 5 hooks, a real-time pipeline visualizer, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
12
- "version": "0.7.2",
12
+ "version": "0.7.4",
13
13
  "source": {
14
14
  "source": "github",
15
15
  "repo": "haytamAroui/AZ-CLAUDE-COPILOT",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azclaude",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "AZCLAUDE is a complete AI coding environment for Claude Code. It installs 40 commands, 10 auto-invoked skills, 15 specialized agents, 5 hooks, a real-time pipeline visualizer, and a persistent memory system — in one command.\n\nKey features:\n• Memory across sessions — goals.md + checkpoints injected automatically before every session\n• Self-improving loop — /reflect fixes stale CLAUDE.md rules, /reflexes learns from tool-use patterns, /evolve creates agents from git evidence\n• Autonomous copilot mode — /copilot runs a three-tier team (orchestrator → problem-architect → milestone-builder) across sessions until the product ships\n• Spec-driven workflow — /constitute writes project rules, /spec writes structured ACs, /analyze detects plan drift and ghost milestones, /blueprint traces every milestone to a spec\n• Security layer — 111-rule environment scan (/sentinel), pre-write secret blocking, pre-ship credential audit\n• Progressive levels 0–10 — start with CLAUDE.md, grow into multi-agent pipelines and self-evolving environments\n• Zero dependencies — no npm packages, no external APIs, no vector databases. Plain markdown files and Claude Code's native architecture.\n• Smart install — npx azclaude-copilot@latest auto-detects first install vs upgrade vs verify. Context-aware onboarding shows the right next command for your project state.\n\nExample use cases:\n• /setup — scan an existing project, detect stack + domain + scale, fill CLAUDE.md, generate project-specific skills and agents automatically\n• /copilot \"Build a compliance SaaS with trilingual support\" — walk away, come back to working code across multiple sessions\n• /sentinel — run a scored security audit (0–100, grade A–F) across hooks, permissions, MCP servers, agent configs, and secrets\n• /evolve — detect gaps in the environment, generate new skills and agents from git co-change evidence, report score delta (e.g. 42/100 → 68/100)\n• /constitute — write your project's constitution (non-negotiables, architectural commitments, definition of done) — gates all future AI actions\n• /analyze — cross-artifact consistency check: ghost milestones, spec vs. code drift, unplanned commits\n• /reflect — find stale, missing, or contradicting rules in CLAUDE.md and propose exact fixes\n• /debate \"REST vs GraphQL for this project\" — adversarial evidence-based decision with order-independent scoring, logged to decisions.md",
5
5
  "author": {
6
6
  "name": "haytamAroui",
package/README.md CHANGED
@@ -637,11 +637,11 @@ AZCLAUDE is a lazy-loaded environment of 48 capability modules. It only loads wh
637
637
 
638
638
  ## Verified
639
639
 
640
- 1881 tests. Every template, command, capability, agent, hook, and CLI feature verified.
640
+ 1958 tests. Every template, command, capability, agent, hook, and CLI feature verified.
641
641
 
642
642
  ```bash
643
643
  bash tests/test-features.sh
644
- # Results: 1881 passed, 0 failed, 1881 total
644
+ # Results: 1958 passed, 0 failed, 1958 total
645
645
  ```
646
646
 
647
647
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azclaude-copilot",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "AI coding environment — 40 commands, 10 skills, 15 agents, real-time visualizer, memory, reflexes, evolution. Install: npx azclaude-copilot@latest, then open Claude Code.",
5
5
  "bin": {
6
6
  "azclaude": "bin/cli.js",
@@ -12,6 +12,11 @@
12
12
  {{PROJECT_DESCRIPTION}}
13
13
  Domain: {{DOMAIN}} | Stack: {{STACK}} | Scale: {{SCALE}}
14
14
 
15
+ ## Verify
16
+ Quick: {{QUICK_VERIFY}}
17
+ Test: {{TEST_VERIFY}}
18
+ Build: {{BUILD_VERIFY}}
19
+
15
20
  ## Rules
16
21
  1. **Completion** — Never say "should work" or "probably passes." Show the output or stay in progress.
17
22
  2. **Precision** — Reference code as `file:line`. Never describe in prose.
@@ -79,19 +79,66 @@ Rules:
79
79
 
80
80
  ---
81
81
 
82
- ### Step 3: Verify
82
+ ### Step 3: Verify — Toolchain Exit Gate (MANDATORY)
83
83
 
84
+ Load `capabilities/shared/toolchain-gate.md` for the stack-to-command mapping.
85
+ Read the `Verify:` field from the Team Spec injected in your prompt. If missing, read CLAUDE.md `## Verify`.
86
+
87
+ Create the logs directory:
88
+ ```bash
89
+ mkdir -p .claude/logs
90
+ ```
91
+
92
+ **Tier 1: Static verification (MANDATORY — always run)**
93
+ ```bash
94
+ # Use the Quick command from Team Spec Verify: field
95
+ {quick_verify_cmd} 2>&1 | tee .claude/logs/verify-log-M{N}.md
96
+ echo "TIER1_EXIT=$?" >> .claude/logs/verify-log-M{N}.md
97
+ ```
98
+ - Errors in YOUR files → fix them (counts as a self-correction attempt)
99
+ - Errors in OTHER files → append to verify log: `"Scope violation: {file} — outside my directories"` — do NOT fix
100
+ - Tool not installed → skip with warning: `"Tier 1 SKIPPED: {tool} not available"`
101
+
102
+ **Tier 2: Scoped test verification (MANDATORY)**
103
+ ```bash
104
+ # Use the Test command from Team Spec Verify: field
105
+ {scoped_test_cmd} 2>&1 | tee -a .claude/logs/verify-log-M{N}.md
106
+ echo "TIER2_EXIT=$?" >> .claude/logs/verify-log-M{N}.md
107
+ ```
108
+ - In parallel mode: run ONLY tests in your Test scope — not the full suite
109
+ - In sequential mode: run full test suite
110
+
111
+ **Tier 2b: Runtime verification (ONLY if Team Spec Verify: Runtime ≠ SKIP)**
84
112
  ```bash
85
- # Run tests detect framework from project
86
- npm test 2>&1 | tail -20 || \
87
- pytest 2>&1 | tail -20 || \
88
- cargo test 2>&1 | tail -20 || \
89
- go test ./... 2>&1 | tail -20
113
+ # Run the app briefly, capture crashes
114
+ timeout 15 {run_command} 2>&1 | tee .claude/logs/runtime-M{N}.log; exit 0
115
+ ```
116
+ The `exit 0` prevents Claude Code from treating a crash as a Bash failure.
117
+ If the runtime log contains stack traces or crash output → read it, diagnose, fix if in your scope.
118
+
119
+ **Write the verify log summary at the top of the file:**
120
+ ```markdown
121
+ ## Verify Log — M{N}: {title}
90
122
 
91
- echo "Exit: $?"
123
+ ### Tier 1: Static ({command})
124
+ Status: PASS | FAIL
125
+ Errors: {count} | Warnings: {count}
126
+
127
+ ### Tier 2: Scoped Tests ({command})
128
+ Status: PASS | FAIL
129
+ Tests: {pass}/{total}, {duration}
130
+
131
+ ### Tier 2b: Runtime
132
+ Status: PASS | SKIP | CRASH
133
+ {stack trace summary if crash}
134
+
135
+ ### Self-Correction History
136
+ Attempt 1: {what happened}
137
+ Fix: {what was changed}
138
+ Attempt 2: {result}
92
139
  ```
93
140
 
94
- Tests must PASS before reporting done. Show actual output — never summarize.
141
+ Tests and Tier 1 must PASS before reporting done. Show actual output — never summarize.
95
142
 
96
143
  ---
97
144
 
@@ -148,9 +195,16 @@ Branch: {current branch name} ← required for orchestrator merge tracking
148
195
  ### Files Changed
149
196
  - {file}: {create|modify} — {one-line description}
150
197
 
151
- ### Test Status
152
- PASS — {N} tests passing
153
- {first 5 lines of test output}
198
+ ### Verify Status
199
+ Tier 1 (static): PASS | FAIL | SKIPPED — {error count} errors, {warning count} warnings
200
+ Tier 2 (tests): PASS | FAIL — {pass}/{total} tests, {duration}
201
+ Runtime: PASS | SKIP | CRASH
202
+ Verify log: .claude/logs/verify-log-M{N}.md
203
+ Runtime log: .claude/logs/runtime-M{N}.log (if exists)
204
+
205
+ ### Self-Correction Summary
206
+ Attempts used: {N} / {budget}
207
+ {one-line per fix if any}
154
208
 
155
209
  ### New Patterns Discovered
156
210
  {pattern description} — or "none"
@@ -36,6 +36,37 @@ If CLAUDE.md unfilled → run `/setup` with intent from copilot-intent.md first.
36
36
 
37
37
  ---
38
38
 
39
+ ### Step 1a: Toolchain Bootstrap (MANDATORY before first dispatch)
40
+
41
+ Load `capabilities/shared/toolchain-gate.md` for the full protocol.
42
+
43
+ ```bash
44
+ # Check if Verify field exists in CLAUDE.md
45
+ grep -q "^## Verify" CLAUDE.md 2>/dev/null && echo "verify=configured" || echo "verify=missing"
46
+ ```
47
+
48
+ If `verify=missing` → run the Toolchain Detection Protocol from toolchain-gate.md:
49
+ 1. Detect stack files (`package.json`, `Cargo.toml`, `go.mod`, etc.)
50
+ 2. Check tool availability (`command -v node`, `command -v cargo`, etc.)
51
+ 3. If tool missing AND installer available → install automatically (copilot mode is autonomous)
52
+ 4. Install dependencies if missing (`npm install`, `cargo fetch`, etc.)
53
+ 5. Write `## Verify` section to CLAUDE.md
54
+ 6. Log all output to `.claude/logs/bootstrap.log`
55
+
56
+ ```bash
57
+ mkdir -p .claude/logs
58
+ ```
59
+
60
+ **Smoke test** — run the quick verify command once:
61
+ ```bash
62
+ {quick_verify_cmd} 2>&1 | tee .claude/logs/bootstrap.log
63
+ ```
64
+ - PASS → proceed to dispatch
65
+ - FAIL → fix the build BEFORE dispatching any agents. This IS the foundation.
66
+ - Tool unavailable → log warning: `"⚠ Verification degraded: {tool} not available"` — proceed with reduced verification
67
+
68
+ ---
69
+
39
70
  ### Step 1b: Resume Interrupted Parallel Wave
40
71
 
41
72
  ```bash
@@ -161,9 +192,11 @@ Load `capabilities/shared/context-relay.md` for relay protocol and role-based fi
161
192
  2. Write `.claude/parallel-wave-state.md` with `dispatch_mode: dag` (see parallel-coordination.md)
162
193
  3. **Pre-read shared files** (models, schemas, configs referenced by 2+ agents) and relay their content via a `## Pre-loaded Context` block in each agent's prompt — builders MUST NOT re-read relayed files
163
194
  4. If problem-architect returned a `## Relay` section, include it in the builder prompt as-is
164
- 5. Spawn each builder via Task with `isolation: "worktree"` in the same message (true parallel)
165
- 5. Include worktree rules + **test scope** (`Test scope: {test-dir}`) in every parallel prompt
166
- 6. **Merge-on-complete**: as each agent reports done, merge its branch immediately (don't wait for all)
195
+ 5. **Skill consistency** collect the UNION of all skills from all Team Specs in this wave. Every agent in the wave loads the SAME skill set (not just its own). This ensures consistent patterns across parallel agents.
196
+ 6. **Include Verify commands** from each Team Spec in the agent prompt — the builder uses these in its exit gate
197
+ 7. Spawn each builder via Task with `isolation: "worktree"` in the same message (true parallel)
198
+ 8. Include worktree rules + **test scope** (`Test scope: {test-dir}`) in every parallel prompt
199
+ 9. **Merge-on-complete**: as each agent reports done, merge its branch immediately (don't wait for all)
167
200
  7. After each merge: check if newly-unblocked milestones exist → dispatch them immediately
168
201
  8. If `max_parallel <= 3` or merge conflicts detected: fall back to batch-merge (wait for all, then merge)
169
202
 
@@ -215,14 +248,67 @@ Dependent milestones, overlapping `Files Written`, or `Parallel Safe: NO` → sp
215
248
 
216
249
  ---
217
250
 
218
- ### Step 5: Monitor Results + Merge-on-Complete
251
+ ### Step 5: Monitor Results + Merge-on-Complete + Verification Wave
219
252
 
220
253
  **When an agent reports PASS (parallel mode):**
221
254
  1. Merge its branch to main immediately: `git merge parallel/{slug} --no-ff`
222
255
  2. Run tests for the merged module: `{test command} tests/{agent-scope}/ 2>&1 | tail -10`
223
256
  3. If tests pass → update plan.md status → `done`, update `.claude/parallel-wave-state.md`
224
- 4. **Check DAG for newly-unblocked milestones** — any milestone whose `Depends:` are now ALL `done` becomes ready. Dispatch it immediately (back to Step 3 → Step 4).
225
- 5. New pattern emerged? → append to patterns.md
257
+ 4. New pattern emerged? append to patterns.md
258
+
259
+ **When ALL agents in a wave complete → VERIFICATION WAVE (mandatory):**
260
+
261
+ Read `capabilities/shared/toolchain-gate.md` for the Tier 3 command and log protocol.
262
+ Before dispatching ANY next-wave agents:
263
+
264
+ ```bash
265
+ # 1. Tier 3: Full build — write to build log
266
+ {build_command} 2>&1 | tee .claude/logs/build-wave{N}.log
267
+ echo "EXIT=$?" >> .claude/logs/build-wave{N}.log
268
+
269
+ # 2. Full test suite (not scoped — the FULL suite)
270
+ {test_command} 2>&1 | tee -a .claude/logs/build-wave{N}.log
271
+ ```
272
+
273
+ **3. Read all agent verify logs for this wave:**
274
+ ```bash
275
+ cat .claude/logs/verify-log-M*.md 2>/dev/null
276
+ cat .claude/logs/runtime-M*.log 2>/dev/null
277
+ ```
278
+ Collect warnings across agents — relay relevant ones to next-wave agents.
279
+
280
+ **4. If build or tests fail → dispatch a FIX agent with log relay:**
281
+ ```
282
+ Task: Fix post-Wave {N} build failure
283
+
284
+ ## Build Log (last 100 lines)
285
+ {tail -100 .claude/logs/build-wave{N}.log}
286
+
287
+ ## Agent Verify Logs Summary
288
+ {for each agent: M{X} — PASS/FAIL, errors, warnings}
289
+
290
+ ## Runtime Logs (if any)
291
+ {contents of .claude/logs/runtime-M{X}.log for this wave}
292
+
293
+ ## Diagnosis
294
+ Build error at {file}:{line} was introduced by M{X}'s merge.
295
+ M{X}'s verify log shows: {relevant warning}
296
+
297
+ Fix the errors. The logs above give you full context — do NOT re-investigate from scratch.
298
+ ```
299
+
300
+ - Build failure → integration error from parallel agents. Fix it now — it multiplies if ignored.
301
+ - Test failure → identify which merge broke it from the build log. Revert that branch or fix in place.
302
+ - **Only after verification passes → check DAG for newly-unblocked milestones → dispatch.**
303
+ - This applies to EVERY wave transition. No exceptions.
304
+
305
+ **Context refresh for Wave 3+ (mandatory):**
306
+
307
+ When dispatching Wave 3 or later, agents work on a codebase modified by many prior agents.
308
+ Before writing agent prompts for Wave N ≥ 3:
309
+ 1. Re-read ALL files that Wave N agents will import or depend on — use FRESH reads, not cached
310
+ 2. Include fresh file contents in `## Pre-loaded Context` — not stale copies from earlier waves
311
+ 3. Add to every Wave 3+ agent prompt: `"Note: {count} milestones have modified the codebase. Pre-loaded Context reflects CURRENT state. Trust it over plan.md assumptions."`
226
312
 
227
313
  **When an agent reports PASS (sequential mode):**
228
314
  - Approve commit
@@ -53,6 +53,7 @@ Also read:
53
53
  - `.claude/memory/patterns.md` — established conventions for this area
54
54
  - `.claude/memory/antipatterns.md` — known failure patterns to avoid
55
55
  - Context artifacts: `prisma/schema.prisma`, `openapi.yaml`, `.env.example`
56
+ - CLAUDE.md `## Verify` section — for the `Verify:` field in Team Spec (see `capabilities/shared/toolchain-gate.md`)
56
57
 
57
58
  ---
58
59
 
@@ -156,11 +157,21 @@ If YES: topic = {what orchestrator must /debate before dispatching}
156
157
  SIMPLE (< 3 files) | MEDIUM (3-8 files) | COMPLEX (8+ files)
157
158
  COMPLEX → orchestrator gives builder 3 fix attempts instead of 2
158
159
 
160
+ ### Verify
161
+ Read CLAUDE.md `## Verify` field for the project's commands. Scope them to this milestone:
162
+ - Quick: `{Tier 1 command}` — static check, MANDATORY before done
163
+ - Test: `{Tier 2 command scoped to this milestone's directories}`
164
+ - Runtime: `{run command if this milestone affects startup/routes/jobs}` — or SKIP
165
+ Example: `Quick: cargo check | Test: cargo test tests/auth/ | Runtime: SKIP`
166
+ The milestone-builder uses these exact commands in its exit gate.
167
+
159
168
  ### Parallel Safe
160
- YES | NO
169
+ YES | NO | SEQUENTIAL-ONLY
161
170
  If NO: reason = {specific conflict — shared file, schema dependency, runtime ordering}
171
+ If SEQUENTIAL-ONLY: reason = {migration, cross-cutting refactor, 15+ files, pattern-setting}
162
172
  The orchestrator uses this to decide whether to use worktree isolation or sequential dispatch.
163
173
  Parallel Safe = YES requires: isolated directories, no shared config/schema, no runtime dependency on a sibling milestone.
174
+ Parallel Safe = SEQUENTIAL-ONLY means: this milestone must NEVER be split across agents — see sizing rules below.
164
175
 
165
176
  ### Relay (for milestone-builder — do not re-read)
166
177
  {Include condensed contents of key files you read during analysis.
@@ -175,6 +186,32 @@ Maximum ~4000 tokens for this section.}
175
186
 
176
187
  ---
177
188
 
189
+ ## Agent Sizing Rules — When to Force Sequential
190
+
191
+ A milestone MUST be marked `Parallel Safe: SEQUENTIAL-ONLY` if ANY of these apply:
192
+
193
+ | Signal | Why it can't be split |
194
+ |--------|----------------------|
195
+ | Touches 15+ files | Too many interdependencies for one agent to track in isolation |
196
+ | Framework/library migration | Every file depends on the pattern set by the first file edited |
197
+ | Store/state management rewrite | All consumers depend on the new store shape |
198
+ | Global type rename or API contract change | Callers can't be split from the definition |
199
+ | Build tool or bundler change | Config affects every file's compilation |
200
+ | Auth/middleware rewrite | Everything downstream depends on the new interface |
201
+
202
+ **When a milestone is too large but must stay sequential, recommend decomposition:**
203
+ ```
204
+ Recommend: Split into 3 SEQUENTIAL sub-milestones:
205
+ 1. {foundation — sets the pattern} → Parallel Safe: SEQUENTIAL-ONLY
206
+ 2. {consumers group A — follows the pattern} → Depends: sub-1
207
+ 3. {consumers group B — follows the pattern} → Depends: sub-2
208
+ ```
209
+ Each sub-milestone has a checkpoint. Still sequential, but with clear boundaries and rollback points.
210
+
211
+ **Key insight:** The fix for an oversized milestone is better decomposition, not more agents. Splitting a migration across parallel agents produces inconsistent patterns that are harder to fix than doing it sequentially.
212
+
213
+ ---
214
+
178
215
  ## Rules
179
216
 
180
217
  - **NEVER implement.** NEVER write to project files. Tools: Read, Grep, Glob, Bash only.
@@ -183,4 +220,5 @@ Maximum ~4000 tokens for this section.}
183
220
  - **Be specific.** "Load security skill" is weak.
184
221
  "Load security skill because M4 handles Stripe webhook HMAC signatures" is strong.
185
222
  - **Files Written must be exhaustive.** A missed file causes silent parallel corruption.
223
+ - **ALWAYS apply agent sizing rules.** A 32-file migration marked Parallel Safe: YES causes cascading failures.
186
224
  - If unsure whether an agent exists → Grep .claude/agents/ for it. Never assume.
@@ -30,6 +30,7 @@ Load only the files that match the current task. Never load the full list.
30
30
  | shared/reward-hack-detection.md | /audit, /ship, post-milestone review — detect reward hacking patterns in test modifications | ~150 |
31
31
  | shared/ultrathink.md | $ARGUMENTS contains --deep, or command needs extended thinking for complex analysis | ~80 |
32
32
  | shared/context-relay.md | About to spawn a subagent — pass pre-read files to eliminate redundant reads across agent boundaries | ~300 |
33
+ | shared/toolchain-gate.md | /copilot dispatch, /parallel, agent verify, env-scan — stack detection, verify commands, toolchain bootstrap, 3-tier verification, log protocol | ~500 |
33
34
 
34
35
  ## Level Builders — load ONE at a time
35
36
  | File | When to load | Tokens |
@@ -342,6 +342,122 @@ After resume completes, continue with Merge Protocol → Plan Update → Cleanup
342
342
 
343
343
  ---
344
344
 
345
+ ## Universal Parallel Execution Rules
346
+
347
+ These rules are technology-agnostic. They apply to every parallel dispatch regardless of stack, framework, or language.
348
+
349
+ ### Rule 1: Verification Wave — Mandatory Between Every Parallel Batch
350
+
351
+ After ALL agents in a wave complete and merge, run a **verification step** before dispatching the next wave:
352
+
353
+ ```
354
+ Wave N agents complete → merge all branches → VERIFICATION:
355
+ 1. Run full build (compile/transpile/lint — whatever the project uses)
356
+ 2. Run full test suite (not scoped — the FULL suite)
357
+ 3. If build fails → fix before next wave (these are integration errors from parallel agents)
358
+ 4. If tests fail → identify which merge broke it → revert or fix before next wave
359
+ 5. Only after verification passes → dispatch Wave N+1
360
+ ```
361
+
362
+ **Why:** Parallel agents can't verify integration — they only see their own worktree. Without verification, errors accumulate across waves. A type change in Wave 1 that breaks a Wave 2 consumer won't surface until the end, when fixing is 10x harder.
363
+
364
+ **The verification agent is lightweight:** it runs build + tests, nothing else. No implementation. Budget ~2 minutes per wave.
365
+
366
+ ### Rule 2: Sweet Spot Is 3–5 Parallel Agents Per Wave
367
+
368
+ | Agent count | Risk | Recommendation |
369
+ |------------|------|----------------|
370
+ | 1–2 | Low | Sequential is simpler — skip parallel overhead |
371
+ | 3–5 | Optimal | Best ratio of speed gain to coordination cost |
372
+ | 6 | Maximum | Only if all 6 own completely disjoint directories |
373
+ | 7+ | Diminishing returns | Prompt quality degrades, merge complexity spikes |
374
+
375
+ **Why:** Beyond 5 agents, the orchestrator's ability to write precise-enough prompts degrades. Each prompt needs exact file ownership, patterns, and anti-patterns. More agents = more surface area for conflicts that safety checks miss.
376
+
377
+ ### Rule 3: Wave 1 Sets the Contract
378
+
379
+ The first wave establishes types, APIs, schemas, and patterns that ALL subsequent waves depend on. If Wave 1 gets something wrong, the error **multiplies** across every later agent.
380
+
381
+ **Rules for Wave 1:**
382
+ - Wave 1 should be the **smallest, most carefully specified wave**
383
+ - Wave 1 milestones define shared types, base schemas, core configs
384
+ - Wave 1 agents get **extra fix attempts** (3 instead of 2)
385
+ - Wave 1 MUST pass verification before Wave 2 dispatches — no exceptions
386
+ - If Wave 1 introduces a new pattern (e.g., error type, response shape), document it in `patterns.md` BEFORE dispatching Wave 2
387
+
388
+ ### Rule 4: Agent Size Limits — When NOT to Split
389
+
390
+ A milestone that touches **15+ files** or performs a **cross-cutting change** (framework migration, global refactor, store pattern rewrite) should NOT be split across agents.
391
+
392
+ **Signs a milestone must stay as one agent (sequential):**
393
+ - Framework/library migration (every file depends on the pattern set by the first file edited)
394
+ - Store/state management rewrite (all consumers depend on the new store shape)
395
+ - Global type rename or API contract change (callers can't be split from the definition)
396
+ - Auth/middleware rewrite (everything downstream depends on the new interface)
397
+
398
+ **The fix is better decomposition, not more agents:**
399
+ ```
400
+ BAD: Split Svelte 5 migration into 5 parallel agents → inconsistent patterns
401
+ GOOD: Split into 3 SEQUENTIAL sub-milestones:
402
+ 1. Stores + shared state (sets the pattern)
403
+ 2. Pages (follows the pattern)
404
+ 3. Components (follows the pattern)
405
+ Each sub-milestone has checkpoints. Still sequential, but with clear boundaries.
406
+ ```
407
+
408
+ **Rule: If a milestone can't be split without creating pattern inconsistency → keep it as one agent, sequential.**
409
+
410
+ ### Rule 5: Context Drift Mitigation for Later Waves
411
+
412
+ By Wave 3+, agents work on a codebase modified by 5–15 previous agents. Assumptions about types, APIs, and file contents may be stale.
413
+
414
+ **Mitigation protocol for Wave N (N ≥ 3):**
415
+ 1. Orchestrator re-reads ALL files that Wave N agents will import/depend on
416
+ 2. Orchestrator includes **fresh file contents** in the `## Pre-loaded Context` block — not cached from earlier waves
417
+ 3. Every Wave 3+ agent prompt includes: `"Warning: {N} milestones have modified the codebase since plan.md was written. Pre-loaded Context below reflects the CURRENT state. Trust it over plan.md assumptions."`
418
+ 4. If a type/interface was changed by a prior wave, include the **new** definition explicitly
419
+
420
+ **Why:** Agents don't communicate with each other. An agent in Wave 4 that assumes `Result<_, String>` when Wave 2 changed it to `CmdResult<_>` will produce code that compiles in its worktree but fails on merge.
421
+
422
+ ### Rule 6: Skills Are the Consistency Layer
423
+
424
+ Parallel agents never communicate, but they must produce consistent code. **Skills are how.**
425
+
426
+ **Rules:**
427
+ - ALL agents in the same wave MUST load the same skill set (from problem-architect's Team Spec)
428
+ - If a project uses a specific pattern (e.g., Svelte 5 runes, Rust async, clean architecture), the matching skill MUST be loaded by every agent that touches that layer
429
+ - If no skill exists for the project's core pattern → create it with `skill-creator` BEFORE dispatching the first wave
430
+ - Skills ensure: consistent error handling, consistent naming, consistent imports, consistent test patterns
431
+
432
+ **Why:** 5 agents in separate rooms producing code in 5 different styles is worse than 3 agents producing consistent code. Skills are the shared style guide that makes parallel agents act like a coordinated team.
433
+
434
+ ### Rule 7: Framework Migrations Are Always Sequential
435
+
436
+ Any milestone classified as a **migration** (framework upgrade, language version bump, build system change, ORM migration) MUST run sequentially — never in a parallel wave.
437
+
438
+ **Detection — a milestone is a migration if it:**
439
+ - Changes `package.json` / `requirements.txt` / `Cargo.toml` / `go.mod` major versions
440
+ - Rewrites import patterns across 10+ files
441
+ - Changes a store/state pattern that all components consume
442
+ - Upgrades a UI framework (React class→hooks, Svelte 4→5, Vue Options→Composition)
443
+ - Switches a build tool (webpack→vite, setuptools→poetry)
444
+
445
+ **Why:** Migrations are inherently cross-cutting. Every file depends on the pattern established by the first file migrated. Splitting a migration across agents produces inconsistent patterns that are harder to fix than doing it sequentially.
446
+
447
+ ### Rule Summary Table
448
+
449
+ | # | Rule | Enforced by |
450
+ |---|------|-------------|
451
+ | 1 | Verification wave between batches | Orchestrator Step 5 |
452
+ | 2 | 3–5 agents per wave (6 max) | Orchestrator Step 2 |
453
+ | 3 | Wave 1 = smallest, most careful | Blueprint Task Classifier |
454
+ | 4 | 15+ file milestones stay sequential | Problem Architect Team Spec |
455
+ | 5 | Fresh context for Wave 3+ agents | Orchestrator Step 4 |
456
+ | 6 | Same skills for all wave agents | Orchestrator Step 4 |
457
+ | 7 | Migrations always sequential | Blueprint Task Classifier |
458
+
459
+ ---
460
+
345
461
  ## Ownership Map Cleanup
346
462
 
347
463
  After wave merge is complete:
@@ -0,0 +1,326 @@
1
+ # Toolchain Gate — Verify Before Ship
2
+
3
+ This capability is loaded by the orchestrator, milestone-builder, and /setup.
4
+ It defines how agents detect, install, and verify the project's toolchain — and how
5
+ logs flow between agents as context for fix dispatches.
6
+
7
+ ---
8
+
9
+ ## Stack-to-Command Mapping
10
+
11
+ The source of truth for every verification command. Agents never guess — they look up.
12
+
13
+ | Stack signal | Quick verify (Tier 1) | Scoped test (Tier 2) | Full build (Tier 3) | Install deps | Install tool |
14
+ |-------------|----------------------|---------------------|--------------------|--------------|----|
15
+ | `Cargo.toml` | `cargo check 2>&1` | `cargo test {scope} 2>&1` | `cargo build 2>&1` | `cargo fetch` | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh -s -- -y` |
16
+ | `package.json` + TS | `npx tsc --noEmit 2>&1` | `npm test -- --testPathPattern={scope} 2>&1` | `npm run build 2>&1` | `npm install` | `curl -fsSL https://fnm.vercel.app/install \| bash && fnm install --lts` |
17
+ | `package.json` (JS only) | `npx eslint src/ 2>&1 \|\| true` | `npm test 2>&1` | `npm run build 2>&1` | `npm install` | same as above |
18
+ | `pyproject.toml` / `requirements.txt` | `python -m py_compile {files} 2>&1` | `python -m pytest {scope} -x 2>&1` | `python -m pytest 2>&1` | `pip install -r requirements.txt` or `pip install -e .` | `curl -fsSL https://pyenv.run \| bash` |
19
+ | `go.mod` | `go vet ./... 2>&1` | `go test ./{scope}/... 2>&1` | `go build ./... 2>&1` | `go mod download` | `curl -fsSL https://go.dev/dl/ (manual)` |
20
+ | `Gemfile` | `ruby -c {files} 2>&1` | `bundle exec rspec {scope} 2>&1` | `bundle exec rspec 2>&1` | `bundle install` | `curl -fsSL https://get.rvm.io \| bash` |
21
+ | `pubspec.yaml` | `dart analyze 2>&1` | `dart test {scope} 2>&1` | `dart compile exe 2>&1` | `dart pub get` | manual |
22
+ | `Makefile` (C/C++) | `make -n 2>&1` | `make test 2>&1` | `make 2>&1` | — | system package manager |
23
+ | `*.sln` / `*.csproj` | `dotnet build --no-restore 2>&1` | `dotnet test {scope} 2>&1` | `dotnet build 2>&1` | `dotnet restore` | `winget install Microsoft.DotNet.SDK.8` |
24
+
25
+ **Multi-stack projects:** If both `Cargo.toml` and `package.json` exist, chain: `cargo check && npx tsc --noEmit`.
26
+ Store all applicable commands in the `Verify:` field, joined by `&&`.
27
+
28
+ **Custom overrides:** If the project has a `Makefile` with a `check` target, or `package.json` has a `"check"` script, prefer those over the table above. Project conventions beat defaults.
29
+
30
+ ---
31
+
32
+ ## Toolchain Detection Protocol
33
+
34
+ Run by env-scan.sh and /setup. Output determines the `Verify:` field in CLAUDE.md.
35
+
36
+ ### Step 1: Detect stack files
37
+ ```bash
38
+ ls package.json Cargo.toml go.mod pyproject.toml requirements.txt Gemfile pubspec.yaml *.sln *.csproj Makefile 2>/dev/null
39
+ ```
40
+
41
+ ### Step 2: Check tool availability
42
+ ```bash
43
+ # For each detected stack, check the runtime
44
+ command -v node 2>/dev/null && node --version || echo "node=missing"
45
+ command -v cargo 2>/dev/null && cargo --version || echo "cargo=missing"
46
+ command -v python3 2>/dev/null && python3 --version || echo "python=missing"
47
+ command -v go 2>/dev/null && go version || echo "go=missing"
48
+ command -v ruby 2>/dev/null && ruby --version || echo "ruby=missing"
49
+ command -v dotnet 2>/dev/null && dotnet --version || echo "dotnet=missing"
50
+ ```
51
+
52
+ ### Step 3: Check dependencies installed
53
+ ```bash
54
+ [ -d node_modules ] && echo "node_deps=installed" || echo "node_deps=missing"
55
+ [ -d target ] && echo "rust_deps=fetched" || echo "rust_deps=missing"
56
+ [ -d venv ] || [ -d .venv ] && echo "py_venv=found" || echo "py_venv=missing"
57
+ [ -d vendor ] && echo "vendor=found" || echo "vendor=missing"
58
+ ```
59
+
60
+ ### Step 4: Check for custom verify scripts
61
+ ```bash
62
+ # package.json custom scripts
63
+ node -e "const p=require('./package.json'); console.log(p.scripts?.check || p.scripts?.typecheck || p.scripts?.lint || 'none')" 2>/dev/null
64
+ # Makefile targets
65
+ grep -q '^check:' Makefile 2>/dev/null && echo "makefile_check=true"
66
+ ```
67
+
68
+ ### Step 5: Compose verify command
69
+ Use the mapping table + any custom overrides detected in Step 4.
70
+ Write result to CLAUDE.md `Verify:` field.
71
+
72
+ ---
73
+
74
+ ## Toolchain Bootstrap Protocol
75
+
76
+ Run by orchestrator before first dispatch, or by /setup at project init.
77
+
78
+ ### Mode: Interactive (/setup, /add, /fix)
79
+ ```
80
+ 1. Detect missing tools (Step 2 above)
81
+ 2. If missing: WARN user, ASK before installing
82
+ "cargo is not installed but Cargo.toml exists. Install Rust via rustup? (y/n)"
83
+ 3. If user says no → log: "Verification disabled for Rust — cargo not available"
84
+ 4. If user says yes → install, verify, continue
85
+ 5. Install dependencies if missing (npm install, cargo fetch, etc.)
86
+ 6. Run quick_verify once as smoke test
87
+ ```
88
+
89
+ ### Mode: Autonomous (/copilot)
90
+ ```
91
+ 1. Detect missing tools
92
+ 2. If missing AND installer available → install automatically
93
+ Log to .claude/logs/bootstrap.log
94
+ 3. If missing AND no installer → WARN in goals.md, continue without verification
95
+ "⚠ Verification degraded: {tool} not available. Agents will skip Tier 1 checks."
96
+ 4. Install dependencies
97
+ 5. Run quick_verify
98
+ 6. FAIL → fix before ANY agent dispatches (this IS the foundation)
99
+ ```
100
+
101
+ ### Bootstrap log
102
+ All install output goes to `.claude/logs/bootstrap.log`:
103
+ ```bash
104
+ {install_command} 2>&1 | tee .claude/logs/bootstrap.log
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Verification Tiers
110
+
111
+ ### Tier 1: Static Verification (MANDATORY — every agent, every mode)
112
+
113
+ **What:** Type-check, lint, or syntax-check without building or running tests.
114
+ **Cost:** 2–30 seconds.
115
+ **Catches:** Type errors, missing imports, syntax errors, undeclared variables.
116
+
117
+ ```bash
118
+ # Agent runs this BEFORE reporting done
119
+ {quick_verify_cmd} 2>&1 | tee .claude/logs/verify-log-M{N}.md
120
+ ```
121
+
122
+ **Rules:**
123
+ - If errors exist in YOUR files → fix them (counts as a self-correction attempt)
124
+ - If errors exist in OTHER files → report but do NOT fix
125
+ - If tool is not installed → skip with warning in verify log
126
+ - MUST run even in worktree mode — the worktree has its own clean state
127
+
128
+ ### Tier 2: Scoped Test Verification (MANDATORY — every agent)
129
+
130
+ **What:** Run tests scoped to the agent's files only.
131
+ **Cost:** 10–60 seconds.
132
+ **Catches:** Logic errors, regression, missing test coverage.
133
+
134
+ ```bash
135
+ # Parallel mode: scoped to agent's directory
136
+ {scoped_test_cmd} 2>&1 | tee -a .claude/logs/verify-log-M{N}.md
137
+
138
+ # Sequential mode: full test suite
139
+ {full_test_cmd} 2>&1 | tee -a .claude/logs/verify-log-M{N}.md
140
+ ```
141
+
142
+ ### Tier 3: Full Build Verification (verification waves only — NOT per-agent)
143
+
144
+ **What:** Full compilation, bundling, linking.
145
+ **Cost:** 30–300 seconds.
146
+ **Catches:** Linking errors, bundle issues, cross-module type mismatches.
147
+
148
+ ```bash
149
+ # Orchestrator runs this after merging ALL agents in a wave
150
+ {full_build_cmd} 2>&1 | tee .claude/logs/build-wave{N}.log
151
+ ```
152
+
153
+ **Tier 3 is NEVER run by individual agents.** It's too slow and in parallel mode it would verify a partial codebase.
154
+
155
+ ---
156
+
157
+ ## Log Protocol
158
+
159
+ ### Log directory structure
160
+
161
+ ```
162
+ .claude/logs/
163
+ ├── bootstrap.log ← Level 1: toolchain install output
164
+ ├── verify-log-M1A.md ← Level 2: per-agent Tier 1+2 output
165
+ ├── verify-log-M1B.md
166
+ ├── verify-log-M2A.md
167
+ ├── runtime-M1A.log ← runtime crash output (when agent runs the app)
168
+ ├── runtime-M2C.log
169
+ ├── build-wave1.log ← post-merge full build (Tier 3)
170
+ ├── build-wave2.log
171
+ ├── integration-final.log ← final integration test output
172
+ └── session-summary.log ← stop.js writes final tally
173
+ ```
174
+
175
+ ### Log Type 1: Verify Logs (per agent)
176
+
177
+ Written by milestone-builder after running Tier 1+2. Format:
178
+
179
+ ```markdown
180
+ ## Verify Log — M{N}: {title}
181
+
182
+ ### Tier 1: Static ({command})
183
+ Status: PASS | FAIL
184
+ Errors: {count}
185
+ Warnings: {count}
186
+ {first 50 lines of output if errors or warnings}
187
+
188
+ ### Tier 2: Scoped Tests ({command})
189
+ Status: PASS | FAIL
190
+ Tests: {pass}/{total}, {failures} failures, {duration}
191
+ {first 30 lines of output if failures}
192
+
193
+ ### Tier 3: Build
194
+ Status: SKIPPED (per-agent — runs in verification wave only)
195
+
196
+ ### Self-Correction History
197
+ Attempt 1: {what happened}
198
+ Fix: {what was changed}
199
+ Attempt 2: {result}
200
+ ```
201
+
202
+ ### Log Type 2: Runtime Logs (crash capture)
203
+
204
+ Written when an agent runs the application and it crashes. The agent captures stderr:
205
+
206
+ ```bash
207
+ # Run app with timeout, capture all output, don't let crash stop execution
208
+ timeout 15 {run_command} 2>&1 | tee .claude/logs/runtime-M{N}.log; exit 0
209
+ ```
210
+
211
+ The `exit 0` prevents Claude Code from treating the crash as a Bash tool failure.
212
+ The agent then reads the log and has full stack trace context to diagnose the issue.
213
+
214
+ **When to capture runtime logs:**
215
+ - Agent's milestone involves a new endpoint, route, or page → run the app briefly
216
+ - Agent's milestone changes startup logic → run the app to verify it starts
217
+ - Agent's milestone changes a background job → run it once to verify
218
+ - Do NOT run the full app for every milestone — only when the milestone directly affects runtime behavior
219
+
220
+ ### Log Type 3: Build Logs (verification wave)
221
+
222
+ Written by the orchestrator after merging all agents in a wave:
223
+
224
+ ```bash
225
+ # After all Wave N branches merged:
226
+ {full_build_cmd} 2>&1 | tee .claude/logs/build-wave{N}.log
227
+ echo "EXIT=$?" >> .claude/logs/build-wave{N}.log
228
+ ```
229
+
230
+ If the build fails, the orchestrator reads the log, identifies which file caused the error,
231
+ traces it back to which agent's merge introduced it, and dispatches a fix agent.
232
+
233
+ ---
234
+
235
+ ## Log Relay — Logs as Context for Fix Agents
236
+
237
+ **This is the key architectural insight: logs are not just records — they are inputs to future agents.**
238
+
239
+ When the orchestrator dispatches a fix agent after a post-merge failure, it constructs the prompt from logs:
240
+
241
+ ```markdown
242
+ ## Fix Agent — Post-Wave {N} Build Failure
243
+
244
+ ### Build Log
245
+ <build-log>
246
+ {contents of .claude/logs/build-wave{N}.log — last 100 lines}
247
+ </build-log>
248
+
249
+ ### Agent Verify Logs Summary
250
+ {for each agent in this wave:}
251
+ - M{A}: {PASS/FAIL} — {error count} errors, {warning count} warnings
252
+ {any warnings that look related to the build failure}
253
+
254
+ ### Runtime Logs (if any)
255
+ {contents of .claude/logs/runtime-M{X}.log if it exists for this wave}
256
+
257
+ ### Diagnosis
258
+ The build error at {file}:{line} was introduced by M{X}'s merge.
259
+ M{X}'s verify log shows: {relevant warning or pass-despite-issue}
260
+ The type mismatch suggests {analysis}.
261
+
262
+ ### Your Task
263
+ Fix the errors in the build log. The verify logs and diagnosis above give you
264
+ full context. Do NOT re-investigate — the logs tell the story.
265
+ ```
266
+
267
+ **Rules for log relay:**
268
+ - Include only the RELEVANT portion of each log (last 100 lines of build, relevant warnings from verify)
269
+ - Never relay the full bootstrap.log — it's only useful for debugging install issues
270
+ - Verify logs are small (< 2KB each) — safe to include in full
271
+ - Build logs can be large — tail to last 100 lines
272
+ - Runtime logs can be large — include only the stack trace (grep for "Error:", "panic:", "FATAL")
273
+
274
+ ---
275
+
276
+ ## CLAUDE.md Verify Field
277
+
278
+ `/setup` writes this to the project's CLAUDE.md after running toolchain detection:
279
+
280
+ ```markdown
281
+ ## Verify
282
+ Quick: {Tier 1 command}
283
+ Test: {Tier 2 command}
284
+ Build: {Tier 3 command}
285
+ ```
286
+
287
+ Example for a Rust + Svelte project:
288
+ ```markdown
289
+ ## Verify
290
+ Quick: cargo check && npx svelte-check
291
+ Test: cargo test && npm test
292
+ Build: cargo build --release && npm run build
293
+ ```
294
+
295
+ Every agent reads this field. No agent guesses the verify command.
296
+ If the field is missing → agent runs toolchain detection inline (slower but safe).
297
+
298
+ ---
299
+
300
+ ## Cleanup Protocol
301
+
302
+ Logs accumulate across waves. Clean up after ship:
303
+
304
+ ```bash
305
+ # After /ship completes successfully:
306
+ mkdir -p .claude/logs/archive
307
+ mv .claude/logs/*.log .claude/logs/*.md .claude/logs/archive/ 2>/dev/null
308
+ echo "Archived $(date -u +%Y-%m-%dT%H:%M:%S)" > .claude/logs/archive/README.md
309
+ ```
310
+
311
+ **Do NOT delete logs before ship** — they may be needed for fix agents.
312
+ **Do NOT commit logs to git** — add `.claude/logs/` to `.gitignore`.
313
+
314
+ ---
315
+
316
+ ## Integration Points
317
+
318
+ | Component | How it uses toolchain-gate |
319
+ |-----------|--------------------------|
320
+ | `/setup` | Runs detection protocol, writes `Verify:` to CLAUDE.md |
321
+ | `env-scan.sh` | Outputs `toolchain` + `verify_cmd` in JSON |
322
+ | `problem-architect` | Reads `Verify:` field, adds `Verify:` to Team Spec per milestone |
323
+ | `milestone-builder` | Runs Tier 1+2 exit gate, writes verify-log, captures runtime logs |
324
+ | `orchestrator` | Runs bootstrap, runs Tier 3 between waves, relays logs to fix agents |
325
+ | `blueprint` | Includes toolchain check in Wave 0 foundation |
326
+ | `.gitignore` | Must include `.claude/logs/` |
@@ -160,9 +160,43 @@ echo "source_files=$SRC_COUNT"
160
160
  ```
161
161
  If source_files < 10 → greenfield project. Force Wave 1 = all foundation work (schema, config, shared utils, types) as a SINGLE milestone regardless of feature count. Parallel only unlocks from Wave 2 onward, after the foundation exists and greps have real files to scan.
162
162
 
163
+ **Step 0b: Toolchain check (load `capabilities/shared/toolchain-gate.md`)**
164
+ ```bash
165
+ # Check Verify field in CLAUDE.md
166
+ grep -q "^Quick:" CLAUDE.md 2>/dev/null && echo "verify=configured" || echo "verify=missing"
167
+ ```
168
+ If `verify=missing` → run toolchain detection protocol from toolchain-gate.md and write `## Verify` to CLAUDE.md.
169
+ If tools are missing → warn in the plan: `"⚠ Toolchain gap: {tool} not installed. Agents cannot run Tier 1 verification. Run: {install command}"`
170
+
171
+ Wave 0 (foundation) MUST include a toolchain bootstrap step:
172
+ ```
173
+ ## M0: Foundation — Toolchain + Schema + Shared Types
174
+ - Install missing tools and dependencies
175
+ - Run smoke test: {quick_verify_cmd}
176
+ - Create shared types, base schemas, core config
177
+ ```
178
+
163
179
  **Step 1: List raw work items**
164
180
  From the intent/spec, enumerate ALL features, endpoints, models, UI pages, and background jobs as raw items. Do not group yet — just list everything the project needs.
165
181
 
182
+ **Step 1b: Migration detection (before coupling analysis)**
183
+ For each raw work item, check if it is a **migration or cross-cutting refactor**:
184
+ - Framework/library upgrade (React class→hooks, Svelte 4→5, Vue Options→Composition, Angular versions)
185
+ - Language version bump that changes syntax or stdlib APIs
186
+ - Build tool change (webpack→vite, setuptools→poetry, Maven→Gradle)
187
+ - Store/state management rewrite (Redux→Zustand, Vuex→Pinia, writable→runes)
188
+ - ORM or database driver migration
189
+ - Auth/middleware pattern rewrite
190
+
191
+ **If detected → force SEQUENTIAL-ONLY.** Never split a migration across parallel agents.
192
+ Mark the milestone: `Parallel: no (migration — SEQUENTIAL-ONLY)`.
193
+ If the migration touches 15+ files, recommend sequential sub-milestones:
194
+ ```
195
+ Sub-1: {foundation — sets the new pattern} → SEQUENTIAL-ONLY
196
+ Sub-2: {consumers group A — follows pattern} → Depends: Sub-1
197
+ Sub-3: {consumers group B — follows pattern} → Depends: Sub-2
198
+ ```
199
+
166
200
  **Step 2: Coupling analysis — merge rule**
167
201
  For each pair of raw work items, check if they share ANY of:
168
202
  - Same database table (both CREATE or ALTER the same table)
@@ -200,6 +234,14 @@ Wave 2 = milestones that only depend on Wave 1
200
234
  Wave N = milestones that only depend on waves 1..N-1
201
235
  ```
202
236
 
237
+ **Wave 1 contract rule:** Wave 1 sets the types, APIs, schemas, and patterns for all later waves.
238
+ - Wave 1 should be the **smallest, most carefully specified wave**
239
+ - Wave 1 milestones define shared types, base schemas, core configs, foundational patterns
240
+ - Wave 1 agents get 3 fix attempts (not 2) — errors here multiply across every later wave
241
+ - Wave 1 MUST pass full build+test verification before Wave 2 dispatches
242
+ - If Wave 1 introduces a new pattern → document it in `patterns.md` before Wave 2 dispatch
243
+ - **Max agents in Wave 1:** 3 (even if more milestones are ready) — precision over speed
244
+
203
245
  **Step 2: Directory-level isolation check (Layer 1a)**
204
246
 
205
247
  For each wave with 2+ milestones:
@@ -173,7 +173,22 @@ if (fs.existsSync(seclogPath)) {
173
173
  } catch (_) {}
174
174
  }
175
175
 
176
- // ── Visualizer session-summary event (opt-in) ──
176
+ // ── Visualizer pipeline-complete + session-summary events (opt-in) ──
177
+ if (process.env.AZCLAUDE_VISUALIZER) {
178
+ // Signal pipeline completion — all stages go green
179
+ try {
180
+ const vPort0 = parseInt(process.env.AZCLAUDE_VISUALIZER, 10) || 8765;
181
+ const pcPayload = JSON.stringify({ type: 'pipeline-complete' });
182
+ const pcReq = require('http').request(
183
+ { hostname: '127.0.0.1', port: vPort0, path: '/event', method: 'POST',
184
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(pcPayload) } },
185
+ () => {}
186
+ );
187
+ pcReq.setTimeout(1500, () => pcReq.destroy());
188
+ pcReq.on('error', () => {});
189
+ pcReq.end(pcPayload);
190
+ } catch (_v) {}
191
+ }
177
192
  if (process.env.AZCLAUDE_VISUALIZER) {
178
193
  try {
179
194
  const vPort = parseInt(process.env.AZCLAUDE_VISUALIZER, 10) || 8765;
@@ -207,8 +207,21 @@ try {
207
207
  console.log('This pipeline is NON-NEGOTIABLE. Do not skip steps. Do not start coding before Step 1 completes.');
208
208
  console.log('--- END PIPELINE ---');
209
209
 
210
- // ── Visualizer event (opt-in) ──
210
+ // ── Visualizer events (opt-in) ──
211
211
  if (process.env.AZCLAUDE_VISUALIZER) {
212
+ try {
213
+ const vPort = parseInt(process.env.AZCLAUDE_VISUALIZER, 10) || 8765;
214
+ // Send user message first
215
+ const msgPayload = JSON.stringify({ type: 'user-message', message: promptText.slice(0, 200) });
216
+ const msgReq = require('http').request(
217
+ { hostname: '127.0.0.1', port: vPort, path: '/event', method: 'POST',
218
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(msgPayload) } },
219
+ () => {}
220
+ );
221
+ msgReq.setTimeout(1500, () => msgReq.destroy());
222
+ msgReq.on('error', () => {});
223
+ msgReq.end(msgPayload);
224
+ } catch (_v) {}
212
225
  try {
213
226
  const vPort = parseInt(process.env.AZCLAUDE_VISUALIZER, 10) || 8765;
214
227
  const payload = JSON.stringify({ type: 'pipeline-start', intents: intents, tier: tier, tierLabel: tierLabel });
@@ -235,6 +248,22 @@ try {
235
248
  const ctxSignal = JSON.parse(fs.readFileSync(ctxSignalPath, 'utf8'));
236
249
  const pct = ctxSignal.ctxPct || 0;
237
250
 
251
+ // Send context % to visualizer
252
+ if (process.env.AZCLAUDE_VISUALIZER) {
253
+ try {
254
+ const vPort = parseInt(process.env.AZCLAUDE_VISUALIZER, 10) || 8765;
255
+ const ctxPayload = JSON.stringify({ type: 'context-update', pct: pct });
256
+ const ctxReq = require('http').request(
257
+ { hostname: '127.0.0.1', port: vPort, path: '/event', method: 'POST',
258
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(ctxPayload) } },
259
+ () => {}
260
+ );
261
+ ctxReq.setTimeout(1500, () => ctxReq.destroy());
262
+ ctxReq.on('error', () => {});
263
+ ctxReq.end(ctxPayload);
264
+ } catch (_v) {}
265
+ }
266
+
238
267
  if (pct >= 85) {
239
268
  // AUTO-SAVE: context is critically high — save checkpoint before compaction wipes it
240
269
  const checkpointDir = path.join(cfg, 'memory', 'checkpoints');
@@ -40,6 +40,40 @@ cat <<EOF
40
40
  "commands_count": $(count_files .claude/commands 2>/dev/null),
41
41
  "agents_count": $(count_files .claude/agents 2>/dev/null)
42
42
  },
43
+ "toolchain": {
44
+ "node": { "installed": $(command -v node >/dev/null 2>&1 && echo true || echo false), "version": "$(node --version 2>/dev/null || echo null)" },
45
+ "cargo": { "installed": $(command -v cargo >/dev/null 2>&1 && echo true || echo false), "version": "$(cargo --version 2>/dev/null | head -1 || echo null)" },
46
+ "python": { "installed": $(command -v python3 >/dev/null 2>&1 && echo true || echo false), "version": "$(python3 --version 2>/dev/null || echo null)" },
47
+ "go": { "installed": $(command -v go >/dev/null 2>&1 && echo true || echo false), "version": "$(go version 2>/dev/null || echo null)" },
48
+ "dotnet": { "installed": $(command -v dotnet >/dev/null 2>&1 && echo true || echo false), "version": "$(dotnet --version 2>/dev/null || echo null)" },
49
+ "ruby": { "installed": $(command -v ruby >/dev/null 2>&1 && echo true || echo false), "version": "$(ruby --version 2>/dev/null || echo null)" }
50
+ },
51
+ "deps": {
52
+ "node_modules": $(has_dir node_modules),
53
+ "target": $(has_dir target),
54
+ "venv": $([ -d venv ] || [ -d .venv ] && echo true || echo false),
55
+ "vendor": $(has_dir vendor)
56
+ },
57
+ "verify_cmd": "$(
58
+ V=""
59
+ if [ -f Cargo.toml ]; then
60
+ command -v cargo >/dev/null 2>&1 && V="cargo check" || V="# cargo missing"
61
+ fi
62
+ if [ -f package.json ]; then
63
+ if command -v npx >/dev/null 2>&1; then
64
+ grep -q '"typescript"' package.json 2>/dev/null && V="${V:+$V && }npx tsc --noEmit" || V="${V:+$V && }npx eslint src/ || true"
65
+ else
66
+ V="${V:+$V && }# node missing"
67
+ fi
68
+ fi
69
+ if [ -f pyproject.toml ] || [ -f requirements.txt ]; then
70
+ command -v python3 >/dev/null 2>&1 && V="${V:+$V && }python3 -m py_compile" || V="${V:+$V && }# python missing"
71
+ fi
72
+ if [ -f go.mod ]; then
73
+ command -v go >/dev/null 2>&1 && V="${V:+$V && }go vet ./..." || V="${V:+$V && }# go missing"
74
+ fi
75
+ echo "${V:-echo no-stack-detected}"
76
+ )",
43
77
  "git_log": "$(git log --oneline -5 2>/dev/null | head -5 | tr '\n' '|' | sed 's/"/\\"/g' || echo 'none')",
44
78
  "readme_head": "$(head -10 README.md 2>/dev/null | tr '\n' '|' | sed 's/"/\\"/g' || echo 'none')"
45
79
  }
@@ -87,6 +87,11 @@
87
87
  case 'WebFetch': return input.url || '(no URL)';
88
88
  case 'WebSearch': return '"' + (input.query || '') + '"';
89
89
  case 'Skill': return input.skill || '(unknown skill)';
90
+ case 'MultiEdit': { let s = input.file_path || '(unknown file)'; if (input.edits) s += ' (' + input.edits.length + ' edits)'; return s; }
91
+ case 'NotebookEdit': { let s = input.notebook || input.file_path || '(notebook)'; if (input.cell_id != null) s += ' cell ' + input.cell_id; return s; }
92
+ case 'AskUserQuestion': return input.question || '(question)';
93
+ case 'TaskCreate': return input.subject || '(new task)';
94
+ case 'TaskUpdate': { let s = 'task #' + (input.taskId || '?'); if (input.status) s += ' → ' + input.status; return s; }
90
95
  default: {
91
96
  const keys = Object.keys(input);
92
97
  if (keys.length === 0) return null;
@@ -197,7 +202,7 @@
197
202
  pipelineProgress.classList.add('visible');
198
203
  const primary = (intents && intents[0]) || 'CODE';
199
204
  const cls = primary.toLowerCase();
200
- brainIntent.innerHTML = '<span class="intent-label ' + (['build','fix','review','test','refactor','plan','devops','frontend'].includes(cls) ? cls : 'default') + '">' + primary + '</span>' +
205
+ brainIntent.innerHTML = '<span class="intent-label ' + (['build','fix','review','test','refactor','plan','devops','frontend','extend','code','security','analyze'].includes(cls) ? cls : 'default') + '">' + primary + '</span>' +
201
206
  (tier ? ' <span style="font-size:9px;color:#5A5448">Tier ' + tier + '</span>' : '');
202
207
  // Reset pipeline stages
203
208
  document.querySelectorAll('.pipeline-stage').forEach(function (el) { el.classList.remove('active', 'complete'); });
@@ -236,6 +241,9 @@
236
241
 
237
242
  if (settings.mcpLabels) { const mcpServer = extractMcpServer(event.tool_name); if (mcpServer) { const label = document.createElement('span'); label.className = 'mcp-label'; label.textContent = mcpServer; header.appendChild(label); } }
238
243
 
244
+ // Agent label — show which subagent made this call
245
+ if (event.agent_type) { const agentLabel = document.createElement('span'); agentLabel.className = 'mcp-label'; agentLabel.style.background = 'rgba(168, 130, 255, 0.15)'; agentLabel.style.color = '#A882FF'; agentLabel.textContent = event.agent_type; header.appendChild(agentLabel); }
246
+
239
247
  // Diff stat badge (AZCLAUDE enriched)
240
248
  if (event.diffStat) { const ds = document.createElement('span'); ds.className = 'diff-stat'; ds.textContent = event.diffStat; header.appendChild(ds); }
241
249
 
@@ -328,6 +336,37 @@
328
336
  addSecurityEvent(event.level, event.rule, event.message);
329
337
  return;
330
338
  }
339
+ if (event.event === 'user-message') {
340
+ var card = document.createElement('div'); card.className = 'user-message-card';
341
+ var hdr = document.createElement('div'); hdr.className = 'user-message-header';
342
+ hdr.innerHTML = '<span class="user-message-icon">&#9656;</span> User';
343
+ var txt = document.createElement('div'); txt.className = 'user-message-text';
344
+ txt.textContent = event.message || '(empty)';
345
+ card.appendChild(hdr); card.appendChild(txt);
346
+ feed.appendChild(card); pruneOldCards(); scrollToBottom();
347
+ return;
348
+ }
349
+ if (event.event === 'context-update') {
350
+ var pct = event.pct || 0;
351
+ var bar = document.getElementById('context-bar');
352
+ var fill = document.getElementById('context-fill');
353
+ var label = document.getElementById('context-pct');
354
+ if (bar && fill && label) {
355
+ bar.classList.add('visible');
356
+ fill.style.width = pct + '%';
357
+ fill.className = 'context-fill' + (pct >= 85 ? ' critical' : pct >= 70 ? ' warn' : '');
358
+ label.textContent = pct + '%';
359
+ label.style.color = pct >= 85 ? '#C85050' : pct >= 70 ? '#D4A017' : '#5A5448';
360
+ }
361
+ return;
362
+ }
363
+ if (event.event === 'pipeline-complete') {
364
+ document.querySelectorAll('.pipeline-stage').forEach(function (el) {
365
+ el.classList.remove('active', 'complete');
366
+ el.classList.add('done');
367
+ });
368
+ return;
369
+ }
331
370
  if (event.event === 'session-summary') {
332
371
  const parts = [];
333
372
  if (event.duration) parts.push(event.duration);
@@ -43,6 +43,11 @@
43
43
  Plan: { register: LOW, style: 'chord', notes: 3, velocity: 0.6 },
44
44
  EnterPlanMode: { register: LOW, style: 'chord', notes: 3, velocity: 0.55 },
45
45
  ExitPlanMode: { register: MID, style: 'arpUp', notes: 3, velocity: 0.55 },
46
+ MultiEdit: { register: MID, style: 'arpDown', notes: 4, velocity: 0.6 },
47
+ NotebookEdit: { register: LOW, style: 'chord', notes: 3, velocity: 0.55 },
48
+ AskUserQuestion: { register: HIGH, style: 'scatter', notes: 3, velocity: 0.5 },
49
+ TaskCreate: { register: LOW, style: 'arpUp', notes: 2, velocity: 0.45 },
50
+ TaskUpdate: { register: LOW, style: 'pulse', notes: 2, velocity: 0.4 },
46
51
  _default: { register: MID, style: 'arpUp', notes: 2, velocity: 0.5 },
47
52
  };
48
53
 
@@ -8,7 +8,10 @@
8
8
  Read: '#D4A017', Edit: '#C86840', Write: '#B85535', Bash: '#6B8E5A',
9
9
  Glob: '#C8A850', Grep: '#B89040', Agent: '#D4B030', WebFetch: '#4A8A7A',
10
10
  WebSearch: '#3A7A6A', TodoWrite: '#A06858', Skill: '#B87040', Plan: '#8A6070',
11
- EnterPlanMode: '#8A6070', ExitPlanMode: '#8A6070', _default: '#7A7060',
11
+ EnterPlanMode: '#8A6070', ExitPlanMode: '#8A6070',
12
+ MultiEdit: '#C86840', NotebookEdit: '#8A6070', AskUserQuestion: '#4A8A7A',
13
+ TaskCreate: '#6B8E5A', TaskUpdate: '#5A7A4A', TaskList: '#5A7A4A',
14
+ _default: '#7A7060',
12
15
  };
13
16
 
14
17
  const SECURITY_COLORS = { block: '#ff2222', warn: '#ffaa00' };
@@ -57,6 +57,12 @@
57
57
 
58
58
  <div id="settings-panel"></div>
59
59
 
60
+ <!-- Context window usage -->
61
+ <div id="context-bar">
62
+ <div class="context-label">Context <span id="context-pct">0%</span></div>
63
+ <div class="context-track"><div class="context-fill" id="context-fill"></div></div>
64
+ </div>
65
+
60
66
  <!-- Pipeline progress -->
61
67
  <div id="pipeline-progress">
62
68
  <div id="brain-intent"></div>
@@ -89,6 +89,22 @@ body { display: flex; flex-direction: row; }
89
89
  .toggle-switch.on { background: #2A3528; }
90
90
  .toggle-switch.on::after { transform: translateX(16px); background: #6B8E5A; }
91
91
 
92
+ /* ===== Context Window Bar ===== */
93
+ #context-bar { padding: 8px 16px; border-bottom: 1px solid #1E1C18; flex-shrink: 0; display: none; }
94
+ #context-bar.visible { display: block; }
95
+ .context-label { font-size: 10px; color: #5A5448; display: flex; justify-content: space-between; margin-bottom: 4px; }
96
+ #context-pct { font-weight: 600; }
97
+ .context-track { height: 4px; background: #1E1C18; border-radius: 2px; overflow: hidden; }
98
+ .context-fill { height: 100%; width: 0%; border-radius: 2px; background: #6B8E5A; transition: width 0.5s ease, background 0.5s ease; }
99
+ .context-fill.warn { background: #D4A017; }
100
+ .context-fill.critical { background: #C85050; animation: pulse-dot 1s ease-in-out infinite; }
101
+
102
+ /* ===== User Message Card ===== */
103
+ .user-message-card { background: #1A1816; border-radius: 6px; margin-bottom: 8px; border-left: 3px solid #4A8A7A; padding: 8px 12px; }
104
+ .user-message-header { display: flex; align-items: center; gap: 8px; font-size: 10px; color: #5A5448; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
105
+ .user-message-icon { font-size: 12px; }
106
+ .user-message-text { font-size: 12px; color: #E8DCC8; opacity: 0.85; line-height: 1.4; word-break: break-word; }
107
+
92
108
  /* ===== AZCLAUDE Pipeline Progress ===== */
93
109
  #pipeline-progress { padding: 10px 16px; border-bottom: 1px solid #1E1C18; flex-shrink: 0; display: none; }
94
110
  #pipeline-progress.visible { display: block; }
@@ -103,12 +119,17 @@ body { display: flex; flex-direction: row; }
103
119
  .intent-label.plan { background: #241A24; color: #8A6070; }
104
120
  .intent-label.devops { background: #1A2418; color: #5A7A4A; }
105
121
  .intent-label.frontend { background: #2A1820; color: #B85570; }
122
+ .intent-label.extend { background: #24201A; color: #D4A017; }
123
+ .intent-label.code { background: #1A1E18; color: #8A9E7A; }
124
+ .intent-label.security { background: #2A1818; color: #C85050; }
125
+ .intent-label.analyze { background: #1A1A24; color: #7A80BA; }
106
126
  .intent-label.default { background: #1E1C18; color: #8A7E6A; }
107
127
 
108
128
  .pipeline-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
109
129
  .pipeline-stage { font-size: 9px; text-align: center; padding: 4px 2px; border-radius: 3px; background: #1E1C18; color: #3A3630; text-transform: uppercase; letter-spacing: 0.5px; transition: all 0.4s ease; }
110
130
  .pipeline-stage.active { background: #1A2A18; color: #6B8E5A; box-shadow: 0 0 8px rgba(107,142,90,0.3); animation: pulse-dot 1.5s ease-in-out infinite; }
111
131
  .pipeline-stage.complete { background: #1A2418; color: #4A6A3A; }
132
+ .pipeline-stage.done { background: #1A2A18; color: #6B8E5A; }
112
133
 
113
134
  /* ===== Security Events ===== */
114
135
  #security-events { flex-shrink: 0; max-height: 120px; overflow-y: auto; }
@@ -21,15 +21,20 @@ const LOG_FILE = path.join(os.tmpdir(), 'azclaude-visualizer.jsonl');
21
21
  const MAX_BODY_SIZE = 1024 * 1024;
22
22
 
23
23
  // ---------------------------------------------------------------------------
24
- // SSE client management
24
+ // SSE client management + replay buffer
25
25
  // ---------------------------------------------------------------------------
26
26
  const sseClients = new Set();
27
+ const EVENT_BUFFER_MAX = 200;
28
+ const eventBuffer = [];
27
29
 
28
30
  function broadcast(event) {
29
31
  const data = `data: ${JSON.stringify(event)}\n\n`;
30
32
  for (const client of sseClients) {
31
33
  try { client.write(data); } catch { sseClients.delete(client); }
32
34
  }
35
+ // Ring buffer for reconnect replay
36
+ eventBuffer.push(event);
37
+ if (eventBuffer.length > EVENT_BUFFER_MAX) eventBuffer.shift();
33
38
  }
34
39
 
35
40
  // SSE heartbeat
@@ -164,6 +169,10 @@ function handleSSE(req, res) {
164
169
  'Access-Control-Allow-Origin': '*',
165
170
  });
166
171
  res.write(': connected\n\n');
172
+ // Replay buffered events so refreshing the browser doesn't lose history
173
+ for (const event of eventBuffer) {
174
+ try { res.write(`data: ${JSON.stringify(event)}\n\n`); } catch { return; }
175
+ }
167
176
  sseClients.add(res);
168
177
  req.on('close', () => { sseClients.delete(res); });
169
178
  }