@polymorphism-tech/morph-spec 4.22.0 → 5.0.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.
Files changed (211) hide show
  1. package/CLAUDE.md +57 -71
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +224 -491
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +55 -38
  8. package/framework/MORPH.md +244 -0
  9. package/framework/agents.json +127 -1198
  10. package/framework/commands/morph-apply.md +56 -240
  11. package/framework/commands/morph-archive.md +48 -85
  12. package/framework/commands/morph-preflight.md +7 -7
  13. package/framework/commands/morph-proposal.md +35 -191
  14. package/framework/commands/morph-status.md +19 -50
  15. package/framework/commands/morph-troubleshoot.md +2 -2
  16. package/framework/evals/rubrics/README.md +44 -0
  17. package/framework/evals/rubrics/architecture.md +46 -0
  18. package/framework/evals/rubrics/code-quality.md +50 -0
  19. package/framework/evals/rubrics/contracts.md +47 -0
  20. package/framework/evals/rubrics/test-coverage.md +50 -0
  21. package/framework/evals/scenarios/dotnet-crud.yaml +42 -0
  22. package/framework/evals/scenarios/nextjs-auth.yaml +38 -0
  23. package/framework/evals/suites/standard.yaml +5 -0
  24. package/framework/evals/trace-schema.md +67 -0
  25. package/framework/hooks/claude-code/core/README.md +3 -0
  26. package/framework/hooks/claude-code/core/denylist.json +14 -0
  27. package/framework/hooks/claude-code/{pre-tool-use → core}/enforce-phase-writes.js +5 -5
  28. package/framework/hooks/claude-code/core/post-edit-typecheck.js +69 -0
  29. package/framework/hooks/claude-code/core/pre-bash-denylist.js +29 -0
  30. package/framework/hooks/claude-code/{pre-tool-use → core}/protect-spec-files.js +4 -6
  31. package/framework/hooks/claude-code/{stop → core}/validate-completion.js +13 -82
  32. package/framework/hooks/shared/phase-utils.js +20 -31
  33. package/framework/hooks/shared/state-reader.js +4 -5
  34. package/framework/{skills/level-0-meta/mcp-registry.json → mcp/registry.json} +254 -243
  35. package/framework/phases.json +41 -115
  36. package/framework/rubrics/eval-rubric.json +66 -0
  37. package/framework/skills/README.md +39 -64
  38. package/framework/skills/core/README.md +3 -0
  39. package/framework/skills/core/morph-brainstorming/SKILL.md +102 -0
  40. package/framework/skills/core/morph-eval/SKILL.md +57 -0
  41. package/framework/skills/core/morph-implement/SKILL.md +83 -0
  42. package/framework/skills/core/morph-plan/SKILL.md +64 -0
  43. package/framework/skills/core/morph-review/SKILL.md +62 -0
  44. package/framework/skills/core/morph-stack-scan/SKILL.md +109 -0
  45. package/framework/skills/core/morph-standards/SKILL.md +49 -0
  46. package/framework/templates/CLAUDE.md.core.guide.md +29 -0
  47. package/framework/templates/CLAUDE.md.core.template +22 -0
  48. package/framework/templates/REGISTRY.json +4 -4
  49. package/framework/workflows/configs/fast-track.json +5 -10
  50. package/framework/workflows/configs/full.json +4 -8
  51. package/framework/workflows/configs/quick.json +32 -0
  52. package/framework/workflows/configs/standard.json +57 -64
  53. package/package.json +7 -6
  54. package/src/commands/mcp/mcp-setup.js +58 -31
  55. package/src/commands/project/doctor.js +69 -70
  56. package/src/commands/project/init.js +26 -5
  57. package/src/commands/project/status.js +18 -19
  58. package/src/commands/state/approve.js +1 -1
  59. package/src/commands/validation/validate-feature.js +18 -112
  60. package/src/core/paths/output-schema.js +133 -152
  61. package/src/core/state/phase-state-machine.js +10 -24
  62. package/src/core/state/state-manager.js +17 -17
  63. package/src/core/workflows/workflow-detector.js +214 -31
  64. package/src/core/workflows/workflow-router.js +204 -0
  65. package/src/dashboard/app/pages/AgentMap.jsx +32 -33
  66. package/src/dashboard/app/pages/LiveState.jsx +1 -1
  67. package/src/dashboard/app/pages/PhasePipeline.jsx +2 -4
  68. package/src/dashboard/app/pages/SkillsLibrary.jsx +2 -3
  69. package/src/dashboard/app/pages/Workflows.jsx +2 -2
  70. package/src/dashboard/scanner/agents-scanner.js +30 -35
  71. package/src/lib/agents/metrics-aggregator.js +1 -1
  72. package/src/lib/agents/output-collector.js +7 -9
  73. package/src/lib/context/context-builder.js +289 -0
  74. package/src/lib/detectors/claude-config-detector.js +19 -3
  75. package/src/lib/generators/context-generator.js +20 -42
  76. package/src/lib/generators/index.js +1 -0
  77. package/src/lib/generators/mandate-generator.js +512 -0
  78. package/src/lib/generators/metadata-extractor.js +1 -1
  79. package/src/lib/generators/recap-generator.js +3 -4
  80. package/src/lib/installers/mcp-installer.js +300 -92
  81. package/src/lib/phase-chain/phase-validator.js +36 -40
  82. package/src/lib/stack/stack-profile.js +74 -91
  83. package/src/lib/tasks/task-parser.js +1 -1
  84. package/src/lib/tasks/wave-resolver.js +353 -0
  85. package/src/lib/validators/checkpoint-persistence.js +2 -2
  86. package/src/lib/validators/content/cross-phase-validator.js +281 -0
  87. package/src/lib/validators/content/index.js +1 -0
  88. package/src/lib/validators/shared/emit-validator-dispatch.js +6 -56
  89. package/src/scripts/global-install.js +2 -27
  90. package/src/utils/agents-installer.js +224 -447
  91. package/src/utils/claude-settings-manager.js +57 -15
  92. package/src/utils/file-copier.js +1 -0
  93. package/src/utils/hooks-installer.js +15 -117
  94. package/src/utils/skills-installer.js +12 -18
  95. package/bin/detect-agents.js +0 -226
  96. package/bin/task-manager.js +0 -1036
  97. package/framework/agents/README.md +0 -13
  98. package/framework/agents/ai-agents/ai-system-architect.md +0 -194
  99. package/framework/agents/ai-agents/vector-search-expert.md +0 -247
  100. package/framework/agents/architecture/architecture-expert.md +0 -98
  101. package/framework/agents/architecture/morph-spec-architect.md +0 -66
  102. package/framework/agents/architecture/packages-validator.md +0 -89
  103. package/framework/agents/architecture/security-expert.md +0 -79
  104. package/framework/agents/architecture/seo-growth-hacker.md +0 -168
  105. package/framework/agents/architecture/standards-architect.md +0 -153
  106. package/framework/agents/backend/dotnet-senior.md +0 -163
  107. package/framework/agents/backend/ef-modeler.md +0 -119
  108. package/framework/agents/backend/hangfire-orchestrator.md +0 -133
  109. package/framework/agents/backend/ms-agent-expert.md +0 -55
  110. package/framework/agents/backend/neon-expert.md +0 -379
  111. package/framework/agents/frontend/css-specialist.md +0 -89
  112. package/framework/agents/frontend/design-system-validator.md +0 -100
  113. package/framework/agents/frontend/gsap-animator.md +0 -131
  114. package/framework/agents/frontend/nextjs-component-validator.md +0 -97
  115. package/framework/agents/frontend/nextjs-expert.md +0 -201
  116. package/framework/agents/frontend/ui-designer.md +0 -259
  117. package/framework/agents/infrastructure/infra-architect.md +0 -215
  118. package/framework/agents/integrations/asaas-financial.md +0 -138
  119. package/framework/agents/integrations/neon-auth.md +0 -151
  120. package/framework/agents/integrations/resend-email.md +0 -127
  121. package/framework/hooks/claude-code/post-tool-use/agent-complete.js +0 -122
  122. package/framework/hooks/claude-code/post-tool-use/dispatch.js +0 -363
  123. package/framework/hooks/claude-code/post-tool-use/handle-tool-failure.js +0 -78
  124. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +0 -194
  125. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +0 -199
  126. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +0 -55
  127. package/framework/hooks/claude-code/session-start/inject-morph-context.js +0 -323
  128. package/framework/hooks/claude-code/session-start/post-compact-restore.js +0 -41
  129. package/framework/hooks/claude-code/session-start/resume-context.js +0 -77
  130. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +0 -90
  131. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +0 -114
  132. package/framework/hooks/shared/compact-restore.js +0 -123
  133. package/framework/hooks/shared/dispatch-helpers.js +0 -147
  134. package/framework/hooks/shared/skill-reminder-helpers.js +0 -79
  135. package/framework/hooks/shared/stale-task-reset.js +0 -57
  136. package/framework/hooks/shared/worktree-helpers.js +0 -75
  137. package/framework/skills/level-0-meta/README.md +0 -7
  138. package/framework/skills/level-0-meta/morph-agent-teams/SKILL.md +0 -472
  139. package/framework/skills/level-0-meta/morph-brainstorming/SKILL.md +0 -174
  140. package/framework/skills/level-0-meta/morph-brainstorming/references/proposal-example.md +0 -138
  141. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +0 -145
  142. package/framework/skills/level-0-meta/morph-code-review/SKILL.md +0 -250
  143. package/framework/skills/level-0-meta/morph-code-review/references/review-example.md +0 -164
  144. package/framework/skills/level-0-meta/morph-code-review/references/review-guidelines.md +0 -100
  145. package/framework/skills/level-0-meta/morph-code-review/scripts/scan-csharp.mjs +0 -151
  146. package/framework/skills/level-0-meta/morph-code-review-nextjs/SKILL.md +0 -165
  147. package/framework/skills/level-0-meta/morph-code-review-nextjs/references/review-example-nextjs.md +0 -254
  148. package/framework/skills/level-0-meta/morph-code-review-nextjs/scripts/scan-nextjs.mjs +0 -189
  149. package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +0 -344
  150. package/framework/skills/level-0-meta/morph-frontend-review/scripts/scan-accessibility.mjs +0 -376
  151. package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +0 -290
  152. package/framework/skills/level-0-meta/morph-init/SKILL.md +0 -537
  153. package/framework/skills/level-0-meta/morph-parallel-dispatch/SKILL.md +0 -225
  154. package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +0 -401
  155. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-dev-server.mjs +0 -153
  156. package/framework/skills/level-0-meta/morph-post-implementation/scripts/detect-stack.mjs +0 -234
  157. package/framework/skills/level-0-meta/morph-simulation-checklist/SKILL.md +0 -106
  158. package/framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md +0 -243
  159. package/framework/skills/level-0-meta/morph-tool-usage-guide/references/tools-per-phase.md +0 -169
  160. package/framework/skills/level-0-meta/morph-verification-before-completion/SKILL.md +0 -148
  161. package/framework/skills/level-0-meta/morph-verification-before-completion/scripts/check-phase-outputs.mjs +0 -110
  162. package/framework/skills/level-1-workflows/README.md +0 -7
  163. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +0 -269
  164. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +0 -453
  165. package/framework/skills/level-1-workflows/morph-phase-design/references/architecture-analysis-guide.md +0 -44
  166. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-authoring-guide.md +0 -55
  167. package/framework/skills/level-1-workflows/morph-phase-design/references/spec-example.md +0 -253
  168. package/framework/skills/level-1-workflows/morph-phase-implement/.morph/logs/activity.json +0 -38
  169. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +0 -634
  170. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +0 -50
  171. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +0 -54
  172. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +0 -47
  173. package/framework/skills/level-1-workflows/morph-phase-implement/references/recap-example.md +0 -132
  174. package/framework/skills/level-1-workflows/morph-phase-implement/references/vsa-implementation-guide.md +0 -92
  175. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +0 -257
  176. package/framework/skills/level-1-workflows/morph-phase-tasks/.morph/logs/activity.json +0 -14
  177. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +0 -291
  178. package/framework/skills/level-1-workflows/morph-phase-tasks/references/task-planning-patterns.md +0 -143
  179. package/framework/skills/level-1-workflows/morph-phase-tasks/references/tasks-example.md +0 -404
  180. package/framework/skills/level-1-workflows/morph-phase-tasks/scripts/validate-tasks.mjs +0 -112
  181. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +0 -995
  182. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +0 -147
  183. package/framework/squad-templates/backend-only.json +0 -47
  184. package/framework/squad-templates/frontend-only.json +0 -56
  185. package/framework/squad-templates/full-stack.json +0 -74
  186. package/src/commands/agents/agent-metrics.js +0 -174
  187. package/src/commands/agents/audit-dispatch.js +0 -82
  188. package/src/commands/agents/detect-agents.js +0 -275
  189. package/src/commands/agents/dispatch-agents.js +0 -461
  190. package/src/commands/agents/index.js +0 -13
  191. package/src/commands/agents/manage-agents.js +0 -352
  192. package/src/commands/agents/project-metrics.js +0 -74
  193. package/src/commands/phase/phase-reset.js +0 -74
  194. package/src/commands/scope/escalate.js +0 -217
  195. package/src/commands/state/advance-phase.js +0 -600
  196. package/src/commands/state/phase-runner.js +0 -215
  197. package/src/commands/state/state.js +0 -444
  198. package/src/commands/task/expand.js +0 -100
  199. package/src/commands/tasks/index.js +0 -4
  200. package/src/commands/tasks/task.js +0 -105
  201. package/src/commands/templates/index.js +0 -5
  202. package/src/commands/templates/template-render.js +0 -93
  203. package/src/commands/trust/trust.js +0 -118
  204. package/src/lib/agents/agents-manager.js +0 -349
  205. package/src/lib/build/build-runner.js +0 -99
  206. package/src/lib/checkpoints/checkpoint-hooks.js +0 -111
  207. package/src/lib/contracts/sprint-contract-generator.js +0 -137
  208. package/src/lib/scope/impact-analyzer.js +0 -106
  209. package/src/lib/trust/trust-manager.js +0 -157
  210. package/src/utils/tier-helpers.js +0 -24
  211. /package/framework/hooks/claude-code/{post-tool-use → core}/loop-detect.js +0 -0
@@ -1,344 +0,0 @@
1
- ---
2
- name: morph-frontend-review
3
- description: Complete frontend audit — validates design outputs (design-system, WCAG contrast,
4
- mockups), static accessibility scan (TSX + Razor), responsive screenshots at 3
5
- breakpoints via Playwright, axe-core a11y at runtime, and SEO (Next.js metadata). Covers Next.js
6
- Triggered at end of phase-uiux and post-implementation.
7
- argument-hint: "[feature-name]"
8
- user-invocable: true
9
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion,
10
- mcp__playwright__browser_navigate, mcp__playwright__browser_resize,
11
- mcp__playwright__browser_take_screenshot, mcp__playwright__browser_snapshot,
12
- mcp__playwright__browser_evaluate, mcp__playwright__browser_console_messages
13
- cliVersion: "4.22.0"
14
- stacks:
15
- - nextjs
16
- ---
17
-
18
- # Frontend Review
19
-
20
- > Complete frontend audit: design outputs, static + runtime accessibility, responsive
21
- > screenshots and SEO. Triggered at end of `phase-uiux` (validates design) and post-implementation
22
- > (validates implemented code).
23
-
24
- > **Note about MCP:** The `mcp__playwright__` prefix corresponds to the Playwright server name
25
- > as configured in the project's `settings.json`. If the server has a different name (e.g.,
26
- > `plugin_playwright_playwright`), adjust the prefix in the calls below.
27
-
28
- ---
29
-
30
- ## Step 0 — Detect Context and Stack
31
-
32
- ```bash
33
- node .claude/skills/morph-post-implementation/scripts/detect-stack.mjs
34
- ```
35
-
36
- Output JSON: `{ stack: "DOTNET" | "NEXTJS" | "FULLSTACK" | "UNKNOWN", frontendPath, backendPath, startCommand }`
37
-
38
- Beyond the stack, determine the **context** by examining what exists:
39
-
40
- ```bash
41
- # Check if design outputs exist
42
- ls .morph/features/$ARGUMENTS/1-ui/ 2>/dev/null
43
-
44
- # Check if implemented frontend files exist
45
- find . -name "*.tsx" 2>/dev/null | head -5
46
- ```
47
-
48
- - If `.morph/features/$ARGUMENTS/1-ui/design-system.md` exists → context includes **design validation**
49
- - If implemented frontend files exist (`.tsx`) → context includes **implementation validation**
50
- - Both can coexist
51
-
52
- Store `stack`, `frontendPath`, `startCommand` and the detected context — all steps depend on them.
53
-
54
- ---
55
-
56
- ## Step 1 — Design Outputs Validation (if context includes design validation)
57
-
58
- ```bash
59
- morph-spec validate-feature $ARGUMENTS
60
- ```
61
-
62
- Verify existence and quality of the 4 mandatory outputs in `.morph/features/$ARGUMENTS/1-ui/`:
63
-
64
- ```
65
- [ ] design-system.md — color palette, typography tokens, spacing
66
- [ ] mockups.md — wireframes with responsive states
67
- [ ] components.md — technical component specs
68
- [ ] flows.md — user journeys and edge cases
69
- [ ] WCAG AA Contrast: primary and text colors ≥ 4.5:1 (check design-system.md)
70
- [ ] Documented touch targets: ≥ 44x44px for mobile
71
- [ ] Loading/error/empty states defined in mockups
72
- ```
73
-
74
- **🚫 BLOCK** if `validate-feature` fails or mandatory outputs missing.
75
-
76
- Read `design-system.md` and manually verify that primary and text colors have a contrast ratio
77
- ≥ 4.5:1. Reference tools: WebAIM Contrast Checker (WCAG 2.1 AA criteria).
78
-
79
- ---
80
-
81
- ## Step 2 — Static Accessibility Scan
82
-
83
- ```bash
84
- node .claude/skills/morph-frontend-review/scripts/scan-accessibility.mjs $frontendPath
85
- ```
86
-
87
- The script automatically detects file extensions for Next.js (`.tsx`).
88
- If `frontendPath` is not defined, the script uses `.` (project root).
89
-
90
- **Checks implemented:**
91
-
92
- | ID | Severity | Files | Checks |
93
- |----|-----------|---------|---------|
94
- | `IMG_MISSING_ALT` | CRITICAL | .tsx | `<img` missing `alt=` attribute |
95
- | `INPUT_MISSING_LABEL` | HIGH | .tsx | `<input` without `aria-label`, `aria-labelledby`, or associated `<label for=` |
96
- | `HEADING_HIERARCHY` | HIGH | .tsx | Heading level skip (H1→H3 skipping H2) |
97
- | `LINK_NO_TEXT` | HIGH | .tsx | `<a` empty or with only icon and no `aria-label` |
98
- | `BUTTON_NO_TEXT` | HIGH | .tsx | `<button` no text and no `aria-label` |
99
- | `AUTOPLAY_MEDIA` | MEDIUM | .tsx | `<video`/`<audio` with `autoPlay` without `muted` |
100
-
101
- **🚫 BLOCK** if any CRITICAL finding or HIGH count ≥ 3.
102
-
103
- Fix all CRITICALs before continuing. For HIGH < 3, record in summary as warnings.
104
-
105
- ---
106
-
107
- ## Step 3 — Frontend Code Scan (if context includes implementation validation)
108
-
109
- ### If NEXTJS or FULLSTACK:
110
-
111
- ```bash
112
- node .claude/skills/morph-code-review-nextjs/scripts/scan-nextjs.mjs $frontendPath
113
- ```
114
-
115
- > Skip if already run by `post-implementation` in the same session.
116
-
117
- **🚫 BLOCK** if CRITICAL findings found.
118
-
119
- ---
120
-
121
- ## Step 4 — Responsive Screenshots (Playwright MCP)
122
-
123
- ### 4a. Detect Dev Server
124
-
125
- ```bash
126
- node .claude/skills/morph-post-implementation/scripts/detect-dev-server.mjs "$startCommand"
127
- ```
128
-
129
- ### 4b. If dev server available (exit 0):
130
-
131
- Extract the main feature URLs by reading `spec.md`:
132
-
133
- ```bash
134
- Read: .morph/features/$ARGUMENTS/2-design/spec.md
135
- ```
136
-
137
- For each main page (max 3), capture screenshots at 3 breakpoints:
138
-
139
- ```javascript
140
- // Mobile (375px)
141
- await mcp__playwright__browser_resize({ width: 375, height: 812 });
142
- await mcp__playwright__browser_navigate({ url: '<feature-url>' });
143
- await mcp__playwright__browser_take_screenshot({
144
- type: 'png',
145
- filename: `.morph/features/${ARGUMENTS}/visual-screenshots/mobile-<page>.png`
146
- });
147
-
148
- // Tablet (768px)
149
- await mcp__playwright__browser_resize({ width: 768, height: 1024 });
150
- await mcp__playwright__browser_navigate({ url: '<feature-url>' });
151
- await mcp__playwright__browser_take_screenshot({
152
- type: 'png',
153
- filename: `.morph/features/${ARGUMENTS}/visual-screenshots/tablet-<page>.png`
154
- });
155
-
156
- // Desktop (1440px)
157
- await mcp__playwright__browser_resize({ width: 1440, height: 900 });
158
- await mcp__playwright__browser_navigate({ url: '<feature-url>' });
159
- await mcp__playwright__browser_take_screenshot({
160
- type: 'png',
161
- filename: `.morph/features/${ARGUMENTS}/visual-screenshots/desktop-<page>.png`
162
- });
163
- ```
164
-
165
- Screenshots saved to: `.morph/features/$ARGUMENTS/visual-screenshots/`
166
- (works in both phase `1-ui` and `5-implement`)
167
-
168
- ### 4c. If dev server NOT available (exit 1):
169
-
170
- **⚠️ WARNING: Dev server not found.**
171
-
172
- Request explicit user confirmation before skipping screenshots:
173
-
174
- ```
175
- Dev server not detected. Responsive screenshots via Playwright cannot be captured.
176
-
177
- Options:
178
- 1. Start the server manually and re-run /morph-frontend-review
179
- 2. Explicitly confirm you want to skip screenshots and why
180
-
181
- Cannot proceed to axe-core without dev server.
182
- ```
183
-
184
- **Wait for response before continuing.**
185
-
186
- ---
187
-
188
- ## Step 5 — axe-core Runtime (Playwright MCP, if dev server active)
189
-
190
- For each feature page (use the same URLs from Step 4):
191
-
192
- ```javascript
193
- // Navigate to the page
194
- await mcp__playwright__browser_navigate({ url: '<feature-url>' });
195
-
196
- // Inject axe-core via CDN and run WCAG 2.1 AA scan
197
- await mcp__playwright__browser_evaluate({
198
- function: `async () => {
199
- if (!window.axe) {
200
- await new Promise((resolve, reject) => {
201
- const s = document.createElement('script');
202
- s.src = 'https://cdnjs.cloudflare.com/ajax/libs/axe-core/4.9.1/axe.min.js';
203
- s.onload = resolve;
204
- s.onerror = reject;
205
- document.head.appendChild(s);
206
- });
207
- }
208
- const results = await window.axe.run(document, {
209
- runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa'] }
210
- });
211
- return results.violations.map(v => ({
212
- id: v.id,
213
- impact: v.impact,
214
- description: v.description,
215
- nodes: v.nodes.length,
216
- helpUrl: v.helpUrl
217
- }));
218
- }`
219
- });
220
- ```
221
-
222
- Group violations by impact:
223
- - `critical` / `serious` → **🚫 BLOCK** (do not create PR)
224
- - `moderate` / `minor` → report as warnings in summary, non-blocking
225
-
226
- Also check for accessibility-related console errors:
227
-
228
- ```javascript
229
- await mcp__playwright__browser_console_messages({ level: 'error' });
230
- ```
231
-
232
- ---
233
-
234
- ## Step 6 — SEO Check (Next.js only)
235
-
236
- Scan feature `page.tsx` files to verify metadata:
237
-
238
- ```bash
239
- # Find feature pages
240
- find . -name "page.tsx" -path "*$ARGUMENTS*" 2>/dev/null
241
-
242
- # Check if they have metadata
243
- grep -l "export const metadata\|export async function generateMetadata" $(find . -name "page.tsx" -path "*$ARGUMENTS*" 2>/dev/null)
244
- ```
245
-
246
- Checklist per page:
247
-
248
- ```
249
- [ ] export const metadata with title and description
250
- [ ] og:title and og:description (Open Graph)
251
- [ ] og:image defined (for social sharing)
252
- [ ] No duplicate titles between pages
253
- [ ] robots doesn't block public page indexing
254
- ```
255
-
256
- > SEO doesn't block PR — report as warnings in final summary.
257
-
258
- ---
259
-
260
- ## Step 7 — Responsive Design Checklist
261
-
262
- After viewing Step 4 screenshots:
263
-
264
- ```
265
- [ ] Mobile (375px): no horizontal scroll, buttons ≥ 44px, legible text
266
- [ ] Tablet (768px): layout adapts (sidebar collapses, grid adjusts columns)
267
- [ ] Desktop (1440px): uses available space, no stretched content
268
- [ ] Navigation works on all breakpoints
269
- [ ] Forms accessible on mobile (visible labels, large enough inputs)
270
- ```
271
-
272
- If screenshots were not captured (dev server unavailable), mark as "unverified" and
273
- record in summary.
274
-
275
- ---
276
-
277
- ## Step 8 — Summary and Artifacts
278
-
279
- Create consolidated summary file:
280
-
281
- ```bash
282
- mkdir -p ".morph/features/$ARGUMENTS/visual-screenshots"
283
- ```
284
-
285
- Save to `.morph/features/$ARGUMENTS/visual-screenshots/morph-frontend-review-summary.md`:
286
-
287
- ```markdown
288
- # Frontend Review — {feature}
289
-
290
- **Date:** {date}
291
- **Stack:** {detected stack}
292
- **Context:** design validation | implementation validation | both
293
-
294
- ## Results
295
-
296
- ### Step 1 — Design Outputs
297
- - validate-feature: ✅ PASS / 🚫 BLOCK
298
- - Outputs verified: design-system.md, mockups.md, components.md, flows.md
299
- - WCAG Contrast: {result}
300
-
301
- ### Step 2 — Static Accessibility Scan
302
- - Files scanned: {N}
303
- - Findings: {total} ({CRITICAL: N, HIGH: N, MEDIUM: N})
304
- - Status: ✅ PASS / 🚫 BLOCK
305
-
306
- ### Step 3 — Frontend Code Scan
307
- - Status: ✅ PASS / 🚫 BLOCK / ⏭️ skipped (already run)
308
-
309
- ### Step 4 — Responsive Screenshots
310
- - Mobile (375px): {paths or "not captured"}
311
- - Tablet (768px): {paths or "not captured"}
312
- - Desktop (1440px): {paths or "not captured"}
313
-
314
- ### Step 5 — axe-core Runtime
315
- - Critical/serious violations: {N} → ✅ / 🚫
316
- - Warnings (moderate/minor): {N}
317
-
318
- ### Step 6 — SEO (Next.js)
319
- - Pages with metadata: {N}/{total}
320
- - Gaps: {list or "none"}
321
-
322
- ## Overall Status
323
-
324
- **{✅ PASS / 🚫 BLOCK}**
325
-
326
- {If BLOCK: reason(s) listed here}
327
- ```
328
-
329
- ---
330
-
331
- ## Block Summary
332
-
333
- | Step | Block Condition |
334
- |------|-------------------|
335
- | Step 1 | `validate-feature` failed or mandatory outputs missing |
336
- | Step 2 | Any CRITICAL finding or HIGH ≥ 3 in static scan |
337
- | Step 3 | Any CRITICAL finding in code scan |
338
- | Step 5 | Dev server active + axe-core violations `critical` or `serious` |
339
-
340
- **All BLOCKs must be resolved before creating the PR (when run post-implementation).**
341
-
342
- ---
343
-
344
- *MORPH-SPEC by Polymorphism Tech*