maxsimcli 4.15.4 → 5.0.0

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