maxsimcli 4.12.0 → 4.14.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.
@@ -25,7 +25,7 @@ INIT=$(node .claude/maxsim/bin/maxsim-tools.cjs init execute-phase "$PHASE")
25
25
 
26
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
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`.
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`, `phase_issue_number`, `task_mappings`.
29
29
 
30
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
31
 
@@ -37,7 +37,16 @@ Use /maxsim:progress to see available phases.
37
37
  ```
38
38
  Exit workflow.
39
39
 
40
- **If `plan_count` is 0:**
40
+ **If `plan_count` is 0 (GitHub check):**
41
+
42
+ When GitHub integration is active (phase_issue_number is set), check for plan comments on the phase issue before reporting no plans:
43
+
44
+ ```
45
+ mcp_get_issue_detail(issue_number: phase_issue_number)
46
+ ```
47
+
48
+ Parse the response to find comments with `<!-- maxsim:type=plan -->` markers or `## Plan NN` headings. If no plan comments are found:
49
+
41
50
  ```
42
51
  No plans found for Phase {phase_number}.
43
52
 
@@ -47,6 +56,58 @@ Exit workflow.
47
56
 
48
57
  ## 2. Detect State
49
58
 
59
+ ### 2a. Load Plan Inventory from GitHub
60
+
61
+ When GitHub integration is active (`phase_issue_number` is set):
62
+
63
+ 1. Fetch the phase issue and its comments:
64
+ ```
65
+ mcp_get_issue_detail(issue_number: phase_issue_number)
66
+ ```
67
+
68
+ 2. Parse issue comments to identify plan comments. A plan comment is one that contains either:
69
+ - A `<!-- maxsim:type=plan -->` HTML comment marker, OR
70
+ - A heading matching `## Plan NN` (where NN is a number)
71
+
72
+ 3. For each plan comment found:
73
+ - Extract the plan number (from the `## Plan NN` heading or frontmatter)
74
+ - Parse YAML frontmatter from the comment body for: `wave`, `dependencies`, `autonomous`, `objective`, `gap_closure`
75
+ - Store plan content in memory as `PLAN_COMMENTS[]`
76
+
77
+ 4. Check completion status for each plan by calling:
78
+ ```
79
+ mcp_list_sub_issues(issue_number: phase_issue_number)
80
+ ```
81
+ A plan is considered complete when ALL of its task sub-issues are closed (state: closed).
82
+ Additionally, check for `<!-- maxsim:type=summary -->` comments on the phase issue as a secondary completion signal.
83
+
84
+ 5. Build `plan_inventory` from GitHub data:
85
+ - `plans[]`: each with `id`, `wave`, `autonomous`, `objective`, `has_summary` (derived from sub-issue closure)
86
+ - `incomplete_plans[]`: plans where not all task sub-issues are closed
87
+ - `plan_count`: total plan comments found
88
+ - `incomplete_count`: count of incomplete plans
89
+
90
+ When GitHub integration is NOT active (no `phase_issue_number`), fall back to local file scanning:
91
+ ```bash
92
+ PLAN_INDEX=$(node .claude/maxsim/bin/maxsim-tools.cjs phase-plan-index "${PHASE_NUMBER}")
93
+ ```
94
+
95
+ ### 2b. Check for External Edits (WIRE-06)
96
+
97
+ If phase_issue_number is set, optionally detect whether the phase issue was externally modified since last read:
98
+
99
+ ```
100
+ mcp_detect_external_edits(issue_number: phase_issue_number)
101
+ ```
102
+
103
+ If external edits are detected: warn the user before proceeding.
104
+ ```
105
+ ⚠️ Phase issue #{phase_issue_number} was modified externally since last check.
106
+ Review the changes before continuing? (yes/no)
107
+ ```
108
+
109
+ ### 2c. Determine Execution State
110
+
50
111
  Determine where to start based on phase artifacts:
51
112
 
52
113
  | Condition | State | Action |
@@ -72,20 +133,20 @@ Display:
72
133
 
73
134
  **Plans:** {plan_count} plan(s) -- all complete
74
135
  **Verification:** Passed
75
- **Phase directory:** {phase_dir}
136
+ **Phase issue:** #{phase_issue_number} (if GitHub active)
76
137
 
77
138
  **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
139
+ 1. View results -- show plan summaries from GitHub comments
140
+ 2. Re-execute from scratch -- reopen task sub-issues and restart execution
141
+ 3. View verification -- show verification comment on phase issue
81
142
  4. Done (exit)
82
143
  ```
83
144
 
84
145
  Wait for user choice via natural conversation.
85
146
 
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.
147
+ - **View results:** Fetch and display summary comments (`<!-- maxsim:type=summary -->`) from the phase issue, then re-show options.
148
+ - **Re-execute:** Reopen task sub-issues via `mcp_reopen_issue` for each task sub-issue, restart from Execute Plans (step 4).
149
+ - **View verification:** Fetch and display the verification comment (`<!-- maxsim:type=verification -->`) from the phase issue, then re-show options.
89
150
  - **Done:** Exit workflow.
90
151
 
91
152
  ## 4. Execute Plans
@@ -94,13 +155,7 @@ Execute all plans in wave order, delegating each plan to a subagent via execute-
94
155
 
95
156
  ### 4.1 Discover and Group Plans
96
157
 
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`.
158
+ Use the plan inventory built in step 2 (from GitHub comments or local files).
104
159
 
105
160
  Skip plans where `has_summary: true` (already complete -- supports resume).
106
161
 
@@ -141,7 +196,7 @@ Execute each wave in sequence. Within a wave: parallel if `parallelization` is t
141
196
 
142
197
  2. **Spawn executor agents:**
143
198
 
144
- Pass paths only -- executors read files themselves with their fresh 200k context.
199
+ Pass plan content and GitHub context -- executors read the plan from GitHub comment content passed in the prompt.
145
200
 
146
201
  ```
147
202
  Task(
@@ -150,7 +205,8 @@ Execute each wave in sequence. Within a wave: parallel if `parallelization` is t
150
205
  prompt="
151
206
  <objective>
152
207
  Execute plan {plan_number} of phase {phase_number}-{phase_name}.
153
- Commit each task atomically. Create SUMMARY.md. Update STATE.md and ROADMAP.md.
208
+ Commit each task atomically. Post SUMMARY as GitHub comment. Update STATE.md and ROADMAP.md.
209
+ Move task sub-issues on the board as you work (In Progress → Done per task).
154
210
  </objective>
155
211
 
156
212
  <execution_context>
@@ -160,9 +216,14 @@ Execute each wave in sequence. Within a wave: parallel if `parallelization` is t
160
216
  @./references/tdd.md
161
217
  </execution_context>
162
218
 
219
+ <github_context>
220
+ Phase issue number: {phase_issue_number}
221
+ Plan comment: {plan_comment_body}
222
+ Task mappings: {task_mappings_for_this_plan}
223
+ </github_context>
224
+
163
225
  <files_to_read>
164
226
  Read these files at execution start using the Read tool:
165
- - {phase_dir}/{plan_file} (Plan)
166
227
  - .planning/STATE.md (State)
167
228
  - .planning/config.json (Config, if exists)
168
229
  - ./CLAUDE.md (Project instructions, if exists)
@@ -171,7 +232,8 @@ Execute each wave in sequence. Within a wave: parallel if `parallelization` is t
171
232
  <success_criteria>
172
233
  - [ ] All tasks executed
173
234
  - [ ] Each task committed individually
174
- - [ ] SUMMARY.md created in plan directory
235
+ - [ ] Summary posted as GitHub comment (mcp_post_comment with type=summary) on phase issue
236
+ - [ ] Task sub-issues moved: In Progress when started, Done when completed
175
237
  - [ ] STATE.md updated with position and decisions
176
238
  - [ ] ROADMAP.md updated with plan progress
177
239
  </success_criteria>
@@ -183,11 +245,12 @@ Execute each wave in sequence. Within a wave: parallel if `parallelization` is t
183
245
 
184
246
  4. **Spot-check results:**
185
247
 
186
- For each completed plan's SUMMARY.md:
187
- - Verify first 2 files from key-files exist on disk
248
+ For each completed plan:
249
+ - Check that a `<!-- maxsim:type=summary -->` comment exists on the phase issue for this plan
188
250
  - 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
251
+ - Verify task sub-issues for this plan are all closed
252
+ - Check for `## Self-Check: FAILED` in the summary comment body
253
+ - Check for `## Review Cycle` section in summary -- verify both Spec and Code stages show PASS
191
254
 
192
255
  If ANY spot-check fails: report which plan failed, ask "Retry plan?" or "Continue with remaining waves?"
193
256
 
@@ -198,7 +261,7 @@ Execute each wave in sequence. Within a wave: parallel if `parallelization` is t
198
261
  ## Wave {N} Complete
199
262
 
200
263
  **{Plan ID}: {Plan Name}**
201
- {What was built -- from SUMMARY.md}
264
+ {What was built -- from summary comment}
202
265
  {Notable deviations, if any}
203
266
 
204
267
  {If more waves: what this enables for next wave}
@@ -218,7 +281,7 @@ After all waves complete:
218
281
 
219
282
  **Plans executed:** {completed}/{total}
220
283
  **Waves:** {wave_count}
221
- **Commits:** {list of commit summaries from SUMMARY.md files}
284
+ **Commits:** {list of commit summaries from summary comments}
222
285
 
223
286
  Proceeding to verification...
224
287
  ```
@@ -241,11 +304,13 @@ VERIFIER_MODEL=$(node .claude/maxsim/bin/maxsim-tools.cjs resolve-model verifier
241
304
  Task(
242
305
  prompt="Verify phase {phase_number} goal achievement.
243
306
  Phase directory: {phase_dir}
307
+ Phase issue: #{phase_issue_number}
244
308
  Phase goal: {goal from ROADMAP.md}
245
309
  Phase requirement IDs: {phase_req_ids}
246
310
  Check must_haves against actual codebase.
247
- Cross-reference requirement IDs from PLAN frontmatter against REQUIREMENTS.md.
248
- Create VERIFICATION.md.",
311
+ Cross-reference requirement IDs from plan frontmatter against REQUIREMENTS.md.
312
+ Post verification results as a GitHub comment (mcp_post_comment with type=verification) on the phase issue.
313
+ Also write VERIFICATION.md to the phase directory for local reference.",
249
314
  subagent_type="verifier",
250
315
  model="{verifier_model}"
251
316
  )
@@ -253,7 +318,15 @@ Create VERIFICATION.md.",
253
318
 
254
319
  ### 5.2 Parse Verifier Result
255
320
 
256
- Read verification status:
321
+ Read verification status from the verification comment on the phase issue:
322
+
323
+ ```
324
+ mcp_get_issue_detail(issue_number: phase_issue_number)
325
+ ```
326
+
327
+ Look for the `<!-- maxsim:type=verification -->` comment and parse the `status:` field from its body.
328
+
329
+ Also fall back to reading locally:
257
330
  ```bash
258
331
  grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
259
332
  ```
@@ -264,11 +337,25 @@ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
264
337
  ## Gate: Verification Passed
265
338
 
266
339
  **Status:** All must-haves verified
267
- **Evidence:** {summary from VERIFICATION.md}
340
+ **Evidence:** {summary from verification comment}
268
341
 
269
342
  Phase {phase_number} complete!
270
343
  ```
271
344
 
345
+ Move phase issue to "Done" status:
346
+ ```
347
+ mcp_move_issue(issue_number: phase_issue_number, status: "Done")
348
+ ```
349
+
350
+ Post phase completion comment:
351
+ ```
352
+ mcp_post_comment(
353
+ issue_number: phase_issue_number,
354
+ type: "phase-complete",
355
+ body: "## Phase {phase_number} Complete\n\nAll plans executed and verified.\n\n**Plans:** {completed}/{total}\n**Waves:** {wave_count}\n**Verification:** Passed"
356
+ )
357
+ ```
358
+
272
359
  Mark phase complete:
273
360
  ```bash
274
361
  COMPLETION=$(node .claude/maxsim/bin/maxsim-tools.cjs phase complete "${PHASE_NUMBER}")
@@ -279,7 +366,15 @@ Update tracking files:
279
366
  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
367
  ```
281
368
 
282
- **If `gaps_found`:** Proceed to Retry Loop (step 6).
369
+ **If `gaps_found`:** Post a gaps comment on the phase issue, then proceed to Retry Loop (step 6).
370
+
371
+ ```
372
+ mcp_post_comment(
373
+ issue_number: phase_issue_number,
374
+ type: "verification-gaps",
375
+ body: "## Verification Gaps Found\n\n{gap summaries from verification result}"
376
+ )
377
+ ```
283
378
 
284
379
  **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
380
 
@@ -299,7 +394,7 @@ If `attempt_count > 2`:
299
394
  **Attempts:** 3 (initial + 2 retries)
300
395
 
301
396
  ### What Failed
302
- {List of unresolved gaps from VERIFICATION.md with evidence}
397
+ {List of unresolved gaps from verification comment with evidence}
303
398
 
304
399
  ### Options
305
400
  1. Fix manually and re-run `/maxsim:execute {phase_number}`
@@ -332,6 +427,7 @@ Task(
332
427
  <downstream_consumer>
333
428
  Output consumed by /maxsim:execute.
334
429
  Plans must be executable prompts.
430
+ Post gap-closure plans as comments on phase issue #{phase_issue_number} using mcp_post_comment with type=plan.
335
431
  </downstream_consumer>
336
432
  ",
337
433
  subagent_type="planner",
@@ -341,7 +437,7 @@ Plans must be executable prompts.
341
437
 
342
438
  ### 6.3 Execute Gap Plans
343
439
 
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.
440
+ After the planner posts gap-closure plan comments on the phase issue, re-read the phase issue to discover the new plan comments. 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
441
 
346
442
  ### 6.4 Re-verify
347
443
 
@@ -356,12 +452,11 @@ At any point during the workflow, if context is getting full (conversation is lo
356
452
 
357
453
  **Checkpoint protocol:**
358
454
  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}"
455
+ ```
456
+ mcp_post_comment(
457
+ issue_number: phase_issue_number,
458
+ type: "checkpoint",
459
+ body: "## 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
460
  )
366
461
  ```
367
462
 
@@ -369,10 +464,10 @@ mcp_post_plan_comment(
369
464
  ```
370
465
  Context is filling up. Recommended: save progress and /clear.
371
466
 
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.
467
+ Your progress has been checkpointed on GitHub issue #{phase_issue_number}. Re-run `/maxsim:execute {phase_number}` after /clear -- it will detect completed plans (via closed task sub-issues) and resume from where it left off.
373
468
  ```
374
469
 
375
- The state detection in step 2 handles resume automatically -- completed plans have SUMMARY.md files that are detected on re-entry.
470
+ The state detection in step 2 handles resume automatically -- completed plans have all their task sub-issues closed, which is detected on re-entry.
376
471
 
377
472
  ## 8. Update State
378
473
 
@@ -394,10 +489,11 @@ Display final results:
394
489
  **Plans:** {completed}/{total} complete
395
490
  **Waves:** {wave_count}
396
491
  **Verification:** Passed (attempt {attempt_count}/3)
492
+ **Phase issue:** #{phase_issue_number} (closed)
397
493
 
398
494
  ### Plan Details
399
- 1. **{plan_id}**: {one-liner from SUMMARY.md}
400
- 2. **{plan_id}**: {one-liner from SUMMARY.md}
495
+ 1. **{plan_id}**: {one-liner from summary comment}
496
+ 2. **{plan_id}**: {one-liner from summary comment}
401
497
 
402
498
  ### Next Steps
403
499
  - `/maxsim:plan {next_phase}` -- Plan next phase
@@ -408,14 +504,17 @@ Display final results:
408
504
 
409
505
  <success_criteria>
410
506
  - [ ] Phase validated against roadmap
411
- - [ ] Current state correctly detected from artifacts
507
+ - [ ] Plan inventory loaded from GitHub issue comments (falling back to local files if no GitHub integration)
508
+ - [ ] External edit detection warns user if phase issue was modified externally
509
+ - [ ] Current state correctly detected from task sub-issue closure and summary comments
412
510
  - [ ] 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
511
+ - [ ] Plans discovered from GitHub comments and grouped by wave
512
+ - [ ] Per-plan execution delegates to execute-plan.md sub-workflow via Task with GitHub context
513
+ - [ ] Spot-check reads summary comments and checks sub-issue closure instead of local SUMMARY.md
416
514
  - [ ] Gate confirmation shown after execution completes
417
- - [ ] Auto-verification spawns verifier agent
515
+ - [ ] Auto-verification spawns verifier agent that posts to GitHub
516
+ - [ ] Phase issue moved to Done on verification pass
418
517
  - [ ] 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)
518
+ - [ ] Checkpoint-before-clear posts to GitHub issue
519
+ - [ ] No references to old SUMMARY.md local file checks for completion detection
421
520
  </success_criteria>
@@ -1,5 +1,5 @@
1
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.
2
+ Auto-detect project state through live GitHub queries, surface problems proactively, and dispatch to the appropriate MAXSIM command. Uses the Show + Act pattern: display detection reasoning first, then act immediately.
3
3
  </purpose>
4
4
 
5
5
  <required_reading>
@@ -30,19 +30,24 @@ PLANNING_EXISTS=$(test -d .planning && echo "true" || echo "false")
30
30
 
31
31
  If `.planning/` does not exist, skip all other checks and go directly to the decision tree (Rule 1: No project found).
32
32
 
33
- **2. Load project state (if .planning/ exists):**
33
+ **2. Load local project context (always from local files per WIRE-02):**
34
34
  ```bash
35
- # State snapshot
35
+ # State snapshot (local)
36
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
37
  ```
41
38
 
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
39
+ Read local files for project context:
40
+ - `.planning/STATE.md` blockers, decisions, session continuity
41
+ - `.planning/ROADMAP.md` phase structure and phase ordering
42
+
43
+ **3. Live GitHub state (primary source — always-live, no cached state):**
44
+
45
+ Call `mcp_get_all_progress` to get current state of all phases from GitHub. Returns:
46
+ - `phase_number`, `title`, `issue_number`
47
+ - `total_tasks`, `completed_tasks`, `remaining_tasks`
48
+ - `status` (GitHub board column: To Do / In Progress / In Review / Done)
49
+
50
+ Call `mcp_detect_interrupted` to check for any phases that were interrupted mid-execution (e.g., agent was stopped while a task was marked in-flight).
46
51
 
47
52
  **4. Git context:**
48
53
  ```bash
@@ -52,20 +57,12 @@ GIT_STATUS=$(git status --porcelain 2>/dev/null | head -20)
52
57
  # Recent commits
53
58
  RECENT_COMMITS=$(git log --oneline -5 2>/dev/null)
54
59
  ```
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
60
  </step>
64
61
 
65
62
  <step name="problem_detection">
66
63
  **Phase 2: Problem Detection**
67
64
 
68
- Check for problems BEFORE suggesting any action. All problems are blocking -- no severity tiers.
65
+ Check for problems BEFORE suggesting any action. All problems are blocking no severity tiers.
69
66
 
70
67
  **Check each of these in order:**
71
68
 
@@ -78,7 +75,7 @@ If uncommitted changes exist in `.planning/`:
78
75
  ## Problem Detected
79
76
 
80
77
  **Issue:** Uncommitted changes in .planning/ directory
81
- **Impact:** State drift -- local planning files may diverge from team or lose work
78
+ **Impact:** State drift local planning files may diverge from team or lose work
82
79
  **Resolution:** Commit planning changes to preserve state
83
80
 
84
81
  **Files with changes:**
@@ -110,22 +107,18 @@ Resolve this before continuing. Options:
110
107
 
111
108
  Block until user responds.
112
109
 
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:
110
+ **3. Failed verification on GitHub**
111
+ Check if any phase issue has a verification comment with FAIL status (from live GitHub data via `mcp_get_all_progress` — look for phases stuck in "In Review" with a known failure, or check recent comments via `mcp_get_issue_detail` for the current phase issue):
119
112
  ```
120
113
  ## Problem Detected
121
114
 
122
115
  **Issue:** Phase verification failed
123
- **Phase:** {phase number and name}
124
- **Impact:** Phase is not verified as complete -- may have gaps
116
+ **Phase:** {phase number and name} (GitHub Issue #{issue_number})
117
+ **Impact:** Phase is not verified as complete may have gaps
125
118
  **Resolution:** Re-run verification or fix identified issues
126
119
 
127
120
  Resolve this before continuing. Options:
128
- 1. View verification results
121
+ 1. View verification results (check GitHub issue comments)
129
122
  2. Re-execute to fix issues
130
123
  3. Skip and continue anyway
131
124
  ```
@@ -142,6 +135,8 @@ Block until user responds.
142
135
 
143
136
  Apply rules in strict precedence order. The FIRST matching rule determines the action.
144
137
 
138
+ Use live GitHub data from `mcp_get_all_progress` and `mcp_detect_interrupted` (gathered in Phase 1) as the primary source of truth for phase state. Use local ROADMAP.md for phase ordering only.
139
+
145
140
  ```
146
141
  Rule 1: No .planning/ directory?
147
142
  -> Action: /maxsim:init
@@ -151,31 +146,35 @@ Rule 2: Has blockers in STATE.md? (not cleared in problem detection)
151
146
  -> Action: Surface blocker, suggest resolution
152
147
  -> Reasoning: "BLOCKED: {blocker text}"
153
148
 
154
- Rule 3: Active phase has plans but not all executed?
155
- -> Check: summaries < plans in current phase directory
149
+ Rule 3: Interrupted phase detected (from mcp_detect_interrupted)?
150
+ -> Action: /maxsim:execute {N}
151
+ -> Reasoning: "Phase {N} ({name}) was interrupted. Resuming execution."
152
+
153
+ Rule 4: Phase "In Progress" on GitHub board with incomplete tasks?
154
+ -> Check: mcp_get_all_progress returns a phase with status="In Progress" and remaining_tasks > 0
156
155
  -> Action: /maxsim:execute {N}
157
- -> Reasoning: "Phase {N} ({name}) has {X} plans, {Y} executed. Ready to continue."
156
+ -> Reasoning: "Phase {N} ({name}) has {remaining} tasks remaining. Ready to continue."
158
157
 
159
- Rule 4: Active phase needs planning? (no PLAN.md files)
160
- -> Check: no PLAN.md files in current phase directory
158
+ Rule 5: Phase "To Do" on GitHub board (not yet started)?
159
+ -> Check: mcp_get_all_progress returns the next unstarted phase (status="To Do")
161
160
  -> Action: /maxsim:plan {N}
162
161
  -> Reasoning: "Phase {N} ({name}) needs planning."
163
162
 
164
- Sub-check: Does CONTEXT.md exist?
163
+ Sub-check: Does local CONTEXT.md exist?
165
164
  -> If yes: "Discussion complete, ready for research + planning."
166
165
  -> If no: "Starting from discussion stage."
167
166
 
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})."
167
+ Rule 6: Current phase "In Review" on GitHub board?
168
+ -> Check: mcp_get_all_progress returns a phase with status="In Review"
169
+ -> Action: /maxsim:verify {N}
170
+ -> Reasoning: "Phase {N} ({name}) is awaiting verification."
172
171
 
173
- Rule 6: All phases complete?
174
- -> Check: all phases in roadmap have all plans executed
172
+ Rule 7: All phases "Done" on GitHub board?
173
+ -> Check: mcp_get_all_progress — all phases have status="Done"
175
174
  -> Action: /maxsim:progress
176
175
  -> Reasoning: "All phases complete. Milestone ready for review."
177
176
 
178
- Rule 7: None of the above?
177
+ Rule 8: None of the above?
179
178
  -> Action: Show interactive menu
180
179
  -> Reasoning: "Project state is ambiguous. Here are your options."
181
180
  ```
@@ -186,53 +185,55 @@ Rule 7: None of the above?
186
185
 
187
186
  Once a rule matches, display detection reasoning FIRST, then act immediately.
188
187
 
189
- **Format for auto-dispatch (Rules 1-6):**
188
+ **Format for auto-dispatch (Rules 1-7):**
190
189
 
191
190
  ```
192
191
  ## Detected: {summary of what was found}
193
192
 
194
193
  **Project:** {project name from PROJECT.md, or "New project"}
195
194
  **Milestone:** {milestone from ROADMAP.md, or "Not started"}
196
- **Current phase:** {phase N - name, or "None"}
197
- **Status:** {description of current state}
195
+ **Current phase:** {phase N - name, or "None"} (GitHub Issue #{issue_number})
196
+ **GitHub Status:** {board column from live mcp_get_all_progress data}
197
+ **Tasks:** {completed}/{total} complete
198
198
 
199
199
  **Action:** Running /maxsim:{command} {args}...
200
200
  ```
201
201
 
202
202
  Then immediately dispatch the command using the SlashCommand tool. The user can Ctrl+C if the detection is wrong.
203
203
 
204
- **Important:** Show the detection block, then dispatch. Do not ask for confirmation -- this is Show + Act, not Show + Ask.
204
+ **Important:** Show the detection block, then dispatch. Do not ask for confirmation this is Show + Act, not Show + Ask.
205
205
  </step>
206
206
 
207
207
  <step name="interactive_menu">
208
- **Phase 5: Interactive Menu (Rule 7 -- no obvious action)**
208
+ **Phase 5: Interactive Menu (Rule 8 no obvious action)**
209
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.
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 (use live GitHub data from mcp_get_all_progress).
211
211
 
212
212
  ```
213
213
  ## Project Status
214
214
 
215
215
  **Project:** {project name}
216
216
  **Milestone:** {milestone}
217
- **Progress:** {X}/{Y} phases complete
217
+ **GitHub Progress:** {X}/{Y} phases Done on board
218
218
 
219
219
  What would you like to do?
220
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
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
225
 
226
226
  Or describe what you'd like to do:
227
227
  ```
228
228
 
229
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)
230
+ - If phases are "In Progress" on GitHub: show execute options prominently
231
+ - If all phases are "Done" on GitHub: show `/maxsim:progress` (offers milestone completion)
232
232
  - If recent git activity suggests debugging: show `/maxsim:debug` prominently
233
- - If no phases exist: show `/maxsim:plan` prominently
233
+ - If no phases exist on board: show `/maxsim:plan` prominently
234
234
  - Always include `/maxsim:quick` as it is always relevant
235
235
  - Always include an open-ended fallback ("Or describe what you'd like to do")
236
+ - If GitHub not available (mcp calls fail): fall back to local ROADMAP analysis and note degraded mode
236
237
 
237
238
  Wait for user selection, then dispatch the chosen command.
238
239
  </step>
@@ -242,9 +243,12 @@ Wait for user selection, then dispatch the chosen command.
242
243
  <constraints>
243
244
  - Never ask for confirmation before dispatching (Show + Act, not Show + Ask)
244
245
  - Always surface problems BEFORE suggesting actions
245
- - All problems block -- no severity tiers, no "warnings"
246
- - No arguments accepted -- this is pure auto-detection
246
+ - All problems block no severity tiers, no "warnings"
247
+ - No arguments accepted this is pure auto-detection
247
248
  - No mention of old commands (plan-phase, execute-phase, etc.)
248
- - Keep initial feedback fast -- show "Analyzing..." before heavy operations
249
+ - Keep initial feedback fast show "Analyzing..." before heavy operations
250
+ - Primary source for phase state: live GitHub (mcp_get_all_progress, mcp_detect_interrupted)
251
+ - Local reads: STATE.md for blockers/decisions, ROADMAP.md for phase ordering only
249
252
  - If context gathering fails (tools not available, etc.), fall back to the interactive menu
250
253
  </constraints>
254
+ </output>