hyperframes 0.4.37 → 0.4.39

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.
@@ -9,37 +9,58 @@ HTML is the source of truth for video. A composition is an HTML file with `data-
9
9
 
10
10
  ## Approach
11
11
 
12
+ ### Discovery (exploratory requests only)
13
+
14
+ For open-ended requests ("make me a product launch video", "create something for our brand") where the user hasn't committed to a direction, understand intent before picking colors:
15
+
16
+ - **Audience** — who watches this? Developers? Executives? General consumers?
17
+ - **Platform** — where does it play? Social (15s), website hero, product demo, internal?
18
+ - **Priority** — what matters most? Motion quality? Content accuracy? Brand fidelity? Speed?
19
+ - **Variations** — does the user want options, or a single best shot?
20
+
21
+ For specific requests ("add a title card", "fix the timing on scene 3"), skip discovery.
22
+
23
+ For exploratory requests, consider offering 2-3 variations that differ meaningfully — not just color swaps, but different pacing, energy levels, or structural approaches. One safe/expected, one ambitious. Don't mandate this — it's a tool available when appropriate.
24
+
25
+ ### Step 1: Design system
26
+
27
+ If `design.md` or `DESIGN.md` exists in the project, read it first (check both casings — they're different files on Linux). It's the source of truth for brand colors, fonts, and constraints. Use its exact values — don't invent colors or substitute fonts. Any format works (YAML frontmatter, prose, tables — just extract the values).
28
+
29
+ If it names fonts you can't find locally (no `fonts/` directory with `.woff2` files, not a built-in font), warn the user before writing HTML: "design.md specifies [font name] but no font files found. Please add .woff2 files to `fonts/` or I'll fall back to [closest built-in alternative]."
30
+
31
+ If no `design.md` exists, offer the user a choice:
32
+
33
+ 1. **User named a style or mood?** → Read [visual-styles.md](./visual-styles.md) for the 8 named presets. Pick the closest match.
34
+ 2. **Want to browse options visually?** → Run the design picker: read [references/design-picker.md](references/design-picker.md) for the full workflow. This serves a visual picker page. The user configures mood, palette, typography, and motion in the browser, then copies the generated design.md and pastes it back into the conversation.
35
+ 3. **Want to skip and go fast?** → Ask: mood, light or dark, any brand colors/fonts? Then pick a palette from [house-style.md](./house-style.md).
36
+
37
+ **design.md defines the brand. It does not define video composition rules.** Those come from [references/video-composition.md](references/video-composition.md) and [house-style.md](./house-style.md). Use brand colors at video-appropriate scale — not at web-UI opacity.
38
+
39
+ ### Step 2: Prompt expansion
40
+
41
+ Always run on every composition (except single-scene pieces and trivial edits). This step grounds the user's intent against `design.md` and `house-style.md` and produces a consistent intermediate that every downstream agent reads the same way.
42
+
43
+ Read [references/prompt-expansion.md](references/prompt-expansion.md) for the full process and output format.
44
+
45
+ ### Step 3: Plan
46
+
12
47
  Before writing HTML, think at a high level:
13
48
 
14
49
  1. **What** — what should the viewer experience? Identify the narrative arc, key moments, and emotional beats.
15
50
  2. **Structure** — how many compositions, which are sub-compositions vs inline, what tracks carry what (video, audio, overlays, captions).
16
- 3. **Timing** — which clips drive the duration, where do transitions land, what's the pacing.
17
- 4. **Layout** — build the end-state first. See "Layout Before Animation" below.
18
- 5. **Animate** — then add motion using the rules below.
51
+ 3. **Rhythm** — declare your scene rhythm before implementing. Which scenes are quick hits, which are holds, where do shaders land, where does energy peak. Name the pattern: fast-fast-SLOW-fast-SHADER-hold. Read [references/beat-direction.md](references/beat-direction.md) for rhythm templates.
52
+ 4. **Timing** — which clips drive the duration, where do transitions land, what's the pacing.
53
+ 5. **Layout** — build the end-state first. See "Layout Before Animation" below.
54
+ 6. **Animate** — then add motion using the rules below.
19
55
 
20
- For small edits (fix a color, adjust timing, add one element), skip straight to the rules.
56
+ **Build what was asked.** A request for "a title card" is not a request for "a title card + 3 supporting scenes + ambient music + captions." Every scene, every element, every tween should earn its place. If additional scenes or elements would genuinely improve the piece, propose them — don't add them.
21
57
 
22
- ### Visual Identity Gate
58
+ For small edits (fix a color, adjust timing, add one element), skip straight to the rules.
23
59
 
24
60
  <HARD-GATE>
25
- Before writing ANY composition HTML, you MUST have a visual identity defined. Do NOT write compositions with default or generic colors.
26
-
27
- Check in this order:
28
-
29
- 1. **DESIGN.md exists in the project?** → Read it. Use its exact colors, fonts, motion rules, and "What NOT to Do" constraints.
30
- 2. **visual-style.md exists?** → Read it. Apply its `style_prompt_full` and structured fields. (Note: `visual-style.md` is a project-specific file. `visual-styles.md` is the style library with 8 named presets — different files.)
31
- 3. **User named a style** (e.g., "Swiss Pulse", "dark and techy", "luxury brand")? → Read [visual-styles.md](./visual-styles.md) for the 8 named presets. Generate a minimal DESIGN.md with: `## Style Prompt` (one paragraph), `## Colors` (3-5 hex values with roles), `## Typography` (1-2 font families), `## What NOT to Do` (3-5 anti-patterns).
32
- 4. **None of the above?** → Ask 3 questions before writing any HTML:
33
- - What's the mood? (explosive / cinematic / fluid / technical / chaotic / warm)
34
- - Light or dark canvas?
35
- - Any specific brand colors, fonts, or visual references?
36
- Then generate a minimal DESIGN.md from the answers.
37
-
38
- Every composition must trace its palette and typography back to a DESIGN.md, visual-style.md, or explicit user direction. If you're reaching for `#333`, `#3b82f6`, or `Roboto` — you skipped this step.
61
+ Before writing ANY composition HTML — verify you have a visual identity from Step 1. If you're reaching for `#333`, `#3b82f6`, or `Roboto`, you skipped it.
39
62
  </HARD-GATE>
40
63
 
41
- For motion defaults, sizing, entrance patterns, and easing — follow [house-style.md](./house-style.md). The house style handles HOW things move. The DESIGN.md handles WHAT things look like.
42
-
43
64
  ## Layout Before Animation
44
65
 
45
66
  Position every element where it should be at its **most visible moment** — the frame where it's fully entered, correctly placed, and not yet exiting. Write this as static HTML+CSS first. No GSAP yet.
@@ -50,7 +71,7 @@ Position every element where it should be at its **most visible moment** — the
50
71
 
51
72
  1. **Identify the hero frame** for each scene — the moment when the most elements are simultaneously visible. This is the layout you build.
52
73
  2. **Write static CSS** for that frame. The `.scene-content` container MUST fill the full scene using `width: 100%; height: 100%; padding: Npx;` with `display: flex; flex-direction: column; gap: Npx; box-sizing: border-box`. Use padding to push content inward — NEVER `position: absolute; top: Npx` on a content container. Absolute-positioned content containers overflow when content is taller than the remaining space. Reserve `position: absolute` for decoratives only.
53
- 3. **Add entrances with `gsap.from()`** — animate FROM offscreen/invisible TO the CSS position. The CSS position is the ground truth; the tween describes the journey to get there.
74
+ 3. **Add entrances with `gsap.from()`** — animate FROM offscreen/invisible TO the CSS position. The CSS position is the ground truth; the tween describes the journey to get there. (In sub-compositions loaded via `data-composition-src`, prefer `gsap.fromTo()` — see load-bearing GSAP rules in [references/motion-principles.md](references/motion-principles.md).)
54
75
  4. **Add exits with `gsap.to()`** — animate TO offscreen/invisible FROM the CSS position.
55
76
 
56
77
  ### Example
@@ -259,27 +280,34 @@ tl.from("#s2-heading", { x: -40, opacity: 0, duration: 0.6, ease: "expo.out" },
259
280
  - 60px+ headlines, 20px+ body, 16px+ data labels for rendered video
260
281
  - `font-variant-numeric: tabular-nums` on number columns
261
282
 
262
- When no `visual-style.md` or animation direction is provided, follow [house-style.md](./house-style.md) for aesthetic defaults.
283
+ If no `design.md` exists, follow [house-style.md](./house-style.md) for aesthetic defaults.
263
284
 
264
285
  ## Typography and Assets
265
286
 
266
- - **Fonts:** Just write the `font-family` you want in CSS — the compiler embeds supported fonts automatically. If a font isn't supported, the compiler warns.
287
+ - **Built-in fonts:** Write the `font-family` you want in CSS — the compiler embeds supported fonts automatically.
288
+ - **Custom fonts:** If design.md names a font that isn't built-in, the user must provide `.woff2` files in a `fonts/` directory. If missing, warn before writing HTML. When files exist, add `@font-face` declarations pointing to the local files.
267
289
  - Add `crossorigin="anonymous"` to external media
268
290
  - For dynamic text overflow, use `window.__hyperframes.fitTextFontSize(text, { maxWidth, fontFamily, fontWeight })`
269
291
  - All files live at the project root alongside `index.html`; sub-compositions use `../`
270
292
 
271
293
  ## Editing Existing Compositions
272
294
 
273
- - Read the full composition firstmatch existing fonts, colors, animation patterns
295
+ - **Read actual files, don't guess.** When editing, extending, or creating companion compositions, read the existing source. Don't reconstruct hex codes from memory. Don't guess GSAP easing patterns. The composition IS the spec extract exact values from it.
296
+ - Match existing fonts, colors, animation patterns from what you read
274
297
  - Only change what was requested
275
298
  - Preserve timing of unrelated clips
276
299
 
277
300
  ## Output Checklist
278
301
 
302
+ **Fast (run immediately, block on results):**
303
+
279
304
  - [ ] `npx hyperframes lint` and `npx hyperframes validate` both pass
305
+ - [ ] Design adherence verified if design.md exists
306
+
307
+ **Slow (run in parallel while presenting the preview to the user):**
308
+
280
309
  - [ ] `npx hyperframes inspect` passes, or every reported overflow is intentionally marked
281
310
  - [ ] Contrast warnings addressed (see Quality Checks below)
282
- - [ ] Layout issues addressed (see Quality Checks below)
283
311
  - [ ] Animation choreography verified (see Quality Checks below)
284
312
 
285
313
  ## Quality Checks
@@ -317,6 +345,24 @@ If warnings appear:
317
345
 
318
346
  Use `--no-contrast` to skip if iterating rapidly and you'll check later.
319
347
 
348
+ ### Design Adherence
349
+
350
+ If a `design.md` exists, verify the composition follows it after authoring. Read the HTML and check:
351
+
352
+ 1. **Colors** — every hex value in the composition appears in design.md's palette section (however the user labeled it: Colors, Palette, Theme, etc.). Flag any invented colors.
353
+ 2. **Typography** — font families and weights match design.md's type spec. No substitutions.
354
+ 3. **Corners** — border-radius values match the declared corner style, if specified.
355
+ 4. **Spacing** — padding and gap values fall within the declared density range, if specified.
356
+ 5. **Depth** — shadow usage matches the declared depth level, if specified (flat = none, subtle = light, layered = glows).
357
+ 6. **Avoidance rules** — if design.md has a section listing things to avoid (commonly "What NOT to Do", "Don'ts", "Anti-patterns", or "Do's and Don'ts"), verify none are present.
358
+
359
+ Report violations as a checklist. Fix each one before serving.
360
+
361
+ If no `design.md` exists (house-style-only path), verify:
362
+
363
+ 1. **Palette consistency** — the same bg, fg, and accent colors are used across all scenes. No per-scene color invention.
364
+ 2. **No lazy defaults** — check the composition against house-style.md's "Lazy Defaults to Question" list. If any appear, they must be a deliberate choice for the content, not a default.
365
+
320
366
  ### Animation Map
321
367
 
322
368
  After authoring animations, run the animation map to verify choreography:
@@ -348,10 +394,15 @@ Skip on small edits (fixing a color, adjusting one duration). Run on new composi
348
394
  - **[references/tts.md](references/tts.md)** — Text-to-speech with Kokoro-82M. Voice selection, speed tuning, TTS+captions workflow. Read when generating narration or voiceover.
349
395
  - **[references/audio-reactive.md](references/audio-reactive.md)** — Audio-reactive animation: map frequency bands and amplitude to GSAP properties. Read when visuals should respond to music, voice, or sound.
350
396
  - **[references/css-patterns.md](references/css-patterns.md)** — CSS+GSAP marker highlighting: highlight, circle, burst, scribble, sketchout. Deterministic, fully seekable. Read when adding visual emphasis to text.
397
+ - **[references/video-composition.md](references/video-composition.md)** — Video-medium rules: density, color presence, scale, frame composition, design.md as brand not layout. **Always read** — these override web instincts.
398
+ - **[references/beat-direction.md](references/beat-direction.md)** — Beat planning: concept, mood, choreography verbs, rhythm templates, transition decisions, depth layers. **Always read for multi-scene compositions.**
351
399
  - **[references/typography.md](references/typography.md)** — Typography: font pairing, OpenType features, dark-background adjustments, font discovery script. **Always read** — every composition has text.
352
- - **[references/motion-principles.md](references/motion-principles.md)** — Motion design principles: easing as emotion, timing as weight, choreography as hierarchy, scene pacing, ambient motion, anti-patterns. Read when choreographing GSAP animations.
353
- - **[visual-styles.md](visual-styles.md)** — 8 named visual styles (Swiss Pulse, Velvet Standard, Deconstructed, Maximalist Type, Data Drift, Soft Signal, Folk Frequency, Shadow Cut) with hex palettes, GSAP easing signatures, and shader pairings. Read when user names a style or when generating DESIGN.md.
354
- - **[house-style.md](house-style.md)** — Default motion, sizing, and color palettes when no style is specified.
400
+ - **[references/motion-principles.md](references/motion-principles.md)** — Motion design principles, image motion treatment, load-bearing GSAP rules. **Always read** every composition has motion.
401
+ - **[references/techniques.md](references/techniques.md)** — 11 visual techniques with code patterns: SVG drawing, Canvas 2D, CSS 3D, kinetic type, Lottie, video compositing, typing effect, variable fonts, MotionPath, velocity transitions, audio-reactive. Read when planning techniques per beat.
402
+ - **[references/narration.md](references/narration.md)** — Pacing, tone, script structure, number pronunciation, opening line patterns. Read when the composition includes voiceover or TTS.
403
+ - **[references/design-picker.md](references/design-picker.md)** — Create a design.md via visual picker. Read when no design.md exists and the user wants to create one.
404
+ - **[visual-styles.md](visual-styles.md)** — 8 named visual styles with hex palettes, GSAP easing signatures, and shader pairings. Read when user names a style or when generating design.md.
405
+ - **[house-style.md](house-style.md)** — Default motion, sizing, and color palettes when no design.md is specified.
355
406
  - **[patterns.md](patterns.md)** — PiP, title cards, slide show patterns.
356
407
  - **[data-in-motion.md](data-in-motion.md)** — Data, stats, and infographic patterns.
357
408
  - **[references/transcript-guide.md](references/transcript-guide.md)** — Transcription commands, whisper models, external APIs, troubleshooting.
@@ -1,6 +1,6 @@
1
1
  # House Style
2
2
 
3
- Creative direction for compositions when no `visual-style.md` is provided. These are starting points — override anything that doesn't serve the content.
3
+ Creative direction for compositions when no `design.md` is provided. These are starting points — override anything that doesn't serve the content. When a `design.md` exists, its brand values take precedence; house-style fills gaps.
4
4
 
5
5
  ## Before Writing HTML
6
6
 
@@ -44,6 +44,8 @@ Ideas (mix and match, 2-5 per scene):
44
44
 
45
45
  All decoratives should have slow ambient GSAP animation — breathing, drift, pulse. Static decoratives feel dead.
46
46
 
47
+ **Decorative count vs motion count.** The "2-5 per scene" count refers to decorative _elements_. If a project's `design.md` says "single ambient motion per scene", it means one looping motion applied to these decoratives (a shared breath/drift/pulse) — not one element total. A scene with 4 decoratives sharing one breathing motion is correct; a scene with 1 decorative is under-dressed.
48
+
47
49
  ## Motion
48
50
 
49
51
  See [references/motion-principles.md](references/motion-principles.md) for full rules. Quick: 0.3–0.6s, vary eases, combine transforms on entrances, overlap entries.
@@ -0,0 +1,102 @@
1
+ # Beat Direction
2
+
3
+ How to plan and direct individual scenes (beats) in a multi-scene composition. Read before writing any multi-scene video.
4
+
5
+ ---
6
+
7
+ ## Per-Beat Direction
8
+
9
+ Each beat is a WORLD, not a layout. Before writing CSS specs and GSAP instructions, describe what the viewer EXPERIENCES. The difference between a great storyboard and a mediocre one:
10
+
11
+ **Mediocre:** "Dark navy background. '$1.9T' in white, 280px. Logo top-left. Wave image bottom-right."
12
+ **Great:** "Camera is already mid-flight over a vast dark canvas. The gradient wave sweeps across the frame like aurora borealis — alive, shifting. '$1.9T' SLAMS into existence with such force the wave ripples in response. This isn't a slide — it's a moment."
13
+
14
+ The first describes pixels. The second describes an experience. Write the second, then figure out the pixels.
15
+
16
+ Each beat should have:
17
+
18
+ ### Concept
19
+
20
+ The big idea for this beat in 2-3 sentences. What visual WORLD are we in? What metaphor drives it? What should the viewer FEEL? This is the most important part — everything else flows from it.
21
+
22
+ ### Mood direction
23
+
24
+ Cultural and design references, not hex codes:
25
+
26
+ - "Geometric, rhythmic, precise. Think Josef Albers or Bauhaus color studies."
27
+ - "Warm workspace. Nice notebook energy, not technical blueprint."
28
+ - "Cinematic title sequence. The kind of opening where you lean forward."
29
+
30
+ ### Animation choreography
31
+
32
+ Specific motion verbs per element — not "it animates in" but HOW:
33
+
34
+ | Energy | Verbs | Example |
35
+ | ------------- | --------------------------------------------- | ------------------------------------- |
36
+ | High impact | SLAMS, CRASHES, PUNCHES, STAMPS, SHATTERS | "$1.9T" SLAMS in from left at -5° |
37
+ | Medium energy | CASCADE, SLIDES, DROPS, FILLS, DRAWS | Three cards CASCADE in staggered 0.3s |
38
+ | Low energy | types on, FLOATS, morphs, COUNTS UP, fades in | Counter COUNTS UP from 0 to 135K |
39
+
40
+ Every element gets a verb. If you can't name the verb, the element is not yet designed.
41
+
42
+ ### Transition
43
+
44
+ How this beat hands off to the next. Specify the type and parameters.
45
+
46
+ **When to pick which:**
47
+
48
+ | Choose shader transition for | Choose CSS transition for | Choose hard cut for |
49
+ | ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -------------------------------------------------------------- |
50
+ | Reveals, big reaction shots, product/logo unveils, energy shifts, "wow" moments | Continuous camera-motion beats where the scene feels like one move broken into cuts | Rapid-fire lists, percussive edits on the beat, comedic timing |
51
+ | Any moment the music/VO punctuates with a downbeat or SFX hit | Beats that ease from one composition into the next with shared motion vocabulary | Sequences of 3+ quick tempo-matched switches |
52
+ | Brand moments where the transition itself _is_ the visual | Minimal/editorial pacing | Anytime a 0.3-0.8s transition would feel too slow |
53
+
54
+ Rule of thumb: if the beat is the _centerpiece_ of the video, shader-transition into it. If the beat is connective tissue, CSS-transition. A brand reel of 5-7 beats usually wants 1-2 shader transitions (the hero reveal + the CTA) and the rest CSS or hard cuts — too many shader transitions flatten their impact.
55
+
56
+ **CSS transitions** (choose from `skills/hyperframes/references/transitions/catalog.md`):
57
+
58
+ - Velocity-matched upward: exit `y:-150, blur:30px, 0.33s power2.in` → entry `y:150→0, blur:30px→0, 1.0s power2.out`
59
+ - Whip pan: exit `x:-400, blur:24px, 0.3s power3.in` → entry `x:400→0, blur:24px→0, 0.3s power3.out`
60
+ - Blur through: exit `blur:20px, 0.3s` → entry `blur:20px→0, 0.25s power3.out`
61
+ - Zoom through: exit `scale:1→1.2, blur:20px, 0.2s power3.in` → entry `scale:0.75→1, blur:20px→0, 0.5s expo.out`
62
+ - Hard cut / smash cut (for rapid-fire sequences)
63
+
64
+ **Shader transitions** (choose from `packages/shader-transitions/README.md`):
65
+
66
+ - Cross-Warp Morph (organic, versatile) — 0.5-0.8s, power2.inOut
67
+ - Cinematic Zoom (professional momentum) — 0.4-0.6s, power2.inOut
68
+ - Gravitational Lens (otherworldly) — 0.6-1.0s, power2.inOut
69
+ - Glitch (aggressive, high energy) — 0.3-0.5s
70
+ - See `packages/shader-transitions/README.md` for the full API, available shaders, and setup
71
+
72
+ ### Depth layers
73
+
74
+ What's in foreground, midground, and background. Every beat should have at least 2 layers:
75
+
76
+ - "BG: dark navy fill + subtle radial glow. MG: stat cards with drop shadow. FG: brand logo bottom-right."
77
+
78
+ ### SFX cues
79
+
80
+ What sounds at what moment:
81
+
82
+ - "On the capture pulse — a soft, warm analog shutter click."
83
+ - "Left side carries a faint low drone. On fold: drone cuts. Silence. Then a single clean chime."
84
+
85
+ ---
86
+
87
+ ## Rhythm Planning
88
+
89
+ Before writing HTML, declare your scene rhythm: which scenes are quick hits, which are holds, where do shaders land, where does energy peak. Name the pattern — fast-fast-SLOW-fast-SHADER-hold — before implementing.
90
+
91
+ | Video type | Typical rhythm pattern |
92
+ | ---------------------- | --------------------------------- |
93
+ | Social ad (15s) | hook-PUNCH-hold-CTA |
94
+ | Product demo (30-60s) | slow-build-BUILD-PEAK-breathe-CTA |
95
+ | Launch teaser (10-20s) | SLAM-proof-SLAM-hold |
96
+ | Brand reel (20-45s) | drift-build-PEAK-drift-resolve |
97
+
98
+ ---
99
+
100
+ ## Velocity-Matched Transitions
101
+
102
+ Exit the outgoing beat with an accelerating ease (power2.in or power3.in) plus a blur ramp. Enter the incoming beat with a decelerating ease (power2.out or power3.out) plus blur clear. The fastest point of both easing curves meets at the cut — the viewer perceives continuous camera motion, not two discrete animations. Match exit velocity to entry velocity within ~5% tolerance.
@@ -0,0 +1,117 @@
1
+ # Design Picker
2
+
3
+ Two-phase visual picker: mood boards first (pick a complete direction), then fine-tune individual categories.
4
+
5
+ ## Prerequisites
6
+
7
+ Read these before generating options — they define the rules your options must follow:
8
+
9
+ - [typography.md](typography.md)
10
+ - [../house-style.md](../house-style.md)
11
+ - [video-composition.md](video-composition.md)
12
+ - [../visual-styles.md](../visual-styles.md)
13
+ - [beat-direction.md](beat-direction.md)
14
+
15
+ ## Building the picker
16
+
17
+ 1. Generate options **deeply contextual to the user's prompt**. Every category — not just architectures — must reflect the specific product, brand, audience, and mood. Generic options that could appear on any picker are a failure.
18
+
19
+ **Mood boards** — as many as the creative space warrants (4-8). Every board must tell a different STORY about the brand, not just reshuffle the same elements. Ask: "what are the genuinely different ways to position this product?" A cat food brand might be: playful chaos, premium positioning, comfort/cozy, social-native, flavor showcase, humor-led, sensory/appetizing. Each is a different narrative, not a different font on the same layout.
20
+
21
+ **Architectures** — one per mood board minimum, each visually distinct. Use `{{prompt_headline}}` and `{{prompt_sub}}` tokens. If the user provided media assets, use them as background images (use `url(path)` without quotes — single quotes inside `style='...'` break the attribute).
22
+
23
+ **Palettes** (5-6) — named after the brand's world, not generic moods. The palette names and colors should feel like they belong to THIS specific product. Always mix dark + light + tinted. **Every palette must be visually distinct at swatch size.** If two palettes share the same background lightness AND a similar accent hue, cut one. Test: would a user see the difference in a 14px swatch chip? If not, they're duplicates.
24
+
25
+ **Type pairings** (5-6) — **RUN the font discovery script from typography.md BEFORE generating pairings.** This is not optional. Download Google Fonts metadata, run the script, and pick from its output. You will otherwise reach for the same 8 fonts every time (Bricolage Grotesque, Instrument Serif, Fraunces, Archivo Black, DM Serif Display, Space Grotesk, Fredoka) — that's your training data default, not a contextual choice. Match the brand's energy and audience. Cross-category per typography.md (never two sans-serifs).
26
+
27
+ 2. `mkdir -p .hyperframes` then copy [../templates/design-picker.html](../templates/design-picker.html) to `.hyperframes/pick-design.html`.
28
+ 3. Replace these placeholders using Python (don't hand-escape quotes in sed):
29
+ - `__ARCHITECTURES_JSON__` — array of architecture objects
30
+ - `__PALETTES_JSON__` — array of palette objects
31
+ - `__TYPEPAIRS_JSON__` — array of type pairing objects
32
+ - `__MOODBOARDS_JSON__` — array of mood board objects (see format below)
33
+ - `__PROMPT_JSON__` — object with prompt context (see format below)
34
+
35
+ ### Architecture data format
36
+
37
+ Each architecture object must include a `preview_html` field — the HTML that renders in the preview panel. Use token placeholders that the template replaces at runtime: `{{bg}}`, `{{fg}}`, `{{ac}}`, `{{mt}}`, `{{hf}}`, `{{hw}}`, `{{bf}}`, `{{bw}}`, `{{cr}}` (corner radius), `{{pad}}`, `{{gap}}`, `{{shadow}}`, `{{g}}` (grid line color), `{{fg3}}`/`{{fg6}}`/`{{fg8}}`/`{{fg15}}` (fg at opacity), `{{ac3}}`/`{{ac5}}`/`{{ac25}}` (accent at opacity).
38
+
39
+ **Every token must be used.** Apply `{{cr}}` to all cards, buttons, and containers. Apply `{{shadow}}` to elevated elements (cards, buttons, code blocks). Apply `{{pad}}` and `{{gap}}` to control spacing. If a token isn't used in the preview_html, that option will have no visible effect.
40
+
41
+ **Density matters.** Each architecture preview must include 15+ distinct elements to give the user a real sense of the layout. Include: headline, subhead, body paragraph, label/overline, stat with number, secondary stat, quote/testimonial, attribution, card with title+body, second card (different treatment), code/command block, primary button, secondary button, list or tags, accent divider/rule, and a data element (table row, progress bar, or chart).
42
+
43
+ Optionally include `components` (component styling rules) and `dos` (do's and don'ts) as strings — these appear in the generated design.md.
44
+
45
+ **Layout constraint:** All preview HTML must use percentage widths or `max-width: 100%`. Use `flex-wrap: wrap` on all flex rows. Absolute-positioned decoratives must stay within a parent with `overflow: hidden`.
46
+
47
+ **Security:** Architecture `preview_html` must not contain `<script>` tags, event handlers (`onclick`, `onerror`, etc.), or `javascript:` URLs. It is injected via `innerHTML`.
48
+
49
+ **Image URLs:** When using background images in `preview_html`, use `url(path/to/image.jpg)` WITHOUT quotes around the path. Single quotes like `url('path.jpg')` break because `preview_html` is inside a `style='...'` attribute — the inner single quotes terminate the outer attribute.
50
+
51
+ **Palette variety:** Always include a mix of light, dark, and tinted backgrounds across the 6 palettes — even for calm/wellness prompts.
52
+
53
+ ### Example architecture object
54
+
55
+ ```json
56
+ {
57
+ "name": "Editorial Stack",
58
+ "description": "Vertical rhythm with large type, pull quotes, and data callouts",
59
+ "tag": "editorial / longform / narrative",
60
+ "mood": "Confident, unhurried, typographically driven",
61
+ "preview_html": "<div style='background:{{bg}};color:{{fg}};padding:{{pad}};min-height:100vh;font-family:\"{{bf}}\",sans-serif;font-weight:{{bw}};'><div style='max-width:100%;display:flex;flex-direction:column;gap:{{gap}};'><div style='font-size:10px;text-transform:uppercase;letter-spacing:0.12em;color:{{mt}};'>Overline Label</div><div style='font-family:\"{{hf}}\",serif;font-weight:{{hw}};font-size:48px;line-height:1.1;letter-spacing:-0.02em;'>The Headline Goes Here</div><div style='font-size:20px;color:{{mt}};max-width:70%;line-height:1.5;'>Subheading text that introduces the narrative arc of this composition with enough words to fill two lines.</div><div style='font-size:15px;line-height:1.7;color:{{fg}};max-width:65%;'>Body paragraph with real sentences. The quick brown fox jumps over the lazy dog. This gives a sense of text density and reading rhythm at the chosen type size.</div><div style='display:flex;gap:{{gap}};flex-wrap:wrap;'><div style='background:{{fg6}};border-radius:{{cr}};padding:{{pad}};flex:1;min-width:200px;box-shadow:{{shadow}};'><div style='font-size:36px;font-family:\"{{hf}}\",serif;font-weight:{{hw}};color:{{ac}};'>2.4M</div><div style='font-size:12px;color:{{mt}};margin-top:4px;'>Primary Stat</div></div><div style='background:{{fg6}};border-radius:{{cr}};padding:{{pad}};flex:1;min-width:200px;box-shadow:{{shadow}};'><div style='font-size:36px;font-family:\"{{hf}}\",serif;font-weight:{{hw}};color:{{fg}};'>87%</div><div style='font-size:12px;color:{{mt}};margin-top:4px;'>Secondary Stat</div></div></div><div style='border-left:3px solid {{ac}};padding:12px {{pad}};background:{{ac3}};border-radius:0 {{cr}} {{cr}} 0;'><div style='font-size:18px;font-style:italic;color:{{fg}};line-height:1.5;'>\"A pull quote that captures the key insight of the piece.\"</div><div style='font-size:12px;color:{{mt}};margin-top:8px;'>— Attribution Name</div></div><div style='background:{{fg3}};border-radius:{{cr}};padding:{{pad}};box-shadow:{{shadow}};'><div style='font-size:14px;font-weight:{{hw}};margin-bottom:8px;'>Card Title</div><div style='font-size:13px;color:{{mt}};line-height:1.5;'>Card body text with a different treatment than the main content area.</div></div><div style='background:{{ac5}};border:1px solid {{ac25}};border-radius:{{cr}};padding:{{pad}};box-shadow:{{shadow}};'><div style='font-size:14px;font-weight:{{hw}};color:{{ac}};margin-bottom:8px;'>Accent Card</div><div style='font-size:13px;color:{{fg}};line-height:1.5;'>Second card with a tinted accent treatment for variety.</div></div><div style='font-family:monospace;font-size:13px;background:{{fg8}};border-radius:{{cr}};padding:{{pad}};color:{{fg15}};box-shadow:{{shadow}};'>$ hyperframes render --output video.mp4</div><div style='display:flex;gap:12px;flex-wrap:wrap;'><button style='background:{{ac}};color:{{bg}};border:none;padding:10px 24px;border-radius:{{cr}};font-size:14px;font-weight:600;box-shadow:{{shadow}};cursor:pointer;'>Primary Action</button><button style='background:transparent;color:{{fg}};border:1px solid {{fg15}};padding:10px 24px;border-radius:{{cr}};font-size:14px;cursor:pointer;'>Secondary</button></div><div style='display:flex;gap:8px;flex-wrap:wrap;'><span style='background:{{fg6}};border-radius:100px;padding:4px 12px;font-size:11px;color:{{mt}};'>Tag One</span><span style='background:{{fg6}};border-radius:100px;padding:4px 12px;font-size:11px;color:{{mt}};'>Tag Two</span><span style='background:{{ac5}};border-radius:100px;padding:4px 12px;font-size:11px;color:{{ac}};'>Accent Tag</span></div><div style='height:1px;background:linear-gradient(to right,{{ac25}},{{fg6}},{{ac25}});'></div><div style='display:flex;justify-content:space-between;font-size:12px;color:{{mt}};border-bottom:1px solid {{g}};padding:8px 0;'><span>Data row label</span><span style='color:{{fg}};font-weight:600;'>1,234</span></div></div></div>"
62
+ }
63
+ ```
64
+
65
+ ### Mood board data format
66
+
67
+ Each mood board pre-selects one option from each category. The user picks a mood board in Phase 1, then fine-tunes in Phase 2 with those selections pre-filled.
68
+
69
+ ```json
70
+ {
71
+ "name": "Terminal Precision",
72
+ "description": "Code-forward, data-dense, CLI energy. Dark canvas, monospace body, sharp corners.",
73
+ "theme": "dark",
74
+ "arch_index": 0,
75
+ "palette_index": 0,
76
+ "type_index": 0,
77
+ "corners_index": 0,
78
+ "density_index": 0,
79
+ "depth_index": 1,
80
+ "easing_index": 0,
81
+ "corners": "0px",
82
+ "padding": "12px",
83
+ "gap": "8px",
84
+ "shadow": "0 2px 16px rgba(0,230,255,0.15)"
85
+ }
86
+ ```
87
+
88
+ Indices reference into the ARCHITECTURES, PALETTES, and TYPEPAIRS arrays. The template renders a mini preview of each mood board using its architecture's `preview_html` with the mood board's palette/type applied.
89
+
90
+ ### Prompt context data format
91
+
92
+ ```json
93
+ {
94
+ "title": "AI Coding Assistant",
95
+ "headline": "Your Code, Understood.",
96
+ "subline": "An AI coding assistant that reads your entire codebase.",
97
+ "section_desc": "Layout options for your product launch"
98
+ }
99
+ ```
100
+
101
+ `title` appears in the Phase 1 header. `headline` and `subline` replace `{{prompt_headline}}` and `{{prompt_sub}}` in architecture preview_html so previews show real content.
102
+
103
+ ### Content tokens in preview_html
104
+
105
+ In addition to the standard design tokens (`{{bg}}`, `{{fg}}`, `{{ac}}`, etc.), architecture `preview_html` can use:
106
+
107
+ - `{{prompt_headline}}` — the user's actual headline text
108
+ - `{{prompt_sub}}` — the user's actual subline text
109
+
110
+ This makes previews contextual — the user sees their own content styled, not generic placeholders.
111
+
112
+ ## Serving and user selection
113
+
114
+ 4. Serve the file: `cd <project-dir> && python3 -m http.server 8723 &` (use port 8723 or any unused port above 8000; if the curl check fails, try the next port). Verify: `curl -s -o /dev/null -w "%{http_code}" http://localhost:8723/.hyperframes/pick-design.html` — only share the link if it returns 200. Do NOT use `npx hyperframes preview` for the picker — it blocks. Only start the HTTP server from the main conversation thread. If you are running as a dispatched task or subagent, return the file path and let the caller serve it.
115
+ 5. Once the user picks, tell them: "Copy the design.md from the picker and paste it here." The user pastes the markdown back into the conversation. Save it verbatim to `design.md` in the project root — it's already in spec format (YAML frontmatter + prose sections). After the user pastes, kill the background server: `kill %1` or `kill $(lsof -ti:8723)`. Then proceed with construction.
116
+
117
+ The picker outputs a [google-labs-code/design.md](https://github.com/google-labs-code/design.md) spec-compliant file: YAML frontmatter with `colors`, `typography`, `rounded`, and `spacing` tokens, followed by `## Overview`, `## Colors`, `## Typography`, `## Layout`, `## Elevation`, `## Components`, and `## Do's and Don'ts` prose sections.
@@ -67,3 +67,76 @@ You build for the web. Video frames are not pages.
67
67
  - **Anchor to edges.** Pin content to left/top or right/bottom. Centered-and-floating is a web pattern.
68
68
  - **Split frames.** Data panel on the left, content on the right. Top bar with metadata, full-width below. Zone-based layouts, not centered stacks.
69
69
  - **Use structural elements.** Rules, dividers, border panels. They create paths for the eye and animate well (scaleX from 0).
70
+
71
+ ## Image Motion Treatment
72
+
73
+ Never embed a raw flat image. Every image must have motion treatment:
74
+
75
+ - **Perspective tilt**: use `gsap.set(el, { transformPerspective: 1200, rotationY: -8 })` + `box-shadow` — creates depth. Do NOT use CSS `transform: perspective(...)` as GSAP will overwrite it.
76
+ - **Slow zoom (Ken Burns)**: GSAP `scale: 1` → `1.04` over beat duration — makes photos cinematic
77
+ - **Device frame**: Wrap in a laptop/phone shape using CSS `border-radius` and `box-shadow`
78
+ - **Floating UI**: Extract a key element and animate it at a different z-depth for parallax
79
+ - **Scroll reveal**: Clip the image to a viewport window and animate `y` position
80
+
81
+ ## Load-Bearing GSAP Rules
82
+
83
+ Rules below came out of two independent website-to-hyperframes builds (2026-04-20) where compositions lint-clean and still ship broken — elements that never appear, ambient motion that doesn't scrub, entrance tweens that silently kill their target. The linter cannot catch these; the rules must be followed by the author.
84
+
85
+ - **No iframes for captured content.** Iframes do not seek deterministically with the timeline — the capture engine cannot scrub inside them, so they appear frozen (or blank) in the rendered output. If the source you're stylizing is a live web app, use the screenshots from `capture/` as stacked panels or layered images, not live embeds.
86
+
87
+ - **Never stack two transform tweens on the same element.** A common failure: a `y` entrance plus a `scale` Ken Burns on the same `<img>`. The second tween's `immediateRender: true` writes the element's initial state at construction time, overwriting whatever the first tween set — leaving the element invisible or offscreen with no lint warning. A secondary mechanism: `tl.from()` resets to its declared "from" state when the playhead is seeked past the timeline's end, so an element that looked correct in linear playback vanishes in the capture engine's non-linear seek. Fix one of two ways:
88
+
89
+ ```html
90
+ <!-- BAD: two transforms on one element -->
91
+ <img class="hero" src="..." />
92
+ <script>
93
+ tl.from(".hero", { y: 50, opacity: 0, duration: 0.6 }, 0);
94
+ tl.to(".hero", { scale: 1.04, duration: beat }, 0); // kills the entrance
95
+ </script>
96
+
97
+ <!-- GOOD option A: combine into one tween -->
98
+ <script>
99
+ tl.fromTo(
100
+ ".hero",
101
+ { y: 50, opacity: 0, scale: 1.0 },
102
+ { y: 0, opacity: 1, scale: 1.04, duration: beat, ease: "none" },
103
+ 0,
104
+ );
105
+ </script>
106
+
107
+ <!-- GOOD option B: split across parent + child -->
108
+ <div class="hero-wrap"><img class="hero" src="..." /></div>
109
+ <script>
110
+ tl.from(".hero-wrap", { y: 50, opacity: 0, duration: 0.6 }, 0); // entrance on parent
111
+ tl.to(".hero", { scale: 1.04, duration: beat }, 0); // Ken Burns on child
112
+ </script>
113
+ ```
114
+
115
+ - **Prefer `tl.fromTo()` over `tl.from()` inside `.clip` scenes.** `gsap.from()` sets `immediateRender: true` by default, which writes the "from" state at timeline construction — before the `.clip` scene's `data-start` is active. Elements can flash visible, start from the wrong position, or skip their entrance entirely when the scene is seeked non-linearly (which the capture engine does). Explicit `fromTo` makes the state at every timeline position deterministic:
116
+
117
+ ```js
118
+ // BRITTLE: immediateRender interacts badly with scene boundaries
119
+ tl.from(el, { opacity: 0, y: 50, duration: 0.6 }, t);
120
+
121
+ // DETERMINISTIC: state is defined at both ends, no immediateRender surprise
122
+ tl.fromTo(el, { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 0.6 }, t);
123
+ ```
124
+
125
+ - **Ambient pulses must attach to the seekable `tl`, never bare `gsap.to()`.** Auras, shimmers, gentle float loops, logo breathing — all of these must be added to the scene's timeline, not fired standalone. Standalone tweens run on wallclock time and do not scrub with the capture engine, so the effect is absent in the rendered video even though it looks correct in the studio preview:
126
+
127
+ ```js
128
+ // BAD: lives outside the timeline, never renders in capture
129
+ gsap.to(".aura", { scale: 1.08, yoyo: true, repeat: 5, duration: 1.2 });
130
+
131
+ // GOOD: seekable, deterministic, renders
132
+ tl.to(".aura", { scale: 1.08, yoyo: true, repeat: 5, duration: 1.2 }, 0);
133
+ ```
134
+
135
+ - **Hard-kill every scene boundary, not just captions.** The caption hard-kill rule above generalizes: any element whose visibility changes at a beat boundary needs a deterministic `tl.set()` kill after its fade, because later tweens on the same element (or `immediateRender` from a sibling tween) can resurrect it. Apply to every element with an exit animation:
136
+
137
+ ```js
138
+ tl.to(el, { opacity: 0, duration: 0.3 }, beatEnd);
139
+ tl.set(el, { opacity: 0, visibility: "hidden" }, beatEnd + 0.3); // deterministic kill
140
+ ```
141
+
142
+ These are the exact rules with the exact code examples — don't summarize or shorten them. They exist because compositions that lint clean still ship broken without them.
@@ -0,0 +1,92 @@
1
+ # Narration & Script
2
+
3
+ How to write narration scripts for video compositions. Read when the composition includes voiceover or TTS.
4
+
5
+ ## Pacing
6
+
7
+ - **2.5 words per second** is natural speaking pace
8
+ - 15s = ~37 words. 30s = ~75 words. 60s = ~150 words
9
+ - Leave room for pauses. Silence between sentences is a feature, not dead air
10
+ - The script should feel SHORTER than the video — visual breathing room matters
11
+
12
+ ## Tone
13
+
14
+ Write like a person, not a brochure:
15
+
16
+ - Use contractions: "it's", "you'll", "that's", "we've"
17
+ - Vary sentence length — short punchy phrases mixed with longer flowing ones
18
+ - Read it out loud. If it sounds robotic, rewrite it
19
+ - Avoid jargon unless the audience expects it
20
+
21
+ ## Number Pronunciation
22
+
23
+ Write what you want the voice to say. TTS reads literally.
24
+
25
+ | In the product | Write in script as |
26
+ | -------------- | --------------------------------- |
27
+ | 135+ | more than one hundred thirty five |
28
+ | $1.9T | nearly two trillion dollars |
29
+ | 99.999% | ninety nine point nine percent |
30
+ | 200M+ | over two hundred million |
31
+ | 10x | ten times |
32
+ | API | A P I |
33
+ | stripe.com | stripe dot com |
34
+
35
+ The visual can show the exact figure while the voice rounds it.
36
+
37
+ ## Structure
38
+
39
+ For product videos:
40
+
41
+ 1. **Hook** — what's surprising or impressive about this product? A bold claim, a provocative question, a contrast, or a striking number. This is the opening line. **Vary the hook type** — don't default to a stat every time.
42
+ 2. **Story** — what does the product do? Who uses it? Keep it concrete.
43
+ 3. **Proof** — stats, customer names, social proof. Real numbers from the product.
44
+ 4. **CTA** — what should the viewer do? "Start building at stripe dot com."
45
+
46
+ Not every video needs all four. A 15-second social ad might be Hook + Proof + CTA. A 60-second product tour uses all four with more Story.
47
+
48
+ ## The Opening Line
49
+
50
+ The most important sentence in the video. It must create tension, curiosity, or surprise in the first 3 seconds.
51
+
52
+ Patterns that work:
53
+
54
+ - **A bold claim**: "The financial infrastructure that powers the internet economy."
55
+ - **A question that provokes**: "What if your database could think?"
56
+ - **A contrast**: "Your AI agent already knows how to make videos. It just needs the right format."
57
+ - **A number that shocks**: "Nearly two trillion dollars." (Use sparingly — not every video should open with a stat.)
58
+
59
+ If the opening is generic ("Welcome to Stripe" / "Introducing our product"), start over.
60
+
61
+ ## Example
62
+
63
+ From a 62-second product launch video (team reference):
64
+
65
+ ```
66
+ Your AI agent already knows how to make videos.
67
+ It just needs the right format.
68
+
69
+ This is Hyperframes. An open source framework. HTML in, video out.
70
+
71
+ A div is a keyframe. Data attributes are your timeline.
72
+ CSS is your look. G-Sap is your animation engine.
73
+
74
+ Anything a browser can render can be a frame in your video.
75
+
76
+ CSS animations. G-Sap. Lottie. Shaders. Three.js.
77
+
78
+ Drop in music, sound effects, footage — it all composes together.
79
+
80
+ No new framework for the agent to learn.
81
+ Just HTML.
82
+
83
+ The agent writes it. The renderer captures every frame as MP4.
84
+ It's deterministic. Identical outputs, every time.
85
+
86
+ Give your agent the CLI. Tell it what to make.
87
+ Watch it build.
88
+
89
+ Hyperframes. Go make something.
90
+ ```
91
+
92
+ Note: ~140 words for 62 seconds — that's 2.3 words/sec, leaving room for pauses and visual breathing.