mindsystem-cc 3.20.0 → 3.22.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 (113) hide show
  1. package/README.md +9 -18
  2. package/agents/ms-mockup-designer.md +1 -1
  3. package/agents/ms-plan-checker.md +30 -30
  4. package/agents/ms-plan-writer.md +1 -1
  5. package/agents/ms-product-researcher.md +71 -0
  6. package/agents/ms-research-synthesizer.md +1 -1
  7. package/agents/ms-researcher.md +8 -8
  8. package/agents/ms-roadmapper.md +9 -13
  9. package/agents/ms-verifier.md +25 -117
  10. package/bin/install.js +68 -5
  11. package/commands/ms/add-phase.md +7 -8
  12. package/commands/ms/add-todo.md +3 -4
  13. package/commands/ms/adhoc.md +4 -5
  14. package/commands/ms/audit-milestone.md +15 -14
  15. package/commands/ms/complete-milestone.md +27 -24
  16. package/commands/ms/config.md +229 -0
  17. package/commands/ms/create-roadmap.md +3 -4
  18. package/commands/ms/debug.md +3 -4
  19. package/commands/ms/design-phase.md +11 -13
  20. package/commands/ms/discuss-phase.md +26 -22
  21. package/commands/ms/doctor.md +28 -205
  22. package/commands/ms/execute-phase.md +20 -12
  23. package/commands/ms/help.md +46 -39
  24. package/commands/ms/insert-phase.md +6 -7
  25. package/commands/ms/map-codebase.md +1 -2
  26. package/commands/ms/new-milestone.md +41 -19
  27. package/commands/ms/new-project.md +56 -47
  28. package/commands/ms/plan-milestone-gaps.md +7 -9
  29. package/commands/ms/plan-phase.md +4 -5
  30. package/commands/ms/progress.md +3 -4
  31. package/commands/ms/remove-phase.md +3 -4
  32. package/commands/ms/research-phase.md +11 -16
  33. package/commands/ms/research-project.md +19 -26
  34. package/commands/ms/review-design.md +4 -2
  35. package/commands/ms/verify-work.md +6 -8
  36. package/mindsystem/references/continuation-format.md +3 -3
  37. package/mindsystem/references/principles.md +1 -1
  38. package/mindsystem/references/routing/audit-result-routing.md +12 -11
  39. package/mindsystem/references/routing/between-milestones-routing.md +2 -2
  40. package/mindsystem/references/routing/milestone-complete-routing.md +1 -1
  41. package/mindsystem/references/routing/next-phase-routing.md +4 -2
  42. package/mindsystem/references/verification-patterns.md +0 -37
  43. package/mindsystem/templates/config.json +2 -1
  44. package/mindsystem/templates/context.md +7 -6
  45. package/mindsystem/templates/milestone-archive.md +5 -5
  46. package/mindsystem/templates/milestone-context.md +1 -1
  47. package/mindsystem/templates/milestone.md +9 -9
  48. package/mindsystem/templates/project.md +2 -2
  49. package/mindsystem/templates/research-subagent-prompt.md +3 -3
  50. package/mindsystem/templates/roadmap-milestone.md +14 -14
  51. package/mindsystem/templates/roadmap.md +10 -8
  52. package/mindsystem/templates/state.md +2 -2
  53. package/mindsystem/templates/verification-report.md +3 -26
  54. package/mindsystem/workflows/adhoc.md +1 -1
  55. package/mindsystem/workflows/complete-milestone.md +40 -75
  56. package/mindsystem/workflows/discuss-phase.md +141 -65
  57. package/mindsystem/workflows/doctor-fixes.md +273 -0
  58. package/mindsystem/workflows/execute-phase.md +9 -21
  59. package/mindsystem/workflows/execute-plan.md +3 -0
  60. package/mindsystem/workflows/map-codebase.md +6 -12
  61. package/mindsystem/workflows/mockup-generation.md +47 -23
  62. package/mindsystem/workflows/plan-phase.md +13 -6
  63. package/mindsystem/workflows/transition.md +2 -2
  64. package/mindsystem/workflows/verify-work.md +97 -70
  65. package/package.json +1 -1
  66. package/scripts/__pycache__/ms-tools.cpython-314.pyc +0 -0
  67. package/scripts/__pycache__/test_ms_tools.cpython-314-pytest-9.0.2.pyc +0 -0
  68. package/scripts/fixtures/scan-context/.planning/ROADMAP.md +16 -0
  69. package/scripts/fixtures/scan-context/.planning/adhoc/20260220-fix-token-SUMMARY.md +12 -0
  70. package/scripts/fixtures/scan-context/.planning/config.json +3 -0
  71. package/scripts/fixtures/scan-context/.planning/debug/resolved/token-bug.md +11 -0
  72. package/scripts/fixtures/scan-context/.planning/knowledge/auth.md +11 -0
  73. package/scripts/fixtures/scan-context/.planning/phases/02-infra/02-1-SUMMARY.md +20 -0
  74. package/scripts/fixtures/scan-context/.planning/phases/04-setup/04-1-SUMMARY.md +21 -0
  75. package/scripts/fixtures/scan-context/.planning/phases/05-auth/05-1-SUMMARY.md +28 -0
  76. package/scripts/fixtures/scan-context/.planning/todos/done/setup-db.md +10 -0
  77. package/scripts/fixtures/scan-context/.planning/todos/pending/add-logout.md +10 -0
  78. package/scripts/fixtures/scan-context/expected-output.json +257 -0
  79. package/scripts/ms-tools.py +2884 -0
  80. package/scripts/test_ms_tools.py +1622 -0
  81. package/agents/ms-flutter-code-quality.md +0 -169
  82. package/agents/ms-flutter-reviewer.md +0 -211
  83. package/agents/ms-flutter-simplifier.md +0 -79
  84. package/commands/ms/list-phase-assumptions.md +0 -56
  85. package/mindsystem/workflows/list-phase-assumptions.md +0 -178
  86. package/mindsystem/workflows/verify-phase.md +0 -625
  87. package/scripts/__pycache__/compare_mockups.cpython-314.pyc +0 -0
  88. package/scripts/archive-milestone-files.sh +0 -68
  89. package/scripts/archive-milestone-phases.sh +0 -138
  90. package/scripts/doctor-scan.sh +0 -402
  91. package/scripts/gather-milestone-stats.sh +0 -179
  92. package/scripts/generate-adhoc-patch.sh +0 -79
  93. package/scripts/generate-phase-patch.sh +0 -169
  94. package/scripts/scan-artifact-subsystems.sh +0 -55
  95. package/scripts/scan-planning-context.py +0 -839
  96. package/scripts/update-state.sh +0 -59
  97. package/scripts/validate-execution-order.sh +0 -104
  98. package/skills/flutter-code-quality/SKILL.md +0 -143
  99. package/skills/flutter-code-simplification/SKILL.md +0 -102
  100. package/skills/flutter-senior-review/AGENTS.md +0 -869
  101. package/skills/flutter-senior-review/SKILL.md +0 -205
  102. package/skills/flutter-senior-review/principles/dependencies-data-not-callbacks.md +0 -75
  103. package/skills/flutter-senior-review/principles/dependencies-provider-tree.md +0 -85
  104. package/skills/flutter-senior-review/principles/dependencies-temporal-coupling.md +0 -97
  105. package/skills/flutter-senior-review/principles/pragmatism-consistent-error-handling.md +0 -130
  106. package/skills/flutter-senior-review/principles/pragmatism-speculative-generality.md +0 -91
  107. package/skills/flutter-senior-review/principles/state-data-clumps.md +0 -64
  108. package/skills/flutter-senior-review/principles/state-invalid-states.md +0 -53
  109. package/skills/flutter-senior-review/principles/state-single-source-of-truth.md +0 -68
  110. package/skills/flutter-senior-review/principles/state-type-hierarchies.md +0 -75
  111. package/skills/flutter-senior-review/principles/structure-composition-over-config.md +0 -105
  112. package/skills/flutter-senior-review/principles/structure-shared-visual-patterns.md +0 -107
  113. package/skills/flutter-senior-review/principles/structure-wrapper-pattern.md +0 -90
@@ -1,138 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # archive-milestone-phases.sh
4
- # Consolidates phase summaries, deletes raw artifacts, and moves phase
5
- # directories to the milestone archive.
6
- #
7
- # Usage: ./scripts/archive-milestone-phases.sh <start_phase> <end_phase> <version>
8
- # Example: ./scripts/archive-milestone-phases.sh 1 6 v1.0
9
-
10
- set -e
11
-
12
- # --- Validation ---
13
- if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
14
- echo "Error: Three arguments required"
15
- echo "Usage: $0 <start_phase> <end_phase> <version>"
16
- exit 1
17
- fi
18
-
19
- START="$1"
20
- END="$2"
21
- VERSION="$3"
22
-
23
- if ! [[ "$START" =~ ^[0-9]+$ ]] || ! [[ "$END" =~ ^[0-9]+$ ]]; then
24
- echo "Error: start_phase and end_phase must be numeric"
25
- echo "Usage: $0 <start_phase> <end_phase> <version>"
26
- exit 1
27
- fi
28
-
29
- if [ "$START" -gt "$END" ]; then
30
- echo "Error: Start phase ($START) cannot exceed end phase ($END)"
31
- exit 1
32
- fi
33
-
34
- # --- Find .planning from git root ---
35
- GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
36
- if [ -z "$GIT_ROOT" ]; then
37
- echo "Error: Not in a git repository"
38
- exit 1
39
- fi
40
-
41
- PHASES_DIR="$GIT_ROOT/.planning/phases"
42
- if [ ! -d "$PHASES_DIR" ]; then
43
- echo "Error: Phases directory not found at $PHASES_DIR"
44
- exit 1
45
- fi
46
-
47
- MILESTONE_DIR="$GIT_ROOT/.planning/milestones/$VERSION"
48
- if [ ! -d "$MILESTONE_DIR" ]; then
49
- echo "Error: Milestone directory not found at $MILESTONE_DIR"
50
- echo "Run archive_milestone step first to create it"
51
- exit 1
52
- fi
53
-
54
- # --- Helper: check if phase number is in range (supports decimals like 02.1) ---
55
- in_range() {
56
- local phase_num="$1"
57
- echo "$phase_num" | awk -v s="$START" -v e="$END" '{
58
- # Strip leading zeros for comparison
59
- val = $1 + 0
60
- if (val >= s && val <= e + 0.999) exit 0
61
- else exit 1
62
- }'
63
- }
64
-
65
- # --- Stage 1: Consolidate summaries ---
66
- SUMMARIES_FILE="$MILESTONE_DIR/PHASE-SUMMARIES.md"
67
- SUMMARY_COUNT=0
68
-
69
- echo "# Phase Summaries: $VERSION" > "$SUMMARIES_FILE"
70
- echo "" >> "$SUMMARIES_FILE"
71
-
72
- for dir in "$PHASES_DIR"/*/; do
73
- [ -d "$dir" ] || continue
74
- dirname=$(basename "$dir")
75
- phase_num="${dirname%%-*}"
76
- phase_name="${dirname#*-}"
77
-
78
- if in_range "$phase_num"; then
79
- has_summaries=false
80
- for f in "$dir"/*-SUMMARY.md; do
81
- [ -f "$f" ] || continue
82
- if [ "$has_summaries" = false ]; then
83
- echo "## Phase $phase_num: $phase_name" >> "$SUMMARIES_FILE"
84
- echo "" >> "$SUMMARIES_FILE"
85
- has_summaries=true
86
- fi
87
- plan_file=$(basename "$f")
88
- plan_id="${plan_file%-SUMMARY.md}"
89
- echo "### $plan_id" >> "$SUMMARIES_FILE"
90
- echo "" >> "$SUMMARIES_FILE"
91
- cat "$f" >> "$SUMMARIES_FILE"
92
- echo "" >> "$SUMMARIES_FILE"
93
- SUMMARY_COUNT=$((SUMMARY_COUNT + 1))
94
- done
95
- fi
96
- done
97
-
98
- echo "Stage 1: Consolidated $SUMMARY_COUNT summaries to PHASE-SUMMARIES.md"
99
-
100
- # --- Stage 2: Delete artifacts ---
101
- DELETED=0
102
- for dir in "$PHASES_DIR"/*/; do
103
- [ -d "$dir" ] || continue
104
- dirname=$(basename "$dir")
105
- phase_num="${dirname%%-*}"
106
-
107
- if in_range "$phase_num"; then
108
- for f in "$dir"/*-CONTEXT.md "$dir"/*-DESIGN.md "$dir"/*-RESEARCH.md \
109
- "$dir"/*-SUMMARY.md "$dir"/*-UAT.md "$dir"/*-VERIFICATION.md \
110
- "$dir"/*-EXECUTION-ORDER.md; do
111
- if [ -f "$f" ]; then
112
- rm -f "$f"
113
- DELETED=$((DELETED + 1))
114
- fi
115
- done
116
- fi
117
- done
118
-
119
- echo "Stage 2: Deleted $DELETED artifact files"
120
-
121
- # --- Stage 3: Move phase directories ---
122
- mkdir -p "$MILESTONE_DIR/phases"
123
- MOVED=0
124
- for dir in "$PHASES_DIR"/*/; do
125
- [ -d "$dir" ] || continue
126
- dirname=$(basename "$dir")
127
- phase_num="${dirname%%-*}"
128
-
129
- if in_range "$phase_num"; then
130
- mv "$dir" "$MILESTONE_DIR/phases/$dirname"
131
- MOVED=$((MOVED + 1))
132
- fi
133
- done
134
-
135
- echo "Stage 3: Moved $MOVED phase directories to milestones/$VERSION/phases/"
136
- echo ""
137
- echo "Archive complete: $SUMMARY_COUNT summaries, $DELETED artifacts deleted, $MOVED dirs moved"
138
- exit 0
@@ -1,402 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # doctor-scan.sh
4
- # Single-pass diagnostic scan of the .planning/ tree.
5
- # Reports on 6 health check categories with structured output.
6
- #
7
- # Usage: ./scripts/doctor-scan.sh
8
- #
9
- # Exit codes:
10
- # 0 — all checks pass
11
- # 1 — one or more checks failed
12
- # 2 — .planning/ or config.json missing (cannot scan)
13
-
14
- set -e
15
-
16
- # --- Find .planning from git root ---
17
- GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
18
- if [ -z "$GIT_ROOT" ]; then
19
- echo "Error: Not in a git repository"
20
- exit 2
21
- fi
22
-
23
- PLANNING="$GIT_ROOT/.planning"
24
- if [ ! -d "$PLANNING" ]; then
25
- echo "Error: No .planning/ directory found"
26
- exit 2
27
- fi
28
-
29
- CONFIG="$PLANNING/config.json"
30
- if [ ! -f "$CONFIG" ]; then
31
- echo "Error: No config.json found at $CONFIG"
32
- exit 2
33
- fi
34
-
35
- MILESTONES_FILE="$PLANNING/MILESTONES.md"
36
- PHASES_DIR="$PLANNING/phases"
37
- MILESTONES_DIR="$PLANNING/milestones"
38
- KNOWLEDGE_DIR="$PLANNING/knowledge"
39
-
40
- PASS_COUNT=0
41
- FAIL_COUNT=0
42
- SKIP_COUNT=0
43
- FAILED_CHECKS=""
44
-
45
- # --- Helper: record check result ---
46
- record_result() {
47
- local status="$1"
48
- local name="$2"
49
- case "$status" in
50
- PASS) PASS_COUNT=$((PASS_COUNT + 1)) ;;
51
- FAIL) FAIL_COUNT=$((FAIL_COUNT + 1)); FAILED_CHECKS="$FAILED_CHECKS $name" ;;
52
- SKIP) SKIP_COUNT=$((SKIP_COUNT + 1)) ;;
53
- esac
54
- }
55
-
56
- # --- Helper: parse phase numbers from a "Phases completed" line ---
57
- # Outputs one phase number per line. Handles:
58
- # - Range format: "1-6" → 1 2 3 4 5 6
59
- # - Comma-separated: "8, 8.3, 9, 10" → 8 8.3 9 10
60
- # - Mixed (multiple milestone entries each handled independently)
61
- parse_phase_numbers() {
62
- local line="$1"
63
- local range
64
- range=$(echo "$line" | grep -o '[0-9]\+-[0-9]\+' || true)
65
- if [ -n "$range" ]; then
66
- local range_start range_end
67
- range_start=$(echo "$range" | cut -d'-' -f1)
68
- range_end=$(echo "$range" | cut -d'-' -f2)
69
- seq "$range_start" "$range_end"
70
- else
71
- echo "$line" | sed 's/.*://' | grep -oE '[0-9]+(\.[0-9]+)?' || true
72
- fi
73
- }
74
-
75
- # --- Helper: format phase number as zero-padded directory prefix ---
76
- # Integer (9) → "09", Decimal (8.3) → "08.3"
77
- format_phase_prefix() {
78
- local phase="$1"
79
- if echo "$phase" | grep -q '\.'; then
80
- local int_part dec_part
81
- int_part=$(echo "$phase" | cut -d'.' -f1)
82
- dec_part=$(echo "$phase" | cut -d'.' -f2)
83
- printf "%02d.%s" "$int_part" "$dec_part"
84
- else
85
- printf "%02d" "$phase"
86
- fi
87
- }
88
-
89
- # ============================================================
90
- # CHECK 1: Subsystem Vocabulary
91
- # ============================================================
92
- echo "=== Subsystem Vocabulary ==="
93
-
94
- SUBSYSTEM_COUNT=$(jq -r '.subsystems // [] | length' "$CONFIG" 2>/dev/null || echo "0")
95
-
96
- if [ "$SUBSYSTEM_COUNT" -eq 0 ]; then
97
- echo "Status: FAIL"
98
- echo "No subsystems array in config.json (or empty)"
99
- record_result "FAIL" "Subsystem Vocabulary"
100
- else
101
- echo "Subsystems: $SUBSYSTEM_COUNT configured"
102
- jq -r '.subsystems[]' "$CONFIG" 2>/dev/null | sed 's/^/ - /'
103
-
104
- # Run artifact scan to check for mismatches
105
- SCAN_SCRIPT="$(dirname "$0")/scan-artifact-subsystems.sh"
106
- if [ -x "$SCAN_SCRIPT" ]; then
107
- CANONICAL=$(jq -r '.subsystems[]' "$CONFIG" 2>/dev/null)
108
- ARTIFACT_VALUES=$("$SCAN_SCRIPT" --values-only 2>/dev/null | grep -v '^===' | sort -u)
109
- MISMATCHES=""
110
- while IFS= read -r val; do
111
- [ -z "$val" ] && continue
112
- if ! echo "$CANONICAL" | grep -qx "$val"; then
113
- MISMATCHES="$MISMATCHES $val"
114
- fi
115
- done <<< "$ARTIFACT_VALUES"
116
-
117
- if [ -n "$MISMATCHES" ]; then
118
- echo "Status: FAIL"
119
- echo "Artifact values not in canonical list:$MISMATCHES"
120
- record_result "FAIL" "Subsystem Vocabulary"
121
- else
122
- ARTIFACT_COUNT=$("$SCAN_SCRIPT" --values-only 2>/dev/null | grep -v '^===' | wc -l | tr -d ' ')
123
- echo "Artifacts scanned: $ARTIFACT_COUNT (all OK)"
124
- echo "Status: PASS"
125
- record_result "PASS" "Subsystem Vocabulary"
126
- fi
127
- else
128
- echo "Status: PASS"
129
- echo "(scan-artifact-subsystems.sh not found — skipped artifact validation)"
130
- record_result "PASS" "Subsystem Vocabulary"
131
- fi
132
- fi
133
- echo ""
134
-
135
- # ============================================================
136
- # CHECK 2: Milestone Directory Structure
137
- # ============================================================
138
- echo "=== Milestone Directory Structure ==="
139
-
140
- if [ ! -d "$MILESTONES_DIR" ]; then
141
- # No milestones directory at all — check if MILESTONES.md has entries
142
- if [ -f "$MILESTONES_FILE" ] && grep -q "^## " "$MILESTONES_FILE" 2>/dev/null; then
143
- echo "Status: FAIL"
144
- echo "MILESTONES.md has entries but no milestones/ directory"
145
- record_result "FAIL" "Milestone Directory Structure"
146
- else
147
- echo "Status: SKIP"
148
- echo "No completed milestones"
149
- record_result "SKIP" "Milestone Directory Structure"
150
- fi
151
- else
152
- # Look for flat files matching v*-*.md directly in milestones/
153
- FLAT_FILES=""
154
- FLAT_COUNT=0
155
- for f in "$MILESTONES_DIR"/v*-*.md; do
156
- [ -f "$f" ] || continue
157
- FLAT_FILES="$FLAT_FILES $(basename "$f")"$'\n'
158
- FLAT_COUNT=$((FLAT_COUNT + 1))
159
- done
160
-
161
- if [ "$FLAT_COUNT" -gt 0 ]; then
162
- echo "Status: FAIL"
163
- echo "Found $FLAT_COUNT flat file(s) in milestones/ (old format):"
164
- echo "$FLAT_FILES"
165
- # Check if corresponding versioned directories exist
166
- for f in "$MILESTONES_DIR"/v*-*.md; do
167
- [ -f "$f" ] || continue
168
- fname=$(basename "$f")
169
- # Extract version prefix: v0.1-ROADMAP.md -> v0.1
170
- version=$(echo "$fname" | sed 's/^\(v[0-9.]*\)-.*/\1/')
171
- if [ -d "$MILESTONES_DIR/$version" ]; then
172
- echo " $fname → directory $version/ exists (can restructure)"
173
- else
174
- echo " $fname → directory $version/ missing (need to create)"
175
- fi
176
- done
177
- record_result "FAIL" "Milestone Directory Structure"
178
- else
179
- # Count versioned directories
180
- DIR_COUNT=0
181
- for d in "$MILESTONES_DIR"/v*/; do
182
- [ -d "$d" ] || continue
183
- DIR_COUNT=$((DIR_COUNT + 1))
184
- done
185
-
186
- if [ "$DIR_COUNT" -eq 0 ]; then
187
- echo "Status: SKIP"
188
- echo "No completed milestones"
189
- record_result "SKIP" "Milestone Directory Structure"
190
- else
191
- echo "Status: PASS"
192
- echo "$DIR_COUNT versioned milestone directories"
193
- record_result "PASS" "Milestone Directory Structure"
194
- fi
195
- fi
196
- fi
197
- echo ""
198
-
199
- # ============================================================
200
- # CHECK 3: Phase Archival
201
- # ============================================================
202
- echo "=== Phase Archival ==="
203
-
204
- if [ ! -f "$MILESTONES_FILE" ] || ! grep -q "Phases completed" "$MILESTONES_FILE" 2>/dev/null; then
205
- echo "Status: SKIP"
206
- echo "No completed milestones with phase ranges in MILESTONES.md"
207
- record_result "SKIP" "Phase Archival"
208
- else
209
- ORPHAN_COUNT=0
210
- ORPHAN_LIST=""
211
-
212
- # Parse each milestone's completed phases from MILESTONES.md
213
- while IFS= read -r line; do
214
- while IFS= read -r phase_num; do
215
- [ -z "$phase_num" ] && continue
216
- prefix=$(format_phase_prefix "$phase_num")
217
- for dir in "$PHASES_DIR"/${prefix}-*/; do
218
- [ -d "$dir" ] || continue
219
- dirname=$(basename "$dir")
220
- ORPHAN_COUNT=$((ORPHAN_COUNT + 1))
221
- ORPHAN_LIST="$ORPHAN_LIST $dirname (should be archived)"$'\n'
222
- done
223
- done < <(parse_phase_numbers "$line")
224
- done < <(grep "Phases completed" "$MILESTONES_FILE")
225
-
226
- if [ "$ORPHAN_COUNT" -gt 0 ]; then
227
- echo "Status: FAIL"
228
- echo "Found $ORPHAN_COUNT orphaned phase directories from completed milestones:"
229
- echo "$ORPHAN_LIST"
230
- record_result "FAIL" "Phase Archival"
231
- else
232
- echo "Status: PASS"
233
- echo "All completed milestone phases are archived"
234
- record_result "PASS" "Phase Archival"
235
- fi
236
- fi
237
- echo ""
238
-
239
- # ============================================================
240
- # CHECK 4: Knowledge Files
241
- # ============================================================
242
- echo "=== Knowledge Files ==="
243
-
244
- if [ "$SUBSYSTEM_COUNT" -eq 0 ]; then
245
- echo "Status: SKIP"
246
- echo "No subsystems configured — knowledge check requires subsystem vocabulary"
247
- record_result "SKIP" "Knowledge Files"
248
- elif [ ! -d "$KNOWLEDGE_DIR" ]; then
249
- echo "Status: FAIL"
250
- echo "Knowledge directory missing: .planning/knowledge/"
251
- echo "Expected files for $SUBSYSTEM_COUNT subsystems"
252
- record_result "FAIL" "Knowledge Files"
253
- else
254
- MISSING_KNOWLEDGE=""
255
- MISSING_COUNT=0
256
- PRESENT_COUNT=0
257
- while IFS= read -r subsystem; do
258
- [ -z "$subsystem" ] && continue
259
- if [ -f "$KNOWLEDGE_DIR/$subsystem.md" ]; then
260
- PRESENT_COUNT=$((PRESENT_COUNT + 1))
261
- else
262
- MISSING_COUNT=$((MISSING_COUNT + 1))
263
- MISSING_KNOWLEDGE="$MISSING_KNOWLEDGE $subsystem.md"$'\n'
264
- fi
265
- done < <(jq -r '.subsystems[]' "$CONFIG" 2>/dev/null)
266
-
267
- # Check for orphaned knowledge files (not in subsystem list)
268
- ORPHAN_KNOWLEDGE=""
269
- ORPHAN_K_COUNT=0
270
- for f in "$KNOWLEDGE_DIR"/*.md; do
271
- [ -f "$f" ] || continue
272
- fname=$(basename "$f" .md)
273
- if ! jq -r '.subsystems[]' "$CONFIG" 2>/dev/null | grep -qx "$fname"; then
274
- ORPHAN_K_COUNT=$((ORPHAN_K_COUNT + 1))
275
- ORPHAN_KNOWLEDGE="$ORPHAN_KNOWLEDGE $fname.md (not in subsystems list)"$'\n'
276
- fi
277
- done
278
-
279
- if [ "$MISSING_COUNT" -gt 0 ] || [ "$ORPHAN_K_COUNT" -gt 0 ]; then
280
- echo "Status: FAIL"
281
- echo "Coverage: $PRESENT_COUNT/$SUBSYSTEM_COUNT subsystems have knowledge files"
282
- if [ "$MISSING_COUNT" -gt 0 ]; then
283
- echo "Missing:"
284
- echo "$MISSING_KNOWLEDGE"
285
- fi
286
- if [ "$ORPHAN_K_COUNT" -gt 0 ]; then
287
- echo "Orphaned:"
288
- echo "$ORPHAN_KNOWLEDGE"
289
- fi
290
- record_result "FAIL" "Knowledge Files"
291
- else
292
- echo "Status: PASS"
293
- echo "All $SUBSYSTEM_COUNT subsystems have knowledge files"
294
- record_result "PASS" "Knowledge Files"
295
- fi
296
- fi
297
- echo ""
298
-
299
- # ============================================================
300
- # CHECK 5: Phase Summaries
301
- # ============================================================
302
- echo "=== Phase Summaries ==="
303
-
304
- if [ ! -d "$MILESTONES_DIR" ]; then
305
- echo "Status: SKIP"
306
- echo "No milestones directory"
307
- record_result "SKIP" "Phase Summaries"
308
- else
309
- MISSING_SUMMARIES=""
310
- MISSING_S_COUNT=0
311
- CHECKED=0
312
-
313
- for d in "$MILESTONES_DIR"/v*/; do
314
- [ -d "$d" ] || continue
315
- CHECKED=$((CHECKED + 1))
316
- version=$(basename "$d")
317
- if [ ! -f "$d/PHASE-SUMMARIES.md" ]; then
318
- MISSING_S_COUNT=$((MISSING_S_COUNT + 1))
319
- MISSING_SUMMARIES="$MISSING_SUMMARIES $version/PHASE-SUMMARIES.md"$'\n'
320
- fi
321
- done
322
-
323
- if [ "$CHECKED" -eq 0 ]; then
324
- echo "Status: SKIP"
325
- echo "No versioned milestone directories"
326
- record_result "SKIP" "Phase Summaries"
327
- elif [ "$MISSING_S_COUNT" -gt 0 ]; then
328
- echo "Status: FAIL"
329
- echo "Missing PHASE-SUMMARIES.md in $MISSING_S_COUNT milestone(s):"
330
- echo "$MISSING_SUMMARIES"
331
- record_result "FAIL" "Phase Summaries"
332
- else
333
- echo "Status: PASS"
334
- echo "All $CHECKED milestones have PHASE-SUMMARIES.md"
335
- record_result "PASS" "Phase Summaries"
336
- fi
337
- fi
338
- echo ""
339
-
340
- # ============================================================
341
- # CHECK 6: PLAN Cleanup
342
- # ============================================================
343
- echo "=== PLAN Cleanup ==="
344
-
345
- if [ ! -f "$MILESTONES_FILE" ] || ! grep -q "Phases completed" "$MILESTONES_FILE" 2>/dev/null; then
346
- echo "Status: SKIP"
347
- echo "No completed milestones — active phase PLANs are expected"
348
- record_result "SKIP" "PLAN Cleanup"
349
- else
350
- LEFTOVER_PLANS=""
351
- LEFTOVER_COUNT=0
352
-
353
- # Check phases/ for PLANs belonging to completed milestones
354
- while IFS= read -r line; do
355
- while IFS= read -r phase_num; do
356
- [ -z "$phase_num" ] && continue
357
- prefix=$(format_phase_prefix "$phase_num")
358
- for plan in "$PHASES_DIR"/${prefix}-*/*-PLAN.md; do
359
- [ -f "$plan" ] || continue
360
- LEFTOVER_COUNT=$((LEFTOVER_COUNT + 1))
361
- LEFTOVER_PLANS="$LEFTOVER_PLANS $(echo "$plan" | sed "s|$GIT_ROOT/.planning/||")"$'\n'
362
- done
363
- done < <(parse_phase_numbers "$line")
364
- done < <(grep "Phases completed" "$MILESTONES_FILE")
365
-
366
- # Check archived milestone phase directories for leftover PLANs
367
- for d in "$MILESTONES_DIR"/v*/phases/*/; do
368
- [ -d "$d" ] || continue
369
- for plan in "$d"*-PLAN.md; do
370
- [ -f "$plan" ] || continue
371
- LEFTOVER_COUNT=$((LEFTOVER_COUNT + 1))
372
- LEFTOVER_PLANS="$LEFTOVER_PLANS $(echo "$plan" | sed "s|$GIT_ROOT/.planning/||")"$'\n'
373
- done
374
- done
375
-
376
- if [ "$LEFTOVER_COUNT" -gt 0 ]; then
377
- echo "Status: FAIL"
378
- echo "Found $LEFTOVER_COUNT leftover PLAN file(s) in completed phases:"
379
- echo "$LEFTOVER_PLANS"
380
- record_result "FAIL" "PLAN Cleanup"
381
- else
382
- echo "Status: PASS"
383
- echo "No leftover PLAN files in completed phases"
384
- record_result "PASS" "PLAN Cleanup"
385
- fi
386
- fi
387
- echo ""
388
-
389
- # ============================================================
390
- # SUMMARY
391
- # ============================================================
392
- TOTAL=$((PASS_COUNT + FAIL_COUNT + SKIP_COUNT))
393
- echo "=== Summary ==="
394
- echo "Checks: $TOTAL total, $PASS_COUNT passed, $FAIL_COUNT failed, $SKIP_COUNT skipped"
395
-
396
- if [ "$FAIL_COUNT" -gt 0 ]; then
397
- echo "Issues:$FAILED_CHECKS"
398
- exit 1
399
- else
400
- echo "All checks passed"
401
- exit 0
402
- fi