hyperframes 0.4.38 → 0.5.0-alpha.10

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,58 +9,37 @@ 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
-
47
12
  Before writing HTML, think at a high level:
48
13
 
49
14
  1. **What** — what should the viewer experience? Identify the narrative arc, key moments, and emotional beats.
50
15
  2. **Structure** — how many compositions, which are sub-compositions vs inline, what tracks carry what (video, audio, overlays, captions).
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.
55
-
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.
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.
57
19
 
58
20
  For small edits (fix a color, adjust timing, add one element), skip straight to the rules.
59
21
 
22
+ ### Visual Identity Gate
23
+
60
24
  <HARD-GATE>
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.
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.
62
39
  </HARD-GATE>
63
40
 
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
+
64
43
  ## Layout Before Animation
65
44
 
66
45
  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.
@@ -71,7 +50,7 @@ Position every element where it should be at its **most visible moment** — the
71
50
 
72
51
  1. **Identify the hero frame** for each scene — the moment when the most elements are simultaneously visible. This is the layout you build.
73
52
  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.
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).)
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.
75
54
  4. **Add exits with `gsap.to()`** — animate TO offscreen/invisible FROM the CSS position.
76
55
 
77
56
  ### Example
@@ -280,34 +259,27 @@ tl.from("#s2-heading", { x: -40, opacity: 0, duration: 0.6, ease: "expo.out" },
280
259
  - 60px+ headlines, 20px+ body, 16px+ data labels for rendered video
281
260
  - `font-variant-numeric: tabular-nums` on number columns
282
261
 
283
- If no `design.md` exists, follow [house-style.md](./house-style.md) for aesthetic defaults.
262
+ When no `visual-style.md` or animation direction is provided, follow [house-style.md](./house-style.md) for aesthetic defaults.
284
263
 
285
264
  ## Typography and Assets
286
265
 
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.
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.
289
267
  - Add `crossorigin="anonymous"` to external media
290
268
  - For dynamic text overflow, use `window.__hyperframes.fitTextFontSize(text, { maxWidth, fontFamily, fontWeight })`
291
269
  - All files live at the project root alongside `index.html`; sub-compositions use `../`
292
270
 
293
271
  ## Editing Existing Compositions
294
272
 
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
273
+ - Read the full composition first match existing fonts, colors, animation patterns
297
274
  - Only change what was requested
298
275
  - Preserve timing of unrelated clips
299
276
 
300
277
  ## Output Checklist
301
278
 
302
- **Fast (run immediately, block on results):**
303
-
304
279
  - [ ] `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
-
309
280
  - [ ] `npx hyperframes inspect` passes, or every reported overflow is intentionally marked
310
281
  - [ ] Contrast warnings addressed (see Quality Checks below)
282
+ - [ ] Layout issues addressed (see Quality Checks below)
311
283
  - [ ] Animation choreography verified (see Quality Checks below)
312
284
 
313
285
  ## Quality Checks
@@ -345,24 +317,6 @@ If warnings appear:
345
317
 
346
318
  Use `--no-contrast` to skip if iterating rapidly and you'll check later.
347
319
 
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
-
366
320
  ### Animation Map
367
321
 
368
322
  After authoring animations, run the animation map to verify choreography:
@@ -394,15 +348,10 @@ Skip on small edits (fixing a color, adjusting one duration). Run on new composi
394
348
  - **[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.
395
349
  - **[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.
396
350
  - **[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.**
399
351
  - **[references/typography.md](references/typography.md)** — Typography: font pairing, OpenType features, dark-background adjustments, font discovery script. **Always read** — every composition has text.
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.
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.
406
355
  - **[patterns.md](patterns.md)** — PiP, title cards, slide show patterns.
407
356
  - **[data-in-motion.md](data-in-motion.md)** — Data, stats, and infographic patterns.
408
357
  - **[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 `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.
3
+ Creative direction for compositions when no `visual-style.md` is provided. These are starting points — override anything that doesn't serve the content.
4
4
 
5
5
  ## Before Writing HTML
6
6
 
@@ -44,8 +44,6 @@ 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
-
49
47
  ## Motion
50
48
 
51
49
  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.
@@ -67,76 +67,3 @@ 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.