opencodekit 0.21.1 → 0.21.3

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 (28) hide show
  1. package/dist/index.js +4 -4
  2. package/dist/template/.opencode/.template-manifest.json +721 -0
  3. package/dist/template/.opencode/.version +1 -1
  4. package/dist/template/.opencode/AGENTS.md +39 -29
  5. package/dist/template/.opencode/agent/vision.md +0 -1
  6. package/dist/template/.opencode/memory.db +0 -0
  7. package/dist/template/.opencode/memory.db-shm +0 -0
  8. package/dist/template/.opencode/memory.db-wal +0 -0
  9. package/dist/template/.opencode/opencode.json +1311 -1134
  10. package/dist/template/.opencode/plugin/README.md +10 -6
  11. package/dist/template/.opencode/plugin/rtk.ts +43 -0
  12. package/dist/template/.opencode/pnpm-lock.yaml +140 -706
  13. package/dist/template/.opencode/skill/agent-evals/SKILL.md +208 -0
  14. package/dist/template/.opencode/skill/anti-ai-slop/SKILL.md +76 -0
  15. package/dist/template/.opencode/skill/brand-asset-protocol/SKILL.md +222 -0
  16. package/dist/template/.opencode/skill/context-condensation/SKILL.md +149 -0
  17. package/dist/template/.opencode/skill/design-direction-advisor/SKILL.md +139 -0
  18. package/dist/template/.opencode/skill/hi-fi-prototype-html/SKILL.md +253 -0
  19. package/dist/template/.opencode/skill/html-deck-export/SKILL.md +189 -0
  20. package/dist/template/.opencode/skill/rtk-command-compression/SKILL.md +134 -0
  21. package/dist/template/.opencode/skill/test-driven-development/SKILL.md +15 -0
  22. package/package.json +1 -1
  23. package/dist/template/.opencode/package.json +0 -22
  24. package/dist/template/.opencode/plugin/package.json +0 -7
  25. package/dist/template/.opencode/plugin/stitch.ts +0 -307
  26. package/dist/template/.opencode/skill/stitch/SKILL.md +0 -164
  27. package/dist/template/.opencode/skill/stitch-design-taste/DESIGN.md +0 -121
  28. package/dist/template/.opencode/skill/stitch-design-taste/SKILL.md +0 -197
@@ -0,0 +1,139 @@
1
+ ---
2
+ name: design-direction-advisor
3
+ description: Use when the user's design brief is vague ("make it look good", "design something", "I don't know what style I want", "make me a nice-looking page") OR when no brand context exists. Recommends 3 differentiated directions from 5 design schools × 20 named designer philosophies (Pentagram, Field.io, Kenya Hara, Sagmeister, etc.) with parallel visual demos so the user can choose by seeing, not imagining.
4
+ ---
5
+
6
+ # Design Direction Advisor (Fallback Mode)
7
+
8
+ > Adapted from `huashu-design`. When you don't have brand context and the user's brief is too vague to execute, **don't guess from generic intuition** — that produces AI slop. Convert ambiguity into structured choice.
9
+
10
+ ## When to Trigger
11
+
12
+ - Vague briefs: "make it look good", "design something", "make me a page", "I don't know what I want"
13
+ - User explicitly asks: "recommend a style", "give me some directions", "pick a philosophy", "show me different styles"
14
+ - No design context exists: no design system, no brand kit, no Figma, no reference site
15
+ - User says "I don't know what style I want either"
16
+
17
+ ## When to Skip
18
+
19
+ - User already provided clear references (Figma / screenshots / brand spec) → run `brand-asset-protocol` instead
20
+ - User already specified the direction ("Apple Silicon launch event style") → go directly to execution
21
+ - Small fix or specific tool call ("convert this HTML to PDF") → skip
22
+ - Uncertain → use the lightest version: list 3 directions in 2 sentences each and let the user pick. Don't generate demos prematurely.
23
+
24
+ ## The 8-Phase Flow
25
+
26
+ ### Phase 1 — Deep-Understand the Need
27
+
28
+ Ask up to **3** focused questions (skip if already clear):
29
+
30
+ - Target audience?
31
+ - Core message?
32
+ - Emotional tone?
33
+ - Output format? (web page / slide / animation / app mockup)
34
+
35
+ ### Phase 2 — Advisor-Style Restatement (~150 words)
36
+
37
+ In your own words, restate: the essential need, audience, scenario, emotional tone. End with: _"Based on this understanding, I've prepared 3 design directions for you."_
38
+
39
+ This forces alignment before generation. If the restatement is wrong, the user corrects you cheaply.
40
+
41
+ ### Phase 3 — Recommend 3 Differentiated Philosophies
42
+
43
+ Each direction must include:
44
+
45
+ - **Named designer or studio** — "Kenya Hara-style Eastern minimalism," not just "minimalism"
46
+ - 50-100 words explaining _why this designer fits your brief_
47
+ - 3-4 signature visual features
48
+ - 3-5 vibe keywords
49
+ - Optional reference work
50
+
51
+ **Differentiation rule (non-negotiable):** the 3 directions must come from **3 different schools** for clear visual contrast.
52
+
53
+ ### The 5 Schools × 20 Philosophies
54
+
55
+ | School | Vibe | Best as | Designers (pick 1 per recommendation) |
56
+ | ------------------------------------ | --------------------------------------- | ------------------------------- | ----------------------------------------------------------------- |
57
+ | **Information Architecture (01-04)** | Rational, data-driven, restrained | Safe / professional choice | Pentagram (Bierut), Stamen Design, Information Architects, Fathom |
58
+ | **Motion Poetics (05-08)** | Dynamic, immersive, technical aesthetic | Bold / cutting-edge choice | Locomotive, Active Theory, Field.io, Resn |
59
+ | **Minimalism (09-12)** | Order, whitespace, refinement | Safe / premium choice | Experimental Jetset, Müller-Brockmann, Build, Sagmeister & Walsh |
60
+ | **Experimental Avant-garde (13-16)** | Generative art, visual impact | Bold / innovative choice | Zach Lieberman, Raven Kwok, Ash Thorp, Territory Studio |
61
+ | **Eastern Philosophy (17-20)** | Warm, poetic, contemplative | Differentiation / unique choice | Takram, Kenya Hara, Irma Boom, Neo Shen |
62
+
63
+ ❌ **Forbidden**: recommending 2 or more from the same school. Insufficient differentiation = user can't tell them apart.
64
+
65
+ A good triplet typically pairs **one safe + one bold + one differentiating** choice.
66
+
67
+ ### Phase 4 — Show Reference Examples (Visual Anchor)
68
+
69
+ Before generating live demos, **show 2-3 reference images per direction** if you can fetch them (search the designer's known projects). The user calibrates "yes, that vibe" or "no, not what I meant" against real work, not your description.
70
+
71
+ Phrasing: _"Before I spin up live demos, here's how each style looks in similar scenarios →"_ then show references.
72
+
73
+ ### Phase 5 — Generate 3 Visual Demos
74
+
75
+ > **Core principle: seeing beats describing.** Don't make the user imagine — show them.
76
+
77
+ For each of the 3 directions, generate one demo using the user's **real content/topic**, not lorem ipsum.
78
+
79
+ - **If parallel subagents are supported:** dispatch 3 in parallel (file-disjoint, see AGENTS.md "Parallel Execution Rules")
80
+ - **If serial:** generate one at a time, all 3 before showing
81
+
82
+ | Style type | Demo path |
83
+ | ----------------- | ----------------------------------------------------------------- |
84
+ | HTML-friendly | Generate full HTML → screenshot via Playwright |
85
+ | AI-image-friendly | Use image generation (e.g. nano-banana-pro) with style DNA prompt |
86
+ | Hybrid | HTML layout + AI-generated illustrations slotted in |
87
+
88
+ Save HTML to `_temp/design-demos/demo-<style>.html`. Screenshot to `_temp/design-demos/demo-<style>.png`. Show all 3 screenshots together.
89
+
90
+ ```bash
91
+ # Reference command
92
+ npx playwright screenshot file:///<absolute-path>.html out.png --viewport-size=1200,900
93
+ ```
94
+
95
+ ### Phase 6 — User Chooses
96
+
97
+ Options to present:
98
+
99
+ - **Pick one** to deepen
100
+ - **Mix** ("A's palette + C's layout")
101
+ - **Tweak** specific aspects of one
102
+ - **Restart** → return to Phase 3 with refined understanding
103
+
104
+ ### Phase 7 — Generate Production Prompt (if AI image-driven)
105
+
106
+ Structure: `[design philosophy constraint] + [content description] + [technical params]`
107
+
108
+ - ✅ Use **specific features**, not style names: "Kenya Hara whitespace + terracotta orange #C04A1A," not "minimalist"
109
+ - ✅ Include HEX colors, ratios, space allocation, output spec
110
+ - ❌ Avoid AI slop list (see `anti-ai-slop` skill)
111
+
112
+ ### Phase 8 — Hand Off to Main Build
113
+
114
+ Direction confirmed → return to the main implementation flow (`hi-fi-prototype-html`, `frontend-design`, etc.). You now have **explicit design context** — no longer guessing.
115
+
116
+ ## Lightweight Variant (Time-Pressured)
117
+
118
+ When the user is in a rush:
119
+
120
+ - Skip Phase 4 references
121
+ - Skip Phase 5 demos
122
+ - Just present 3 named directions in 2 sentences each
123
+ - Let user pick by name
124
+
125
+ This trades signal-fidelity for speed but still beats "generic AI default."
126
+
127
+ ## Why This Beats "Just Make a Reasonable Default"
128
+
129
+ 1. **Generic default = AI slop** (see `anti-ai-slop`). It dilutes brand identity to the average of all training data.
130
+ 2. **Named designer references** give the user concrete vocabulary to push back ("more like Pentagram, less like Sagmeister").
131
+ 3. **3 differentiated demos** convert vague preferences into testable choices in one round, instead of N rounds of "looks ok but not quite right."
132
+ 4. **The advisor restatement (Phase 2)** catches misunderstandings before any pixel is committed — the cheapest possible correction point.
133
+
134
+ ## Pairs Well With
135
+
136
+ - `brand-asset-protocol` — runs **after** direction is locked, when brand assets must be sourced
137
+ - `anti-ai-slop` — keeps each demo from collapsing into the AI default
138
+ - `hi-fi-prototype-html` — production target after direction is chosen
139
+ - `brainstorming` — for non-visual, non-design ambiguity
@@ -0,0 +1,253 @@
1
+ ---
2
+ name: hi-fi-prototype-html
3
+ description: Use when building high-fidelity HTML prototypes, interactive product mockups, app/iOS/Android screen demos, or design-variation explorations (NOT production web apps — use frontend-design for that). Enforces Junior Designer mode (show assumptions early, iterate), single-file inline React for double-clickable mockups, real images instead of generic placeholders, and Playwright click-test before delivery.
4
+ ---
5
+
6
+ # Hi-Fi Prototype (HTML as Medium)
7
+
8
+ > Adapted from `huashu-design`. HTML is your **medium**, not your destination. You are a designer who happens to use HTML, not a developer who happens to be designing.
9
+
10
+ ## When to Use
11
+
12
+ - **Interactive prototypes** — clickable product mockups for user testing or design review
13
+ - **Design variation exploration** — 3+ side-by-side directions before committing
14
+ - **App / iOS / Android mockups** — single-page or full-flow demos
15
+ - **Concept demos** — convey an interaction or feel before any production code
16
+ - **Information graphics** with hand-tuned typography
17
+
18
+ **Don't use for**:
19
+
20
+ - Production web apps with real backends → `frontend-design` + `react-best-practices`
21
+ - SEO/marketing sites → `frontend-design`
22
+ - Component library work → `mockup-to-code` (mockup → production component)
23
+
24
+ ## Core Discipline
25
+
26
+ ### 1. Start From Existing Context — Don't Design From Air
27
+
28
+ Good hi-fi designs grow from existing context. Before opening a blank file:
29
+
30
+ - Ask: do you have a design system / UI kit / Figma / brand site / reference screenshots?
31
+ - If yes → run `brand-asset-protocol` to extract real assets
32
+ - If no AND brief is vague → run `design-direction-advisor` first
33
+ - Only as last resort: design from generic intuition (will produce AI slop — see `anti-ai-slop`)
34
+
35
+ ### 2. Junior Designer Mode — Show Assumptions Early, Then Iterate
36
+
37
+ You are the user's junior designer. The user is the manager.
38
+
39
+ ❌ **Don't** disappear for an hour and reveal a finished file.
40
+
41
+ ✅ **Do** open the HTML with your assumptions written as comments + reasoning + grayblock placeholders. Show this **first**. Get nod. Then write components. Show again at 50% done. Iterate.
42
+
43
+ ```html
44
+ <!-- Assumptions:
45
+ - Audience: enterprise admins
46
+ - Style direction: Pentagram-style (per design-direction-advisor)
47
+ - 3 variations differ in: density, hierarchy, accent color
48
+ - Real product photos pending from user (Step 1 of brand-asset-protocol)
49
+ -->
50
+ <div class="placeholder">[Hero image — DJI Pocket 4 product render, TBD]</div>
51
+ <div class="placeholder">[Headline copy — TBD from user]</div>
52
+ ```
53
+
54
+ **Why**: misunderstanding the brief is 100× cheaper to fix at this stage than after a finished build.
55
+
56
+ ### 3. Give Variations, Not "The Answer"
57
+
58
+ When the user says "design X", don't deliver one polished answer. Deliver **3+ variations** spanning:
59
+
60
+ - by-the-book → novel (a continuum, not all in one corner)
61
+ - different axes: visual, interaction, color, layout, animation
62
+ - let the user mix and match
63
+
64
+ Implementation:
65
+
66
+ - Pure visual comparison → side-by-side static layout (`design_canvas`-style grid)
67
+ - Interactive flow with branching options → full prototype with toggles ("Tweaks") for live parameter swap
68
+
69
+ ### 4. Honest Placeholders Beat Bad Implementations
70
+
71
+ - Missing icon? → gray block + label "[icon]". Don't draw a wonky SVG.
72
+ - Missing data? → `<!-- TBD: real data from user -->`. Don't fabricate plausible-looking numbers.
73
+ - Missing image? → labeled placeholder. Don't AI-draw a face.
74
+
75
+ **In hi-fi work, an honest placeholder is 10× better than a clumsy attempt at the real thing.**
76
+
77
+ ### 5. System First, Don't Pad Filler
78
+
79
+ Every element earns its place. Whitespace is a design problem solved by **composition**, not by inventing content.
80
+
81
+ Especially watch for these "slop" categories (see `anti-ai-slop`):
82
+
83
+ - **Data slop** — meaningless stats, decorative numbers
84
+ - **Iconography slop** — every heading needs an icon
85
+ - **Gradient slop** — every background gets a gradient
86
+
87
+ > "One thousand no's for every yes."
88
+
89
+ ## App / iOS Prototype Rules (override generic placeholder rules)
90
+
91
+ App mockups are **demos at presentation time** — generic gray rectangles and lorem ipsum kill credibility. Different rules apply:
92
+
93
+ ### A. Architecture: Default to Single-File Inline React
94
+
95
+ **Default**: all JSX/data/styles inside a `<script type="text/babel">…</script>` tag in one HTML file. Reasons:
96
+
97
+ - `file://` blocks external JS as cross-origin → forces user to spin up an HTTP server → violates "double-click to open" principle
98
+ - Local images must be base64 data URLs (don't assume a server)
99
+
100
+ **Split files only when**:
101
+
102
+ - Single file >1000 lines and unmaintainable → split into `components.jsx` + `data.js`, document the `python3 -m http.server` command in delivery notes
103
+ - Multiple subagents need to write different screens in parallel → `index.html` + per-screen HTML, iframe-aggregated, each screen self-contained
104
+
105
+ | Scenario | Architecture | Delivery |
106
+ | --------------------------------- | ------------------------ | ----------------------------------------- |
107
+ | Single dev, 4-6 screens (default) | Single-file inline React | One `.html`, double-click |
108
+ | Single dev, large app (>10 scr) | Multi-jsx + HTTP server | Include startup command |
109
+ | Multi-agent parallel | Multi-HTML + iframe | `index.html` aggregator, each opens alone |
110
+
111
+ ### B. Real Images First, Not "Just Placeholders"
112
+
113
+ By default, **actively fetch real images**. Don't draw SVG. Don't leave gray blocks. Don't wait for user to ask.
114
+
115
+ | Use case | Source |
116
+ | --------------------------------- | ------------------------------------------------------------------- |
117
+ | Art / museum / historical content | Wikimedia Commons (public domain), Met Museum Open Access, AIC API |
118
+ | General lifestyle photography | Unsplash, Pexels (royalty-free) |
119
+ | User's existing assets | `~/Downloads`, project `_archive/`, user's configured asset library |
120
+
121
+ Wikimedia caveat: `curl` via TLS proxy often fails. Use Python `urllib` and a compliant User-Agent (`MyProject/0.1 (https://github.com/you; you@example.com)`). Use the MediaWiki API (`action=query&list=categorymembers`) for batch / `prop=imageinfo&iiurlwidth=` for sized thumbs.
122
+
123
+ **Honest-image test**: before fetching, ask — _"if I remove this image, is information lost?"_
124
+
125
+ | Scenario | Verdict | Action |
126
+ | ------------------------------------------------------------ | ------------------------------ | ------------------------------------------- |
127
+ | Essay list cover / profile background / settings page banner | Decoration, no link to content | **Don't add** — equivalent to gradient slop |
128
+ | Museum content portrait / product detail / map card location | Image IS the content | **Must add** — real image required |
129
+ | Graph / visualization background texture (very subtle) | Atmosphere, not focus | Add at `opacity ≤ 0.08` |
130
+
131
+ ❌ Don't pad text essays with Unsplash "inspiration shots." Permission to use real images ≠ license to over-use them.
132
+
133
+ ### C. Two Standard Delivery Forms — Ask First
134
+
135
+ Multi-screen app prototypes split into two standard forms. **Ask which one** before defaulting:
136
+
137
+ | Form | When | How |
138
+ | ----------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
139
+ | **Overview tile (design review default)** | User wants to see all screens, compare layout, walk through consistency | All screens in parallel, each in its own iPhone frame, no clicks needed |
140
+ | **Flow demo (single device)** | User wants to demonstrate a specific user flow (onboarding, purchase) | One iPhone with `AppPhone` state machine — tabs, buttons, annotations all clickable |
141
+
142
+ Routing keywords:
143
+
144
+ - "tile / show all pages / overview / compare / all screens" → overview
145
+ - "demonstrate flow / user path / walk through / clickable / interactive demo" → flow demo
146
+ - Ambiguous → ask. Don't default to flow demo (it's much more work).
147
+
148
+ **Overview skeleton:**
149
+
150
+ ```jsx
151
+ <div style={{ display: "flex", gap: 32, flexWrap: "wrap", padding: 48, alignItems: "flex-start" }}>
152
+ {screens.map((s) => (
153
+ <div key={s.id}>
154
+ <div style={{ fontSize: 13, color: "#666", marginBottom: 8, fontStyle: "italic" }}>
155
+ {s.label}
156
+ </div>
157
+ <IosFrame>
158
+ <ScreenComponent data={s} />
159
+ </IosFrame>
160
+ </div>
161
+ ))}
162
+ </div>
163
+ ```
164
+
165
+ **Flow demo skeleton:**
166
+
167
+ ```jsx
168
+ function AppPhone({ initial = "today" }) {
169
+ const [screen, setScreen] = React.useState(initial);
170
+ const [modal, setModal] = React.useState(null);
171
+ // dispatch to the right ScreenComponent, pass onEnter/onClose/onTabChange callbacks
172
+ }
173
+ ```
174
+
175
+ Each Screen takes callback props (`onEnter`, `onClose`, `onTabChange`, `onOpen`, `onAnnotation`) — don't hard-code state. TabBar, buttons, cards get `cursor: pointer` + hover feedback.
176
+
177
+ ### D. Click-Test Before Delivery
178
+
179
+ Static screenshots only show layout. Interaction bugs only surface when you click. Run a **3-action minimum Playwright test** before saying done:
180
+
181
+ 1. Enter detail view
182
+ 2. Trigger a key annotation
183
+ 3. Switch tabs
184
+
185
+ Check `pageerror` count is 0. If not, fix and re-run.
186
+
187
+ ```bash
188
+ npx playwright test prototype.spec.ts
189
+ ```
190
+
191
+ ### E. iOS Frame: Use a Pinned-Spec Component, Don't Hand-Code
192
+
193
+ The iPhone Dynamic Island has fixed pixel dimensions (124×36, top:12, centered). Hand-coding the bezel + status bar + island + home indicator → 99% chance of placement bugs (status bar items get squeezed by the island, content top-padding miscalculated).
194
+
195
+ **Rule**: bind to a known-good iOS frame component (e.g. an `IosFrame` you keep in a personal asset library). Don't write `.dynamic-island`, `.status-bar`, `.home-indicator`, or the bezel chrome inline.
196
+
197
+ ```jsx
198
+ <IosFrame time="9:41" battery={85}>
199
+ <YourScreen />
200
+ </IosFrame>
201
+ ```
202
+
203
+ Same rule for Android (`AndroidFrame`), macOS windows (`MacosWindow`), browser windows (`BrowserWindow`).
204
+
205
+ ## Position Questions — Answer Before Designing the System
206
+
207
+ For every page / screen / shot, answer these **4 position questions** before opening CSS:
208
+
209
+ - **Narrative role** — hero / transition / data / quote / closer? (every page in a deck differs)
210
+ - **Viewing distance** — 10cm phone / 1m laptop / 10m projector? (drives font size + density)
211
+ - **Visual temperature** — quiet / excited / cool / authoritative / tender / mournful? (drives palette + rhythm)
212
+ - **Capacity check** — sketch 3 five-second thumbnails on paper. Does the content fit?
213
+
214
+ Then verbalize the design system (palette / type / layout rhythm / component patterns). System serves the answers — don't pick the system first and stuff content in.
215
+
216
+ 🛑 **Checkpoint**: state the 4 answers + the system out loud. Wait for user nod **before** opening CSS.
217
+
218
+ ## Standard Workflow (with Checkpoints)
219
+
220
+ 1. **Understand the need.**
221
+ - 🔍 If task names a specific real product (DJI Pocket 4, Gemini 3 Pro, etc.): WebSearch first, write facts to `product-facts.md`. Don't guess from memory.
222
+ - Ask focused clarifying questions — batch them, don't drip-feed.
223
+ - 🛑 **Checkpoint 1**: send all questions, wait for user to answer in batch.
224
+ - 🛑 If brief is vague → run `design-direction-advisor` and complete Phase 1-4 first.
225
+
226
+ 2. **Explore resources + extract assets.** Read design system, linked files, screenshots. For specific brands: run `brand-asset-protocol` (5 steps).
227
+ - 🛑 **Checkpoint 2 (asset self-check)**: physical product → product photo present (not CSS silhouette); digital product → logo + UI screenshot present; colors extracted from real HTML/SVG. Missing → stop and fix.
228
+
229
+ 3. **Answer the 4 position questions, then verbalize the system.**
230
+ - 🛑 **Checkpoint 3**: state position answers + system. Wait for nod.
231
+
232
+ 4. **Build folder structure.** `<project-name>/` holds main HTML + needed asset copies (don't bulk-copy >20 files).
233
+
234
+ 5. **Junior pass.** HTML opens with assumptions + placeholders + reasoning comments.
235
+ - 🛑 **Checkpoint 4**: show early (gray blocks + labels are fine). Wait for feedback before writing components.
236
+
237
+ 6. **Full pass.** Fill placeholders, build variations, add Tweaks if needed. **Show again mid-way**, not only at the end.
238
+
239
+ 7. **Verify.** Playwright screenshot + console error check. Send to user.
240
+ - 🛑 **Checkpoint 5**: open the file in your own browser. Walk through. AI-written prototype code commonly has subtle interaction bugs.
241
+
242
+ 8. **Summary.** Minimal — caveats and next steps only.
243
+
244
+ **Checkpoint principle**: when you hit a 🛑, stop and explicitly say _"I did X, next I plan Y, confirm?"_ — then **actually wait**. Don't say it and immediately continue.
245
+
246
+ ## Pairs Well With
247
+
248
+ - `brand-asset-protocol` — extract real brand assets before designing
249
+ - `anti-ai-slop` — actively avoid the AI default aesthetic
250
+ - `design-direction-advisor` — when brief is too vague to start
251
+ - `design-taste-frontend` / `high-end-visual-design` — base aesthetic discipline
252
+ - `frontend-design` — when prototype graduates to production code
253
+ - `playwright` — for the click-test step
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: html-deck-export
3
+ description: Use when building HTML-based slide decks that need to ship as PDF or editable PPTX. MUST load BEFORE writing the first line of HTML if PPTX (with editable text) is a delivery target — choosing the wrong architecture costs 2-3 hours of rework. Covers multi-file vs single-file deck architecture, browser presentation, PDF export, and the 4 hard constraints for editable PPTX.
4
+ ---
5
+
6
+ # HTML Deck Export
7
+
8
+ > Adapted from `huashu-design`. The hardest checkpoint isn't "single-file or multi-file" — it's **"what's the final delivery format?"** Get this wrong and you're rewriting 17 pages of HTML.
9
+
10
+ ## The Critical Decision (Before First Line of HTML)
11
+
12
+ ```
13
+ Q: What's the final delivery format?
14
+ ├── Browser fullscreen presentation only / local HTML → maximum visual freedom
15
+ ├── PDF (print / share / archive) → maximum visual freedom, any architecture exports
16
+ └── Editable PPTX (teammates will edit text) → 🛑 MUST follow 4 hard constraints from the first line
17
+ ```
18
+
19
+ **Why "editable PPTX" forces decisions early**: PPTX with editable text requires `html2pptx`-style element-by-element DOM translation. That tool needs a structurally constrained HTML (see "4 Hard Constraints" below). Writing visually-rich HTML and converting after is a 2-3 hour rewrite. **From-scratch with constraints adds ~5 minutes per slide.**
20
+
21
+ ### Real-Cost Comparison
22
+
23
+ | Path | Approach | Result | Cost |
24
+ | ------------------------------------- | ------------------------------------------------------ | ---------------------------------------------------------------------------- | ----------------------------------------------------------------- |
25
+ | ❌ **Free-form HTML, fix PPTX later** | Single-file deck-stage + lots of SVG / span / gradient | To get editable PPTX: hand-write hundreds of pptxgenjs lines OR rewrite HTML | **2-3 hour rework + ongoing maintenance debt** (HTML edit ≠ PPTX) |
26
+ | ✅ **Path-A constraints from line 1** | Per-page HTML + 4 constraints + 720×405pt | One command exports 100% editable PPTX, also presents in browser | **+5 min per slide thinking "how do I wrap text in `<p>`?"** |
27
+
28
+ ## Opening Questionnaire (paste-ready)
29
+
30
+ > Before I touch HTML, confirm delivery:
31
+ >
32
+ > - **Browser presentation / PDF** → I can use animations, web components, complex SVG, CSS gradients
33
+ > - **Editable PPTX** (someone will edit text in PowerPoint) → I must follow 4 hard HTML constraints from the start. Visual capabilities reduce (no gradients, no web components, no complex SVG), but export becomes a single command
34
+ >
35
+ > Which?
36
+
37
+ **Mixed delivery clarifications:**
38
+
39
+ - "I want HTML presentation **and** editable PPTX" → not actually mixed. Path-A HTML _is_ presentable HTML; just add a deck index. Zero extra cost.
40
+ - "I want PPTX **and** animation/web component" → real conflict. Make the user choose. Don't silently hand-write pptxgenjs (becomes permanent maintenance debt).
41
+
42
+ ## Architecture: Single-File vs Multi-File
43
+
44
+ After delivery format is locked, pick architecture:
45
+
46
+ | Architecture | When | Pattern |
47
+ | ------------------------ | ---------------------------------------------------- | ------------------------------------------------------------------------ |
48
+ | **Multi-file** (default) | ≥10 pages, academic/courseware, multi-agent parallel | Each page is its own HTML; an `index.html`/iframe stitcher combines them |
49
+ | **Single-file** | ≤10 pages, pitch decks, cross-page state needed | One HTML with a slide container component (web component or React) |
50
+
51
+ **Multi-file advantages**: independent CSS scopes (no specificity wars), trivial parallel work, individual page reload during dev.
52
+ **Single-file advantages**: one file to share, easy state sharing across slides.
53
+
54
+ ### Multi-File Stitcher (skeleton)
55
+
56
+ ```html
57
+ <!-- index.html -->
58
+ <!doctype html>
59
+ <style>
60
+ body {
61
+ margin: 0;
62
+ background: #000;
63
+ }
64
+ iframe {
65
+ display: block;
66
+ width: 100vw;
67
+ height: 100vh;
68
+ border: 0;
69
+ }
70
+ </style>
71
+ <iframe id="stage" src="01.html"></iframe>
72
+ <script>
73
+ const slides = ["01.html", "02.html", "03.html", "04.html"];
74
+ let i = 0;
75
+ const stage = document.getElementById("stage");
76
+ document.addEventListener("keydown", (e) => {
77
+ if (e.key === "ArrowRight" && i < slides.length - 1) i++;
78
+ if (e.key === "ArrowLeft" && i > 0) i--;
79
+ stage.src = slides[i];
80
+ });
81
+ </script>
82
+ ```
83
+
84
+ Each `NN.html` is a fully standalone, double-clickable slide.
85
+
86
+ ### Single-File Pattern (web component or React)
87
+
88
+ ```html
89
+ <deck-stage>
90
+ <section class="active">Slide 1</section>
91
+ <section>Slide 2</section>
92
+ </deck-stage>
93
+ <script src="deck_stage.js"></script>
94
+ ```
95
+
96
+ Two **hard constraints** for the web-component pattern:
97
+
98
+ - The `<script>` tag for the component **must come after** the `</deck-stage>` close tag (else slot rendering breaks)
99
+ - Section's `display: flex` must be on the `.active` class (not the section itself, else inactive slides fight for space)
100
+
101
+ ## The 4 Hard Constraints for Editable PPTX
102
+
103
+ If you need editable PPTX export (via `html2pptx`-style tooling):
104
+
105
+ 1. **Body fixed at 720pt × 405pt** — _not_ 1920×1080px. Use `pt` units for the deck container (PowerPoint's native unit).
106
+ 2. **All text wrapped in `<p>` or `<h1>`–`<h6>`** — never plain `<div>` with text. Never `<span>` as the primary text carrier.
107
+ 3. **`<p>` and `<h*>` themselves cannot have background / border / shadow** — put those on an outer `<div>`.
108
+ 4. **No `background-image` on `<div>`** — use real `<img>` tags. No CSS gradients. No web components. No complex decorative SVG.
109
+
110
+ **If your HTML violates any of these**, the editable export will produce broken slides or fail outright. The _image-mode_ PPTX export (slide rendered as an image, embedded in PowerPoint) doesn't have these constraints — but the result is **not editable**.
111
+
112
+ ## Two PPTX Export Modes
113
+
114
+ | Mode | Visual fidelity | Editability | When |
115
+ | ----------------- | --------------------- | ---------------------------------- | --------------------------------------------------------------------- |
116
+ | **Image mode** | 100% — pixel-perfect | None — text is image | Visual-rich slides, no edits expected, PDF-equivalent in PPTX wrapper |
117
+ | **Editable mode** | Reduced — constraints | Full — text editable in PowerPoint | Teammates will edit text, brand-spec font fallbacks expected |
118
+
119
+ Tools (per huashu-design pattern):
120
+
121
+ - `playwright` for browser rendering (already in this kit)
122
+ - `pptxgenjs` for PPTX object construction
123
+ - `pdf-lib` for multi-page PDF merge
124
+ - `sharp` (only for editable mode image fallbacks)
125
+
126
+ ## PDF Export (Easy Path)
127
+
128
+ PDF tolerates any HTML architecture. Per-page browser screenshot → merge.
129
+
130
+ ```js
131
+ // scripts/export-deck-pdf.mjs (skeleton)
132
+ import { chromium } from "playwright";
133
+ import { PDFDocument } from "pdf-lib";
134
+ import fs from "fs";
135
+
136
+ const slides = fs.readdirSync("slides").filter((f) => f.endsWith(".html"));
137
+ const browser = await chromium.launch();
138
+ const ctx = await browser.newContext({ viewport: { width: 1920, height: 1080 } });
139
+ const merged = await PDFDocument.create();
140
+
141
+ for (const file of slides) {
142
+ const page = await ctx.newPage();
143
+ await page.goto(`file://${process.cwd()}/slides/${file}`);
144
+ const pdfBytes = await page.pdf({ width: "1920px", height: "1080px", printBackground: true });
145
+ const tmp = await PDFDocument.load(pdfBytes);
146
+ const pages = await merged.copyPages(tmp, tmp.getPageIndices());
147
+ pages.forEach((p) => merged.addPage(p));
148
+ await page.close();
149
+ }
150
+
151
+ fs.writeFileSync("deck.pdf", await merged.save());
152
+ await browser.close();
153
+ ```
154
+
155
+ **Single-file deck-stage caveat**: shadow-DOM slot rendering can cause "only first slide exports." Use a per-slide URL fragment (`?slide=N`) and force the active slide before `page.pdf()`, or convert to multi-file before exporting.
156
+
157
+ ## Recovery: Rewriting for Editable PPTX After the Fact
158
+
159
+ You're already mid-build and the user pivots to "we need editable PPTX." Two imperfect options:
160
+
161
+ | Option | Cost | When |
162
+ | ----------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------ |
163
+ | **Rewrite HTML to satisfy 4 constraints** | 2-3 hours for a typical 15-20 page deck | Long-term — it's the only path to ongoing one-command export |
164
+ | **Hand-write pptxgenjs version** | 1-2 hours initially + permanent dual-maintenance | One-shot delivery — never edited again |
165
+
166
+ **Always tell the user explicitly** which option you're picking and why. Don't silently choose the maintenance-debt path.
167
+
168
+ ## Position Questions for Each Slide
169
+
170
+ Same as `hi-fi-prototype-html` — answer these before writing any slide:
171
+
172
+ - **Narrative role** — hero, transition, data, quote, closer?
173
+ - **Viewing distance** — laptop screen at 1m or projector at 10m? Drives font size and density.
174
+ - **Visual temperature** — quiet/excited/cool/authoritative/tender? Drives palette and rhythm.
175
+ - **Capacity check** — sketch 3 five-second thumbnails. Does it fit? (Most overcrowding is caught here.)
176
+
177
+ ## Anti-Patterns
178
+
179
+ - ❌ Drawing slide chrome (page numbers, progress bars, titles) inside each slide AND in the deck stitcher → both render, double chrome
180
+ - ❌ Using `1920×1080px` units for editable-PPTX target (must be `720pt × 405pt`)
181
+ - ❌ One CSS file shared across multi-file slides — defeats the architecture's main benefit (scope isolation)
182
+ - ❌ Building visual-rich slides "we can convert to PPTX later" — the 2-3 hour rework is real
183
+
184
+ ## Pairs Well With
185
+
186
+ - `hi-fi-prototype-html` — same checkpoint discipline (4 position questions, junior pass)
187
+ - `brand-asset-protocol` — required for branded decks
188
+ - `anti-ai-slop` — slide decks are slop-prone (gradient backgrounds, emoji bullets)
189
+ - `playwright` — drives PDF / image-mode PPTX export