mindsystem-cc 3.18.1 → 3.20.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.
@@ -8,19 +8,19 @@ allowed-tools:
8
8
  - Bash
9
9
  - Glob
10
10
  - Grep
11
+ - Task
11
12
  - AskUserQuestion
12
13
  ---
13
14
 
14
15
  <objective>
15
- Run health checks on project configuration. Detect and fix configuration issues.
16
-
17
- V1 check: subsystem vocabulary setup and validation. Ensures `.planning/config.json` has a canonical `subsystems` array and all artifacts use values from it.
16
+ Run comprehensive health checks on project configuration. Detect and fix structural drift across 6 categories: subsystem vocabulary, milestone directory structure, phase archival, knowledge files, phase summaries, and PLAN cleanup.
18
17
 
19
18
  Idempotent — safe to run repeatedly.
20
19
  </objective>
21
20
 
22
21
  <context>
23
22
  @.planning/config.json
23
+ @.planning/MILESTONES.md
24
24
  </context>
25
25
 
26
26
  <process>
@@ -64,55 +64,98 @@ Write to `.planning/config.json`. Log: "Created config.json with empty subsystem
64
64
  Proceed to next step.
65
65
  </step>
66
66
 
67
- <step name="read_current_subsystems">
67
+ <step name="run_scan">
68
+ Run the diagnostic scan:
69
+
68
70
  ```bash
69
- jq -r '.subsystems // [] | length' .planning/config.json
71
+ ~/.claude/mindsystem/scripts/doctor-scan.sh
70
72
  ```
71
73
 
72
- - If 0 **State A**: no subsystems configured. Go to `audit_existing_usage`.
73
- - If >0 → **State B**: subsystems exist. Go to `validate_vocabulary`.
74
+ Capture the full output. Parse each check's Status (PASS/FAIL/SKIP) and detail lines.
75
+ </step>
76
+
77
+ <step name="present_results">
78
+ Display results as a markdown table:
79
+
80
+ ```
81
+ ## Doctor Report
82
+
83
+ | Check | Result | Details |
84
+ |--------------------------|--------|----------------------------------|
85
+ | Subsystem vocabulary | PASS | 9 subsystems, all artifacts OK |
86
+ | Milestone directories | FAIL | 2 flat files need restructuring |
87
+ | Phase archival | FAIL | 8 orphaned phase directories |
88
+ | Knowledge files | FAIL | Directory missing |
89
+ | Phase summaries | FAIL | 2 milestones missing summaries |
90
+ | PLAN cleanup | FAIL | 9 leftover PLAN.md files |
91
+ ```
92
+
93
+ Populate Result and Details from scan output. Use concise detail summaries.
94
+
95
+ If all PASS → go to `report`.
96
+ If any FAIL → go to `confirm_action`.
74
97
  </step>
75
98
 
76
- <step name="audit_existing_usage">
77
- **State A only.** Scan all artifact types for existing free-form `subsystem:` values.
99
+ <step name="confirm_action">
100
+ Use AskUserQuestion:
101
+ - header: "Fix issues"
102
+ - question: "How would you like to handle the failed checks?"
103
+ - options:
104
+ - "Fix all" — apply all fixes in dependency order
105
+ - "Review each" — present each failed check individually for decision
106
+ - "Skip" — leave as-is, report only
107
+
108
+ If "Skip" → go to `report`.
109
+
110
+ If "Review each" → use AskUserQuestion for each failed check with its details and options: "Fix" / "Skip". Only run fixes for accepted checks.
111
+
112
+ Apply fixes in dependency order: fix_subsystems → fix_milestone_dirs → fix_phase_archival → fix_plan_cleanup → fix_knowledge. Skip any fix whose check passed or was skipped by user.
113
+ </step>
114
+
115
+ <step name="fix_subsystems">
116
+ **Only if Subsystem Vocabulary failed.**
117
+
118
+ If subsystems array is empty (State A):
119
+
120
+ 1. Scan all artifacts for existing values:
78
121
 
79
122
  ```bash
80
123
  ~/.claude/mindsystem/scripts/scan-artifact-subsystems.sh --values-only
81
124
  ```
82
125
 
83
- Collect all unique values found. Note count of artifacts scanned and values found.
84
- </step>
126
+ 2. Read `.planning/PROJECT.md` and `.planning/ROADMAP.md`.
85
127
 
86
- <step name="derive_and_confirm">
87
- **State A only.** Read `.planning/PROJECT.md` and `.planning/ROADMAP.md`.
128
+ 3. Derive 5-12 canonical subsystem identifiers from:
129
+ - Unique values found in artifacts
130
+ - Project domain from PROJECT.md
131
+ - Phase structure from ROADMAP.md
88
132
 
89
- Derive 5-12 canonical subsystem identifiers from:
133
+ Rules:
134
+ - Lowercase, single-word or hyphenated (e.g., "auth", "real-time", "ui")
135
+ - Merge synonyms into one canonical value (pick shortest/most common)
136
+ - Cover all existing usage plus obvious gaps
137
+ - Include infrastructure-level subsystems if relevant (api, database, infra, testing)
90
138
 
91
- 1. Unique values found in `audit_existing_usage`
92
- 2. Project domain from PROJECT.md
93
- 3. Phase structure from ROADMAP.md
139
+ 4. Present the proposed list with merge mappings (e.g., "authentication" -> "auth").
94
140
 
95
- Rules:
96
- - Lowercase, single-word or hyphenated (e.g., "auth", "real-time", "ui")
97
- - Merge synonyms into one canonical value (pick shortest/most common)
98
- - Cover all existing usage plus obvious gaps
99
- - Include infrastructure-level subsystems if relevant (api, database, infra, testing)
141
+ 5. Use AskUserQuestion:
142
+ - header: "Subsystems"
143
+ - question: "These subsystems were derived from your project. Look good?"
144
+ - options:
145
+ - "Looks good" accept and apply
146
+ - "Add/remove some" — iterate on the list
147
+ - "Start over" — re-derive from scratch
100
148
 
101
- Present the proposed list with merge mappings (e.g., "authentication" -> "auth").
149
+ 6. After confirmation: update `config.json` (subsystems as first field), standardize existing artifact `subsystem:` fields using Edit tool.
102
150
 
103
- Use AskUserQuestion:
104
- - header: "Subsystems"
105
- - question: "These subsystems were derived from your project. Look good?"
106
- - options:
107
- - "Looks good" — accept and apply
108
- - "Add/remove some" — iterate on the list
109
- - "Start over" — re-derive from scratch
151
+ If subsystems exist but artifacts have mismatches (State B):
110
152
 
111
- After confirmation:
153
+ 1. Classify each artifact as OK/MISMATCH/MISSING.
154
+ 2. For MISMATCH: propose closest canonical value.
155
+ 3. For MISSING: propose based on artifact content/path.
156
+ 4. Apply fixes using Edit tool.
112
157
 
113
- 1. Update `config.json` — set `subsystems` array as first field
114
- 2. If existing artifacts had free-form values, standardize each `subsystem:` field to the canonical value using the Edit tool (only modify the `subsystem:` line, never body content)
115
- 3. Commit all changes:
158
+ Commit:
116
159
 
117
160
  ```bash
118
161
  git add .planning/config.json
@@ -126,99 +169,184 @@ git add .planning/todos/done/*.md 2>/dev/null
126
169
 
127
170
  ```bash
128
171
  git commit -m "$(cat <<'EOF'
129
- chore: initialize subsystem vocabulary
172
+ chore(doctor): fix subsystem vocabulary
130
173
 
131
- Added subsystems array to config.json and standardized existing artifact values.
174
+ Standardized subsystem configuration and artifact values.
132
175
  EOF
133
176
  )"
134
177
  ```
135
178
  </step>
136
179
 
137
- <step name="validate_vocabulary">
138
- **State B only.** Read canonical list from config.json:
180
+ <step name="fix_milestone_dirs">
181
+ **Only if Milestone Directory Structure failed.**
182
+
183
+ For each flat file like `milestones/v0.1-ROADMAP.md`:
184
+
185
+ 1. Extract version prefix (e.g., `v0.1`).
186
+ 2. Create versioned directory if it doesn't exist: `mkdir -p .planning/milestones/v0.1`
187
+ 3. `git mv` the file, stripping the version prefix from the filename:
188
+ `git mv .planning/milestones/v0.1-ROADMAP.md .planning/milestones/v0.1/ROADMAP.md`
189
+
190
+ Commit:
191
+
192
+ ```bash
193
+ git add .planning/milestones/
194
+ ```
195
+
196
+ ```bash
197
+ git commit -m "$(cat <<'EOF'
198
+ chore(doctor): restructure milestone directories
199
+
200
+ Moved flat milestone files into versioned directories.
201
+ EOF
202
+ )"
203
+ ```
204
+ </step>
205
+
206
+ <step name="fix_phase_archival">
207
+ **Only if Phase Archival failed.**
208
+
209
+ Parse MILESTONES.md for completed milestones and their phase ranges (`**Phases completed:** X-Y`).
210
+
211
+ For each completed milestone with orphaned phases in `.planning/phases/`:
212
+
213
+ 1. Determine the version and phase range from MILESTONES.md.
214
+ 2. Ensure the milestone directory exists: `mkdir -p .planning/milestones/{version}`
215
+ 3. Run the archive script:
216
+
217
+ ```bash
218
+ ~/.claude/mindsystem/scripts/archive-milestone-phases.sh <start> <end> <version>
219
+ ```
220
+
221
+ This simultaneously:
222
+ - Consolidates PHASE-SUMMARIES.md (fixes Phase Summaries check)
223
+ - Deletes raw artifacts (CONTEXT, DESIGN, RESEARCH, SUMMARY, UAT, VERIFICATION)
224
+ - Moves phase directories to milestone archive
225
+
226
+ **If MILESTONES.md doesn't have parseable phase ranges:** Use AskUserQuestion to ask the user for the phase range for each milestone.
227
+
228
+ After archive completes, clean up leftover PLAN files in archived phases (fixes PLAN Cleanup check):
139
229
 
140
230
  ```bash
141
- jq -r '.subsystems[]' .planning/config.json
231
+ find .planning/milestones/*/phases/ -name "*-PLAN.md" -delete 2>/dev/null
142
232
  ```
143
233
 
144
- Scan all artifacts for `subsystem:` values. Extract from YAML frontmatter:
234
+ Commit:
145
235
 
146
236
  ```bash
147
- ~/.claude/mindsystem/scripts/scan-artifact-subsystems.sh
237
+ git add .planning/phases/ .planning/milestones/
238
+ ```
239
+
240
+ ```bash
241
+ git commit -m "$(cat <<'EOF'
242
+ chore(doctor): archive completed milestone phases
243
+
244
+ Consolidated summaries, deleted raw artifacts, moved phase directories.
245
+ EOF
246
+ )"
148
247
  ```
248
+ </step>
149
249
 
150
- Classify each artifact's `subsystem:` value:
151
- - **OK** value is in canonical list
152
- - **MISMATCH** — value exists but not in canonical list
153
- - **MISSING** — no `subsystem:` field found
250
+ <step name="fix_plan_cleanup">
251
+ **Only if PLAN Cleanup failed AND fix_phase_archival did not already handle it.**
154
252
 
155
- Display results grouped by status. If all OK:
253
+ Delete leftover PLAN files in completed phase directories:
156
254
 
255
+ ```bash
256
+ find .planning/milestones/*/phases/ -name "*-PLAN.md" -delete 2>/dev/null
157
257
  ```
158
- ## Subsystem Vocabulary
159
258
 
160
- PASS all N artifacts use canonical subsystem values.
259
+ For any leftover PLANs in `phases/` belonging to completed milestones (identified by the scan), delete those too.
260
+
261
+ Commit:
262
+
263
+ ```bash
264
+ git add .planning/
161
265
  ```
162
266
 
163
- Go to `report`.
267
+ ```bash
268
+ git commit -m "$(cat <<'EOF'
269
+ chore(doctor): clean up leftover PLAN files
164
270
 
165
- If MISMATCH or MISSING found, use AskUserQuestion:
166
- - header: "Fix issues"
167
- - question: "Found N issues (X mismatches, Y missing). How to proceed?"
168
- - options:
169
- - "Fix all" — apply best-match canonical values to all issues
170
- - "Review each" — present each issue individually for decision
171
- - "Skip" — leave as-is
271
+ Removed PLAN files from completed phase directories.
272
+ EOF
273
+ )"
274
+ ```
275
+ </step>
172
276
 
173
- For fixes:
174
- - MISMATCH: propose closest canonical value (fuzzy match on prefix/synonym)
175
- - MISSING: propose based on artifact content/path context
277
+ <step name="fix_knowledge">
278
+ **Only if Knowledge Files failed.**
176
279
 
177
- Apply fixes using Edit tool. Commit:
280
+ Spawn a `general-purpose` subagent (Task tool) to generate knowledge files retroactively. Provide the subagent with:
281
+
282
+ - Subsystem vocabulary from config.json
283
+ - Instructions to read all PHASE-SUMMARIES.md from `milestones/*/PHASE-SUMMARIES.md` AND any remaining SUMMARY files in `phases/`
284
+ - The knowledge template at `~/.claude/mindsystem/templates/knowledge.md`
285
+ - Instructions to read any existing knowledge files and merge (rewrite semantics — current state, not append)
286
+ - Instructions to create `.planning/knowledge/` directory if missing
287
+ - Instructions to write `.planning/knowledge/{subsystem}.md` for each missing subsystem
288
+
289
+ After subagent completes, verify files exist:
178
290
 
179
291
  ```bash
180
- git add .planning/phases/*/*-SUMMARY.md 2>/dev/null
181
- git add .planning/adhoc/*-SUMMARY.md 2>/dev/null
182
- git add .planning/debug/*.md 2>/dev/null
183
- git add .planning/debug/resolved/*.md 2>/dev/null
184
- git add .planning/todos/pending/*.md 2>/dev/null
185
- git add .planning/todos/done/*.md 2>/dev/null
292
+ ls .planning/knowledge/*.md
293
+ ```
294
+
295
+ Commit:
296
+
297
+ ```bash
298
+ git add .planning/knowledge/
186
299
  ```
187
300
 
188
301
  ```bash
189
302
  git commit -m "$(cat <<'EOF'
190
- chore: fix subsystem vocabulary mismatches
303
+ chore(doctor): generate knowledge files
191
304
 
192
- Standardized artifact subsystem values to canonical vocabulary.
305
+ Created per-subsystem knowledge files from phase summaries.
193
306
  EOF
194
307
  )"
195
308
  ```
196
309
  </step>
197
310
 
311
+ <step name="verify">
312
+ Re-run the diagnostic scan:
313
+
314
+ ```bash
315
+ ~/.claude/mindsystem/scripts/doctor-scan.sh
316
+ ```
317
+
318
+ All checks should now PASS. If any still fail, report which checks remain and why.
319
+ </step>
320
+
198
321
  <step name="report">
199
- Final summary:
322
+ Final summary table:
200
323
 
201
324
  ```
202
325
  ## Doctor Report
203
326
 
204
- | Check | Result | Details |
205
- |------------------------|-------------|----------------------------|
206
- | Subsystem vocabulary | PASS / INIT | N artifacts, M subsystems |
327
+ | Check | Result | Details |
328
+ |--------------------------|--------|----------------------------------|
329
+ | Subsystem vocabulary | PASS | ... |
330
+ | Milestone directories | PASS | ... |
331
+ | Phase archival | PASS | ... |
332
+ | Knowledge files | PASS | ... |
333
+ | Phase summaries | PASS | ... |
334
+ | PLAN cleanup | PASS | ... |
207
335
 
208
336
  All checks passed.
209
337
  ```
210
338
 
211
- - **PASS**: subsystems were already configured and all artifacts validated
212
- - **INIT**: subsystems were initialized during this run
213
- - Include artifact count (how many scanned) and subsystem count
339
+ Include counts: checks total, passed, fixed during this run.
214
340
  </step>
215
341
 
216
342
  </process>
217
343
 
218
344
  <success_criteria>
219
- - [ ] State A: config.json updated, existing artifacts standardized to canonical values, changes committed
220
- - [ ] State B issues: offers fix/review/skip, applies fixes, commits
221
- - [ ] Final report displayed with check name, result, and artifact/subsystem counts
222
- - [ ] State A: derives canonical list from audit + project context, confirms with user before applying
223
- - [ ] State B: all artifacts scanned and classified; reports PASS if all OK
345
+ - [ ] Each fix group committed atomically
346
+ - [ ] Re-scan verifies all checks pass after fixes
347
+ - [ ] User confirms fix strategy before changes (Fix all / Review each / Skip)
348
+ - [ ] Fixes applied in dependency order: subsystems dirs archival cleanup knowledge
349
+ - [ ] Results displayed as markdown table before any action
350
+ - [ ] All 6 categories reported with PASS/FAIL/SKIP
351
+ - [ ] Clean project reports all PASS with no fix prompts
224
352
  </success_criteria>
@@ -69,21 +69,21 @@ PHASE=$(printf "%02d" "$PHASE_ARG" 2>/dev/null || echo "$PHASE_ARG")
69
69
  - Collect summaries from all plans
70
70
  - Report phase completion status
71
71
 
72
- 6. **Code review (optional)**
73
- - Read `code_review.phase` from config.json (default: `ms-code-simplifier`)
74
- - If `"skip"`: proceed to step 7
75
- - Spawn code review agent with phase file scope
76
- - If changes made: commit as `refactor({phase}): code review improvements`
77
-
78
- 7. **Verify phase goal**
72
+ 6. **Verify phase goal**
79
73
  - Spawn `ms-verifier` subagent with phase directory and goal
80
74
  - Verifier checks Must-Haves against actual codebase (not SUMMARY claims)
81
75
  - Creates VERIFICATION.md with detailed report
82
76
  - Route by status:
83
- - `passed` → continue to step 8
77
+ - `passed` → continue to step 7
84
78
  - `human_needed` → present items, get approval or feedback
85
79
  - `gaps_found` → present gaps, offer `/ms:plan-phase {X} --gaps`
86
80
 
81
+ 7. **Code review (optional)**
82
+ - Read `code_review.phase` from config.json (default: `ms-code-simplifier`)
83
+ - If `"skip"`: proceed to step 8
84
+ - Spawn code review agent with phase file scope
85
+ - If changes made: commit as `refactor({phase}): code review improvements`
86
+
87
87
  8. **Generate phase patch**
88
88
  - Run: `~/.claude/mindsystem/scripts/generate-phase-patch.sh ${PHASE_NUMBER}`
89
89
  - Outputs to `.planning/phases/{phase_dir}/{phase}-changes.patch`
@@ -377,12 +377,12 @@ Usage: `/ms:adhoc Fix auth token not refreshing on 401`
377
377
  ### Utility Commands
378
378
 
379
379
  **`/ms:doctor`**
380
- Health check and fix project configuration.
380
+ Health check and fix project configuration — subsystems, milestone structure, knowledge files.
381
381
 
382
- - Use when: subsystems are missing, artifacts have inconsistent vocabulary, or periodic health check
383
- - V1: subsystem vocabulary setup and validation
384
- - If subsystems missing: derives from project context and guides through setup
385
- - If subsystems present: validates all artifacts use canonical values
382
+ - Use when: project has structural drift, missing config, or periodic health check
383
+ - Runs 6 checks: subsystem vocabulary, milestone directories, phase archival, knowledge files, phase summaries, PLAN cleanup
384
+ - Presents results table, then offers to fix all issues in dependency order
385
+ - Each fix group gets its own atomic commit
386
386
  - Idempotent — safe to run repeatedly
387
387
 
388
388
  Usage: `/ms:doctor`
@@ -133,13 +133,36 @@ Confirm: "Created directory: $phase_dir"
133
133
  Insert the new phase entry into the roadmap:
134
134
 
135
135
  1. Find insertion point: immediately after Phase {after_phase}'s content (before next phase heading or "---")
136
- 2. Insert new phase heading with (INSERTED) marker:
136
+
137
+ 2. Before writing the phase entry, analyze the description to determine pre-work flags:
138
+
139
+ **Discuss**: Likely when description mentions user-facing features, UX decisions,
140
+ experiential qualities, or novel features. Unlikely for backend/infra, bug fixes,
141
+ technical debt, or clear-cut work.
142
+
143
+ **Design**: Likely when description involves UI work, visual elements, forms,
144
+ dashboards, or multi-screen flows. Unlikely for backend-only, API, infrastructure,
145
+ or established UI patterns.
146
+
147
+ **Research**: Likely when description mentions external APIs/services, new
148
+ libraries/frameworks, or unclear technical approach. Unlikely for established
149
+ internal patterns or well-documented conventions.
150
+
151
+ Use binary Likely/Unlikely with parenthetical reason. Include topics/focus only when Likely.
152
+
153
+ 3. Insert new phase heading with (INSERTED) marker and pre-work flags:
137
154
 
138
155
  ```
139
156
  ### Phase {decimal_phase}: {Description} (INSERTED)
140
157
 
141
158
  **Goal:** [Urgent work - to be planned]
142
159
  **Depends on:** Phase {after_phase}
160
+ **Discuss**: {Likely (reason) | Unlikely (reason)}
161
+ **Discuss topics**: {topics} ← only if Likely
162
+ **Design**: {Likely (reason) | Unlikely (reason)}
163
+ **Design focus**: {focus} ← only if Likely
164
+ **Research**: {Likely (reason) | Unlikely (reason)}
165
+ **Research topics**: {topics} ← only if Likely
143
166
  **Plans:** 0 plans
144
167
 
145
168
  Plans:
@@ -149,7 +172,7 @@ Insert the new phase entry into the roadmap:
149
172
  [To be added during planning]
150
173
  ```
151
174
 
152
- 3. Write updated roadmap back to file
175
+ 4. Write updated roadmap back to file
153
176
 
154
177
  The "(INSERTED)" marker helps identify decimal phases as urgent insertions.
155
178
 
@@ -183,24 +206,13 @@ Phase {decimal_phase} inserted after Phase {after_phase}:
183
206
  Roadmap updated: {roadmap-path}
184
207
  Project state updated: .planning/STATE.md
185
208
 
186
- ---
187
-
188
- ## ▶ Next Up
189
-
190
- **Phase {decimal_phase}: {description}** — urgent insertion
191
-
192
- `/ms:plan-phase {decimal_phase}`
193
-
194
- <sub>`/clear` first → fresh context window</sub>
209
+ ```
195
210
 
196
- ---
211
+ Read `~/.claude/mindsystem/references/routing/next-phase-routing.md` and follow its instructions
212
+ to present "Next Up" with pre-work context for Phase {decimal_phase}.
197
213
 
198
- **Also available:**
214
+ After the "Next Up" section, add:
199
215
  - Review insertion impact: Check if Phase {next_integer} dependencies still make sense
200
- - Review roadmap
201
-
202
- ---
203
- ```
204
216
  </step>
205
217
 
206
218
  <step name="update_last_command">
@@ -88,7 +88,7 @@ Milestone name: $ARGUMENTS (optional — will emerge during discovery if not pro
88
88
  - Settled decisions and patterns from knowledge files
89
89
  - Untested assumptions from previous audit
90
90
  - Unaddressed requirements from previous milestones
91
- - Strategic features inferred from PROJECT.md's problem/audience/USP
91
+ - Strategic features inferred from PROJECT.md: Who It's For, Core Problem, How It's Different
92
92
  - Pending todos from STATE.md
93
93
 
94
94
  If no meaningful artifacts exist (first milestone after v1.0), base suggestions purely on PROJECT.md.
@@ -199,8 +199,8 @@ Milestone name: $ARGUMENTS (optional — will emerge during discovery if not pro
199
199
  - [Feature 3]
200
200
  ```
201
201
 
202
- Update Active requirements section with new goals.
203
202
  Update "Last updated" footer.
203
+ Note: Milestone-specific goals live in MILESTONE-CONTEXT.md (step 15), not in PROJECT.md.
204
204
 
205
205
  15. **Write MILESTONE-CONTEXT.md:**
206
206
 
@@ -285,7 +285,6 @@ Milestone name: $ARGUMENTS (optional — will emerge during discovery if not pro
285
285
 
286
286
  <success_criteria>
287
287
  - PROJECT.md updated with Current Milestone section
288
- - Active requirements reflect new milestone goals
289
288
  - MILESTONE-CONTEXT.md created with vision, features, scope, priorities
290
289
  - STATE.md reset for new milestone
291
290
  - Git commit made