maxsimcli 4.7.1 → 4.9.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 (161) hide show
  1. package/dist/assets/CHANGELOG.md +20 -0
  2. package/dist/assets/hooks/maxsim-check-update.cjs +38 -0
  3. package/dist/assets/hooks/maxsim-check-update.cjs.map +1 -1
  4. package/dist/assets/hooks/maxsim-statusline.cjs +116 -48
  5. package/dist/assets/hooks/maxsim-statusline.cjs.map +1 -1
  6. package/dist/assets/hooks/maxsim-sync-reminder.cjs +117 -0
  7. package/dist/assets/hooks/maxsim-sync-reminder.cjs.map +1 -0
  8. package/dist/assets/templates/agents/AGENTS.md +78 -106
  9. package/dist/assets/templates/agents/executor.md +101 -0
  10. package/dist/assets/templates/agents/planner.md +86 -0
  11. package/dist/assets/templates/agents/researcher.md +71 -0
  12. package/dist/assets/templates/agents/verifier.md +88 -0
  13. package/dist/assets/templates/commands/maxsim/debug.md +7 -7
  14. package/dist/assets/templates/commands/maxsim/execute.md +45 -0
  15. package/dist/assets/templates/commands/maxsim/go.md +29 -0
  16. package/dist/assets/templates/commands/maxsim/help.md +2 -2
  17. package/dist/assets/templates/commands/maxsim/init.md +52 -0
  18. package/dist/assets/templates/commands/maxsim/plan.md +50 -0
  19. package/dist/assets/templates/commands/maxsim/progress.md +4 -3
  20. package/dist/assets/templates/commands/maxsim/quick.md +6 -4
  21. package/dist/assets/templates/commands/maxsim/settings.md +4 -3
  22. package/dist/assets/templates/references/continuation-format.md +16 -16
  23. package/dist/assets/templates/references/model-profile-resolution.md +1 -1
  24. package/dist/assets/templates/references/model-profiles.md +12 -19
  25. package/dist/assets/templates/rules/conventions.md +51 -0
  26. package/dist/assets/templates/rules/verification-protocol.md +57 -0
  27. package/dist/assets/templates/skills/agent-system-map/SKILL.md +92 -0
  28. package/dist/assets/templates/skills/brainstorming/SKILL.md +48 -36
  29. package/dist/assets/templates/skills/code-review/SKILL.md +40 -61
  30. package/dist/assets/templates/skills/commit-conventions/SKILL.md +75 -0
  31. package/dist/assets/templates/skills/evidence-collection/SKILL.md +87 -0
  32. package/dist/assets/templates/skills/handoff-contract/SKILL.md +70 -0
  33. package/dist/assets/templates/skills/input-validation/SKILL.md +51 -0
  34. package/dist/assets/templates/skills/maxsim-batch/SKILL.md +41 -45
  35. package/dist/assets/templates/skills/maxsim-simplify/SKILL.md +37 -90
  36. package/dist/assets/templates/skills/memory-management/SKILL.md +32 -67
  37. package/dist/assets/templates/skills/research-methodology/SKILL.md +137 -0
  38. package/dist/assets/templates/skills/roadmap-writing/SKILL.md +40 -58
  39. package/dist/assets/templates/skills/sdd/SKILL.md +34 -69
  40. package/dist/assets/templates/skills/systematic-debugging/SKILL.md +20 -26
  41. package/dist/assets/templates/skills/tdd/SKILL.md +25 -33
  42. package/dist/assets/templates/skills/tool-priority-guide/SKILL.md +80 -0
  43. package/dist/assets/templates/skills/using-maxsim/SKILL.md +42 -73
  44. package/dist/assets/templates/skills/verification-before-completion/SKILL.md +12 -24
  45. package/dist/assets/templates/skills/verification-gates/SKILL.md +169 -0
  46. package/dist/assets/templates/templates/UAT.md +3 -3
  47. package/dist/assets/templates/templates/VALIDATION.md +1 -1
  48. package/dist/assets/templates/templates/context.md +4 -4
  49. package/dist/assets/templates/templates/debug-subagent-prompt.md +3 -3
  50. package/dist/assets/templates/templates/discovery.md +2 -2
  51. package/dist/assets/templates/templates/phase-prompt.md +2 -2
  52. package/dist/assets/templates/templates/planner-subagent-prompt.md +7 -7
  53. package/dist/assets/templates/templates/project.md +1 -1
  54. package/dist/assets/templates/templates/research.md +1 -1
  55. package/dist/assets/templates/templates/state.md +2 -2
  56. package/dist/assets/templates/templates/summary.md +41 -0
  57. package/dist/assets/templates/workflows/batch.md +5 -5
  58. package/dist/assets/templates/workflows/diagnose-issues.md +2 -2
  59. package/dist/assets/templates/workflows/discovery-phase.md +3 -3
  60. package/dist/assets/templates/workflows/discuss-phase.md +11 -11
  61. package/dist/assets/templates/workflows/execute-phase.md +205 -11
  62. package/dist/assets/templates/workflows/execute-plan.md +299 -34
  63. package/dist/assets/templates/workflows/execute.md +421 -0
  64. package/dist/assets/templates/workflows/go.md +250 -0
  65. package/dist/assets/templates/workflows/health.md +5 -5
  66. package/dist/assets/templates/workflows/help.md +165 -435
  67. package/dist/assets/templates/workflows/init-existing.md +23 -23
  68. package/dist/assets/templates/workflows/init.md +205 -0
  69. package/dist/assets/templates/workflows/new-milestone.md +9 -9
  70. package/dist/assets/templates/workflows/new-project.md +26 -26
  71. package/dist/assets/templates/workflows/plan-create.md +298 -0
  72. package/dist/assets/templates/workflows/plan-discuss.md +347 -0
  73. package/dist/assets/templates/workflows/plan-phase.md +29 -29
  74. package/dist/assets/templates/workflows/plan-research.md +177 -0
  75. package/dist/assets/templates/workflows/plan.md +231 -0
  76. package/dist/assets/templates/workflows/progress.md +46 -42
  77. package/dist/assets/templates/workflows/quick.md +195 -14
  78. package/dist/assets/templates/workflows/research-phase.md +5 -5
  79. package/dist/assets/templates/workflows/sdd.md +20 -12
  80. package/dist/assets/templates/workflows/settings.md +18 -14
  81. package/dist/assets/templates/workflows/verify-phase.md +1 -1
  82. package/dist/assets/templates/workflows/verify-work.md +16 -16
  83. package/dist/cli.cjs +496 -91
  84. package/dist/cli.cjs.map +1 -1
  85. package/dist/core-D5zUr9cb.cjs.map +1 -1
  86. package/dist/install.cjs +274 -355
  87. package/dist/install.cjs.map +1 -1
  88. package/dist/mcp-server.cjs +5213 -2248
  89. package/dist/mcp-server.cjs.map +1 -1
  90. package/dist/skills-CjFWZIGM.cjs.map +1 -1
  91. package/package.json +4 -1
  92. package/dist/assets/hooks/maxsim-context-monitor.cjs +0 -121
  93. package/dist/assets/hooks/maxsim-context-monitor.cjs.map +0 -1
  94. package/dist/assets/templates/agents/maxsim-code-reviewer.md +0 -239
  95. package/dist/assets/templates/agents/maxsim-codebase-mapper.md +0 -214
  96. package/dist/assets/templates/agents/maxsim-debugger.md +0 -572
  97. package/dist/assets/templates/agents/maxsim-drift-checker.md +0 -522
  98. package/dist/assets/templates/agents/maxsim-executor.md +0 -504
  99. package/dist/assets/templates/agents/maxsim-integration-checker.md +0 -273
  100. package/dist/assets/templates/agents/maxsim-phase-researcher.md +0 -305
  101. package/dist/assets/templates/agents/maxsim-plan-checker.md +0 -343
  102. package/dist/assets/templates/agents/maxsim-planner.md +0 -610
  103. package/dist/assets/templates/agents/maxsim-project-researcher.md +0 -359
  104. package/dist/assets/templates/agents/maxsim-research-synthesizer.md +0 -263
  105. package/dist/assets/templates/agents/maxsim-roadmapper.md +0 -324
  106. package/dist/assets/templates/agents/maxsim-spec-reviewer.md +0 -245
  107. package/dist/assets/templates/agents/maxsim-verifier.md +0 -393
  108. package/dist/assets/templates/commands/maxsim/add-phase.md +0 -43
  109. package/dist/assets/templates/commands/maxsim/add-tests.md +0 -41
  110. package/dist/assets/templates/commands/maxsim/add-todo.md +0 -57
  111. package/dist/assets/templates/commands/maxsim/artefakte.md +0 -122
  112. package/dist/assets/templates/commands/maxsim/audit-milestone.md +0 -36
  113. package/dist/assets/templates/commands/maxsim/batch.md +0 -42
  114. package/dist/assets/templates/commands/maxsim/check-drift.md +0 -56
  115. package/dist/assets/templates/commands/maxsim/check-todos.md +0 -46
  116. package/dist/assets/templates/commands/maxsim/cleanup.md +0 -18
  117. package/dist/assets/templates/commands/maxsim/complete-milestone.md +0 -136
  118. package/dist/assets/templates/commands/maxsim/discuss-phase.md +0 -87
  119. package/dist/assets/templates/commands/maxsim/discuss.md +0 -70
  120. package/dist/assets/templates/commands/maxsim/execute-phase.md +0 -41
  121. package/dist/assets/templates/commands/maxsim/health.md +0 -22
  122. package/dist/assets/templates/commands/maxsim/init-existing.md +0 -46
  123. package/dist/assets/templates/commands/maxsim/insert-phase.md +0 -32
  124. package/dist/assets/templates/commands/maxsim/list-phase-assumptions.md +0 -46
  125. package/dist/assets/templates/commands/maxsim/map-codebase.md +0 -71
  126. package/dist/assets/templates/commands/maxsim/new-milestone.md +0 -44
  127. package/dist/assets/templates/commands/maxsim/new-project.md +0 -46
  128. package/dist/assets/templates/commands/maxsim/pause-work.md +0 -38
  129. package/dist/assets/templates/commands/maxsim/plan-milestone-gaps.md +0 -34
  130. package/dist/assets/templates/commands/maxsim/plan-phase.md +0 -44
  131. package/dist/assets/templates/commands/maxsim/realign.md +0 -39
  132. package/dist/assets/templates/commands/maxsim/reapply-patches.md +0 -110
  133. package/dist/assets/templates/commands/maxsim/remove-phase.md +0 -31
  134. package/dist/assets/templates/commands/maxsim/research-phase.md +0 -189
  135. package/dist/assets/templates/commands/maxsim/resume-work.md +0 -40
  136. package/dist/assets/templates/commands/maxsim/roadmap.md +0 -19
  137. package/dist/assets/templates/commands/maxsim/sdd.md +0 -39
  138. package/dist/assets/templates/commands/maxsim/set-profile.md +0 -34
  139. package/dist/assets/templates/commands/maxsim/update.md +0 -37
  140. package/dist/assets/templates/commands/maxsim/verify-work.md +0 -38
  141. package/dist/assets/templates/workflows/add-phase.md +0 -111
  142. package/dist/assets/templates/workflows/add-tests.md +0 -351
  143. package/dist/assets/templates/workflows/add-todo.md +0 -247
  144. package/dist/assets/templates/workflows/audit-milestone.md +0 -297
  145. package/dist/assets/templates/workflows/check-drift.md +0 -248
  146. package/dist/assets/templates/workflows/check-todos.md +0 -261
  147. package/dist/assets/templates/workflows/cleanup.md +0 -153
  148. package/dist/assets/templates/workflows/complete-milestone.md +0 -701
  149. package/dist/assets/templates/workflows/discuss.md +0 -343
  150. package/dist/assets/templates/workflows/insert-phase.md +0 -129
  151. package/dist/assets/templates/workflows/list-phase-assumptions.md +0 -178
  152. package/dist/assets/templates/workflows/map-codebase.md +0 -315
  153. package/dist/assets/templates/workflows/pause-work.md +0 -122
  154. package/dist/assets/templates/workflows/plan-milestone-gaps.md +0 -274
  155. package/dist/assets/templates/workflows/realign.md +0 -288
  156. package/dist/assets/templates/workflows/remove-phase.md +0 -154
  157. package/dist/assets/templates/workflows/resume-project.md +0 -306
  158. package/dist/assets/templates/workflows/roadmap.md +0 -130
  159. package/dist/assets/templates/workflows/set-profile.md +0 -81
  160. package/dist/assets/templates/workflows/transition.md +0 -544
  161. package/dist/assets/templates/workflows/update.md +0 -220
@@ -0,0 +1,421 @@
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
+ Thin orchestrator for the /maxsim:execute state machine. Detects the current state of a phase (already done, needs verification, needs execution), delegates per-plan execution to execute-plan.md subagents, runs auto-verification, and handles retry with gap closure.
9
+
10
+ This file is the ORCHESTRATOR ONLY. Per-plan execution logic lives in:
11
+ - @./workflows/execute-plan.md (per-plan subagent execution)
12
+
13
+ Verification is handled inline (spawning verifier agent) since it is a stage of this workflow, not a separate command.
14
+ </purpose>
15
+
16
+ <process>
17
+
18
+ ## 1. Initialize
19
+
20
+ Load phase state in one call:
21
+
22
+ ```bash
23
+ INIT=$(node .claude/maxsim/bin/maxsim-tools.cjs init execute-phase "$PHASE")
24
+ ```
25
+
26
+ Parse `$ARGUMENTS` for: phase number (required), `--worktrees` (force worktree mode), `--no-worktrees` (force standard mode), `--auto` (auto-advance), `--gaps-only` (gap plans only).
27
+
28
+ Parse JSON for: `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `plans`, `incomplete_plans`, `plan_count`, `incomplete_count`, `has_verification`, `commit_docs`, `executor_model`, `verifier_model`, `parallelization`, `state_path`, `roadmap_path`, `requirements_path`, `phase_req_ids`.
29
+
30
+ All flags from `$ARGUMENTS` are passed through to the execute-phase workflow steps so they are available for execution mode decision and auto-advance detection.
31
+
32
+ **If `phase_found` is false:**
33
+ ```
34
+ Phase [X] not found in roadmap.
35
+
36
+ Use /maxsim:progress to see available phases.
37
+ ```
38
+ Exit workflow.
39
+
40
+ **If `plan_count` is 0:**
41
+ ```
42
+ No plans found for Phase {phase_number}.
43
+
44
+ Run /maxsim:plan {phase_number} first to create execution plans.
45
+ ```
46
+ Exit workflow.
47
+
48
+ ## 2. Detect State
49
+
50
+ Determine where to start based on phase artifacts:
51
+
52
+ | Condition | State | Action |
53
+ |-----------|-------|--------|
54
+ | `incomplete_count == 0` AND `has_verification == true` | Already done | Go to **Re-entry flow** (step 3) |
55
+ | `incomplete_count == 0` AND `has_verification == false` | Needs verification | Start at **Auto-Verify** (step 5) |
56
+ | `incomplete_count > 0` | Needs execution | Start at **Execute Plans** (step 4) |
57
+
58
+ Display detected state:
59
+ ```
60
+ Phase {phase_number}: {phase_name}
61
+ Current state: {Already executed | Needs verification | Ready to execute}
62
+ Plans: {plan_count} total, {incomplete_count} incomplete
63
+ ```
64
+
65
+ ## 3. Re-entry Flow (Already Executed and Verified)
66
+
67
+ When all plans are complete and verification has passed, show status and offer options.
68
+
69
+ Display:
70
+ ```
71
+ ## Phase {phase_number} Already Executed
72
+
73
+ **Plans:** {plan_count} plan(s) -- all complete
74
+ **Verification:** Passed
75
+ **Phase directory:** {phase_dir}
76
+
77
+ **Options:**
78
+ 1. View results -- show SUMMARY.md files and verification report
79
+ 2. Re-execute from scratch -- delete SUMMARYs, restart execution
80
+ 3. View verification -- show VERIFICATION.md
81
+ 4. Done (exit)
82
+ ```
83
+
84
+ Wait for user choice via natural conversation.
85
+
86
+ - **View results:** Display contents of each SUMMARY.md file, then re-show options.
87
+ - **Re-execute:** Delete existing SUMMARY.md files, restart from Execute Plans (step 4).
88
+ - **View verification:** Display VERIFICATION.md contents, then re-show options.
89
+ - **Done:** Exit workflow.
90
+
91
+ ## 4. Execute Plans
92
+
93
+ Execute all plans in wave order, delegating each plan to a subagent via execute-plan.md.
94
+
95
+ ### 4.1 Discover and Group Plans
96
+
97
+ Load plan inventory with wave grouping:
98
+
99
+ ```bash
100
+ PLAN_INDEX=$(node .claude/maxsim/bin/maxsim-tools.cjs phase-plan-index "${PHASE_NUMBER}")
101
+ ```
102
+
103
+ Parse JSON for: `plans[]` (each with `id`, `wave`, `autonomous`, `objective`, `has_summary`), `waves` (map of wave number to plan IDs), `incomplete`.
104
+
105
+ Skip plans where `has_summary: true` (already complete -- supports resume).
106
+
107
+ If all plans already have summaries: skip to Auto-Verify (step 5).
108
+
109
+ Report:
110
+ ```
111
+ ## Execution Plan
112
+
113
+ **Phase {phase_number}: {phase_name}** -- {total_plans} plans across {wave_count} waves
114
+
115
+ | Wave | Plans | What it builds |
116
+ |------|-------|----------------|
117
+ | 1 | 03-01, 03-02 | {from plan objectives, 3-8 words} |
118
+ | 2 | 03-03 | ... |
119
+ ```
120
+
121
+ ### 4.2 Execute Waves
122
+
123
+ Execute each wave in sequence. Within a wave: parallel if `parallelization` is true, sequential if false.
124
+
125
+ **For each wave:**
126
+
127
+ 1. **Describe what is being built (BEFORE spawning):**
128
+
129
+ Read each plan's `<objective>`. Extract what is being built and why.
130
+
131
+ ```
132
+ ---
133
+ ## Wave {N}
134
+
135
+ **{Plan ID}: {Plan Name}**
136
+ {2-3 sentences: what this builds, technical approach, why it matters}
137
+
138
+ Spawning {count} agent(s)...
139
+ ---
140
+ ```
141
+
142
+ 2. **Spawn executor agents:**
143
+
144
+ Pass paths only -- executors read files themselves with their fresh 200k context.
145
+
146
+ ```
147
+ Task(
148
+ subagent_type="executor",
149
+ model="{executor_model}",
150
+ prompt="
151
+ <objective>
152
+ Execute plan {plan_number} of phase {phase_number}-{phase_name}.
153
+ Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
154
+ </objective>
155
+
156
+ <execution_context>
157
+ @./workflows/execute-plan.md
158
+ @./templates/summary.md
159
+ @./references/checkpoints.md
160
+ @./references/tdd.md
161
+ </execution_context>
162
+
163
+ <files_to_read>
164
+ Read these files at execution start using the Read tool:
165
+ - {phase_dir}/{plan_file} (Plan)
166
+ - .planning/STATE.md (State)
167
+ - .planning/config.json (Config, if exists)
168
+ - ./CLAUDE.md (Project instructions, if exists)
169
+ </files_to_read>
170
+
171
+ <success_criteria>
172
+ - [ ] All tasks executed
173
+ - [ ] Each task committed individually
174
+ - [ ] SUMMARY.md created in plan directory
175
+ - [ ] STATE.md updated with position and decisions
176
+ - [ ] ROADMAP.md updated with plan progress
177
+ </success_criteria>
178
+ "
179
+ )
180
+ ```
181
+
182
+ 3. **Wait for all agents in wave to complete.**
183
+
184
+ 4. **Spot-check results:**
185
+
186
+ For each completed plan's SUMMARY.md:
187
+ - Verify first 2 files from key-files exist on disk
188
+ - Check `git log --oneline --all --grep="{phase}-{plan}"` returns at least 1 commit
189
+ - Check for `## Self-Check: FAILED` marker
190
+ - Check for `## Review Cycle` section -- verify both Spec and Code stages show PASS
191
+
192
+ If ANY spot-check fails: report which plan failed, ask "Retry plan?" or "Continue with remaining waves?"
193
+
194
+ 5. **Report wave completion:**
195
+
196
+ ```
197
+ ---
198
+ ## Wave {N} Complete
199
+
200
+ **{Plan ID}: {Plan Name}**
201
+ {What was built -- from SUMMARY.md}
202
+ {Notable deviations, if any}
203
+
204
+ {If more waves: what this enables for next wave}
205
+ ---
206
+ ```
207
+
208
+ 6. **Handle checkpoint plans:** Plans with `autonomous: false` may return checkpoints. Present checkpoint to user, spawn continuation agent after user responds, wait for completion before proceeding.
209
+
210
+ 7. **Proceed to next wave.**
211
+
212
+ ### 4.3 Execution Summary Gate
213
+
214
+ After all waves complete:
215
+
216
+ ```
217
+ ## Gate: Execution Complete
218
+
219
+ **Plans executed:** {completed}/{total}
220
+ **Waves:** {wave_count}
221
+ **Commits:** {list of commit summaries from SUMMARY.md files}
222
+
223
+ Proceeding to verification...
224
+ ```
225
+
226
+ Wait for user confirmation before proceeding to verification.
227
+
228
+ ## 5. Auto-Verify
229
+
230
+ Verify that the phase achieved its GOAL, not just that tasks completed.
231
+
232
+ ### 5.1 Spawn Verifier
233
+
234
+ Resolve verifier model and spawn the verifier agent:
235
+
236
+ ```bash
237
+ VERIFIER_MODEL=$(node .claude/maxsim/bin/maxsim-tools.cjs resolve-model verifier --raw)
238
+ ```
239
+
240
+ ```
241
+ Task(
242
+ prompt="Verify phase {phase_number} goal achievement.
243
+ Phase directory: {phase_dir}
244
+ Phase goal: {goal from ROADMAP.md}
245
+ Phase requirement IDs: {phase_req_ids}
246
+ Check must_haves against actual codebase.
247
+ Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md.
248
+ Create VERIFICATION.md.",
249
+ subagent_type="verifier",
250
+ model="{verifier_model}"
251
+ )
252
+ ```
253
+
254
+ ### 5.2 Parse Verifier Result
255
+
256
+ Read verification status:
257
+ ```bash
258
+ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
259
+ ```
260
+
261
+ **If `passed`:** Show verification gate and proceed to completion.
262
+
263
+ ```
264
+ ## Gate: Verification Passed
265
+
266
+ **Status:** All must-haves verified
267
+ **Evidence:** {summary from VERIFICATION.md}
268
+
269
+ Phase {phase_number} complete!
270
+ ```
271
+
272
+ Mark phase complete:
273
+ ```bash
274
+ COMPLETION=$(node .claude/maxsim/bin/maxsim-tools.cjs phase complete "${PHASE_NUMBER}")
275
+ ```
276
+
277
+ Update tracking files:
278
+ ```bash
279
+ 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
280
+ ```
281
+
282
+ **If `gaps_found`:** Proceed to Retry Loop (step 6).
283
+
284
+ **If `human_needed`:** Present items for human testing, get approval or feedback. If approved, treat as passed. If issues reported, proceed to Retry Loop.
285
+
286
+ ## 6. Retry Loop (Max 2 Retries)
287
+
288
+ If verification failed, attempt gap closure. Maximum 2 retries (3 total attempts including the initial execution).
289
+
290
+ Initialize: `attempt_count = 1`
291
+
292
+ ### 6.1 Check Attempt Budget
293
+
294
+ If `attempt_count > 2`:
295
+ ```
296
+ ## Verification Failed After 3 Attempts
297
+
298
+ **Status:** Could not resolve all gaps
299
+ **Attempts:** 3 (initial + 2 retries)
300
+
301
+ ### What Failed
302
+ {List of unresolved gaps from VERIFICATION.md with evidence}
303
+
304
+ ### Options
305
+ 1. Fix manually and re-run `/maxsim:execute {phase_number}`
306
+ 2. Run `/maxsim:debug` to investigate failing items
307
+ 3. Accept as-is and continue to next phase
308
+ ```
309
+
310
+ Wait for user decision. Exit workflow.
311
+
312
+ ### 6.2 Plan Gap Closure
313
+
314
+ Display: "Verification failed. Retrying... (attempt {attempt_count + 1}/3)"
315
+
316
+ Spawn planner in gap-closure mode to create fix plans:
317
+
318
+ ```
319
+ Task(
320
+ prompt="
321
+ <planning_context>
322
+ **Phase:** {phase_number}
323
+ **Mode:** gap_closure
324
+
325
+ <files_to_read>
326
+ - {phase_dir}/{phase_num}-VERIFICATION.md (Verification with gaps)
327
+ - .planning/STATE.md (Project State)
328
+ - .planning/ROADMAP.md (Roadmap)
329
+ </files_to_read>
330
+ </planning_context>
331
+
332
+ <downstream_consumer>
333
+ Output consumed by /maxsim:execute.
334
+ Plans must be executable prompts.
335
+ </downstream_consumer>
336
+ ",
337
+ subagent_type="planner",
338
+ model="{planner_model}"
339
+ )
340
+ ```
341
+
342
+ ### 6.3 Execute Gap Plans
343
+
344
+ Execute the newly created gap-closure plans using the same wave execution logic from step 4. Only execute plans with `gap_closure: true` in frontmatter.
345
+
346
+ ### 6.4 Re-verify
347
+
348
+ Spawn verifier again (back to step 5). Increment `attempt_count`.
349
+
350
+ If verification passes: proceed to completion.
351
+ If verification fails and attempts remain: loop back to 6.1.
352
+
353
+ ## 7. Checkpoint Before /clear
354
+
355
+ At any point during the workflow, if context is getting full (conversation is long, many tool calls made), recommend checkpointing before `/clear`.
356
+
357
+ **Checkpoint protocol:**
358
+ 1. Post a checkpoint comment to the phase's GitHub Issue (if issue tracking is active):
359
+ ```bash
360
+ # Use MCP tool to post checkpoint
361
+ mcp_post_plan_comment(
362
+ phase_issue_number={issue_number},
363
+ plan_number="checkpoint",
364
+ plan_content="## MAXSIM Checkpoint\n\n**Command:** /maxsim:execute\n**Stage:** {current_stage}\n**Plans completed:** {completed_count}/{total_count}\n**Verification attempts:** {attempt_count}/3\n**Resume from:** {next_action}\n**Timestamp:** {ISO timestamp}"
365
+ )
366
+ ```
367
+
368
+ 2. Display checkpoint recommendation:
369
+ ```
370
+ Context is filling up. Recommended: save progress and /clear.
371
+
372
+ Your progress has been checkpointed. Re-run `/maxsim:execute {phase_number}` after /clear -- it will detect completed plans and resume from where it left off.
373
+ ```
374
+
375
+ The state detection in step 2 handles resume automatically -- completed plans have SUMMARY.md files that are detected on re-entry.
376
+
377
+ ## 8. Update State
378
+
379
+ After verification passes, update STATE.md:
380
+
381
+ ```bash
382
+ node .claude/maxsim/bin/maxsim-tools.cjs state record-session \
383
+ --stopped-at "Phase ${PHASE} executed and verified" \
384
+ --resume-file "${phase_dir}"
385
+ ```
386
+
387
+ ## 9. Completion
388
+
389
+ Display final results:
390
+
391
+ ```
392
+ ## Phase {phase_number}: {phase_name} -- Execution Complete
393
+
394
+ **Plans:** {completed}/{total} complete
395
+ **Waves:** {wave_count}
396
+ **Verification:** Passed (attempt {attempt_count}/3)
397
+
398
+ ### Plan Details
399
+ 1. **{plan_id}**: {one-liner from SUMMARY.md}
400
+ 2. **{plan_id}**: {one-liner from SUMMARY.md}
401
+
402
+ ### Next Steps
403
+ - `/maxsim:plan {next_phase}` -- Plan next phase
404
+ - `/maxsim:progress` -- View overall progress
405
+ ```
406
+
407
+ </process>
408
+
409
+ <success_criteria>
410
+ - [ ] Phase validated against roadmap
411
+ - [ ] Current state correctly detected from artifacts
412
+ - [ ] Re-entry flow works for already-executed phases
413
+ - [ ] Plans discovered and grouped by wave
414
+ - [ ] Per-plan execution delegates to execute-plan.md sub-workflow via Task
415
+ - [ ] Spot-check of SUMMARY.md after each wave
416
+ - [ ] Gate confirmation shown after execution completes
417
+ - [ ] Auto-verification spawns verifier agent
418
+ - [ ] Retry loop with gap closure (max 2 retries, 3 total attempts)
419
+ - [ ] Checkpoint-before-clear pattern available
420
+ - [ ] No references to old commands (execute-phase, verify-work)
421
+ </success_criteria>
@@ -0,0 +1,250 @@
1
+ <purpose>
2
+ Auto-detect project state through deep context gathering, surface problems proactively, and dispatch to the appropriate MAXSIM command. Uses the Show + Act pattern: display detection reasoning first, then act immediately.
3
+ </purpose>
4
+
5
+ <required_reading>
6
+ Read all files referenced by the invoking prompt's execution_context before starting.
7
+ </required_reading>
8
+
9
+ <process>
10
+
11
+ <step name="immediate_feedback">
12
+ **Show immediate feedback while gathering context:**
13
+
14
+ ```
15
+ Analyzing project state...
16
+ ```
17
+
18
+ This ensures the user sees something immediately while context gathering runs.
19
+ </step>
20
+
21
+ <step name="deep_context_gathering">
22
+ **Phase 1: Deep Context Gathering**
23
+
24
+ Gather all project signals in parallel for speed. Run these checks simultaneously:
25
+
26
+ **1. Project existence check:**
27
+ ```bash
28
+ PLANNING_EXISTS=$(test -d .planning && echo "true" || echo "false")
29
+ ```
30
+
31
+ If `.planning/` does not exist, skip all other checks and go directly to the decision tree (Rule 1: No project found).
32
+
33
+ **2. Load project state (if .planning/ exists):**
34
+ ```bash
35
+ # State snapshot
36
+ STATE=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs state-snapshot 2>/dev/null || echo "{}")
37
+
38
+ # Roadmap analysis
39
+ ROADMAP=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap analyze 2>/dev/null || echo "{}")
40
+ ```
41
+
42
+ **3. Read key files (if they exist):**
43
+ - `.planning/PROJECT.md` -- project name and vision
44
+ - `.planning/STATE.md` -- blockers, decisions, session continuity
45
+ - `.planning/ROADMAP.md` -- phase structure and progress
46
+
47
+ **4. Git context:**
48
+ ```bash
49
+ # Uncommitted changes
50
+ GIT_STATUS=$(git status --porcelain 2>/dev/null | head -20)
51
+
52
+ # Recent commits
53
+ RECENT_COMMITS=$(git log --oneline -5 2>/dev/null)
54
+ ```
55
+
56
+ **5. Phase directory scan:**
57
+ ```bash
58
+ # List phase directories and their contents
59
+ ls -1 .planning/phases/ 2>/dev/null
60
+ ```
61
+
62
+ For each phase directory, check for PLAN.md, SUMMARY.md, CONTEXT.md, RESEARCH.md files to determine phase state.
63
+ </step>
64
+
65
+ <step name="problem_detection">
66
+ **Phase 2: Problem Detection**
67
+
68
+ Check for problems BEFORE suggesting any action. All problems are blocking -- no severity tiers.
69
+
70
+ **Check each of these in order:**
71
+
72
+ **1. Uncommitted changes in .planning/**
73
+ ```bash
74
+ git status --porcelain .planning/ 2>/dev/null | head -10
75
+ ```
76
+ If uncommitted changes exist in `.planning/`:
77
+ ```
78
+ ## Problem Detected
79
+
80
+ **Issue:** Uncommitted changes in .planning/ directory
81
+ **Impact:** State drift -- local planning files may diverge from team or lose work
82
+ **Resolution:** Commit planning changes to preserve state
83
+
84
+ **Files with changes:**
85
+ {list of changed files}
86
+
87
+ Resolve this before continuing. Options:
88
+ 1. Commit now (recommended)
89
+ 2. Investigate changes first
90
+ 3. Skip and continue anyway
91
+ ```
92
+
93
+ Block until user responds.
94
+
95
+ **2. Blockers in STATE.md**
96
+ Extract blockers from state snapshot. If any exist:
97
+ ```
98
+ ## Problem Detected
99
+
100
+ **Issue:** Active blocker recorded in project state
101
+ **Blocker:** {blocker text}
102
+ **Impact:** Execution cannot proceed safely until this is resolved
103
+ **Resolution:** Address the blocker or remove it if no longer relevant
104
+
105
+ Resolve this before continuing. Options:
106
+ 1. Investigate and resolve
107
+ 2. Remove blocker (if no longer relevant)
108
+ 3. Skip and continue anyway
109
+ ```
110
+
111
+ Block until user responds.
112
+
113
+ **3. Failed verification**
114
+ Check for VERIFICATION.md in the current/latest phase with FAIL status:
115
+ ```bash
116
+ grep -l "FAIL\|status: failed" .planning/phases/*/VERIFICATION.md 2>/dev/null | tail -1
117
+ ```
118
+ If found:
119
+ ```
120
+ ## Problem Detected
121
+
122
+ **Issue:** Phase verification failed
123
+ **Phase:** {phase number and name}
124
+ **Impact:** Phase is not verified as complete -- may have gaps
125
+ **Resolution:** Re-run verification or fix identified issues
126
+
127
+ Resolve this before continuing. Options:
128
+ 1. View verification results
129
+ 2. Re-execute to fix issues
130
+ 3. Skip and continue anyway
131
+ ```
132
+
133
+ Block until user responds.
134
+
135
+ **If any problem is found:** Surface it and wait for user resolution. Do NOT proceed to the decision tree until all problems are cleared or explicitly skipped.
136
+
137
+ **If no problems found:** Proceed to the decision tree.
138
+ </step>
139
+
140
+ <step name="decision_tree">
141
+ **Phase 3: Decision Tree**
142
+
143
+ Apply rules in strict precedence order. The FIRST matching rule determines the action.
144
+
145
+ ```
146
+ Rule 1: No .planning/ directory?
147
+ -> Action: /maxsim:init
148
+ -> Reasoning: "No MAXSIM project found in this directory."
149
+
150
+ Rule 2: Has blockers in STATE.md? (not cleared in problem detection)
151
+ -> Action: Surface blocker, suggest resolution
152
+ -> Reasoning: "BLOCKED: {blocker text}"
153
+
154
+ Rule 3: Active phase has plans but not all executed?
155
+ -> Check: summaries < plans in current phase directory
156
+ -> Action: /maxsim:execute {N}
157
+ -> Reasoning: "Phase {N} ({name}) has {X} plans, {Y} executed. Ready to continue."
158
+
159
+ Rule 4: Active phase needs planning? (no PLAN.md files)
160
+ -> Check: no PLAN.md files in current phase directory
161
+ -> Action: /maxsim:plan {N}
162
+ -> Reasoning: "Phase {N} ({name}) needs planning."
163
+
164
+ Sub-check: Does CONTEXT.md exist?
165
+ -> If yes: "Discussion complete, ready for research + planning."
166
+ -> If no: "Starting from discussion stage."
167
+
168
+ Rule 5: Current phase complete, next phase exists?
169
+ -> Check: all plans have summaries AND next phase exists in roadmap
170
+ -> Action: /maxsim:plan {N+1}
171
+ -> Reasoning: "Phase {N} complete. Next: Phase {N+1} ({name})."
172
+
173
+ Rule 6: All phases complete?
174
+ -> Check: all phases in roadmap have all plans executed
175
+ -> Action: /maxsim:progress
176
+ -> Reasoning: "All phases complete. Milestone ready for review."
177
+
178
+ Rule 7: None of the above?
179
+ -> Action: Show interactive menu
180
+ -> Reasoning: "Project state is ambiguous. Here are your options."
181
+ ```
182
+ </step>
183
+
184
+ <step name="show_and_act">
185
+ **Phase 4: Show + Act**
186
+
187
+ Once a rule matches, display detection reasoning FIRST, then act immediately.
188
+
189
+ **Format for auto-dispatch (Rules 1-6):**
190
+
191
+ ```
192
+ ## Detected: {summary of what was found}
193
+
194
+ **Project:** {project name from PROJECT.md, or "New project"}
195
+ **Milestone:** {milestone from ROADMAP.md, or "Not started"}
196
+ **Current phase:** {phase N - name, or "None"}
197
+ **Status:** {description of current state}
198
+
199
+ **Action:** Running /maxsim:{command} {args}...
200
+ ```
201
+
202
+ Then immediately dispatch the command using the SlashCommand tool. The user can Ctrl+C if the detection is wrong.
203
+
204
+ **Important:** Show the detection block, then dispatch. Do not ask for confirmation -- this is Show + Act, not Show + Ask.
205
+ </step>
206
+
207
+ <step name="interactive_menu">
208
+ **Phase 5: Interactive Menu (Rule 7 -- no obvious action)**
209
+
210
+ When no clear action is detected, show a contextual menu. The menu items are NOT static -- filter based on what makes sense for the current project state.
211
+
212
+ ```
213
+ ## Project Status
214
+
215
+ **Project:** {project name}
216
+ **Milestone:** {milestone}
217
+ **Progress:** {X}/{Y} phases complete
218
+
219
+ What would you like to do?
220
+
221
+ 1. /maxsim:plan {next_phase} -- Plan next phase
222
+ 2. /maxsim:quick -- Quick ad-hoc task
223
+ 3. /maxsim:progress -- View detailed progress
224
+ 4. /maxsim:debug -- Debug an issue
225
+
226
+ Or describe what you'd like to do:
227
+ ```
228
+
229
+ **Contextual filtering rules:**
230
+ - If phases are planned but not executed: show execute options prominently
231
+ - If all phases are done: show `/maxsim:progress` (offers milestone completion)
232
+ - If recent git activity suggests debugging: show `/maxsim:debug` prominently
233
+ - If no phases exist: show `/maxsim:plan` prominently
234
+ - Always include `/maxsim:quick` as it is always relevant
235
+ - Always include an open-ended fallback ("Or describe what you'd like to do")
236
+
237
+ Wait for user selection, then dispatch the chosen command.
238
+ </step>
239
+
240
+ </process>
241
+
242
+ <constraints>
243
+ - Never ask for confirmation before dispatching (Show + Act, not Show + Ask)
244
+ - Always surface problems BEFORE suggesting actions
245
+ - All problems block -- no severity tiers, no "warnings"
246
+ - No arguments accepted -- this is pure auto-detection
247
+ - No mention of old commands (plan-phase, execute-phase, etc.)
248
+ - Keep initial feedback fast -- show "Analyzing..." before heavy operations
249
+ - If context gathering fails (tools not available, etc.), fall back to the interactive menu
250
+ </constraints>
@@ -62,10 +62,10 @@ Errors: N | Warnings: N | Info: N
62
62
  ## Errors
63
63
 
64
64
  - [E001] config.json: JSON parse error at line 5
65
- Fix: Run /maxsim:health --repair to reset to defaults
65
+ Fix: Run /maxsim:progress (health check) --repair to reset to defaults
66
66
 
67
67
  - [E002] PROJECT.md not found
68
- Fix: Run /maxsim:new-project to create
68
+ Fix: Run /maxsim:init to create
69
69
  ```
70
70
 
71
71
  **If warnings exist:**
@@ -73,7 +73,7 @@ Errors: N | Warnings: N | Info: N
73
73
  ## Warnings
74
74
 
75
75
  - [W001] STATE.md references phase 5, but only phases 1-3 exist
76
- Fix: Run /maxsim:health --repair to regenerate
76
+ Fix: Run /maxsim:progress (health check) --repair to regenerate
77
77
 
78
78
  - [W005] Phase directory "1-setup" doesn't follow NN-name format
79
79
  Fix: Rename to match pattern (e.g., 01-setup)
@@ -90,7 +90,7 @@ Errors: N | Warnings: N | Info: N
90
90
  **Footer (if repairable issues exist and --repair was NOT used):**
91
91
  ```
92
92
  ---
93
- N issues can be auto-repaired. Run: /maxsim:health --repair
93
+ N issues can be auto-repaired. Run: /maxsim:progress (health check) --repair
94
94
  ```
95
95
  </step>
96
96
 
@@ -100,7 +100,7 @@ N issues can be auto-repaired. Run: /maxsim:health --repair
100
100
  Ask user if they want to run repairs:
101
101
 
102
102
  ```
103
- Would you like to run /maxsim:health --repair to fix N issues automatically?
103
+ Would you like to run /maxsim:progress (health check) --repair to fix N issues automatically?
104
104
  ```
105
105
 
106
106
  If yes, re-run with --repair flag and display results.