@polymorphism-tech/morph-spec 4.21.0 → 4.22.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.
- package/README.md +2 -2
- package/claude-plugin.json +1 -1
- package/docs/CHEATSHEET.md +1 -1
- package/docs/QUICKSTART.md +1 -1
- package/framework/agents.json +15 -0
- package/framework/hooks/shared/phase-utils.js +3 -0
- package/framework/phases.json +1 -1
- package/framework/skills/level-0-meta/mcp-registry.json +35 -2
- package/framework/skills/level-0-meta/morph-frontend-review/SKILL.md +1 -1
- package/framework/skills/level-0-meta/morph-gemini-image/SKILL.md +290 -0
- package/framework/skills/level-0-meta/morph-post-implementation/SKILL.md +19 -0
- package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +10 -10
- package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +146 -5
- package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +8 -0
- package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
- package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +216 -9
- package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
- package/framework/standards/STANDARDS.json +32 -0
- package/framework/standards/frontend/design-system/ai-image-generation.md +244 -0
- package/framework/standards/integration/mcp/mcp-tools.md +48 -0
- package/package.json +1 -1
- package/src/core/paths/output-schema.js +1 -0
- package/src/lib/agents/output-collector.js +1 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# AI Image Generation
|
|
2
|
+
|
|
3
|
+
> **Scope:** nextjs
|
|
4
|
+
> **Layer:** 1 (load when relevant)
|
|
5
|
+
> **Keywords:** image, gemini, asset, ai-generation, placeholder, mcp, next/image
|
|
6
|
+
> **Load When:** feature has UI components requiring image assets
|
|
7
|
+
|
|
8
|
+
## When to Use AI-Generated Images
|
|
9
|
+
|
|
10
|
+
| Use Case | Approach | Examples |
|
|
11
|
+
|----------|----------|---------|
|
|
12
|
+
| **AI generation** | Gemini Image MCP | Hero images, brand illustrations, feature-specific visuals, empty states, background panels |
|
|
13
|
+
| **Stock photos** | External sources | Generic content (people in offices, nature scenes, stock portraits) |
|
|
14
|
+
| **SVG/CSS** | Code-based | Icons, patterns, gradients, geometric shapes, loading animations |
|
|
15
|
+
| **Skip** | Other tools | Screenshots (Playwright), diagrams (Mermaid), logos (vector tools) |
|
|
16
|
+
|
|
17
|
+
**Decision rule:** If the image is unique to the project's brand/aesthetic and doesn't exist as stock, use AI generation. If it's generic and widely available, use stock. If it's geometric or icon-based, use SVG/CSS.
|
|
18
|
+
|
|
19
|
+
## Gemini Image MCP API
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// Generate a new image
|
|
23
|
+
mcp__gemini_image_mcp__generate_image({
|
|
24
|
+
prompt: string, // Text description (max 5000 chars, narrative style)
|
|
25
|
+
aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "9:16" | "16:9",
|
|
26
|
+
outputPath?: string, // File path to save (e.g., "public/images/feature/hero.png")
|
|
27
|
+
model?: string, // Default: gemini-2.5-flash-image
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// Edit an existing image
|
|
31
|
+
mcp__gemini_image_mcp__edit_image({
|
|
32
|
+
imageSource: string, // Path to image or image ID
|
|
33
|
+
prompt: string, // Short, targeted edit instructions (1-2 sentences)
|
|
34
|
+
outputPath?: string,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
// Continue editing last image
|
|
38
|
+
mcp__gemini_image_mcp__continue_editing({
|
|
39
|
+
prompt: string, // One adjustment at a time
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// List generated images
|
|
43
|
+
mcp__gemini_image_mcp__list_images({
|
|
44
|
+
type?: "generated" | "edited" | "all",
|
|
45
|
+
limit?: number,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Get image details
|
|
49
|
+
mcp__gemini_image_mcp__get_image_info({
|
|
50
|
+
imageId?: string, // Defaults to last image
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Prompt Engineering Patterns
|
|
55
|
+
|
|
56
|
+
### Design-System-Aware Prompts
|
|
57
|
+
|
|
58
|
+
Read `design-system.md` or `globals.css` to extract project tokens. Inject into prompts:
|
|
59
|
+
|
|
60
|
+
- **Background color** → use as image background
|
|
61
|
+
- **Primary/accent colors** → use as highlight colors
|
|
62
|
+
- **Font pair** → mention for text elements
|
|
63
|
+
- **Aesthetic direction** → "Modern Luxury", "Kinetic Atelier", etc.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
"{subject description}. Dark charcoal background (#10131a) with copper (#D2802D)
|
|
67
|
+
and gold (#FFB779) accent colors. {style modifiers}. Premium luxury aesthetic.
|
|
68
|
+
{composition rules}."
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Component-Contextual Prompts
|
|
72
|
+
|
|
73
|
+
Describe what the image will BE in the UI, not just the subject:
|
|
74
|
+
|
|
75
|
+
- **Hero image** → "floating tablet showing app dashboard on dark background" (not just "fitness dashboard")
|
|
76
|
+
- **Auth background** → "gym equipment with moody lighting" (matches brand feel)
|
|
77
|
+
- **Empty state** → "artistic wireframe body silhouette" (matches feature context)
|
|
78
|
+
|
|
79
|
+
### Narrative Style
|
|
80
|
+
|
|
81
|
+
Gemini responds best to coherent paragraphs. Build prompts by layering:
|
|
82
|
+
|
|
83
|
+
1. **Subject** — hyper-specific description
|
|
84
|
+
2. **Environment** — foreground, mid-ground, background (layered for depth)
|
|
85
|
+
3. **Lighting** — multiple sources with different colors/directions
|
|
86
|
+
4. **Style** — photography terms ("85mm portrait lens") or art style ("cel-shaded")
|
|
87
|
+
5. **Color palette** — dominant colors and contrast relationships
|
|
88
|
+
6. **Composition** — camera angle, framing, negative space
|
|
89
|
+
|
|
90
|
+
**Never:** keyword spam ("beautiful, stunning, 4k, masterpiece"), JSON prompts, negative prompts ("no cars").
|
|
91
|
+
|
|
92
|
+
## Iterative Editing Workflows
|
|
93
|
+
|
|
94
|
+
**Cardinal rule: generation demands depth; editing demands restraint.**
|
|
95
|
+
|
|
96
|
+
### Adding / Removing Elements
|
|
97
|
+
One sentence. Don't describe how to integrate — the model handles that.
|
|
98
|
+
```
|
|
99
|
+
"Add a knitted wizard hat to the cat."
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Background Replacement
|
|
103
|
+
State the new background simply. Don't over-describe.
|
|
104
|
+
```
|
|
105
|
+
"Replace the background with a tropical beach at sunset."
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Inpainting (Targeted Changes)
|
|
109
|
+
Name what changes and what stays in one line.
|
|
110
|
+
```
|
|
111
|
+
"Change the blue sofa to a brown leather chesterfield. Keep everything else."
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Style Transfer
|
|
115
|
+
Name the target style.
|
|
116
|
+
```
|
|
117
|
+
"Transform this into Van Gogh's Starry Night style."
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Iterative Refinement with `continue_editing`
|
|
121
|
+
One change at a time:
|
|
122
|
+
- "Make the lighting warmer"
|
|
123
|
+
- "More contrast in the shadows"
|
|
124
|
+
- "Zoom out a bit"
|
|
125
|
+
- "More serious expression"
|
|
126
|
+
|
|
127
|
+
### Text Rendering
|
|
128
|
+
The model frequently misspells words. After generating any image with text:
|
|
129
|
+
1. View the result
|
|
130
|
+
2. If text is wrong: `continue_editing` with "Fix the text — it should read '{correct text}' exactly. Keep everything else."
|
|
131
|
+
3. Expect 2-3 iterations for correct text
|
|
132
|
+
|
|
133
|
+
## Aspect Ratio Guide
|
|
134
|
+
|
|
135
|
+
| Use Case | Ratio | Examples |
|
|
136
|
+
|----------|-------|---------|
|
|
137
|
+
| Hero / banner | `16:9` | Landing page hero, YouTube thumbnail, desktop wallpaper |
|
|
138
|
+
| Card / blog header | `3:2` | Feature cards, blog post headers, landscape photo |
|
|
139
|
+
| Avatar / icon | `1:1` | Profile pictures, social media posts, square icons |
|
|
140
|
+
| Auth panel / sidebar | `3:4` | Login brand image, Pinterest-style, portrait poster |
|
|
141
|
+
| Portrait | `2:3` | Book cover, tall illustration, portrait photo |
|
|
142
|
+
| Story / reel | `9:16` | Mobile wallpaper, social story, vertical banner |
|
|
143
|
+
| Standard display | `4:3` | Documentation, slides, standard display |
|
|
144
|
+
|
|
145
|
+
## File Naming & Directory
|
|
146
|
+
|
|
147
|
+
**Convention:** `public/images/{feature}/{purpose}.png`
|
|
148
|
+
|
|
149
|
+
- Lowercase, kebab-case, descriptive names
|
|
150
|
+
- Group by feature, not by type
|
|
151
|
+
- Examples:
|
|
152
|
+
- `public/images/ui-redesign/hero-mockup.png`
|
|
153
|
+
- `public/images/ui-redesign/gym-equipment.png`
|
|
154
|
+
- `public/images/ui-redesign/body-analysis.png`
|
|
155
|
+
|
|
156
|
+
## Next.js Image Integration
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import Image from 'next/image';
|
|
160
|
+
|
|
161
|
+
// Above-the-fold hero image (priority for LCP)
|
|
162
|
+
<Image
|
|
163
|
+
src="/images/{feature}/hero-mockup.png"
|
|
164
|
+
alt="AI fitness analysis dashboard"
|
|
165
|
+
width={1440}
|
|
166
|
+
height={810}
|
|
167
|
+
priority
|
|
168
|
+
sizes="100vw"
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
// Card image with responsive sizing
|
|
172
|
+
<Image
|
|
173
|
+
src="/images/{feature}/card-image.png"
|
|
174
|
+
alt="Feature card illustration"
|
|
175
|
+
width={600}
|
|
176
|
+
height={400}
|
|
177
|
+
sizes="(max-width: 768px) 100vw, 50vw"
|
|
178
|
+
className="rounded-lg"
|
|
179
|
+
/>
|
|
180
|
+
|
|
181
|
+
// Background image with fill
|
|
182
|
+
<div className="relative h-full">
|
|
183
|
+
<Image
|
|
184
|
+
src="/images/{feature}/auth-background.png"
|
|
185
|
+
alt=""
|
|
186
|
+
fill
|
|
187
|
+
className="object-cover"
|
|
188
|
+
priority={false}
|
|
189
|
+
/>
|
|
190
|
+
</div>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## `assets.md` Format
|
|
194
|
+
|
|
195
|
+
The `assets.md` file is created during the UI/UX phase (Step 4.5) and consumed by the implement phase.
|
|
196
|
+
|
|
197
|
+
```markdown
|
|
198
|
+
# Image Assets — {feature}
|
|
199
|
+
|
|
200
|
+
## Design Context
|
|
201
|
+
- Aesthetic: {from design-system.md}
|
|
202
|
+
- Primary: {--color-primary value}
|
|
203
|
+
- Background: {--color-background value}
|
|
204
|
+
- Accent: {--color-accent value}
|
|
205
|
+
- Font pair: {display + body fonts}
|
|
206
|
+
|
|
207
|
+
## Assets
|
|
208
|
+
|
|
209
|
+
### IMG-001: {Descriptive Name}
|
|
210
|
+
- **Purpose:** {What this image represents in the UI}
|
|
211
|
+
- **Route:** {App route where it appears}
|
|
212
|
+
- **Component:** {React component name}
|
|
213
|
+
- **Aspect Ratio:** {1:1 | 3:2 | 16:9 | etc.}
|
|
214
|
+
- **Output Path:** `public/images/{feature}/{kebab-name}.png`
|
|
215
|
+
- **Prompt:** "{Narrative prompt with design system colors and aesthetic direction injected}"
|
|
216
|
+
- **Priority:** {high | medium | low}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Example entry:**
|
|
220
|
+
|
|
221
|
+
```markdown
|
|
222
|
+
### IMG-001: Hero Mockup
|
|
223
|
+
- **Purpose:** App dashboard floating on dark background for landing page hero
|
|
224
|
+
- **Route:** /
|
|
225
|
+
- **Component:** HeroSection
|
|
226
|
+
- **Aspect Ratio:** 16:9
|
|
227
|
+
- **Output Path:** `public/images/ui-redesign/hero-mockup.png`
|
|
228
|
+
- **Prompt:** "A floating tablet showing a modern AI fitness analysis dashboard on a dark charcoal background (#10131a). Copper (#D2802D) and gold (#FFB779) accent lighting creates warm rim highlights around the device edges. The screen displays body metrics with glassmorphism cards. Premium luxury aesthetic, photorealistic, cinematic lighting with a key light from the left and cool blue fill from the right."
|
|
229
|
+
- **Priority:** high
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Quality Checklist
|
|
233
|
+
|
|
234
|
+
- [ ] Colors match design system tokens (no random colors in prompts)
|
|
235
|
+
- [ ] No text artifacts or misspellings (if text in image)
|
|
236
|
+
- [ ] Correct aspect ratio for intended use
|
|
237
|
+
- [ ] Appropriate file size (< 500KB for web, < 200KB for cards)
|
|
238
|
+
- [ ] Descriptive alt text written for accessibility
|
|
239
|
+
- [ ] `<Image>` component with proper width/height dimensions
|
|
240
|
+
- [ ] `priority` prop set for above-the-fold images
|
|
241
|
+
- [ ] Build compiles after integration (`npm run build`)
|
|
242
|
+
- [ ] Image visible in dev server at correct route
|
|
243
|
+
|
|
244
|
+
*MORPH-SPEC by Polymorphism Tech*
|
|
@@ -81,6 +81,53 @@ const docs = await mcp__context7__query_docs({
|
|
|
81
81
|
// WebFetch for specific component API pages
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
### Gemini Image MCP — AI Image Generation
|
|
85
|
+
|
|
86
|
+
> Available in: **UI/UX** (preview generation), **Implement** (production assets)
|
|
87
|
+
|
|
88
|
+
| Tool | Use Case | Example |
|
|
89
|
+
|------|----------|---------|
|
|
90
|
+
| `generate_image` | Create new image from text prompt | `mcp__gemini-image-mcp__generate_image({ prompt, aspectRatio, outputPath })` |
|
|
91
|
+
| `edit_image` | Modify existing image | `mcp__gemini-image-mcp__edit_image({ imageSource, prompt })` |
|
|
92
|
+
| `continue_editing` | Iterate on last generated/edited image | `mcp__gemini-image-mcp__continue_editing({ prompt })` |
|
|
93
|
+
| `list_images` | Browse image generation history | `mcp__gemini-image-mcp__list_images({ type: "all" })` |
|
|
94
|
+
| `get_image_info` | Get metadata about a specific image | `mcp__gemini-image-mcp__get_image_info({ imageId })` |
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
// Generate a hero image using design system tokens
|
|
98
|
+
// Read design-system.md first to get project colors and aesthetic direction
|
|
99
|
+
const image = await mcp__gemini_image_mcp__generate_image({
|
|
100
|
+
prompt: "A floating tablet showing a modern dashboard interface on a dark charcoal background with copper and gold accent lighting. Premium luxury aesthetic, photorealistic, cinematic lighting with warm rim light.",
|
|
101
|
+
aspectRatio: "16:9",
|
|
102
|
+
outputPath: "public/images/my-feature/hero-mockup.png"
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// Edit an existing image (keep edits short and targeted)
|
|
106
|
+
await mcp__gemini_image_mcp__edit_image({
|
|
107
|
+
imageSource: "public/images/my-feature/hero-mockup.png",
|
|
108
|
+
prompt: "Make the lighting warmer and add a subtle copper glow around the tablet edges."
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Iterate with continue_editing (one change at a time)
|
|
112
|
+
await mcp__gemini_image_mcp__continue_editing({
|
|
113
|
+
prompt: "More contrast in the shadows."
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Fallback: Manual image creation, stock photos, or placeholder divs
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Use cases by phase:**
|
|
120
|
+
|
|
121
|
+
| Phase | Use Case | Tool |
|
|
122
|
+
|-------|----------|------|
|
|
123
|
+
| UI/UX (2) | Generate preview images for design approval | `generate_image` |
|
|
124
|
+
| Implement (7) | Generate production assets from assets.md specs | `generate_image` + `edit_image` |
|
|
125
|
+
| Implement (7) | Iterate on generated images for quality | `continue_editing` |
|
|
126
|
+
|
|
127
|
+
> **Standard:** See `frontend/design-system/ai-image-generation.md` for prompt engineering patterns, aspect ratio guide, and `assets.md` format.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
84
131
|
### Phase 3 (Design) — Schema & Architecture
|
|
85
132
|
|
|
86
133
|
| Tool | Use Case | Example |
|
|
@@ -246,6 +293,7 @@ await mcp__vercel__manage_env_vars({
|
|
|
246
293
|
| Container ops | Docker CLI (`docker ps`, `docker logs`, `docker compose`) | — |
|
|
247
294
|
| Cloud resources | Azure CLI (`az resource`, `az deployment`) | — |
|
|
248
295
|
| Vercel deployments | Vercel MCP | Bash `vercel` CLI |
|
|
296
|
+
| AI image generation | Gemini Image MCP | Manual creation or stock photos |
|
|
249
297
|
|
|
250
298
|
**Rule:** MCP tools provide structured data (JSON responses). Native tools require manual parsing. **Always prefer MCP when available** — fall back to native when not. **Exceptions:** Neon, Docker, and Azure always use their respective CLIs directly — never MCP.
|
|
251
299
|
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ export const OUTPUT_SCHEMA = {
|
|
|
35
35
|
uiMockups: { filename: 'mockups.md', phaseDir: '1-ui', phase: 'uiux', protected: true, approvalGate: 'uiux' },
|
|
36
36
|
uiComponents: { filename: 'components.md', phaseDir: '1-ui', phase: 'uiux', protected: true, approvalGate: 'uiux' },
|
|
37
37
|
uiFlows: { filename: 'flows.md', phaseDir: '1-ui', phase: 'uiux', protected: true, approvalGate: 'uiux' },
|
|
38
|
+
stitchHtml: { filename: 'stitch-screen-map.json', phaseDir: '1-ui', phase: 'uiux', protected: true, approvalGate: 'uiux' },
|
|
38
39
|
decisions: { filename: 'decisions.md', phaseDir: '2-design', phase: 'design', protected: false },
|
|
39
40
|
recap: { filename: 'recap.md', phaseDir: '5-implement', phase: 'implement', protected: false },
|
|
40
41
|
};
|