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
@@ -1,11 +1,11 @@
1
1
  <sanity_check>
2
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:new-project` first.
3
+ 1. The current directory contains a `.planning/` folder — if not, stop and tell the user to run `/maxsim:init` first.
4
4
  2. `.planning/ROADMAP.md` exists — if not, stop and tell the user to initialize the project.
5
5
  </sanity_check>
6
6
 
7
7
  <purpose>
8
- Create executable phase prompts (PLAN.md files) for a roadmap phase with integrated research and verification. Default flow: Research (if needed) -> Plan -> Verify -> Done. Orchestrates maxsim-phase-researcher, maxsim-planner, and maxsim-plan-checker agents with a revision loop (max 3 iterations).
8
+ Create executable phase prompts (PLAN.md files) for a roadmap phase with integrated research and verification. Default flow: Research (if needed) -> Plan -> Verify -> Done. Orchestrates researcher, planner, and planner (plan-checking mode) agents with a revision loop (max 3 iterations).
9
9
  </purpose>
10
10
 
11
11
  <required_reading>
@@ -29,7 +29,7 @@ Parse JSON for: `researcher_model`, `planner_model`, `checker_model`, `research_
29
29
 
30
30
  **File paths (for <files_to_read> blocks):** `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `research_path`, `verification_path`, `uat_path`. These are null if files don't exist.
31
31
 
32
- **If `planning_exists` is false:** Error — run `/maxsim:new-project` first.
32
+ **If `planning_exists` is false:** Error — run `/maxsim:init` first.
33
33
 
34
34
  ## 2. Parse and Normalize Arguments
35
35
 
@@ -68,7 +68,7 @@ Use AskUserQuestion:
68
68
  - "Run discuss-phase first" — Capture design decisions before planning
69
69
 
70
70
  If "Continue without context": Proceed to step 5.
71
- If "Run discuss-phase first": Display `/maxsim:discuss-phase {X}` and exit workflow.
71
+ If "Run discuss-phase first": Display `/maxsim:plan {X}` (discussion stage) and exit workflow.
72
72
 
73
73
  ## 5. Handle Research
74
74
 
@@ -87,7 +87,7 @@ Display banner:
87
87
  ◆ Spawning researcher...
88
88
  ```
89
89
 
90
- ### Spawn maxsim-phase-researcher
90
+ ### Spawn researcher
91
91
 
92
92
  ```bash
93
93
  PHASE_DESC=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap get-phase "${PHASE}" | jq -r '.section')
@@ -102,7 +102,7 @@ Answer: "What do I need to know to PLAN this phase well?"
102
102
  </objective>
103
103
 
104
104
  <files_to_read>
105
- - {context_path} (USER DECISIONS from /maxsim:discuss-phase)
105
+ - {context_path} (USER DECISIONS from /maxsim:plan discussion stage)
106
106
  - {requirements_path} (Project requirements)
107
107
  - {state_path} (Project decisions and history)
108
108
  </files_to_read>
@@ -122,8 +122,8 @@ Write to: {phase_dir}/{phase_num}-RESEARCH.md
122
122
 
123
123
  ```
124
124
  Task(
125
- prompt="First, read ~/.claude/agents/maxsim-phase-researcher.md for your role and instructions.\n\n" + research_prompt,
126
- subagent_type="general-purpose",
125
+ prompt=research_prompt,
126
+ subagent_type="researcher",
127
127
  model="{researcher_model}",
128
128
  description="Research Phase {phase}"
129
129
  )
@@ -181,7 +181,7 @@ UAT_PATH=$(echo "$INIT" | jq -r '.uat_path // empty')
181
181
  CONTEXT_PATH=$(echo "$INIT" | jq -r '.context_path // empty')
182
182
  ```
183
183
 
184
- ## 8. Spawn maxsim-planner Agent
184
+ ## 8. Spawn planner Agent
185
185
 
186
186
  Display banner:
187
187
  ```
@@ -203,7 +203,7 @@ Planner prompt:
203
203
  - {state_path} (Project State)
204
204
  - {roadmap_path} (Roadmap)
205
205
  - {requirements_path} (Requirements)
206
- - {context_path} (USER DECISIONS from /maxsim:discuss-phase)
206
+ - {context_path} (USER DECISIONS from /maxsim:plan discussion stage)
207
207
  - {research_path} (Technical Research)
208
208
  - {verification_path} (Verification Gaps - if --gaps)
209
209
  - {uat_path} (UAT Gaps - if --gaps)
@@ -216,7 +216,7 @@ Planner prompt:
216
216
  </planning_context>
217
217
 
218
218
  <downstream_consumer>
219
- Output consumed by /maxsim:execute-phase. Plans need:
219
+ Output consumed by /maxsim:execute. Plans need:
220
220
  - Frontmatter (wave, depends_on, files_modified, autonomous)
221
221
  - Tasks in XML format
222
222
  - Verification criteria
@@ -235,8 +235,8 @@ Output consumed by /maxsim:execute-phase. Plans need:
235
235
 
236
236
  ```
237
237
  Task(
238
- prompt="First, read ~/.claude/agents/maxsim-planner.md for your role and instructions.\n\n" + filled_prompt,
239
- subagent_type="general-purpose",
238
+ prompt=filled_prompt,
239
+ subagent_type="planner",
240
240
  model="{planner_model}",
241
241
  description="Plan Phase {phase}"
242
242
  )
@@ -248,7 +248,7 @@ Task(
248
248
  - **`## CHECKPOINT REACHED`:** Present to user, get response, spawn continuation (step 12)
249
249
  - **`## PLANNING INCONCLUSIVE`:** Show attempts, offer: Add context / Retry / Manual
250
250
 
251
- ## 10. Spawn maxsim-plan-checker Agent
251
+ ## 10. Spawn planner Agent (Plan Verification Mode)
252
252
 
253
253
  Display banner:
254
254
  ```
@@ -270,7 +270,7 @@ Checker prompt:
270
270
  - {PHASE_DIR}/*-PLAN.md (Plans to verify)
271
271
  - {roadmap_path} (Roadmap)
272
272
  - {requirements_path} (Requirements)
273
- - {context_path} (USER DECISIONS from /maxsim:discuss-phase)
273
+ - {context_path} (USER DECISIONS from /maxsim:plan discussion stage)
274
274
  - {research_path} (Technical Research — includes Validation Architecture)
275
275
  </files_to_read>
276
276
 
@@ -288,8 +288,8 @@ Checker prompt:
288
288
 
289
289
  ```
290
290
  Task(
291
- prompt=checker_prompt,
292
- subagent_type="maxsim-plan-checker",
291
+ prompt="## Task: Verify plans achieve phase goal\n\n## Suggested Skills: verification-gates\n\n" + checker_prompt,
292
+ subagent_type="planner",
293
293
  model="{checker_model}",
294
294
  description="Verify Phase {phase} plans"
295
295
  )
@@ -317,7 +317,7 @@ Revision prompt:
317
317
 
318
318
  <files_to_read>
319
319
  - {PHASE_DIR}/*-PLAN.md (Existing plans)
320
- - {context_path} (USER DECISIONS from /maxsim:discuss-phase)
320
+ - {context_path} (USER DECISIONS from /maxsim:plan discussion stage)
321
321
  </files_to_read>
322
322
 
323
323
  **Checker issues:** {structured_issues_from_checker}
@@ -332,8 +332,8 @@ Return what changed.
332
332
 
333
333
  ```
334
334
  Task(
335
- prompt="First, read ~/.claude/agents/maxsim-planner.md for your role and instructions.\n\n" + revision_prompt,
336
- subagent_type="general-purpose",
335
+ prompt=revision_prompt,
336
+ subagent_type="planner",
337
337
  model="{planner_model}",
338
338
  description="Revise Phase {phase} plans"
339
339
  )
@@ -396,8 +396,8 @@ Task(
396
396
  1. Read execute-phase.md from execution_context for your complete workflow
397
397
  2. Follow ALL steps: initialize, handle_branching, validate_phase, discover_and_group_plans, execute_waves, aggregate_results, close_parent_artifacts, verify_phase_goal, update_roadmap
398
398
  3. The --no-transition flag means: after verification + roadmap update, STOP and return status. Do NOT run transition.md.
399
- 4. When spawning executor agents, use subagent_type='maxsim-executor' with the existing @file pattern from the workflow
400
- 5. When spawning verifier agents, use subagent_type='maxsim-verifier'
399
+ 4. When spawning executor agents, use subagent_type='executor' with the existing @file pattern from the workflow
400
+ 5. When spawning verifier agents, use subagent_type='verifier'
401
401
  6. Preserve the classifyHandoffIfNeeded workaround (spot-check on that specific error)
402
402
  7. Do NOT use the Skill tool or /maxsim: commands
403
403
  </instructions>
@@ -416,14 +416,14 @@ Task(
416
416
 
417
417
  Auto-advance pipeline finished.
418
418
 
419
- Next: /maxsim:discuss-phase ${NEXT_PHASE} --auto
419
+ Next: /maxsim:plan ${NEXT_PHASE} --auto
420
420
  ```
421
421
  - **GAPS FOUND / VERIFICATION FAILED** → Display result, stop chain:
422
422
  ```
423
423
  Auto-advance stopped: Execution needs review.
424
424
 
425
425
  Review the output above and continue manually:
426
- /maxsim:execute-phase ${PHASE}
426
+ /maxsim:execute ${PHASE}
427
427
  ```
428
428
 
429
429
  **If neither `--auto` nor config enabled:**
@@ -454,7 +454,7 @@ Verification: {Passed | Passed with override | Skipped}
454
454
 
455
455
  **Execute Phase {X}** — run all {N} plans
456
456
 
457
- /maxsim:execute-phase {X}
457
+ /maxsim:execute {X}
458
458
 
459
459
  <sub>/clear first → fresh context window</sub>
460
460
 
@@ -462,7 +462,7 @@ Verification: {Passed | Passed with override | Skipped}
462
462
 
463
463
  **Also available:**
464
464
  - cat .planning/phases/{phase-dir}/*-PLAN.md — review plans
465
- - /maxsim:plan-phase {X} --research — re-research first
465
+ - /maxsim:plan {X} --research — re-research first
466
466
 
467
467
  ───────────────────────────────────────────────────────────────
468
468
  </offer_next>
@@ -473,11 +473,11 @@ Verification: {Passed | Passed with override | Skipped}
473
473
  - [ ] Phase directory created if needed
474
474
  - [ ] CONTEXT.md loaded early (step 4) and passed to ALL agents
475
475
  - [ ] Research completed (unless --skip-research or --gaps or exists)
476
- - [ ] maxsim-phase-researcher spawned with CONTEXT.md
476
+ - [ ] researcher spawned with CONTEXT.md
477
477
  - [ ] Existing plans checked
478
- - [ ] maxsim-planner spawned with CONTEXT.md + RESEARCH.md
478
+ - [ ] planner spawned with CONTEXT.md + RESEARCH.md
479
479
  - [ ] Plans created (PLANNING COMPLETE or CHECKPOINT handled)
480
- - [ ] maxsim-plan-checker spawned with CONTEXT.md
480
+ - [ ] planner (plan-check mode) spawned with CONTEXT.md
481
481
  - [ ] Verification passed OR user override OR max iterations with user decision
482
482
  - [ ] User sees status between agent spawns
483
483
  - [ ] User knows next steps
@@ -0,0 +1,177 @@
1
+ <purpose>
2
+ Research stage sub-workflow for /maxsim:plan. Spawns the researcher agent with phase context to produce RESEARCH.md.
3
+
4
+ This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on running research and validating the output.
5
+ </purpose>
6
+
7
+ <process>
8
+
9
+ ## Step 1: Check Prerequisites
10
+
11
+ The orchestrator provides phase context. Verify we have what we need:
12
+
13
+ - `phase_number`, `phase_name`, `phase_dir`, `padded_phase`, `phase_slug`
14
+ - `researcher_model`, `research_enabled`
15
+ - `has_research` (whether RESEARCH.md already exists)
16
+ - `state_path`, `roadmap_path`, `requirements_path`, `context_path`
17
+ - `phase_req_ids` (requirement IDs that this phase must address)
18
+ - `--force-research` flag presence
19
+
20
+ ## Step 2: Resolve Researcher Model
21
+
22
+ ```bash
23
+ RESEARCHER_MODEL=$(node .claude/maxsim/bin/maxsim-tools.cjs resolve-model researcher --raw)
24
+ ```
25
+
26
+ ## Step 3: Check Existing Research
27
+
28
+ **If `has_research` is true AND `--force-research` is NOT set:**
29
+
30
+ Research already exists. Display:
31
+ ```
32
+ Using existing research from: {research_path}
33
+ ```
34
+
35
+ Return control to orchestrator -- no need to re-research.
36
+
37
+ **If `has_research` is true AND `--force-research` IS set:**
38
+
39
+ Continue to Step 4 (re-research will overwrite existing RESEARCH.md).
40
+
41
+ **If `has_research` is false:**
42
+
43
+ Continue to Step 4.
44
+
45
+ **If `research_enabled` is false AND `--force-research` is NOT set:**
46
+
47
+ Research is disabled in config. Display:
48
+ ```
49
+ Research disabled in config (workflow.research = false).
50
+ Skipping research stage.
51
+ ```
52
+
53
+ Return control to orchestrator.
54
+
55
+ ## Step 4: Gather Phase Context
56
+
57
+ ```bash
58
+ PHASE_DESC=$(node .claude/maxsim/bin/maxsim-tools.cjs roadmap get-phase "${PHASE}" 2>/dev/null)
59
+ ```
60
+
61
+ Extract the phase section/description from the JSON output for the researcher prompt.
62
+
63
+ ## Step 5: Spawn Researcher
64
+
65
+ Display:
66
+ ```
67
+ Researching Phase {phase_number}: {phase_name}...
68
+ ```
69
+
70
+ Construct the research prompt:
71
+
72
+ ```markdown
73
+ <objective>
74
+ Research how to implement Phase {phase_number}: {phase_name}
75
+ Answer: "What do I need to know to PLAN this phase well?"
76
+ </objective>
77
+
78
+ <files_to_read>
79
+ - {context_path} (USER DECISIONS -- locked choices that constrain research)
80
+ - {requirements_path} (Project requirements)
81
+ - {state_path} (Project decisions and history)
82
+ </files_to_read>
83
+
84
+ <additional_context>
85
+ **Phase description:** {phase_description from PHASE_DESC}
86
+ **Phase requirement IDs (MUST address):** {phase_req_ids}
87
+
88
+ **Project instructions:** Read ./CLAUDE.md if exists -- follow project-specific guidelines
89
+ **Project skills:** Check .skills/ directory (if exists) -- read SKILL.md files, research should account for project skill patterns
90
+ </additional_context>
91
+
92
+ <output>
93
+ Write to: {phase_dir}/{padded_phase}-RESEARCH.md
94
+ </output>
95
+ ```
96
+
97
+ Spawn the researcher:
98
+
99
+ ```
100
+ Task(
101
+ prompt=research_prompt,
102
+ subagent_type="researcher",
103
+ model="{researcher_model}",
104
+ description="Research Phase {phase_number}"
105
+ )
106
+ ```
107
+
108
+ ## Step 6: Handle Researcher Return
109
+
110
+ Parse the researcher's return message:
111
+
112
+ - **`## RESEARCH COMPLETE`:**
113
+ Validate RESEARCH.md was created:
114
+ ```bash
115
+ test -f "${phase_dir}/${padded_phase}-RESEARCH.md" && echo "FOUND" || echo "MISSING"
116
+ ```
117
+
118
+ If FOUND:
119
+ - If `commit_docs` is true:
120
+ ```bash
121
+ node .claude/maxsim/bin/maxsim-tools.cjs commit "docs(${padded_phase}): research phase domain" --files "${phase_dir}/${padded_phase}-RESEARCH.md"
122
+ ```
123
+ - Display confirmation:
124
+ ```
125
+ Research complete. RESEARCH.md written to {path}.
126
+ ```
127
+ - Return control to orchestrator.
128
+
129
+ If MISSING:
130
+ - Error: "Researcher reported complete but RESEARCH.md not found at expected path."
131
+ - Check for alternative paths:
132
+ ```bash
133
+ ls "${phase_dir}"/*RESEARCH* 2>/dev/null
134
+ ```
135
+ - If found elsewhere, note the actual path and continue.
136
+ - If truly missing, offer: retry or skip research.
137
+
138
+ - **`## RESEARCH BLOCKED`:**
139
+ Display the blocker reason. Offer options:
140
+ ```
141
+ Research blocked: {reason}
142
+
143
+ 1. Provide additional context and retry
144
+ 2. Skip research and proceed to planning
145
+ 3. Abort
146
+ ```
147
+ Wait for user choice.
148
+
149
+ - If "Provide context": Get additional info, re-spawn researcher with augmented prompt.
150
+ - If "Skip": Return to orchestrator without RESEARCH.md.
151
+ - If "Abort": Exit workflow.
152
+
153
+ - **`## RESEARCH INCONCLUSIVE`:**
154
+ Display what was attempted. Offer:
155
+ ```
156
+ Research inconclusive after {N} attempts.
157
+
158
+ 1. Provide more context and retry
159
+ 2. Skip research
160
+ 3. Abort
161
+ ```
162
+ Handle same as BLOCKED options.
163
+
164
+ ## Step 7: Return to Orchestrator
165
+
166
+ After RESEARCH.md is validated (or research is skipped), return control to the plan.md orchestrator. Do NOT show gate confirmation or next steps -- the orchestrator handles the gate between Research and Planning.
167
+
168
+ </process>
169
+
170
+ <success_criteria>
171
+ - Researcher model resolved from config
172
+ - Existing research detected and reused (unless --force-research)
173
+ - researcher agent spawned with full context (CONTEXT.md, requirements, state)
174
+ - RESEARCH.md created and validated
175
+ - Blocked/inconclusive scenarios handled with user options
176
+ - Control returned to orchestrator without showing gate or next steps
177
+ </success_criteria>
@@ -0,0 +1,231 @@
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:plan state machine. Detects the current stage of a phase (Discussion, Research, Planning), delegates to stage sub-workflows, shows gate confirmations between stages, and handles re-entry on already-planned phases.
9
+
10
+ This file is the ORCHESTRATOR ONLY. Stage-specific logic lives in:
11
+ - @./workflows/plan-discuss.md (Discussion stage)
12
+ - @./workflows/plan-research.md (Research stage)
13
+ - @./workflows/plan-create.md (Planning stage)
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 plan-phase "$PHASE")
24
+ ```
25
+
26
+ Parse JSON for: `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_context`, `has_research`, `has_plans`, `plan_count`, `plans`, `commit_docs`, `researcher_model`, `planner_model`, `checker_model`, `research_enabled`, `plan_checker_enabled`, `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `research_path`, `phase_req_ids`.
27
+
28
+ **If `phase_found` is false:**
29
+ ```
30
+ Phase [X] not found in roadmap.
31
+
32
+ Use /maxsim:progress to see available phases.
33
+ ```
34
+ Exit workflow.
35
+
36
+ ## 2. Parse Arguments
37
+
38
+ Extract from $ARGUMENTS: phase number (integer or decimal like `2.1`), flags (`--force-research`, `--skip-verify`).
39
+
40
+ **If no phase number:** Detect next unplanned phase from roadmap using the `plans` and `has_context`/`has_research` fields.
41
+
42
+ ## 3. Detect Current Stage
43
+
44
+ Determine where to start based on artifacts that already exist:
45
+
46
+ | Condition | Stage | Action |
47
+ |-----------|-------|--------|
48
+ | `plan_count > 0` | Already planned | Go to **Re-entry flow** (step 4) |
49
+ | `has_research == true` AND `plan_count == 0` | Planning | Start at **Planning stage** (step 7) |
50
+ | `has_context == true` AND `has_research == false` | Research | Start at **Research stage** (step 6) |
51
+ | None of the above | Discussion | Start at **Discussion stage** (step 5) |
52
+
53
+ Display detected stage:
54
+ ```
55
+ Phase {phase_number}: {phase_name}
56
+ Current stage: {Discussion | Research | Planning | Already planned}
57
+ ```
58
+
59
+ ## 4. Re-entry Flow (Already Planned)
60
+
61
+ When `plan_count > 0`, the phase has existing plans. Show status and offer options.
62
+
63
+ Display:
64
+ ```
65
+ ## Phase {phase_number} Already Planned
66
+
67
+ **Plans:** {plan_count} plan(s)
68
+ **Plan files:** {list of plan filenames from `plans` array}
69
+ **Phase directory:** {phase_dir}
70
+
71
+ **Options:**
72
+ 1. View existing plans
73
+ 2. Re-plan from scratch (deletes existing plans, restarts from Discussion)
74
+ 3. Execute phase -- run /maxsim:execute {phase_number}
75
+ 4. Done (exit)
76
+ ```
77
+
78
+ Wait for user choice via natural conversation.
79
+
80
+ - **View:** Display contents of each PLAN.md file, then re-show options.
81
+ - **Re-plan:** Delete existing PLAN.md files, reset to Discussion stage (step 5).
82
+ - **Execute:** Display `/maxsim:execute {phase_number}` and exit.
83
+ - **Done:** Exit workflow.
84
+
85
+ ## 5. Discussion Stage
86
+
87
+ Delegate to the discussion sub-workflow for full discussion logic:
88
+
89
+ @./workflows/plan-discuss.md
90
+
91
+ Pass context: `phase_number`, `phase_name`, `phase_dir`, `padded_phase`, `phase_slug`, `commit_docs`, `roadmap_path`, `state_path`.
92
+
93
+ **After discussion completes (CONTEXT.md written):**
94
+
95
+ Refresh state to pick up the newly created CONTEXT.md:
96
+ ```bash
97
+ INIT=$(node .claude/maxsim/bin/maxsim-tools.cjs init plan-phase "$PHASE")
98
+ ```
99
+
100
+ Show gate:
101
+ ```
102
+ ## Gate: Discussion Complete
103
+
104
+ **Captured:** {N} decisions across {M} areas
105
+ **Locked decisions:**
106
+ {bullet list of key decisions from CONTEXT.md}
107
+
108
+ **Claude's discretion:** {list of areas where Claude decides}
109
+ **Context file:** {path to CONTEXT.md}
110
+
111
+ Continue to research? [Yes / Review context / Re-discuss area]
112
+ ```
113
+
114
+ Wait for user response via natural conversation (not AskUserQuestion).
115
+
116
+ - **Yes:** Advance to Research stage (step 6).
117
+ - **Review context:** Display CONTEXT.md contents, then re-show gate.
118
+ - **Re-discuss area:** Loop back to discussion sub-workflow with the area to re-discuss.
119
+
120
+ ## 6. Research Stage
121
+
122
+ Delegate to the research sub-workflow:
123
+
124
+ @./workflows/plan-research.md
125
+
126
+ Pass context: `phase_number`, `phase_name`, `phase_dir`, `padded_phase`, `phase_slug`, `commit_docs`, `researcher_model`, `research_enabled`, `has_research`, `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `phase_req_ids`. Also pass the `--force-research` flag if present in $ARGUMENTS.
127
+
128
+ **After research completes (RESEARCH.md written or already exists):**
129
+
130
+ Refresh state:
131
+ ```bash
132
+ INIT=$(node .claude/maxsim/bin/maxsim-tools.cjs init plan-phase "$PHASE")
133
+ ```
134
+
135
+ Show gate:
136
+ ```
137
+ ## Gate: Research Complete
138
+
139
+ **Key findings:** {3-5 bullet summary from RESEARCH.md}
140
+ **Confidence:** {HIGH/MEDIUM/LOW from RESEARCH.md metadata}
141
+ **File:** {path to RESEARCH.md}
142
+
143
+ Continue to planning? [Yes / Review research / Re-research]
144
+ ```
145
+
146
+ Wait for user response via natural conversation.
147
+
148
+ - **Yes:** Advance to Planning stage (step 7).
149
+ - **Review research:** Display RESEARCH.md contents, then re-show gate.
150
+ - **Re-research:** Loop back to research sub-workflow with `--force-research`.
151
+
152
+ ## 7. Planning Stage
153
+
154
+ Delegate to the planning sub-workflow:
155
+
156
+ @./workflows/plan-create.md
157
+
158
+ Pass context: `phase_number`, `phase_name`, `phase_dir`, `padded_phase`, `phase_slug`, `commit_docs`, `planner_model`, `checker_model`, `plan_checker_enabled`, `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `research_path`, `phase_req_ids`. Also pass the `--skip-verify` flag if present in $ARGUMENTS.
159
+
160
+ **After planning completes (PLAN.md files created):**
161
+
162
+ Refresh state:
163
+ ```bash
164
+ INIT=$(node .claude/maxsim/bin/maxsim-tools.cjs init plan-phase "$PHASE")
165
+ ```
166
+
167
+ Show final gate:
168
+ ```
169
+ ## Gate: Planning Complete
170
+
171
+ **Plans:** {plan_count} plan(s) in {wave_count} wave(s)
172
+ **Wave structure:**
173
+ | Wave | Plans | What it builds |
174
+ |------|-------|----------------|
175
+ {wave summary from plan frontmatter}
176
+
177
+ **Plan files:** {list of PLAN.md paths}
178
+
179
+ Ready to execute? Run `/maxsim:execute {phase_number}`
180
+ ```
181
+
182
+ This is the final gate -- no confirmation needed. The user's next action is to run `/maxsim:execute`.
183
+
184
+ ## 8. Checkpoint Before /clear
185
+
186
+ At any point during the workflow, if context is getting full (conversation is long, many tool calls made), recommend checkpointing before `/clear`.
187
+
188
+ **Checkpoint protocol:**
189
+ 1. Post a checkpoint comment to the phase's GitHub Issue (if issue tracking is active):
190
+ ```bash
191
+ # Use MCP tool to post checkpoint
192
+ mcp_post_plan_comment(
193
+ phase_issue_number={issue_number},
194
+ plan_number="checkpoint",
195
+ plan_content="## MAXSIM Checkpoint\n\n**Command:** /maxsim:plan\n**Stage:** {current_stage} ({stage_num}/3)\n**Completed:**\n{list of completed stages with summaries}\n**Resume from:** {next_stage}\n**Timestamp:** {ISO timestamp}"
196
+ )
197
+ ```
198
+
199
+ 2. Display checkpoint recommendation:
200
+ ```
201
+ Context is filling up. Recommended: save progress and /clear.
202
+
203
+ Your progress has been checkpointed. Re-run `/maxsim:plan {phase_number}` after /clear -- it will detect completed stages and resume from {next_stage}.
204
+ ```
205
+
206
+ The stage detection in step 3 handles resume automatically -- completed stages produce artifacts (CONTEXT.md, RESEARCH.md, PLAN.md) that are detected on re-entry.
207
+
208
+ ## 9. Update State
209
+
210
+ After all stages complete, update STATE.md:
211
+
212
+ ```bash
213
+ node .claude/maxsim/bin/maxsim-tools.cjs state record-session \
214
+ --stopped-at "Phase ${PHASE} planned" \
215
+ --resume-file "${phase_dir}"
216
+ ```
217
+
218
+ </process>
219
+
220
+ <success_criteria>
221
+ - [ ] Phase validated against roadmap
222
+ - [ ] Current stage correctly detected from artifacts
223
+ - [ ] Re-entry flow works for already-planned phases
224
+ - [ ] Discussion stage delegates to plan-discuss.md sub-workflow
225
+ - [ ] Research stage delegates to plan-research.md sub-workflow
226
+ - [ ] Planning stage delegates to plan-create.md sub-workflow
227
+ - [ ] Gate confirmation shown after each stage transition
228
+ - [ ] User confirms before advancing to next stage
229
+ - [ ] Checkpoint-before-clear pattern available
230
+ - [ ] No stage-specific logic inline -- all delegated to sub-workflows
231
+ </success_criteria>