Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
feat: add HyperFrames skills for AI coding tools (#46)
Vance Ingalls0ce9dd84967a
diff --git a/skills/captions/SKILL.md b/skills/captions/SKILL.mdnew file mode 100644index 0000000000..0831a51a2e--- /dev/null+++ b/skills/captions/SKILL.md@@ -0,0 +1,138 @@+---+name: captions+description: Build tone-adaptive captions from whisper transcripts. Detects script energy (hype, corporate, tutorial, storytelling, social) and applies matching typography, color, and animation. Supports per-word styling for brand names, ALL CAPS, numbers, and CTAs. Use when adding captions or subtitles to a HyperFrames composition.+---++# Captions++Analyze the spoken content to determine caption style. If the user specifies a style, use that. Otherwise, detect tone from the transcript.++## Transcript Source++The project's `transcript.json` contains word-level timestamps from whisper.cpp (`--output-json-full` with `--dtw`):++```json+{+ "transcription": [+ {+ "offsets": { "from": 0, "to": 5000 },+ "text": " Hello world.",+ "tokens": [+ { "text": " Hello", "offsets": { "from": 0, "to": 1000 }, "p": 0.98 },+ { "text": " world", "offsets": { "from": 1000, "to": 2000 }, "p": 0.95 }+ ]+ }+ ]+}+```++Normalize tokens into a word array before grouping:++```js+const words = [];+for (const segment of transcript.transcription) {+ for (const token of segment.tokens || []) {+ const text = token.text.trim();+ if (!text) continue;+ words.push({+ text,+ start: token.offsets.from / 1000,+ end: token.offsets.to / 1000,+ });+ }+}+```++If no `transcript.json` exists, check for `.srt` or `.vtt` files. If no transcript is available, ask the user to provide one or run `hyperframes transcribe` (when available).++## Style Detection (Default — When No Style Is Specified)++Read the full transcript before choosing a style. The style comes from the content, not a template.++### Four Dimensions++**1. Visual feel** — the overall aesthetic personality:++- Corporate/professional scripts → clean, minimal, restrained+- Energetic/marketing scripts → bold, punchy, high-impact+- Storytelling/narrative scripts → elegant, warm, cinematic+- Technical/educational scripts → precise, high-contrast, structured+- Social media/casual scripts → playful, dynamic, friendly++**2. Color palette** — driven by the content's mood:++- Dark backgrounds with bright accents for high energy+- Muted/neutral tones for professional or calm content+- High contrast (white on black, black on white) for clarity+- One accent color for emphasis — not multiple++**3. Font mood** — typography character, not specific font names:++- Heavy/condensed for impact and energy+- Clean sans-serif for modern and professional+- Rounded for friendly and approachable+- Serif for elegance and storytelling++**4. Animation character** — how words enter and exit:++- Scale-pop/slam for punchy energy+- Gentle fade/slide for calm or professional+- Word-by-word reveal for emphasis+- Typewriter for technical or narrative pacing++## Per-Word Styling++Scan the script for words that deserve distinct visual treatment. Not every word is equal — some carry the message.++### What to Detect++- **Brand names / product names** — larger size, unique color, distinct entrance+- **ALL CAPS words** — the author emphasized them intentionally. Scale boost, flash, or accent color.+- **Numbers / statistics** — bold weight, accent color. Numbers are the payload in data-driven content.+- **Emotional keywords** — "incredible", "insane", "amazing", "revolutionary" → exaggerated animation (overshoot, bounce)+- **Proper nouns** — names of people, places, events → distinct accent or italic+- **Call-to-action phrases** — "sign up", "get started", "try it now" → highlight, underline, or color pop++### How to Apply++For each detected word, specify:++- Font size multiplier (e.g., 1.3x for emphasis, 1.5x for hero moments)+- Color override (specific hex value)+- Weight/style change (bolder, italic)+- Animation variant (overshoot entrance, glow pulse, scale pop)++## Script-to-Style Mapping++| Script tone | Font mood | Animation | Color | Size |+| -------------------- | ------------------------------------- | --------------------------------------- | -------------------------------------------- | -------------------- |+| Hype/launch | Heavy condensed, 800-900 weight | Scale-pop, back.out(1.7), fast 0.1-0.2s | Bright accent on dark (cyan, yellow, lime) | Large 72-96px |+| Corporate/pitch | Clean sans-serif, 600-700 weight | Fade + slide-up, power3.out, 0.3s | White/neutral on dark, single muted accent | Medium 56-72px |+| Tutorial/educational | Mono or clean sans, 500-600 weight | Typewriter or gentle fade, 0.4-0.5s | High contrast, minimal color | Medium 48-64px |+| Storytelling/brand | Serif or elegant sans, 400-500 weight | Slow fade, power2.out, 0.5-0.6s | Warm muted tones, low opacity (0.85-0.9) | Smaller 44-56px |+| Social/casual | Rounded sans, 700-800 weight | Bounce, elastic.out, word-by-word | Playful colors, colored backgrounds on pills | Medium-large 56-80px |++## Word Grouping by Tone++Group size affects pacing. Fast content needs fast caption turnover.++- **High energy:** 2-3 words per group. Quick turnover matches rapid delivery.+- **Conversational:** 3-5 words per group. Natural phrase length.+- **Measured/calm:** 4-6 words per group. Longer groups match slower pace.++Break groups on sentence boundaries (`.` `?` `!`), pauses (>150ms gap), or max word count — whichever comes first.++## Positioning++- **Landscape (1920x1080):** Bottom 80-120px, centered+- **Portrait (1080x1920):** Lower middle ~600-700px from bottom, centered+- Never cover the subject's face+- Use `position: absolute` — never relative (causes overflow)+- One caption group visible at a time++## Constraints++- **Deterministic.** No `Math.random()`, no `Date.now()`.+- **Sync to transcript timestamps.** Words appear when spoken.+- **One group visible at a time.** No overlapping caption groups.+- **Check project root** for font files before defaulting to Google Fonts.diff --git a/skills/compose-video/SKILL.md b/skills/compose-video/SKILL.mdnew file mode 100644index 0000000000..540e764503--- /dev/null+++ b/skills/compose-video/SKILL.md@@ -0,0 +1,147 @@+---+name: compose-video+description: Create HyperFrames HTML video compositions. Use when asked to create a video, build an animation, make a composition, add a title card, or generate any HTML-based video content for HyperFrames.+---++# Compose Video++HTML is the source of truth for video. A composition is an HTML file with `data-*` attributes for timing, a GSAP timeline for animation, and CSS for appearance. The framework handles clip visibility, media playback, and timeline sync.++## Approach++Before writing HTML, think at a high level:++1. **What** — what should the viewer experience? Identify the narrative arc, key moments, and emotional beats.+2. **Structure** — how many compositions, which are sub-compositions vs inline, what tracks carry what (video, audio, overlays, captions).+3. **Timing** — which clips drive the duration, where do transitions land, what's the pacing.+4. **Execute** — then implement using the rules below.++For small edits (fix a color, adjust timing, add one element), skip straight to the rules.++## Data Attributes++### All Clips++| Attribute | Required | Values |+| ------------------ | --------------------------------- | ------------------------------------------------------ |+| `id` | Yes | Unique identifier |+| `data-start` | Yes | Seconds or clip ID reference (`"el-1"`, `"intro + 2"`) |+| `data-duration` | Required for img/div/compositions | Seconds. Video/audio defaults to media duration. |+| `data-track-index` | Yes | Integer. Same-track clips **cannot overlap**. |+| `data-media-start` | No | Trim offset into source (seconds) |+| `data-volume` | No | 0-1 (default 1) |++`data-track-index` does **not** affect visual layering — use CSS `z-index`.++### Composition Clips++| Attribute | Required | Values |+| ---------------------------- | -------- | -------------------------------------------- |+| `data-composition-id` | Yes | Unique composition ID |+| `data-duration` | Yes | Takes precedence over GSAP timeline duration |+| `data-width` / `data-height` | Yes | Pixel dimensions (1920x1080 or 1080x1920) |+| `data-composition-src` | No | Path to external HTML file |++## Composition Structure++Every composition is a `<template>` wrapping a `<div>` with `data-composition-id`. Each must include its own GSAP script and register its timeline:++```html+<template id="my-comp-template">+ <div data-composition-id="my-comp" data-width="1920" data-height="1080">+ <!-- content -->+ <style>+ [data-composition-id="my-comp"] {+ /* scoped styles */+ }+ </style>+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>+ <script>+ window.__timelines = window.__timelines || {};+ const tl = gsap.timeline({ paused: true });+ // tweens...+ window.__timelines["my-comp"] = tl;+ </script>+ </div>+</template>+```++Load in root: `<div id="el-1" data-composition-id="my-comp" data-composition-src="compositions/my-comp.html" data-start="0" data-duration="10" data-track-index="1"></div>`++## Video and Audio++Video must be `muted playsinline`. Audio is always a separate `<audio>` element:++```html+<video+ id="el-v"+ data-start="0"+ data-duration="30"+ data-track-index="0"+ src="video.mp4"+ muted+ playsinline+></video>+<audio+ id="el-a"+ data-start="0"+ data-duration="30"+ data-track-index="2"+ src="video.mp4"+ data-volume="1"+></audio>+```++## Timeline Contract++- All timelines start `{ paused: true }` — the player controls playback+- Register every timeline: `window.__timelines["<composition-id>"] = tl`+- Framework auto-nests sub-timelines — do NOT manually add them+- Duration comes from `data-duration`, not from GSAP timeline length+- Never create empty tweens to set duration++## Rules (Non-Negotiable)++**Deterministic:** No `Math.random()`, `Date.now()`, or time-based logic. The renderer must produce identical output every time.++**GSAP:** Only animate visual properties (`opacity`, `x`, `y`, `scale`, `rotation`, `color`, `backgroundColor`, `borderRadius`, transforms). Do NOT animate `visibility`, `display`, or call `video.play()`/`audio.play()`.++**Animation conflicts:** Never animate the same property on the same element from multiple timelines simultaneously — causes flickering in headless renders.++**Never do:**++1. Forget `window.__timelines` registration+2. Use video for audio — always muted video + separate `<audio>`+3. Nest video inside a timed div — use a non-timed wrapper+4. Use `data-layer` (use `data-track-index`) or `data-end` (use `data-duration`)+5. Animate video element dimensions — animate a wrapper div+6. Call play/pause/seek on media — framework owns playback+7. Create a top-level container without `data-composition-id`++## Editing Existing Compositions++- Read the full composition first — match existing fonts, colors, animation patterns+- Only change what was requested — don't rewrite untouched sections+- Don't rewrite entire files for small changes+- Preserve timing of unrelated clips++## Typography and Assets++- Every composition loads its own fonts (`@import` or `@font-face` in `<style>`)+- Use `font-display: block` for local fonts — renderer needs fonts loaded before capturing+- Add `crossorigin="anonymous"` to media loaded from external URLs+- Minimum readable text: 20px landscape, 18px portrait+- All files (video, audio, fonts, images) live at the project root alongside `index.html`+- From sub-compositions, use `../` to reference root files++For PiP, title cards, and slide show patterns, see [patterns.md](./patterns.md).++## Output Checklist++- [ ] Every top-level container has `data-composition-id`+- [ ] Every composition has `data-width`, `data-height`, `data-duration`+- [ ] Compositions in own HTML files, loaded via `data-composition-src`+- [ ] `<template>` wrapper on sub-compositions+- [ ] `window.__timelines` registered for every composition+- [ ] 100% deterministic — no randomness+- [ ] Each composition includes GSAP: `<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>`diff --git a/skills/compose-video/patterns.md b/skills/compose-video/patterns.mdnew file mode 100644index 0000000000..dfa8775760--- /dev/null+++ b/skills/compose-video/patterns.md@@ -0,0 +1,118 @@+# Composition Patterns++## Picture-in-Picture (Video in a Frame)++Animate a wrapper div for position/size. The video fills the wrapper. The wrapper has NO data attributes.++```html+<div+ id="pip-frame"+ style="position:absolute;top:0;left:0;width:1920px;height:1080px;z-index:50;overflow:hidden;"+>+ <video+ id="el-video"+ data-start="0"+ data-duration="60"+ data-track-index="0"+ src="talking-head.mp4"+ muted+ playsinline+ ></video>+</div>+```++```js+tl.to(+ "#pip-frame",+ { top: 700, left: 1360, width: 500, height: 280, borderRadius: 16, duration: 1 },+ 10,+);+tl.to("#pip-frame", { left: 40, duration: 0.6 }, 30);+```++## Title Card with Fade++```html+<div+ id="title-card"+ data-start="0"+ data-duration="5"+ data-track-index="5"+ style="display:flex;align-items:center;justify-content:center;background:#111;z-index:60;"+>+ <h1 style="font-size:64px;color:#fff;opacity:0;">My Video Title</h1>+</div>+```++```js+tl.to("#title-card h1", { opacity: 1, duration: 0.6 }, 0.3);+tl.to("#title-card", { opacity: 0, duration: 0.5 }, 4);+```++## Slide Show with Section Headers++Use separate elements on the same track, each with its own time range. Slides auto-mount/unmount based on `data-start`/`data-duration`.++```html+<div class="slide" data-start="0" data-duration="30" data-track-index="3">...</div>+<div class="slide" data-start="30" data-duration="25" data-track-index="3">...</div>+<div class="slide" data-start="55" data-duration="20" data-track-index="3">...</div>+```++## Top-Level Composition Example++```html+<div+ id="comp-1"+ data-composition-id="my-video"+ data-start="0"+ data-duration="60"+ data-width="1920"+ data-height="1080"+>+ <!-- Primitive clips -->+ <video+ id="el-1"+ data-start="0"+ data-duration="10"+ data-track-index="0"+ src="..."+ muted+ playsinline+ ></video>+ <video+ id="el-2"+ data-start="el-1"+ data-duration="8"+ data-track-index="0"+ src="..."+ muted+ playsinline+ ></video>+ <img id="el-3" data-start="5" data-duration="4" data-track-index="1" src="..." />+ <audio id="el-4" data-start="0" data-duration="30" data-track-index="2" src="..." />++ <!-- Sub-compositions loaded from files -->+ <div+ id="el-5"+ data-composition-id="intro-anim"+ data-composition-src="compositions/intro-anim.html"+ data-start="0"+ data-track-index="3"+ ></div>++ <div+ id="el-6"+ data-composition-id="captions"+ data-composition-src="compositions/caption-overlay.html"+ data-start="0"+ data-track-index="4"+ ></div>++ <script>+ // Just register the timeline — framework auto-nests sub-compositions+ const tl = gsap.timeline({ paused: true });+ window.__timelines["my-video"] = tl;+ </script>+</div>+```