maxsimcli 4.16.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/CHANGELOG.md +31 -0
  2. package/dist/assets/hooks/maxsim-check-update.cjs.map +1 -1
  3. package/dist/assets/hooks/maxsim-notification-sound.cjs +70 -0
  4. package/dist/assets/hooks/maxsim-notification-sound.cjs.map +1 -0
  5. package/dist/assets/hooks/maxsim-statusline.cjs.map +1 -1
  6. package/dist/assets/hooks/maxsim-stop-sound.cjs +70 -0
  7. package/dist/assets/hooks/maxsim-stop-sound.cjs.map +1 -0
  8. package/dist/assets/hooks/maxsim-sync-reminder.cjs.map +1 -1
  9. package/dist/assets/templates/agents/executor.md +2 -2
  10. package/dist/assets/templates/agents/planner.md +1 -1
  11. package/dist/assets/templates/agents/verifier.md +1 -1
  12. package/dist/assets/templates/commands/maxsim/quick.md +2 -2
  13. package/dist/assets/templates/skills/github-artifact-protocol/SKILL.md +8 -8
  14. package/dist/assets/templates/skills/github-tools-guide/SKILL.md +96 -0
  15. package/dist/assets/templates/workflows/execute-plan.md +82 -68
  16. package/dist/assets/templates/workflows/execute.md +51 -36
  17. package/dist/assets/templates/workflows/go.md +21 -16
  18. package/dist/assets/templates/workflows/init-existing.md +13 -16
  19. package/dist/assets/templates/workflows/new-milestone.md +23 -1
  20. package/dist/assets/templates/workflows/new-project.md +13 -16
  21. package/dist/assets/templates/workflows/plan-create.md +16 -24
  22. package/dist/assets/templates/workflows/plan-discuss.md +6 -8
  23. package/dist/assets/templates/workflows/plan-research.md +7 -6
  24. package/dist/assets/templates/workflows/plan.md +21 -14
  25. package/dist/assets/templates/workflows/progress.md +45 -20
  26. package/dist/assets/templates/workflows/quick.md +21 -13
  27. package/dist/assets/templates/workflows/sdd.md +13 -11
  28. package/dist/assets/templates/workflows/verify-phase.md +77 -58
  29. package/dist/cli.cjs +4410 -2265
  30. package/dist/cli.cjs.map +1 -1
  31. package/dist/install.cjs +61 -38
  32. package/dist/install.cjs.map +1 -1
  33. package/package.json +2 -4
  34. package/dist/assets/templates/workflows/discovery-phase.md +0 -292
  35. package/dist/assets/templates/workflows/execute-phase.md +0 -752
  36. package/dist/mcp-server.cjs +0 -41031
  37. package/dist/mcp-server.cjs.map +0 -1
@@ -1,752 +0,0 @@
1
- <sanity_check>
2
- Before executing any step in this workflow, verify:
3
- 1. The current directory contains a `.planning/` folder — if not, stop and tell the user to run `/maxsim:init` first.
4
- 2. `.planning/ROADMAP.md` exists — if not, stop and tell the user to initialize the project.
5
- </sanity_check>
6
-
7
- <purpose>
8
- Execute all plans in a phase using wave-based parallel execution. Orchestrator stays lean — delegates plan execution to subagents. Plans are read from GitHub issue comments; summaries are posted as GitHub comments; task sub-issues are transitioned on the board per task.
9
- </purpose>
10
-
11
- <core_principle>
12
- Orchestrator coordinates, not executes. Each subagent loads the full execute-plan context. Orchestrator: discover plans from GitHub → analyze deps → group waves → spawn agents → handle checkpoints → collect results.
13
- </core_principle>
14
-
15
- <agent_teams>
16
- **Agent Teams Model:** MAXSIM uses Agent Teams for grouping parallel agents, NOT for peer-to-peer communication.
17
-
18
- - `team_name` groups agents in a wave so Claude Code can track them as a unit
19
- - All coordination routes through the orchestrator (this workflow)
20
- - Subagents CANNOT spawn other subagents — only the orchestrator spawns agents
21
- - Inter-wave handoff: orchestrator passes wave N results as context to wave N+1 agents
22
- - Status tracking: orchestrator maintains a progress table per wave
23
- </agent_teams>
24
-
25
- <required_reading>
26
- Read STATE.md before any operation to load project context.
27
- </required_reading>
28
-
29
- <process>
30
-
31
- <step name="initialize" priority="first">
32
- Load all context in one call:
33
-
34
- ```bash
35
- INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init execute-phase "${PHASE_ARG}")
36
- ```
37
-
38
- Parse JSON for: `executor_model`, `verifier_model`, `commit_docs`, `parallelization`, `branching_strategy`, `branch_name`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `state_exists`, `roadmap_exists`, `phase_req_ids`, `phase_issue_number`, `task_mappings`.
39
-
40
- Also extract parallel execution fields:
41
- ```
42
- WORKTREE_MODE (from init JSON worktree_mode — "auto", "always", or "never")
43
- MAX_PARALLEL_AGENTS (from init JSON max_parallel_agents — default 10)
44
- REVIEW_CONFIG (from init JSON review_config — spec_review, code_review, simplify_review, retry_limit)
45
- ```
46
-
47
- **If `phase_found` is false:** Error — phase directory not found.
48
- **If `plan_count` is 0:** Check GitHub before reporting no plans (see discover_and_group_plans step).
49
- **If `state_exists` is false but `.planning/` exists:** Offer reconstruct or continue.
50
-
51
- When `parallelization` is false, plans within a wave execute sequentially.
52
- </step>
53
-
54
- <step name="handle_branching">
55
- Check `branching_strategy` from init:
56
-
57
- **"none":** Skip, continue on current branch.
58
-
59
- **"phase" or "milestone":** Use pre-computed `branch_name` from init:
60
- ```bash
61
- git checkout -b "$BRANCH_NAME" 2>/dev/null || git checkout "$BRANCH_NAME"
62
- ```
63
-
64
- All subsequent commits go to this branch. User handles merging.
65
- </step>
66
-
67
- <step name="validate_phase">
68
- From init JSON: `phase_dir`, `plan_count`, `incomplete_count`.
69
-
70
- Report: "Found {plan_count} plans in {phase_dir} ({incomplete_count} incomplete)"
71
- </step>
72
-
73
- <step name="discover_and_group_plans">
74
-
75
- ## Plan Discovery -- GitHub First
76
-
77
- When `phase_issue_number` is set (GitHub integration active):
78
-
79
- 1. **Check for external edits (WIRE-06):**
80
- ```
81
- mcp_detect_external_edits(issue_number: phase_issue_number)
82
- ```
83
- If external edits detected: warn user before continuing.
84
-
85
- 2. **Fetch the phase issue and its comments:**
86
- ```
87
- mcp_get_issue_detail(issue_number: phase_issue_number)
88
- ```
89
-
90
- 3. **Parse plan comments:** Identify comments containing either:
91
- - `<!-- maxsim:type=plan -->` HTML marker, OR
92
- - A heading `## Plan NN` (where NN is a number)
93
-
94
- 4. **For each plan comment:**
95
- - Extract plan number from the heading or frontmatter
96
- - Parse YAML frontmatter from the comment body for: `wave`, `dependencies`, `autonomous`, `objective`, `gap_closure`, `task_count`
97
- - Store plan content in memory as `PLAN_COMMENTS[]`
98
-
99
- 5. **Determine completion status for each plan:**
100
- - Call `mcp_list_sub_issues(issue_number: phase_issue_number)` to get all task sub-issues
101
- - A plan is complete when all its task sub-issues are closed (cross-reference using `task_mappings`)
102
- - Also check for `<!-- maxsim:type=summary -->` comments as a secondary completion signal
103
-
104
- 6. **Build plan inventory:**
105
- - `plans[]`: each with `id`, `wave`, `autonomous`, `objective`, `has_summary` (true if all sub-issues closed), `plan_comment_body`, `task_mappings`
106
- - `waves`: map of wave number → plan IDs
107
- - `incomplete`: IDs of plans that are not yet complete
108
- - `has_checkpoints`: true if any plan has `autonomous: false`
109
-
110
- **Filtering:** Skip plans where `has_summary: true`. If `--gaps-only`: also skip non-gap_closure plans. If all filtered: "No matching incomplete plans" → exit.
111
-
112
- **If GitHub integration is NOT active** (`phase_issue_number` is not set):
113
-
114
- GitHub Issues is the source of truth for plans. Report the error and exit:
115
- ```
116
- GitHub integration required. Ensure GitHub Issues is configured: run /maxsim:init to set up.
117
- ```
118
-
119
- Report:
120
- ```
121
- ## Execution Plan
122
-
123
- **Phase {X}: {Name}** — {total_plans} plans across {wave_count} waves
124
-
125
- | Wave | Plans | What it builds |
126
- |------|-------|----------------|
127
- | 1 | 01-01, 01-02 | {from plan objectives, 3-8 words} |
128
- | 2 | 01-03 | ... |
129
- ```
130
- </step>
131
-
132
- <step name="decide_execution_mode">
133
- After discovering plans and grouping by wave, determine whether to use batch (worktree) or standard execution.
134
-
135
- ```bash
136
- # Parse --worktrees / --no-worktrees flags from $ARGUMENTS
137
- FLAG_OVERRIDE=""
138
- if echo "$ARGUMENTS" | grep -q "\-\-worktrees"; then FLAG_OVERRIDE="worktrees"; fi
139
- if echo "$ARGUMENTS" | grep -q "\-\-no-worktrees"; then FLAG_OVERRIDE="no-worktrees"; fi
140
-
141
- # Call CLI decision function
142
- MODE_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs decide-execution-mode \
143
- "${INCOMPLETE_PLAN_COUNT}" "${WAVE_COUNT}" \
144
- --worktree-mode "${WORKTREE_MODE}" \
145
- ${FLAG_OVERRIDE:+--flag-override "$FLAG_OVERRIDE"})
146
- EXECUTION_MODE=$(echo "$MODE_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).mode))")
147
- ```
148
-
149
- Display decision:
150
- ```
151
- **Execution Mode:** {Batch (worktree isolation) | Standard}
152
- {If batch: "Will create {N} worktrees for parallel plan execution"}
153
- {If standard and parallelization true: "Parallel within waves, sequential across waves"}
154
- {If standard and parallelization false: "Sequential execution"}
155
- ```
156
-
157
- **If batch mode, validate plan independence:**
158
- ```bash
159
- # Build plans JSON from plan inventory data
160
- VALID=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs validate-plan-independence "$PLANS_JSON")
161
- ```
162
- If conflicts found: report conflicts, fall back to standard mode with warning.
163
- </step>
164
-
165
- <step name="execute_waves">
166
- Execute each wave in sequence. The execution path depends on `EXECUTION_MODE` from the decide_execution_mode step.
167
-
168
- **BATCH PATH (when EXECUTION_MODE == "batch"):**
169
-
170
- For each wave:
171
-
172
- 1. **Create worktrees for all plans in the wave:**
173
- ```bash
174
- for PLAN_ID in $WAVE_PLANS; do
175
- WT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs worktree-create "${PHASE_NUMBER}" "$PLAN_ID" "$WAVE_NUM")
176
- # Parse WT JSON for path and branch
177
- done
178
- ```
179
-
180
- 2. **Describe what is being built (BEFORE spawning):**
181
-
182
- Read each plan's `<objective>` from the plan comment content. Extract what is being built and why.
183
-
184
- ```
185
- ---
186
- ## Wave {N} (Batch Mode)
187
-
188
- **{Plan ID}: {Plan Name}**
189
- {2-3 sentences: what this builds, technical approach, why it matters}
190
-
191
- Spawning {count} isolated agent(s) in worktrees...
192
- ---
193
- ```
194
-
195
- 3. **Spawn executor agents with worktree isolation:**
196
-
197
- ```
198
- Task(
199
- subagent_type="executor",
200
- model="{executor_model}",
201
- isolation="worktree",
202
- team_name="maxsim-phase-{PHASE_NUMBER}-wave-{WAVE_NUM}",
203
- prompt="
204
- <objective>
205
- Execute plan {plan_number} of phase {phase_number}-{phase_name}.
206
- Commit each task atomically. Post SUMMARY as GitHub comment.
207
- Move task sub-issues on the board: In Progress when started, Done when completed.
208
- IMPORTANT: Do NOT update STATE.md or ROADMAP.md — the orchestrator handles metadata.
209
- </objective>
210
-
211
- <execution_context>
212
- @./workflows/execute-plan.md
213
- @./templates/summary.md
214
- @./references/checkpoints.md
215
- </execution_context>
216
-
217
- <github_context>
218
- Phase issue number: {phase_issue_number}
219
- Plan comment body: {plan_comment_body}
220
- Task mappings: {task_mappings_for_this_plan}
221
- </github_context>
222
-
223
- <files_to_read>
224
- Read these files at execution start using the Read tool:
225
- - .planning/STATE.md (State — READ ONLY, do not modify)
226
- - .planning/config.json (Config, if exists)
227
- - ./CLAUDE.md (Project instructions, if exists)
228
- </files_to_read>
229
-
230
- <constraints>
231
- - You are running in a worktree. Do NOT modify .planning/STATE.md or .planning/ROADMAP.md.
232
- - Only post summary comment to GitHub and commit task code.
233
- - The orchestrator will handle metadata updates after all agents complete.
234
- </constraints>
235
-
236
- <success_criteria>
237
- - [ ] All tasks executed
238
- - [ ] Each task committed individually
239
- - [ ] Summary posted as GitHub comment (type=summary) on phase issue #{phase_issue_number}
240
- - [ ] Task sub-issues moved: In Progress → Done per task
241
- </success_criteria>
242
- ",
243
- run_in_background=true
244
- )
245
- ```
246
-
247
- 4. **Track progress with status table** (update as agents complete):
248
- ```
249
- | Plan | Agent | Status | Duration |
250
- |------|-------|--------|----------|
251
- | 05-01 | agent-abc | Running... | 2m |
252
- | 05-02 | agent-def | Complete | 5m |
253
- ```
254
-
255
- 5. **After all agents in wave complete, collect results:**
256
- - Check for `<!-- maxsim:type=summary -->` comments on the phase issue for each plan
257
- - Run spot-checks (same as standard path: summary comment exists, commits present, sub-issues closed, review cycle check)
258
- - Orchestrator performs batch metadata updates:
259
- ```bash
260
- for PLAN_ID in $COMPLETED_PLANS; do
261
- node ~/.claude/maxsim/bin/maxsim-tools.cjs state advance-plan
262
- node ~/.claude/maxsim/bin/maxsim-tools.cjs state update-progress
263
- done
264
- node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap update-plan-progress "${PHASE_NUMBER}"
265
- ```
266
- - Report:
267
- ```
268
- ---
269
- ## Wave {N} Complete (Batch)
270
-
271
- **{Plan ID}: {Plan Name}**
272
- {What was built — from summary comment}
273
- {Notable deviations, if any}
274
-
275
- {If more waves: what this enables for next wave}
276
- ---
277
- ```
278
-
279
- 6. **Cleanup worktrees after wave completes:**
280
- ```bash
281
- node ~/.claude/maxsim/bin/maxsim-tools.cjs worktree-cleanup --all
282
- ```
283
-
284
- 7. **Prepare inter-wave handoff context (for waves after Wave 1):**
285
-
286
- When spawning agents for the next wave, include a brief context block so they can reference prior wave outputs without fetching full summary comments:
287
-
288
- ```
289
- <prior_wave_results>
290
- Wave {N-1} completed:
291
- {For each plan in prior wave: plan ID, one-liner from summary comment, key files created/modified}
292
- </prior_wave_results>
293
- ```
294
-
295
- Add this block to the `<objective>` section of the next wave's Task() prompts.
296
-
297
- 8. **Proceed to next wave.**
298
-
299
- **STANDARD PATH (when EXECUTION_MODE == "standard"):**
300
-
301
- **For each wave:**
302
-
303
- 1. **Describe what's being built (BEFORE spawning):**
304
-
305
- Read each plan's `<objective>` from the plan comment content. Extract what's being built and why.
306
-
307
- ```
308
- ---
309
- ## Wave {N}
310
-
311
- **{Plan ID}: {Plan Name}**
312
- {2-3 sentences: what this builds, technical approach, why it matters}
313
-
314
- Spawning {count} agent(s)...
315
- ---
316
- ```
317
-
318
- - Bad: "Executing terrain generation plan"
319
- - Good: "Procedural terrain generator using Perlin noise — creates height maps, biome zones, and collision meshes. Required before vehicle physics can interact with ground."
320
-
321
- 2. **Spawn executor agents:**
322
-
323
- Pass plan content from GitHub and GitHub context — executors do NOT need to read local PLAN.md files.
324
- This keeps orchestrator context lean (~10-15%).
325
-
326
- When the wave has multiple plans (parallel execution), add `team_name` to group agents:
327
-
328
- ```
329
- Task(
330
- subagent_type="executor",
331
- model="{executor_model}",
332
- team_name="maxsim-phase-{PHASE_NUMBER}-wave-{WAVE_NUM}", // only for multi-plan waves
333
- prompt="
334
- <objective>
335
- Execute plan {plan_number} of phase {phase_number}-{phase_name}.
336
- Commit each task atomically. Post SUMMARY as GitHub comment. Update STATE.md and ROADMAP.md.
337
- Move task sub-issues on the board: In Progress when started, Done when completed.
338
- </objective>
339
-
340
- <execution_context>
341
- @./workflows/execute-plan.md
342
- @./templates/summary.md
343
- @./references/checkpoints.md
344
- @./references/tdd.md
345
- </execution_context>
346
-
347
- <github_context>
348
- Phase issue number: {phase_issue_number}
349
- Plan comment body: {plan_comment_body}
350
- Task mappings: {task_mappings_for_this_plan}
351
- </github_context>
352
-
353
- <files_to_read>
354
- Read these files at execution start using the Read tool:
355
- - .planning/STATE.md (State)
356
- - .planning/config.json (Config, if exists)
357
- - ./CLAUDE.md (Project instructions, if exists — follow project-specific guidelines and coding conventions)
358
- - .skills/ (Project skills, if exists — list skills, read SKILL.md for each, follow relevant rules during implementation)
359
- </files_to_read>
360
-
361
- <success_criteria>
362
- - [ ] All tasks executed
363
- - [ ] Each task committed individually
364
- - [ ] Summary posted as GitHub comment (type=summary) on phase issue #{phase_issue_number}
365
- - [ ] Task sub-issues moved: In Progress when started, Done when completed
366
- - [ ] STATE.md updated with position and decisions
367
- - [ ] ROADMAP.md updated with plan progress (via `roadmap update-plan-progress`)
368
- </success_criteria>
369
- "
370
- )
371
- ```
372
-
373
- 3. **Wait for all agents in wave to complete.**
374
-
375
- 4. **Report completion — spot-check claims and review cycle:**
376
-
377
- For each completed plan:
378
- - Fetch the phase issue comments and verify a `<!-- maxsim:type=summary -->` comment exists for this plan
379
- - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
380
- - Verify all task sub-issues for this plan are closed:
381
- ```
382
- mcp_list_sub_issues(issue_number: phase_issue_number)
383
- ```
384
- - Check for `## Self-Check: FAILED` in the summary comment body
385
- - **Check for `## Review Cycle` section** in the summary comment — verify both review stages (Spec and Code) show PASS or SKIPPED (not BLOCKED or FAIL)
386
-
387
- If ANY spot-check fails: report which plan failed, route to failure handler — ask "Retry plan?" or "Continue with remaining waves?"
388
-
389
- If review cycle is missing or has unresolved issues: flag the plan as **review-incomplete** — ask "Run review cycle for this plan?" or "Continue (review will block phase completion)?"
390
-
391
- **Note:** The executor agent runs the two-stage review (Spec Review + Code Review) after each wave. The orchestrator does NOT run reviews itself — it only checks the executor's review results in the summary comment. If review is missing, the executor failed to run it, and the orchestrator should offer to re-run the affected plan.
392
-
393
- Review stages to check: `Spec:` and `Code:` lines in `## Review Cycle`. Both must be PASS or SKIPPED for the plan to be considered review-complete.
394
-
395
- If pass — report:
396
- ```
397
- ---
398
- ## Wave {N} Complete
399
-
400
- **{Plan ID}: {Plan Name}**
401
- {What was built — from summary comment}
402
- {Notable deviations, if any}
403
-
404
- {If more waves: what this enables for next wave}
405
- ---
406
- ```
407
-
408
- - Bad: "Wave 2 complete. Proceeding to Wave 3."
409
- - Good: "Terrain system complete — 3 biome types, height-based texturing, physics collision meshes. Vehicle physics (Wave 3) can now reference ground surfaces."
410
-
411
- 5. **Handle failures:**
412
-
413
- **Known Claude Code bug (classifyHandoffIfNeeded):** If an agent reports "failed" with error containing `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a MAXSIM or agent issue. The error fires in the completion handler AFTER all tool calls finish. In this case: run the same spot-checks as step 4 (summary comment exists, git commits present, sub-issues closed, no Self-Check: FAILED). If spot-checks PASS → treat as **successful**. If spot-checks FAIL → treat as real failure below.
414
-
415
- For real failures: report which plan failed → ask "Continue?" or "Stop?" → if continue, dependent plans may also fail. If stop, partial completion report.
416
-
417
- 6. **Execute checkpoint plans between waves** — see `<checkpoint_handling>`.
418
-
419
- 7. **Prepare inter-wave handoff context (for waves after Wave 1):**
420
-
421
- When spawning agents for the next wave, include a brief context block so they can reference prior wave outputs without fetching full summary comments:
422
-
423
- ```
424
- <prior_wave_results>
425
- Wave {N-1} completed:
426
- {For each plan in prior wave: plan ID, one-liner from summary comment, key files created/modified}
427
- </prior_wave_results>
428
- ```
429
-
430
- Add this block to the `<objective>` section of the next wave's Task() prompts.
431
-
432
- 8. **Proceed to next wave.**
433
- </step>
434
-
435
- <step name="checkpoint_handling">
436
- Plans with `autonomous: false` require user interaction.
437
-
438
- **Auto-mode checkpoint handling:**
439
-
440
- Read auto-advance config:
441
- ```bash
442
- AUTO_CFG=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs config-get workflow.auto_advance 2>/dev/null || echo "false")
443
- ```
444
-
445
- When executor returns a checkpoint AND `AUTO_CFG` is `"true"`:
446
- - **human-verify** → Auto-spawn continuation agent with `{user_response}` = `"approved"`. Log `⚡ Auto-approved checkpoint`.
447
- - **decision** → Auto-spawn continuation agent with `{user_response}` = first option from checkpoint details. Log `⚡ Auto-selected: [option]`.
448
- - **human-action** → Present to user (existing behavior below). Auth gates cannot be automated.
449
-
450
- **Standard flow (not auto-mode, or human-action type):**
451
-
452
- 1. Spawn agent for checkpoint plan
453
- 2. Agent runs until checkpoint task or auth gate → returns structured state
454
- 3. Agent return includes: completed tasks table, current task + blocker, checkpoint type/details, what's awaited
455
- 4. **Present to user:**
456
- ```
457
- ## Checkpoint: [Type]
458
-
459
- **Plan:** 03-03 Dashboard Layout
460
- **Progress:** 2/3 tasks complete
461
-
462
- [Checkpoint Details from agent return]
463
- [Awaiting section from agent return]
464
- ```
465
- 5. User responds: "approved"/"done" | issue description | decision selection
466
- 6. **Spawn continuation agent (NOT resume)** using continuation-prompt.md template:
467
- - `{completed_tasks_table}`: From checkpoint return
468
- - `{resume_task_number}` + `{resume_task_name}`: Current task
469
- - `{user_response}`: What user provided
470
- - `{resume_instructions}`: Based on checkpoint type
471
- - `{github_context}`: Pass phase_issue_number and task_mappings for board transitions
472
- 7. Continuation agent verifies previous commits, continues from resume point
473
- 8. Repeat until plan completes or user stops
474
-
475
- **Why fresh agent, not resume:** Resume relies on internal serialization that breaks with parallel tool calls. Fresh agents with explicit state are more reliable.
476
-
477
- **Checkpoints in parallel waves:** Agent pauses and returns while other parallel agents may complete. Present checkpoint, spawn continuation, wait for all before next wave.
478
- </step>
479
-
480
- <step name="aggregate_results">
481
- After all waves:
482
-
483
- ```markdown
484
- ## Phase {X}: {Name} Execution Complete
485
-
486
- **Execution Mode:** {Batch (worktree) | Standard}
487
- **Worktrees Used:** {N} (batch only — omit for standard mode)
488
- **Waves:** {N} | **Plans:** {M}/{total} complete
489
-
490
- | Wave | Plans | Status |
491
- |------|-------|--------|
492
- | 1 | plan-01, plan-02 | ✓ Complete |
493
- | CP | plan-03 | ✓ Verified |
494
- | 2 | plan-04 | ✓ Complete |
495
-
496
- ### Plan Details
497
- 1. **03-01**: [one-liner from summary comment]
498
- 2. **03-02**: [one-liner from summary comment]
499
-
500
- ### Review Cycle Summary
501
- | Plan | Spec Review | Code Review | Retries |
502
- |------|-------------|-------------|---------|
503
- | 03-01 | PASS | PASS | 0 |
504
- | 03-02 | PASS | PASS | 1 |
505
-
506
- [Aggregate review findings from each plan's summary comment `## Review Cycle` section.
507
- If any plan has no Review Cycle section in its summary comment: mark as "NOT RUN" and flag for attention.
508
- If any plan has unresolved BLOCKED/FAIL status: list the blocking issues below.]
509
-
510
- ### Unresolved Review Issues
511
- [List any plans with BLOCKED or FAIL review stages. These MUST be resolved before phase completion.]
512
-
513
- ### Issues Encountered
514
- [Aggregate from summary comments, or "None"]
515
- ```
516
-
517
- **Move phase issue to "In Review" on GitHub (WIRE-08):**
518
- All tasks are complete — move the phase to "In Review" before running verification:
519
- ```
520
- mcp_move_issue(issue_number: phase_issue_number, status: "In Review")
521
- ```
522
-
523
- **Phase completion gate:** If any plan has unresolved review issues (BLOCKED or FAIL in Spec Review or Code Review stages), the phase CANNOT proceed to `verify_phase_goal`. Present unresolved issues and offer:
524
- - "Fix review issues now" — re-run the review cycle for affected plans
525
- - "Override and continue" — mark as acknowledged, proceed (adds warning to VERIFICATION.md)
526
- </step>
527
-
528
- <step name="close_parent_artifacts">
529
- **For decimal/polish phases only (X.Y pattern):** Close the feedback loop by resolving parent UAT and debug artifacts.
530
-
531
- **Skip if** phase number has no decimal (e.g., `3`, `04`) — only applies to gap-closure phases like `4.1`, `03.1`.
532
-
533
- **1. Detect decimal phase and derive parent:**
534
- ```bash
535
- # Check if phase_number contains a decimal
536
- if [[ "$PHASE_NUMBER" == *.* ]]; then
537
- PARENT_PHASE="${PHASE_NUMBER%%.*}"
538
- fi
539
- ```
540
-
541
- **2. Find parent UAT:**
542
-
543
- When GitHub integration is active, look for `<!-- maxsim:type=uat -->` comments on the parent phase issue:
544
- ```
545
- mcp_get_issue_detail(issue_number: parent_phase_issue_number)
546
- ```
547
-
548
- **If no parent UAT found:** Skip this step (gap-closure may have been triggered by VERIFICATION.md instead).
549
-
550
- **3. Update UAT gap statuses:**
551
-
552
- Read the parent UAT content (from comment or local file). For each gap entry with `status: failed`:
553
- - Update to `status: resolved`
554
-
555
- **4. If all gaps resolved — update UAT status:**
556
-
557
- - If posting to GitHub: update the UAT comment body with resolved statuses
558
- - If local file: update frontmatter `status: diagnosed` → `status: resolved`, update `updated:` timestamp
559
-
560
- **5. Resolve referenced debug sessions:**
561
-
562
- For each gap that has a `debug_session:` field:
563
- - Read the debug session file
564
- - Update frontmatter `status:` → `resolved`
565
- - Update frontmatter `updated:` timestamp
566
- - Move to resolved directory:
567
- ```bash
568
- mkdir -p .planning/debug/resolved
569
- mv .planning/debug/{slug}.md .planning/debug/resolved/
570
- ```
571
-
572
- **6. Commit updated artifacts:**
573
- ```bash
574
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs(phase-${PARENT_PHASE}): resolve UAT gaps and debug sessions after ${PHASE_NUMBER} gap closure" --files .planning/phases/*${PARENT_PHASE}*/*-UAT.md .planning/debug/resolved/*.md
575
- ```
576
- </step>
577
-
578
- <step name="verify_phase_goal">
579
- Verify phase achieved its GOAL, not just completed tasks.
580
-
581
- ```
582
- Task(
583
- prompt="Verify phase {phase_number} goal achievement.
584
- Phase directory: {phase_dir}
585
- Phase issue: #{phase_issue_number}
586
- Phase goal: {goal from ROADMAP.md}
587
- Phase requirement IDs: {phase_req_ids}
588
- Check must_haves against actual codebase.
589
- Cross-reference requirement IDs from plan frontmatter against REQUIREMENTS.md — every ID MUST be accounted for.
590
- Post verification results as a GitHub comment (mcp_post_comment with type=verification) on phase issue #{phase_issue_number}.
591
- Also write VERIFICATION.md to the phase directory for local reference.",
592
- subagent_type="verifier",
593
- model="{verifier_model}"
594
- )
595
- ```
596
-
597
- Read status from the verification comment posted to GitHub:
598
- ```
599
- mcp_get_issue_detail(issue_number: phase_issue_number)
600
- ```
601
-
602
- Look for `<!-- maxsim:type=verification -->` comment and parse `status:` field.
603
-
604
- | Status | Action |
605
- |--------|--------|
606
- | `passed` | → update_roadmap |
607
- | `human_needed` | Present items for human testing, get approval or feedback |
608
- | `gaps_found` | Present gap summary, offer `/maxsim:plan {phase} --gaps` |
609
-
610
- **If human_needed:**
611
- ```
612
- ## Phase {X}: {Name} — Human Verification Required
613
-
614
- All automated checks passed. {N} items need human testing:
615
-
616
- {From verification comment human_verification section}
617
-
618
- "approved" → continue | Report issues → gap closure
619
- ```
620
-
621
- **If gaps_found:**
622
- ```
623
- ## Phase {X}: {Name} — Gaps Found
624
-
625
- **Score:** {N}/{M} must-haves verified
626
- **Report:** Phase issue #{phase_issue_number} (verification comment)
627
-
628
- ### What's Missing
629
- {Gap summaries from verification comment}
630
-
631
- ---
632
- ## Next Up
633
-
634
- `/maxsim:plan {X} --gaps`
635
-
636
- <sub>`/clear` first → fresh context window</sub>
637
-
638
- Also: view the verification comment on issue #{phase_issue_number} for the full report
639
- Also: `/maxsim:execute {X}` (includes verification) — manual testing first
640
- ```
641
-
642
- Gap closure cycle: `/maxsim:plan {X} --gaps` reads verification comment → creates gap plans as new comments on phase issue (with `gap_closure: true` frontmatter) → user runs `/maxsim:execute {X} --gaps-only` → verifier re-runs.
643
- </step>
644
-
645
- <step name="update_roadmap">
646
- **Mark phase complete and update all tracking files:**
647
-
648
- ```bash
649
- COMPLETION=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs phase complete "${PHASE_NUMBER}")
650
- ```
651
-
652
- The CLI handles:
653
- - Marking phase checkbox `[x]` with completion date
654
- - Updating Progress table (Status → Complete, date)
655
- - Updating plan count to final
656
- - Advancing STATE.md to next phase
657
- - Updating REQUIREMENTS.md traceability
658
-
659
- Extract from result: `next_phase`, `next_phase_name`, `is_last_phase`.
660
-
661
- ```bash
662
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs(phase-{X}): complete phase execution" --files .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md {phase_dir}/*-VERIFICATION.md
663
- ```
664
-
665
- **Move phase issue to Done on GitHub:**
666
- ```
667
- mcp_move_issue(issue_number: phase_issue_number, status: "Done")
668
- ```
669
-
670
- **Post phase completion summary comment on the phase issue:**
671
- ```
672
- mcp_post_comment(
673
- issue_number: phase_issue_number,
674
- type: "phase-complete",
675
- body: "## Phase {phase_number} Execution Complete\n\nAll plans executed and verified.\n\n**Execution Mode:** {Batch | Standard}\n**Waves:** {wave_count}\n**Plans:** {completed}/{total}\n**Verification:** Passed\n\n### Plan Summary\n{one-liner per plan from summary comments}"
676
- )
677
- ```
678
-
679
- </step>
680
-
681
- <step name="offer_next">
682
-
683
- **Exception:** If `gaps_found`, the `verify_phase_goal` step already presents the gap-closure path (`/maxsim:plan {X} --gaps`). No additional routing needed — skip auto-advance.
684
-
685
- **No-transition check (spawned by auto-advance chain):**
686
-
687
- Parse `--no-transition` flag from $ARGUMENTS.
688
-
689
- **If `--no-transition` flag present:**
690
-
691
- Execute-phase was spawned by plan's auto-advance. After verification passes and roadmap is updated, return completion status to parent:
692
-
693
- ```
694
- ## PHASE COMPLETE
695
-
696
- Phase: ${PHASE_NUMBER} - ${PHASE_NAME}
697
- Plans: ${completed_count}/${total_count}
698
- Verification: {Passed | Gaps Found}
699
- GitHub: Phase issue #{phase_issue_number} moved to Done
700
-
701
- [Include aggregate_results output]
702
- ```
703
-
704
- STOP. Do not proceed to auto-advance or transition.
705
-
706
- **If `--no-transition` flag is NOT present:**
707
-
708
- **Auto-advance detection:**
709
-
710
- 1. Parse `--auto` flag from $ARGUMENTS
711
- 2. Read `workflow.auto_advance` from config:
712
- ```bash
713
- AUTO_CFG=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs config-get workflow.auto_advance 2>/dev/null || echo "false")
714
- ```
715
-
716
- **If `--auto` flag present OR `AUTO_CFG` is true (AND verification passed with no gaps):**
717
-
718
- ```
719
- ╔══════════════════════════════════════════╗
720
- ║ AUTO-ADVANCING → TRANSITION ║
721
- ║ Phase {X} verified, continuing chain ║
722
- ╚══════════════════════════════════════════╝
723
- ```
724
-
725
- Phase advancement is complete. The user may run `/maxsim:go` or `/maxsim:execute` to continue to the next phase.
726
-
727
- **If neither `--auto` nor `AUTO_CFG` is true:**
728
-
729
- The workflow ends. The user runs `/maxsim:go` or `/maxsim:execute` to advance to the next phase.
730
- </step>
731
-
732
- </process>
733
-
734
- <context_efficiency>
735
- Orchestrator: ~10-15% context. Subagents: fresh 200k each. No polling (Task blocks). No context bleed.
736
- Plan content passed directly from GitHub comments to subagents — no local PLAN.md reads in the orchestrator.
737
- </context_efficiency>
738
-
739
- <failure_handling>
740
- - **classifyHandoffIfNeeded false failure:** Agent reports "failed" but error is `classifyHandoffIfNeeded is not defined` → Claude Code bug, not MAXSIM. Spot-check (summary comment exists, commits present, sub-issues closed) → if pass, treat as success
741
- - **Agent fails mid-plan:** Missing summary comment on GitHub → report, ask user how to proceed
742
- - **Dependency chain breaks:** Wave 1 fails → Wave 2 dependents likely fail → user chooses attempt or skip
743
- - **All agents in wave fail:** Systemic issue → stop, report for investigation
744
- - **Checkpoint unresolvable:** "Skip this plan?" or "Abort phase execution?" → record partial progress in STATE.md
745
- - **GitHub integration unavailable:** Report error — GitHub Issues is the source of truth for plans and summaries
746
- </failure_handling>
747
-
748
- <resumption>
749
- Re-run `/maxsim:execute {phase}` → discover_and_group_plans fetches the phase issue comments and checks sub-issue closure → skips plans with all sub-issues closed → resumes from first incomplete plan → continues wave execution.
750
-
751
- STATE.md tracks: last completed plan, current wave, pending checkpoints.
752
- </resumption>