@massu/core 0.9.0 → 0.9.1

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.
@@ -1,31 +1,29 @@
1
1
  ---
2
2
  name: massu-gap-enhancement-analyzer
3
3
  description: "When user says 'analyze gaps', 'find enhancements', 'gap analysis', or has completed a massu-loop implementation and needs to identify remaining gaps and enhancement opportunities"
4
- allowed-tools: Bash(*), Read(*), Write(*), Grep(*), Glob(*)
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), Task(*)
5
5
  ---
6
6
  name: massu-gap-enhancement-analyzer
7
7
 
8
- > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding.
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-12, CR-45 enforced.
9
9
 
10
- # Massu Gap & Enhancement Analyzer
10
+ # Massu Gap & Enhancement Analyzer — Zero-Gap Loop
11
11
 
12
12
  ## Objective
13
13
 
14
- Perform a comprehensive post-implementation review of a plan executed through massu-loop to identify:
15
- 1. **Gaps**: Missing functionality, incomplete implementations, untested paths, or deviations from plan
16
- 2. **Enhancements**: Opportunities to improve UX, performance, security, or functionality beyond the original scope
14
+ Run a continuous analysis→fix→re-analysis loop that catches everything implementation missed: incomplete features, missing edge cases, UX gaps, untested paths, security issues, and enhancement opportunities.
17
15
 
18
- This tool produces a detailed analysis report. ALL gaps and enhancements identified MUST be fixed/implemented — no severity is exempt (CR-45).
16
+ **ALL gaps and enhancements found MUST be fixed/implemented — no severity is exempt (CR-45).**
17
+
18
+ **This command loops until a FULL PASS discovers ZERO gaps AND ZERO enhancements.**
19
19
 
20
20
  ---
21
21
 
22
22
  ## WHEN TO USE THIS COMMAND
23
23
 
24
- Use this command AFTER a plan has been implemented through `/massu-loop` to:
25
- - Validate that ALL plan items were actually implemented
26
- - Identify gaps that may have been missed during implementation
27
- - Discover enhancement opportunities that became apparent during implementation
28
- - Create a prioritized action list for follow-up work
24
+ - **Standalone**: After a plan has been implemented via `/massu-loop` or manual implementation
25
+ - **Inside golden path**: Invoked automatically as Phase 2.5
26
+ - **Ad hoc**: Any time you want to sweep a codebase area for gaps and enhancements
29
27
 
30
28
  ---
31
29
 
@@ -33,134 +31,198 @@ Use this command AFTER a plan has been implemented through `/massu-loop` to:
33
31
 
34
32
  The user MUST provide:
35
33
  1. **Plan file path**: The original plan document that was implemented
36
- 2. **Implementation scope**: Files/directories that were touched during implementation
37
34
 
38
- If not provided, ask for these inputs before proceeding.
35
+ If not provided, ask for the plan path before proceeding.
39
36
 
40
37
  ---
41
38
 
42
- ## PHASE 1: PLAN EXTRACTION & INVENTORY
43
-
44
- ### Step 1.1: Read the Complete Plan
45
-
46
- ```bash
47
- # Read the entire plan document
48
- cat [PLAN_FILE_PATH]
49
- ```
50
-
51
- **Extract ALL of the following into structured inventory:**
52
-
53
- | Category | What to Extract |
54
- |----------|-----------------|
55
- | **Database** | Tables, columns, migrations, policies, grants (if applicable) |
56
- | **API/Backend** | Endpoints, procedures, inputs, outputs, mutations, queries |
57
- | **Components** | UI components, their locations, dependencies |
58
- | **Pages** | Routes, page files, layouts |
59
- | **Features** | User-facing functionality, workflows, integrations |
60
- | **Configuration** | Environment variables, feature flags, settings |
61
- | **Tests** | Test files, test coverage requirements |
62
- | **Documentation** | Help site updates, README changes |
39
+ ## THIS IS A LOOP CONTROLLER
63
40
 
64
- ### Step 1.2: Create Plan Item Checklist
41
+ **Your job is to:**
42
+ 1. Spawn a `general-purpose` subagent for ONE complete analysis-and-fix pass
43
+ 2. Parse the structured result (`GAPS_DISCOVERED: N`)
44
+ 3. If gaps discovered > 0: spawn ANOTHER full pass (even if all gaps were fixed)
45
+ 4. Only when a COMPLETE FRESH PASS discovers ZERO gaps can you declare complete
65
46
 
66
- ```markdown
67
- ## PLAN ITEM INVENTORY
68
-
69
- | ID | Category | Item Description | Expected Location | Status |
70
- |----|----------|------------------|-------------------|--------|
71
- | P-001 | DB | [table_name] table | migration file | PENDING |
72
- | P-002 | API | [endpoint_name] endpoint | [path from plan] | PENDING |
73
- | P-003 | UI | [ComponentName] component | [path from plan] | PENDING |
74
- | P-004 | Feature | [Feature description] | [path from plan] | PENDING |
75
- ```
47
+ **You are NOT the analyzer. You are the LOOP. The analyzer runs inside Task subagents.**
76
48
 
77
49
  ---
78
50
 
79
- ## PHASE 2: IMPLEMENTATION VERIFICATION
80
-
81
- > **IMPORTANT**: Derive all file paths from the plan document. Do NOT assume any specific framework directory structure. The plan specifies where files should live — use those paths for all verification commands below.
82
-
83
- ### Step 2.1: Database Verification
84
-
85
- > **Skip this section if the plan does not include database changes.**
86
-
87
- For EACH database item in the plan, use the project's database CLI or query tool to verify:
51
+ ## CRITICAL: GAPS_DISCOVERED Semantics
88
52
 
89
- - Table exists with expected name
90
- - Columns match plan (names, types, nullability)
91
- - Access policies exist (RLS, grants, permissions — whatever the project uses)
92
- - Indexes or constraints mentioned in the plan are present
53
+ **`GAPS_DISCOVERED` = total gaps + enhancements FOUND during the pass, REGARDLESS of whether they were also fixed.**
93
54
 
94
- ```bash
95
- # Example: check migration files exist
96
- ls -la [MIGRATION_PATH_FROM_PLAN]
55
+ | Scenario | GAPS_DISCOVERED | Loop Action |
56
+ |----------|----------------|-------------|
57
+ | Pass finds 0 gaps/enhancements | 0 | **EXIT** — analysis complete |
58
+ | Pass finds 12 gaps, fixes all 12 | **12** (NOT 0) | **CONTINUE** — must re-analyze |
59
+ | Pass finds 5 gaps, fixes 3, 2 need controller | **5** | **CONTINUE** — fix remaining, re-analyze |
97
60
 
98
- # Example: grep migration content for expected table/column names
99
- grep -n "[TABLE_NAME]" [MIGRATION_FILE]
100
- grep -n "[COLUMN_NAME]" [MIGRATION_FILE]
101
- ```
102
-
103
- ### Step 2.2: API/Backend Verification
61
+ **THE RULE**: A clean pass means zero issues DISCOVERED from the start. Fixing gaps during a pass does NOT make it a clean pass. Only a fresh pass starting clean and finding nothing wrong proves the implementation is complete.
104
62
 
105
- For EACH endpoint or procedure in the plan:
106
-
107
- ```bash
108
- # Verify endpoint/procedure exists at the path specified in the plan
109
- grep -n "[endpoint_name]" [BACKEND_FILE_FROM_PLAN]
63
+ ---
110
64
 
111
- # Verify input validation/schema
112
- grep -A 20 "[endpoint_name]" [BACKEND_FILE_FROM_PLAN] | grep -A 10 "input\|schema\|validate"
65
+ ## MANDATORY LOOP CONTROLLER (EXECUTE THIS — DO NOT SKIP)
113
66
 
114
- # Verify the backend module is registered/exported in the project's routing layer
115
- grep "[module_name]" [ROUTER_OR_ENTRY_FILE_FROM_PLAN]
116
67
  ```
117
-
118
- ### Step 2.3: Component Verification
119
-
120
- For EACH UI component in the plan:
121
-
122
- ```bash
123
- # Verify component file exists at the path specified in the plan
124
- ls -la [COMPONENT_PATH_FROM_PLAN]
125
-
126
- # CRITICAL: Verify component is RENDERED in a page
127
- grep -rn "[ComponentName]" [PAGES_DIR_FROM_PLAN]
128
-
129
- # Verify component imports are correct
130
- grep -rn "import.*[ComponentName]" [PAGES_DIR_FROM_PLAN]
68
+ PLAN_PATH = $ARGUMENTS (the plan file path)
69
+ iteration = 0
70
+ MAX_ITERATIONS = 10
71
+
72
+ WHILE iteration < MAX_ITERATIONS:
73
+ iteration += 1
74
+
75
+ result = Task(subagent_type="general-purpose", prompt="
76
+ Gap & Enhancement Analysis — Iteration {iteration}
77
+
78
+ CONTEXT:
79
+ - Plan file: {PLAN_PATH}
80
+ - Implementation is COMPLETE
81
+ - Your job: find ALL gaps and enhancements, then FIX every one
82
+
83
+ INSTRUCTIONS:
84
+ 1. Read the plan file from disk
85
+ 2. Read CLAUDE.md for rules and patterns
86
+ 3. Review ALL files changed: git diff origin/main --name-only (or git diff HEAD~10 --name-only)
87
+ 4. Run ALL analysis categories below (A through H)
88
+ 5. For EACH gap/enhancement found: FIX IT immediately
89
+ 6. Verify each fix (build, type-check, test as appropriate)
90
+ 7. Report GAPS_DISCOVERED as total FOUND (even if all fixed)
91
+
92
+ ANALYSIS CATEGORIES:
93
+
94
+ A. FUNCTIONAL GAPS
95
+ - Missing error handling (try/catch, error boundaries, fallbacks)
96
+ - Missing loading states (spinners, skeletons, disabled buttons)
97
+ - Missing empty states ('No items found' messaging)
98
+ - Missing null/undefined guards on nullable fields
99
+ - Missing input validation (required fields, format, bounds)
100
+ - Incomplete CRUD (create exists but no edit/delete, or vice versa)
101
+ - Missing timeout wrappers on async calls (asyncio.timeout)
102
+ - Missing concurrency limits on external clients (semaphores)
103
+
104
+ B. UX GAPS
105
+ - Missing success feedback after mutations
106
+ - Missing confirmation for destructive actions
107
+ - Missing keyboard navigation
108
+ - Missing responsive behavior
109
+ - Inconsistent spacing or layout
110
+ - Missing breadcrumbs or navigation context
111
+ - User-unfriendly error messages (must be human-readable)
112
+
113
+ C. DATA INTEGRITY GAPS
114
+ - Optimistic updates without rollback
115
+ - Missing cache invalidation after mutations
116
+ - Stale data after navigation
117
+ - Missing pagination for large datasets
118
+ - Unhandled serialization edge cases
119
+
120
+ D. SECURITY GAPS
121
+ - Missing auth checks on mutations
122
+ - Missing input validation on API inputs
123
+ - Missing access control policies on new tables/resources
124
+ - Exposed sensitive data in responses
125
+ - Service token auth ordering (must precede auth bypass)
126
+
127
+ E. PATTERN COMPLIANCE
128
+ - Check for pattern violations against CLAUDE.md rules
129
+ - Verify naming conventions (snake_case, PascalCase, etc.)
130
+ - Check for hardcoded values that should be configurable
131
+ - Verify async patterns (lazy lock init, strong task refs, timeouts)
132
+
133
+ F. ENHANCEMENT OPPORTUNITIES
134
+ - Type safety improvements (replace Any with proper types)
135
+ - Code deduplication (extract shared logic)
136
+ - Performance optimizations (caching, batching, lazy loading)
137
+ - Accessibility improvements (aria-labels, focus management)
138
+ - Better logging (WARNING for dropped data, structured log levels)
139
+
140
+ G. E2E WIRING GAPS
141
+ - For each data flow, verify the complete chain:
142
+ WRITE: mutation/action reachable from UI or scheduler
143
+ STORE: data persists to real storage
144
+ READ: query reads from that same storage
145
+ DISPLAY: component/log renders the data
146
+ - Background features: WRITE->STORE->READ sufficient
147
+ - Query-only features: READ->DISPLAY sufficient
148
+
149
+ H. TEST COVERAGE GAPS
150
+ - Files without corresponding tests
151
+ - Tests behind guards that don't mock the guard
152
+ - Missing edge case tests (empty input, max bounds, error paths)
153
+ - Missing integration tests for multi-stage pipelines
154
+
155
+ FOR EACH FINDING:
156
+ 1. Classify: GAP or ENHANCEMENT
157
+ 2. Severity: P0 (broken/security) / P1 (incorrect/major) / P2 (polish/minor)
158
+ 3. FIX IT immediately
159
+ 4. Verify the fix works
160
+
161
+ CRITICAL INSTRUCTION FOR GAPS_DISCOVERED:
162
+ Report GAPS_DISCOVERED as the total number of issues you FOUND during this pass,
163
+ EVEN IF you also fixed them. Finding 12 issues and fixing all 12 = GAPS_DISCOVERED: 12.
164
+ A clean pass that finds nothing wrong from the start = GAPS_DISCOVERED: 0.
165
+
166
+ Return the structured result block at the end:
167
+ ---STRUCTURED-RESULT---
168
+ ITERATION: {iteration}
169
+ GAPS_DISCOVERED: [number]
170
+ ENHANCEMENTS_DISCOVERED: [number]
171
+ TOTAL_ISSUES: [number] (gaps + enhancements)
172
+ ITEMS_FIXED: [number]
173
+ ITEMS_REMAINING: [number]
174
+ ---END-RESULT---
175
+ ")
176
+
177
+ # Parse structured result
178
+ gaps = parse TOTAL_ISSUES from result (fallback: GAPS_DISCOVERED)
179
+
180
+ # Report iteration to user
181
+ Output: "Iteration {iteration}: {gaps} issues discovered"
182
+
183
+ IF gaps == 0:
184
+ Output: "GAP ANALYSIS COMPLETE — Clean pass with zero issues in iteration {iteration}"
185
+ BREAK
186
+ ELSE:
187
+ Output: "{gaps} issues discovered (and fixed) in iteration {iteration}, starting fresh re-analysis..."
188
+ CONTINUE
189
+
190
+ IF iteration == MAX_ITERATIONS AND gaps > 0:
191
+ Output: "WARNING: Gap analyzer did not converge after {MAX_ITERATIONS} iterations. {gaps} issues remain."
131
192
  ```
132
193
 
133
- ### Step 2.4: Backend-Frontend Coupling Verification (CRITICAL)
134
-
135
- **MANDATORY**: Verify ALL backend features are exposed in frontend.
194
+ ---
136
195
 
137
- Use grep to check that every backend endpoint/procedure is called from at least one frontend file:
196
+ ## RULES FOR THE LOOP CONTROLLER
138
197
 
139
- ```bash
140
- # For each backend endpoint, verify frontend usage
141
- grep -rn "[endpoint_or_procedure_name]" [FRONTEND_DIR_FROM_PLAN]
142
- # If 0 results, the backend feature is unreachable from the UI
143
- ```
198
+ | Rule | Meaning |
199
+ |------|---------|
200
+ | **NEVER output a final verdict while gaps > 0** | Only a zero-issue-from-start iteration produces the final report |
201
+ | **NEVER treat "found and fixed" as zero gaps** | Fixing during a pass still means gaps were discovered |
202
+ | **NEVER ask user "should I continue?"** | The loop is mandatory |
203
+ | **NEVER stop after fixing gaps** | Requires a FRESH re-analysis to verify |
204
+ | **ALWAYS use Task tool for analysis passes** | Subagents keep context clean |
205
+ | **ALWAYS parse GAPS_DISCOVERED from result** | This is the loop control variable |
206
+ | **Maximum 10 iterations** | If still failing after 10, report to user |
207
+ | **Enhancements are NOT optional** | All enhancements MUST be implemented (CR-45) |
208
+ | **No severity exemptions** | CRITICAL through MINOR, all get fixed |
144
209
 
145
- **Manual verification for plan-specific items:**
210
+ ---
146
211
 
147
- | Backend Item | Frontend Requirement | Verification |
148
- |--------------|---------------------|--------------|
149
- | Enum/constant values in backend | SELECT options in form | grep values in constants/config files |
150
- | New API endpoint | UI component calls it | grep endpoint name in frontend files |
151
- | Input schema fields | Form has all fields | grep field names in form component |
152
- | Type definitions | Frontend types match | compare backend types to component types |
212
+ ## ANALYSIS DETAIL: PLAN EXTRACTION (Subagent does this in each pass)
153
213
 
154
- ```markdown
155
- ### Backend-Frontend Coupling Status
156
- | Backend Feature | Frontend Exposure | Status |
157
- |-----------------|-------------------|--------|
158
- | [feature] | [component/form] | PRESENT/MISSING |
159
- ```
214
+ ### Plan Inventory
160
215
 
161
- ---
216
+ The subagent reads the plan and extracts ALL items:
162
217
 
163
- ## PHASE 3: GAP ANALYSIS
218
+ | Category | What to Extract |
219
+ |----------|-----------------|
220
+ | **Database** | Tables, columns, migrations, policies, grants |
221
+ | **API/Routers** | Endpoints, inputs, outputs, mutations, queries |
222
+ | **Components** | UI components, locations, dependencies |
223
+ | **Features** | User-facing functionality, workflows, integrations |
224
+ | **Configuration** | Environment variables, feature flags, settings |
225
+ | **Tests** | Test files, coverage requirements |
164
226
 
165
227
  ### Gap Categories
166
228
 
@@ -170,194 +232,82 @@ grep -rn "[endpoint_or_procedure_name]" [FRONTEND_DIR_FROM_PLAN]
170
232
  | **COUPLING** | Backend feature not exposed in UI (users can't access it) | P0 |
171
233
  | **MAJOR** | Significant functionality missing, UX broken | P1 |
172
234
  | **MINOR** | Small missing piece, cosmetic issue | P2 |
173
- | **DEVIATION** | Implemented differently than planned (may be intentional) | P3 |
174
-
175
- ### Gap Detection Methods
176
-
177
- #### 3.1: Plan-to-Implementation Gaps
178
-
179
- Compare plan items against actual implementation:
180
-
181
- ```markdown
182
- ### PLAN-TO-IMPLEMENTATION GAPS
183
-
184
- | Plan Item | Expected | Actual | Gap Type | Severity |
185
- |-----------|----------|--------|----------|----------|
186
- | P-001 | Table X with columns A,B,C | Only A,B exist | MISSING_COLUMN | MAJOR |
187
- | P-002 | Endpoint Y | Not found | MISSING_ENDPOINT | CRITICAL |
188
- | P-003 | Component Z | File exists but not rendered | NOT_RENDERED | CRITICAL |
189
- ```
190
-
191
- #### 3.2: Cross-Reference Gaps
192
-
193
- Check for inconsistencies between layers:
194
-
195
- ```bash
196
- # Backend endpoints without UI consumers (use paths from plan)
197
- grep -rn "[endpoint_name]" [FRONTEND_DIR_FROM_PLAN] | wc -l
198
- # If 0, endpoint may be unused
199
-
200
- # Components without page integration (use paths from plan)
201
- find [COMPONENTS_DIR_FROM_PLAN] -name "*.tsx" -o -name "*.jsx" -o -name "*.vue" | while read f; do
202
- name=$(basename "$f" | sed 's/\.[^.]*$//')
203
- grep -rn "$name" [PAGES_DIR_FROM_PLAN] || echo "ORPHAN: $name"
204
- done
205
- ```
235
+ | **ENHANCEMENT** | Improvement opportunity beyond original scope | P2 |
206
236
 
207
- #### 3.3: Error Handling Gaps
237
+ ### Backend-Frontend Coupling (VR-COUPLING)
208
238
 
209
- ```bash
210
- # Check for try/catch in async operations (use paths from plan)
211
- grep -rn "async" [BACKEND_FILES_FROM_PLAN] | grep -v "try" | head -20
239
+ **MANDATORY**: Verify ALL backend features are exposed in frontend.
212
240
 
213
- # Check for loading states (use paths from plan)
214
- grep -rn "loading\|isLoading\|isPending" [FRONTEND_FILES_FROM_PLAN] | wc -l
215
- ```
241
+ | Backend Item | Frontend Requirement |
242
+ |--------------|---------------------|
243
+ | Enum values in router | SELECT/UI options match |
244
+ | New API endpoint | UI component calls it |
245
+ | Input schema fields | Form has all fields |
246
+ | Response fields | Display component renders them |
216
247
 
217
248
  ---
218
249
 
219
- ## PHASE 4: ENHANCEMENT ANALYSIS
220
-
221
- ### Enhancement Categories
222
-
223
- | Category | Description | Priority Framework |
224
- |----------|-------------|-------------------|
225
- | **UX** | User experience improvements | Impact vs Effort |
226
- | **Performance** | Speed, efficiency optimizations | Measurable benefit |
227
- | **Security** | Hardening, additional checks | Risk reduction |
228
- | **Functionality** | Feature extensions | User value |
229
- | **Developer Experience** | Code quality, maintainability | Long-term value |
230
- | **Accessibility** | A11y improvements | Compliance + UX |
231
-
232
- ### Enhancement Detection Methods
233
-
234
- #### 4.1: UX Enhancements
235
-
236
- ```bash
237
- # Empty states - are they helpful? (use paths from plan)
238
- grep -rn "length === 0\|EmptyState\|empty" [FRONTEND_FILES_FROM_PLAN]
250
+ ## POST-LOOP: REPORT GENERATION
239
251
 
240
- # Loading states - are they smooth?
241
- grep -rn "isLoading\|Skeleton\|Spinner\|loading" [FRONTEND_FILES_FROM_PLAN]
252
+ After the loop exits with zero gaps, generate a final summary report.
242
253
 
243
- # Success feedback - is it clear?
244
- grep -rn "toast\|notification\|alert\|success" [FRONTEND_FILES_FROM_PLAN]
245
- ```
246
-
247
- #### 4.2: Performance Enhancements
254
+ ### Report Storage
248
255
 
249
- ```bash
250
- # Large list rendering - virtualization needed? (use paths from plan)
251
- grep -rn "\.map(" [FRONTEND_FILES_FROM_PLAN] | grep -v "slice\|virtualized\|paginate"
252
-
253
- # API calls - batching opportunity?
254
- grep -rn "fetch\|useQuery\|useMutation\|axios\|request" [FRONTEND_FILES_FROM_PLAN] | wc -l
255
256
  ```
256
-
257
- #### 4.3: Security Enhancements
258
-
259
- ```bash
260
- # Input validation - are all string inputs constrained? (use paths from plan)
261
- grep -rn "string\|text\|varchar" [BACKEND_FILES_FROM_PLAN] | grep -v "min\|max\|regex\|length\|validate"
257
+ reports/gap-analysis/[YYYY-MM-DD]-[plan-name-slug]-gap-analysis.md
262
258
  ```
263
259
 
264
- #### 4.4: Accessibility Enhancements
265
-
266
- ```bash
267
- # ARIA attributes (use paths from plan)
268
- grep -rn "aria-\|role=" [FRONTEND_FILES_FROM_PLAN]
269
-
270
- # Alt text
271
- grep -rn "<img\|<Image" [FRONTEND_FILES_FROM_PLAN] | grep -v "alt="
272
- ```
260
+ ### Report Contents
273
261
 
262
+ ```markdown
263
+ ---
264
+ title: Gap & Enhancement Analysis Report
265
+ plan: [PLAN_FILE_PATH]
266
+ analyzed_date: [YYYY-MM-DD HH:MM]
267
+ analyzer: massu-gap-enhancement-analyzer v2.0 (loop-until-zero)
268
+ iterations: [N]
274
269
  ---
275
270
 
276
- ## PHASE 5: REPORT GENERATION
277
-
278
- ### Report Structure
279
-
280
- ```markdown
281
271
  # Gap & Enhancement Analysis Report
282
272
 
283
273
  ## Executive Summary
284
274
 
285
275
  | Metric | Count |
286
276
  |--------|-------|
287
- | Plan Items | [N] |
288
- | Verified Complete | [X] |
289
- | Gaps Found | [G] |
290
- | Critical Gaps | [C] |
291
- | Enhancements Identified | [E] |
292
-
293
- **Overall Score**: [X/N] items verified ([%]%)
294
- **Gap Severity Distribution**: [C] Critical, [M] Major, [m] Minor
295
-
296
- ---
297
-
298
- ## Section 1: Plan Coverage Analysis
299
-
300
- ### Coverage Matrix
301
-
302
- | Phase | Items | Complete | Gaps | Coverage |
303
- |-------|-------|----------|------|----------|
304
- | Phase 1 | [N] | [X] | [G] | [%]% |
305
- | Phase 2 | [N] | [X] | [G] | [%]% |
306
- | **TOTAL** | [N] | [X] | [G] | [%]% |
307
-
308
- ---
309
-
310
- ## Section 2: Gap Report
311
-
312
- ### Critical Gaps (P0) - Must Fix
313
-
314
- | ID | Gap Description | Expected | Actual | Impact | Remediation |
315
- |----|-----------------|----------|--------|--------|-------------|
316
- | G-001 | [description] | [expected] | [actual] | [impact] | [fix steps] |
277
+ | Total Iterations | [N] |
278
+ | Total Gaps Found (all iterations) | [G] |
279
+ | Total Enhancements Found (all iterations) | [E] |
280
+ | All Fixed | YES |
281
+ | Clean Pass | Iteration [N] |
317
282
 
318
- ### Major Gaps (P1) - Should Fix
283
+ ## Iteration Log
319
284
 
320
- | ID | Gap Description | Expected | Actual | Impact | Remediation |
321
- |----|-----------------|----------|--------|--------|-------------|
285
+ | Iteration | Gaps | Enhancements | Fixed | Status |
286
+ |-----------|------|--------------|-------|--------|
287
+ | 1 | [N] | [N] | [N] | CONTINUE |
288
+ | 2 | [N] | [N] | [N] | CONTINUE |
289
+ | ... | | | | |
290
+ | [final] | 0 | 0 | 0 | CLEAN PASS |
322
291
 
323
- ### Minor Gaps (P2) - Nice to Fix
292
+ ## Items Fixed (All Iterations)
324
293
 
325
- | ID | Gap Description | Expected | Actual | Impact | Remediation |
326
- |----|-----------------|----------|--------|--------|-------------|
294
+ | # | Type | Severity | Description | File | Iteration |
295
+ |---|------|----------|-------------|------|-----------|
296
+ | 1 | GAP | P0 | [description] | [file] | 1 |
297
+ | 2 | ENHANCEMENT | P2 | [description] | [file] | 1 |
327
298
 
328
299
  ---
300
+ *Generated by massu-gap-enhancement-analyzer v2.0 (loop-until-zero)*
301
+ ```
329
302
 
330
- ## Section 3: Enhancement Recommendations
331
-
332
- ### High-Impact Enhancements (Recommended)
333
-
334
- | ID | Enhancement | Category | Impact | Effort | Priority |
335
- |----|-------------|----------|--------|--------|----------|
336
- | E-001 | [description] | UX/Perf/Sec | High/Med/Low | High/Med/Low | [1-5] |
337
-
338
- ---
339
-
340
- ## Section 4: Technical Debt Identified
341
-
342
- | ID | Debt Type | Location | Description | Risk if Unaddressed |
343
- |----|-----------|----------|-------------|---------------------|
344
- | TD-001 | [type] | [file:line] | [description] | [risk] |
345
-
346
- ---
347
-
348
- ## Section 5: Action Items
349
-
350
- ### Immediate Actions (Gaps)
351
-
352
- - [ ] G-001: [fix description]
353
-
354
- ### Recommended Enhancements
355
-
356
- - [ ] E-001: [enhancement description]
303
+ ### Report Index
357
304
 
358
- ### Technical Debt Items
305
+ Update `reports/gap-analysis/INDEX.md`:
359
306
 
360
- - [ ] TD-001: [debt resolution]
307
+ ```markdown
308
+ | Date | Plan | Iterations | Gaps Fixed | Enhancements | Report |
309
+ |------|------|------------|------------|--------------|--------|
310
+ | [date] | [plan] | [N] | [G] | [E] | [link] |
361
311
  ```
362
312
 
363
313
  ---
@@ -368,113 +318,36 @@ grep -rn "<img\|<Image" [FRONTEND_FILES_FROM_PLAN] | grep -v "alt="
368
318
  START
369
319
  |
370
320
  v
371
- [PHASE 1: Plan Extraction]
372
- - Read complete plan file
373
- - Extract all items into inventory
374
- - Create checklist
321
+ [Parse plan path from $ARGUMENTS]
375
322
  |
376
323
  v
377
- [PHASE 2: Implementation Verification]
378
- - Database verification (if applicable)
379
- - API/Backend verification
380
- - Component verification
381
- - Feature verification
382
- - Configuration verification
324
+ [LOOP ITERATION 1]
325
+ - Spawn subagent
326
+ - Subagent: read plan, read CLAUDE.md, analyze categories A-H
327
+ - Subagent: fix ALL issues found
328
+ - Subagent: return GAPS_DISCOVERED count
383
329
  |
384
330
  v
385
- [PHASE 3: Gap Analysis]
386
- - Plan-to-implementation gaps
387
- - Cross-reference gaps
388
- - Error handling gaps
331
+ [GAPS > 0?] --YES--> [LOOP ITERATION 2] --> ...
389
332
  |
390
- v
391
- [PHASE 4: Enhancement Analysis]
392
- - UX enhancements
393
- - Performance enhancements
394
- - Security enhancements
395
- - Accessibility enhancements
333
+ NO
396
334
  |
397
335
  v
398
- [PHASE 5: Report Generation]
399
- - Executive summary
400
- - Detailed gap report
401
- - Enhancement recommendations
402
- - Action items
336
+ [GENERATE FINAL REPORT]
337
+ - Save to reports/gap-analysis/
338
+ - Update INDEX.md
403
339
  |
404
340
  v
405
- [PHASE 6: Report Saving]
406
- - Save report to .claude/reports/gap-analysis/
407
- - Verify file saved
408
- |
409
- v
410
- OUTPUT: Full analysis report (displayed AND saved)
411
- ```
412
-
413
- ---
414
-
415
- ## OUTPUT REQUIREMENTS
416
-
417
- The final output MUST include:
418
-
419
- 1. **Executive Summary** with key metrics
420
- 2. **Coverage Matrix** showing plan completion percentage
421
- 3. **Gap Report** with severity, impact, and remediation for each gap
422
- 4. **Enhancement Recommendations** prioritized by impact/effort
423
- 5. **Action Items** checklist for follow-up work
424
- 6. **Verification Evidence** proving each check was performed
425
-
426
- ---
427
-
428
- ## PHASE 6: REPORT SAVING (MANDATORY)
429
-
430
- ### Report Storage Location
431
-
432
- ```
433
- .claude/reports/gap-analysis/
341
+ [OUTPUT: Zero-gap certification + report location]
434
342
  ```
435
343
 
436
- ### Report Naming Convention
437
-
438
- ```
439
- [YYYY-MM-DD]-[plan-name-slug]-gap-analysis.md
440
- ```
441
-
442
- ### Step 6.1: Create Reports Directory (if needed)
443
-
444
- ```bash
445
- mkdir -p .claude/reports/gap-analysis
446
- ```
447
-
448
- ### Step 6.2: Save the Complete Report
449
-
450
- Write the full report (from Phase 5) to the report file.
451
-
452
- ### Step 6.3: Verification
453
-
454
- ```bash
455
- # Verify report was saved
456
- ls -la .claude/reports/gap-analysis/[REPORT_FILE]
457
-
458
- # Verify report has content
459
- wc -l .claude/reports/gap-analysis/[REPORT_FILE]
460
- ```
461
-
462
- ---
463
-
464
- ## IMPORTANT NOTES
465
-
466
- - **When invoked standalone**: This command produces a report. ALL identified gaps and enhancements MUST then be fixed/implemented before the task is considered complete (CR-45). No severity level is exempt — CRITICAL through MINOR, all get fixed.
467
- - **When invoked as part of golden path/massu-loop**: Gaps and enhancements are fixed inline by the subagent during analysis.
468
- - Document evidence for every finding
469
- - **Enhancements are NOT optional** — all identified enhancements must be implemented (CR-45)
470
-
471
344
  ---
472
345
 
473
346
  ## START NOW
474
347
 
475
- 1. Confirm plan file path with user
476
- 2. Read the complete plan document
477
- 3. Execute Phase 1-5 in order
478
- 4. Generate comprehensive report
479
- 5. Save report to `.claude/reports/gap-analysis/`
480
- 6. Present findings to user with report location
348
+ 1. Parse plan file path from `$ARGUMENTS`
349
+ 2. Start the loop: spawn subagent for iteration 1
350
+ 3. Parse `GAPS_DISCOVERED` / `TOTAL_ISSUES` from the result
351
+ 4. If > 0: spawn another iteration (DO NOT ASK — loop is mandatory)
352
+ 5. If == 0: generate report, output final summary
353
+ 6. Continue until zero or max 10 iterations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massu/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "description": "AI Engineering Governance MCP Server - Session memory, knowledge system, feature registry, code intelligence, rule enforcement, auto-learning pipeline, tiered tooling (12 free / 72 total), 55+ workflow commands, 15 agents, 20+ patterns",
6
6
  "main": "src/server.ts",