mindsystem-cc 4.0.0 → 4.0.2

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 (45) hide show
  1. package/README.md +246 -220
  2. package/agents/ms-debugger.md +2 -3
  3. package/agents/ms-verifier.md +4 -4
  4. package/bin/install.js +9 -1
  5. package/commands/ms/add-todo.md +1 -1
  6. package/commands/ms/audit-milestone.md +1 -1
  7. package/commands/ms/config.md +8 -10
  8. package/commands/ms/debug.md +1 -1
  9. package/commands/ms/design-phase.md +1 -1
  10. package/commands/ms/execute-phase.md +1 -1
  11. package/commands/ms/help.md +31 -22
  12. package/commands/ms/plan-phase.md +3 -17
  13. package/commands/ms/progress.md +9 -5
  14. package/commands/ms/research-phase.md +1 -1
  15. package/mindsystem/references/continuation-format.md +1 -1
  16. package/mindsystem/references/plan-format.md +1 -1
  17. package/mindsystem/references/plan-risk-assessment.md +1 -2
  18. package/mindsystem/references/routing/gap-closure-routing.md +44 -18
  19. package/mindsystem/templates/debug-subagent-prompt.md +0 -5
  20. package/mindsystem/workflows/adhoc.md +5 -4
  21. package/mindsystem/workflows/compound.md +2 -2
  22. package/mindsystem/workflows/discuss-phase.md +1 -1
  23. package/mindsystem/workflows/execute-phase.md +3 -37
  24. package/mindsystem/workflows/execute-plan.md +1 -1
  25. package/mindsystem/workflows/mockup-generation.md +1 -1
  26. package/mindsystem/workflows/plan-phase.md +3 -139
  27. package/package.json +5 -2
  28. package/scripts/ms-tools.py +202 -0
  29. package/commands/ms/check-phase.md +0 -134
  30. package/mindsystem/workflows/diagnose-issues.md +0 -238
  31. package/scripts/__pycache__/ms-tools.cpython-314.pyc +0 -0
  32. package/scripts/__pycache__/test_ms_tools.cpython-314-pytest-9.0.2.pyc +0 -0
  33. package/scripts/fixtures/scan-context/.planning/ROADMAP.md +0 -16
  34. package/scripts/fixtures/scan-context/.planning/adhoc/20260220-fix-token-SUMMARY.md +0 -12
  35. package/scripts/fixtures/scan-context/.planning/adhoc/20260225-refactor-api/adhoc-01-SUMMARY.md +0 -39
  36. package/scripts/fixtures/scan-context/.planning/config.json +0 -3
  37. package/scripts/fixtures/scan-context/.planning/debug/resolved/token-bug.md +0 -11
  38. package/scripts/fixtures/scan-context/.planning/knowledge/auth.md +0 -11
  39. package/scripts/fixtures/scan-context/.planning/phases/02-infra/02-1-SUMMARY.md +0 -20
  40. package/scripts/fixtures/scan-context/.planning/phases/04-setup/04-1-SUMMARY.md +0 -21
  41. package/scripts/fixtures/scan-context/.planning/phases/05-auth/05-1-SUMMARY.md +0 -28
  42. package/scripts/fixtures/scan-context/.planning/todos/add-logout.md +0 -10
  43. package/scripts/fixtures/scan-context/.planning/todos/done/setup-db.md +0 -10
  44. package/scripts/fixtures/scan-context/expected-output.json +0 -271
  45. package/scripts/test_ms_tools.py +0 -1701
@@ -12,7 +12,6 @@ You are a Mindsystem debugger. You investigate bugs using systematic scientific
12
12
  You are spawned by:
13
13
 
14
14
  - `/ms:debug` command (interactive debugging)
15
- - `diagnose-issues` workflow (parallel UAT diagnosis)
16
15
 
17
16
  Your job: Find the root cause through hypothesis testing, maintain debug file state, optionally fix and verify (depending on mode).
18
17
 
@@ -94,7 +93,7 @@ ls .planning/debug/*.md 2>/dev/null | grep -v resolved
94
93
  2. `mkdir -p .planning/debug`
95
94
  3. Read project context for frontmatter:
96
95
  ```bash
97
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
96
+ ms-tools config-get subsystems
98
97
  grep "^Phase:" .planning/STATE.md 2>/dev/null | head -1
99
98
  ```
100
99
  4. Create file with initial state including all 10 frontmatter fields:
@@ -368,7 +367,7 @@ Check for mode flags in prompt context:
368
367
  - Diagnose but don't fix
369
368
  - Stop after confirming root cause
370
369
  - Skip fix_and_verify step
371
- - Return root cause to caller (for plan-phase --gaps to handle)
370
+ - Return root cause to caller
372
371
 
373
372
  **goal: find_and_fix** (default)
374
373
  - Find root cause, then fix and verify
@@ -257,7 +257,7 @@ score = (verified_truths / total_truths)
257
257
 
258
258
  ## Step 9: Structure Gap Output (If Gaps Found)
259
259
 
260
- When gaps are found, structure them in YAML frontmatter for consumption by `/ms:plan-phase --gaps`. Use the `gaps:` format shown in the VERIFICATION.md template below.
260
+ When gaps are found, structure them in YAML frontmatter for gap triage. Use the `gaps:` format shown in the VERIFICATION.md template below.
261
261
 
262
262
  **Gap fields:** `truth` (observable truth that failed), `status` (failed | partial), `reason` (why it failed), `artifacts` (files with issues), `missing` (specific things to add/fix).
263
263
 
@@ -383,7 +383,7 @@ Consider `/ms:verify-work {phase}` to validate these through UAT.
383
383
  2. **{Truth 2}** — {reason}
384
384
  - Missing: {what needs to be added}
385
385
 
386
- Structured gaps in VERIFICATION.md frontmatter for `/ms:plan-phase --gaps`.
386
+ Structured gaps in VERIFICATION.md frontmatter for gap triage.
387
387
  ```
388
388
 
389
389
  </output>
@@ -396,7 +396,7 @@ Structured gaps in VERIFICATION.md frontmatter for `/ms:plan-phase --gaps`.
396
396
 
397
397
  **DO NOT skip key link verification.** This is where 80% of stubs hide. The pieces exist but aren't connected.
398
398
 
399
- **Structure gaps in YAML frontmatter.** The planner (`/ms:plan-phase --gaps`) creates plans from your analysis.
399
+ **Structure gaps in YAML frontmatter.** Gap triage routes gaps to the appropriate primitive based on scope analysis.
400
400
 
401
401
  **DO keep verification fast.** Use grep/file checks, not running the app. Goal is structural verification, not functional testing.
402
402
 
@@ -406,7 +406,7 @@ Structured gaps in VERIFICATION.md frontmatter for `/ms:plan-phase --gaps`.
406
406
 
407
407
  <success_criteria>
408
408
 
409
- - [ ] Gaps structured in YAML frontmatter (if gaps_found) — planner depends on this
409
+ - [ ] Gaps structured in YAML frontmatter (if gaps_found) — gap triage depends on this
410
410
  - [ ] Key links verified — not just artifact existence; this is where stubs hide
411
411
  - [ ] Artifacts checked at all three levels (exists → substantive → wired)
412
412
  - [ ] SUMMARY.md claims verified against actual code, not trusted
package/bin/install.js CHANGED
@@ -150,6 +150,10 @@ function isInteractive() {
150
150
  * @param {string} destPrefix - The destination prefix (e.g., 'commands/ms', 'agents')
151
151
  * @returns {Array<{relativePath: string, absolutePath: string}>}
152
152
  */
153
+ // Directories and file patterns excluded from installation
154
+ const EXCLUDED_DIRS = new Set(['.pytest_cache', '__pycache__', 'fixtures', 'node_modules', '.git', '.venv']);
155
+ const EXCLUDED_FILE_PATTERNS = [/^test_/, /\.test\./, /\.spec\./];
156
+
153
157
  function collectFiles(baseDir, currentDir, destPrefix) {
154
158
  const files = [];
155
159
  if (!fs.existsSync(currentDir)) {
@@ -158,13 +162,17 @@ function collectFiles(baseDir, currentDir, destPrefix) {
158
162
 
159
163
  const entries = fs.readdirSync(currentDir, { withFileTypes: true });
160
164
  for (const entry of entries) {
165
+ if (EXCLUDED_DIRS.has(entry.name)) {
166
+ continue;
167
+ }
168
+
161
169
  const absolutePath = path.join(currentDir, entry.name);
162
170
  const relativeToCurrent = path.relative(baseDir, absolutePath);
163
171
  const relativePath = path.join(destPrefix, relativeToCurrent);
164
172
 
165
173
  if (entry.isDirectory()) {
166
174
  files.push(...collectFiles(baseDir, absolutePath, destPrefix));
167
- } else {
175
+ } else if (!EXCLUDED_FILE_PATTERNS.some(p => p.test(entry.name))) {
168
176
  files.push({ relativePath, absolutePath });
169
177
  }
170
178
  }
@@ -58,7 +58,7 @@ Infer priority, estimate, and subsystem from description and conversation contex
58
58
  | L | 5 | Multi-file feature, new subsystem area |
59
59
  | XL | 8 | Cross-cutting concern, architectural change |
60
60
 
61
- **Subsystem:** Read `jq -r '.subsystems[]' .planning/config.json 2>/dev/null`. Match against description and conversation context. Must match config.json vocabulary.
61
+ **Subsystem:** Read `ms-tools config-get subsystems`. Match against description and conversation context. Must match config.json vocabulary.
62
62
  </step>
63
63
 
64
64
  <step name="confirm">
@@ -191,7 +191,7 @@ Route by status (see `<offer_next>`).
191
191
  Read code review agent from config:
192
192
 
193
193
  ```bash
194
- CODE_REVIEW=$(cat .planning/config.json 2>/dev/null | jq -r '.code_review.milestone // empty')
194
+ CODE_REVIEW=$(ms-tools config-get code_review.milestone)
195
195
  ```
196
196
 
197
197
  **If CODE_REVIEW = "skip":**
@@ -76,12 +76,10 @@ If "Custom": use AskUserQuestion for each tier (adhoc, phase, milestone) individ
76
76
 
77
77
  If "Skip code review": set all three values to `"skip"`.
78
78
 
79
- Update config.json with selected values via jq:
79
+ Update config.json:
80
80
 
81
81
  ```bash
82
- jq '.code_review = {"adhoc": $a, "phase": $p, "milestone": $m}' \
83
- --arg a "$ADHOC" --arg p "$PHASE" --arg m "$MILESTONE" \
84
- .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
82
+ ms-tools config-set code_review --json '{"adhoc": "'"$ADHOC"'", "phase": "'"$PHASE"'", "milestone": "'"$MILESTONE"'"}'
85
83
  ```
86
84
 
87
85
  </step>
@@ -119,7 +117,7 @@ If no selections: skip gitignore changes.
119
117
  Read current value:
120
118
 
121
119
  ```bash
122
- CURRENT=$(cat .planning/config.json 2>/dev/null | jq -r '.open_mockups // "auto"')
120
+ CURRENT=$(ms-tools config-get open_mockups --default "auto")
123
121
  echo "Current open_mockups: $CURRENT"
124
122
  ```
125
123
 
@@ -136,10 +134,10 @@ Map selection to config value:
136
134
  - "Ask first" → `"ask"`
137
135
  - "Don't open" → `"off"`
138
136
 
139
- Update config.json with selected value via jq:
137
+ Update config.json:
140
138
 
141
139
  ```bash
142
- jq --arg v "$VALUE" '.open_mockups = $v' .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
140
+ ms-tools config-set open_mockups "$VALUE"
143
141
  ```
144
142
 
145
143
  </step>
@@ -149,7 +147,7 @@ jq --arg v "$VALUE" '.open_mockups = $v' .planning/config.json > .planning/confi
149
147
  Read current value:
150
148
 
151
149
  ```bash
152
- CURRENT=$(cat .planning/config.json 2>/dev/null | jq -r '.task_tracker.type // "not configured"')
150
+ CURRENT=$(ms-tools config-get task_tracker.type --default "not configured")
153
151
  echo "Current task_tracker: $CURRENT"
154
152
  ```
155
153
 
@@ -175,13 +173,13 @@ If "Custom path": ask user for path via AskUserQuestion.
175
173
  Write to config.json:
176
174
 
177
175
  ```bash
178
- jq '.task_tracker = {"type": "linear", "cli": $cli}' --arg cli "$CLI_PATH" .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
176
+ ms-tools config-set task_tracker --json '{"type": "linear", "cli": "'"$CLI_PATH"'"}'
179
177
  ```
180
178
 
181
179
  If "None / not yet":
182
180
 
183
181
  ```bash
184
- jq '.task_tracker = null' .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
182
+ ms-tools config-delete task_tracker
185
183
  ```
186
184
 
187
185
  </step>
@@ -93,7 +93,7 @@ Task(
93
93
  - Display root cause and evidence summary
94
94
  - Offer options:
95
95
  - "Fix now" — spawn ms-debugger with `goal: find_and_fix` and the debug file
96
- - "Plan fix" — suggest /ms:plan-phase --gaps
96
+ - "Plan fix" — suggest `/ms:adhoc` for small fixes, `/ms:insert-phase` for larger scope
97
97
  - "Done" — leave the diagnosis
98
98
 
99
99
  **If `## CHECKPOINT REACHED`:**
@@ -132,7 +132,7 @@ If exists, extract:
132
132
  Match subsystem(s) to this phase by comparing ROADMAP phase description against subsystem names in config.json. Load matching knowledge files:
133
133
 
134
134
  ```bash
135
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
135
+ ms-tools config-get subsystems
136
136
  cat .planning/knowledge/{matched_subsystem}.md 2>/dev/null
137
137
  ```
138
138
 
@@ -75,7 +75,7 @@ ms-tools find-phase "$ARGUMENTS"
75
75
  - Creates VERIFICATION.md with detailed report
76
76
  - Route by status:
77
77
  - `passed` → continue to step 7
78
- - `gaps_found` → present gaps, offer `/ms:plan-phase {X} --gaps`
78
+ - `gaps_found` → present gaps, route via gap-closure-routing.md triage
79
79
 
80
80
  7. **Code review (optional)**
81
81
  - Read `code_review.phase` from config.json (default: `ms-code-simplifier`)
@@ -61,13 +61,32 @@ Initialize → (Optional Research) → Roadmap → Plan → Execute → Verify
61
61
 
62
62
  Common deviations:
63
63
  - Existing repo: `/ms:map-codebase` after `/ms:new-project` (or before — either works)
64
- - Plan looks wrong: `/ms:discuss-phase <phase>` or `/ms:check-phase <phase>`
64
+ - Plan looks wrong: `/ms:discuss-phase <phase>`
65
65
  - Unknown domain: `/ms:research-project` or `/ms:research-phase <phase>`
66
66
  - Phase prep: `/ms:discuss-phase` → `/ms:design-phase` → `/ms:research-phase` → `/ms:plan-phase` (all optional before plan)
67
- - Execution gaps: `/ms:plan-phase <phase> --gaps` then `/ms:execute-phase <phase>`
68
67
  - New urgent work: `/ms:insert-phase <after> "<desc>"`
69
68
  - New non-urgent work: `/ms:add-todo "<desc>"`
70
69
 
70
+ ### Choosing the Right Command
71
+
72
+ **"I found something that needs fixing"**
73
+
74
+ | What you know | Best command | Why |
75
+ |--------------|-------------|-----|
76
+ | Quick fix, single context window | `/ms:adhoc` | Full pipeline (plan, execute, consolidate) in one session |
77
+ | Blocking — must happen before next phase | `/ms:insert-phase` | Creates decimal phase (e.g., 5.1) with full plan-execute cycle |
78
+ | Important but not urgent | `/ms:add-phase` | Appends to roadmap end, planned and executed in sequence |
79
+ | Just capture it for later | `/ms:add-todo` | Flat-file capture with priority and estimate |
80
+
81
+ **"I want to prepare before planning"**
82
+
83
+ | What you need | Best command |
84
+ |--------------|-------------|
85
+ | Align on vision, validate assumptions | `/ms:discuss-phase` |
86
+ | UI layouts, component specs, mockups | `/ms:design-phase` |
87
+ | Stack research, ecosystem knowledge | `/ms:research-phase` |
88
+ | All three (UI-heavy feature) | discuss, then design, then research, then plan |
89
+
71
90
  ### Project Initialization
72
91
 
73
92
  **`/ms:new-project`**
@@ -170,10 +189,10 @@ Comprehensive ecosystem research for niche/complex domains.
170
189
 
171
190
  Usage: `/ms:research-phase 3`
172
191
 
173
- **`/ms:plan-phase [number] [--gaps]`**
192
+ **`/ms:plan-phase [number]`**
174
193
  Create detailed execution plan for a specific phase.
175
194
 
176
- - Use when: you're about to start a phase, or you need additional plans (including verifier-driven gap closure via `--gaps`).
195
+ - Use when: you're about to start a phase.
177
196
  - Generates `.planning/phases/XX-phase-name/XX-YY-PLAN.md`
178
197
  - Breaks phase into concrete, actionable tasks
179
198
  - Includes verification criteria and success measures
@@ -202,16 +221,6 @@ Usage: `/ms:execute-phase 5`
202
221
 
203
222
  ### Verification
204
223
 
205
- **`/ms:check-phase <number>`**
206
- Verify phase plans before execution (optional quality gate).
207
-
208
- - Use when: the phase is complex or risky and you want a “will this actually achieve the goal?” sanity check before executing.
209
- - Spawns plan checker agent to analyze PLAN.md files
210
- - Checks requirement coverage, task completeness, dependencies
211
- - Use for complex phases before committing to execution
212
-
213
- Usage: `/ms:check-phase 5`
214
-
215
224
  **`/ms:verify-work [number]`**
216
225
  User acceptance testing of phase or plan.
217
226
 
@@ -479,11 +488,11 @@ Usage: `/ms:release-notes`
479
488
 
480
489
  ```
481
490
  /ms:plan-phase 5 # Create one or more PLAN.md files
482
- /ms:check-phase 5 # (optional) Sanity check: plans will achieve goal
483
491
  /ms:execute-phase 5 # Execute; produces SUMMARY + VERIFICATION
484
- # If gaps found during verification:
485
- /ms:plan-phase 5 --gaps # Create additional plans to close verifier gaps
486
- /ms:execute-phase 5 # Re-run until phase verifies cleanly
492
+ # If gaps found during verification, follow triage recommendation:
493
+ # Small gaps: /ms:adhoc "Close phase 5 gaps: ..."
494
+ # Larger gaps: /ms:insert-phase 5 "Close verification gaps"
495
+ # Minor polish: /ms:add-todo "Phase 5 polish: ..."
487
496
  ```
488
497
 
489
498
  **Found a bug:**
@@ -493,9 +502,9 @@ Usage: `/ms:release-notes`
493
502
  # Then decide where the fix belongs:
494
503
  # - If it fits in a single context window:
495
504
  /ms:adhoc "Fix auth token refresh on 401" # Knowledge-aware fix with consolidation
496
- # - If it's required to satisfy the current phase goal: add more plans to the current phase
497
- /ms:plan-phase 5 # (or: /ms:plan-phase 5 --gaps after verification)
498
- /ms:execute-phase 5
505
+ # - If it's required to satisfy the current phase goal:
506
+ /ms:adhoc "Fix auth token refresh on 401" # Small scope single context
507
+ /ms:insert-phase 5 "Close verification gaps" # Larger scope — full plan-execute cycle
499
508
  # - If it's urgent but should happen before the next phase (and not worth renumbering):
500
509
  /ms:insert-phase 5 "Fix critical auth bug" # Creates 05.1
501
510
  /ms:plan-phase 5.1
@@ -507,7 +516,7 @@ Usage: `/ms:release-notes`
507
516
  **Need to adjust scope (new info, new requirements, or a cut):**
508
517
 
509
518
  Common options:
510
- - If the current phase goal can’t be met: add more plans to the current phase (`/ms:plan-phase <current>` or `/ms:plan-phase <current> --gaps`) then `/ms:execute-phase <current>`
519
+ - If the current phase goal can’t be met: `/ms:adhoc` for small gaps, `/ms:insert-phase` for larger gaps, `/ms:add-todo` for minor polish
511
520
  - Add work later: `/ms:add-phase "…"`
512
521
  - Insert urgent work before the next phase: `/ms:insert-phase <after> "…"`
513
522
  - Cut future work: `/ms:remove-phase <phase>`
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ms:plan-phase
3
3
  description: Create detailed execution plan for a phase (PLAN.md)
4
- argument-hint: "[phase] [--gaps]"
4
+ argument-hint: "[phase]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Bash
@@ -21,8 +21,6 @@ Create executable phase prompt with discovery, context injection, and task break
21
21
  Purpose: Break down roadmap phases into concrete, executable PLAN.md files that Claude can execute.
22
22
  Output: One or more PLAN.md files in the phase directory (.planning/phases/XX-name/{phase}-{plan}-PLAN.md)
23
23
 
24
- **Gap closure mode (`--gaps` flag):**
25
- When invoked with `--gaps`, plans address gaps identified by the verifier. Load VERIFICATION.md, create plans to close specific gaps.
26
24
  </objective>
27
25
 
28
26
  <execution_context>
@@ -32,7 +30,6 @@ When invoked with `--gaps`, plans address gaps identified by the verifier. Load
32
30
 
33
31
  <context>
34
32
  Phase number: $ARGUMENTS (optional - auto-detects next unplanned phase if not provided)
35
- Gap closure mode: `--gaps` flag triggers gap closure workflow
36
33
 
37
34
  **Resolve phase if provided:**
38
35
  ```bash
@@ -76,17 +73,14 @@ Check for and read `.planning/TECH-DEBT.md` — prioritized issues for scope sel
76
73
  **Load codebase context if exists:**
77
74
  Check for `.planning/codebase/` and load relevant documents based on phase type.
78
75
 
79
- **If --gaps flag present, also load:**
80
- @.planning/phases/XX-name/{phase}-VERIFICATION.md — contains structured gaps in YAML frontmatter
81
76
  </context>
82
77
 
83
78
  <process>
84
79
  1. Check .planning/ directory exists (error if not - user should run /ms:new-project)
85
- 2. Parse arguments: extract phase number and check for `--gaps` flag
80
+ 2. Parse arguments: extract phase number
86
81
  3. If phase number provided, validate it exists in roadmap
87
82
  4. If no phase number, detect next unplanned phase from roadmap
88
83
 
89
- **Standard mode (no --gaps flag):**
90
84
  5. Follow plan-phase.md workflow:
91
85
  - Load project state and accumulated decisions
92
86
  - Perform mandatory discovery (Level 0-3 as appropriate)
@@ -97,17 +91,9 @@ Check for `.planning/codebase/` and load relevant documents based on phase type.
97
91
  - Hand off tasks + proposed grouping + confirmed skills to plan-writer subagent
98
92
  - Create PLAN.md file(s) with executable structure
99
93
 
100
- **Gap closure mode (--gaps flag):**
101
- 5. Follow plan-phase.md workflow with gap_closure_mode:
102
- - Load VERIFICATION.md and parse `gaps:` YAML from frontmatter
103
- - Read existing SUMMARYs to understand what's already built
104
- - Create tasks from gaps (each gap.missing item → task candidates)
105
- - Number plans sequentially after existing (if 01-03 exist, create 04, 05...)
106
- - Create PLAN.md file(s) focused on closing specific gaps
107
-
108
94
  6. **Update last command:** `ms-tools set-last-command "ms:plan-phase $ARGUMENTS"`
109
95
 
110
- 7. **Risk assessment** (skip if `--gaps` flag present)
96
+ 7. **Risk assessment**
111
97
  - Calculate risk score from context already loaded (task count, plan count, external services, CONTEXT.md, cross-cutting concerns, new deps, complex domains)
112
98
  - Present score + top factors via AskUserQuestion
113
99
  - Tier-based recommendation: Skip (0-39), Optional (40-69), Verify (70+)
@@ -155,23 +155,27 @@ ms-tools list-artifacts [current-phase-number]
155
155
 
156
156
  State: "This phase has {X} plans, {Y} summaries."
157
157
 
158
- **Step 1.5: Check for unaddressed UAT gaps**
158
+ **Step 1.5: Check for unaddressed gaps**
159
159
 
160
- Check for UAT.md files with status "diagnosed" (has gaps needing fixes).
160
+ Check for VERIFICATION.md with gaps or UAT.md with diagnosed gaps.
161
161
 
162
162
  ```bash
163
+ # Check for verification gaps
164
+ grep -l "status: gaps_found" .planning/phases/[current-phase-dir]/*-VERIFICATION.md 2>/dev/null
165
+
163
166
  # Check for diagnosed UAT with gaps
164
167
  grep -l "status: diagnosed" .planning/phases/[current-phase-dir]/*-UAT.md 2>/dev/null
165
168
  ```
166
169
 
167
170
  Track:
171
+ - `verification_gaps`: VERIFICATION.md files with status "gaps_found"
168
172
  - `uat_with_gaps`: UAT.md files with status "diagnosed" (gaps need fixing)
169
173
 
170
174
  **Step 2: Route based on counts**
171
175
 
172
176
  | Condition | Meaning | Action |
173
177
  |-----------|---------|--------|
174
- | uat_with_gaps > 0 | UAT gaps need fix plans | Go to **Route E** |
178
+ | verification_gaps > 0 OR uat_with_gaps > 0 | Gaps need resolution | Go to **Route E** |
175
179
  | summaries < plans | Unexecuted plans exist | Go to **Route A** |
176
180
  | summaries = plans AND plans > 0 | Phase complete | Go to Step 3 |
177
181
  | plans = 0 | Phase not yet planned | Go to **Route B** |
@@ -246,9 +250,9 @@ Check if `{phase}-CONTEXT.md` exists in phase directory.
246
250
 
247
251
  ---
248
252
 
249
- **Route E: UAT gaps need fix plans**
253
+ **Route E: Verification or UAT gaps need resolution**
250
254
 
251
- UAT.md exists with gaps (diagnosed issues). Read `~/.claude/mindsystem/references/routing/gap-closure-routing.md` and follow its instructions to present the gap closure section.
255
+ VERIFICATION.md or UAT.md exists with gaps. Read `~/.claude/mindsystem/references/routing/gap-closure-routing.md` and follow its triage instructions to present gap summary and route to the appropriate primitive.
252
256
 
253
257
  ---
254
258
 
@@ -69,7 +69,7 @@ cat .planning/phases/${PHASE}-*/${PHASE}-DESIGN.md 2>/dev/null
69
69
  grep -A30 "### Decisions Made" .planning/STATE.md 2>/dev/null
70
70
 
71
71
  # Prior knowledge — match subsystem(s) by comparing phase description against config.json names
72
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
72
+ ms-tools config-get subsystems
73
73
  cat .planning/knowledge/{matched_subsystem}.md 2>/dev/null
74
74
  ```
75
75
 
@@ -33,7 +33,7 @@ When there's meaningful additional context (like a phase identifier), add it as
33
33
  ## Format Rules
34
34
 
35
35
  1. **Command is the anchor** — backtick command + description on one line, no separate bold label restating the command name
36
- 2. **Phase identifiers are additive context** — `**Phase 2: Auth**` carries info the command doesn't; bold labels like `**Plan gap closure**` just restate `/ms:plan-phase --gaps` and should be omitted
36
+ 2. **Phase identifiers are additive context** — `**Phase 2: Auth**` carries info the command doesn't; bold labels that just restate the command name should be omitted
37
37
  3. **Pull context from source** — ROADMAP.md for phases, PLAN.md `<objective>` for plans
38
38
  4. **Command in inline code** — backticks, easy to copy-paste, renders as clickable link
39
39
  5. **`/clear` explanation** — always include, keeps it concise but explains why
@@ -195,7 +195,7 @@ Execution order lives in a single `EXECUTION-ORDER.md` file alongside the plans.
195
195
  |----------|--------|
196
196
  | How does the verifier find must-haves? | Reads `## Must-Haves` section |
197
197
  | How does the executor know the subsystem? | Reads inline metadata (`**Subsystem:**`) |
198
- | How does the plan-checker validate plans? | Reads EXECUTION-ORDER.md + plan structure |
198
+ | How is plan verification done? | Reads EXECUTION-ORDER.md + plan structure |
199
199
  | What triggers TDD lazy-loading? | `**Type:** tdd` in inline metadata |
200
200
  | How does the executor know why an approach was chosen? | Reads `## Context` section |
201
201
  | How does the executor find existing utilities? | Reads `**Files:**` lines and inline references in `## Changes` |
@@ -2,14 +2,13 @@
2
2
  Optional verification step for plan-phase workflow. Calculates risk score from already-loaded context and prompts user to verify or skip.
3
3
 
4
4
  <purpose>
5
- Provide lightweight risk assessment after plan creation to help users decide whether to run the ms-plan-checker before execution.
5
+ Provide lightweight risk assessment after plan creation to help users decide whether to run plan verification before execution.
6
6
 
7
7
  **Key principle:** All information is already in context from earlier workflow steps. No additional file reads or subagent spawns needed for scoring.
8
8
  </purpose>
9
9
 
10
10
  <skip_conditions>
11
11
  Skip risk assessment entirely when:
12
- - `--gaps` flag present (gap closure plans don't need risk assessment)
13
12
  - Zero plans created (error state)
14
13
  </skip_conditions>
15
14
 
@@ -1,10 +1,10 @@
1
1
  # Gap Closure Routing
2
2
 
3
- Reference for presenting "Next Up" guidance when phase verification found gaps. Used by execute-phase and progress commands.
3
+ Reference for triaging verification and UAT gaps by scope and routing to the appropriate primitive. Used by execute-phase and progress commands.
4
4
 
5
5
  ## Purpose
6
6
 
7
- Guide user toward planning gap closure when VERIFICATION.md reports gaps.
7
+ Analyze VERIFICATION.md or UAT.md gaps and recommend the best primitive based on scope and urgency.
8
8
 
9
9
  ## Variables
10
10
 
@@ -14,22 +14,42 @@ From calling context:
14
14
  - `{N}/{M}` — must-haves score from VERIFICATION.md
15
15
  - `{phase_dir}` — phase directory path
16
16
  - `{phase}` — phase identifier (e.g., "04")
17
- - `{gap_summaries}` — extracted gap summaries from VERIFICATION.md
18
17
 
19
18
  ## Information to Extract
20
19
 
21
- Read VERIFICATION.md for the phase:
20
+ Read the gap source for the phase (one or both may exist):
22
21
 
23
22
  ```bash
24
- cat .planning/phases/${phase_dir}/${phase}-VERIFICATION.md
23
+ # Code verification gaps
24
+ cat .planning/phases/${phase_dir}/${phase}-VERIFICATION.md 2>/dev/null
25
+
26
+ # User testing gaps (status: diagnosed means root causes identified)
27
+ cat .planning/phases/${phase_dir}/${phase}-UAT.md 2>/dev/null
25
28
  ```
26
29
 
27
- Extract:
28
- - Score (must-haves verified count)
30
+ Extract from whichever exists (combine if both present):
31
+ - Score (must-haves verified count, from VERIFICATION.md)
32
+ - Gap count and severity (critical vs non-critical)
29
33
  - Gap summaries from gaps section
30
34
 
35
+ ## Triage Table
36
+
37
+ | Scope | Criteria | Route | Rationale |
38
+ |-------|----------|-------|-----------|
39
+ | Small | 1-2 gaps, localized files, quick fixes | `/ms:adhoc` | Single context window, no multi-plan overhead |
40
+ | Larger (blocking) | 3+ gaps OR cross-cutting, blocks next phase | `/ms:insert-phase` | Needs full plan-execute cycle, preserves phase numbering |
41
+ | Larger (non-blocking) | 3+ gaps OR cross-cutting, next phase can proceed | `/ms:add-phase` | Defers to end of milestone, no urgency |
42
+ | Minor | Cosmetic, non-functional, polish items | `/ms:add-todo` | Capture for later, not worth planning now |
43
+
44
+ **Judgment calls:**
45
+ - If all gaps share the same root cause, treat as small regardless of count
46
+ - If gaps span multiple subsystems, prefer insert-phase even if count is low
47
+ - Mix routes when gaps vary: adhoc for quick wins + insert-phase for larger items
48
+
31
49
  ## Output Format
32
50
 
51
+ Present gap summary, then route recommendation using standard "Next Up" format:
52
+
33
53
  ```markdown
34
54
  ---
35
55
 
@@ -46,7 +66,21 @@ Extract:
46
66
 
47
67
  ## ▶ Next Up
48
68
 
49
- `/ms:plan-phase {Z} --gaps` create additional plans to complete the phase
69
+ {Primary recommendation based on triage:}
70
+
71
+ {If adhoc:}
72
+ `/ms:adhoc "Close phase {Z} gaps: {brief description}"` — fix {N} localized gaps in a single context
73
+
74
+ <sub>Reference: `.planning/phases/{phase_dir}/{phase}-VERIFICATION.md`</sub>
75
+
76
+ {If insert-phase:}
77
+ `/ms:insert-phase {Z} "Close verification gaps"` — plan and execute gap closure as phase {Z}.1
78
+
79
+ {If add-phase:}
80
+ `/ms:add-phase "Close phase {Z} verification gaps"` — defer gap closure to end of milestone
81
+
82
+ {If add-todo:}
83
+ `/ms:add-todo "Phase {Z} polish: {brief description}"` — capture for later
50
84
 
51
85
  <sub>`/clear` first → fresh context window</sub>
52
86
 
@@ -54,16 +88,8 @@ Extract:
54
88
 
55
89
  **Also available:**
56
90
  - `cat .planning/phases/{phase_dir}/{phase}-VERIFICATION.md` — see full report
57
- - `/ms:verify-work {Z}` — manual testing before planning
91
+ - `/ms:verify-work {Z}` — manual testing before fixing
92
+ {Include other routes not chosen as alternatives}
58
93
 
59
94
  ---
60
95
  ```
61
-
62
- ## Gap Closure Flow
63
-
64
- After user runs `/ms:plan-phase {Z} --gaps`:
65
- 1. Planner reads VERIFICATION.md gaps
66
- 2. Creates plans 04, 05, etc. to close gaps
67
- 3. User runs `/ms:execute-phase {Z}` again
68
- 4. Execute-phase runs incomplete plans (04, 05...)
69
- 5. Verifier runs again — loop until passed
@@ -60,11 +60,6 @@ Task(
60
60
  )
61
61
  ```
62
62
 
63
- **From diagnose-issues (UAT):**
64
- ```python
65
- Task(prompt=template, subagent_type="ms-debugger", description="Debug UAT-001")
66
- ```
67
-
68
63
  ---
69
64
 
70
65
  ## Continuation
@@ -38,8 +38,8 @@ Read STATE.md for project context (current phase, accumulated decisions, blocker
38
38
  **Ticket detection:** Check `task_tracker` in config.json. If configured and `$ARGUMENTS` matches the ticket ID pattern, lazy-load `~/.claude/mindsystem/references/{type}-cli.md` and follow its **Ticket Detection** process. If no tracker configured or no match, proceed with `$ARGUMENTS` as free-text.
39
39
 
40
40
  ```bash
41
- TRACKER_TYPE=$(jq -r '.task_tracker.type // empty' .planning/config.json 2>/dev/null)
42
- TRACKER_CLI=$(jq -r '.task_tracker.cli // empty' .planning/config.json 2>/dev/null)
41
+ TRACKER_TYPE=$(ms-tools config-get task_tracker.type)
42
+ TRACKER_CLI=$(ms-tools config-get task_tracker.cli)
43
43
  ```
44
44
 
45
45
  **Todo detection:** If `$ARGUMENTS` matches a `.planning/todos/*.md` file path and the file exists, lazy-load `~/.claude/mindsystem/references/todo-file.md` and follow its **Todo Detection** process. Todo detection is independent of ticket detection — both can be inactive.
@@ -50,7 +50,7 @@ Read subsystems and match knowledge files to work description:
50
50
 
51
51
  ```bash
52
52
  # Read subsystems from config
53
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
53
+ ms-tools config-get subsystems
54
54
  ```
55
55
 
56
56
  Match keywords from work description against subsystem names. Read matching `.planning/knowledge/*.md` files (1-3 most relevant).
@@ -152,7 +152,8 @@ The executor reads the plan, executes tasks with atomic commits, creates SUMMARY
152
152
  Read code review agent from config:
153
153
 
154
154
  ```bash
155
- CODE_REVIEW=$(cat .planning/config.json 2>/dev/null | jq -r '.code_review.adhoc // .code_review.phase // empty')
155
+ CODE_REVIEW=$(ms-tools config-get code_review.adhoc)
156
+ [ -z "$CODE_REVIEW" ] && CODE_REVIEW=$(ms-tools config-get code_review.phase)
156
157
  ```
157
158
 
158
159
  **If CODE_REVIEW = "skip":** Skip to generate_patch.
@@ -55,7 +55,7 @@ Thoroughness: "medium".
55
55
  Read config.json subsystems and match changes:
56
56
 
57
57
  ```bash
58
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
58
+ ms-tools config-get subsystems
59
59
  ```
60
60
 
61
61
  **Git/file mode:** Match file paths from diff stats against subsystem names via keyword matching.
@@ -94,7 +94,7 @@ Agent reads changes, reads affected knowledge files, writes updates, returns rep
94
94
  **Update config.json** (if new subsystems were confirmed in step 4):
95
95
  ```bash
96
96
  # Add new subsystem to config.json
97
- jq '.subsystems += ["new-subsystem"]' .planning/config.json > tmp.$$.json && mv tmp.$$.json .planning/config.json
97
+ ms-tools config-set subsystems --append "new-subsystem"
98
98
  ```
99
99
 
100
100
  **Commit changes:**
@@ -57,7 +57,7 @@ Load milestone artifacts and prior knowledge. Handle gracefully when any file is
57
57
  cat .planning/PROJECT.md 2>/dev/null
58
58
  cat .planning/MILESTONE-CONTEXT.md 2>/dev/null
59
59
  cat .planning/REQUIREMENTS.md 2>/dev/null
60
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
60
+ ms-tools config-get subsystems
61
61
  grep -A20 "Phase ${PHASE}:" .planning/ROADMAP.md
62
62
  ```
63
63