@massu/core 0.1.2 → 0.4.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 (84) hide show
  1. package/commands/_shared-preamble.md +76 -0
  2. package/commands/massu-audit-deps.md +211 -0
  3. package/commands/massu-changelog.md +174 -0
  4. package/commands/massu-cleanup.md +315 -0
  5. package/commands/massu-commit.md +481 -0
  6. package/commands/massu-create-plan.md +752 -0
  7. package/commands/massu-dead-code.md +131 -0
  8. package/commands/massu-debug.md +484 -0
  9. package/commands/massu-deploy.md +91 -0
  10. package/commands/massu-deps.md +374 -0
  11. package/commands/massu-doc-gen.md +279 -0
  12. package/commands/massu-docs.md +364 -0
  13. package/commands/massu-estimate.md +313 -0
  14. package/commands/massu-golden-path.md +973 -0
  15. package/commands/massu-guide.md +167 -0
  16. package/commands/massu-hotfix.md +480 -0
  17. package/commands/massu-loop-playwright.md +837 -0
  18. package/commands/massu-loop.md +775 -0
  19. package/commands/massu-new-feature.md +511 -0
  20. package/commands/massu-parity.md +214 -0
  21. package/commands/massu-plan.md +456 -0
  22. package/commands/massu-push-light.md +207 -0
  23. package/commands/massu-push.md +434 -0
  24. package/commands/massu-refactor.md +410 -0
  25. package/commands/massu-release.md +363 -0
  26. package/commands/massu-review.md +238 -0
  27. package/commands/massu-simplify.md +281 -0
  28. package/commands/massu-status.md +278 -0
  29. package/commands/massu-tdd.md +201 -0
  30. package/commands/massu-test.md +516 -0
  31. package/commands/massu-verify-playwright.md +281 -0
  32. package/commands/massu-verify.md +667 -0
  33. package/dist/cli.js +12522 -0
  34. package/dist/hooks/cost-tracker.js +80 -5
  35. package/dist/hooks/post-edit-context.js +72 -6
  36. package/dist/hooks/post-tool-use.js +234 -57
  37. package/dist/hooks/pre-compact.js +144 -5
  38. package/dist/hooks/pre-delete-check.js +141 -11
  39. package/dist/hooks/quality-event.js +80 -5
  40. package/dist/hooks/security-gate.js +29 -0
  41. package/dist/hooks/session-end.js +83 -8
  42. package/dist/hooks/session-start.js +153 -7
  43. package/dist/hooks/user-prompt.js +166 -5
  44. package/package.json +6 -5
  45. package/src/backfill-sessions.ts +5 -4
  46. package/src/cli.ts +6 -0
  47. package/src/commands/doctor.ts +193 -6
  48. package/src/commands/init.ts +235 -6
  49. package/src/commands/install-commands.ts +137 -0
  50. package/src/config.ts +68 -2
  51. package/src/db.ts +115 -2
  52. package/src/docs-tools.ts +8 -6
  53. package/src/hooks/post-edit-context.ts +1 -1
  54. package/src/hooks/post-tool-use.ts +130 -0
  55. package/src/hooks/pre-compact.ts +23 -1
  56. package/src/hooks/pre-delete-check.ts +92 -4
  57. package/src/hooks/security-gate.ts +32 -0
  58. package/src/hooks/session-start.ts +97 -4
  59. package/src/hooks/user-prompt.ts +46 -1
  60. package/src/import-resolver.ts +2 -1
  61. package/src/knowledge-db.ts +169 -0
  62. package/src/knowledge-indexer.ts +704 -0
  63. package/src/knowledge-tools.ts +1413 -0
  64. package/src/license.ts +482 -0
  65. package/src/memory-db.ts +14 -1
  66. package/src/observation-extractor.ts +11 -4
  67. package/src/page-deps.ts +3 -2
  68. package/src/python/coupling-detector.ts +124 -0
  69. package/src/python/domain-enforcer.ts +83 -0
  70. package/src/python/impact-analyzer.ts +95 -0
  71. package/src/python/import-parser.ts +244 -0
  72. package/src/python/import-resolver.ts +135 -0
  73. package/src/python/migration-indexer.ts +115 -0
  74. package/src/python/migration-parser.ts +332 -0
  75. package/src/python/model-indexer.ts +70 -0
  76. package/src/python/model-parser.ts +279 -0
  77. package/src/python/route-indexer.ts +58 -0
  78. package/src/python/route-parser.ts +317 -0
  79. package/src/python-tools.ts +629 -0
  80. package/src/sentinel-db.ts +2 -1
  81. package/src/server.ts +29 -6
  82. package/src/session-archiver.ts +4 -5
  83. package/src/tools.ts +283 -31
  84. package/README.md +0 -40
@@ -0,0 +1,973 @@
1
+ ---
2
+ name: massu-golden-path
3
+ description: Complete end-to-end workflow from requirements to production push with minimal pause points
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), Task(*), mcp__plugin_playwright_playwright__*, mcp__playwright__*
5
+ ---
6
+ name: massu-golden-path
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
9
+
10
+ # Massu Golden Path: Requirements to Production Push
11
+
12
+ ## Objective
13
+
14
+ Execute the COMPLETE development workflow in one continuous run:
15
+ **Requirements --> Plan Creation --> Plan Audit --> Implementation --> Browser Verification --> Simplification --> Commit --> Push**
16
+
17
+ This command has FULL FEATURE PARITY with the individual commands it replaces:
18
+ `/massu-create-plan` --> `/massu-plan` --> `/massu-loop` --> `/massu-loop-playwright` --> `/massu-simplify` --> `/massu-commit` --> `/massu-push`
19
+
20
+ ---
21
+
22
+ ## NON-NEGOTIABLE RULES
23
+
24
+ - **Complete workflow** -- ALL phases must execute, no skipping
25
+ - **Zero failures** -- Each phase gate must pass before proceeding
26
+ - **Proof required** -- Show output of each phase gate
27
+ - **FIX ALL ISSUES ENCOUNTERED (CR-9)** -- Whether from current changes or pre-existing
28
+ - **MEMORY IS MANDATORY (CR-38)** -- Persist ALL learnings before session ends
29
+
30
+ ---
31
+
32
+ ## APPROVAL POINTS (Max 4 Pauses)
33
+
34
+ ```
35
+ +-----------------------------------------------------------------------------+
36
+ | THIS COMMAND RUNS STRAIGHT THROUGH THE ENTIRE GOLDEN PATH. |
37
+ | IT ONLY PAUSES FOR THESE APPROVAL POINTS: |
38
+ | |
39
+ | 1. PLAN APPROVAL - After plan creation + audit (user reviews plan) |
40
+ | 2. NEW PATTERN APPROVAL - If a new pattern is needed (during any phase) |
41
+ | 3. COMMIT APPROVAL - Before creating the commit |
42
+ | 4. PUSH APPROVAL - Before pushing to remote |
43
+ | |
44
+ | EVERYTHING ELSE RUNS AUTOMATICALLY WITHOUT STOPPING. |
45
+ +-----------------------------------------------------------------------------+
46
+ ```
47
+
48
+ ### Approval Point Format
49
+
50
+ ```
51
+ ===============================================================================
52
+ APPROVAL REQUIRED: [TYPE]
53
+ ===============================================================================
54
+
55
+ [Details]
56
+
57
+ OPTIONS:
58
+ - "approve" / "yes" to continue
59
+ - "modify" to request changes
60
+ - "abort" to stop the golden path
61
+
62
+ ===============================================================================
63
+ ```
64
+
65
+ After receiving approval, immediately continue. Do NOT ask "shall I continue?" -- just proceed.
66
+
67
+ ---
68
+
69
+ ## INPUT MODES
70
+
71
+ | Mode | Input | Behavior |
72
+ |------|-------|----------|
73
+ | **Task Description** | `/massu-golden-path "Implement feature X"` | Full flow from Phase 0 |
74
+ | **Plan File** | `/massu-golden-path /path/to/plan.md` | Skip to Phase 1C (audit) |
75
+ | **Continue** | `/massu-golden-path "Continue [feature]"` | Resume from session state |
76
+
77
+ ---
78
+
79
+ ## PHASE 0: REQUIREMENTS & CONTEXT LOADING
80
+
81
+ ### 0.1 Session Context Loading
82
+
83
+ ```
84
+ [GOLDEN PATH -- PHASE 0: REQUIREMENTS & CONTEXT]
85
+ ```
86
+
87
+ - Read `session-state/CURRENT.md` for any prior state
88
+ - Read `massu.config.yaml` for project configuration
89
+ - Search memory files for relevant prior context
90
+
91
+ ### 0.2 Requirements Coverage Map
92
+
93
+ Initialize ALL dimensions as `pending`:
94
+
95
+ | # | Dimension | Status | Resolved By |
96
+ |---|-----------|--------|-------------|
97
+ | D1 | Problem & Scope | pending | User request + interview |
98
+ | D2 | Users & Personas | pending | Interview |
99
+ | D3 | Data Model | pending | Phase 1A (Config/Schema Reality Check) |
100
+ | D4 | Backend / API | pending | Phase 1A (Codebase Reality Check) |
101
+ | D5 | Frontend / UX | pending | Interview + Phase 1A |
102
+ | D6 | Auth & Permissions | pending | Phase 1A (Security Pre-Screen) |
103
+ | D7 | Error Handling | pending | Phase 1A (Pattern Compliance) |
104
+ | D8 | Security | pending | Phase 1A (Security Pre-Screen) |
105
+ | D9 | Edge Cases | pending | Phase 1A (Question Filtering) |
106
+ | D10 | Performance | pending | Phase 1A (Pattern Compliance) |
107
+
108
+ ### 0.3 Ambiguity Detection (7 Signals)
109
+
110
+ | Signal | Description |
111
+ |--------|-------------|
112
+ | A1 | Vague scope -- no clear boundary |
113
+ | A2 | No success criteria -- no measurable outcome |
114
+ | A3 | Implicit requirements -- unstated but necessary |
115
+ | A4 | Multi-domain -- spans 3+ domains |
116
+ | A5 | Contradictions -- conflicting constraints |
117
+ | A6 | No persona -- unclear who benefits |
118
+ | A7 | New integration -- external service not yet in codebase |
119
+
120
+ **Score >= 2**: Enter interview loop (0.4). **Score 0-1**: Fast-track to Phase 1A.
121
+
122
+ ### 0.4 Interview Loop (When Triggered)
123
+
124
+ Ask via AskUserQuestion, one question at a time:
125
+ 1. Show compact coverage status: `Coverage: D1:done D2:pending ...`
126
+ 2. Provide 2-4 curated options (never open-ended)
127
+ 3. Push back on contradictions and over-engineering
128
+ 4. Self-terminate when D1, D2, D5 covered
129
+ 5. Escape hatch: user says "skip" / "enough" / "just do it" --> mark remaining as `n/a`
130
+
131
+ ---
132
+
133
+ ## PHASE 1: PLAN CREATION & AUDIT
134
+
135
+ ### Phase 1A: Research & Reality Check
136
+
137
+ ```
138
+ [GOLDEN PATH -- PHASE 1A: RESEARCH & REALITY CHECK]
139
+ ```
140
+
141
+ **If plan file was provided**: Skip to Phase 1C.
142
+
143
+ #### 1A.1 Feature Understanding
144
+
145
+ - Document: exact user request, feature type, affected domains
146
+ - Search codebase for similar features, tool modules, existing patterns
147
+ - Read `massu.config.yaml` for relevant config sections
148
+
149
+ #### 1A.2 Config & Schema Reality Check
150
+
151
+ For features touching config or databases:
152
+
153
+ - Parse `massu.config.yaml` and verify all referenced config keys exist
154
+ - Check SQLite schema for affected tables (`getCodeGraphDb`, `getDataDb`, `getMemoryDb`)
155
+ - Verify tool definitions in `tools.ts` for any tools being modified
156
+
157
+ Document: existing config keys, required new keys, required schema changes.
158
+
159
+ #### 1A.3 Config-Code Alignment (VR-CONFIG)
160
+
161
+ If feature uses config-driven values:
162
+
163
+ ```bash
164
+ # Check config keys used in code
165
+ grep -rn "getConfig()" packages/core/src/ | grep -oP 'config\.\w+' | sort -u
166
+ # Compare to massu.config.yaml structure
167
+ ```
168
+
169
+ #### 1A.4 Codebase Reality Check
170
+
171
+ - Verify target directories/files exist
172
+ - Read similar tool modules and handlers
173
+ - Load relevant pattern files (build/testing/security/database/mcp)
174
+
175
+ #### 1A.5 Blast Radius Analysis (CR-10)
176
+
177
+ **MANDATORY when plan changes any constant, export name, config key, or tool name.**
178
+
179
+ 1. Identify ALL changed values (old --> new)
180
+ 2. Codebase-wide grep for EACH value
181
+ 3. If plan deletes files: verify no remaining imports or references
182
+ 4. Categorize EVERY occurrence: CHANGE / KEEP (with reason) / INVESTIGATE
183
+ 5. Resolve ALL INVESTIGATE to 0. Add ALL CHANGE items as plan deliverables.
184
+
185
+ #### 1A.6 Pattern Compliance Check
186
+
187
+ Check applicable patterns: ESM imports (.ts extensions), config access (getConfig()), tool registration (3-function pattern), hook compilation (esbuild), SQLite DB access (getCodeGraphDb/getDataDb/getMemoryDb), memDb lifecycle (try/finally close).
188
+
189
+ Read most similar tool module for patterns used.
190
+
191
+ #### 1A.7 Tool Registration Check (CR-11)
192
+
193
+ For EVERY new MCP tool planned -- verify a corresponding registration item exists in the plan (definitions + routing + handler in `tools.ts`). If NOT, ADD IT.
194
+
195
+ #### 1A.8 Question Filtering
196
+
197
+ 1. List all open questions
198
+ 2. Self-answer anything answerable by reading code or config
199
+ 3. Surface only business logic / UX / scope / priority questions to user via AskUserQuestion
200
+ 4. If all self-answerable, skip user prompt
201
+
202
+ #### 1A.9 Security Pre-Screen (5 Dimensions)
203
+
204
+ | Dim | Check | If Triggered |
205
+ |-----|-------|-------------|
206
+ | S1 | PII / Sensitive Data | Add access controls |
207
+ | S2 | Authentication | Verify auth checks |
208
+ | S3 | Authorization | Add permission checks |
209
+ | S4 | Injection Surfaces | Add input validation, parameterized queries |
210
+ | S5 | Rate Limiting | Add rate limiting considerations |
211
+
212
+ **BLOCKS_REMAINING must = 0 before proceeding.**
213
+
214
+ Mark all coverage dimensions as `done` or `n/a`.
215
+
216
+ ### Phase 1B: Plan Generation
217
+
218
+ ```
219
+ [GOLDEN PATH -- PHASE 1B: PLAN GENERATION]
220
+ ```
221
+
222
+ Write plan to: `docs/plans/[YYYY-MM-DD]-[feature-name].md`
223
+
224
+ **Plan structure** (P-XXX numbered items):
225
+ - Overview (feature, complexity, domains, item count)
226
+ - Requirements Coverage Map (D1-D10 all resolved)
227
+ - Phase 1: Configuration Changes (massu.config.yaml)
228
+ - Phase 2: Backend Implementation (tool modules, handlers, SQLite schema)
229
+ - Phase 3: Frontend/Hook Implementation (hooks, plugin code)
230
+ - Phase 4: Testing & Verification
231
+ - Phase 5: Documentation
232
+ - Verification Commands table
233
+ - Item Summary table
234
+ - Risk Assessment
235
+ - Dependencies
236
+
237
+ **Item numbering**: P1-XXX (config), P2-XXX (backend), P3-XXX (frontend/hooks), P4-XXX (testing), P5-XXX (docs).
238
+
239
+ **Implementation Specificity Check**: Every item MUST have exact file path, exact content, insertion point, format matches target, verification command.
240
+
241
+ ### Phase 1C: Plan Audit Loop
242
+
243
+ ```
244
+ [GOLDEN PATH -- PHASE 1C: PLAN AUDIT LOOP]
245
+ ```
246
+
247
+ Run audit loop using subagent architecture (prevents early termination):
248
+
249
+ ```
250
+ iteration = 0
251
+ WHILE true:
252
+ iteration += 1
253
+
254
+ result = Task(subagent_type="massu-plan-auditor", model="opus", prompt="
255
+ Audit iteration {iteration} for plan: {PLAN_PATH}
256
+ Execute ONE complete audit pass. Verify ALL deliverables.
257
+ Check: VR-PLAN-FEASIBILITY, VR-PLAN-SPECIFICITY, Pattern Alignment, Config Reality.
258
+ Fix any plan document gaps you find.
259
+
260
+ CRITICAL: Report GAPS_DISCOVERED as total gaps FOUND, EVEN IF you fixed them.
261
+ Finding N gaps and fixing all N = GAPS_DISCOVERED: N.
262
+ A clean pass finding nothing = GAPS_DISCOVERED: 0.
263
+ ")
264
+
265
+ gaps = parse GAPS_DISCOVERED from result
266
+ IF gaps == 0: BREAK (clean pass)
267
+ ELSE: CONTINUE (re-audit)
268
+
269
+ IF iteration >= 10: Report to user, ask how to proceed
270
+ END WHILE
271
+ ```
272
+
273
+ **VR-PLAN-FEASIBILITY**: Files exist, config keys valid, dependencies available, patterns documented.
274
+ **VR-PLAN-SPECIFICITY**: Every item has exact path, exact content, insertion point, verification command.
275
+ **Pattern Alignment**: Cross-reference ALL applicable patterns from CLAUDE.md and patterns/*.md.
276
+
277
+ ### Phase 1 Complete --> APPROVAL POINT #1: PLAN
278
+
279
+ ```
280
+ ===============================================================================
281
+ APPROVAL REQUIRED: PLAN
282
+ ===============================================================================
283
+
284
+ Plan created and audited ({iteration} audit passes, 0 gaps).
285
+
286
+ PLAN SUMMARY:
287
+ -------------------------------------------------------------------------------
288
+ Feature: [name]
289
+ File: [plan path]
290
+ Total Items: [N]
291
+ Phases: [list]
292
+
293
+ Requirements Coverage: [X]/10 dimensions resolved
294
+ Feasibility: VERIFIED (config, files, patterns, security)
295
+ Audit Passes: {iteration} (final pass: 0 gaps)
296
+ -------------------------------------------------------------------------------
297
+
298
+ OPTIONS:
299
+ - "approve" to begin implementation
300
+ - "modify: [changes]" to adjust plan
301
+ - "abort" to stop
302
+
303
+ ===============================================================================
304
+ ```
305
+
306
+ ---
307
+
308
+ ## PHASE 2: IMPLEMENTATION
309
+
310
+ ### Phase 2A: Plan Item Extraction & Setup
311
+
312
+ ```
313
+ [GOLDEN PATH -- PHASE 2: IMPLEMENTATION]
314
+ ```
315
+
316
+ 1. Read plan from disk (NOT memory -- CR-5)
317
+ 2. Extract ALL deliverables into tracking table:
318
+
319
+ | Item # | Type | Description | Location | Verification | Status |
320
+ |--------|------|-------------|----------|--------------|--------|
321
+ | P1-001 | CONFIG | ... | ... | VR-CONFIG | PENDING |
322
+
323
+ 3. Create VR-PLAN verification strategy:
324
+
325
+ | # | VR-* Check | Target | Why Applicable | Status |
326
+ |---|-----------|--------|----------------|--------|
327
+ | 1 | VR-BUILD | Full project | Always | PENDING |
328
+
329
+ 4. Initialize session state with AUTHORIZED_COMMAND: massu-golden-path
330
+
331
+ ### Phase 2B: Implementation Loop
332
+
333
+ For each plan item:
334
+ 1. **Pre-check**: Verify file exists, read current state
335
+ 2. **Execute**: Implement the item following established patterns
336
+ 3. **Guardrail**: Run `bash scripts/massu-pattern-scanner.sh` (ABORT if fails)
337
+ 4. **Verify**: Run applicable VR-* checks with proof
338
+ 5. **Update**: Mark item complete in tracking table
339
+
340
+ **DO NOT STOP between items** unless:
341
+ - New pattern needed (Approval Point #2)
342
+ - True blocker (external service, credentials)
343
+ - Critical error after 3 retries
344
+
345
+ **Checkpoint Audit at phase boundaries** (after all P1-XXX, after all P2-XXX, etc.):
346
+
347
+ ```
348
+ CHECKPOINT:
349
+ [1] READ plan section [2] GREP tool registrations [3] LS modules
350
+ [4] VR-CONFIG check [5] VR-TOOL-REG check [6] VR-HOOK-BUILD check
351
+ [7] Pattern scanner [8] npm run build [9] cd packages/core && npx tsc --noEmit
352
+ [10] npm test [11] VR-GENERIC check [12] Security scanner
353
+ [13] COUNT gaps --> IF > 0: FIX and return to [1]
354
+ ```
355
+
356
+ ### Phase 2C: Multi-Perspective Review
357
+
358
+ After implementation, BEFORE verification loop -- spawn 3 review agents **IN PARALLEL**:
359
+
360
+ ```
361
+ security_result = Task(subagent_type="massu-security-reviewer", model="opus", prompt="
362
+ Review implementation for plan: {PLAN_PATH}
363
+ Focus: Security vulnerabilities, auth gaps, input validation, data exposure.
364
+ Return structured result with SECURITY_GATE: PASS/FAIL.
365
+ ")
366
+
367
+ architecture_result = Task(subagent_type="massu-architecture-reviewer", model="opus", prompt="
368
+ Review implementation for plan: {PLAN_PATH}
369
+ Focus: Design issues, coupling, pattern compliance, scalability.
370
+ Return structured result with ARCHITECTURE_GATE: PASS/FAIL.
371
+ ")
372
+
373
+ quality_result = Task(subagent_type="massu-quality-reviewer", model="sonnet", prompt="
374
+ Review implementation for plan: {PLAN_PATH}
375
+ Focus: Code quality, ESM compliance, config-driven patterns, TypeScript strict mode, test coverage.
376
+ Return structured result with QUALITY_GATE: PASS/FAIL.
377
+ ")
378
+ ```
379
+
380
+ Fix ALL CRITICAL/HIGH findings before proceeding. WARN findings = document and proceed.
381
+
382
+ ### Phase 2D: Verification Audit Loop
383
+
384
+ ```
385
+ iteration = 0
386
+ WHILE true:
387
+ iteration += 1
388
+
389
+ # Circuit breaker (CR-37)
390
+ IF iteration >= 3 AND same gaps as previous iteration:
391
+ AskUserQuestion: "Loop stalled after {iteration} passes. Re-plan / Continue / Stop?"
392
+
393
+ result = Task(subagent_type="massu-plan-auditor", model="opus", prompt="
394
+ Audit iteration {iteration} for plan: {PLAN_PATH}
395
+ Verify ALL deliverables with VR-* proof.
396
+ Check code quality (patterns, build, types, tests).
397
+ Check plan coverage (every item verified).
398
+ Fix any gaps you find.
399
+
400
+ CRITICAL: GAPS_DISCOVERED = total FOUND, even if fixed.
401
+ Finding 5 + fixing 5 = GAPS_DISCOVERED: 5 (NOT 0).
402
+ ")
403
+
404
+ gaps = parse GAPS_DISCOVERED from result
405
+ Output: "Verification iteration {iteration}: {gaps} gaps"
406
+
407
+ IF gaps == 0: BREAK
408
+ IF iteration >= 10: Report remaining gaps, ask user
409
+ END WHILE
410
+ ```
411
+
412
+ ### Phase 2E: Post-Build Reflection + Memory Persist (CR-38)
413
+
414
+ **MANDATORY -- reflection + memory write = ONE atomic action.**
415
+
416
+ Answer these questions:
417
+ 1. "Now that I've built this, what would I have done differently?"
418
+ 2. "What should be refactored before moving on?"
419
+ 3. "Did we over-build? Is there a simpler way?"
420
+ 4. "Would a staff engineer approve this?" (Core Principle #9)
421
+
422
+ **IMMEDIATELY write ALL learnings to memory/ files** -- failed approaches, new patterns, tool gotchas, architectural insights. DO NOT output reflections as text without writing to memory.
423
+
424
+ Apply any low-risk refactors immediately. Log remaining suggestions in plan under `## Post-Build Reflection`.
425
+
426
+ ### Phase 2F: Documentation Sync (User-Facing Features)
427
+
428
+ If plan includes ANY user-facing features (new MCP tools, config changes, hook changes):
429
+
430
+ 1. Update relevant documentation (README, API docs, config docs)
431
+ 2. Ensure tool descriptions match implementation
432
+ 3. Update config schema documentation if config keys changed
433
+
434
+ Skip ONLY if purely internal refactoring with zero user-facing changes.
435
+
436
+ ### Phase 2G: Browser Verification & Fix Loop (`/massu-loop-playwright`)
437
+
438
+ ```
439
+ [GOLDEN PATH -- PHASE 2G: BROWSER VERIFICATION]
440
+ ```
441
+
442
+ **This phase executes the full `/massu-loop-playwright` protocol inline.** See `massu-loop-playwright.md` for the standalone version.
443
+
444
+ **Auto-trigger condition**: If plan touches ANY UI/demo files or produces visual output, this phase runs automatically. If purely backend/MCP/config with zero visual output, skip with log note: `Browser verification: SKIPPED (no UI files changed)`.
445
+
446
+ #### 2G.1 Determine Target Pages
447
+
448
+ Map changed features to testable URLs:
449
+ - If Massu has a demo page or documentation site: test affected pages
450
+ - If testing MCP tool output: use a test harness or verify tool responses
451
+ - Component changes: identify ALL pages that render the component
452
+
453
+ #### 2G.2 Browser Setup & Authentication
454
+
455
+ Use Playwright MCP plugin tools (`mcp__plugin_playwright_playwright__*`). Fallback: `mcp__playwright__*`.
456
+
457
+ 1. `browser_navigate` to target URL ($TARGET_URL)
458
+ 2. `browser_snapshot` to check page status
459
+ 3. If authentication required: STOP and request manual login
460
+
461
+ ```
462
+ AUTHENTICATION REQUIRED
463
+
464
+ The Playwright browser is not logged in to the target application.
465
+ Please log in manually in the open browser window, then re-run the golden path.
466
+ ```
467
+
468
+ **NEVER type credentials. NEVER hardcode passwords. NEVER proceed without authentication.**
469
+
470
+ #### 2G.3 Load Audit (Per Page)
471
+
472
+ For EACH target page:
473
+
474
+ | Check | Tool | Captures |
475
+ |-------|------|----------|
476
+ | Console errors/warnings | `browser_console_messages` | React errors, TypeError, CSP violations |
477
+ | Network failures | `browser_network_requests` | 500s, 404s, CORS failures, timeouts |
478
+
479
+ Categorize findings:
480
+
481
+ | Category | Severity |
482
+ |----------|----------|
483
+ | Crash, 500 error, data exposure | **P0 -- CRITICAL** |
484
+ | Network failure, broken interaction | **P1 -- HIGH** |
485
+ | Visual issues, performance warnings | **P2 -- MEDIUM** |
486
+ | Console warnings, deprecations | **P3 -- LOW** |
487
+
488
+ #### 2G.4 Interactive Testing (Per Page)
489
+
490
+ 1. `browser_snapshot` --> inventory ALL interactive elements (buttons, links, forms, selects, tabs, modals, data tables)
491
+ 2. For EACH testable element:
492
+ - Capture console state BEFORE interaction (`browser_console_messages`)
493
+ - Perform interaction (`browser_click`, `browser_select_option`, `browser_fill_form`)
494
+ - Wait 2-3 seconds for async operations
495
+ - Capture console state AFTER interaction
496
+ - Record any NEW errors introduced
497
+ - `browser_snapshot` to verify DOM state after interaction
498
+ - If interaction opened modal/sheet: test elements inside, then close
499
+
500
+ **SAFETY**: Never submit forms, click Delete/Send/Submit, or create real records on production.
501
+
502
+ #### 2G.5 Visual & Performance Audit
503
+
504
+ **Visual checks**:
505
+ - Broken images: `browser_evaluate` to find `img` elements with `naturalWidth === 0`
506
+ - Layout issues: overflow, overlapping, missing content, broken alignment
507
+ - Responsive: `browser_resize` at 1440x900 (desktop), 768x1024 (tablet), 375x812 (mobile)
508
+ - Screenshot evidence: `browser_take_screenshot` at each breakpoint if issues found
509
+
510
+ **Performance checks**:
511
+ - Page load timing via `browser_evaluate` (`performance.getEntriesByType('navigation')`)
512
+ - Resources > 500KB via `browser_evaluate` (`performance.getEntriesByType('resource')`)
513
+ - Slow API calls > 3s, duplicate requests via `browser_network_requests`
514
+
515
+ | Metric | Good | Needs Work | Critical |
516
+ |--------|------|------------|----------|
517
+ | DOM Content Loaded | < 2s | 2-5s | > 5s |
518
+ | Full Load | < 4s | 4-8s | > 8s |
519
+ | TTFB | < 500ms | 500ms-1.5s | > 1.5s |
520
+
521
+ #### 2G.6 Fix Loop
522
+
523
+ ```
524
+ issues = ALL findings from 2G.3-2G.5, sorted by priority (P0 first)
525
+
526
+ FOR EACH issue WHERE priority <= P2:
527
+ 1. IDENTIFY root cause (Grep/Read source files)
528
+ 2. APPLY fix (follow CLAUDE.md patterns)
529
+ 3. VERIFY fix (VR-GREP, VR-NEGATIVE, VR-BUILD, VR-TYPE)
530
+ 4. LOG fix in report
531
+
532
+ Zero-issue standard: ALL P0/P1 fixed, ALL P2 fixed or documented with justification.
533
+ Circuit breaker: 5 iterations on same page --> ask user.
534
+ ```
535
+
536
+ Post-fix: reload target URLs, re-run load audit + interactive testing for elements that had failures. If new errors appear, add to issues list and continue fix loop.
537
+
538
+ #### 2G.7 Report
539
+
540
+ Save to `.claude/playwright-reports/{TIMESTAMP}-{SLUG}.md`.
541
+
542
+ Report includes: summary table, console errors, network failures, interactive element failures, visual issues, performance issues, fix log with files changed and VR checks, unfixed issues with justification, screenshots.
543
+
544
+ #### 2G.8 Auto-Learning Protocol
545
+
546
+ For EACH browser-discovered fix:
547
+ 1. Update memory files with symptom/root cause/fix/files
548
+ 2. Add to `scripts/massu-pattern-scanner.sh` if the bad pattern is grep-able
549
+ 3. Codebase-wide search for same bad pattern (CR-9) -- fix ALL instances
550
+
551
+ ```
552
+ [GOLDEN PATH -- PHASE 2 COMPLETE]
553
+ - All plan items implemented
554
+ - Multi-perspective review: PASSED (security, architecture, quality)
555
+ - Verification audit: PASSED (Loop #{iteration}, 0 gaps)
556
+ - Post-build reflection: PERSISTED to memory
557
+ - Documentation sync: COMPLETE / N/A
558
+ - Browser verification: PASSED ({N} pages tested, {M} issues fixed) / SKIPPED (no UI files)
559
+ ```
560
+
561
+ ---
562
+
563
+ ## PHASE 3: SIMPLIFICATION (`/massu-simplify`)
564
+
565
+ ```
566
+ [GOLDEN PATH -- PHASE 3: SIMPLIFICATION]
567
+ ```
568
+
569
+ **This phase executes the full `/massu-simplify` protocol inline.** See `massu-simplify.md` for the standalone version.
570
+
571
+ ### 3.1 Fast Gate
572
+
573
+ ```bash
574
+ bash scripts/massu-pattern-scanner.sh # Fix ALL violations before semantic analysis
575
+ ```
576
+
577
+ ### 3.2 Parallel Semantic Review (3 Agents)
578
+
579
+ Spawn IN PARALLEL (Core Principle #10 -- one task per agent):
580
+
581
+ **Efficiency Reviewer** (haiku): Query inefficiency (findMany equivalent vs SQL COUNT, N+1 queries, unbounded queries), algorithmic inefficiency (O(n^2), repeated sort/filter), unnecessary allocations, missing caching opportunities.
582
+
583
+ **Reuse Reviewer** (haiku): Known utilities (getConfig(), stripPrefix(), tool registration patterns, memDb lifecycle pattern), module duplication against existing tool modules, pattern duplication across new files, config values that should be in massu.config.yaml.
584
+
585
+ **Pattern Compliance Reviewer** (haiku): ESM compliance (.ts import extensions, no require()), config-driven patterns (no hardcoded project-specific values -- CR-38/VR-GENERIC), TypeScript strict mode compliance, tool registration (3-function pattern preferred -- CR-11), hook compilation (esbuild compatible -- CR-12), memDb lifecycle (try/finally close), security (input validation, no eval/exec).
586
+
587
+ ### 3.3 Apply ALL Findings
588
+
589
+ Sort by SEVERITY (CRITICAL --> LOW). Fix ALL (CR-9). Re-run pattern scanner.
590
+
591
+ ```
592
+ SIMPLIFY_GATE: PASS (N findings, N fixed, 0 remaining)
593
+ ```
594
+
595
+ ---
596
+
597
+ ## PHASE 4: PRE-COMMIT VERIFICATION
598
+
599
+ ```
600
+ [GOLDEN PATH -- PHASE 4: PRE-COMMIT VERIFICATION]
601
+ ```
602
+
603
+ ### 4.1 Auto-Verification Gates (ALL must pass in SINGLE run)
604
+
605
+ | Gate | Command | Expected |
606
+ |------|---------|----------|
607
+ | 1. Pattern Scanner | `bash scripts/massu-pattern-scanner.sh` | Exit 0 |
608
+ | 2. Type Safety (VR-TYPE) | `cd packages/core && npx tsc --noEmit` | 0 errors |
609
+ | 3. Build (VR-BUILD) | `npm run build` | Exit 0 |
610
+ | 4. Tests (VR-TEST) | `npm test` | ALL pass |
611
+ | 5. Hook Compilation (VR-HOOK-BUILD) | `cd packages/core && npm run build:hooks` | Exit 0 |
612
+ | 6. Generalization (VR-GENERIC) | `bash scripts/massu-generalization-scanner.sh` | Exit 0 |
613
+ | 7. Security Scanner | `bash scripts/massu-security-scanner.sh` | Exit 0 |
614
+ | 8. Secrets Staged | `git diff --cached --name-only \| grep -E '\.(env\|pem\|key\|secret)'` | 0 files |
615
+ | 9. Credentials in Code | `grep -rn "sk-\|password.*=.*['\"]" --include="*.ts" packages/ \| grep -v "process.env" \| wc -l` | 0 |
616
+ | 10. VR-TOOL-REG | For EACH new tool: verify definitions + handler wired in tools.ts | All wired |
617
+ | 11. Plan Coverage | Verify ALL plan items with VR-* proof | 100% |
618
+ | 12. VR-PLAN-STATUS | `grep "IMPLEMENTATION STATUS" [plan]` | Match |
619
+ | 13. Dependency Security | `npm audit --audit-level=high` | 0 high/crit |
620
+
621
+ ### 4.2 Quality Scoring Gate
622
+
623
+ Spawn `massu-output-scorer` (sonnet): Code Clarity, Pattern Compliance, Error Handling, Test Coverage, Config-Driven Design (1-5 each). All >= 3: PASS. Any < 3: FAIL.
624
+
625
+ ### 4.3 If ANY Gate Fails
626
+
627
+ **DO NOT PAUSE** -- Fix automatically, re-run ALL gates, repeat until all pass.
628
+
629
+ ### 4.4 Auto-Learning Protocol
630
+
631
+ - For each bug fixed: update memory files
632
+ - For new patterns: record in memory
633
+ - Add detection to `scripts/massu-pattern-scanner.sh` if grep-able
634
+ - Codebase-wide search: no other instances of same bad pattern (CR-9)
635
+ - Record user corrections to `memory/corrections.md`
636
+
637
+ ### Phase 4 Complete --> APPROVAL POINT #3: COMMIT
638
+
639
+ ```
640
+ ===============================================================================
641
+ APPROVAL REQUIRED: COMMIT
642
+ ===============================================================================
643
+
644
+ All verification checks passed. Ready to commit.
645
+
646
+ VERIFICATION RESULTS:
647
+ -------------------------------------------------------------------------------
648
+ - Pattern scanner: Exit 0
649
+ - Type check: 0 errors
650
+ - Build: Exit 0
651
+ - Tests: ALL pass
652
+ - Hook compilation: Exit 0
653
+ - Generalization: Exit 0
654
+ - Security: No secrets staged, no credentials in code
655
+ - Tool registration: All new tools wired
656
+ - Plan Coverage: [X]/[X] = 100%
657
+ - Quality Score: [X.X]/5.0
658
+ -------------------------------------------------------------------------------
659
+
660
+ FILES TO BE COMMITTED:
661
+ [list]
662
+
663
+ PROPOSED COMMIT MESSAGE:
664
+ -------------------------------------------------------------------------------
665
+ [type]: [description]
666
+
667
+ [body]
668
+
669
+ Co-Authored-By: Claude <noreply@anthropic.com>
670
+ -------------------------------------------------------------------------------
671
+
672
+ OPTIONS:
673
+ - "approve" to commit and continue to push
674
+ - "message: [new message]" to change commit message
675
+ - "abort" to stop (changes remain staged)
676
+
677
+ ===============================================================================
678
+ ```
679
+
680
+ ### Commit Format
681
+
682
+ ```bash
683
+ git commit -m "$(cat <<'EOF'
684
+ [type]: [description]
685
+
686
+ [Body]
687
+
688
+ Changes:
689
+ - [Change 1]
690
+ - [Change 2]
691
+
692
+ Verified:
693
+ - Pattern scanner: PASS | Type check: 0 errors | Build: PASS
694
+ - Tests: ALL pass | Hooks: compiled | Generalization: PASS
695
+
696
+ Co-Authored-By: Claude <noreply@anthropic.com>
697
+ EOF
698
+ )"
699
+ ```
700
+
701
+ ---
702
+
703
+ ## PHASE 5: PUSH VERIFICATION & PUSH
704
+
705
+ ```
706
+ [GOLDEN PATH -- PHASE 5: PUSH VERIFICATION]
707
+ ```
708
+
709
+ ### 5.1 Pre-Flight
710
+
711
+ ```bash
712
+ git log origin/main..HEAD --oneline # Commits to push
713
+ ```
714
+
715
+ ### 5.2 Tier 1: Quick Re-Verification
716
+
717
+ Run in parallel where possible:
718
+
719
+ | Check | Command |
720
+ |-------|---------|
721
+ | Pattern Scanner | `bash scripts/massu-pattern-scanner.sh` |
722
+ | Generalization | `bash scripts/massu-generalization-scanner.sh` |
723
+ | TypeScript | `cd packages/core && npx tsc --noEmit` |
724
+ | Build | `npm run build` |
725
+ | Hook Compilation | `cd packages/core && npm run build:hooks` |
726
+
727
+ ### 5.3 Tier 2: Test Suite (CRITICAL)
728
+
729
+ #### 5.3.0 Regression Detection (MANDATORY FIRST)
730
+
731
+ ```bash
732
+ # Establish baseline on main
733
+ git stash && git checkout main -q
734
+ npm test 2>&1 | tee /tmp/baseline-tests.txt
735
+ git checkout - -q && git stash pop -q
736
+
737
+ # Run on current branch
738
+ npm test 2>&1 | tee /tmp/current-tests.txt
739
+
740
+ # Compare: any test passing on main but failing now = REGRESSION
741
+ # Regressions MUST be fixed before push
742
+ ```
743
+
744
+ #### 5.3.1-5.3.3 Test Execution
745
+
746
+ Use **parallel Task agents** for independent checks:
747
+
748
+ ```
749
+ Agent Group A (parallel):
750
+ - Agent 1: npm test (unit tests)
751
+ - Agent 2: npm audit --audit-level=high
752
+ - Agent 3: bash scripts/massu-security-scanner.sh
753
+
754
+ Sequential:
755
+ - VR-TOOL-REG: verify ALL new tools registered in tools.ts
756
+ - VR-GENERIC: verify ALL files pass generalization scanner
757
+ ```
758
+
759
+ ### 5.4 Tier 3: Security & Compliance
760
+
761
+ | Check | Command |
762
+ |-------|---------|
763
+ | npm audit | `npm audit --audit-level=high` |
764
+ | Security scan | `bash scripts/massu-security-scanner.sh` |
765
+ | Config validation | Parse massu.config.yaml without errors |
766
+
767
+ ### 5.5 Tier 4: Final Gate
768
+
769
+ All tiers must pass:
770
+
771
+ | Tier | Status |
772
+ |------|--------|
773
+ | Tier 1: Quick Checks | PASS/FAIL |
774
+ | Tier 2: Test Suite + Regression | PASS/FAIL |
775
+ | Tier 3: Security & Compliance | PASS/FAIL |
776
+
777
+ ### Phase 5 Gate --> APPROVAL POINT #4: PUSH
778
+
779
+ ```
780
+ ===============================================================================
781
+ APPROVAL REQUIRED: PUSH TO REMOTE
782
+ ===============================================================================
783
+
784
+ All verification tiers passed. Ready to push.
785
+
786
+ PUSH GATE SUMMARY:
787
+ -------------------------------------------------------------------------------
788
+ Commit: [hash]
789
+ Message: [message]
790
+ Files changed: [N] | +[N] / -[N]
791
+ Branch: [branch] --> origin
792
+
793
+ Tier 1 (Quick): PASS
794
+ Tier 2 (Tests): PASS -- Unit: X/X, Regression: 0
795
+ Tier 3 (Security): PASS -- Audit: 0 high/crit, Secrets: clean
796
+ -------------------------------------------------------------------------------
797
+
798
+ OPTIONS:
799
+ - "approve" / "push" to push to remote
800
+ - "abort" to stop (commit remains local)
801
+
802
+ ===============================================================================
803
+ ```
804
+
805
+ After approval: `git push origin [branch]`, then verify with `gh run list --limit 3`.
806
+
807
+ ---
808
+
809
+ ## PHASE 6: COMPLETION
810
+
811
+ ### 6.1 Final Report
812
+
813
+ ```
814
+ ===============================================================================
815
+ GOLDEN PATH COMPLETE
816
+ ===============================================================================
817
+
818
+ SUMMARY:
819
+ -------------------------------------------------------------------------------
820
+ Phase 0: Requirements & Context - D1-D10 resolved
821
+ Phase 1: Plan Creation & Audit - [N] items, [M] audit passes
822
+ Phase 2: Implementation - [N] audit loops, 3 reviewers passed
823
+ Phase 2G: Browser Verification - [N] pages tested, [M] issues fixed / SKIPPED
824
+ Phase 3: Simplification - [N] findings fixed
825
+ Phase 4: Pre-Commit Verification - All gates passed
826
+ Phase 5: Push Verification - 3 tiers passed, 0 regressions
827
+ -------------------------------------------------------------------------------
828
+
829
+ DELIVERABLES:
830
+ - Plan: [plan path]
831
+ - Commit: [hash]
832
+ - Branch: [branch]
833
+ - Pushed: YES
834
+ - Files changed: [N]
835
+
836
+ ===============================================================================
837
+ ```
838
+
839
+ ### 6.2 Plan Document Update (MANDATORY)
840
+
841
+ Add to TOP of plan document:
842
+
843
+ ```markdown
844
+ # IMPLEMENTATION STATUS
845
+
846
+ **Plan**: [Name]
847
+ **Status**: COMPLETE -- PUSHED
848
+ **Last Updated**: [YYYY-MM-DD HH:MM]
849
+ **Push Commit**: [hash]
850
+ **Completed By**: Claude Code (Massu Golden Path)
851
+
852
+ ## Task Completion Summary
853
+ | # | Task/Phase | Status | Verification | Date |
854
+ |---|------------|--------|--------------|------|
855
+ | 1 | [description] | 100% COMPLETE | VR-BUILD: Pass | [date] |
856
+ ```
857
+
858
+ ### 6.3 Auto-Learning Protocol (MANDATORY)
859
+
860
+ 1. Review ALL fixes: `git diff origin/main..HEAD`
861
+ 2. For each fix: verify memory files updated
862
+ 3. For each new pattern: verify recorded
863
+ 4. For each failed approach: verify recorded
864
+ 5. Record user corrections to `memory/corrections.md`
865
+ 6. Consider new CR rule if a class of bug was found
866
+
867
+ ### 6.4 Update Session State
868
+
869
+ Update `session-state/CURRENT.md` with completion status.
870
+
871
+ ---
872
+
873
+ ## NEW PATTERN APPROVAL (APPROVAL POINT #2 -- Any Phase)
874
+
875
+ If a new pattern is needed during ANY phase:
876
+
877
+ ```
878
+ ===============================================================================
879
+ APPROVAL REQUIRED: NEW PATTERN
880
+ ===============================================================================
881
+
882
+ A new pattern is needed for: [functionality]
883
+
884
+ Existing patterns checked:
885
+ - [pattern 1]: Not suitable because [reason]
886
+
887
+ PROPOSED NEW PATTERN:
888
+ -------------------------------------------------------------------------------
889
+ Name: [Pattern Name]
890
+ Domain: [Config/MCP/Hook/etc.]
891
+
892
+ WRONG: ```[code]```
893
+ CORRECT: ```[code]```
894
+ Error if violated: [What breaks]
895
+ -------------------------------------------------------------------------------
896
+
897
+ OPTIONS:
898
+ - "approve" to save and continue
899
+ - "modify: [changes]" to adjust
900
+ - "abort" to stop
901
+
902
+ ===============================================================================
903
+ ```
904
+
905
+ ---
906
+
907
+ ## ABORT HANDLING
908
+
909
+ ```
910
+ ===============================================================================
911
+ GOLDEN PATH ABORTED
912
+ ===============================================================================
913
+
914
+ Stopped at: [Phase N -- Approval Point]
915
+
916
+ CURRENT STATE:
917
+ - Completed phases: [list]
918
+ - Pending phases: [list]
919
+ - Plan file: [path]
920
+ - Files changed: [list]
921
+ - Commit created: YES/NO
922
+ - Pushed: NO
923
+
924
+ TO RESUME:
925
+ Run /massu-golden-path again with the same plan
926
+ Or run individual commands:
927
+ /massu-loop -- Continue implementation
928
+ /massu-commit -- Run commit verification
929
+ /massu-push -- Run push verification
930
+
931
+ ===============================================================================
932
+ ```
933
+
934
+ ---
935
+
936
+ ## ERROR HANDLING
937
+
938
+ **Recoverable**: Fix automatically --> re-run failed step --> if fixed, continue without pausing --> if not fixable after 3 attempts, pause and report.
939
+
940
+ **Non-Recoverable**:
941
+ ```
942
+ ===============================================================================
943
+ GOLDEN PATH BLOCKED
944
+ ===============================================================================
945
+
946
+ BLOCKER: [Description]
947
+ Required: [Steps to resolve]
948
+ After resolving, run /massu-golden-path again.
949
+
950
+ ===============================================================================
951
+ ```
952
+
953
+ ---
954
+
955
+ ## START NOW
956
+
957
+ **Step 0: Write AUTHORIZED_COMMAND to session state (CR-35)**
958
+
959
+ Update `session-state/CURRENT.md`:
960
+ ```
961
+ AUTHORIZED_COMMAND: massu-golden-path
962
+ ```
963
+
964
+ 1. **Determine input**: Task description, plan file, or continue
965
+ 2. **Phase 0**: Requirements & context (if task description)
966
+ 3. **Phase 1**: Plan creation & audit --> **PAUSE: Plan Approval**
967
+ 4. **Phase 2**: Implementation with verification loops + browser verification (UI changes)
968
+ 5. **Phase 3**: Simplification (efficiency, reuse, patterns)
969
+ 6. **Phase 4**: Pre-commit verification --> **PAUSE: Commit Approval**
970
+ 7. **Phase 5**: Push verification --> **PAUSE: Push Approval**
971
+ 8. **Phase 6**: Completion, learning, quality metrics
972
+
973
+ **This command does NOT stop to ask "should I continue?" -- it runs straight through.**