@massu/core 0.1.1 → 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 (151) 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 +7772 -3140
  34. package/dist/hooks/cost-tracker.js +103 -40
  35. package/dist/hooks/post-edit-context.js +74 -8
  36. package/dist/hooks/post-tool-use.js +268 -106
  37. package/dist/hooks/pre-compact.js +167 -43
  38. package/dist/hooks/pre-delete-check.js +159 -42
  39. package/dist/hooks/quality-event.js +103 -40
  40. package/dist/hooks/security-gate.js +29 -0
  41. package/dist/hooks/session-end.js +143 -84
  42. package/dist/hooks/session-start.js +186 -49
  43. package/dist/hooks/user-prompt.js +189 -43
  44. package/package.json +10 -15
  45. package/src/adr-generator.ts +9 -2
  46. package/src/analytics.ts +9 -3
  47. package/src/audit-trail.ts +10 -3
  48. package/src/backfill-sessions.ts +5 -4
  49. package/src/cli.ts +6 -0
  50. package/src/cloud-sync.ts +14 -18
  51. package/src/commands/doctor.ts +193 -6
  52. package/src/commands/init.ts +230 -5
  53. package/src/commands/install-commands.ts +137 -0
  54. package/src/config.ts +68 -2
  55. package/src/cost-tracker.ts +11 -6
  56. package/src/db.ts +115 -2
  57. package/src/dependency-scorer.ts +9 -2
  58. package/src/docs-tools.ts +21 -16
  59. package/src/hooks/post-edit-context.ts +4 -4
  60. package/src/hooks/post-tool-use.ts +130 -0
  61. package/src/hooks/pre-compact.ts +23 -1
  62. package/src/hooks/pre-delete-check.ts +92 -4
  63. package/src/hooks/security-gate.ts +32 -0
  64. package/src/hooks/session-end.ts +3 -3
  65. package/src/hooks/session-start.ts +99 -6
  66. package/src/hooks/user-prompt.ts +46 -1
  67. package/src/import-resolver.ts +2 -1
  68. package/src/knowledge-db.ts +169 -0
  69. package/src/knowledge-indexer.ts +704 -0
  70. package/src/knowledge-tools.ts +1413 -0
  71. package/src/license.ts +482 -0
  72. package/src/memory-db.ts +1364 -23
  73. package/src/memory-tools.ts +14 -15
  74. package/src/observability-tools.ts +13 -2
  75. package/src/observation-extractor.ts +11 -4
  76. package/src/page-deps.ts +3 -2
  77. package/src/prompt-analyzer.ts +9 -2
  78. package/src/python/coupling-detector.ts +124 -0
  79. package/src/python/domain-enforcer.ts +83 -0
  80. package/src/python/impact-analyzer.ts +95 -0
  81. package/src/python/import-parser.ts +244 -0
  82. package/src/python/import-resolver.ts +135 -0
  83. package/src/python/migration-indexer.ts +115 -0
  84. package/src/python/migration-parser.ts +332 -0
  85. package/src/python/model-indexer.ts +70 -0
  86. package/src/python/model-parser.ts +279 -0
  87. package/src/python/route-indexer.ts +58 -0
  88. package/src/python/route-parser.ts +317 -0
  89. package/src/python-tools.ts +629 -0
  90. package/src/regression-detector.ts +9 -3
  91. package/src/security-scorer.ts +9 -2
  92. package/src/sentinel-db.ts +45 -89
  93. package/src/sentinel-tools.ts +8 -11
  94. package/src/server.ts +29 -7
  95. package/src/session-archiver.ts +4 -5
  96. package/src/team-knowledge.ts +9 -2
  97. package/src/tools.ts +1032 -44
  98. package/src/validate-features-runner.ts +0 -1
  99. package/src/validation-engine.ts +9 -2
  100. package/README.md +0 -40
  101. package/dist/server.js +0 -7008
  102. package/src/__tests__/adr-generator.test.ts +0 -260
  103. package/src/__tests__/analytics.test.ts +0 -282
  104. package/src/__tests__/audit-trail.test.ts +0 -382
  105. package/src/__tests__/backfill-sessions.test.ts +0 -690
  106. package/src/__tests__/cli.test.ts +0 -290
  107. package/src/__tests__/cloud-sync.test.ts +0 -261
  108. package/src/__tests__/config-sections.test.ts +0 -359
  109. package/src/__tests__/config.test.ts +0 -732
  110. package/src/__tests__/cost-tracker.test.ts +0 -348
  111. package/src/__tests__/db.test.ts +0 -177
  112. package/src/__tests__/dependency-scorer.test.ts +0 -325
  113. package/src/__tests__/docs-integration.test.ts +0 -178
  114. package/src/__tests__/docs-tools.test.ts +0 -199
  115. package/src/__tests__/domains.test.ts +0 -236
  116. package/src/__tests__/hooks.test.ts +0 -221
  117. package/src/__tests__/import-resolver.test.ts +0 -95
  118. package/src/__tests__/integration/path-traversal.test.ts +0 -134
  119. package/src/__tests__/integration/pricing-consistency.test.ts +0 -88
  120. package/src/__tests__/integration/tool-registration.test.ts +0 -146
  121. package/src/__tests__/memory-db.test.ts +0 -404
  122. package/src/__tests__/memory-enhancements.test.ts +0 -316
  123. package/src/__tests__/memory-tools.test.ts +0 -199
  124. package/src/__tests__/middleware-tree.test.ts +0 -177
  125. package/src/__tests__/observability-tools.test.ts +0 -595
  126. package/src/__tests__/observability.test.ts +0 -437
  127. package/src/__tests__/observation-extractor.test.ts +0 -167
  128. package/src/__tests__/page-deps.test.ts +0 -60
  129. package/src/__tests__/prompt-analyzer.test.ts +0 -298
  130. package/src/__tests__/regression-detector.test.ts +0 -295
  131. package/src/__tests__/rules.test.ts +0 -87
  132. package/src/__tests__/schema-mapper.test.ts +0 -29
  133. package/src/__tests__/security-scorer.test.ts +0 -238
  134. package/src/__tests__/security-utils.test.ts +0 -175
  135. package/src/__tests__/sentinel-db.test.ts +0 -491
  136. package/src/__tests__/sentinel-scanner.test.ts +0 -750
  137. package/src/__tests__/sentinel-tools.test.ts +0 -324
  138. package/src/__tests__/sentinel-types.test.ts +0 -750
  139. package/src/__tests__/server.test.ts +0 -452
  140. package/src/__tests__/session-archiver.test.ts +0 -524
  141. package/src/__tests__/session-state-generator.test.ts +0 -900
  142. package/src/__tests__/team-knowledge.test.ts +0 -327
  143. package/src/__tests__/tools.test.ts +0 -340
  144. package/src/__tests__/transcript-parser.test.ts +0 -195
  145. package/src/__tests__/trpc-index.test.ts +0 -25
  146. package/src/__tests__/validate-features-runner.test.ts +0 -517
  147. package/src/__tests__/validation-engine.test.ts +0 -300
  148. package/src/core-tools.ts +0 -685
  149. package/src/memory-queries.ts +0 -804
  150. package/src/memory-schema.ts +0 -546
  151. package/src/tool-helpers.ts +0 -41
@@ -0,0 +1,837 @@
1
+ ---
2
+ name: massu-loop-playwright
3
+ description: Browser-based audit and fix loop — functional, visual, and performance testing with Playwright
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*), mcp__plugin_playwright_playwright__*, mcp__playwright__*
5
+ ---
6
+ name: massu-loop-playwright
7
+
8
+ # Massu Loop Playwright: Browser-Based Audit & Fix Protocol
9
+
10
+ **Shared rules**: Read `.claude/commands/_shared-preamble.md` for POST-COMPACTION (CR-35), QUALITY STANDARDS, and CR-9 (fix all issues) rules.
11
+
12
+ ---
13
+
14
+ ## Workflow Position
15
+
16
+ ```
17
+ /massu-loop -> /massu-loop-playwright -> [/massu-simplify] -> /massu-commit -> /massu-push
18
+ (IMPLEMENT) (BROWSER VERIFY+FIX) (QUALITY) (COMMIT) (PUSH)
19
+ ```
20
+
21
+ **This command runs after implementation (standalone or post-massu-loop). It is the browser-level verification and fix loop.**
22
+
23
+ **Golden Path Integration**: This command is integrated into `/massu-golden-path` as Phase 2G. When running the golden path, this phase auto-triggers if the plan touches UI files. It can also be run standalone.
24
+
25
+ ---
26
+
27
+ ## USAGE
28
+
29
+ ```
30
+ # Test a specific URL
31
+ /massu-loop-playwright https://example.com/docs
32
+
33
+ # Test a specific page path (requires a full URL)
34
+ /massu-loop-playwright https://localhost:3000/docs/getting-started
35
+
36
+ # Test multiple pages
37
+ /massu-loop-playwright https://example.com/docs https://example.com/pricing
38
+
39
+ # Auto-triggered after massu-loop when plan touches UI files
40
+ (integrated -- no manual invocation needed)
41
+ ```
42
+
43
+ ### Argument Parsing
44
+
45
+ ```
46
+ INPUT = $ARGUMENTS
47
+
48
+ IF INPUT starts with "http":
49
+ MODE = "single" (or "multi" if multiple URLs provided)
50
+ TARGET_URL(s) = INPUT (space-separated URLs)
51
+
52
+ ELSE IF INPUT starts with "/":
53
+ MODE = "single"
54
+ WARN: "No base URL configured. Please provide a full URL (e.g., https://example.com{INPUT})"
55
+ STOP
56
+
57
+ ELSE:
58
+ MODE = "single"
59
+ WARN: "Please provide a full URL (starting with http:// or https://)"
60
+ STOP
61
+ ```
62
+
63
+ **Note**: Massu is a CLI/package, not a fixed web app. The user MUST provide the full target URL(s) to test. These could be:
64
+ - A documentation site
65
+ - A demo/marketing page
66
+ - Output artifacts generated by Massu (static sites, reports, etc.)
67
+ - A local dev server (`http://localhost:...`)
68
+
69
+ Alternatively, use `--url` to test specific pages when the target app routes are known.
70
+
71
+ ---
72
+
73
+ ## SAFETY RULE (ABSOLUTE)
74
+
75
+ **NEVER use real client data for testing. NEVER modify production data during testing.**
76
+
77
+ - ALL test interactions MUST be read-only or use dedicated test data
78
+ - NEVER submit forms, create records, or trigger actions on production systems
79
+ - NEVER click destructive actions (Delete, Remove, etc.) on live data
80
+ - NEVER create test proposals/orders/emails targeting real clients or contacts
81
+ - NEVER use real client names in test data
82
+ - When a test requires data entry, use clearly fake/test values only
83
+ - If testing a system you do not own, limit to observation and navigation
84
+
85
+ **Violation of this rule is a P0 incident.**
86
+
87
+ ---
88
+
89
+ ## TOOL SELECTION
90
+
91
+ Use the Playwright MCP plugin tools (`mcp__plugin_playwright_playwright__*`) as the primary browser automation tool. These provide:
92
+
93
+ | Tool | Purpose |
94
+ |------|---------|
95
+ | `browser_navigate` | Navigate to URLs |
96
+ | `browser_snapshot` | Capture DOM state for inspection |
97
+ | `browser_take_screenshot` | Capture visual screenshot for evidence |
98
+ | `browser_console_messages` | Retrieve console errors/warnings |
99
+ | `browser_network_requests` | Check for failed network requests |
100
+ | `browser_click` | Click interactive elements |
101
+ | `browser_fill_form` | Fill form fields |
102
+ | `browser_select_option` | Select dropdown options |
103
+ | `browser_press_key` | Keyboard interactions |
104
+ | `browser_hover` | Hover over elements |
105
+ | `browser_tabs` | Manage browser tabs |
106
+ | `browser_wait_for` | Wait for elements/conditions |
107
+ | `browser_evaluate` | Execute JavaScript in browser context |
108
+ | `browser_resize` | Test responsive layouts |
109
+
110
+ If the plugin tools are unavailable, fall back to standalone `mcp__playwright__*` tools (identical API).
111
+
112
+ ---
113
+
114
+ ## PHASE 0: SETUP
115
+
116
+ ### 0.1 Initialize Report
117
+
118
+ ```
119
+ TIMESTAMP = current time in PST (America/Los_Angeles), format: YYYY-MM-DD-HH-MM
120
+ REPORT_PATH = .claude/playwright-reports/{TIMESTAMP}-{PAGE_SLUG}.md
121
+ ```
122
+
123
+ Create the report directory if needed:
124
+
125
+ ```bash
126
+ mkdir -p .claude/playwright-reports
127
+ ```
128
+
129
+ ### 0.2 Navigate to Target URL
130
+
131
+ ```
132
+ Use browser_navigate to: {TARGET_URL}
133
+ ```
134
+
135
+ If the URL includes a path, navigate directly to that path.
136
+
137
+ ### 0.3 Check Application Status
138
+
139
+ After navigation, use `browser_snapshot` to capture the page state.
140
+
141
+ | Indicator | Meaning | Action |
142
+ |-----------|---------|--------|
143
+ | Page content visible | App/site loaded | PROCEED |
144
+ | URL redirected to `/login` or auth page | Not logged in | Attempt persistent session or STOP |
145
+ | Error page, blank page, or connection refused | App not running or URL invalid | STOP and report |
146
+ | URL is target path with page content visible | Loaded successfully | PROCEED |
147
+
148
+ ### 0.4 If NOT Ready
149
+
150
+ If the page requires authentication and persistent session cookies are not available, STOP and output:
151
+
152
+ ```
153
+ AUTHENTICATION REQUIRED
154
+
155
+ The Playwright browser cannot access the target application.
156
+
157
+ Please:
158
+ 1. The Playwright browser window should be open
159
+ 2. Log in to the target application manually in that browser
160
+ 3. Wait until you see the expected page loaded
161
+ 4. Re-run: /massu-loop-playwright {ORIGINAL_ARGUMENTS}
162
+
163
+ The command cannot proceed without access to the target page.
164
+ ```
165
+
166
+ **Do NOT attempt to type credentials. Do NOT hardcode passwords. Do NOT proceed without a loaded page.**
167
+
168
+ ### 0.5 If Ready
169
+
170
+ Report to the user:
171
+
172
+ ```
173
+ Page confirmed loaded. Starting browser audit...
174
+ Mode: {single / multi}
175
+ Target: {URL(s)}
176
+ Pages to test: {N}
177
+ ```
178
+
179
+ ---
180
+
181
+ ## PHASE 1: LOAD AUDIT
182
+
183
+ For each target URL, execute these steps. Capture ALL findings before moving to Phase 2.
184
+
185
+ ### 1.1 Navigate and Wait
186
+
187
+ ```
188
+ 1. browser_navigate to the target URL
189
+ 2. browser_wait_for page load (up to 15 seconds)
190
+ 3. If page does not load in 15 seconds, record as TIMEOUT
191
+ ```
192
+
193
+ ### 1.2 Console Error Capture
194
+
195
+ ```
196
+ 1. browser_console_messages -- capture ALL messages
197
+ 2. Categorize each message:
198
+ ```
199
+
200
+ | Category | Pattern | Severity |
201
+ |----------|---------|----------|
202
+ | **Console Error** | `level: error` | HIGH |
203
+ | **Console Warning** | `level: warning` | MEDIUM |
204
+ | **React Error** | `Uncaught Error`, `Cannot read properties`, hydration mismatch | CRITICAL |
205
+ | **CSP Violation** | `Content Security Policy`, `Refused to`, `blocked by CSP` | HIGH |
206
+ | **Auth Warning** | `401`, `403`, `Unauthorized`, `token expired` | HIGH |
207
+ | **i18n Missing** | `Missing message`, `MISSING_MESSAGE`, `IntlError` | LOW |
208
+ | **Deprecation** | `deprecated`, `will be removed` | LOW |
209
+
210
+ ### 1.3 Network Failure Check
211
+
212
+ ```
213
+ 1. browser_network_requests -- check for failed requests
214
+ 2. Record any request with status >= 400 or status = 0 (failed to connect)
215
+ ```
216
+
217
+ | Network Issue | Pattern | Severity |
218
+ |---------------|---------|----------|
219
+ | **500 Error** | Status 500+ | CRITICAL |
220
+ | **404 Not Found** | Status 404 on API/resource | HIGH |
221
+ | **CORS Failure** | Status 0, CORS error in console | HIGH |
222
+ | **Timeout** | Request hung > 10s | MEDIUM |
223
+ | **CSP Block** | Resource blocked by CSP | MEDIUM |
224
+
225
+ ### 1.4 CSP Violation Detection
226
+
227
+ Use `browser_evaluate` to check for CSP violations:
228
+
229
+ ```javascript
230
+ // Check for CSP violation reports
231
+ window.__cspViolations = window.__cspViolations || [];
232
+ document.addEventListener('securitypolicyviolation', (e) => {
233
+ window.__cspViolations.push({
234
+ blockedURI: e.blockedURI,
235
+ violatedDirective: e.violatedDirective,
236
+ originalPolicy: e.originalPolicy
237
+ });
238
+ });
239
+ ```
240
+
241
+ After a brief wait, collect violations:
242
+
243
+ ```javascript
244
+ JSON.stringify(window.__cspViolations || []);
245
+ ```
246
+
247
+ ### 1.5 Record Load Audit Results
248
+
249
+ ```markdown
250
+ ### Load Audit: {URL}
251
+
252
+ | Check | Result | Details |
253
+ |-------|--------|---------|
254
+ | Console Errors | {N} | [list] |
255
+ | Console Warnings | {N} | [list] |
256
+ | Network Failures | {N} | [list] |
257
+ | CSP Violations | {N} | [list] |
258
+ | Load Time | fast/slow/timeout | {ms if available} |
259
+ ```
260
+
261
+ ---
262
+
263
+ ## PHASE 2: INTERACTIVE TESTING
264
+
265
+ ### 2.1 Element Discovery
266
+
267
+ Use `browser_snapshot` to capture the full DOM state and identify ALL interactive elements:
268
+
269
+ - **Buttons**: All `<button>` elements and elements with `role="button"`
270
+ - **Links**: All `<a>` elements with `href` attributes
271
+ - **Forms**: All `<form>` elements with their inputs
272
+ - **Selects/Dropdowns**: All `<select>` and custom dropdown components
273
+ - **Tabs**: All tab navigation elements
274
+ - **Modals/Dialogs**: Any trigger elements for sheets, dialogs, modals
275
+ - **Data Tables**: Sortable headers, pagination, filters, row actions
276
+
277
+ Create an inventory:
278
+
279
+ ```markdown
280
+ ### Interactive Element Inventory: {URL}
281
+
282
+ | # | Element | Type | Text/Label | Testable |
283
+ |---|---------|------|------------|----------|
284
+ | 1 | Button | button | "Get Started" | YES |
285
+ | 2 | Link | a | "Documentation" | YES |
286
+ | 3 | Select | select | "Version" | YES |
287
+ | 4 | Tab | tab | "Overview" | YES |
288
+ ```
289
+
290
+ ### 2.2 Systematic Interaction Testing
291
+
292
+ For EACH testable interactive element:
293
+
294
+ ```
295
+ 1. Capture console state BEFORE interaction (browser_console_messages)
296
+ 2. Perform the interaction:
297
+ - Buttons: browser_click
298
+ - Links: browser_click (check navigation or action)
299
+ - Selects: browser_select_option (try each option)
300
+ - Tabs: browser_click (switch between tabs)
301
+ - Forms: browser_fill_form (with safe test data ONLY)
302
+ 3. Wait briefly for async operations (2-3 seconds)
303
+ 4. Capture console state AFTER interaction (browser_console_messages)
304
+ 5. Compare before/after -- record any NEW errors
305
+ 6. browser_snapshot to verify DOM state after interaction
306
+ 7. If interaction opened a modal/sheet: test elements inside, then close it
307
+ 8. Navigate BACK if the interaction changed the URL (unless testing navigation)
308
+ ```
309
+
310
+ **SAFETY RULES for interactive testing:**
311
+
312
+ | Rule | Why |
313
+ |------|-----|
314
+ | NEVER submit forms with real data | Could create real records |
315
+ | NEVER click "Delete" or destructive actions | Could destroy production data |
316
+ | NEVER click "Send" on emails/notifications | Would send to real users |
317
+ | NEVER click "Submit" on payment/order forms | Would create real transactions |
318
+ | For forms: fill but do NOT submit | Test validation without side effects |
319
+ | For destructive buttons: test existence, do NOT click | Verify they render, nothing more |
320
+
321
+ ### 2.3 Record Interactive Test Results
322
+
323
+ For each element tested:
324
+
325
+ ```markdown
326
+ | # | Element | Action | Console Errors After | Visual Issue | Status |
327
+ |---|---------|--------|---------------------|--------------|--------|
328
+ | 1 | "Get Started" button | click | 0 | None | PASS |
329
+ | 2 | "Version" select | select "v2" | 1: TypeError | None | FAIL |
330
+ | 3 | "Overview" tab | click | 0 | Content missing | FAIL |
331
+ ```
332
+
333
+ ---
334
+
335
+ ## PHASE 3: VISUAL AUDIT
336
+
337
+ ### 3.1 Broken Image Detection
338
+
339
+ Use `browser_evaluate` to check for broken images:
340
+
341
+ ```javascript
342
+ Array.from(document.querySelectorAll('img')).filter(img =>
343
+ !img.complete || img.naturalWidth === 0
344
+ ).map(img => ({ src: img.src, alt: img.alt }));
345
+ ```
346
+
347
+ ### 3.2 Layout Issue Detection
348
+
349
+ Use `browser_snapshot` and `browser_take_screenshot` to check for:
350
+
351
+ | Issue | How to Detect |
352
+ |-------|---------------|
353
+ | **Overflow/Scroll** | Elements extending beyond viewport |
354
+ | **Overlapping** | Z-index issues, elements stacking incorrectly |
355
+ | **Missing Content** | Empty sections that should have content |
356
+ | **Broken Alignment** | Elements not aligned with grid/layout |
357
+ | **Text Truncation** | Important text cut off without ellipsis |
358
+ | **Icon Issues** | Missing or broken icons |
359
+
360
+ ### 3.3 Responsive Check
361
+
362
+ Use `browser_resize` to test at key breakpoints:
363
+
364
+ | Breakpoint | Width | Height | What to Check |
365
+ |------------|-------|--------|---------------|
366
+ | Desktop | 1440 | 900 | Full layout |
367
+ | Tablet | 768 | 1024 | Responsive collapse |
368
+ | Mobile | 375 | 812 | Mobile layout |
369
+
370
+ For each breakpoint:
371
+ 1. `browser_resize` to the dimensions
372
+ 2. `browser_take_screenshot` for visual evidence
373
+ 3. Check for layout breaks, overflow, overlapping elements
374
+ 4. Resize back to desktop (1440x900) when done
375
+
376
+ ### 3.4 Screenshot Evidence
377
+
378
+ Take screenshots at these key states:
379
+
380
+ | State | When | Save As |
381
+ |-------|------|---------|
382
+ | **Initial Load** | After page fully loads | `{report-dir}/01-initial-load.png` |
383
+ | **After Interaction** | After any interaction reveals an issue | `{report-dir}/02-interaction-{element}.png` |
384
+ | **Responsive** | At each breakpoint if issues found | `{report-dir}/03-responsive-{breakpoint}.png` |
385
+ | **Error State** | When a visual error is visible | `{report-dir}/04-error-{description}.png` |
386
+
387
+ ### 3.5 Record Visual Audit Results
388
+
389
+ ```markdown
390
+ ### Visual Audit: {URL}
391
+
392
+ | # | Issue | Type | Location | Severity | Screenshot |
393
+ |---|-------|------|----------|----------|------------|
394
+ | 1 | Broken image | Image | Hero section | MEDIUM | 04-error-broken-img.png |
395
+ | 2 | Layout overflow | Overflow | Sidebar on mobile | HIGH | 03-responsive-375.png |
396
+ ```
397
+
398
+ ---
399
+
400
+ ## PHASE 4: PERFORMANCE AUDIT
401
+
402
+ ### 4.1 Page Load Timing
403
+
404
+ Use `browser_evaluate` to collect performance metrics:
405
+
406
+ ```javascript
407
+ const perf = performance.getEntriesByType('navigation')[0];
408
+ JSON.stringify({
409
+ domContentLoaded: Math.round(perf.domContentLoadedEventEnd - perf.startTime),
410
+ loadComplete: Math.round(perf.loadEventEnd - perf.startTime),
411
+ ttfb: Math.round(perf.responseStart - perf.requestStart),
412
+ domInteractive: Math.round(perf.domInteractive - perf.startTime)
413
+ });
414
+ ```
415
+
416
+ ### 4.2 Resource Analysis
417
+
418
+ Use `browser_evaluate` to find large resources:
419
+
420
+ ```javascript
421
+ performance.getEntriesByType('resource')
422
+ .filter(r => r.transferSize > 500000)
423
+ .map(r => ({
424
+ name: r.name.split('/').pop(),
425
+ url: r.name,
426
+ size: Math.round(r.transferSize / 1024) + 'KB',
427
+ duration: Math.round(r.duration) + 'ms',
428
+ type: r.initiatorType
429
+ }));
430
+ ```
431
+
432
+ ### 4.3 Network Waterfall Check
433
+
434
+ Use `browser_network_requests` to identify:
435
+
436
+ - Requests taking > 3 seconds
437
+ - Sequential requests that could be parallelized
438
+ - Duplicate requests to the same endpoint
439
+ - Large payloads (> 1MB)
440
+
441
+ ### 4.4 Performance Thresholds
442
+
443
+ | Metric | Good | Needs Work | Critical |
444
+ |--------|------|------------|----------|
445
+ | DOM Content Loaded | < 2s | 2-5s | > 5s |
446
+ | Full Load | < 4s | 4-8s | > 8s |
447
+ | TTFB | < 500ms | 500ms-1.5s | > 1.5s |
448
+ | Largest Resource | < 500KB | 500KB-2MB | > 2MB |
449
+ | API Response | < 1s | 1-3s | > 3s |
450
+
451
+ ### 4.5 Record Performance Results
452
+
453
+ ```markdown
454
+ ### Performance Audit: {URL}
455
+
456
+ | Metric | Value | Rating |
457
+ |--------|-------|--------|
458
+ | DOM Content Loaded | {N}ms | GOOD/WARN/CRITICAL |
459
+ | Full Load | {N}ms | GOOD/WARN/CRITICAL |
460
+ | TTFB | {N}ms | GOOD/WARN/CRITICAL |
461
+ | Largest Resource | {name} ({size}) | GOOD/WARN/CRITICAL |
462
+ | Slow API Calls | {N} | GOOD/WARN/CRITICAL |
463
+ ```
464
+
465
+ ---
466
+
467
+ ## PHASE 5: FIX LOOP
468
+
469
+ **This is what differentiates `/massu-loop-playwright` from `/massu-verify-playwright`. This command FIXES issues.**
470
+
471
+ ### 5.1 Triage Findings
472
+
473
+ Compile ALL issues from Phases 1-4 into a single prioritized list:
474
+
475
+ | Priority | Criteria | Action |
476
+ |----------|----------|--------|
477
+ | **P0 - CRITICAL** | Console errors, React crashes, 500s, data exposure | Fix immediately in this loop |
478
+ | **P1 - HIGH** | Network failures, CSP violations, broken interactions, auth warnings | Fix in this loop |
479
+ | **P2 - MEDIUM** | Visual issues, performance warnings, broken images | Fix in this loop if code-fixable |
480
+ | **P3 - LOW** | Console warnings, deprecations, i18n missing keys | Document but do not fix unless trivial |
481
+
482
+ ### 5.2 Fix Loop Execution
483
+
484
+ ```
485
+ issues = ALL findings from Phases 1-4, sorted by priority (P0 first)
486
+ fix_count = 0
487
+
488
+ FOR EACH issue in issues WHERE priority <= P2:
489
+ 1. IDENTIFY the root cause
490
+ - Use Grep/Glob/Read to find the source file
491
+ - Trace from browser error to source code
492
+ - Check CLAUDE.md patterns for known fixes
493
+
494
+ 2. APPLY the fix
495
+ - Edit the source file(s)
496
+ - Follow ALL CLAUDE.md patterns (no shortcuts)
497
+
498
+ 3. VERIFY the fix
499
+ - The live site requires a deployment/rebuild to verify browser-side
500
+ - For code-level verification: run applicable VR-* checks
501
+ - VR-GREP: Confirm correct pattern is present
502
+ - VR-NEGATIVE: Confirm incorrect pattern is removed
503
+ - VR-BUILD: npm run build (must pass)
504
+ - VR-TYPE: npx tsc --noEmit (must pass)
505
+
506
+ 4. LOG the fix
507
+ - Record in fix log table (see report format below)
508
+ - fix_count += 1
509
+
510
+ END FOR
511
+ ```
512
+
513
+ ### 5.3 Post-Fix Browser Retest
514
+
515
+ **After ALL code fixes are applied and build/type checks pass:**
516
+
517
+ ```
518
+ 1. Reload the target URL in the browser (browser_navigate)
519
+ 2. Re-run Phase 1 (Load Audit) on all target URLs
520
+ 3. Re-run Phase 2 (Interactive Testing) for elements that had failures
521
+ 4. Compare before/after error counts
522
+
523
+ IF new_errors > 0:
524
+ Add new errors to issues list
525
+ Return to 5.2 (fix loop)
526
+ ELSE:
527
+ PROCEED to Phase 6
528
+ ```
529
+
530
+ **NOTE**: Browser retesting after code fixes requires a rebuild/deployment. If the site is built locally, rebuild and re-check. If deployed via CI/CD, note that a deployment is needed and document the expected fix.
531
+
532
+ ### 5.4 Zero-Issue Standard
533
+
534
+ The fix loop continues until:
535
+
536
+ - ALL P0 and P1 issues have code fixes applied
537
+ - ALL P2 issues are either fixed or documented with justification
538
+ - Build passes (exit 0)
539
+ - Type check passes (0 errors)
540
+ - No new console errors introduced by fixes
541
+
542
+ **Partial fixes are NOT acceptable. Every fixable issue must be addressed.**
543
+
544
+ ---
545
+
546
+ ## PHASE 6: REPORT
547
+
548
+ ### 6.1 Generate Report
549
+
550
+ Save the complete report to: `.claude/playwright-reports/{TIMESTAMP}-{PAGE_SLUG}.md`
551
+
552
+ Timestamps MUST be in PST (America/Los_Angeles).
553
+
554
+ ### 6.2 Report Format
555
+
556
+ ```markdown
557
+ # Playwright Audit Report
558
+
559
+ **URL**: {tested URL(s)}
560
+ **Date**: {YYYY-MM-DD HH:MM PST}
561
+ **Mode**: {single / multi}
562
+ **Status**: PASS / FAIL ({N} issues remaining)
563
+
564
+ ---
565
+
566
+ ## Summary
567
+
568
+ | Metric | Count |
569
+ |--------|-------|
570
+ | Pages Tested | {N} |
571
+ | Console Errors Found | {N} |
572
+ | Console Warnings Found | {N} |
573
+ | Network Failures Found | {N} |
574
+ | CSP Violations Found | {N} |
575
+ | Broken Images Found | {N} |
576
+ | Interactive Element Failures | {N} |
577
+ | Visual Issues Found | {N} |
578
+ | Performance Issues Found | {N} |
579
+ | **Total Issues** | **{N}** |
580
+ | **Issues Fixed** | **{N}** |
581
+ | **Issues Remaining** | **{N}** |
582
+
583
+ ---
584
+
585
+ ## Console Errors ({N})
586
+
587
+ | # | Page | Message | Severity | Fixed |
588
+ |---|------|---------|----------|-------|
589
+ | 1 | /docs | TypeError: Cannot read properties of null | CRITICAL | YES |
590
+
591
+ ## Console Warnings ({N})
592
+
593
+ | # | Page | Message | Severity | Fixed |
594
+ |---|------|---------|----------|-------|
595
+
596
+ ## Network Failures ({N})
597
+
598
+ | # | Page | URL | Status | Type | Fixed |
599
+ |---|------|-----|--------|------|-------|
600
+
601
+ ## CSP Violations ({N})
602
+
603
+ | # | Page | Blocked URI | Directive | Fixed |
604
+ |---|------|-------------|-----------|-------|
605
+
606
+ ## Broken Images ({N})
607
+
608
+ | # | Page | Image Src | Alt Text | Fixed |
609
+ |---|------|-----------|----------|-------|
610
+
611
+ ## Interactive Element Failures ({N})
612
+
613
+ | # | Page | Element | Action | Error | Fixed |
614
+ |---|------|---------|--------|-------|-------|
615
+
616
+ ## Visual Issues ({N})
617
+
618
+ | # | Page | Issue | Location | Breakpoint | Fixed |
619
+ |---|------|-------|----------|------------|-------|
620
+
621
+ ## Performance Issues ({N})
622
+
623
+ | # | Page | Metric | Value | Threshold | Fixed |
624
+ |---|------|--------|-------|-----------|-------|
625
+
626
+ ---
627
+
628
+ ## Fix Log
629
+
630
+ | # | Issue | Severity | File(s) Changed | Fix Applied | VR Check | Verified |
631
+ |---|-------|----------|-----------------|-------------|----------|----------|
632
+ | 1 | TypeError in DocsPage | P0 | packages/core/src/... | Added null guard | VR-GREP | YES |
633
+
634
+ ---
635
+
636
+ ## Screenshots
637
+
638
+ | # | Description | Path |
639
+ |---|-------------|------|
640
+ | 1 | Initial page load | .claude/playwright-reports/{dir}/01-initial-load.png |
641
+
642
+ ---
643
+
644
+ ## Unfixed Issues (P3 / Deferred)
645
+
646
+ | # | Issue | Severity | Reason Not Fixed |
647
+ |---|-------|----------|------------------|
648
+ | 1 | Deprecation warning: findDOMNode | P3 | Third-party library, not actionable |
649
+
650
+ ---
651
+
652
+ ## Post-Fix Verification
653
+
654
+ | Check | Command | Result |
655
+ |-------|---------|--------|
656
+ | Build | npm run build | Exit 0 / PENDING |
657
+ | Types | npx tsc --noEmit | 0 errors / PENDING |
658
+ | Browser Retest | Console errors after reload | 0 / PENDING DEPLOY |
659
+ ```
660
+
661
+ ### 6.3 Present to User
662
+
663
+ After saving the report, present to the user:
664
+
665
+ 1. Summary (total issues found vs fixed)
666
+ 2. Any remaining unfixed issues with justification
667
+ 3. The report file path
668
+ 4. Whether a rebuild/deployment is needed to verify browser-side fixes
669
+ 5. Recommendation for next steps
670
+
671
+ ---
672
+
673
+ ## INTEGRATION WITH MASSU-LOOP
674
+
675
+ ### Auto-Trigger Criteria
676
+
677
+ When running as part of `/massu-loop`, this command auto-triggers if the plan touches ANY of these file patterns:
678
+
679
+ ```
680
+ packages/*/src/**/*.tsx
681
+ packages/*/src/**/*.ts
682
+ src/**/*.tsx
683
+ src/**/*.ts
684
+ src/**/*.css
685
+ *.html
686
+ ```
687
+
688
+ ### Integration Protocol
689
+
690
+ ```
691
+ IF massu-loop plan touches UI files:
692
+ 1. Identify which pages are affected by the changed files
693
+ - Use file path to determine which output/page is affected
694
+ - Include parent layout/template pages if layout files changed
695
+ 2. Run /massu-loop-playwright for each affected page
696
+ 3. Include playwright report in massu-loop completion output
697
+ 4. Any P0/P1 issues found become GAPS in the massu-loop audit
698
+ ```
699
+
700
+ ---
701
+
702
+ ## COMMON ISSUE PATTERNS
703
+
704
+ ### Issues This Command Catches That Code Review Misses
705
+
706
+ | Issue | Example | Root Cause |
707
+ |-------|---------|------------|
708
+ | Hydration mismatch | `Text content does not match server-rendered HTML` | Date formatting, random IDs |
709
+ | Missing null guard | `Cannot read properties of undefined (reading 'map')` | Data not loaded yet |
710
+ | CSP violation | `Refused to load script from 'cdn.example.com'` | Missing CSP directive |
711
+ | Broken API call | `Failed to fetch`, `NetworkError` | Endpoint renamed/removed |
712
+ | Layout shift | Content jumps after data loads | Missing skeleton/loading state |
713
+ | Dark mode issue | Element invisible in dark mode | Hardcoded color instead of semantic class |
714
+ | Mobile overflow | Horizontal scroll on mobile | Fixed-width element in flex container |
715
+ | Stale cache | Old data shown after mutation | Missing query invalidation |
716
+
717
+ ### Common Error Patterns
718
+
719
+ | Error | Likely Fix |
720
+ |-------|-----------|
721
+ | `Hydration failed` | Check for browser-only APIs in server components |
722
+ | `Cannot update during render` | Move state update to useEffect |
723
+ | `Maximum update depth exceeded` | Check useEffect/useCallback dependency arrays |
724
+ | `Each child should have a unique key` | Add stable key prop to list items |
725
+ | `Invalid hook call` | Check component is not called as regular function |
726
+ | `Module not found` | Check import paths, missing dependency |
727
+
728
+ ---
729
+
730
+ ## NON-NEGOTIABLE RULES
731
+
732
+ 1. **NEVER use real client data** -- all test data uses fake/test values only
733
+ 2. **NEVER click destructive actions** -- no Delete, Send, Submit on live data
734
+ 3. **NEVER skip a phase** -- all 6 phases must execute
735
+ 4. **NEVER claim "PASS" with unfixed P0/P1 issues** -- zero-issue standard for critical/high
736
+ 5. **Evidence over claims** -- every finding has a console message, screenshot, or DOM snapshot
737
+ 6. **Fix in code, verify in browser** -- fixes are applied to source files, not browser hacks
738
+ 7. **PST timestamps** -- all report timestamps in America/Los_Angeles timezone
739
+ 8. **Complete reports** -- even if zero issues found, generate the full report structure
740
+ 9. **Follow CLAUDE.md patterns** -- all code fixes must comply with established patterns
741
+ 10. **CR-9 always** -- fix ALL issues encountered, whether from current changes or pre-existing
742
+
743
+ ---
744
+
745
+ ## ERROR HANDLING
746
+
747
+ ### Browser Session Issues
748
+
749
+ | Scenario | Action |
750
+ |----------|--------|
751
+ | Page returns 404 | Record as issue, check if route exists in codebase |
752
+ | Page hangs (>15s) | Record as TIMEOUT, check for infinite loops |
753
+ | Redirected to login/auth | Session expired. STOP. Report partial results. |
754
+ | Playwright not available | STOP. Tell user to check MCP server. |
755
+ | Console messages unavailable | Use browser_evaluate as fallback to check window.console |
756
+
757
+ ### Fix Loop Safety
758
+
759
+ | Scenario | Action |
760
+ |----------|--------|
761
+ | Fix introduces new error | Revert fix, try alternative approach |
762
+ | Build fails after fix | Revert fix, investigate build error separately |
763
+ | Fix requires DB change | Document but do NOT apply -- DB changes need separate migration |
764
+ | Fix scope expands beyond page | Document for separate task, fix only the targeted issue |
765
+ | More than 20 issues on one page | Fix P0/P1 first, document P2/P3 for batch fix |
766
+
767
+ ### Circuit Breaker
768
+
769
+ If the fix loop exceeds 5 iterations on the same page without reaching zero issues:
770
+
771
+ ```
772
+ CIRCUIT BREAKER: Fix loop stalled after {N} iterations on {URL}.
773
+ Remaining issues: {list}
774
+ Options:
775
+ (a) Continue with different approach
776
+ (b) Save partial report and stop
777
+ (c) Escalate remaining issues for manual review
778
+ ```
779
+
780
+ Ask the user how to proceed.
781
+
782
+ ---
783
+
784
+ ## AUTO-LEARNING PROTOCOL (MANDATORY after every fix)
785
+
786
+ After EVERY browser-discovered bug fix:
787
+
788
+ ### Step 1: Ingest into Memory
789
+ Use `mcp__massu__massu_memory_ingest` with:
790
+ - type: "bugfix"
791
+ - description: "[Browser symptom] -> [Code fix]"
792
+ - files: [list of files changed]
793
+ - importance: 5 (if crash/data issue), 3 (if build/type), 2 (if cosmetic)
794
+
795
+ ### Step 2: Record Pattern
796
+ Update `.claude/session-state/CURRENT.md` with:
797
+ ```markdown
798
+ ## [Category] Browser Bug (discovered [date])
799
+ - SYMPTOM: [what the browser showed]
800
+ - ROOT CAUSE: [what was wrong in code]
801
+ - FIX: [what was changed]
802
+ - File(s): [where]
803
+ ```
804
+
805
+ ### Step 3: Add to Pattern Scanner (if grep-able)
806
+ If the incorrect pattern can be detected by grep, add it to `scripts/massu-pattern-scanner.sh`.
807
+
808
+ ### Step 4: Codebase-Wide Search (CR-9)
809
+ ```bash
810
+ grep -rn "[bad_pattern]" packages/ src/ --include="*.ts" --include="*.tsx"
811
+ ```
812
+ Fix ALL instances, not just the one found on this page.
813
+
814
+ ---
815
+
816
+ ## START NOW
817
+
818
+ **Step 0: Write AUTHORIZED_COMMAND to session state (CR-35)**
819
+
820
+ Before any other work, update `session-state/CURRENT.md` to include:
821
+ ```
822
+ AUTHORIZED_COMMAND: massu-loop-playwright
823
+ ```
824
+
825
+ **Then execute:**
826
+
827
+ 1. Parse arguments to determine mode (single URL / multi URL)
828
+ 2. Launch Playwright and navigate to target
829
+ 3. Verify page is loaded (STOP if not accessible)
830
+ 4. **PHASE 1**: Load audit -- console errors, network failures, CSP violations
831
+ 5. **PHASE 2**: Interactive testing -- discover and test all interactive elements
832
+ 6. **PHASE 3**: Visual audit -- broken images, layout issues, responsive check
833
+ 7. **PHASE 4**: Performance audit -- load times, large resources, slow APIs
834
+ 8. **PHASE 5**: Fix loop -- triage, fix code, verify, repeat until zero P0/P1 issues
835
+ 9. **PHASE 6**: Report -- generate comprehensive report, save to filesystem, present to user
836
+
837
+ **Remember: Find it. Fix it. Prove it. Report it.**