@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,995 +0,0 @@
1
- ---
2
- name: morph-phase-uiux
3
- description: MORPH-SPEC Phase 2 (UI/UX). Creates design-system.md, mockups.md, components.md, and flows.md using Playwright/Context7 MCPs. Use after setup for features with frontend UI components, pages, dashboards, forms, wizards, or visual interactions requiring design documentation.
4
- argument-hint: "[feature-name]"
5
- user-invocable: false
6
- allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.22.0"
8
- ---
9
-
10
- # MORPH UI/UX Design - Phase 2
11
-
12
- > INTERNAL: Workflow skill used by /morph-proposal during automated phase orchestration. Not a user command.
13
-
14
- Conditional phase for features with front-end. Collects UI/UX requirements, generates wireframes, component specs, and user flows.
15
-
16
- ## Prerequisites
17
-
18
- - [ ] Proposal approved by the user
19
- - [ ] Feature has detected UI keywords (ui, component, page, dashboard, wizard, form, chart)
20
- - [ ] `ui-designer` agent activated
21
-
22
- ## Recommended Tools
23
-
24
- > **Ref:** `framework/skills/level-0-meta/morph-tool-usage-guide/SKILL.md` for complete guide.
25
- > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` for MCP reference.
26
-
27
- | Action | Tool | Alternative |
28
- |--------|------|-------------|
29
- | Check existing design system | **Read** `.morph/context/design-system.md` | — |
30
- | Read user screenshots | **Read** (image file) | — |
31
- | Search for existing CSS variables | **Grep** `--root:` in `*.css,*.scss` | — |
32
- | Find existing components | **Glob** `**/components/**/*.tsx` | — |
33
- | UI component documentation | **Context7 MCP** `query_docs({ libraryId, query })` | **WebSearch** + **WebFetch** |
34
- | Preview existing page | **Playwright MCP** `browser_navigate()` + `browser_take_screenshot()` | **WebFetch** URL |
35
- | Generate visual mockup | **Playwright MCP** `browser_navigate()` + `browser_resize()` + `browser_take_screenshot()` | HTML file + manual screenshot |
36
- | Inspect page structure | **Playwright MCP** `browser_snapshot()` | **WebFetch** + manual parse |
37
- | Test responsive layout | **Playwright MCP** `browser_resize()` + `browser_take_screenshot()` | Manual testing |
38
- | External design references | **WebSearch** + **WebFetch** | — |
39
- | Render UI templates | **Bash** `morph-spec template render docs/ui-mockups ...` | — |
40
- | Generate design system from existing CSS | **Bash** `morph-spec generate design-system --scan` | — |
41
- | Update state | **Bash** `morph-spec state mark-output ...` | — |
42
- | Auto-detect dev server | **Glob** `next.config.*`, `vite.config.*`, `*.csproj` | **Read** `package.json` scripts |
43
- | Capture existing app | **Playwright MCP** `browser_navigate()` + `browser_take_screenshot()` | — |
44
- | Read Tailwind config | **Read** `tailwind.config.{js,ts}` | **Grep** `colors:` |
45
- | Trend research | **Context7 MCP** / **WebSearch** | — |
46
- | Generate AI screen designs | **Stitch MCP** `generate_screen_from_text()` + `fetch_screen_image()` | HTML mockup + Playwright (Step 3.5) |
47
- | Export design tokens from Stitch | **Stitch MCP** `fetch_screen_code()` | Manual design-system.md creation |
48
- | Download Stitch HTML exports | **Stitch MCP** `fetch_screen_code()` → save to `stitch-html/` | Step 3.5.0.5 |
49
-
50
- **MCPs for this phase:** Playwright (preview, inspection, responsiveness), Context7 (component docs), Stitch (optional: AI screen generation, design.md export).
51
-
52
- **Anti-patterns:**
53
- - Task agent to read a screenshot (use Read directly on image)
54
- - Guess component props (use Context7 for actual API)
55
-
56
- ---
57
-
58
- ## Workflow
59
-
60
- ### Step 0: Ensure uiux phase
61
-
62
- ```bash
63
- morph-spec state get $ARGUMENTS
64
- ```
65
-
66
- Check the `"phase"` field in the output:
67
-
68
- **If `"phase": "uiux"`** → correct phase, proceed.
69
-
70
- **If `"phase": "proposal"`** → execute in sequence:
71
- 1. `morph-spec state mark-output $ARGUMENTS proposal`
72
- 2. `morph-spec phase advance $ARGUMENTS` (→ uiux)
73
-
74
- **Any other value** → do not proceed — inconsistent state, report to user.
75
-
76
- > **Rule:** Never write to `1-ui/` until the phase is `uiux`. The hook will block writes.
77
-
78
- ---
79
-
80
- ### Step 0.2: Capture Existing App (Playwright)
81
-
82
- > **Purpose:** Before analyzing tokens, capture visual screenshots of the existing app to understand current design patterns.
83
- > **Skip if:** Greenfield project (no existing UI pages).
84
-
85
- #### 0.2.1 — Auto-detect dev server
86
-
87
- Check in priority order:
88
-
89
- 1. **`config.json`**: Read `.morph/config/config.json` → check for `project.devServerUrl` field → use if present
90
- 2. **`package.json` port flags**: Read `package.json` scripts → scan for `--port`, `-p` flags → extract port
91
- 3. **Next.js**: Glob `next.config.*` → try `http://localhost:3000`
92
- 4. **Vite**: Glob `vite.config.*` → try `http://localhost:5173`
93
- 5. **.NET**: Glob `**/Properties/launchSettings.json` → Read → extract `applicationUrl`
94
-
95
- Track: `detectedUrl` (string or null).
96
-
97
- #### 0.2.2 — Attempt connection
98
-
99
- If `detectedUrl` is not null:
100
-
101
- ```
102
- mcp__plugin_playwright_playwright__browser_navigate({ url: detectedUrl })
103
- ```
104
-
105
- - **Timeout:** 5 seconds
106
- - **If connects:** proceed to 0.2.3
107
- - **If fails (timeout/error):**
108
-
109
- ```json
110
- {
111
- "questions": [{
112
- "header": "Dev Server",
113
- "question": "Could not connect to dev server at {detectedUrl}. How to proceed?",
114
- "multiSelect": false,
115
- "options": [
116
- { "label": "Start server first", "description": "I'll start the dev server — wait for me" },
117
- { "label": "Use different URL", "description": "I'll provide the correct URL (Other)" },
118
- { "label": "Skip screenshots", "description": "Continue without existing app screenshots" }
119
- ]
120
- }]
121
- }
122
- ```
123
-
124
- If `detectedUrl` is null (no indicators found):
125
-
126
- ```json
127
- {
128
- "questions": [{
129
- "header": "Existing UI?",
130
- "question": "Does this project have existing UI pages I should capture?",
131
- "multiSelect": false,
132
- "options": [
133
- { "label": "Yes, provide URL", "description": "I'll provide the URL in the field below (Other)" },
134
- { "label": "No, greenfield", "description": "Skip — this is a new project" }
135
- ]
136
- }]
137
- }
138
- ```
139
-
140
- #### 0.2.3 — Screenshot main pages
141
-
142
- Once connected, take screenshots of up to 5 pages:
143
-
144
- 1. **Current page** (usually home/root)
145
- 2. Navigate to common routes: `/dashboard`, `/admin`, `/settings`, or detect from sidebar links via `browser_snapshot()`
146
- 3. For each page:
147
- ```
148
- mcp__plugin_playwright_playwright__browser_resize({ width: 1440, height: 900 })
149
- mcp__plugin_playwright_playwright__browser_take_screenshot({})
150
- ```
151
- 4. Save screenshots to `.morph/features/$ARGUMENTS/1-ui/existing-*.png`
152
-
153
- #### 0.2.4 — Visual analysis
154
-
155
- Analyze the captured screenshots and write `.morph/features/$ARGUMENTS/1-ui/existing-ui-analysis.md`:
156
-
157
- > **Note:** This is an intermediate artifact — NOT a tracked output in `output-schema.js`. It will not appear in `state mark-output`. Advisory warnings from `task-tracking-guard.js` are expected.
158
-
159
- ```markdown
160
- # Existing UI Analysis — {Feature}
161
-
162
- ## Visual Summary
163
- - **Color palette:** [dominant colors observed]
164
- - **Typography:** [serif/sans/mono, approximate weights, scale]
165
- - **Layout:** [sidebar/topbar/fullwidth, grid system, card patterns]
166
- - **Sophistication level:** [basic/intermediate/advanced]
167
- - **Dark/Light mode:** [which mode detected, or both]
168
-
169
- ## Design Tokens Detected Visually
170
- - Primary color: [approx hex from screenshots]
171
- - Background: [surface colors observed]
172
- - Border style: [rounded/sharp, thickness]
173
- - Shadow style: [flat/elevated/colored]
174
-
175
- ## Patterns Worth Preserving
176
- - [List patterns that work well and should be maintained]
177
-
178
- ## Opportunities for Improvement
179
- - [List areas where modern techniques could improve the UI]
180
- ```
181
-
182
- This analysis feeds into Step 0.5 (cross-check with extracted tokens) and Step 1.5 (domain-adaptive direction).
183
-
184
- ---
185
-
186
- ### Step 0.5: Check Design System
187
-
188
- **This step is MANDATORY and must always run before Step 1.**
189
-
190
- #### Step 0.5.1 — Scan frontend for design tokens (ALWAYS)
191
-
192
- Search for existing design tokens across ALL supported stacks. Run these scans in parallel:
193
-
194
- **A. CSS Custom Properties (all stacks):**
195
- Glob these patterns (exclude `node_modules/`, `.next/`, `dist/`, `build/`, `obj/`, `bin/`):
196
- ```
197
- wwwroot/**/*.css
198
- wwwroot/**/*.scss
199
- styles/**/*.css
200
- src/styles/**/*.css
201
- src/**/*.css
202
- src/**/*.scss
203
- src/**/*.module.css
204
- public/**/*.css
205
- app/**/*.css
206
- ```
207
- For each file found, Grep for `:root {` blocks containing `--` custom properties.
208
-
209
- **B. Tailwind Config (Next.js / Vite):**
210
- Glob: `tailwind.config.{js,ts,mjs,cjs}`
211
- If found, Read the file and extract:
212
- - `theme.colors` / `theme.extend.colors` → map to color tokens
213
- - `theme.fontFamily` → map to font tokens
214
- - `theme.spacing` → map to spacing tokens
215
- - `theme.borderRadius` → map to radius tokens
216
-
217
- **C. shadcn/ui Config:**
218
- Glob: `components.json`
219
- If found and contains `"style"` field, also scan `src/lib/utils.ts` or `lib/utils.ts` for CSS var references.
220
-
221
- **D. Global theme files:**
222
- Glob: `**/theme.{ts,js}`, `**/tokens.{ts,js}`, `**/design-tokens.{ts,js}`
223
- If found, Read and extract exported color/spacing/font objects.
224
-
225
- Classify ALL found tokens into:
226
- - **Colors**: `--color-*`, hex values, rgb()
227
- - **Fonts**: `--font-*`, `font-family:`, fontFamily config
228
- - **Spacing**: `--space-*`, `--gap-*`, spacing config
229
- - **Radius**: `--radius-*`, borderRadius config
230
- - **Shadows**: `--shadow-*`, boxShadow config
231
-
232
- Track: `tokensFound` (object by category), `tokenSources` (array of {file, stack, tokenCount}).
233
-
234
- #### Step 0.5.2 — Check if design-system.md exists
235
-
236
- ```
237
- Read: .morph/context/design-system.md
238
- ```
239
-
240
- Track: `dsExists` (bool).
241
-
242
- #### Step 0.5.3 — Decision tree (4 cases)
243
-
244
- | Case | Condition | Action |
245
- |------|-----------|--------|
246
- | **A** | `dsExists` AND `cssTokensFound` | Cross-check DS vs scanned tokens. If >2 colors diverge, flag misalignment and ask user if they want to update DS with `AskUserQuestion`. Proceed to Step 1. |
247
- | **B** | `dsExists` AND NOT `cssTokensFound` | Print: `✓ Design system found (no CSS tokens to cross-check)`. Proceed to Step 1. |
248
- | **C** | NOT `dsExists` AND tokens found | Auto-generate `.morph/context/design-system.md` from ALL scanned token sources (CSS vars, Tailwind config, etc.). Merge tokens from multiple sources, preferring Tailwind/Theme config over raw CSS. If Step 0.2 produced `existing-ui-analysis.md`, cross-reference visual analysis with extracted tokens. Proceed to Step 1. |
249
- | **D** | NOT `dsExists` AND NOT `cssTokensFound` | Greenfield project. Ask user for aesthetic direction + brand color using `AskUserQuestion` (same options as morph-init). Scaffold from template. Proceed to Step 1. |
250
- | **E** | Stitch MCP available AND `design.md` found in project root | Parse Stitch design.md, extract color/typography/spacing/radius/shadow tokens, map into `.morph/context/design-system.md` template. If `dsExists`, merge (Stitch fills gaps, manually-set tokens preserved). Add changelog entry. Proceed to Step 1. |
251
-
252
- **Case E — Stitch design.md integration:**
253
-
254
- > **Prerequisite:** Stitch MCP detected (tools matching pattern `stitch` found) OR a `design.md` file exists in the project root.
255
-
256
- 1. If Stitch MCP is available, check for existing projects:
257
- ```
258
- stitch__list_projects({})
259
- ```
260
- If projects exist, list screens and fetch the design export:
261
- ```
262
- stitch__list_screens({ projectId: selectedProjectId })
263
- stitch__fetch_screen_code({ screenId: screenId })
264
- ```
265
-
266
- 2. If `design.md` exists in project root (manual export from Stitch), read it directly.
267
-
268
- 3. Parse the design.md content and map tokens into `design-system.md` template sections:
269
- - Color values → `## Color Tokens` (map to `--color-primary`, `--color-accent`, etc.)
270
- - Font families/sizes → `## Typography` (map to `--font-display`, `--font-body`)
271
- - Spacing values → `## Spacing Tokens`
272
- - Border radius → `## Border Radius Tokens`
273
- - Shadow definitions → `## Shadow Tokens`
274
-
275
- 4. Write or merge into `.morph/context/design-system.md` using the existing template structure.
276
-
277
- 5. Add changelog entry:
278
- `- [today's date] [morph-phase-uiux] Tokens imported from Stitch design.md ({N} tokens)`
279
-
280
- Print: `✓ Design system populated from Stitch design — .morph/context/design-system.md`
281
-
282
- **Case C — auto-generate from scanned tokens:**
283
-
284
- Create `.morph/context/design-system.md` with these sections populated from scan results:
285
- - `## Color Tokens` → `:root { }` block with all found color variables (preserve exact variable names)
286
- - `## Typography` → found font-family values (map by variable name heuristic: `--font-display` vs `--font-body`)
287
- - `## Spacing Tokens` → found spacing variables
288
- - `## Aesthetic Direction` → `#TODO` (requires user judgment, fill in manually)
289
- - `## Changelog` → `- [today's date] [morph-phase-uiux] Auto-generated from CSS scan ([N] tokens from [files])`
290
-
291
- Print: `✓ Design system generated from [N] tokens — .morph/context/design-system.md`
292
-
293
- > **Design system is mandatory** for UI features. The implementation gate (Phase 7) will block if no design system exists.
294
-
295
- ## MANDATORY: Session Tasks
296
-
297
- > **BEFORE starting UI/UX work**, analyze the workflow below and create session tasks.
298
- >
299
- > **Rules:** Minimum 3 tasks, typically 5-7. Mark `in_progress` before starting, `completed` after.
300
- >
301
- > **Typical tasks:** design system check, user input collection, UI library selection, visual mockup, deliverable generation, accessibility validation, approval
302
-
303
- ### Step 1: Detect If Phase Is Needed
304
-
305
- Check if active agents include `ui-designer`:
306
-
307
- ```bash
308
- morph-spec state get $ARGUMENTS
309
- ```
310
-
311
- If `ui-designer` is NOT in `activeAgents`, skip this phase and continue to Phase 3 (Design).
312
-
313
- ### Step 1.3: Trend Research
314
-
315
- > **Purpose:** Before defining aesthetic direction, research current design trends relevant to this project's domain.
316
- > Use Context7 MCP or web search for current design trends.
317
-
318
- #### 1.3.1 — Research current trends
319
-
320
- > **MCP:** Use **WebSearch** to research current design trends for the detected domain (e.g., "{currentYear} UI design trends {detectedDomain}"). WebSearch provides real-time results that are more current than any static reference. If WebSearch is not available, use **Context7 MCP** to query UI library documentation for latest component patterns and best practices. If neither is available, rely on your training knowledge of current design trends.
321
-
322
- Research current design trends relevant to the project's domain and stack. Identify 3-5 techniques that fit the project.
323
-
324
- #### 1.3.2 — Detect project domain
325
-
326
- Scan `.morph/features/$ARGUMENTS/0-proposal/proposal.md` for domain keywords:
327
-
328
- | Domain | Keywords |
329
- |--------|----------|
330
- | SaaS Dashboard | dashboard, analytics, metrics, monitoring, kpi, chart |
331
- | E-commerce | e-commerce, store, product, cart, checkout, catalog |
332
- | Landing Page | landing, marketing, site, hero, launch, waitlist |
333
- | Internal Tool | admin, backoffice, internal, settings, management |
334
- | Social/Community | social, feed, community, chat, post, notification |
335
-
336
- Count keyword hits per domain. Use the domain with most hits. If zero hits across all domains, skip domain-specific filtering.
337
-
338
- #### 1.3.3 — Research current trends (optional enhancement)
339
-
340
- If Context7 MCP or WebSearch is available:
341
- - Search: "{currentYear} UI design trends {detectedDomain}"
342
- - Extract 2-3 additional techniques not in the curated catalog
343
- - Evaluate if they are production-ready (browser support, performance)
344
-
345
- #### 1.3.4 — Present recommendations
346
-
347
- Use `AskUserQuestion` to present 3-4 recommended modern techniques:
348
-
349
- ```json
350
- {
351
- "questions": [{
352
- "header": "Trends",
353
- "question": "Based on your project domain ({detectedDomain}), these modern techniques are recommended. Which ones do you want to incorporate?",
354
- "multiSelect": true,
355
- "options": [
356
- { "label": "{Technique 1}", "description": "{Brief description + when to use}" },
357
- { "label": "{Technique 2}", "description": "{Brief description + when to use}" },
358
- { "label": "{Technique 3}", "description": "{Brief description + when to use}" },
359
- { "label": "None / custom", "description": "Skip trends or describe your own preference (Other)" }
360
- ]
361
- }]
362
- }
363
- ```
364
-
365
- Selected trends feed into Step 1.5 (Aesthetic Direction) and Step 4 (Deliverables).
366
-
367
- ---
368
-
369
- ### Step 1.5: Design Thinking — Aesthetic Direction
370
-
371
- **BEFORE collecting technical requirements**, define visual direction with 4 questions:
372
-
373
- 1. **Purpose**: What problem does it solve? Who uses it? What is the professional context?
374
- 2. **Tone**: What direction? (Minimal Refined / Editorial / Soft Professional / Industrial / Modern Luxury)
375
- 3. **Differentiation**: What is the 1 memorable element of this interface?
376
- 4. **Constraints**: Framework, performance budget, existing brand guidelines
377
-
378
- **CRITICAL:** Commit to direction BEFORE technical specs. Document in `design-system.md`
379
- in section `## Aesthetic Direction` (template available in the standard above).
380
-
381
- #### Domain-Adaptive Patterns
382
-
383
- After defining aesthetic direction, apply domain-specific pattern suggestions:
384
-
385
- Based on the domain detected in Step 1.3.2, suggest domain-adaptive patterns:
386
-
387
- | Domain | Preferred Directions | Key Patterns to Suggest |
388
- |--------|---------------------|------------------------|
389
- | SaaS Dashboard | Industrial, Minimal Refined | Dense bento grid KPIs, skeleton loaders, sidebar glassmorphism, dark mode default |
390
- | E-commerce | Modern Luxury, Soft Professional | Product card hover lift, CTA colored shadows, image-first layouts, scroll galleries |
391
- | Landing Page | Editorial, Modern Luxury | Hero aurora gradient, scroll-driven narrative, fluid typography, overlapping layers |
392
- | Internal Tool | Industrial, Minimal Refined | Compact forms, dense tables, status chips, monospace data displays |
393
- | Social/Community | Soft Professional, Editorial | Card feed, notification badges, avatar systems, drawer navigation |
394
-
395
- If the user's chosen direction conflicts with domain recommendations (e.g., Industrial for E-commerce), present an `AskUserQuestion` advisory:
396
-
397
- ```json
398
- {
399
- "questions": [{
400
- "header": "Direction",
401
- "question": "You chose {direction} for a {domain} project. The recommended directions are {recommended}. Keep your choice or adapt?",
402
- "multiSelect": false,
403
- "options": [
404
- { "label": "Keep {direction}", "description": "I have specific reasons for this choice" },
405
- { "label": "Switch to {recommended[0]}", "description": "{Brief rationale}" }
406
- ]
407
- }]
408
- }
409
- ```
410
-
411
- #### Integration with Selected Trends
412
-
413
- Incorporate the trends selected in Step 1.3.4 into the aesthetic direction documentation:
414
-
415
- - Add selected trends to `## Aesthetic Direction` in `design-system.md`
416
- - Document how each trend maps to the chosen direction
417
-
418
- **Anti-patterns to avoid:**
419
- - Purple gradient on white background (AI cliche)
420
- - Inter/Roboto as display font
421
- - 3-column card grid without visual differentiation
422
- - 5-color palette with equal weight (without dominant + accent)
423
-
424
- ### Step 2: Collect User Input
425
-
426
- **ALWAYS ask the user FIRST:**
427
-
428
- 1. **Layout and style**:
429
- - Do you have any layout ideas in mind?
430
- - Do you have visual references? (sites, apps, screenshots)
431
- - How do you envision the user flow?
432
-
433
- 2. **Components and interactions**:
434
- - What are the main components of this screen/page?
435
- - What states need to be considered? (loading, error, empty, success)
436
-
437
- 3. **Reference images**:
438
- - Do you have example images I can analyze?
439
- - If YES: use Read tool to read screenshots and extract patterns
440
-
441
- ### Step 3: Choose UI Library
442
-
443
- Detect the stack from `.morph/config/config.json` and recommend the appropriate library:
444
-
445
- **Next.js stack:**
446
- - **shadcn/ui + Radix** (recommended) — composable primitives, full control, Tailwind-native
447
- - **MUI** — feature-rich, enterprise-grade, material design
448
-
449
- **Document the decision as an ADR in `decisions.md`** with: context, options considered, decision, and rationale.
450
-
451
- > **MCP:** After selecting the UI library, use **Context7 MCP** (`resolve-library-id` → `query-docs`) to fetch the library's latest component API (e.g., shadcn/ui primitives, Radix props, MUI component APIs). This ensures component specs in `components.md` reference real, current props — not outdated or hallucinated ones. If Context7 is not available, use **WebSearch** + **WebFetch** to check the official component documentation.
452
-
453
- ### Step 3.5: Visual Mockup (Playwright MCP or Stitch MCP)
454
-
455
- > **Purpose:** Generate a real visual preview using project design tokens before writing formal specs.
456
- > Seeing the actual visual before committing to components prevents misaligned specs.
457
-
458
- #### 3.5.0 — Stitch MCP Path (Alternative to HTML Mockup)
459
-
460
- > **Skip if:** Stitch MCP is NOT available. Fall through to 3.5.1 (HTML mockup).
461
- > **Use when:** Stitch MCP is detected and user wants AI-generated screen designs.
462
-
463
- If Stitch MCP is available, present the user with a choice:
464
-
465
- ```json
466
- {
467
- "questions": [{
468
- "header": "Design Tool",
469
- "question": "Stitch MCP is available for AI-generated screen designs. How would you like to create visual mockups?",
470
- "multiSelect": false,
471
- "options": [
472
- { "label": "Use Stitch", "description": "Generate screens via Google Stitch AI — higher fidelity, exportable design.md" },
473
- { "label": "Use HTML mockup", "description": "Generate HTML file + Playwright screenshots — current default workflow" }
474
- ]
475
- }]
476
- }
477
- ```
478
-
479
- **If "Use Stitch" selected:**
480
-
481
- 1. **Create or select project:**
482
- ```
483
- stitch__create_project({ name: "{feature-name}-design" })
484
- ```
485
- Or if project already exists (from Case E in Step 0.5.3), reuse it.
486
-
487
- 2. **Generate screens from design brief:**
488
- Build a prompt from the aesthetic direction (Step 1.5), selected trends (Step 1.3), and user input (Step 2):
489
- ```
490
- stitch__generate_screen_from_text({
491
- projectId: projectId,
492
- prompt: "Create a {detectedDomain} screen with {aestheticDirection} direction. Colors: {primaryColor}, {accentColor}. Font: {fontPair}. Layout: {layoutDescription}. Features: {componentList}"
493
- })
494
- ```
495
-
496
- 3. **Fetch screen images for review:**
497
- ```
498
- stitch__list_screens({ projectId: projectId })
499
- stitch__fetch_screen_image({ screenId: screenId })
500
- ```
501
- Save images to `.morph/features/$ARGUMENTS/1-ui/stitch-screen-*.png`
502
-
503
- 4. **Present to user for feedback** (same approval loop as 3.5.3):
504
- - Show Stitch-generated screen images
505
- - Ask: "Does this visual direction match your intent?"
506
- - Iterate: regenerate via `generate_screen_from_text` with refined prompts
507
-
508
- 5. **Export design tokens:**
509
- ```
510
- stitch__fetch_screen_code({ screenId: approvedScreenId })
511
- ```
512
- Parse the design.md export and update `.morph/context/design-system.md` with any new or refined tokens.
513
-
514
- 6. **Skip to Step 4** — Stitch screens replace the HTML mockup. `mockups.md` still documents states and interactions textually.
515
-
516
- > **Key advantage:** Unlike screenshots, the Stitch MCP transmits real HTML/CSS code via `fetch_screen_code()`.
517
- > This produces dramatically higher fidelity results than screenshot-based workflows because Claude Code
518
- > receives the actual component structure, CSS properties, and design tokens — not pixel approximations.
519
- > Use `react-components` or `shadcn-ui` companion skills to convert Stitch HTML into production React components.
520
-
521
- #### 3.5.0.5 — Download Stitch HTML Exports (after screen approval)
522
-
523
- > **Purpose:** Save the actual HTML/CSS from each Stitch screen so implementation agents can reference
524
- > real structure and styles instead of relying solely on text descriptions in mockups.md.
525
- > **Skip if:** Stitch path was not chosen, or no screens were approved.
526
-
527
- 1. **Create stitch-html directory:**
528
- ```bash
529
- mkdir -p .morph/features/$ARGUMENTS/1-ui/stitch-html/
530
- ```
531
-
532
- 2. **For each approved screen**, fetch the full HTML:
533
- ```
534
- stitch__fetch_screen_code({ screenId: approvedScreenId })
535
- ```
536
- Save the returned HTML content to:
537
- `.morph/features/$ARGUMENTS/1-ui/stitch-html/{screenId}.html`
538
-
539
- > If `fetch_screen_code()` returns a structured object, extract the `.html` or `.code` field.
540
-
541
- 3. **Auto-generate CSS mapping from design-system.md:**
542
- Read `.morph/context/design-system.md` and extract all CSS custom properties (`--color-*`, `--font-*`, `--space-*`).
543
- Scan each downloaded HTML file's `<style>` block for color literals, font families, and spacing values.
544
- Produce a best-effort mapping file at `.morph/features/$ARGUMENTS/1-ui/stitch-html/stitch-css-map.json`:
545
-
546
- ```json
547
- {
548
- "mappings": [
549
- { "stitchValue": "#6366f1", "projectToken": "var(--color-primary)", "type": "color" },
550
- { "stitchValue": "Inter", "projectToken": "var(--font-body)", "type": "font" }
551
- ],
552
- "unmapped": ["#ff0000"],
553
- "source": ".morph/context/design-system.md"
554
- }
555
- ```
556
-
557
- If no `design-system.md` exists, create the file with empty mappings:
558
- ```json
559
- { "mappings": [], "unmapped": [], "source": null, "note": "No design system found — use Stitch values directly" }
560
- ```
561
-
562
- 4. **Ask user for screen-to-route mapping:**
563
- Use `AskUserQuestion` to map each screen to an app route. Present all screens in one call (up to 4 per call):
564
-
565
- ```json
566
- {
567
- "questions": [{
568
- "header": "Route Map",
569
- "question": "Which app route does screen '{screenTitle}' correspond to?",
570
- "multiSelect": false,
571
- "options": [
572
- { "label": "/{screenTitleLower}", "description": "Inferred from screen title" },
573
- { "label": "/", "description": "Home/landing page" },
574
- { "label": "Skip", "description": "This screen has no direct route" }
575
- ]
576
- }]
577
- }
578
- ```
579
-
580
- For more than 4 screens, make sequential `AskUserQuestion` calls.
581
-
582
- 5. **Create `stitch-screen-map.json`:**
583
- Save to `.morph/features/$ARGUMENTS/1-ui/stitch-screen-map.json`:
584
- ```json
585
- {
586
- "version": "1.0.0",
587
- "projectId": "{stitchProjectId}",
588
- "generatedAt": "{ISO timestamp}",
589
- "screens": [
590
- {
591
- "screenId": "{screenId}",
592
- "title": "{screenTitle}",
593
- "route": "/dashboard",
594
- "htmlFile": "stitch-html/{screenId}.html",
595
- "screenshotFile": "stitch-screen-{index}.png",
596
- "device": "desktop"
597
- }
598
- ],
599
- "cssMapFile": "stitch-html/stitch-css-map.json"
600
- }
601
- ```
602
-
603
- 6. **Update mockups.md** to reference downloaded HTML files.
604
- Add a section at the top of `mockups.md`:
605
-
606
- ```markdown
607
- ## Stitch HTML Reference
608
-
609
- This feature has Stitch HTML exports for implementation fidelity.
610
- See `stitch-screen-map.json` for the full screen-to-route mapping.
611
-
612
- | Screen | Route | HTML File |
613
- |--------|-------|-----------|
614
- | {title} | {route} | `stitch-html/{screenId}.html` |
615
- ```
616
-
617
- 7. **Mark output:**
618
- ```bash
619
- morph-spec state mark-output $ARGUMENTS stitchHtml
620
- ```
621
-
622
- ---
623
-
624
- **If "Use HTML mockup" selected:**
625
- → Proceed to 3.5.1 (existing workflow, unchanged)
626
-
627
- ---
628
-
629
- #### 3.5.1 — Generate HTML Mockup
630
-
631
- Create an HTML file that represents the main screen/layout using **real tokens from `.morph/context/design-system.md`**:
632
-
633
- **Rules for the HTML:**
634
- - `<style>` block must have `:root { }` with real values from design-system.md (not Tailwind colors)
635
- - Tailwind CDN only for layout utilities (flex, grid, padding) — NOT for colors or typography
636
- - Represents real layout hierarchy and visual weight — not ASCII
637
- - Include representative content (realistic text, placeholder images)
638
- - All colors via CSS variables: `color: var(--color-primary)` not `color: #3b82f6`
639
-
640
- **Save to:** `.morph/features/$ARGUMENTS/1-ui/mockup.html`
641
-
642
- Example structure:
643
- ```html
644
- <!DOCTYPE html>
645
- <html lang="en">
646
- <head>
647
- <meta charset="UTF-8">
648
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
649
- <title>[Feature] Mockup</title>
650
- <link rel="preconnect" href="https://fonts.googleapis.com">
651
- <!-- Load fonts from design-system.md font pair -->
652
- <script src="https://cdn.tailwindcss.com"></script>
653
- <style>
654
- /* Real tokens from .morph/context/design-system.md */
655
- :root {
656
- --color-primary: [value from design-system.md];
657
- --color-accent: [value from design-system.md];
658
- --color-surface: [value from design-system.md];
659
- --color-text-primary: [value from design-system.md];
660
- --color-text-secondary: [value from design-system.md];
661
- --font-display: [value from design-system.md];
662
- --font-body: [value from design-system.md];
663
- /* ... add all relevant tokens ... */
664
- }
665
- body {
666
- font-family: var(--font-body);
667
- background-color: var(--color-surface);
668
- color: var(--color-text-primary);
669
- }
670
- h1, h2, h3 { font-family: var(--font-display); }
671
- </style>
672
- </head>
673
- <body>
674
- <!-- Layout representing the feature's main screen -->
675
- </body>
676
- </html>
677
- ```
678
-
679
- #### 3.5.2 — Screenshot at 3 Breakpoints
680
-
681
- **Navigate to the file:**
682
- ```
683
- mcp__plugin_playwright_playwright__browser_navigate({ url: "file:///[ABSOLUTE_PATH_TO].morph/features/$ARGUMENTS/1-ui/mockup.html" })
684
- ```
685
-
686
- **Take screenshots at 3 breakpoints** (resize then screenshot for each):
687
-
688
- **Mobile (375px):**
689
- ```
690
- mcp__plugin_playwright_playwright__browser_resize({ width: 375, height: 812 })
691
- mcp__plugin_playwright_playwright__browser_take_screenshot({}) → save as .morph/features/$ARGUMENTS/1-ui/mockup-mobile.png
692
- ```
693
-
694
- **Tablet (768px):**
695
- ```
696
- mcp__plugin_playwright_playwright__browser_resize({ width: 768, height: 1024 })
697
- mcp__plugin_playwright_playwright__browser_take_screenshot({}) → save as .morph/features/$ARGUMENTS/1-ui/mockup-tablet.png
698
- ```
699
-
700
- **Desktop (1440px):**
701
- ```
702
- mcp__plugin_playwright_playwright__browser_resize({ width: 1440, height: 900 })
703
- mcp__plugin_playwright_playwright__browser_take_screenshot({}) → save as .morph/features/$ARGUMENTS/1-ui/mockup-desktop.png
704
- ```
705
-
706
- #### 3.5.3 — Present and Iterate
707
-
708
- 1. **Show all 3 screenshots to the user**
709
- 2. Ask for feedback:
710
- - "Does this visual direction match your intent?"
711
- - "Any layout, color, or typography adjustments?"
712
- 3. **Iterate:** Refine `mockup.html` → re-take screenshots → show updated previews
713
- 4. **Continue only when user approves** this visual direction
714
-
715
- > **Note:** `mockups.md` (Step 4.2) continues to exist as the reference for states and interactions.
716
- > The PNGs are the visual reference; the .md covers behavior and edge cases.
717
-
718
- ---
719
-
720
- ### Step 4: Generate Deliverables
721
-
722
- Create the following files in `.morph/features/$ARGUMENTS/`:
723
-
724
- > **Use templates:** Use `morph-spec template render` to generate files from templates in `.morph/framework/templates/docs/`. Available templates: `ui-design-system`, `ui-mockups`, `ui-components`, `ui-flows`.
725
-
726
- #### 4.1. `design-system.md`
727
-
728
- **If project-level design system exists (`.morph/context/design-system.md`):**
729
- - Reference it in specs: "Uses project design system at .morph/context/design-system.md"
730
- - Create `design-system.md` only if there are feature-specific colors/components
731
-
732
- **If it doesn't exist:**
733
- - Create complete feature-level design system with:
734
- - **Section `## Aesthetic Direction`**:
735
- direction, font pair, color philosophy, motion intent, composition approach
736
- - Color palette (primary, secondary, accent, semantic)
737
- - Typography (heading scales, body text, code)
738
- - Spacing and layout (grid, margins, paddings)
739
- - Base components (buttons, inputs, cards)
740
-
741
- **If Stitch was used (Step 3.5.0):**
742
- - Derive `design-system.md` primarily from Stitch's exported design.md
743
- - Map Stitch tokens into existing template sections (Color Tokens, Typography, Spacing, etc.)
744
- - Cross-reference with tokens from Step 0.5 — preserve manually-set tokens, let Stitch values fill gaps
745
- - Add to `## Aesthetic Direction`: "Visual direction generated via Google Stitch (project: {projectName})"
746
- - Ensure all CSS custom properties use the standard `--color-*`, `--font-*`, `--space-*` naming convention
747
-
748
- #### 4.2. `mockups.md`
749
-
750
- ASCII wireframes + descriptions:
751
- - General layout of each screen/page
752
- - Component positioning
753
- - Responsiveness (desktop, tablet, mobile)
754
- - States (loading, error, empty, success)
755
-
756
- #### 4.3. `components.md`
757
-
758
- Technical specs for UI library components:
759
- - Component to use (Button, DataTable, etc.)
760
- - Props and configurations
761
- - Events and bindings
762
- - Validations and states
763
-
764
- #### 4.4. `flows.md`
765
-
766
- Complete user flows:
767
- - User stories
768
- - Flow diagrams (text/ASCII)
769
- - Edge cases (what happens if...?)
770
- - Validations and feedback
771
-
772
- ### CHECKPOINT: Validate UI Deliverables
773
-
774
- **PAUSE - Before proceeding to accessibility:**
775
-
776
- - [ ] Aesthetic direction defined and documented in `design-system.md`?
777
- - [ ] Font pair specified (not just Inter/Roboto for display)?
778
- - [ ] Color philosophy: dominant + accent + rationale documented?
779
- - [ ] Design system defined (project-level or feature-level)?
780
- - [ ] Wireframes cover all states (loading, error, empty, success)?
781
- - [ ] Components specified with actual props from chosen UI library?
782
- - [ ] Complete user flows with edge cases?
783
- - [ ] Chosen UI library documented as ADR in `decisions.md`?
784
-
785
- **If any checkbox is NOT checked:**
786
- → Go back and complete the missing deliverable
787
-
788
- **If ALL checkboxes are checked:**
789
- → Proceed to image assets spec (Step 4.5) or accessibility validation (Step 5)
790
-
791
- ---
792
-
793
- ### Step 4.5: Generate Image Assets Spec (`assets.md`)
794
-
795
- > **Skip if:** Feature has no UI components, no mockups, no Stitch screens.
796
- > **Skip if:** No images needed (pure data/form UI with no visual assets).
797
- > **MCP:** Gemini Image MCP (optional — used for preview generation only).
798
- > **Standard:** `frontend/design-system/ai-image-generation.md`
799
-
800
- When the feature has UI components that need images (hero sections, brand panels, illustrations, empty states):
801
-
802
- 1. **Identify image requirements:**
803
- Scan these sources for image references:
804
- - `mockups.md` — look for image placeholders, illustrations, photos
805
- - `stitch-screen-map.json` (if exists) — Stitch designs reference Google-hosted images that need production replacements
806
- - `components.md` — components listing image props or visual areas
807
-
808
- 2. **Read design system context:**
809
- ```
810
- Read: .morph/context/design-system.md
811
- ```
812
- Extract: aesthetic direction, primary/accent/background colors, font pair.
813
-
814
- 3. **Ask user to confirm image requirements:**
815
-
816
- ```json
817
- {
818
- "questions": [{
819
- "header": "Image Assets",
820
- "question": "I identified these images needed for the feature. Which should we include in assets.md?",
821
- "multiSelect": true,
822
- "options": [
823
- { "label": "{image1 purpose}", "description": "{route} — {aspect ratio}" },
824
- { "label": "{image2 purpose}", "description": "{route} — {aspect ratio}" },
825
- { "label": "None needed", "description": "Skip image asset generation entirely" }
826
- ]
827
- }]
828
- }
829
- ```
830
-
831
- 4. **For each confirmed image**, ask for prompt refinement:
832
-
833
- ```json
834
- {
835
- "questions": [{
836
- "header": "IMG-001",
837
- "question": "Prompt for {purpose}: '{auto-generated prompt based on design context}'. Adjust?",
838
- "multiSelect": false,
839
- "options": [
840
- { "label": "Use as-is", "description": "The prompt looks good" },
841
- { "label": "Adjust", "description": "I want to refine the prompt (Other)" }
842
- ]
843
- }]
844
- }
845
- ```
846
-
847
- 5. **Generate `assets.md`:**
848
- Write to `.morph/features/$ARGUMENTS/1-ui/assets.md`:
849
-
850
- ```markdown
851
- # Image Assets — {feature}
852
-
853
- ## Design Context
854
- - Aesthetic: {from design-system.md}
855
- - Primary: {--color-primary value}
856
- - Background: {--color-background value}
857
- - Accent: {--color-accent value}
858
- - Font pair: {display + body fonts}
859
-
860
- ## Assets
861
-
862
- ### IMG-001: {Descriptive Name}
863
- - **Purpose:** {What this image represents in the UI}
864
- - **Route:** {App route where it appears}
865
- - **Component:** {React component name}
866
- - **Aspect Ratio:** {1:1 | 3:2 | 16:9 | etc.}
867
- - **Output Path:** `public/images/{feature}/{kebab-name}.png`
868
- - **Prompt:** "{Narrative prompt with design system colors and aesthetic direction injected}"
869
- - **Priority:** {high | medium | low}
870
- ```
871
-
872
- 6. **Optional — Generate preview images:**
873
- If Gemini Image MCP is available, offer to generate preview images for user approval:
874
-
875
- ```json
876
- {
877
- "questions": [{
878
- "header": "Previews",
879
- "question": "Gemini Image MCP is available. Want to generate preview images now for approval?",
880
- "multiSelect": false,
881
- "options": [
882
- { "label": "Yes, generate previews", "description": "Generate images now for visual approval before implement phase" },
883
- { "label": "Skip previews", "description": "Generate during implement phase instead" }
884
- ]
885
- }]
886
- }
887
- ```
888
-
889
- If yes: invoke `/morph-gemini-image` for each asset, save previews to `1-ui/asset-previews/`, show to user for feedback. Iterate prompts if needed.
890
-
891
- ---
892
-
893
- ### Step 5: Validate Accessibility and Responsiveness
894
-
895
- Document in UI files:
896
- - **WCAG 2.1 Level AA** compliance
897
- - Adequate color contrast
898
- - Accessible labels for screen readers
899
- - Keyboard navigation
900
- - **Responsive breakpoints**
901
- - Desktop (>1200px)
902
- - Tablet (768px - 1199px)
903
- - Mobile (<768px)
904
-
905
- ### Step 6: Update State
906
-
907
- ```bash
908
- morph-spec state mark-output $ARGUMENTS ui-design-system
909
- morph-spec state mark-output $ARGUMENTS ui-mockups
910
- morph-spec state mark-output $ARGUMENTS ui-components
911
- morph-spec state mark-output $ARGUMENTS ui-flows
912
- # Only if Stitch path was used (stitch-screen-map.json exists):
913
- morph-spec state mark-output $ARGUMENTS stitchHtml
914
- ```
915
-
916
- > **Format note:** The `mark-output` commands accept BOTH kebab-case (`ui-design-system`)
917
- > AND camelCase (`uiDesignSystem`). Both formats work equally! Use whichever is more
918
- > comfortable for you. Examples:
919
- > - `morph-spec state mark-output my-feature uiDesignSystem`
920
- > - `morph-spec state mark-output my-feature ui-design-system`
921
-
922
- ## Generated Outputs
923
-
924
- - `.morph/features/$ARGUMENTS/1-ui/design-system.md`
925
- - `.morph/features/$ARGUMENTS/1-ui/mockups.md`
926
- - `.morph/features/$ARGUMENTS/1-ui/components.md`
927
- - `.morph/features/$ARGUMENTS/1-ui/flows.md`
928
- - `.morph/features/$ARGUMENTS/2-design/decisions.md` (updated with UI library ADR)
929
-
930
- ### Step 7: Validate Design with Frontend Review
931
-
932
- After generating all 4 UI outputs and updating state (Step 6):
933
-
934
- ```bash
935
- /frontend-review $ARGUMENTS
936
- ```
937
-
938
- The skill validates: WCAG token contrast, existence of all outputs, static design accessibility, and generates mockup screenshots if dev server is available.
939
-
940
- **If frontend-review blocks**, fix issues before presenting to user.
941
-
942
- ---
943
-
944
- ## MANDATORY PAUSE
945
-
946
- Use `AskUserQuestion` to capture explicit approval before advancing:
947
-
948
- ```json
949
- {
950
- "questions": [{
951
- "header": "Approval",
952
- "question": "UI/UX generated. Approve to advance to technical design?",
953
- "multiSelect": false,
954
- "options": [
955
- { "label": "Approve UI/UX", "description": "Advance to technical design phase" },
956
- { "label": "I have feedback", "description": "Type what you want to adjust in the field below (Other)" }
957
- ]
958
- }]
959
- }
960
- ```
961
-
962
- - **"Approve UI/UX"** →
963
- ```bash
964
- morph-spec approve $ARGUMENTS uiux
965
- morph-spec phase advance $ARGUMENTS
966
- ```
967
- - **"I have feedback" or "Other"** → apply the received feedback and repeat this PAUSE
968
-
969
- ## Advancement Criteria
970
-
971
- - [x] User input collected (layout, references)
972
- - [x] UI library chosen and justified (ADR)
973
- - [x] 4 deliverables created (design-system, mockups, components, flows)
974
- - [x] WCAG 2.1 accessibility documented
975
- - [x] Responsiveness specified
976
- - [x] State updated
977
- - [x] User approved UI/UX
978
-
979
- ---
980
-
981
- ## Phase Outputs
982
-
983
- <!-- morph-outputs:uiux -->
984
- | Output | Caminho |
985
- |--------|---------|
986
- | `uiDesignSystem` | `.morph/features/{feature}/1-ui/design-system.md` |
987
- | `uiMockups` | `.morph/features/{feature}/1-ui/mockups.md` |
988
- | `uiComponents` | `.morph/features/{feature}/1-ui/components.md` |
989
- | `uiFlows` | `.morph/features/{feature}/1-ui/flows.md` |
990
- | `stitchHtml` | `.morph/features/{feature}/1-ui/stitch-screen-map.json` |
991
- <!-- /morph-outputs -->
992
-
993
- ---
994
-
995
- Continue automatically to Phase 3 (Design) after approval.