dreative 0.1.0 → 0.2.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 +35 -35
- package/dist/cli/index.js +8 -8
- package/dist/server/preview.js +73 -73
- package/dist/shared/design.js +2 -0
- package/dist/ui/index.html +11 -11
- package/package.json +44 -44
- package/skill/dreative/DESIGN.md +387 -358
- package/skill/dreative/SKILL.md +108 -108
- package/skill/dreative/skills/3d.md +134 -131
- package/skill/dreative/skills/cinematic.md +171 -0
- package/skill/dreative/skills/immersive.md +217 -0
- package/skill/dreative/skills/interaction.md +129 -126
- package/skill/dreative/skills/motion.md +137 -125
- package/dist/server/ai.js +0 -177
package/skill/dreative/SKILL.md
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dreative
|
|
3
|
-
description: Frontend design skill + optional visual round-trip editor. Use for ANY frontend design work — redesign/restyle/build pages, landing pages, animations, motion, 3D, micro-interactions, "make my UI look good" — and for visual editing when the user says "open dreative" or "let me edit the layout visually". Default is direct design: apply the design doctrine straight to the codebase. The browser editor (extract → wireframes → edit → apply diff) is an optional mode the user can ask for.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Dreative — frontend design skill (+ optional visual editor)
|
|
7
|
-
|
|
8
|
-
You (the coding agent) are the intelligence. Dreative has **two modes**:
|
|
9
|
-
|
|
10
|
-
- **Mode A — Direct design (default).** The user asks you to design, redesign, restyle, animate, or build UI. Read `DESIGN.md` (and any specialist `skills/<name>.md` the work calls for — motion, 3d, interaction), then design/edit the real code directly. No server, no extraction, no wireframes. When you finish, add one closing note: *"Tip: run `dreative start` / say 'open dreative' if you want to tweak this visually — I'll extract the pages into an editable canvas."* That's the only place the editor should come up; never force the round-trip on a plain design request.
|
|
11
|
-
- **Mode B — Visual round-trip (only when asked).** The user explicitly wants the visual editor ("open dreative", "let me edit visually"). Flow: **extract → baseline → serve requests → finish → apply**. Be token-frugal at every step: read only the files you need, never re-read the whole app, and keep JSON compact.
|
|
12
|
-
|
|
13
|
-
Everything below §0 describes Mode B; the design doctrine paragraphs apply to both modes.
|
|
14
|
-
|
|
15
|
-
**Design quality is a hard requirement.** `DESIGN.md` (same folder as this file) is the design doctrine. Read it ONCE before servicing the first `propose-skeletons`, `propose-variants`, `design-page`, or `edit-element` request, keep it in mind for all later ones, and run its pre-flight checklist (§12) before every respond. Requests may carry a `brief` object (aesthetic preset + vibe + dials set by the user in the UI); when present it is the user's explicit direction and overrides doctrine defaults. Before writing any `design-page` code, state (to yourself, one line) the register, the design read, and the signature element — if you cannot name all three, you are about to produce the generic default; stop and commit first.
|
|
16
|
-
|
|
17
|
-
**Specialist skills.** The `skills/` folder next to this file holds expert playbooks for advanced work: `motion.md` (animation & scroll choreography), `3d.md` (WebGL/three.js/shaders), `interaction.md` (micro-interactions & effect craft). When a request's `plan.skills` lists names, read each listed `skills/<name>.md` ONCE before writing code (then keep it in mind, like DESIGN.md); when `plan.sections[].skills` tags a section, that section gets that treatment (e.g. "this hero has 3d"). If the brief/prompt clearly calls for one of these but the plan missed it, read it anyway. If a listed file isn't installed, proceed on DESIGN.md alone and note it to the user (`dreative install-skill` installs all).
|
|
18
|
-
|
|
19
|
-
## 0. Setup
|
|
20
|
-
|
|
21
|
-
Requires `dreative` on PATH (`npm i -g dreative` or `npx dreative`). All commands run from the user's project root. State lives in `.dreative/` (paths in payloads are relative to `.dreative/`).
|
|
22
|
-
|
|
23
|
-
## 1. Extract (code → layout + replica)
|
|
24
|
-
|
|
25
|
-
Goal: replicate the app's current UI **view-by-view** so the user recognizes every screen. Do this **one page at a time** — find the routes/pages first (router config, pages/ dir, app/ dir), then open only each page's component files. **Single pass per page:** while the source is in front of you, produce all three outputs at once (layout JSON, replica file, summaries) — never revisit a file for a second output.
|
|
26
|
-
|
|
27
|
-
**One Dreative page per VIEW, not per route file.** If a route renders mutually-exclusive views — tab panels, admin vs viewer modes, auth states, wizard steps, a modal that fills the screen — each view becomes its own Dreative page. A page's layout must show exactly what the user sees at one moment; never stack multiple tab panels' content into one layout. Name split views `"<Screen> — <View>"` (e.g. "Admin Studio — Library", "Admin Studio — Ranking Board"), give them the same `source`, the same `group` (e.g. `"group": "Admin Studio"`), and cluster them on the canvas. Shared chrome (header, tab bar) repeats in each view's layout, with the active tab noted in its `text`.
|
|
28
|
-
|
|
29
|
-
**Expose hidden UI.** UI that exists but isn't visible by default must still surface, or the user gets a wrong picture of their app:
|
|
30
|
-
- *Full-screen or view-sized* hidden UI (modals, dialogs, drawers, overlay panels with real content) → its own Dreative page, grouped with its parent screen (e.g. "Library — Edit Show modal").
|
|
31
|
-
- *Small* hidden UI (dropdown menus, tooltips-with-actions, hover-revealed buttons, expandable rows) → model it as a block **inside its trigger's parent**, labeled for what it is (e.g. label "Sort dropdown (opens on click)"), with a `summary` saying when it appears. Don't invent open-state visuals in the replica — the replica shows the default state; the layout is where hidden things are enumerated.
|
|
32
|
-
|
|
33
|
-
**Fidelity is the whole point.** The wireframe and replica must be recognizable as *that* page at a glance. Model every visible major section in order — hero/banner, search+filter bars, stat/KPI rows, each shelf/carousel with its cards, footers. A real page with 8 visible sections must yield ~8 top-level children, not 3 generic boxes. Card grids get realistic counts (a shelf showing 7 posters → a card-grid the user reads as a row of posters, with real show titles in `text`). Before moving on, self-check: *would the user, seeing only this wireframe, name which page of their app it is?* If not, you under-extracted — fix it before the next page.
|
|
34
|
-
|
|
35
|
-
Per page, produce:
|
|
36
|
-
|
|
37
|
-
1. **Layout** — the block tree in `project.json` (schema below).
|
|
38
|
-
2. **Replica** — `.dreative/replica/<pageId>.tsx`: a stripped, non-functional **1:1 visual copy** of the real page. Single file, default export, no imports beyond react, Tailwind classes (translate other styling to Tailwind or inline styles). Strip everything behavioral: no handlers, no hooks, no data fetching; replace dynamic state/props with representative literal values (the ones a real user would see). It only needs to LOOK identical, not work. Every block id from the layout appears as `data-dreative-id="<id>"` on the matching element. Set `replicaFile` on the page.
|
|
39
|
-
3. **Summaries** — on each meaningful block, `summary`: one plain line of what it shows or does ("Submits the signup form and redirects to /dashboard", "Lists the 6 most recent orders from the API"). These render as hover tooltips in the replica so the user understands behavior without you re-reading code later, and they are your own re-entry notes at apply time. Keep each under ~120 chars.
|
|
40
|
-
|
|
41
|
-
Write `.dreative/project.json`:
|
|
42
|
-
|
|
43
|
-
```json
|
|
44
|
-
{ "version": 1, "brief": { "aesthetic": "minimal", "vibe": "", "audience": "", "variance": 7, "motion": 5, "density": 4, "notes": "" }, "pages": [ {
|
|
45
|
-
"id": "pg_home", "name": "Home", "canvasPos": {"x": 40, "y": 40},
|
|
46
|
-
"theme": { "bg": "#0d0d0f", "fg": "#e8e8ea", "accent": "#f59e0b" },
|
|
47
|
-
"status": "skeleton", "source": "src/pages/Home.tsx",
|
|
48
|
-
"layout": { "id": "blk_root", "type": "section", "label": "Home", "direction": "column", "children": [ … ] }
|
|
49
|
-
} ] }
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
(page objects also take `"replicaFile": "replica/pg_home.tsx"` and `"group": "Admin Studio"` for split views of one screen)
|
|
53
|
-
|
|
54
|
-
Block: `{ id, type, label, text?, summary?, direction?, sizeHint?, source?, children? }`
|
|
55
|
-
- `type`: section | row | column | nav | hero | card-grid | list | form | footer | text | image | button
|
|
56
|
-
- `label`: short recognizable name (shown on hover/inspector).
|
|
57
|
-
- `text`: the **actual visible copy** (heading text, button caption, first ~80 chars of a paragraph) — set it on every text/button/hero leaf; it renders verbatim in the wireframe so the user recognizes the page.
|
|
58
|
-
- Page `theme` `{bg, fg, accent}`: pull the real CSS colors (page background, main text color, brand accent) so the wireframe card matches the app's look. Set it on every page.
|
|
59
|
-
- `source`: the real file that owns this block (component path). Set it on every block whose owner differs from its parent's — this is what lets you apply the diff later without re-searching.
|
|
60
|
-
- Keep depth sensible (3–5 levels); every meaningful visible element should exist, but don't model every span.
|
|
61
|
-
- Ids must be unique and stable; prefix `pg_`/`blk_` plus a slug.
|
|
62
|
-
- Space pages on the canvas: x += 480 per page.
|
|
63
|
-
- Top-level `brief` is optional at extraction time (the user edits it in the UI); if the app has an obvious existing aesthetic, seed it so redesigns preserve the brand.
|
|
64
|
-
|
|
65
|
-
Then snapshot the baseline: `dreative baseline` (start the server first, step 2, if not running).
|
|
66
|
-
|
|
67
|
-
## 2. Launch
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
dreative start # serves http://localhost:4820, opens browser (background this)
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Tell the user the UI is open: they can view the **Replica** tab (1:1 copy of their real page, hover shows your summaries), drag elements in **Layout**, add/remove blocks, set the **Design brief** (preset + dials), attach reference images and prompts, hit **🎨 Design all**, and click **Finish** when done.
|
|
74
|
-
|
|
75
|
-
## 3. Service requests (the wait loop)
|
|
76
|
-
|
|
77
|
-
Repeat until finish:
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
dreative wait # blocks up to ~8 min; prints ONE event as JSON
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
- `{"kind":"none"}` → just run `dreative wait` again.
|
|
84
|
-
- `{"kind":"request","id","type","payload"}` → handle per table below, then
|
|
85
|
-
`dreative respond <id> <resultFile>` (write the result JSON to a temp file) or `dreative respond <id> --error "why"`.
|
|
86
|
-
- `{"kind":"finish","diff":…}` → go to step 4.
|
|
87
|
-
|
|
88
|
-
| type | payload | result to respond with |
|
|
89
|
-
|---|---|---|
|
|
90
|
-
| `propose-skeletons` | `{prompt, brief?}` | Array of 1–3 `{name, layout}` page proposals (block schema above), structured per DESIGN.md layout rules |
|
|
91
|
-
| `propose-variants` | `{pageName, layout, brief?}` | Array of 1–3 `{name, layout}` variants |
|
|
92
|
-
| `edit-block` | `{block, instruction}` | The updated block JSON (same id) |
|
|
93
|
-
| `design-page` | `{pageName, layout, brief?, plan?, refImage?, blockRefs, designPrompt?, previousFile?, siblingPages, outFile}` | Write a single-file React+Tailwind component (default export, no imports beyond react) to `.dreative/<outFile>`; every block id in layout must appear as `data-dreative-id="<id>"`. **`plan` is Dreative's pre-computed design decision — execute it, don't re-decide:** it carries resolved dials, a layout family per section (`plan.sections`, sections may carry `skills` tags like `["3d"]`), spacing/motion budgets (`plan.directives`), doctrine violations to fix (`plan.lints`), and required specialist skills (`plan.skills` → read `skills/<name>.md` first). DESIGN.md still governs everything the plan doesn't specify. Read `refImage`/`blockRefs[].refImage` (paths under `.dreative/`) with your image tools; if `previousFile` set, read it and preserve prior element edits. Respond `{"ok":true}` |
|
|
94
|
-
| `edit-element` | `{file, elementId, instruction, refImage?}` | Edit `.dreative/<file>` in place, only the element with `data-dreative-id=elementId`, keeping DESIGN.md rules intact. Respond `{"ok":true}` |
|
|
95
|
-
|
|
96
|
-
A "Design all pages" click in the UI arrives as one `design-page` request per page, back to back: keep visual consistency across them (same accent, type scale, radius system — the first page you design sets the system for the rest).
|
|
97
|
-
|
|
98
|
-
Token rules: only read ref images when a request names them; never dump whole files into responses; for edits, edit files directly instead of returning code.
|
|
99
|
-
|
|
100
|
-
## 4. Apply (finish)
|
|
101
|
-
|
|
102
|
-
The finish event's `diff` (also saved at `.dreative/finish.json`) contains only what changed vs the baseline:
|
|
103
|
-
|
|
104
|
-
- `pagesAdded` — full layouts; create real pages/components for them.
|
|
105
|
-
- `pagesRemoved` — confirm with the user before deleting real code.
|
|
106
|
-
- `pagesChanged` — per page: `blocksMoved` (reorder in the source), `blocksAdded`, `blocksRemoved`, `blocksChanged` (only differing props listed; `refImage` = style reference to match, `intents` = behavior notes), plus page-level `refImage`/`designPrompt`.
|
|
107
|
-
|
|
108
|
-
Use each block's/page's `source` pointer to open **only the owning files**, and each block's `summary` to recall what an element does **without re-reading unrelated code**. Read annotated ref images now (paths relative to `.dreative/`). Make the real code match the final layout and annotations, run the project's checks, and summarize what you changed.
|
|
1
|
+
---
|
|
2
|
+
name: dreative
|
|
3
|
+
description: Frontend design skill + optional visual round-trip editor. Use for ANY frontend design work — redesign/restyle/build pages, landing pages, animations, motion, 3D, micro-interactions, "make my UI look good" — and for visual editing when the user says "open dreative" or "let me edit the layout visually". Default is direct design: apply the design doctrine straight to the codebase. The browser editor (extract → wireframes → edit → apply diff) is an optional mode the user can ask for.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dreative — frontend design skill (+ optional visual editor)
|
|
7
|
+
|
|
8
|
+
You (the coding agent) are the intelligence. Dreative has **two modes**:
|
|
9
|
+
|
|
10
|
+
- **Mode A — Direct design (default).** The user asks you to design, redesign, restyle, animate, or build UI. Read `DESIGN.md` (and any specialist `skills/<name>.md` the work calls for — motion, 3d, interaction), then design/edit the real code directly. No server, no extraction, no wireframes. When you finish, add one closing note: *"Tip: run `dreative start` / say 'open dreative' if you want to tweak this visually — I'll extract the pages into an editable canvas."* That's the only place the editor should come up; never force the round-trip on a plain design request. **Depth first:** when the request implies more than a fresh coat of paint ("redesign", "change it entirely", "make it like <reference site>"), present DESIGN.md §11's transformation-depth ladder (restyle → re-layout → restructure → reimagine) as explicit options and let the user pick BEFORE designing; a confirmed restructure/reimagine means rebuilding markup, component trees, and routing for real — never just editing stylesheets on the old skeleton.
|
|
11
|
+
- **Mode B — Visual round-trip (only when asked).** The user explicitly wants the visual editor ("open dreative", "let me edit visually"). Flow: **extract → baseline → serve requests → finish → apply**. Be token-frugal at every step: read only the files you need, never re-read the whole app, and keep JSON compact.
|
|
12
|
+
|
|
13
|
+
Everything below §0 describes Mode B; the design doctrine paragraphs apply to both modes.
|
|
14
|
+
|
|
15
|
+
**Design quality is a hard requirement.** `DESIGN.md` (same folder as this file) is the design doctrine. Read it ONCE before servicing the first `propose-skeletons`, `propose-variants`, `design-page`, or `edit-element` request, keep it in mind for all later ones, and run its pre-flight checklist (§12) before every respond. Requests may carry a `brief` object (aesthetic preset + vibe + dials set by the user in the UI); when present it is the user's explicit direction and overrides doctrine defaults. Before writing any `design-page` code, state (to yourself, one line) the register, the design read, and the signature element — if you cannot name all three, you are about to produce the generic default; stop and commit first.
|
|
16
|
+
|
|
17
|
+
**Specialist skills.** The `skills/` folder next to this file holds expert playbooks for advanced work: `motion.md` (animation & scroll choreography), `3d.md` (WebGL/three.js/shaders), `interaction.md` (micro-interactions & effect craft), `immersive.md` (award-site worlds, spatial page transitions, scroll-as-journey), `cinematic.md` (dark shader-graded experiential interfaces: fluid/particle surfaces, drag-to-explore, click & hold, sound design — opt-in aesthetic). All are universal: they apply directly to any codebase in Mode A; the editor is never required. When a request's `plan.skills` lists names, read each listed `skills/<name>.md` ONCE before writing code (then keep it in mind, like DESIGN.md); when `plan.sections[].skills` tags a section, that section gets that treatment (e.g. "this hero has 3d"). If the brief/prompt clearly calls for one of these but the plan missed it, read it anyway. If a listed file isn't installed, proceed on DESIGN.md alone and note it to the user (`dreative install-skill` installs all).
|
|
18
|
+
|
|
19
|
+
## 0. Setup
|
|
20
|
+
|
|
21
|
+
Requires `dreative` on PATH (`npm i -g dreative` or `npx dreative`). All commands run from the user's project root. State lives in `.dreative/` (paths in payloads are relative to `.dreative/`).
|
|
22
|
+
|
|
23
|
+
## 1. Extract (code → layout + replica)
|
|
24
|
+
|
|
25
|
+
Goal: replicate the app's current UI **view-by-view** so the user recognizes every screen. Do this **one page at a time** — find the routes/pages first (router config, pages/ dir, app/ dir), then open only each page's component files. **Single pass per page:** while the source is in front of you, produce all three outputs at once (layout JSON, replica file, summaries) — never revisit a file for a second output.
|
|
26
|
+
|
|
27
|
+
**One Dreative page per VIEW, not per route file.** If a route renders mutually-exclusive views — tab panels, admin vs viewer modes, auth states, wizard steps, a modal that fills the screen — each view becomes its own Dreative page. A page's layout must show exactly what the user sees at one moment; never stack multiple tab panels' content into one layout. Name split views `"<Screen> — <View>"` (e.g. "Admin Studio — Library", "Admin Studio — Ranking Board"), give them the same `source`, the same `group` (e.g. `"group": "Admin Studio"`), and cluster them on the canvas. Shared chrome (header, tab bar) repeats in each view's layout, with the active tab noted in its `text`.
|
|
28
|
+
|
|
29
|
+
**Expose hidden UI.** UI that exists but isn't visible by default must still surface, or the user gets a wrong picture of their app:
|
|
30
|
+
- *Full-screen or view-sized* hidden UI (modals, dialogs, drawers, overlay panels with real content) → its own Dreative page, grouped with its parent screen (e.g. "Library — Edit Show modal").
|
|
31
|
+
- *Small* hidden UI (dropdown menus, tooltips-with-actions, hover-revealed buttons, expandable rows) → model it as a block **inside its trigger's parent**, labeled for what it is (e.g. label "Sort dropdown (opens on click)"), with a `summary` saying when it appears. Don't invent open-state visuals in the replica — the replica shows the default state; the layout is where hidden things are enumerated.
|
|
32
|
+
|
|
33
|
+
**Fidelity is the whole point.** The wireframe and replica must be recognizable as *that* page at a glance. Model every visible major section in order — hero/banner, search+filter bars, stat/KPI rows, each shelf/carousel with its cards, footers. A real page with 8 visible sections must yield ~8 top-level children, not 3 generic boxes. Card grids get realistic counts (a shelf showing 7 posters → a card-grid the user reads as a row of posters, with real show titles in `text`). Before moving on, self-check: *would the user, seeing only this wireframe, name which page of their app it is?* If not, you under-extracted — fix it before the next page.
|
|
34
|
+
|
|
35
|
+
Per page, produce:
|
|
36
|
+
|
|
37
|
+
1. **Layout** — the block tree in `project.json` (schema below).
|
|
38
|
+
2. **Replica** — `.dreative/replica/<pageId>.tsx`: a stripped, non-functional **1:1 visual copy** of the real page. Single file, default export, no imports beyond react, Tailwind classes (translate other styling to Tailwind or inline styles). Strip everything behavioral: no handlers, no hooks, no data fetching; replace dynamic state/props with representative literal values (the ones a real user would see). It only needs to LOOK identical, not work. Every block id from the layout appears as `data-dreative-id="<id>"` on the matching element. Set `replicaFile` on the page.
|
|
39
|
+
3. **Summaries** — on each meaningful block, `summary`: one plain line of what it shows or does ("Submits the signup form and redirects to /dashboard", "Lists the 6 most recent orders from the API"). These render as hover tooltips in the replica so the user understands behavior without you re-reading code later, and they are your own re-entry notes at apply time. Keep each under ~120 chars.
|
|
40
|
+
|
|
41
|
+
Write `.dreative/project.json`:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{ "version": 1, "brief": { "aesthetic": "minimal", "vibe": "", "audience": "", "variance": 7, "motion": 5, "density": 4, "notes": "" }, "pages": [ {
|
|
45
|
+
"id": "pg_home", "name": "Home", "canvasPos": {"x": 40, "y": 40},
|
|
46
|
+
"theme": { "bg": "#0d0d0f", "fg": "#e8e8ea", "accent": "#f59e0b" },
|
|
47
|
+
"status": "skeleton", "source": "src/pages/Home.tsx",
|
|
48
|
+
"layout": { "id": "blk_root", "type": "section", "label": "Home", "direction": "column", "children": [ … ] }
|
|
49
|
+
} ] }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
(page objects also take `"replicaFile": "replica/pg_home.tsx"` and `"group": "Admin Studio"` for split views of one screen)
|
|
53
|
+
|
|
54
|
+
Block: `{ id, type, label, text?, summary?, direction?, sizeHint?, source?, children? }`
|
|
55
|
+
- `type`: section | row | column | nav | hero | card-grid | list | form | footer | text | image | button
|
|
56
|
+
- `label`: short recognizable name (shown on hover/inspector).
|
|
57
|
+
- `text`: the **actual visible copy** (heading text, button caption, first ~80 chars of a paragraph) — set it on every text/button/hero leaf; it renders verbatim in the wireframe so the user recognizes the page.
|
|
58
|
+
- Page `theme` `{bg, fg, accent}`: pull the real CSS colors (page background, main text color, brand accent) so the wireframe card matches the app's look. Set it on every page.
|
|
59
|
+
- `source`: the real file that owns this block (component path). Set it on every block whose owner differs from its parent's — this is what lets you apply the diff later without re-searching.
|
|
60
|
+
- Keep depth sensible (3–5 levels); every meaningful visible element should exist, but don't model every span.
|
|
61
|
+
- Ids must be unique and stable; prefix `pg_`/`blk_` plus a slug.
|
|
62
|
+
- Space pages on the canvas: x += 480 per page.
|
|
63
|
+
- Top-level `brief` is optional at extraction time (the user edits it in the UI); if the app has an obvious existing aesthetic, seed it so redesigns preserve the brand.
|
|
64
|
+
|
|
65
|
+
Then snapshot the baseline: `dreative baseline` (start the server first, step 2, if not running).
|
|
66
|
+
|
|
67
|
+
## 2. Launch
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
dreative start # serves http://localhost:4820, opens browser (background this)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Tell the user the UI is open: they can view the **Replica** tab (1:1 copy of their real page, hover shows your summaries), drag elements in **Layout**, add/remove blocks, set the **Design brief** (preset + dials), attach reference images and prompts, hit **🎨 Design all**, and click **Finish** when done.
|
|
74
|
+
|
|
75
|
+
## 3. Service requests (the wait loop)
|
|
76
|
+
|
|
77
|
+
Repeat until finish:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
dreative wait # blocks up to ~8 min; prints ONE event as JSON
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `{"kind":"none"}` → just run `dreative wait` again.
|
|
84
|
+
- `{"kind":"request","id","type","payload"}` → handle per table below, then
|
|
85
|
+
`dreative respond <id> <resultFile>` (write the result JSON to a temp file) or `dreative respond <id> --error "why"`.
|
|
86
|
+
- `{"kind":"finish","diff":…}` → go to step 4.
|
|
87
|
+
|
|
88
|
+
| type | payload | result to respond with |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| `propose-skeletons` | `{prompt, brief?}` | Array of 1–3 `{name, layout}` page proposals (block schema above), structured per DESIGN.md layout rules |
|
|
91
|
+
| `propose-variants` | `{pageName, layout, brief?}` | Array of 1–3 `{name, layout}` variants |
|
|
92
|
+
| `edit-block` | `{block, instruction}` | The updated block JSON (same id) |
|
|
93
|
+
| `design-page` | `{pageName, layout, brief?, plan?, refImage?, blockRefs, designPrompt?, previousFile?, siblingPages, outFile}` | Write a single-file React+Tailwind component (default export, no imports beyond react) to `.dreative/<outFile>`; every block id in layout must appear as `data-dreative-id="<id>"`. **`plan` is Dreative's pre-computed design decision — execute it, don't re-decide:** it carries resolved dials, a layout family per section (`plan.sections`, sections may carry `skills` tags like `["3d"]`), spacing/motion budgets (`plan.directives`), doctrine violations to fix (`plan.lints`), and required specialist skills (`plan.skills` → read `skills/<name>.md` first). DESIGN.md still governs everything the plan doesn't specify. Read `refImage`/`blockRefs[].refImage` (paths under `.dreative/`) with your image tools; if `previousFile` set, read it and preserve prior element edits. Respond `{"ok":true}` |
|
|
94
|
+
| `edit-element` | `{file, elementId, instruction, refImage?}` | Edit `.dreative/<file>` in place, only the element with `data-dreative-id=elementId`, keeping DESIGN.md rules intact. Respond `{"ok":true}` |
|
|
95
|
+
|
|
96
|
+
A "Design all pages" click in the UI arrives as one `design-page` request per page, back to back: keep visual consistency across them (same accent, type scale, radius system — the first page you design sets the system for the rest).
|
|
97
|
+
|
|
98
|
+
Token rules: only read ref images when a request names them; never dump whole files into responses; for edits, edit files directly instead of returning code.
|
|
99
|
+
|
|
100
|
+
## 4. Apply (finish)
|
|
101
|
+
|
|
102
|
+
The finish event's `diff` (also saved at `.dreative/finish.json`) contains only what changed vs the baseline:
|
|
103
|
+
|
|
104
|
+
- `pagesAdded` — full layouts; create real pages/components for them.
|
|
105
|
+
- `pagesRemoved` — confirm with the user before deleting real code.
|
|
106
|
+
- `pagesChanged` — per page: `blocksMoved` (reorder in the source), `blocksAdded`, `blocksRemoved`, `blocksChanged` (only differing props listed; `refImage` = style reference to match, `intents` = behavior notes), plus page-level `refImage`/`designPrompt`.
|
|
107
|
+
|
|
108
|
+
Use each block's/page's `source` pointer to open **only the owning files**, and each block's `summary` to recall what an element does **without re-reading unrelated code**. Read annotated ref images now (paths relative to `.dreative/`). Make the real code match the final layout and annotations, run the project's checks, and summarize what you changed.
|
|
@@ -1,131 +1,134 @@
|
|
|
1
|
-
# Dreative Specialist Skill — 3D, WebGL & Shaders
|
|
2
|
-
|
|
3
|
-
Load this file when `plan.skills` includes `3d`, or the brief/prompt mentions 3D,
|
|
4
|
-
WebGL, three.js, shaders, particles, globes, or point clouds. DESIGN.md still
|
|
5
|
-
governs everything around the canvas (layout, color, type, motion budgets).
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
signature
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- **
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
- **
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
- **
|
|
131
|
-
|
|
1
|
+
# Dreative Specialist Skill — 3D, WebGL & Shaders
|
|
2
|
+
|
|
3
|
+
Load this file when `plan.skills` includes `3d`, or the brief/prompt mentions 3D,
|
|
4
|
+
WebGL, three.js, shaders, particles, globes, or point clouds. DESIGN.md still
|
|
5
|
+
governs everything around the canvas (layout, color, type, motion budgets).
|
|
6
|
+
Integrating 3D usually changes component structure (canvas placement, lazy
|
|
7
|
+
boundaries, scroll wrappers) — when it does, follow DESIGN.md §11's
|
|
8
|
+
transformation-depth ladder: offer the restructure, then do it for real.
|
|
9
|
+
|
|
10
|
+
## 0. Does 3D earn its place?
|
|
11
|
+
|
|
12
|
+
3D is the most expensive pixel on the web — in bytes, battery, and attention.
|
|
13
|
+
It earns its place when the SUBJECT is spatial (a physical product, a device, a
|
|
14
|
+
map/globe, an environment, data with real dimensionality) or when the brand brief
|
|
15
|
+
explicitly buys a signature 3D moment. It does not earn its place as ambient
|
|
16
|
+
decoration: a random floating torus/blob behind hero text is the 3D equivalent of
|
|
17
|
+
the gradient blob — banned as a default reach. One 3D moment per page; make it the
|
|
18
|
+
signature element (DESIGN.md §2) or don't ship it.
|
|
19
|
+
|
|
20
|
+
Cheaper substitutes to consider first: CSS 3D transforms (`perspective` +
|
|
21
|
+
`rotateX/Y` on real DOM — free, accessible, great for cards/mockups/tilt), a
|
|
22
|
+
pre-rendered video/image sequence scrubbed on scroll, or a Lottie/Rive vector
|
|
23
|
+
animation. If the object never needs live lighting or user-driven rotation,
|
|
24
|
+
pre-render it.
|
|
25
|
+
|
|
26
|
+
## 1. Stack
|
|
27
|
+
|
|
28
|
+
- **React app → React Three Fiber (`@react-three/fiber`) + `@react-three/drei`.**
|
|
29
|
+
Never hand-roll a three.js imperative setup inside React. Drei gives you 80%:
|
|
30
|
+
`Environment`, `ContactShadows`, `Float`, `ScrollControls`, `Html`, `Text`,
|
|
31
|
+
`useGLTF`, `MeshTransmissionMaterial`, `Center`, `Bounds`.
|
|
32
|
+
- **Non-React → three.js** with a small render-loop module; or **OGL** when the
|
|
33
|
+
scene is one shader plane and three.js is overkill.
|
|
34
|
+
- Post-processing via `@react-three/postprocessing` (Bloom, DoF, Noise) — 1-2
|
|
35
|
+
effects max; the stacked-postFX look reads as demo-scene, not product.
|
|
36
|
+
- Physics only if interaction demands it (`@react-three/rapier`).
|
|
37
|
+
|
|
38
|
+
Lazy-load the entire 3D bundle (`next/dynamic` / `React.lazy`) with an SSR-off
|
|
39
|
+
canvas and a styled poster fallback. Three.js must never be in the critical path.
|
|
40
|
+
|
|
41
|
+
## 2. Scene fundamentals (where amateur scenes fail)
|
|
42
|
+
|
|
43
|
+
- **Lighting is the craft.** Default: `<Environment preset="studio"|"city">` for
|
|
44
|
+
image-based lighting + ONE key directional light for shadows. Ambient light
|
|
45
|
+
alone = flat plastic. Match light temperature to the page palette.
|
|
46
|
+
- **Color management:** renderer defaults in modern three are correct
|
|
47
|
+
(`outputColorSpace: SRGBColorSpace`, `ACESFilmicToneMapping`) — don't disable
|
|
48
|
+
them; DO set `toneMappingExposure` deliberately. Convert hex from the page
|
|
49
|
+
palette with `new THREE.Color(hex)` — scene colors and page colors must read as
|
|
50
|
+
one system.
|
|
51
|
+
- **Ground the object:** `<ContactShadows opacity={0.4} blur={2.5}>` or a real
|
|
52
|
+
shadow plane. Floating unanchored objects read as clipart.
|
|
53
|
+
- Camera: 35-50° FOV for product shots (85°+ distorts); frame with
|
|
54
|
+
`<Bounds fit clip>` or `<Center>`; subtle idle via `<Float>` or damped
|
|
55
|
+
mouse-parallax (`useFrame` + `THREE.MathUtils.damp`), amplitude ≤ 3°.
|
|
56
|
+
- Materials: `meshStandardMaterial`/`meshPhysicalMaterial` with `roughness`/
|
|
57
|
+
`metalness` chosen from the real object; `MeshTransmissionMaterial` for glass
|
|
58
|
+
(expensive — one object max). Untextured default-gray = unfinished.
|
|
59
|
+
|
|
60
|
+
## 3. Models
|
|
61
|
+
|
|
62
|
+
- glTF/GLB only, Draco or Meshopt compressed (`gltf-transform optimize in.glb
|
|
63
|
+
out.glb --compress draco`). Budget: hero model ≤ 2-3 MB, ≤ 100k triangles.
|
|
64
|
+
- `useGLTF.preload(url)`; wrap in `<Suspense>` with a poster (not a spinner).
|
|
65
|
+
- No model available? Build from primitives + good materials/lighting (a laptop
|
|
66
|
+
from rounded boxes with an `Html` screen reads better than a bad download), or
|
|
67
|
+
tell the user what asset is needed — never ship an unrelated placeholder model.
|
|
68
|
+
|
|
69
|
+
## 4. Shaders (the highest-leverage 100 lines)
|
|
70
|
+
|
|
71
|
+
A fullscreen/plane fragment shader is the cheapest way to a signature visual:
|
|
72
|
+
animated gradient meshes, flowfields, displacement on hover, image transitions.
|
|
73
|
+
|
|
74
|
+
- Structure: `shaderMaterial` (drei) with `uTime`, `uMouse`, `uResolution`,
|
|
75
|
+
palette colors as `uColorA/B/C` uniforms fed FROM the page palette.
|
|
76
|
+
- Vocabulary: fbm/simplex noise for organic movement (inline a noise fn; don't
|
|
77
|
+
import a library for it), `smoothstep` for banding-free ramps, domain warping
|
|
78
|
+
(`noise(p + noise(p))`) for the expensive look, `mix()` between palette colors
|
|
79
|
+
only — never rainbow hue-rotation.
|
|
80
|
+
- Displace vertices in the vertex shader for cloth/terrain/blob effects; compute
|
|
81
|
+
normals or fake lighting with the noise derivative.
|
|
82
|
+
- Animate `uTime` at 0.05-0.2 speed; slow reads as premium, fast as screensaver.
|
|
83
|
+
- Image effects: sample two textures + a noise mask for transitions; barrel/flow
|
|
84
|
+
distortion on scroll velocity for editorial galleries.
|
|
85
|
+
|
|
86
|
+
## 5. Particles and points
|
|
87
|
+
|
|
88
|
+
Points/instancing, never meshes-per-particle: `<Points>` + `BufferAttribute`
|
|
89
|
+
positions animated in a shader (`uTime` in the vertex shader), or
|
|
90
|
+
`<Instances>`/`InstancedMesh` for repeated geometry (≤ ~10k instances). Counts:
|
|
91
|
+
2-5k points desktop, halve on mobile. Particle color from the page palette at 1-2
|
|
92
|
+
hues; size attenuation on; additive blending only on dark surfaces.
|
|
93
|
+
|
|
94
|
+
## 6. Scroll- and layout-integration
|
|
95
|
+
|
|
96
|
+
- Canvas placement: either a bounded block IN the layout (preferred — it composes
|
|
97
|
+
with the grid) or a full-bleed fixed background with content scrolling over.
|
|
98
|
+
Full-page persistent canvases with DOM scrolled on top: use drei
|
|
99
|
+
`ScrollControls` + `<Scroll html>` so 3D and DOM share one scroll.
|
|
100
|
+
- Scroll-linked 3D: map scroll progress (Motion `useScroll` / ScrollTrigger /
|
|
101
|
+
drei `useScroll`) to camera position along a path or object rotation — damped
|
|
102
|
+
(`damp3`, `dampE`), never raw-set per frame.
|
|
103
|
+
- DOM/3D registration (labels pinned to model parts): drei `<Html transform
|
|
104
|
+
occlude>`; keep text as real DOM for accessibility, never texture-baked type.
|
|
105
|
+
- The block's `data-dreative-id` goes on the wrapper div around the Canvas.
|
|
106
|
+
|
|
107
|
+
## 7. Performance & fallbacks (ship-blockers)
|
|
108
|
+
|
|
109
|
+
- `<Canvas dpr={[1, 2]}>` (cap device pixel ratio), `frameloop="demand"` +
|
|
110
|
+
`invalidate()` for static-until-interacted scenes; pause the loop when the
|
|
111
|
+
canvas leaves the viewport (IntersectionObserver) and on `document.hidden`.
|
|
112
|
+
- One `useFrame` per concern; no allocations inside it (reuse vectors created
|
|
113
|
+
outside). Dispose on unmount (R3F handles it; imperative three must
|
|
114
|
+
`dispose()` geometries/materials/textures).
|
|
115
|
+
- Mobile: halve particle counts, drop post-processing, consider a poster image
|
|
116
|
+
below 768px — a janky 3D hero is worse than none.
|
|
117
|
+
- `prefers-reduced-motion`: stop idle rotation/particle drift; render one static
|
|
118
|
+
well-lit frame (`frameloop="demand"` makes this free).
|
|
119
|
+
- WebGL unavailable/context-lost → the poster fallback, never a blank block.
|
|
120
|
+
- Keyboard/screen-reader: canvas gets `role="img"` + `aria-label`; any 3D-driven
|
|
121
|
+
interaction has a DOM equivalent.
|
|
122
|
+
|
|
123
|
+
## 8. Recipes
|
|
124
|
+
|
|
125
|
+
- **Product hero**: GLB + `Environment` + key light + `ContactShadows`, `Float`
|
|
126
|
+
idle, damped mouse parallax, scroll scrubs a 90° orbit. Poster until loaded.
|
|
127
|
+
- **Gradient-mesh hero background**: one plane, fbm + domain-warp fragment shader
|
|
128
|
+
mixing 3 palette colors, `uTime` 0.08, `uMouse` warps locally. ~120 lines, no
|
|
129
|
+
model, no lighting — the best effort/impact ratio in this file.
|
|
130
|
+
- **Point-cloud globe**: sphere-distributed points, shader-animated shimmer,
|
|
131
|
+
arcs as `TubeGeometry`/fat lines between coords, slow idle rotation, drag to
|
|
132
|
+
spin (damped).
|
|
133
|
+
- **Scroll story**: `ScrollControls pages={4}` + camera on a `CatmullRomCurve3`
|
|
134
|
+
path, DOM copy in `<Scroll html>`, one damped lookAt target per section.
|