Skip to content

Write HTML. Render video. Built for agents.

feat(media-use): v2 media OS core (resolve cascade, providers, local generation, telemetry) + retire hyperframes-media

Miguel Angel Simon Sierra5fe957363d2b
diff --git a/CLAUDE.md b/CLAUDE.md
index 47fd0ab761..3478aeb614 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4,11 +4,11 @@ Open-source video rendering framework: write HTML, render video.
## Skills
-This repo ships 21 AI agent skills via [vercel-labs/skills](https://github.com/vercel-labs/skills). Install them before writing compositions — they encode framework-specific patterns that generic docs don't cover.
+This repo ships 20 AI agent skills via [vercel-labs/skills](https://github.com/vercel-labs/skills). Install them before writing compositions — they encode framework-specific patterns that generic docs don't cover.
```bash
npx skills add heygen-com/hyperframes # interactive picker
-npx skills add heygen-com/hyperframes --all # install all 21 (skips picker)
+npx skills add heygen-com/hyperframes --all # install all 20 (skips picker)
npx skills add heygen-com/hyperframes --skill <name> # just one (bare name, no leading slash)
```
@@ -36,8 +36,7 @@ Atomic capabilities the creation workflows compose against — pull one when you
- `/hyperframes-animation` — all animation knowledge: atomic motion rules, scene blueprints, transitions, runtime adapters (GSAP default, plus Lottie / Three.js / Anime.js / CSS / WAAPI / TypeGPU).
- `/hyperframes-keyframes` — seek-safe keyframe authoring across runtimes: GSAP timelines, CSS keyframes, Anime.js, WAAPI, FLIP, paths, masks, SVG morph/draw, text trails, cursor demos, 3D depth; plus `hyperframes keyframes` diagnostics for surfacing and verifying rendered motion.
- `/hyperframes-creative` — non-animation creative direction: `frame.md` / `design.md` handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns.
-- `/hyperframes-media` — audio + media: TTS voiceover, background music, sound effects, Whisper transcription, background removal, caption authoring (one shared `scripts/audio.mjs` engine, multi-provider).
-- `/media-use` — resolve any media need (BGM, SFX, image, icon) into a frozen local file + ledger record. One verb (`resolve`) over the HeyGen catalog with manifest tracking; keeps search noise on disk.
+- `/media-use` — the media OS: resolve any media need (BGM, SFX, image, icon, voice) into a frozen local file + ledger record; generate via TTS / music when the catalog misses; transcribe, remove backgrounds, and reuse assets across projects. One shared `scripts/audio.mjs` engine + manifest tracking; keeps search noise on disk.
- `/hyperframes-cli` — CLI dev loop: `init`, `add`, `lint`, `validate`, `inspect`, `preview`, `render`, `publish`, `doctor`, `lambda` (AWS Lambda cloud rendering).
- `/hyperframes-registry` — install and wire registry blocks and components into compositions via `hyperframes add`. Covers authoring a new block or component to contribute upstream.
- `/figma` — import Figma assets, tokens, components, and storyboard sections → reconstructed motion (frames read as states, not slides) (REST/CLI) plus Motion animations and shaders (MCP) into a composition.
@@ -49,7 +48,7 @@ When adding a new skill, or substantially renaming / repurposing an existing one
1. The skill list above (CLAUDE.md) AND the `## Skills` section in `README.md` AND `docs/guides/skills.mdx` (rendered at [hyperframes.heygen.com/guides/skills](https://hyperframes.heygen.com/guides/skills)). Out-of-date entries silently kill discovery.
2. If the skill changes the routing surface for "make a video" requests, also update the capability map and intent router in `skills/hyperframes/SKILL.md` — that's the canonical router agents read first.
3. Mirror the Router / Creation workflows / Domain skills grouping across all three surfaces so a skill always lives in the same column.
-4. Skill count appears in the README and CLAUDE.md intro lines ("21 AI agent skills…") — update on add/remove. The `docs/guides/skills.mdx` page deliberately omits a count to avoid drift; keep it count-free.
+4. Skill count appears in the README and CLAUDE.md intro lines ("20 AI agent skills…") — update on add/remove. The `docs/guides/skills.mdx` page deliberately omits a count to avoid drift; keep it count-free.
The skill's own `SKILL.md` frontmatter `description:` is the source of truth for the one-line "use when" blurb; copy from there into the catalog rather than paraphrasing.
diff --git a/README.md b/README.md
index ee9962c146..8c080c9396 100644
--- a/README.md
+++ b/README.md
@@ -49,9 +49,9 @@ The skills teach agents the HyperFrames production loop: plan the video, write v
## Skills
-HyperFrames ships 21 skills agents load on demand. Read `/hyperframes` first — it's the router and capability map; it picks a workflow for any "make me a video" request and points to the domain skills below.
+HyperFrames ships 20 skills agents load on demand. Read `/hyperframes` first — it's the router and capability map; it picks a workflow for any "make me a video" request and points to the domain skills below.
-Run `npx skills add heygen-com/hyperframes` for the interactive picker, `npx skills add heygen-com/hyperframes --all` to install all 21 at once (skips the picker), or `npx skills add heygen-com/hyperframes --skill <name>` for just one (bare name, no leading `/`).
+Run `npx skills add heygen-com/hyperframes` for the interactive picker, `npx skills add heygen-com/hyperframes --all` to install all 20 at once (skips the picker), or `npx skills add heygen-com/hyperframes --skill <name>` for just one (bare name, no leading `/`).
### Router
@@ -85,8 +85,7 @@ Atomic capabilities the creation workflows compose against — pull one when you
| `/hyperframes-animation` | All animation knowledge — atomic motion rules, scene blueprints, transitions, runtime adapters (GSAP / Lottie / Three.js / Anime.js / CSS / WAAPI / TypeGPU). |
| `/hyperframes-keyframes` | Seek-safe keyframe authoring across runtimes — GSAP timelines, CSS keyframes, Anime.js, WAAPI, FLIP, paths, masks, SVG morph/draw, 3D depth — plus `hyperframes keyframes` diagnostics for rendered motion. |
| `/hyperframes-creative` | Non-animation creative direction — `frame.md` / `design.md`, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns. |
-| `/hyperframes-media` | Audio + media — TTS voiceover, background music, sound effects, Whisper transcription, background removal, caption authoring (one shared audio engine). |
-| `/media-use` | Resolve any media need (BGM, SFX, image, icon) into a frozen local file + ledger record. One verb (`resolve`) over the HeyGen catalog with manifest tracking. |
+| `/media-use` | The media OS — resolve any media need (BGM, SFX, image, icon, voice) into a frozen local file + ledger record, generate via TTS/music when the catalog misses, transcribe, remove backgrounds, and reuse assets across projects. One shared audio engine + manifest tracking. |
| `/hyperframes-cli` | CLI dev loop — `init`, `lint`, `validate`, `inspect`, `preview`, `render`, `publish`, `doctor`, plus AWS Lambda cloud rendering (`lambda deploy / render / progress`). |
| `/hyperframes-registry` | Install and wire registry blocks and components into compositions via `hyperframes add`. Authoring a new block or component to contribute upstream. |
| `/figma` | Import Figma assets, tokens, components, and storyboard sections → reconstructed motion (frames read as states, not slides) (REST/CLI) plus Motion animations and shaders (MCP) into a composition. |
diff --git a/docs/guides/antigravity.mdx b/docs/guides/antigravity.mdx
index 7c3ebb77cb..292b588762 100644
--- a/docs/guides/antigravity.mdx
+++ b/docs/guides/antigravity.mdx
@@ -42,7 +42,7 @@ Antigravity uses **semantic matching** — when you type a prompt, the agent com
| "Create a 10-second product intro with captions" | `hyperframes`, `hyperframes-core` |
| "Add a GSAP scale-pop to the title" | `hyperframes-animation` |
| "Use Tailwind for styling" | `hyperframes-core` |
-| "Transcribe this audio and add captions" | `hyperframes-media` |
+| "Transcribe this audio and add captions" | `media-use` |
| "Add a shimmer sweep transition" | `hyperframes-registry` |
The skill is only injected into the agent's context window when it matches — this keeps the context clean and focused.
diff --git a/docs/guides/pipeline.mdx b/docs/guides/pipeline.mdx
index 7bd5b7b60b..c701ddb7ac 100644
--- a/docs/guides/pipeline.mdx
+++ b/docs/guides/pipeline.mdx
@@ -141,7 +141,7 @@ npx hyperframes transcribe narration.wav
| `narration.txt` | The exact spoken text with pronunciation substitutions applied (`API` → `A P I`, `$2T` → `two trillion`). Distinct from `SCRIPT.md` so you can regenerate the audio later with a different voice without redoing the substitutions. |
| `transcript.json`| `[{ text, start, end }]` for every word. Every later step reads this for timing. |
-Hyperframes ships multiple TTS adapters (Kokoro, ElevenLabs, HeyGen); see [`/hyperframes-media`](/guides/prompting) for the skill that picks one. After generating audio, update `STORYBOARD.md` with the real beat boundaries from `transcript.json`.
+Hyperframes ships multiple TTS adapters (Kokoro, ElevenLabs, HeyGen); see [`/media-use`](/guides/prompting) for the skill that picks one. After generating audio, update `STORYBOARD.md` with the real beat boundaries from `transcript.json`.
**Gate:** `narration.wav`, `narration.txt`, and `transcript.json` exist. `STORYBOARD.md` beat timings reference real timestamps, not estimates.
diff --git a/docs/guides/prompting.mdx b/docs/guides/prompting.mdx
index ac48079573..49907ccc6a 100644
--- a/docs/guides/prompting.mdx
+++ b/docs/guides/prompting.mdx
@@ -24,7 +24,7 @@ The installer shows a picker. Select the **core skills** below — every project
| `/hyperframes-animation`| All animation — motion rules, scene blueprints, transitions, and the runtime adapters (GSAP, Lottie, Three.js, Anime.js, CSS, WAAPI, TypeGPU) |
| `/hyperframes-creative` | Creative direction — design spec, palettes, typography, narration, beats |
| `/hyperframes-cli` | Dev-loop CLI — `init`, `lint`, `validate`, `inspect`, `preview`, `render`, `doctor` |
-| `/hyperframes-media` | Audio + media — TTS voiceover, BGM, SFX, transcription, background removal, caption authoring |
+| `/media-use` | Asset preprocessing — `tts`, `transcribe`, `remove-background` |
| `/hyperframes-registry` | Block and component installation via `hyperframes add` |
| `/general-video` | The general authoring workflow — fallback for any video that doesn't match a specific workflow below |
diff --git a/docs/guides/skills.mdx b/docs/guides/skills.mdx
index 0662b5d53d..b732d391d6 100644
--- a/docs/guides/skills.mdx
+++ b/docs/guides/skills.mdx
@@ -80,8 +80,7 @@ Atomic capabilities the creation workflows compose against — pull one when you
| `/hyperframes-animation` | All animation knowledge — atomic motion rules, scene blueprints, transitions, runtime adapters (GSAP / Lottie / Three.js / Anime.js / CSS / WAAPI / TypeGPU). |
| `/hyperframes-keyframes` | Seek-safe keyframe authoring across runtimes — GSAP timelines, CSS keyframes, Anime.js, WAAPI, FLIP, paths, masks, SVG morph/draw, 3D depth — plus `hyperframes keyframes` diagnostics for rendered motion. |
| `/hyperframes-creative` | Non-animation creative direction — `frame.md` / `design.md`, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns. |
-| `/hyperframes-media` | Audio + media — TTS voiceover, background music, sound effects, Whisper transcription, background removal, caption authoring (one shared audio engine). |
-| `/media-use` | Resolve any media need (BGM, SFX, image, icon) into a frozen local file + ledger record. One verb (`resolve`) over the HeyGen catalog with manifest tracking. |
+| `/media-use` | The media OS — resolve any media need (BGM, SFX, image, icon, voice) into a frozen local file + ledger record, generate via TTS/music when the catalog misses, transcribe, remove backgrounds, and reuse assets across projects. One shared audio engine + manifest tracking. |
| `/hyperframes-cli` | CLI dev loop — `init`, `lint`, `validate`, `inspect`, `preview`, `render`, `publish`, `doctor`, plus AWS Lambda cloud rendering (`lambda deploy / render / progress / destroy / policies`). |
| `/hyperframes-registry` | Install and wire registry blocks and components into compositions via `hyperframes add`. Authoring a new block or component to contribute upstream. |
| `/figma` | Import Figma assets, tokens, components, and storyboard sections → reconstructed motion (frames read as states, not slides) (REST/CLI) plus Motion animations and shaders (MCP) into a composition. |
diff --git a/docs/packages/cli.mdx b/docs/packages/cli.mdx
index 2d6363eb8d..eeca389245 100644
--- a/docs/packages/cli.mdx
+++ b/docs/packages/cli.mdx
@@ -932,7 +932,7 @@ Word-level transcripts (whisper output) are grouped into readable caption cues o
| `--codex` | Install to Codex CLI (`~/.codex/skills/`) |
| `--cursor` | Install to Cursor (`.cursor/skills/` in current project) |
- Skills are fetched from GitHub: the `/hyperframes` entry skill (routes "make me a video" to a workflow), the composition contract and Tailwind v4 browser-runtime guidance (`/hyperframes-core`), all animation including the GSAP / Anime.js / CSS / Lottie / Three.js / WAAPI / TypeGPU runtime adapters (`/hyperframes-animation`), creative direction (`/hyperframes-creative`), media preprocessing (`/hyperframes-media`), registry block/component wiring (`/hyperframes-registry`), and the video workflows. The `init` command also offers to install skills automatically after scaffolding a project.
+ Skills are fetched from GitHub: the `/hyperframes` entry skill (routes "make me a video" to a workflow), the composition contract and Tailwind v4 browser-runtime guidance (`/hyperframes-core`), all animation including the GSAP / Anime.js / CSS / Lottie / Three.js / WAAPI / TypeGPU runtime adapters (`/hyperframes-animation`), creative direction (`/hyperframes-creative`), media preprocessing (`/media-use`), registry block/component wiring (`/hyperframes-registry`), and the video workflows. The `init` command also offers to install skills automatically after scaffolding a project.
#### Troubleshooting: `fatal: active post-checkout hook found during git clone`
diff --git a/docs/quickstart.mdx b/docs/quickstart.mdx
index ce8e8ada59..af6fb3e448 100644
--- a/docs/quickstart.mdx
+++ b/docs/quickstart.mdx
@@ -22,7 +22,7 @@ The installer shows a picker. Select the **core set** every project needs — th
| `/hyperframes-animation` | All animation + the GSAP / Lottie / Three.js / Anime.js / CSS / WAAPI / TypeGPU runtime adapters |
| `/hyperframes-creative` | Design direction — palettes, typography, narration, beat planning |
| `/hyperframes-cli` | Dev-loop CLI — init, lint, preview, render, doctor |
-| `/hyperframes-media` | Asset preprocessing — TTS, transcription, background removal |
+| `/media-use` | Asset preprocessing — TTS, transcription, background removal |
| `/hyperframes-registry` | Install catalog blocks and components |
| `/general-video` | The general authoring workflow — the fallback for any video that doesn't match a specific workflow |
diff --git a/scripts/test-skills-fresh.sh b/scripts/test-skills-fresh.sh
index 6cac301e44..c57372d739 100755
--- a/scripts/test-skills-fresh.sh
+++ b/scripts/test-skills-fresh.sh
@@ -237,7 +237,7 @@ ROUTER="hyperframes"
WORKFLOWS=(product-launch-video website-to-video faceless-explainer embedded-captions \
talking-head-recut pr-to-video motion-graphics general-video \
remotion-to-hyperframes slideshow)
-DOMAIN=(hyperframes-core hyperframes-creative hyperframes-animation hyperframes-cli hyperframes-media hyperframes-registry)
+DOMAIN=(hyperframes-core hyperframes-creative hyperframes-animation hyperframes-cli media-use hyperframes-registry)
MISSING=()
check_skill() { if [[ -d "$SKILLS_DIR/$1" ]]; then ok "$SKILLS_DIR/$1/"; else MISSING+=("$1"); fi; }
diff --git a/skills-manifest.json b/skills-manifest.json
index bcd3f0d47e..f0ca9ef95c 100644
--- a/skills-manifest.json
+++ b/skills-manifest.json
@@ -2,11 +2,11 @@
"source": "heygen-com/hyperframes",
"skills": {
"embedded-captions": {
- "hash": "62aec45830eda54b",
+ "hash": "1cf326d503115227",
"files": 144
},
"faceless-explainer": {
- "hash": "6dac80491c3db278",
+ "hash": "868057217d0499e8",
"files": 18
},
"figma": {
@@ -14,23 +14,23 @@
"files": 1
},
"general-video": {
- "hash": "a30225e30ec7b06c",
+ "hash": "d30096cfc7bd5db2",
"files": 1
},
"hyperframes": {
- "hash": "e4e2f137d492c6d7",
+ "hash": "c52186059c9796ae",
"files": 1
},
"hyperframes-animation": {
- "hash": "19024009fab8e5d1",
+ "hash": "6323b750d67287e9",
"files": 116
},
"hyperframes-cli": {
- "hash": "9b36a367a0e3a332",
+ "hash": "9f9fa8d0cf3ef9e2",
"files": 7
},
"hyperframes-core": {
- "hash": "50ed383eb88a58b6",
+ "hash": "afea2e8bb200ee71",
"files": 13
},
"hyperframes-creative": {
@@ -41,32 +41,28 @@
"hash": "47f20312033792c3",
"files": 3
},
- "hyperframes-media": {
- "hash": "56190192ead45ed1",
- "files": 47
- },
"hyperframes-registry": {
"hash": "e3b389526834109d",
"files": 10
},
"media-use": {
- "hash": "75dda0086dda18ce",
- "files": 19
+ "hash": "969e6ed350111d63",
+ "files": 87
},
"motion-graphics": {
- "hash": "be1d1f159d5eb0e4",
+ "hash": "73771b2d1300236d",
"files": 23
},
"music-to-video": {
- "hash": "0c5738fac0fe622f",
+ "hash": "84295adeeebcf923",
"files": 132
},
"pr-to-video": {
- "hash": "d40ba25aa5af30e1",
+ "hash": "0bc51f6ba74b2bfd",
"files": 22
},
"product-launch-video": {
- "hash": "b1895d518ec04da5",
+ "hash": "40bfb0bf49ae17cd",
"files": 20
},
"remotion-to-hyperframes": {
@@ -82,7 +78,7 @@
"files": 27
},
"website-to-video": {
- "hash": "ac39931f9a7da749",
+ "hash": "813dc861e4214a35",
"files": 32
}
}
diff --git a/skills/embedded-captions/modes/standard/_anatomy.md b/skills/embedded-captions/modes/standard/_anatomy.md
index 234f71c84e..0eb3fa0232 100644
--- a/skills/embedded-captions/modes/standard/_anatomy.md
+++ b/skills/embedded-captions/modes/standard/_anatomy.md
@@ -226,7 +226,7 @@ The gallery used a `setInterval` loop; HyperFrames needs the same beats as **abs
## Pairs with HF skills
-- `hyperframes-media` — `remove-background` (the matte) + `transcribe` (word timings).
+- `media-use` — `remove-background` (the matte) + `transcribe` (word timings).
- `hyperframes-captions` — transcript consumption, grouping, positioning, exit guarantees, `fitTextFontSize`.
- `hyperframes-animation/rules/asr-keyword-glow.md` — the verbatim active-word envelope.
- `hyperframes-gsap` — single paused timeline, transform aliases, ease palette.
diff --git a/skills/embedded-captions/references/rail.md b/skills/embedded-captions/references/rail.md
index 1f676f724d..580380bab0 100644
--- a/skills/embedded-captions/references/rail.md
+++ b/skills/embedded-captions/references/rail.md
@@ -10,7 +10,7 @@ with only the climax(es) promoted to embed. Rail is not a fallback — it's the
> **Implementation note.** A dedicated rail renderer is the next build step. The rail is a
> plain `fg` caption track and maps cleanly onto hyperframes' native caption pipeline
-> (`hyperframes-media` captions) — prefer reusing that over hand-rolling. Until wired, render
+> (`media-use` captions) — prefer reusing that over hand-rolling. Until wired, render
> the rail as a simple `data-caption-layer="fg"` composition (no matte overlay for these caps).
## Position & safe area
diff --git a/skills/embedded-captions/scripts/transcribe.cjs b/skills/embedded-captions/scripts/transcribe.cjs
index 8185759747..5775d2b827 100644
--- a/skills/embedded-captions/scripts/transcribe.cjs
+++ b/skills/embedded-captions/scripts/transcribe.cjs
@@ -110,7 +110,7 @@ function main() {
console.error("usage: transcribe.cjs <project-dir> [model] [language]");
process.exit(1);
}
- // Default = multilingual `small`, NOT `small.en`. Per hyperframes-media: ".en models
+ // Default = multilingual `small`, NOT `small.en`. Per media-use: ".en models
// mistranslate non-English and mis-handle accented speech; default to small (auto-detects
// language)." We hardcoded small.en before — it hallucinated a wrong transcript on an
// accented speaker. Pass `small.en` only for known-clean-English; tough accents → a larger model.
diff --git a/skills/faceless-explainer/SKILL.md b/skills/faceless-explainer/SKILL.md
index 6a80d44e9e..4d0d7a2512 100644
--- a/skills/faceless-explainer/SKILL.md
+++ b/skills/faceless-explainer/SKILL.md
@@ -25,7 +25,7 @@ Initialize only if `hyperframes.json` is missing. Name `<project>` from the topi
`npx hyperframes init "videos/<project>" --non-interactive --example=blank` — `init` checks the installed skills against the latest on GitHub and updates the global set if any are out of date.
-**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../hyperframes-media` → Preflight for the canonical guidance.
+**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../media-use` → Preflight for the canonical guidance.
**Gate:** `hyperframes.json` exists, and angle, length, aspect ratio, and language are locked; sign-in status was shown (signed in, or continuing offline).
@@ -88,7 +88,7 @@ Start audio after Step 3 approval. Run it in the background, then continue to St
`node <SKILL_DIR>/scripts/audio.mjs --script ./SCRIPT.md --storyboard ./STORYBOARD.md --hyperframes . --out ./audio_meta.json &`
-The audio script handles narration, word timings, BGM lookup from HeyGen's music library, and timing metadata. BGM mood comes from the storyboard's `music:` field. This uses the HeyGen Audio API for retrieval, not generation, and the same `~/.heygen` credential as TTS. For provider details, read `../hyperframes-media/references/tts.md`.
+The audio script handles narration, word timings, BGM lookup from HeyGen's music library, and timing metadata. BGM mood comes from the storyboard's `music:` field. This uses the HeyGen Audio API for retrieval, not generation, and the same `~/.heygen` credential as TTS. For provider details, read `../media-use/audio/references/tts.md`.
If there is no narration and no `SCRIPT.md`, skip voice generation. BGM may still run if the storyboard has a music mood.
@@ -200,7 +200,7 @@ The reusable, domain-agnostic shot shapes live in `../hyperframes-animation/blue
| `[../hyperframes-animation/blueprints-index.md](../hyperframes-animation/blueprints-index.md)` | Step 3: role→blueprint menu. Step 4: pick the shot shape. |
| `[../hyperframes-core/references/storyboard-format.md](../hyperframes-core/references/storyboard-format.md)` | Step 3: write `STORYBOARD.md`. |
| `[../hyperframes-core/references/script-format.md](../hyperframes-core/references/script-format.md)` | Step 3: write `SCRIPT.md`. |
-| `[../hyperframes-media/references/tts.md](../hyperframes-media/references/tts.md)` | Step 3.1: choose or understand TTS providers and voices. |
+| `[../media-use/audio/references/tts.md](../media-use/audio/references/tts.md)` | Step 3.1: choose or understand TTS providers and voices. |
| `[references/visual-design.md](references/visual-design.md)` | Step 4: write the frame's shot sequence (+ Layout vocabulary). |
| `[references/motion-language.md](references/motion-language.md)` | Step 4: the motion vocabulary + the motion doctrine. |
| `[references/cut-catalog.md](references/cut-catalog.md)` | Step 4-5: the cut catalog (worker builds within-frame seams). |
diff --git a/skills/faceless-explainer/scripts/audio.mjs b/skills/faceless-explainer/scripts/audio.mjs
index f1f9df1b97..864e66214f 100644
--- a/skills/faceless-explainer/scripts/audio.mjs
+++ b/skills/faceless-explainer/scripts/audio.mjs
@@ -1,12 +1,14 @@
#!/usr/bin/env node
-// audio.mjs — faceless-explainer audio ADAPTER. The TTS / BGM / SFX implementation
+// audio.mjs — audio ADAPTER (reuses the product-launch SCRIPT.md / STORYBOARD.md
+// model; this file is intentionally identical across the reusing skills). The
+// TTS / BGM / SFX implementation
// no longer lives here: it is the shared engine at
-// ../../hyperframes-media/scripts/audio.mjs. This file only (a) maps the
-// frame model (SCRIPT.md frames + STORYBOARD.md music/sfx) into the
+// ../../media-use/audio/scripts/audio.mjs. This file only (a) maps the
+// product-launch model (SCRIPT.md frames + STORYBOARD.md music/sfx) into the
// engine's neutral audio_request.json, (b) converts the engine's id-keyed
// audio_meta back into the frame-keyed shape captions.mjs / assemble-index.mjs
// already consume, and (c) keeps the local `sync-durations` pass (it rewrites
-// STORYBOARD.md, which is this skill's concern).
+// STORYBOARD.md, which is product-launch-specific).
//
// Three modes (unchanged CLI surface):
// (default) generate — engine --only tts,bgm. BGM mode is "retrieve" (strict:
@@ -27,7 +29,7 @@ import { fileURLToPath } from "node:url";
import { parseStoryboard } from "./lib/storyboard.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
-const DEFAULT_ENGINE = join(HERE, "..", "..", "hyperframes-media", "scripts", "audio.mjs");
+const DEFAULT_ENGINE = join(HERE, "..", "..", "media-use", "audio", "scripts", "audio.mjs");
const flag = (argv, name, def) => {
const i = argv.indexOf(`--${name}`);
@@ -86,9 +88,9 @@ function runEngine({ request, hyperframesDir, neutral, only, extra = [] }, die)
if (r.status !== 0) die(`media audio engine exited ${r.status}`);
}
-// Engine neutral meta (id-keyed) → frame-keyed meta consumed by
+// Engine neutral meta (id-keyed) → product-launch meta (frame-keyed) consumed by
// captions.mjs / assemble-index.mjs. id is the zero-padded frame number.
-function toFrameKeyedMeta(neutral) {
+function toProductLaunchMeta(neutral) {
const voices = (neutral.voices ?? []).map((v) => ({
frame: Number(v.id),
path: v.path,
@@ -152,7 +154,7 @@ function runGenerate(argv) {
const neutral = neutralPath(outPath);
runEngine({ request, hyperframesDir, neutral, only: "tts,bgm" }, die);
- const meta = toFrameKeyedMeta(JSON.parse(readFileSync(neutral, "utf8")));
+ const meta = toProductLaunchMeta(JSON.parse(readFileSync(neutral, "utf8")));
writeFileSync(outPath, JSON.stringify(meta, null, 2));
console.log(
`✓ audio generate: ${meta.voices.length} voice + ${meta.bgm ? "1 bgm" : "no bgm"} → ${outPath}`,
@@ -189,7 +191,7 @@ function runFetchSfx(argv) {
// voices/bgm written by the earlier generate (--only tts,bgm) pass are preserved.
runEngine({ request, hyperframesDir, neutral, only: "sfx" }, die);
- const meta = toFrameKeyedMeta(JSON.parse(readFileSync(neutral, "utf8")));
+ const meta = toProductLaunchMeta(JSON.parse(readFileSync(neutral, "utf8")));
writeFileSync(outPath, JSON.stringify(meta, null, 2));
console.log(`✓ audio fetch-sfx: ${meta.sfx.length} SFX cue(s) → ${outPath}`);
}
diff --git a/skills/general-video/SKILL.md b/skills/general-video/SKILL.md
index 2a4b5d376c..c3f1975b38 100644
--- a/skills/general-video/SKILL.md
+++ b/skills/general-video/SKILL.md
@@ -96,24 +96,24 @@ Never use `position: absolute; top: Npx` on a content container — it overflows
## Build — delegate to the domain skills
-This maps the skill's full surface (see the `description`) to its references — non-exhaustive; when an intent isn't listed, route through `hyperframes-creative` (look/concept), `hyperframes-animation` (motion), `hyperframes-core` (contract), `hyperframes-media` (audio/captions). **The first row is ADDITIVE — read it AND your intent row, not one or the other.**
-
-| Building… | Read first (in order) |
-| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| **ALWAYS — every non-trivial piece, on top of your intent row below** | `hyperframes-creative/references/house-style.md` + `references/video-composition.md` (also gated in Step 1 / HARD-GATE; the "produced, not generated" foreground detailing) |
-| **Kinetic typography / text-forward** | `hyperframes-animation/techniques.md` (kinetic type) + `adapters/gsap-easing-and-stagger.md` + `rules/kinetic-beat-slam.md` |
-| **Title card / lower-third / overlay / PiP / text-behind-subject** | `hyperframes-creative/references/composition-patterns.md` + (for the centered/sized frame) `hyperframes-core` → "Root must be sized" |
-| **Logo / brand-mark reveal** | `hyperframes-animation/rules/svg-path-draw.md` (draw-on) + `rules/3d-text-depth-layers.md` + `rules/scale-swap-transition.md` |
-| **Data / stats / numbers** | `hyperframes-animation/rules/counting-dynamic-scale.md` + `rules/stat-bars-and-fills.md` + `hyperframes-creative/references/data-in-motion.md` |
-| **Product / app / UI demo** | `hyperframes-animation/rules/3d-page-scroll.md` + `rules/cursor-click-ripple.md` + `rules/press-release-spring.md` |
-| **Audio-reactive / music-driven** | `hyperframes-creative/references/audio-reactive.md` (pre-extract bands; map to motion) |
-| **Narrated / voiceover / music / SFX / captions** | `hyperframes-media` → the shared audio engine `scripts/audio.mjs` (one call = TTS + BGM + SFX → `audio_meta.json`); caption authoring + asset placement via `hyperframes-core`. See **Audio** below. |
-| **Multi-scene / transitions** | `hyperframes-animation/transitions/overview.md` **then** `transitions/catalog.md` (you are not done after the overview — the GSAP recipe is in the catalog) |
-| **Modular / sub-compositions** | `hyperframes-core/references/composition-patterns.md` + `references/sub-compositions.md` |
+This maps the skill's full surface (see the `description`) to its references — non-exhaustive; when an intent isn't listed, route through `hyperframes-creative` (look/concept), `hyperframes-animation` (motion), `hyperframes-core` (contract), `media-use` (audio/captions). **The first row is ADDITIVE — read it AND your intent row, not one or the other.**
+
+| Building… | Read first (in order) |
+| --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **ALWAYS — every non-trivial piece, on top of your intent row below** | `hyperframes-creative/references/house-style.md` + `references/video-composition.md` (also gated in Step 1 / HARD-GATE; the "produced, not generated" foreground detailing) |
+| **Kinetic typography / text-forward** | `hyperframes-animation/techniques.md` (kinetic type) + `adapters/gsap-easing-and-stagger.md` + `rules/kinetic-beat-slam.md` |
+| **Title card / lower-third / overlay / PiP / text-behind-subject** | `hyperframes-creative/references/composition-patterns.md` + (for the centered/sized frame) `hyperframes-core` → "Root must be sized" |
+| **Logo / brand-mark reveal** | `hyperframes-animation/rules/svg-path-draw.md` (draw-on) + `rules/3d-text-depth-layers.md` + `rules/scale-swap-transition.md` |
+| **Data / stats / numbers** | `hyperframes-animation/rules/counting-dynamic-scale.md` + `rules/stat-bars-and-fills.md` + `hyperframes-creative/references/data-in-motion.md` |
+| **Product / app / UI demo** | `hyperframes-animation/rules/3d-page-scroll.md` + `rules/cursor-click-ripple.md` + `rules/press-release-spring.md` |
+| **Audio-reactive / music-driven** | `hyperframes-creative/references/audio-reactive.md` (pre-extract bands; map to motion) |
+| **Narrated / voiceover / music / SFX / captions** | `media-use` → the shared audio engine `scripts/audio.mjs` (one call = TTS + BGM + SFX → `audio_meta.json`); caption authoring + asset placement via `hyperframes-core`. See **Audio** below. |
+| **Multi-scene / transitions** | `hyperframes-animation/transitions/overview.md` **then** `transitions/catalog.md` (you are not done after the overview — the GSAP recipe is in the catalog) |
+| **Modular / sub-compositions** | `hyperframes-core/references/composition-patterns.md` + `references/sub-compositions.md` |
### Audio: one engine (TTS · BGM · SFX)
-Only when the piece calls for it (per "build exactly what was asked" — no ambient music on a title card). Don't hand-roll TTS or vendor a copy: write a neutral `audio_request.json` and call the shared engine in `hyperframes-media`. It auto-degrades on one switch — HeyGen credential present → HeyGen TTS + music/SFX **retrieval**; absent → ElevenLabs/Kokoro TTS, Lyria/MusicGen BGM **generation**, and the bundled SFX library. Full flag list + request/meta schema: the header comment of `hyperframes-media/scripts/audio.mjs`.
+Only when the piece calls for it (per "build exactly what was asked" — no ambient music on a title card). Don't hand-roll TTS or vendor a copy: write a neutral `audio_request.json` and call the shared engine in `media-use`. It auto-degrades on one switch — HeyGen credential present → HeyGen TTS + music/SFX **retrieval**; absent → ElevenLabs/Kokoro TTS, Lyria/MusicGen BGM **generation**, and the bundled SFX library. Full flag list + request/meta schema: the header comment of `media-use/audio/scripts/audio.mjs`.
```jsonc
// audio_request.json — one line per narrated segment; `id` is yours (joins audio_meta back)
@@ -127,11 +127,11 @@ Only when the piece calls for it (per "build exactly what was asked" — no ambi
```
```bash
-# <MEDIA_DIR> = the installed hyperframes-media skill dir (sibling of this skill)
+# <MEDIA_DIR> = the installed media-use skill dir (sibling of this skill)
node <MEDIA_DIR>/scripts/audio.mjs --request ./audio_request.json --hyperframes . --out ./audio_meta.json
```
-Then read `audio_meta.json`: mount each `voices[].path` + (`bgm.path`, `sfx[]`) as `<audio>` tracks and use `voices[].words` for captions, all per `hyperframes-core` (audio tracks + caption authoring). If BGM took the generate path (`bgm_pending: true`), run `hyperframes-media/scripts/wait-bgm.mjs` before final render.
+Then read `audio_meta.json`: mount each `voices[].path` + (`bgm.path`, `sfx[]`) as `<audio>` tracks and use `voices[].words` for captions, all per `hyperframes-core` (audio tracks + caption authoring). If BGM took the generate path (`bgm_pending: true`), run `media-use/audio/scripts/wait-bgm.mjs` before final render.
## Output checklist → `hyperframes-cli`
diff --git a/skills/hyperframes-animation/rules/asr-keyword-glow.md b/skills/hyperframes-animation/rules/asr-keyword-glow.md
index 5c59cead7d..aca91047eb 100644
--- a/skills/hyperframes-animation/rules/asr-keyword-glow.md
+++ b/skills/hyperframes-animation/rules/asr-keyword-glow.md
@@ -280,7 +280,7 @@ Ease family — discrete choice:
## Pairs with HF skills
- `/hyperframes-animation` — single driver, multi-element envelope
-- `/hyperframes-media` — `hyperframes transcribe` outputs real ASR data
-- `/hyperframes-media` — pair with caption rendering
+- `/media-use` — `hyperframes transcribe` outputs real ASR data
+- `/media-use` — pair with caption rendering
- `/hyperframes-core` — composition wiring
- `/hyperframes-cli` — `hyperframes lint`
diff --git a/skills/hyperframes-cli/SKILL.md b/skills/hyperframes-cli/SKILL.md
index dbcab763c3..62cddf51c0 100644
--- a/skills/hyperframes-cli/SKILL.md
+++ b/skills/hyperframes-cli/SKILL.md
@@ -56,7 +56,7 @@ Cross-cutting rules that hold for every command:
- **Tailwind projects** (`init --tailwind`) → use `hyperframes-core` (Tailwind reference) before editing classes or theme tokens.
- **Registry blocks/components** (`hyperframes add`, `hyperframes catalog`) → use `hyperframes-registry` for install paths, sub-composition wiring, and snippet merging.
-- **Asset preprocessing** (`tts`, `transcribe`, `remove-background`) → use `hyperframes-media` for voice selection, Whisper model rules, captions, and TTS-to-captions chain.
+- **Asset preprocessing** (`tts`, `transcribe`, `remove-background`) → use `media-use` for voice selection, Whisper model rules, captions, and TTS-to-captions chain.
- **Parametrized renders** (`--variables`) → declared via `data-composition-variables` on `<html>`; see `hyperframes-core` for the full schema.
## Lambda (Cloud Rendering)
diff --git a/skills/hyperframes-cli/references/init-and-scaffold.md b/skills/hyperframes-cli/references/init-and-scaffold.md
index 6c319f1cf2..bfd327aa5f 100644
--- a/skills/hyperframes-cli/references/init-and-scaffold.md
+++ b/skills/hyperframes-cli/references/init-and-scaffold.md
@@ -27,7 +27,7 @@ Other useful flags:
When using `--tailwind`, invoke the `hyperframes-core` (Tailwind reference) skill before editing classes or theme tokens. The scaffold uses Tailwind v4 browser runtime patterns, not Studio's Tailwind v3 setup.
-When `--audio` or `--video` is supplied, `init` transcribes the file with Whisper. For voice/model selection see the `hyperframes-media` skill.
+When `--audio` or `--video` is supplied, `init` transcribes the file with Whisper. For voice/model selection see the `media-use` skill.
## capture
diff --git a/skills/hyperframes-cli/references/upgrade-info-misc.md b/skills/hyperframes-cli/references/upgrade-info-misc.md
index 8ad73809b6..89d72034de 100644
--- a/skills/hyperframes-cli/references/upgrade-info-misc.md
+++ b/skills/hyperframes-cli/references/upgrade-info-misc.md
@@ -72,4 +72,4 @@ npx hyperframes remove-background
These produce assets (narration audio, word-level transcripts, transparent video) that get dropped into a composition. Each may download its own model on first run.
-For voice selection, Whisper model rules, output format choice, and the TTS → transcript → captions chain, invoke the `hyperframes-media` skill. This skill stays focused on the dev loop.
+For voice selection, Whisper model rules, output format choice, and the TTS → transcript → captions chain, invoke the `media-use` skill. This skill stays focused on the dev loop.
diff --git a/skills/hyperframes-core/SKILL.md b/skills/hyperframes-core/SKILL.md
index 47e7ad019d..1e33a6b75c 100644
--- a/skills/hyperframes-core/SKILL.md
+++ b/skills/hyperframes-core/SKILL.md
@@ -7,7 +7,7 @@ description: The HyperFrames composition contract — build one renderable proje
HyperFrames renders video from HTML. A composition is an HTML file whose DOM declares timing with `data-*` attributes, whose animation runtime is seekable, and whose media playback is owned by the framework.
-This skill is the **technical contract** — how to build one hyperframes project. The body below is the build guide; per-topic detail lives in `references/` (index next), read on demand. Other concerns live in the sibling domain skills — `hyperframes-animation`, `hyperframes-creative`, `hyperframes-media`, `hyperframes-cli`, `hyperframes-registry`. The capability map in `/hyperframes` says what each one covers.
+This skill is the **technical contract** — how to build one hyperframes project. The body below is the build guide; per-topic detail lives in `references/` (index next), read on demand. Other concerns live in the sibling domain skills — `hyperframes-animation`, `hyperframes-creative`, `media-use`, `hyperframes-cli`, `hyperframes-registry`. The capability map in `/hyperframes` says what each one covers.
## References
diff --git a/skills/hyperframes-core/references/script-format.md b/skills/hyperframes-core/references/script-format.md
index 18e003c77b..1946bf9a37 100644
--- a/skills/hyperframes-core/references/script-format.md
+++ b/skills/hyperframes-core/references/script-format.md
@@ -2,7 +2,7 @@
The **locked narration** for a project: the final spoken lines + voice + delivery. It is an _optional_ plan-layer file — a video with no narration (bgm-only, silent overlay) has none. The storyboard's per-frame `voiceover` is the lighter, editable _guide_; `SCRIPT.md` is the _commit_. (Storyboard format → `references/storyboard-format.md`.)
-This file defines the SCRIPT.md **shape** only. Synthesizing the spoken lines into audio is a capability owned by `hyperframes-media` → `references/tts.md`.
+This file defines the SCRIPT.md **shape** only. Synthesizing the spoken lines into audio is a capability owned by `media-use` → `references/tts.md`.
Free-form markdown — there is no strict parser; the Studio renders it read-only beside the Storyboard board, and the TTS step extracts the indented spoken lines.
@@ -46,4 +46,4 @@ A header block, then one section per spoken line.
## To TTS
-Feed each line's spoken text to `npx hyperframes tts` (pin `--voice` / `--provider` from the header; capture word timestamps for captions). Real per-word timing replaces the `**Time:**` guides. CLI contract → `hyperframes-media/references/tts.md`.
+Feed each line's spoken text to `npx hyperframes tts` (pin `--voice` / `--provider` from the header; capture word timestamps for captions). Real per-word timing replaces the `**Time:**` guides. CLI contract → `media-use/audio/references/tts.md`.
diff --git a/skills/hyperframes-media/SKILL.md b/skills/hyperframes-media/SKILL.md
deleted file mode 100644
index 33d77eb67d..0000000000
--- a/skills/hyperframes-media/SKILL.md
+++ /dev/null
@@ -1,97 +0,0 @@
----
-name: hyperframes-media
-description: Audio and media assets for HyperFrames compositions, produced by one shared audio engine (`scripts/audio.mjs`) — multi-provider TTS (HeyGen / ElevenLabs / Kokoro local), background music + sound effects (HeyGen audio-library retrieval by default, with local Lyria / MusicGen BGM generation and a bundled SFX library as the no-credential fallback), Whisper transcription, background removal, and caption authoring. Use for voiceover / TTS, BGM, SFX / sound effects, transcription, captions / subtitles / lyrics / karaoke / per-word styling, voice + provider selection, and music-mood prompting.
----
-
-# HyperFrames Media
-
-Create the audio and media assets a composition needs — voiceover (TTS), background music + sound effects, transcription, captions, background removal — then consume and animate that data in HTML. For placing assets into compositions, see `hyperframes-core`.
-
-## The audio engine — one source for TTS · BGM · SFX
-
-Workflows do NOT hand-roll audio or vendor a copy. There is one engine — **`scripts/audio.mjs`** — that takes a neutral `audio_request.json` and writes `audio_meta.json` (plus assets under `assets/voice|bgm|sfx`):
-
-```bash
-# <MEDIA_DIR> = this skill's directory
-node <MEDIA_DIR>/scripts/audio.mjs --request ./audio_request.json --hyperframes . --out ./audio_meta.json
-```
-
-All three capabilities degrade on **ONE switch** — whether a HeyGen credential is present (resolved from `$HEYGEN_API_KEY` / `$HYPERFRAMES_API_KEY` / `~/.heygen`, **not** the CLI):
-
-| Capability | HeyGen credential present | absent |
-| ---------- | -------------------------------------------------- | ---------------------------------------------------- |
-| TTS | HeyGen Starfish REST (native word timestamps) | → ElevenLabs → Kokoro (chain `transcribe` for words) |
-| BGM | HeyGen music **retrieval** | Lyria → MusicGen local **generation** (detached) |
-| SFX | HeyGen sound-effects **retrieval** (min_score 0.4) | bundled 21-file library (`assets/sfx/`) |
-
-- **Request** (`audio_request.json`): `{ provider?, lang?, speed?, lines: [{ id, text, sfx?: [names] }], bgm: { mode?, query?, prompt? } }`. `id` joins each line back to the caller's model (a frame number, a scene id, …). `bgm.mode` = `retrieve | generate | none`; omit for auto (retrieve when credentialed, else generate). An **explicit** `retrieve` is strict — it skips rather than starting a detached generate (for callers with no `wait-bgm` step).
-- **Output** (`audio_meta.json`, id-keyed): `{ tts_provider, voice_id, bgm, bgm_pending, …, voices: [{ id, path, duration_s, words }], sfx: [{ id, name, file, source, offset_s, duration_s, volume }], total_duration_s }`.
-- `--only tts,bgm,sfx` runs a subset and **merges** into an existing `--out` (e.g. TTS+BGM early, SFX once cues exist).
-- BGM generate is spawned **detached** (`bgm_pending: true`) — run `scripts/wait-bgm.mjs` before assembling.
-- `scripts/heygen-tts.mjs` is a single-shot CLI over the same code (one text → wav + words) for when you just need HeyGen TTS without a request file.
-
-Full flag list + the `audio_meta.json` schema live in the header of `scripts/audio.mjs`. The references below cover the provider details and edge cases behind each capability.
-
-## Preflight — show sign-in status before any audio
-
-**Always run this before generating voice or BGM — inside a full workflow _or_ a one-off "generate me a BGM/voiceover" request.** No HeyGen credential is **not** a reason to silently fall back to local engines: first recommend signing in and let the user decide. Run the shared preflight and **relay its output verbatim** — don't improvise your own "missing key" prompt, and don't offer to write keys into a per-repo `.env`:
-
-```bash
-npx hyperframes auth status
-```
-
-- **Signed in** → it prints the account; proceed.
-- **Not signed in** (`exit 1` is expected here — "not signed in" is a normal state, not a failure) → it prints registration-first guidance. Recommend signing in: `npx hyperframes auth login` is browser OAuth — it **signs in and creates an account** (always available through this repo's CLI). To use an existing HeyGen API key (from app.heygen.com/settings/api), run `npx hyperframes auth login --api-key` — it saves to the shared `~/.heygen` (no per-repo `.env`). The output also lists the local engines voice/BGM will fall back to and a `pip` hint when deps are missing. **Relay this output as-is — don't paraphrase it into your own wording.** Then **STOP and wait** for the user to choose — sign in, or say "go" / "local" to continue offline — **before generating anything.** This is a real decision point, not a passing note: don't fold it into another question, and don't proceed past it on your own. (Exception: in autonomous / non-interactive mode, note the status and continue offline.)
-- `npx hyperframes auth status --json` returns `{ configured, recommended_action, offline_engines }` for deterministic branching.
-- **If the CLI can't run** (not on PATH and `npx` can't fetch it) → still **recommend signing in** (`npx hyperframes auth login`) and **STOP for the user's choice** — don't treat "no credential" as a silent green light for local generation.
-
-Credential resolution, full key priority, and the local-dependency list are in `references/requirements.md`.
-
-## Provider chains (the detail behind the engine)
-
-**TTS** — first available provider wins (the engine, or `npx hyperframes tts "..."`):
-
-| Order | Provider | Detected when | Word timestamps |
-| ----- | ----------------------------- | -------------------------------------------- | ---------------------------------------------------------------- |
-| 1 | HeyGen (Starfish) | `$HEYGEN_API_KEY` / `hyperframes auth login` | **Yes, native** — pass `--words narration.words.json` to capture |
-| 2 | ElevenLabs | `$ELEVENLABS_API_KEY` set | No — chain `transcribe` after |
-| 3 | Kokoro-82M (local, 54 voices) | always (no key required) | No — chain `transcribe` after |
-
-> The published `hyperframes tts` CLI is often the local-only build (its `--help` says "Kokoro-82M", no `--provider`/`--words`) and silently falls back to Kokoro even with `$HEYGEN_API_KEY` set. That is why the engine's HeyGen path is the self-contained `scripts/heygen-tts.mjs` (REST), NOT the CLI; the CLI is used only for the Kokoro path. See `references/tts.md`.
-
-**BGM & SFX** — by default **retrieved** from the HeyGen audio library (`/v3/audio/sounds`), same credential as HeyGen TTS, with the no-credential fallback from the switch above:
-
-| Asset | HeyGen `type` | Lands in | Fallback (no credential) |
-| ----- | ------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
-| BGM | `music` | `assets/bgm/track.mp3` (retrieve) · `track.wav` (generate) | Lyria / MusicGen generation |
-| SFX | `sound_effects` (min_score 0.4) | `assets/sfx/<slug>.mp3` | bundled 21-file library (`assets/sfx/*` + `manifest.json`) |
-
-See `references/bgm.md` and `references/sfx.md`.
-
-## Routing
-
-| Task | Read |
-| ------------------------------------------------------------------- | -------------------------------------------- |
-| The audio engine — request/meta schema, `--only`, the switch | `scripts/audio.mjs` (header comment) |
-| `npx hyperframes tts` / `heygen-tts.mjs` — providers, voices, words | `references/tts.md` |
-| BGM — HeyGen retrieval + local Lyria / MusicGen generation | `references/bgm.md` |
-| SFX — HeyGen retrieval (min_score 0.4) + bundled local library | `references/sfx.md` |
-| `npx hyperframes transcribe` — Whisper, model rules, output shape | `references/transcribe.md` |
-| `npx hyperframes remove-background` — transparent cutouts | `references/remove-background.md` |
-| TTS → transcription → captions (no recorded voiceover) | `references/tts-to-captions.md` |
-| Caption authoring — style detection, layout, word grouping, exit | `references/captions/authoring.md` |
-| Transcript handling — input formats, quality gates, cleanup, APIs | `references/captions/transcript-handling.md` |
-| Caption motion — karaoke, marker effects, audio-reactive | `references/captions/motion.md` |
-| Model caches, system dependencies, troubleshooting | `references/requirements.md` |
-
-## Non-negotiable rules
-
-- **One engine, no vendored copies.** Produce audio via `scripts/audio.mjs` (or `heygen-tts.mjs` for one-shot HeyGen TTS). Don't re-implement TTS/BGM/SFX inside a workflow — write an `audio_request.json` adapter and call the engine.
-- **"HeyGen available" = a resolvable credential, not the CLI.** The whole switch keys off `heygenCredential()`; the published `hyperframes tts` may be Kokoro-only, and there is no `hyperframes bgm` / `hyperframes sfx` command at all.
-- **Voice IDs are provider-specific.** `am_michael` is Kokoro-only; HeyGen UUIDs don't work on Kokoro. If you pass `--voice`, also pin `--provider` to avoid silent provider drift when the user's env changes.
-- **Always pass `--model` to `transcribe`.** The CLI default `small.en` silently translates non-English audio. See `references/transcribe.md` → "Language Rule".
-- **HeyGen returns word timestamps; ElevenLabs / Kokoro do not.** The engine chains `transcribe` automatically for the latter two; standalone, pass `--words` to HeyGen or run `transcribe` against the audio file.
-- **Captions consume the flat word-array format** with `{ id, text, start, end }`. See `references/transcribe.md` → "Output Shape".
-- **`remove-background --background-output` is hole-cut, not inpainted.** For "scene without the person", a different tool is needed. See `references/remove-background.md` → "When NOT the right tool".
-- **BGM/SFX default to HeyGen retrieval; the no-credential fallback is generation (BGM) or the bundled library (SFX).** `/audio/sounds` ranks by a text query — name effects concretely (`glass shatter`, not `dramatic sound`); a no-match **skips**, never blocks the render. SFX sit at volume ~0.35 under voice + BGM. See `references/sfx.md` / `references/bgm.md`.
-- **Treat workflow caption HTML as generated output.** For preset-backed videos, the reusable skin source lives at `.hyperframes/caption-skin.html` and the workflow script writes `compositions/captions.html`; do not edit generated `compositions/captions.html` to fix the skin. Rebuild via the workflow's `captions.mjs`, or use that workflow's explicit overrides mechanism when present.
diff --git a/skills/hyperframes/SKILL.md b/skills/hyperframes/SKILL.md
index c10a1261bb..e788e1578c 100644
--- a/skills/hyperframes/SKILL.md
+++ b/skills/hyperframes/SKILL.md
@@ -31,8 +31,7 @@ Atomic capabilities you load **on demand** — not full video workflows. For "ma
| **Animate** — atomic motion, scene blueprints, transitions, runtime adapters (GSAP / Lottie / Three.js / Anime.js / CSS / WAAPI / TypeGPU) | `/hyperframes-animation` |
| **Author seek-safe keyframes** — GSAP timelines, CSS keyframes, Anime.js, WAAPI, FLIP, paths, masks, SVG morph/draw, 3D depth, plus `hyperframes keyframes` diagnostics | `/hyperframes-keyframes` |
| **Creative direction** — `frame.md` / `design.md`, palettes, typography, narration, beat planning, audio-reactive | `/hyperframes-creative` |
-| **Media** — TTS voiceover, background music, transcription, background removal, captions | `/hyperframes-media` |
-| **Media resolve** — find + freeze BGM, SFX, images, icons from HeyGen catalog into `.media/` with manifest tracking | `/media-use` |
+| **Media** — resolve/generate BGM, SFX, image, icon, voice; TTS voiceover, transcription, background removal, captions; cross-project reuse | `/media-use` |
| **CLI dev loop** — init, lint, validate, inspect, preview, render, publish, doctor | `/hyperframes-cli` |
| **Install registry blocks / components** (`hyperframes add`) | `/hyperframes-registry` |
| **Import Figma content** — assets, tokens, components, storyboards→reconstructed motion (REST/CLI); Motion, shaders (MCP) | `/figma` |
diff --git a/skills/media-use/SKILL.md b/skills/media-use/SKILL.md
index 100b0f2240..c332052bbb 100644
--- a/skills/media-use/SKILL.md
+++ b/skills/media-use/SKILL.md
@@ -1,15 +1,32 @@
---
name: media-use
-description: Agent Media OS — resolve any media need (BGM, SFX, image, icon) into a frozen local file + ledger record. One verb (`resolve`) handles the full cascade — project cache, global cache, HeyGen catalog search, freeze, register. Keeps search noise on disk, hands the agent a path. Use when a composition needs background music, sound effects, images, or icons.
+description: Agent Media OS, the single skill for every media need in a HyperFrames project. Resolve BGM, SFX, image, icon, or voice into a frozen local file + ledger record (one verb, `resolve`); generate via TTS / music / image models when the catalog misses; produce voiceover, transcription, captions, and background removal through one shared audio engine; operate on media (cut / reframe / transform); and reuse assets across projects. Keeps search noise on disk, hands the agent a path. Use for any audio, image, icon, voiceover, caption, or media-asset need.
---
# media-use
-Resolve media needs into frozen local files. One verb, four types, zero context noise.
+The media OS for HyperFrames: resolve · generate · operate · remember, every media type, one skill, zero context noise.
+
+## What it owns (the gaps HyperFrames leaves)
+
+HyperFrames owns media _playback_; media-use owns everything else. Each row is enforced by `scripts/lib/coverage.test.mjs` so the claim can't rot.
+
+| HyperFrames gap | media-use owns it via |
+| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
+| Audio-only, no image/icon | `resolve --type image\|icon` (heygen asset search) |
+| No voice / audio generation | `resolve --type voice` + the audio engine (`audio/scripts/audio.mjs`) |
+| Scattered/duplicated audio engine | one consolidated engine under `audio/` (hyperframes-media retired) |
+| No agent media-ops (cut/reframe/transform) | `references/operations.md` + `resolve --from` to register outputs |
+| No transcript-driven cutting | `scripts/transcript-cut.mjs` compiles word-timestamp edits into cut lists |
+| No auto-duck / publish loudness | `scripts/audio-duck.mjs` + `references/operations.md` loudnorm/sidechain recipes |
+| No cross-project memory | global content-addressed cache + auto-promote (`~/.media`) |
+| No image generation | RAM-graded local mflux (FLUX) via `scripts/lib/mflux-provider.mjs`, codex `image_gen` upsell (`scripts/lib/codex-provider.mjs`) |
+| No video generation | spec-gated local LTX (`videogen` in `scripts/lib/local-models.mjs`); `heygen video create` avatar upsell |
+| Weak local-model defaults | free-usage HeyGen first (TTS, bg-removal) via the `heygen` CLI; local open-source only as an opt-out fallback (`scripts/lib/local-run.mjs`) |
## When to use
-Call `resolve` whenever a composition needs media — background music, sound effects, images, or icons. media-use searches the HeyGen catalog, downloads the best match, freezes it locally, and registers it in a manifest. The agent gets back one line; all search noise stays on disk.
+Call `resolve` whenever a composition needs media: background music, sound effects, images, icons, or voice. For voiceover / TTS, music, SFX, and caption timing, use the **audio engine** (below); background removal is delegated to the `hyperframes` CLI; transcription defaults to Parakeet (better than whisper.cpp: 6.05% vs 7.44% WER, 5-10x faster) via `scripts/transcribe.mjs`, with whisper.cpp auto-fallback (see `references/operations.md`). For cutting / reframing / transforming existing media, see `references/operations.md`. media-use searches the HeyGen catalog first, freezes the best match locally, registers it in a manifest, and hands the agent one line; all search noise stays on disk.
## Resolve
@@ -27,6 +44,7 @@ Returns one line: `resolved <id> → <path> (<type>, <metadata>)`
| `sfx` | Sound effects | Bundled 19-file library + HeyGen catalog |
| `image` | Photos, backgrounds | HeyGen asset search (75k+ vectors) |
| `icon` | Icons, logos | HeyGen asset search (type=icon) |
+| `voice` | TTS voiceover | Local Kokoro (free); HeyGen TTS upsell |
### Examples
@@ -50,14 +68,46 @@ node <SKILL_DIR>/scripts/resolve.mjs --type icon --intent "rocket" --project .
### Flags
-| Flag | Description |
-| --------------- | ------------------------------------------ |
-| `--type, -t` | Media type: bgm, sfx, image, icon |
-| `--intent, -i` | What you need (natural language) |
-| `--entity, -e` | Entity name for cache matching (optional) |
-| `--project, -p` | Project directory (default: .) |
-| `--adopt` | Bulk-import existing assets/ into manifest |
-| `--json` | Output JSON instead of one-line result |
+| Flag | Description |
+| --------------- | --------------------------------------------------------------- |
+| `--type, -t` | Media type: bgm, sfx, image, icon, voice |
+| `--intent, -i` | What you need (natural language) |
+| `--entity, -e` | Entity name for cache matching (optional) |
+| `--project, -p` | Project directory (default: .) |
+| `--from` | Freeze a local file or direct public URL (ingest) |
+| `--local-only` | Offline: skip every network provider (cache + local only) |
+| `--provider` | Force one generator (e.g. `codex`, `mflux`, `kokoro`, `heygen`) |
+| `--adopt` | Bulk-import existing assets/ into manifest |
+| `--json` | Output JSON instead of one-line result |
+
+## Providers
+
+media-use holds no keys; every external tool owns its auth. Generation is
+local-first with a cloud upsell where one helps. `resolve` spec-checks
+AVAILABLE RAM and auto-picks the best local model that fits (a RAM-graded
+ladder, `describeModelLadder`); the agent can see the ladder and override.
+
+| Type | Provider (in order) |
+| ------------- | --------------------------------------------------------------------------------------- |
+| bgm/sfx | heygen catalog (free) |
+| image | heygen search, then local mflux (best FLUX for your RAM), then codex `image_gen` upsell |
+| voice | local **Kokoro** (free, on-device), then **heygen tts** paid upsell |
+| icon | heygen asset search |
+| video (local) | local LTX (`videogen` ladder); `heygen video create` avatar upsell |
+
+Local Kokoro (voice), mflux (image), and LTX (video) run on-device (free,
+private, offline once cached). Paid/cloud upsells sit behind them: HeyGen TTS
+for voice, the `codex` CLI (ChatGPT sub) for a better image, the `heygen` CLI
+for avatar video. Cost rule (X4): the agent confirms before an agent-initiated
+paid call; a user-requested one just runs.
+
+To force a specific generator (e.g. a user says "make this image with codex"),
+pass `--provider codex`: it pins resolution to that provider and skips the
+free-first default. See `references/operations.md` for the RAM ladders and
+upsell recipes.
+
+`--local-only` skips every network provider, including the free HeyGen ones,
+leaving the project + global cache and any local provider.
## How it works
@@ -90,35 +140,84 @@ After resolve or adopt, read `.media/index.md` for the full inventory:
# .media · 4 assets
id type dur dims path description
-bgm_001 bgm 25s — .media/audio/bgm/bgm_001.mp3 upbeat tech launch
-sfx_001 sfx 0.6s — .media/audio/sfx/sfx_001.mp3 whoosh
-image_001 image — 1920×1080 .media/images/image_001.jpg gradient tech background
-icon_001 icon — 200×200 .media/images/icon_001.png rocket
+bgm_001 bgm 25s - .media/audio/bgm/bgm_001.mp3 upbeat tech launch
+sfx_001 sfx 0.6s - .media/audio/sfx/sfx_001.mp3 whoosh
+image_001 image - 1920×1080 .media/images/image_001.jpg gradient tech background
+icon_001 icon - 200×200 .media/images/icon_001.png rocket
```
## Cross-project reuse
-Assets are cached automatically on resolve. Subsequent resolves for the same prompt hit the global cache at `~/.media/` — no re-download, no provider call. Promote an asset explicitly with `organize --promote <id>` to make it reusable across all projects.
+Assets are cached automatically on resolve. Every resolved/ingested asset is auto-promoted to the global cache at `~/.media/`, so subsequent resolves for the same prompt, in any project, hit the cache with no re-download and no provider call.
## Files
-- `.media/manifest.jsonl` — machine SSOT, one JSON record per line
-- `.media/index.md` — agent-readable table (id, type, dur, dims, path, description)
-- `~/.media/` — global cross-project reuse cache (content-addressed, SHA-256)
-
-## CLI tools used
+- `.media/manifest.jsonl`: machine SSOT, one JSON record per line
+- `.media/index.md`: agent-readable table (id, type, dur, dims, path, description)
+- `~/.media/`: global cross-project reuse cache (content-addressed, SHA-256)
-| Tool | Purpose | Required? |
-| --------- | ------------------------------------------ | ------------- |
-| `ffprobe` | Probe duration, dimensions, codec on adopt | Yes |
-| `heygen` | Audio catalog, asset search | For providers |
+## Audio engine: voiceover, music, SFX, captions, transcription
-Install the `heygen` CLI (single static binary, no runtime) and authenticate:
+For a full audio pass (TTS voiceover + background music + sound effects in one
+shot), use the shared engine at `audio/scripts/audio.mjs`. It takes a neutral
+`audio_request.json` and writes `audio_meta.json` plus assets under
+`.media/audio/{voice,bgm,sfx}`:
```bash
-curl -fsSL https://static.heygen.ai/cli/install.sh | bash # installs latest to ~/.local/bin
-heygen update # if already installed: needs >= v0.1.6
-export HEYGEN_API_KEY=<your-key> # or: heygen auth login --key <key>
+node <SKILL_DIR>/audio/scripts/audio.mjs --request ./audio_request.json --out ./audio_meta.json
```
-Requires **heygen >= v0.1.6** — the providers tag requests with the allowlisted `--headers 'X-HeyGen-Client-Source: media-use'` flag, added in v0.1.6. `asset search` is a pre-launch command hidden from `heygen --help`, but it runs. Without a `heygen` on PATH (or a valid key) the providers print a one-line diagnostic to stderr and resolve falls through to "no provider could resolve".
+- **Request** `{ provider?, lang?, speed?, lines: [{ id, text, sfx?: [names] }], bgm: { mode?, query?, prompt? } }`: `id` joins each line back to your model; `bgm.mode` = `retrieve | generate | none` (omit for auto). `--only tts,bgm,sfx` runs a subset and merges into an existing `--out`.
+- **Output** `audio_meta.json` (id-keyed): `voices[].{path,duration_s,words[]}` (word timestamps for captions), `sfx[]`, `bgm`, `total_duration_s`.
+- **Auto-degrades on one switch**: HeyGen credential present → HeyGen TTS + music/SFX retrieval; absent → ElevenLabs/Kokoro TTS, Lyria/MusicGen BGM generation, and the bundled SFX library (no credential needed).
+- If BGM took the generate path (`bgm_pending: true`), run `audio/scripts/wait-bgm.mjs` before final render.
+
+Single-shot helpers: `audio/scripts/heygen-tts.mjs` (one voice file). Transcription / background removal / captions use the `hyperframes` CLI (`transcribe`, `remove-background`), see the per-topic guides in `audio/references/` (`tts.md`, `bgm.md`, `sfx.md`, `transcribe.md`, `remove-background.md`, `captions/`).
+
+## Operating on media (cut, reframe, transform)
+
+media-use resolves + remembers; for **operating** on assets see
+`references/operations.md`: local-tool recipes (ffmpeg trim/reframe/montage,
+auto-editor, scenedetect) and the local-vs-HeyGen transform table (background
+removal, upscale, lipsync, translate). Run the tool, then register the output
+with `resolve --from <output> --type <type>` so it joins the ledger + global
+cache.
+
+## CLI tools used (what to run, and how to enable each)
+
+`resolve` auto-cascades; each provider shells one CLI. Local tools are OPT-IN:
+if a local tool is absent, resolve degrades gracefully to the free/cloud path,
+so nothing here is strictly required except `ffmpeg`/`ffprobe`. Install a local
+tool to unlock its free, private, on-device path. media-use holds no keys.
+
+| Tool | Serves | Install |
+| ------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
+| `ffmpeg`/`ffprobe` | adopt probing, cut, duck bake, loudnorm | system package (`brew install ffmpeg`) |
+| `heygen` | catalog (bgm/sfx/image/icon), TTS + avatar upsell | `curl -fsSL https://static.heygen.ai/cli/install.sh \| bash` then `heygen auth login --key <key>` (needs >= v0.1.6) |
+| `mflux-generate` | local image gen (FLUX), best-for-RAM | `uv venv ~/.venvs/mflux && VIRTUAL_ENV=~/.venvs/mflux uv pip install mflux==0.9.6` |
+| `codex` | image gen upsell (ChatGPT sub) | Codex CLI, logged in via ChatGPT (owns its own auth) |
+| `parakeet-mlx` | local transcription (default ASR, best) | `uv venv ~/.venvs/parakeet && VIRTUAL_ENV=~/.venvs/parakeet uv pip install parakeet-mlx` |
+| `ltx-2-mlx` | local video gen | `git clone https://github.com/dgrauet/ltx-2-mlx && cd ltx-2-mlx && uv sync --all-extras` |
+| `npx hyperframes` | Kokoro TTS (voice), whisper.cpp (transcribe fallback), remove-background | bundled with the hyperframes CLI |
+
+The RAM-graded local-model shortlist + exact per-tier install/invoke lives in
+`scripts/lib/local-models.mjs` (the agent can read `describeModelLadder(cap, specs)`
+to see which model fits this machine). Without a tool on PATH, its provider
+prints a one-line diagnostic to stderr and resolve falls through to the next
+provider (e.g. no `mflux` -> codex image upsell; no `parakeet-mlx` -> whisper.cpp).
+
+`heygen asset search` is a pre-launch command hidden from `heygen --help`, but it
+runs; providers tag requests with the allowlisted `X-HeyGen-Client-Source` header
+(v0.1.6+).
+
+## Telemetry
+
+`resolve` and the edit tools (transcribe / transcript-cut / audio-duck) send an
+anonymous usage event to PostHog (`scripts/lib/telemetry.mjs`), so we can see
+which capabilities are actually used. It records only the media TYPE, the
+resolution SOURCE, and the winning PROVIDER: never the intent text, file names,
+or paths, and `$ip:null` so no IP is stored. Best-effort and non-blocking (a
+resolve never waits on or fails from telemetry).
+
+Opt out with `DO_NOT_TRACK=1` or `HYPERFRAMES_NO_TELEMETRY=1` (also off in CI and
+dev). Same public PostHog project key and opt-outs as the `hyperframes` CLI.
diff --git a/skills/hyperframes-media/assets/sfx/CREDITS.md b/skills/media-use/audio/assets/sfx/CREDITS.md
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/CREDITS.md
rename to skills/media-use/audio/assets/sfx/CREDITS.md
diff --git a/skills/hyperframes-media/assets/sfx/chime.mp3 b/skills/media-use/audio/assets/sfx/chime.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/chime.mp3
rename to skills/media-use/audio/assets/sfx/chime.mp3
diff --git a/skills/hyperframes-media/assets/sfx/click-soft.mp3 b/skills/media-use/audio/assets/sfx/click-soft.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/click-soft.mp3
rename to skills/media-use/audio/assets/sfx/click-soft.mp3
diff --git a/skills/hyperframes-media/assets/sfx/click.mp3 b/skills/media-use/audio/assets/sfx/click.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/click.mp3
rename to skills/media-use/audio/assets/sfx/click.mp3
diff --git a/skills/hyperframes-media/assets/sfx/error.mp3 b/skills/media-use/audio/assets/sfx/error.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/error.mp3
rename to skills/media-use/audio/assets/sfx/error.mp3
diff --git a/skills/hyperframes-media/assets/sfx/glitch-1.mp3 b/skills/media-use/audio/assets/sfx/glitch-1.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/glitch-1.mp3
rename to skills/media-use/audio/assets/sfx/glitch-1.mp3
diff --git a/skills/hyperframes-media/assets/sfx/glitch-2.mp3 b/skills/media-use/audio/assets/sfx/glitch-2.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/glitch-2.mp3
rename to skills/media-use/audio/assets/sfx/glitch-2.mp3
diff --git a/skills/hyperframes-media/assets/sfx/glitch-3.mp3 b/skills/media-use/audio/assets/sfx/glitch-3.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/glitch-3.mp3
rename to skills/media-use/audio/assets/sfx/glitch-3.mp3
diff --git a/skills/hyperframes-media/assets/sfx/impact-bass-1.mp3 b/skills/media-use/audio/assets/sfx/impact-bass-1.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/impact-bass-1.mp3
rename to skills/media-use/audio/assets/sfx/impact-bass-1.mp3
diff --git a/skills/hyperframes-media/assets/sfx/impact-bass-2.mp3 b/skills/media-use/audio/assets/sfx/impact-bass-2.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/impact-bass-2.mp3
rename to skills/media-use/audio/assets/sfx/impact-bass-2.mp3
diff --git a/skills/hyperframes-media/assets/sfx/key-press.mp3 b/skills/media-use/audio/assets/sfx/key-press.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/key-press.mp3
rename to skills/media-use/audio/assets/sfx/key-press.mp3
diff --git a/skills/hyperframes-media/assets/sfx/manifest.json b/skills/media-use/audio/assets/sfx/manifest.json
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/manifest.json
rename to skills/media-use/audio/assets/sfx/manifest.json
diff --git a/skills/hyperframes-media/assets/sfx/notification.mp3 b/skills/media-use/audio/assets/sfx/notification.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/notification.mp3
rename to skills/media-use/audio/assets/sfx/notification.mp3
diff --git a/skills/hyperframes-media/assets/sfx/ping.mp3 b/skills/media-use/audio/assets/sfx/ping.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/ping.mp3
rename to skills/media-use/audio/assets/sfx/ping.mp3
diff --git a/skills/hyperframes-media/assets/sfx/pop.mp3 b/skills/media-use/audio/assets/sfx/pop.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/pop.mp3
rename to skills/media-use/audio/assets/sfx/pop.mp3
diff --git a/skills/hyperframes-media/assets/sfx/riser.mp3 b/skills/media-use/audio/assets/sfx/riser.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/riser.mp3
rename to skills/media-use/audio/assets/sfx/riser.mp3
diff --git a/skills/hyperframes-media/assets/sfx/sparkle.mp3 b/skills/media-use/audio/assets/sfx/sparkle.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/sparkle.mp3
rename to skills/media-use/audio/assets/sfx/sparkle.mp3
diff --git a/skills/hyperframes-media/assets/sfx/typing.mp3 b/skills/media-use/audio/assets/sfx/typing.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/typing.mp3
rename to skills/media-use/audio/assets/sfx/typing.mp3
diff --git a/skills/hyperframes-media/assets/sfx/whoosh-cinematic.mp3 b/skills/media-use/audio/assets/sfx/whoosh-cinematic.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/whoosh-cinematic.mp3
rename to skills/media-use/audio/assets/sfx/whoosh-cinematic.mp3
diff --git a/skills/hyperframes-media/assets/sfx/whoosh-short.mp3 b/skills/media-use/audio/assets/sfx/whoosh-short.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/whoosh-short.mp3
rename to skills/media-use/audio/assets/sfx/whoosh-short.mp3
diff --git a/skills/hyperframes-media/assets/sfx/whoosh.mp3 b/skills/media-use/audio/assets/sfx/whoosh.mp3
similarity index 100%
rename from skills/hyperframes-media/assets/sfx/whoosh.mp3
rename to skills/media-use/audio/assets/sfx/whoosh.mp3
diff --git a/skills/hyperframes-media/references/bgm.md b/skills/media-use/audio/references/bgm.md
similarity index 100%
rename from skills/hyperframes-media/references/bgm.md
rename to skills/media-use/audio/references/bgm.md
diff --git a/skills/hyperframes-media/references/captions/authoring.md b/skills/media-use/audio/references/captions/authoring.md
similarity index 100%
rename from skills/hyperframes-media/references/captions/authoring.md
rename to skills/media-use/audio/references/captions/authoring.md
diff --git a/skills/hyperframes-media/references/captions/motion.md b/skills/media-use/audio/references/captions/motion.md
similarity index 100%
rename from skills/hyperframes-media/references/captions/motion.md
rename to skills/media-use/audio/references/captions/motion.md
diff --git a/skills/hyperframes-media/references/captions/transcript-handling.md b/skills/media-use/audio/references/captions/transcript-handling.md
similarity index 100%
rename from skills/hyperframes-media/references/captions/transcript-handling.md
rename to skills/media-use/audio/references/captions/transcript-handling.md
diff --git a/skills/hyperframes-media/references/remove-background.md b/skills/media-use/audio/references/remove-background.md
similarity index 100%
rename from skills/hyperframes-media/references/remove-background.md
rename to skills/media-use/audio/references/remove-background.md
diff --git a/skills/hyperframes-media/references/requirements.md b/skills/media-use/audio/references/requirements.md
similarity index 100%
rename from skills/hyperframes-media/references/requirements.md
rename to skills/media-use/audio/references/requirements.md
diff --git a/skills/hyperframes-media/references/sfx.md b/skills/media-use/audio/references/sfx.md
similarity index 100%
rename from skills/hyperframes-media/references/sfx.md
rename to skills/media-use/audio/references/sfx.md
diff --git a/skills/hyperframes-media/references/transcribe.md b/skills/media-use/audio/references/transcribe.md
similarity index 100%
rename from skills/hyperframes-media/references/transcribe.md
rename to skills/media-use/audio/references/transcribe.md
diff --git a/skills/hyperframes-media/references/tts-to-captions.md b/skills/media-use/audio/references/tts-to-captions.md
similarity index 100%
rename from skills/hyperframes-media/references/tts-to-captions.md
rename to skills/media-use/audio/references/tts-to-captions.md
diff --git a/skills/hyperframes-media/references/tts.md b/skills/media-use/audio/references/tts.md
similarity index 97%
rename from skills/hyperframes-media/references/tts.md
rename to skills/media-use/audio/references/tts.md
index 22ec77f0b4..1e88665872 100644
--- a/skills/hyperframes-media/references/tts.md
+++ b/skills/media-use/audio/references/tts.md
@@ -44,11 +44,11 @@ expired OAuth token it stops with a hint to run `npx hyperframes auth refresh`.
export HEYGEN_API_KEY=... # or put it in a project .env
# Synthesize + capture word timestamps in one call (skips a Whisper pass)
-node skills/hyperframes-media/scripts/heygen-tts.mjs \
+node skills/media-use/audio/scripts/heygen-tts.mjs \
"Welcome to HyperFrames." -o narration.wav --words narration.words.json
-node skills/hyperframes-media/scripts/heygen-tts.mjs ./script.txt -o narration.wav
-node skills/hyperframes-media/scripts/heygen-tts.mjs --list # public starfish voices
+node skills/media-use/audio/scripts/heygen-tts.mjs ./script.txt -o narration.wav
+node skills/media-use/audio/scripts/heygen-tts.mjs --list # public starfish voices
```
- **Voice:** `--voice <id>` must be a **starfish** voice_id (`--list`, or `GET /v3/voices?engine=starfish`). v2-catalog ids are rejected with HTTP 400. Omit `--voice` (English) and it defaults to **Marcia** (`05f19352e8f74b0392a8f411eba40de1`, a fixed default so the choice is deterministic). Non-English with no `--voice` falls back to the first matching catalog voice.
diff --git a/skills/hyperframes-media/scripts/audio.mjs b/skills/media-use/audio/scripts/audio.mjs
similarity index 99%
rename from skills/hyperframes-media/scripts/audio.mjs
rename to skills/media-use/audio/scripts/audio.mjs
index d2fb4589d4..a332dc7d3b 100644
--- a/skills/hyperframes-media/scripts/audio.mjs
+++ b/skills/media-use/audio/scripts/audio.mjs
@@ -11,7 +11,7 @@
//
// TTS : HeyGen REST → ElevenLabs → Kokoro (CLI)
// BGM : HeyGen retrieve → (no credential) Lyria/MusicGen generate
-// SFX : HeyGen retrieve → (no credential) bundled 21-file library
+// SFX : HeyGen retrieve → (no credential) bundled 19-file library
//
// ── audio_request.json (input) ────────────────────────────────────────────────
// {
diff --git a/skills/media-use/audio/scripts/audio.test.mjs b/skills/media-use/audio/scripts/audio.test.mjs
new file mode 100644
index 0000000000..b229e40cc3
--- /dev/null
+++ b/skills/media-use/audio/scripts/audio.test.mjs
@@ -0,0 +1,49 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { mkdtempSync, rmSync, existsSync } from "node:fs";
+import { join, dirname } from "node:path";
+import { tmpdir } from "node:os";
+import { fileURLToPath } from "node:url";
+import { resolveSfx } from "./lib/sfx.mjs";
+
+// Proves the relocated engine (skills/media-use/audio/) still resolves its
+// bundled SFX library from the moved location — the path most likely to break
+// on a subtree move. Offline (heygenOK:false), no network.
+
+const HERE = dirname(fileURLToPath(import.meta.url));
+const sfxLibDir = join(HERE, "..", "assets", "sfx"); // same offset the engine uses
+
+test("bundled SFX library resolves from the relocated path", async () => {
+ assert.ok(existsSync(join(sfxLibDir, "manifest.json")), "moved manifest is present");
+ const dir = mkdtempSync(join(tmpdir(), "mu-audio-"));
+ try {
+ const { sfx, anomalies } = await resolveSfx({
+ cues: [{ id: "1", name: "whoosh" }],
+ heygenOK: false,
+ hyperframesDir: dir,
+ sfxLibDir,
+ });
+ assert.equal(sfx.length, 1, `expected 1 resolved cue, got anomalies: ${anomalies.join("; ")}`);
+ assert.equal(sfx[0].source, "local");
+ assert.match(sfx[0].file, /assets\/sfx\//);
+ assert.ok(existsSync(join(dir, sfx[0].file)), "matched SFX copied into the project");
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
+
+test("an unknown cue is reported, not fatal", async () => {
+ const dir = mkdtempSync(join(tmpdir(), "mu-audio-"));
+ try {
+ const { sfx, anomalies } = await resolveSfx({
+ cues: [{ id: "1", name: "definitely-not-a-real-sfx" }],
+ heygenOK: false,
+ hyperframesDir: dir,
+ sfxLibDir,
+ });
+ assert.equal(sfx.length, 0);
+ assert.ok(anomalies.some((a) => /not in bundled library/.test(a)));
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/skills/hyperframes-media/scripts/heygen-tts.mjs b/skills/media-use/audio/scripts/heygen-tts.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/heygen-tts.mjs
rename to skills/media-use/audio/scripts/heygen-tts.mjs
diff --git a/skills/hyperframes-media/scripts/lib/bgm.mjs b/skills/media-use/audio/scripts/lib/bgm.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/bgm.mjs
rename to skills/media-use/audio/scripts/lib/bgm.mjs
diff --git a/skills/hyperframes-media/scripts/lib/concurrency.mjs b/skills/media-use/audio/scripts/lib/concurrency.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/concurrency.mjs
rename to skills/media-use/audio/scripts/lib/concurrency.mjs
diff --git a/skills/hyperframes-media/scripts/lib/concurrency.test.mjs b/skills/media-use/audio/scripts/lib/concurrency.test.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/concurrency.test.mjs
rename to skills/media-use/audio/scripts/lib/concurrency.test.mjs
diff --git a/skills/hyperframes-media/scripts/lib/heygen.mjs b/skills/media-use/audio/scripts/lib/heygen.mjs
similarity index 95%
rename from skills/hyperframes-media/scripts/lib/heygen.mjs
rename to skills/media-use/audio/scripts/lib/heygen.mjs
index ef466e4bb1..a2a50fc805 100644
--- a/skills/hyperframes-media/scripts/lib/heygen.mjs
+++ b/skills/media-use/audio/scripts/lib/heygen.mjs
@@ -1,7 +1,6 @@
// heygen.mjs — vendored HeyGen REST helpers (auth + transport) for the audio
-// pipeline. The credential resolver is copied from hyperframes-media's
-// heygen-tts.mjs (and matches the hyperframes CLI auth): first usable source
-// wins — $HEYGEN_API_KEY / $HYPERFRAMES_API_KEY → a nearby .env → ~/.heygen/
+// pipeline. The credential resolver matches the hyperframes CLI auth: first
+// usable source wins — $HEYGEN_API_KEY / $HYPERFRAMES_API_KEY → a nearby .env → ~/.heygen/
// credentials (oauth → Bearer, else api_key → X-Api-Key; $HEYGEN_CONFIG_DIR
// overrides the dir). Vendored so the skill ships standalone. Pure node.
diff --git a/skills/hyperframes-media/scripts/lib/python.mjs b/skills/media-use/audio/scripts/lib/python.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/python.mjs
rename to skills/media-use/audio/scripts/lib/python.mjs
diff --git a/skills/hyperframes-media/scripts/lib/python.test.mjs b/skills/media-use/audio/scripts/lib/python.test.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/python.test.mjs
rename to skills/media-use/audio/scripts/lib/python.test.mjs
diff --git a/skills/hyperframes-media/scripts/lib/sfx.mjs b/skills/media-use/audio/scripts/lib/sfx.mjs
similarity index 98%
rename from skills/hyperframes-media/scripts/lib/sfx.mjs
rename to skills/media-use/audio/scripts/lib/sfx.mjs
index c695ca8a81..f72baf34ee 100644
--- a/skills/hyperframes-media/scripts/lib/sfx.mjs
+++ b/skills/media-use/audio/scripts/lib/sfx.mjs
@@ -122,7 +122,7 @@ export async function resolveSfx({ cues, heygenOK, headers, hyperframesDir, sfxL
if (!existsSync(src)) {
anomalies.push(
`sfx "${name}" (id ${id}): bundled file ${hit.file} missing from the offline ` +
- `library (${sfxLibDir}) — skipped. Reinstall the hyperframes-media skill to ` +
+ `library (${sfxLibDir}) — skipped. Reinstall the media-use skill to ` +
`restore assets/sfx/*.mp3, or configure a HeyGen credential for retrieval.`,
);
continue;
diff --git a/skills/hyperframes-media/scripts/lib/sfx.test.mjs b/skills/media-use/audio/scripts/lib/sfx.test.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/sfx.test.mjs
rename to skills/media-use/audio/scripts/lib/sfx.test.mjs
diff --git a/skills/hyperframes-media/scripts/lib/tts.mjs b/skills/media-use/audio/scripts/lib/tts.mjs
similarity index 99%
rename from skills/hyperframes-media/scripts/lib/tts.mjs
rename to skills/media-use/audio/scripts/lib/tts.mjs
index c41965b381..8385bd7a43 100644
--- a/skills/hyperframes-media/scripts/lib/tts.mjs
+++ b/skills/media-use/audio/scripts/lib/tts.mjs
@@ -181,7 +181,7 @@ export function spawnP(
if (!_warnedNpxResolution) {
_warnedNpxResolution = true;
console.error(
- `[hyperframes-media] Cannot run "${cmd}" on Windows: npm_execpath is not set, so the ` +
+ `[media-use] Cannot run "${cmd}" on Windows: npm_execpath is not set, so the ` +
`npx JS CLI can't be located. This happens when this script is run directly with ` +
`\`node\` instead of through npm/npx. Every "${cmd}" call is being skipped. ` +
`Fix: run via \`npx\`/\`npm run\`, or export npm_execpath pointing at your npm-cli.js.`,
diff --git a/skills/hyperframes-media/scripts/lib/tts.spawn.test.mjs b/skills/media-use/audio/scripts/lib/tts.spawn.test.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/tts.spawn.test.mjs
rename to skills/media-use/audio/scripts/lib/tts.spawn.test.mjs
diff --git a/skills/hyperframes-media/scripts/lib/tts.test.mjs b/skills/media-use/audio/scripts/lib/tts.test.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/lib/tts.test.mjs
rename to skills/media-use/audio/scripts/lib/tts.test.mjs
diff --git a/skills/hyperframes-media/scripts/lyria-recipe.py b/skills/media-use/audio/scripts/lyria-recipe.py
similarity index 100%
rename from skills/hyperframes-media/scripts/lyria-recipe.py
rename to skills/media-use/audio/scripts/lyria-recipe.py
diff --git a/skills/hyperframes-media/scripts/wait-bgm.mjs b/skills/media-use/audio/scripts/wait-bgm.mjs
similarity index 100%
rename from skills/hyperframes-media/scripts/wait-bgm.mjs
rename to skills/media-use/audio/scripts/wait-bgm.mjs
diff --git a/skills/media-use/references/operations.md b/skills/media-use/references/operations.md
new file mode 100644
index 0000000000..a7dc76ca27
--- /dev/null
+++ b/skills/media-use/references/operations.md
@@ -0,0 +1,226 @@
+# Media operations: agent guidance
+
+media-use resolves and remembers assets. For **operating** on them: cutting,
+reframing, stitching, transforming, it does not wrap every action as a bespoke
+command. Instead it points you at the right local tool (decision OP1). Run the
+tool, then register the output with `resolve --from <output> --type <type>` so the
+result lands in the ledger and the global cache like any other asset.
+
+All tools below are local and free. ffmpeg is assumed present (it backs the
+engine already).
+
+## Cut / trim: keep a slice
+
+```bash
+ffmpeg -i in.mp4 -ss 00:00:12 -to 00:00:20 -c copy out.mp4 # 0:12–0:20, no re-encode
+```
+
+In-composition trimming usually needs **no new file**: a clip plays a sub-window
+via `data-media-start` + `data-duration` (see hyperframes-core). Only cut a
+physical file when exporting/assembling outside the composition.
+
+## Reframe / crop: change aspect ratio
+
+```bash
+# 16:9 -> 9:16, crop centered
+ffmpeg -i in.mp4 -vf "crop=ih*9/16:ih,scale=1080:1920" out.mp4
+```
+
+For a non-destructive crop, set a `clip-path` on the element in the composition
+itself (render-time, source file untouched) instead of re-encoding with ffmpeg.
+
+## Montage / stitch: join clips
+
+```bash
+printf "file '%s'\n" a.mp4 b.mp4 c.mp4 > list.txt
+ffmpeg -f concat -safe 0 -i list.txt -c copy out.mp4
+```
+
+## Silence-cut / highlight: trim dead air, grab the best moment
+
+```bash
+auto-editor in.mp4 --edit audio:threshold=4% -o tight.mp4 # pip install auto-editor
+scenedetect -i in.mp4 detect-adaptive list-scenes # pip install scenedetect
+```
+
+## Transforms with a quality choice (process)
+
+These have a local option AND a higher-quality HeyGen-CLI option. Run the local
+one for free/offline; use the HeyGen CLI when quality matters. Showing the user
+a **side-by-side** (local vs HeyGen) is the honest way to let them choose.
+
+| Op | Local (free) | HeyGen CLI (quality) |
+| ------------------ | -------------------------------------------------- | --------------------------- |
+| Background removal | `hyperframes remove-background in.png` (u2net) | `heygen background-removal` |
+| Upscale | `realesrgan-ncnn-vulkan -i in.png -o out.png -s 4` | n/a |
+| Lipsync (dub) | n/a | `heygen lipsync` |
+| Translate | n/a | `heygen video-translate` |
+
+After any op: `resolve --from out.ext --type <type>` to register the derived
+asset (it records provenance and auto-promotes to the global cache).
+
+> ponytail: media-use doesn't re-wrap ffmpeg/heygen here, that's deliberate
+> (OP1). The value it adds is the ledger + global reuse on the _output_, via
+> `--from`. Add a thin `process` verb only if agents repeatedly fumble these
+> recipes.
+
+## Transcription (default: Parakeet, better than whisper.cpp)
+
+`transcribe.mjs` is the default local transcription path. It runs **NVIDIA
+Parakeet-TDT via parakeet-mlx**, which beats whisper.cpp on the Open ASR
+Leaderboard (avg WER ~6.05% vs 7.44%; on NOISY audio 4.73% vs 5.96%, where
+whisper-large-v3 hallucinated to 308% WER on meetings) and is 5-10x faster.
+It emits `{ text, words:[{text,start,end}] }` with word timestamps (merged from
+Parakeet's sub-word tokens), feeding transcript-cut, captions, and the audio
+engine directly.
+
+```bash
+# install once: uv venv ~/.venvs/parakeet && VIRTUAL_ENV=~/.venvs/parakeet uv pip install parakeet-mlx
+node <SKILL_DIR>/scripts/transcribe.mjs --input talk.mp4 --out talk.transcribe.json
+
+# equivalently, the hyperframes CLI has Parakeet built in (auto-detects it, whisper fallback):
+npx hyperframes transcribe talk.mp4 --engine parakeet # or --engine auto (default)
+```
+
+VERIFIED on 24GB: accurate, ~3s (cached) for 8s audio. Parakeet covers English +
+25 European languages. For other languages, or when parakeet-mlx is not
+installed, transcribe.mjs auto-falls-back to whisper.cpp (99 languages) via
+`hyperframes transcribe`. `--engine parakeet|whisper` forces one. (Cohere
+Transcribe tops the leaderboard on paper but its mlx-audio quants produced
+garbage and ran 40-70x slower on a Mac in testing, so it is not wired in.)
+
+## Text-based editing (transcript cut)
+
+`transcript-cut.mjs` is a compiler, not a wrapper: it turns word timestamps and
+agent cut decisions into exact kept segments. It is provided even though the rest
+of this file is guidance-only.
+
+```bash
+node <SKILL_DIR>/scripts/transcript-cut.mjs \
+ --input talk.mp4 \
+ --transcript talk.transcribe.json \
+ --remove "12.41-15.02,88.3-91.7" \
+ --remove-fillers "um,uh,like" \
+ --cut-silence 0.8 \
+ --out talk.cut.mp4
+
+resolve --from talk.cut.mp4 --type video
+```
+
+Use `--plan` first when you want to inspect the kept segment JSON before encoding.
+
+## Ducking (declare in-composition / bake for export)
+
+B1, declare ducking in the composition. `audio-duck.mjs` emits GSAP volume
+keyframes. Paste them into the composition timeline, the source file stays
+untouched.
+
+```bash
+node <SKILL_DIR>/scripts/audio-duck.mjs \
+ --meta audio_meta.json \
+ --target "#bgm" \
+ --composition index.html
+```
+
+```js
+// auto-duck: #bgm under narration (generated; base volume 0.6)
+tl.to("#bgm", { volume: 0.15, duration: 0.15 }, 3.42);
+tl.to("#bgm", { volume: 0.6, duration: 0.4 }, 9.87);
+```
+
+B2, bake ducking only for exported or standalone files.
+
+```bash
+ffmpeg -i bgm.mp3 -i voice.wav \
+ -filter_complex "[0][1]sidechaincompress=threshold=0.03:ratio=8:attack=200:release=400[ducked]" \
+ -map "[ducked]" bgm.ducked.wav
+```
+
+Declare inside compositions. Bake only for assets leaving the hyperframes
+pipeline.
+
+## Publish loudness
+
+Two-pass `loudnorm` measures first, then applies the measured values with the
+target LUFS baked in.
+
+Socials target, -14 LUFS:
+
+```bash
+ffmpeg -i mix.wav \
+ -af loudnorm=I=-14:TP=-1.5:LRA=11:print_format=json \
+ -f null -
+
+ffmpeg -i mix.wav \
+ -af loudnorm=I=-14:TP=-1.5:LRA=11:measured_I=<input_i>:measured_TP=<input_tp>:measured_LRA=<input_lra>:measured_thresh=<input_thresh>:offset=<target_offset>:linear=true:print_format=summary \
+ mix.social.wav
+```
+
+Podcast target, -16 LUFS:
+
+```bash
+ffmpeg -i mix.wav \
+ -af loudnorm=I=-16:TP=-1.5:LRA=11:print_format=json \
+ -f null -
+
+ffmpeg -i mix.wav \
+ -af loudnorm=I=-16:TP=-1.5:LRA=11:measured_I=<input_i>:measured_TP=<input_tp>:measured_LRA=<input_lra>:measured_thresh=<input_thresh>:offset=<target_offset>:linear=true:print_format=summary \
+ mix.podcast.wav
+```
+
+## Generate: images (local first, cloud upsell)
+
+`resolve --type image` retrieves from the HeyGen catalog first; on a miss it
+GENERATES. Two paths, best-for-the-machine picked automatically:
+
+1. **Local (default, free, private): mflux** (FLUX-on-MLX). `resolve` spec-checks
+ AVAILABLE RAM and runs the best FLUX-class model that fits, via
+ `scripts/lib/local-models.mjs` (`imagegen` ladder) + `mflux-provider.mjs`.
+ The RAM ladder (agent sees it via `describeModelLadder("imagegen", specs)`):
+
+ | Tier | Model | Needs (available RAM) | Notes |
+ | ------ | -------------------- | --------------------- | ----------------------------------- |
+ | medium | FLUX.1 schnell int4 | ~8GB (`--low-ram`) | ~20s/512px on 24GB. VERIFIED. Fast. |
+ | large | FLUX.2 Klein 4B int4 | ~32GB | higher quality, full-resident |
+ | xlarge | Qwen-Image | ~64GB | top quality, 64GB+ Macs only |
+
+ Gotchas baked into the table: the official FLUX repos are HF-gated, so it
+ points at non-gated community 4-bit re-uploads; and `--low-ram` is MANDATORY
+ at the medium tier (without it a 768x512 run swap-thrashed to 90 minutes on
+ 24GB; with it, 20 seconds).
+
+2. **Cloud upsell (better quality): the `codex` CLI** `image_gen` tool, on the
+ user's ChatGPT subscription (codex owns auth, no key here, no per-call
+ charge). It is the automatic fallback when no local model fits AND the
+ explicit "make it better" choice on any machine. Users who just want codex
+ can ask for it directly. Verified: prompt -> raster -> frozen + ledgered.
+
+`--local-only` keeps mflux (once cached) and skips codex (network).
+
+## Generate: video (local first, HeyGen avatar upsell)
+
+Operate-on-video ships now; GENERATING video is local-first with a HeyGen
+avatar upsell (decision X3).
+
+- **Local (default): LTX 2.3 on MLX** via `dgrauet/ltx-2-mlx`, the `videogen`
+ ladder in `local-models.mjs`. Generative clips (t2v / i2v), spec-gated to RAM.
+ Verified on 24GB: 512x320 x 33f with audio.
+- **HeyGen avatar upsell (better, script-driven): the `heygen` CLI**, NOT the
+ raw API. For a talking-head / avatar video, `heygen video create` (avatar
+ engine IV by default) beats a generative clip when you want a real presenter:
+
+ ```bash
+ # discover an avatar + a starfish voice, then create + wait
+ heygen avatar list --ownership public --limit 5
+ heygen voice list --engine starfish --limit 5
+ heygen video create --wait -d '{
+ "type": "avatar",
+ "avatar_id": "<avatar-id>",
+ "script": "Your narration here.",
+ "voice_id": "<voice-id>"
+ }'
+ ```
+
+ Avatar videos are deterministic + script-driven (lip-sync from a script or a
+ pre-recorded `audio_url`), distinct from the generative LTX clips. After it
+ renders, `resolve --from <downloaded.mp4> --type video` to ledger it.
diff --git a/skills/media-use/scripts/lib/cache.mjs b/skills/media-use/scripts/lib/cache.mjs
index e138e2bc01..d092f24718 100644
--- a/skills/media-use/scripts/lib/cache.mjs
+++ b/skills/media-use/scripts/lib/cache.mjs
@@ -29,8 +29,12 @@ function markComplete(entryDir) {
writeFileSync(join(entryDir, COMPLETE_SENTINEL), "", "utf8");
}
+// The manifest helpers append their own ".media" to the dir they get, so the
+// global manifest must be addressed by HOME, not by globalMediaDir() — passing
+// the latter nested it at ~/.media/.media/manifest.jsonl, invisible to the
+// Studio /api/assets/global route (which reads the documented flat path).
function readGlobalManifest() {
- return readManifest(globalMediaDir());
+ return readManifest(homedir());
}
function validateCacheHit(match) {
@@ -55,6 +59,11 @@ export function cacheGetByEntity(entity) {
export function cachePut(filePath, record) {
const sha = contentHash(filePath);
+ // Idempotent: same content already promoted -> don't duplicate the global
+ // record. ponytail: skips usage_count bump; add it when the metric is needed.
+ const existing = readGlobalManifest().find((r) => r.sha === sha);
+ if (existing) return { sha, cached_path: existing.cached_path, deduped: true };
+
const dir = globalMediaDir();
const entryDir = cacheEntryDir(dir, sha);
mkdirSync(entryDir, { recursive: true });
@@ -69,7 +78,7 @@ export function cachePut(filePath, record) {
reusable: true,
cached_path: dest,
};
- appendRecord(globalMediaDir(), globalRecord);
+ appendRecord(homedir(), globalRecord);
return { sha, cached_path: dest };
}
diff --git a/skills/media-use/scripts/lib/codex-provider.mjs b/skills/media-use/scripts/lib/codex-provider.mjs
new file mode 100644
index 0000000000..9940031915
--- /dev/null
+++ b/skills/media-use/scripts/lib/codex-provider.mjs
@@ -0,0 +1,133 @@
+import { execFileSync } from "node:child_process";
+import { copyFileSync, existsSync, readdirSync, statSync, unlinkSync } from "node:fs";
+import { homedir, tmpdir } from "node:os";
+import { join } from "node:path";
+
+// Image generation via the OpenAI Codex CLI's built-in image tool (gpt-image-2)
+// on the user's ChatGPT subscription: the codex CLI owns auth, media-use holds
+// no key (CLI-only). The image UPSELL behind local mflux; skipped by --local-only.
+//
+// Retrieval mirrors illo-skill rather than trusting the model to save a file:
+// `--enable imagegenext` makes the built-in tool drop the rendered artifact into
+// $CODEX_HOME/generated_images/, and we fetch the freshest file that postdates
+// this run. The save-to-path instruction is only a best-effort verify-first.
+
+const TIMEOUT_MS = 600000; // codex exec round-trips the sub; first-run tool spin-up is slow
+const MTIME_SKEW_MS = 2000; // tolerate mtime granularity / clock skew (illo uses 2s)
+
+function codexGeneratedDir() {
+ // Codex relocates CODEX_HOME on some hosts, so resolve it at run time.
+ return join(process.env.CODEX_HOME || join(homedir(), ".codex"), "generated_images");
+}
+
+// Newest artifact that postdates `sinceMs` (minus skew), so a stale prior render
+// or a concurrent session's file can't be mistaken for this run's output.
+function freshestGeneratedImage(sinceMs) {
+ const dir = codexGeneratedDir();
+ if (!existsSync(dir)) return null;
+ const floor = sinceMs - MTIME_SKEW_MS;
+ let best = null;
+ for (const name of readdirSync(dir)) {
+ let st;
+ try {
+ st = statSync(join(dir, name));
+ } catch {
+ continue;
+ }
+ if (!st.isFile() || st.mtimeMs < floor) continue;
+ if (!best || st.mtimeMs > best.mtimeMs) best = { path: join(dir, name), mtimeMs: st.mtimeMs };
+ }
+ return best?.path ?? null;
+}
+
+// Short `codex` subcommand → combined stdout+stderr, or null if it can't run.
+function codexRun(args) {
+ try {
+ return execFileSync("codex", args, {
+ encoding: "utf8",
+ stdio: ["ignore", "pipe", "pipe"],
+ timeout: 10000,
+ });
+ } catch (err) {
+ return `${err.stdout?.toString() ?? ""}${err.stderr?.toString() ?? ""}` || null;
+ }
+}
+
+// Fail-fast host check (mirrors illo): don't burn a minutes-long exec when Codex
+// isn't usable. Returns null when ready, else a human reason. imagegenext ships
+// default-disabled ("under development"), so we check the ROW is present (the
+// capability signal) — the exec enables it per-render with --enable.
+function codexUnavailableReason() {
+ try {
+ const which = process.platform === "win32" ? "where" : "which";
+ execFileSync(which, ["codex"], { stdio: ["ignore", "ignore", "ignore"], timeout: 5000 });
+ } catch {
+ return "codex CLI not on PATH";
+ }
+ const login = codexRun(["login", "status"]);
+ if (!login || !/logged in/i.test(login)) return "codex not logged in (run: codex login)";
+ const feats = codexRun(["features", "list"]);
+ if (feats == null) return "could not read `codex features list`";
+ if (!/\bimage_generation\b/.test(feats)) return "codex image_generation feature unavailable";
+ if (!/\bimagegenext\b/.test(feats)) return "codex imagegenext unavailable (upgrade Codex CLI)";
+ return null;
+}
+
+export async function codexImageGenerate(intent) {
+ const unavailable = codexUnavailableReason();
+ if (unavailable) {
+ console.error(`media-use: codex image upsell unavailable: ${unavailable}`);
+ return null;
+ }
+ const outPath = join(tmpdir(), `media-use-codex-${process.pid}-${Date.now()}.png`);
+ const prompt =
+ `${intent}\n\n` +
+ `Use your built-in image generation tool to render this, then save the image ` +
+ `to ${outPath} (overwrite if it exists). Do not ask for confirmation. ` +
+ `If you have no built-in image tool, do nothing (no PIL/matplotlib/SVG substitute).`;
+ try {
+ unlinkSync(outPath); // clear any prior file so verify-first can't accept a stale render
+ } catch {
+ /* no prior file */
+ }
+ const started = Date.now();
+ try {
+ execFileSync(
+ "codex",
+ [
+ "exec",
+ "--cd",
+ tmpdir(),
+ "-s",
+ "workspace-write",
+ "--skip-git-repo-check",
+ "--enable",
+ "imagegenext",
+ "-",
+ ],
+ { input: prompt, encoding: "utf8", timeout: TIMEOUT_MS, stdio: ["pipe", "pipe", "pipe"] },
+ );
+ } catch (err) {
+ console.error(
+ `media-use: \`codex exec\` image generation failed: ${err.stderr?.toString().trim().slice(-200) || err.message}`,
+ );
+ return null;
+ }
+ // Verify-first (save-to-path may have worked), else fetch the imagegenext artifact.
+ const produced =
+ existsSync(outPath) && statSync(outPath).size > 0 ? outPath : freshestGeneratedImage(started);
+ if (!produced) return null;
+ if (produced !== outPath) {
+ try {
+ copyFileSync(produced, outPath);
+ } catch {
+ return null;
+ }
+ }
+ return {
+ localPath: outPath,
+ ext: ".png",
+ source: "generated",
+ metadata: { description: intent, provider: "codex.image_gen", provenance: { prompt: intent } },
+ };
+}
diff --git a/skills/media-use/scripts/lib/freeze.mjs b/skills/media-use/scripts/lib/freeze.mjs
index aa4704201d..2527f6626d 100644
--- a/skills/media-use/scripts/lib/freeze.mjs
+++ b/skills/media-use/scripts/lib/freeze.mjs
@@ -6,21 +6,65 @@ import { dirname } from "node:path";
const MAX_FREEZE_BYTES = 256 * 1024 * 1024;
export async function freezeUrl(url, destPath) {
+ const where = String(url).slice(0, 80);
const res = await fetch(url);
- if (!res.ok) throw new Error(`freeze failed: HTTP ${res.status} for ${String(url).slice(0, 80)}`);
- const bytes = Buffer.from(await res.arrayBuffer());
- if (bytes.length === 0)
- throw new Error(`freeze failed: empty response for ${String(url).slice(0, 80)}`);
- if (bytes.length > MAX_FREEZE_BYTES)
+ if (!res.ok) throw new Error(`freeze failed: HTTP ${res.status} for ${where}`);
+
+ // Fail fast on an advertised oversize body before reading a single byte.
+ const declared = Number(res.headers.get("content-length"));
+ if (declared > MAX_FREEZE_BYTES)
throw new Error(
- `freeze failed: ${bytes.length} bytes exceeds ${MAX_FREEZE_BYTES} cap for ${String(url).slice(0, 80)}`,
+ `freeze failed: ${declared} bytes exceeds ${MAX_FREEZE_BYTES} cap for ${where}`,
);
+
+ // Stream and abort once the cap is crossed, so a lying/chunked hostile URL
+ // can't buffer the whole payload into memory before the check (M1).
+ const chunks = [];
+ let total = 0;
+ for await (const chunk of res.body) {
+ total += chunk.length;
+ if (total > MAX_FREEZE_BYTES)
+ throw new Error(`freeze failed: stream exceeds ${MAX_FREEZE_BYTES} cap for ${where}`);
+ chunks.push(chunk);
+ }
+ if (total === 0) throw new Error(`freeze failed: empty response for ${where}`);
+
mkdirSync(dirname(destPath), { recursive: true });
- writeFileSync(destPath, bytes);
- return bytes.length;
+ writeFileSync(destPath, Buffer.concat(chunks, total));
+ return total;
}
export function freezeLocalFile(srcPath, destPath) {
mkdirSync(dirname(destPath), { recursive: true });
copyFileSync(srcPath, destPath);
}
+
+// Ingest accepts a DIRECT public media URL only — not a platform page. yt-dlp is
+// deliberately out (cloud IPs get blocked, and it's brittle); the supported case
+// is "user points at their own file or a direct asset link". A direct URL is a
+// non-platform host whose path ends in a known media extension.
+const PLATFORM_HOSTS =
+ /(^|\.)(youtube\.com|youtu\.be|vimeo\.com|tiktok\.com|instagram\.com|twitter\.com|x\.com|facebook\.com|dailymotion\.com)$/i;
+const MEDIA_EXT = /\.(mp3|wav|m4a|aac|ogg|flac|mp4|mov|webm|mkv|png|jpe?g|webp|gif|svg|avif)$/i;
+
+// SSRF guard (m11): a user-supplied --from URL must not point at the local host
+// or a private network. Blocks loopback/localhost, RFC1918, link-local, and the
+// IPv6 equivalents on the literal hostname.
+// ponytail: literal-host check only; a DNS name that *resolves* to a private IP
+// (rebinding) still passes — add resolve-then-check if --from ever fetches from
+// untrusted hostnames at scale.
+const PRIVATE_HOST =
+ /^(localhost|.*\.local|.*\.internal|127\.|10\.|0\.|169\.254\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|\[?(::1|::ffff:127\.|f[cd][0-9a-f]{2}:|fe80:))/i;
+
+export function isDirectMediaUrl(u) {
+ let url;
+ try {
+ url = new URL(u);
+ } catch {
+ return false;
+ }
+ if (url.protocol !== "http:" && url.protocol !== "https:") return false;
+ if (PLATFORM_HOSTS.test(url.hostname)) return false;
+ if (PRIVATE_HOST.test(url.hostname)) return false;
+ return MEDIA_EXT.test(url.pathname);
+}
diff --git a/skills/media-use/scripts/lib/freeze.test.mjs b/skills/media-use/scripts/lib/freeze.test.mjs
new file mode 100644
index 0000000000..c71eb76a08
--- /dev/null
+++ b/skills/media-use/scripts/lib/freeze.test.mjs
@@ -0,0 +1,46 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { isDirectMediaUrl } from "./freeze.mjs";
+
+test("accepts direct public media URLs", () => {
+ assert.equal(isDirectMediaUrl("https://cdn.example.com/clip.mp4"), true);
+ assert.equal(isDirectMediaUrl("https://example.com/a/b/track.mp3"), true);
+ assert.equal(isDirectMediaUrl("http://example.com/logo.svg"), true);
+});
+
+test("rejects platform pages (no yt-dlp)", () => {
+ assert.equal(isDirectMediaUrl("https://www.youtube.com/watch?v=abc"), false);
+ assert.equal(isDirectMediaUrl("https://youtu.be/abc"), false);
+ assert.equal(isDirectMediaUrl("https://vimeo.com/12345"), false);
+ assert.equal(isDirectMediaUrl("https://x.com/u/status/1"), false);
+});
+
+test("rejects non-direct / non-media URLs", () => {
+ assert.equal(isDirectMediaUrl("https://example.com/page"), false, "no media extension");
+ assert.equal(isDirectMediaUrl("ftp://example.com/a.mp4"), false, "non-http(s)");
+ assert.equal(isDirectMediaUrl("not a url"), false);
+});
+
+test("rejects local / private hosts (SSRF guard, m11)", () => {
+ for (const u of [
+ "http://localhost/a.mp4",
+ "http://127.0.0.1/a.mp4",
+ "http://127.1.2.3/a.mp4",
+ "http://0.0.0.0/a.mp4",
+ "http://10.0.0.5/a.mp4",
+ "http://192.168.1.1/a.mp4",
+ "http://172.16.0.1/a.mp4",
+ "http://172.31.255.255/a.mp4",
+ "http://169.254.169.254/a.mp4", // cloud metadata endpoint
+ "http://printer.local/a.mp4",
+ "http://svc.internal/a.mp4",
+ "http://[::1]/a.mp4",
+ "http://[fe80::1]/a.mp4",
+ "http://[fd00::1]/a.mp4",
+ ]) {
+ assert.equal(isDirectMediaUrl(u), false, `should block ${u}`);
+ }
+ // A public host that merely starts with similar digits is still allowed.
+ assert.equal(isDirectMediaUrl("https://172.40.0.1/a.mp4"), true, "172.40 is public");
+ assert.equal(isDirectMediaUrl("https://11.example.com/a.mp4"), true);
+});
diff --git a/skills/media-use/scripts/lib/local-models.mjs b/skills/media-use/scripts/lib/local-models.mjs
new file mode 100644
index 0000000000..021cb6c7b9
--- /dev/null
+++ b/skills/media-use/scripts/lib/local-models.mjs
@@ -0,0 +1,279 @@
+// Declarative table of USER-INSTALLED local models, for the spec-gated fallback.
+//
+// These models run on the user's own machine for their own use; media-use
+// recommends, spec-checks, and assists install; it does not bundle, redistribute,
+// or sell them. Because nothing is redistributed, selection is purely by
+// quality / size / spec-fit / word-timestamp support (there is deliberately NO
+// license field gating availability).
+//
+// Tiers (`small`|`medium`|`large`|`xlarge`) are human labels; `needs.ramMB` is
+// what selection actually gates on. selectModel() returns the best model that
+// fits the machine's AVAILABLE RAM, best-first: by explicit `rank` when set
+// (quality that is NOT size, e.g. ASR), else by RAM footprint (the quality
+// proxy for generation). No fit -> recommend the CLI/cloud path.
+//
+// Picks reflect the 2026 research pass, verified live where noted.
+
+export const CAPABILITIES = ["tts", "asr", "upscale", "videogen", "imagegen"];
+
+const MODELS = {
+ tts: [
+ {
+ id: "kokoro",
+ tier: "medium",
+ sizeMB: 330,
+ needs: { ramMB: 2048, gpu: false },
+ wordTimestamps: "native",
+ install: "pip install kokoro",
+ invoke: "python -m kokoro --text {text} --voice {voice} --out {out}",
+ notes: "CPU, faster-than-realtime, native per-word timestamps. Default floor.",
+ },
+ {
+ id: "fish-speech",
+ tier: "large",
+ sizeMB: 1100,
+ needs: { ramMB: 16000, gpu: true, vramMB: 12000 },
+ wordTimestamps: "whisperx", // needs forced alignment (run ASR over output)
+ install: "pip install fish-speech",
+ invoke: "fish-speech synth --text {text} --ref {ref} --out {out}",
+ notes: "Expressive zero-shot voice cloning; meeting pick. WhisperX for word timing.",
+ },
+ ],
+ asr: [
+ // Parakeet is BETTER than Whisper yet SMALLER (0.6B vs 1.5B), so quality is
+ // not size here: `rank` pins it ahead of whisper regardless of footprint.
+ // Open ASR Leaderboard avg WER: Parakeet ~6.05% vs whisper-large-v3 7.44%
+ // (~19% better); on NOISY test-other 4.73% vs 5.96%, and whisper-v3
+ // hallucinated to 308% WER on meetings where Parakeet held. 5-10x faster.
+ //
+ // Cohere Transcribe 2B tops the leaderboard (5.42%) and is nominally the most
+ // accurate, but its mlx-audio community MLX quants (4bit AND 8bit, with and
+ // without --language en) produced multilingual token-soup garbage AND ran
+ // 40-70x slower than Parakeet on a 24GB Mac (live-tested 2026-07). Excluded
+ // until the mlx-audio Cohere decoder stabilizes; Parakeet is the default.
+ {
+ id: "parakeet-mlx",
+ tier: "small",
+ rank: 0,
+ sizeMB: 2400,
+ needs: { ramMB: 4000, gpu: true },
+ wordTimestamps: "tokens", // sub-word tokens; merged to words by parakeet-words.mjs
+ repo: "mlx-community/parakeet-tdt-0.6b-v3",
+ install:
+ "uv venv ~/.venvs/parakeet && VIRTUAL_ENV=~/.venvs/parakeet uv pip install parakeet-mlx",
+ invoke:
+ "parakeet-mlx {audio} --model mlx-community/parakeet-tdt-0.6b-v3 --output-format json --output-dir {outdir}",
+ notes:
+ "NVIDIA Parakeet-TDT 0.6B via parakeet-mlx. VERIFIED on 24GB: accurate transcript, ~3s (cached model) for 8s audio, word timestamps drive transcript-cut. English + 25 European languages. Beats whisper.cpp on accuracy (6.05% vs 7.44% WER) AND speed (5-10x).",
+ },
+ {
+ id: "whisperx",
+ tier: "medium",
+ rank: 1,
+ sizeMB: 1500,
+ needs: { ramMB: 4096, gpu: false },
+ wordTimestamps: "native", // faster-whisper + wav2vec2 forced alignment
+ install: "pip install whisperx",
+ invoke: "whisperx {audio} --output_format json --out {out}",
+ notes:
+ "CPU-only fallback (no GPU): faster-whisper + wav2vec2 forced alignment, native word timestamps. The packaged `hyperframes transcribe` (whisper.cpp) is the zero-setup baseline below this.",
+ },
+ ],
+ upscale: [
+ {
+ id: "real-esrgan",
+ tier: "medium",
+ sizeMB: 70,
+ needs: { ramMB: 2048, gpu: false },
+ wordTimestamps: false,
+ install: "brew install real-esrgan-ncnn-vulkan # or download the ncnn binary",
+ invoke: "realesrgan-ncnn-vulkan -i {in} -o {out} -s 4",
+ notes: "ncnn-vulkan binary, CPU-capable. GFPGAN for faces.",
+ },
+ {
+ id: "seedvr2",
+ tier: "large",
+ sizeMB: 6000,
+ needs: { ramMB: 24000, gpu: true, vramMB: 16000 },
+ wordTimestamps: false,
+ install: "pip install seedvr2",
+ invoke: "seedvr2 upscale --in {in} --out {out}",
+ notes: "Diffusion upscaler, GPU-only. Video2X for video.",
+ },
+ ],
+ videogen: [
+ // 2026-07 X research pass + live verification on a 24GB M-series Mac.
+ // The Mac-local video story is LTX 2.3 on MLX via dgrauet/ltx-2-mlx (the
+ // pipeline these weights were converted for; also powers Phosphene).
+ // Wan 2.x MLX exists only as A14B conversions (too large for consumer
+ // unified memory); revisit when a 5B Wan MLX conversion lands.
+ // IMPORTANT: download the weights with a targeted include list first;
+ // pointing tools at the repo blind snapshot-downloads all 60 GB:
+ // hf download dgrauet/ltx-2.3-mlx-q4 --include \
+ // transformer-distilled-1.1.safetensors connector.safetensors \
+ // "vae_*.safetensors" audio_vae.safetensors vocoder.safetensors "*.json"
+ {
+ id: "ltx-2.3-mlx-q4",
+ tier: "medium",
+ sizeMB: 20000, // distilled subset; gemma-3-12b-4bit text encoder adds ~7GB
+ needs: { ramMB: 16384, gpu: true },
+ wordTimestamps: false,
+ install:
+ "git clone https://github.com/dgrauet/ltx-2-mlx && cd ltx-2-mlx && uv sync --all-extras",
+ invoke:
+ "ltx-2-mlx generate --prompt {prompt} --distilled --low-ram --model dgrauet/ltx-2.3-mlx-q4 --width {w} --height {h} --frames {frames} --frame-rate 24 --output {out}",
+ notes:
+ "LTX 2.3 int4 on MLX. Verified on 24GB unified: 512x320 x 33 frames in ~19 min cold (incl. text-encoder download), t2v with audio. Dims must be multiples of 64. i2v, retake/extend, keyframe interpolation supported.",
+ },
+ {
+ id: "ltx-2.3-mlx-bf16",
+ tier: "large",
+ sizeMB: 45000,
+ needs: { ramMB: 32768, gpu: true },
+ wordTimestamps: false,
+ install:
+ "git clone https://github.com/dgrauet/ltx-2-mlx && cd ltx-2-mlx && uv sync --all-extras",
+ invoke:
+ "ltx-2-mlx generate --prompt {prompt} --two-stage --model dgrauet/ltx-2.3-mlx-bf16 --width {w} --height {h} --frames {frames} --frame-rate 24 --output {out}",
+ notes:
+ "Full-precision two-stage pipeline (upstream production default). 32GB with --low-ram block streaming; 64-128GB Macs for long/HD runs (the 25s multi-scene spots seen in the wild).",
+ },
+ ],
+ imagegen: [
+ // 2026-07 X research + live verification on a 24GB M-series Mac. mflux
+ // (FLUX-on-MLX) is the Mac-native runner; FLUX is the quality leader. Two
+ // hard-won findings baked into `needs.ramMB`:
+ // 1. The OFFICIAL FLUX repos are HF-gated (license wall). Point --path at a
+ // non-gated community 4-bit re-upload (self-contained, incl. VAE).
+ // 2. Without --low-ram, FLUX's T5-XXL text encoder + transformer blow past
+ // 24GB into swap: a 768x512 run took 90 MINUTES. With --low-ram (streams
+ // components from disk) the SAME machine did 512x512 in ~20s at 7.6GB
+ // free. So the medium tier's needs.ramMB is the streamed floor, not the
+ // resident footprint; the large tiers are the no-streaming thresholds.
+ // The runner resolves `repo` to a local snapshot (hf download) before --path;
+ // a bare repo id in --path breaks mlx unflatten.
+ {
+ id: "flux-schnell-mflux-q4",
+ tier: "medium",
+ sizeMB: 8700,
+ needs: { ramMB: 8000, gpu: true },
+ repo: "dhairyashil/FLUX.1-schnell-mflux-4bit",
+ wordTimestamps: false,
+ install: "uv venv ~/.venvs/mflux && VIRTUAL_ENV=~/.venvs/mflux uv pip install mflux==0.9.6",
+ invoke:
+ "mflux-generate --model schnell --path {model_path} --low-ram --steps 4 --prompt {prompt} --width {w} --height {h} --seed {seed} --output {out}",
+ notes:
+ "FLUX.1 schnell int4. VERIFIED on 24GB (7.6GB free): --low-ram 512x512 in ~20s, photoreal. --low-ram is MANDATORY at this tier (streams to avoid swap). Few-step, fast.",
+ },
+ {
+ id: "flux2-klein-mflux-q4",
+ tier: "large",
+ sizeMB: 12000,
+ needs: { ramMB: 32000, gpu: true },
+ repo: "Runpod/FLUX.2-klein-4B-mflux-4bit",
+ wordTimestamps: false,
+ install: "uv venv ~/.venvs/mflux && VIRTUAL_ENV=~/.venvs/mflux uv pip install mflux",
+ invoke:
+ "mflux-generate --base-model flux2-klein-4b --path {model_path} --steps 8 --prompt {prompt} --width {w} --height {h} --seed {seed} --output {out}",
+ notes:
+ "FLUX.2 Klein 4B int4 (most-downloaded mflux community repo). Newer, higher quality than schnell; full-resident (no streaming) so needs 32GB+ to stay fast. Needs mflux >= 0.18 for the flux2-klein base model.",
+ },
+ {
+ id: "qwen-image-mflux",
+ tier: "xlarge",
+ sizeMB: 40000,
+ needs: { ramMB: 64000, gpu: true },
+ repo: "Qwen/Qwen-Image",
+ wordTimestamps: false,
+ install: "uv venv ~/.venvs/mflux && VIRTUAL_ENV=~/.venvs/mflux uv pip install mflux",
+ invoke:
+ "mflux-generate --base-model qwen --steps 20 --prompt {prompt} --width {w} --height {h} --seed {seed} --output {out}",
+ notes:
+ "Qwen-Image, top-tier quality. Heavy: 'several minutes' even on 128GB M4 Max, 'almost fried' a 32GB M4 Pro. 64GB+ only. Below that, the cloud upsell (codex) is faster and better.",
+ },
+ ],
+};
+
+function tableFor(capability) {
+ const t = MODELS[capability];
+ if (!t) throw new Error(`unknown local-model capability: ${capability}`);
+ return t;
+}
+
+/** All local models for a capability. */
+export function listModels(capability) {
+ return tableFor(capability).slice();
+}
+
+/** Does this machine meet a model's needs? Apple Silicon unified memory counts as VRAM. */
+export function meetsSpecs(model, specs) {
+ const n = model.needs || {};
+ // Gate on AVAILABLE RAM when the probe reported it (the real budget with the
+ // OS + open apps resident); fall back to total RAM otherwise. Older specs
+ // objects (and unit fixtures) that only set ramMB keep working unchanged.
+ const budget = specs.availableRamMB ?? specs.ramMB;
+ if (n.ramMB && budget < n.ramMB) return false;
+ if (n.gpu && !specs.gpu?.present) return false;
+ if (n.vramMB) {
+ const vram = specs.gpu?.vramMB ?? 0;
+ if (vram < n.vramMB) return false;
+ }
+ return true;
+}
+
+// "Best model the machine can run" == best-first among those that fit. Ordering:
+// 1. explicit `rank` (lower = better) when a model declares it. Needed where
+// quality is NOT size: Parakeet-0.6B beats Whisper-large-1.5B at ASR, so
+// footprint would pick the wrong one.
+// 2. otherwise RAM footprint descending, the quality proxy for generation
+// (a 40GB image model out-renders a 12GB one).
+function rankedByPreference(table) {
+ return [...table].sort((a, b) => {
+ const ra = a.rank ?? Infinity;
+ const rb = b.rank ?? Infinity;
+ if (ra !== rb) return ra - rb;
+ return (b.needs?.ramMB ?? 0) - (a.needs?.ramMB ?? 0);
+ });
+}
+
+/**
+ * Pick the best local model the machine can run for a capability: the
+ * highest-footprint model that fits the available-RAM budget (and GPU/VRAM).
+ * `preferTier` pins the search to one tier (e.g. force a smaller/faster model).
+ * Returns `{ model, tier }`, or `{ recommend: "cli", reason }` when nothing fits.
+ */
+export function selectModel(capability, specs, { preferTier } = {}) {
+ const table = tableFor(capability);
+ const pool = preferTier ? table.filter((m) => m.tier === preferTier) : table;
+ for (const model of rankedByPreference(pool)) {
+ if (meetsSpecs(model, specs)) return { model, tier: model.tier };
+ }
+ const smallest = table.reduce((a, b) => (a.sizeMB <= b.sizeMB ? a : b));
+ return {
+ recommend: "cli",
+ reason: `machine does not meet specs for any local ${capability} model (smallest needs ~${smallest.needs.ramMB}MB RAM${smallest.needs.gpu ? " + GPU" : ""}); use the CLI path instead`,
+ };
+}
+
+/**
+ * Agent-facing ladder: every model for a capability, best-first, each flagged
+ * with whether it fits this machine and why. Lets the agent see the RAM-graded
+ * options and choose (e.g. trade the auto-picked best for a smaller/faster one,
+ * or step up to a cloud upsell) rather than only getting one auto-selection.
+ */
+export function describeModelLadder(capability, specs) {
+ const budget = specs.availableRamMB ?? specs.ramMB;
+ return rankedByPreference(tableFor(capability)).map((model) => {
+ const fits = meetsSpecs(model, specs);
+ return {
+ id: model.id,
+ tier: model.tier,
+ needsRamMB: model.needs?.ramMB ?? 0,
+ fits,
+ reason: fits
+ ? `fits (needs ~${model.needs?.ramMB}MB, ${budget}MB available)`
+ : `too big (needs ~${model.needs?.ramMB}MB${model.needs?.gpu ? " + GPU" : ""}, ${budget}MB available)`,
+ notes: model.notes,
+ };
+ });
+}
diff --git a/skills/media-use/scripts/lib/local-models.test.mjs b/skills/media-use/scripts/lib/local-models.test.mjs
new file mode 100644
index 0000000000..e1cc56368f
--- /dev/null
+++ b/skills/media-use/scripts/lib/local-models.test.mjs
@@ -0,0 +1,154 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import {
+ listModels,
+ meetsSpecs,
+ selectModel,
+ describeModelLadder,
+ CAPABILITIES,
+} from "./local-models.mjs";
+
+const TIERS = ["small", "medium", "large", "xlarge"];
+
+const strongGpu = {
+ ramMB: 64000,
+ gpu: { present: true, kind: "nvidia", vramMB: 24000 },
+ appleSilicon: false,
+};
+const cpuOnly = { ramMB: 16000, gpu: { present: false, vramMB: 0 }, appleSilicon: false };
+const tiny = { ramMB: 1024, gpu: { present: false, vramMB: 0 }, appleSilicon: false };
+
+test("every capability table is non-empty and well-formed", () => {
+ for (const cap of CAPABILITIES) {
+ const models = listModels(cap);
+ assert.ok(models.length > 0, `no models for ${cap}`);
+ for (const m of models) {
+ assert.ok(m.id && m.tier && m.needs, `${cap}/${m.id} missing fields`);
+ assert.ok(TIERS.includes(m.tier), `${cap}/${m.id} bad tier: ${m.tier}`);
+ assert.equal(typeof m.install, "string", `${cap}/${m.id} needs an install command`);
+ assert.equal(typeof m.invoke, "string", `${cap}/${m.id} needs an invoke command`);
+ // user-installed, local-use-only: there is NO license gate on selection
+ assert.equal("license" in m, false, `${cap}/${m.id} must not carry a license gate`);
+ }
+ }
+});
+
+test("meetsSpecs enforces RAM, GPU presence, and VRAM", () => {
+ const gpuModel = { needs: { ramMB: 8000, gpu: true, vramMB: 12000 } };
+ assert.equal(meetsSpecs(gpuModel, strongGpu), true);
+ assert.equal(meetsSpecs(gpuModel, cpuOnly), false, "no GPU -> fails a GPU model");
+ const cpuModel = { needs: { ramMB: 2000, gpu: false } };
+ assert.equal(meetsSpecs(cpuModel, cpuOnly), true);
+ assert.equal(meetsSpecs(cpuModel, tiny), false, "too little RAM");
+});
+
+test("Apple Silicon unified memory counts as VRAM", () => {
+ const apple = {
+ ramMB: 24000,
+ appleSilicon: true,
+ gpu: { present: true, kind: "apple", vramMB: 24000 },
+ };
+ const gpuModel = { needs: { ramMB: 8000, gpu: true, vramMB: 16000 } };
+ assert.equal(meetsSpecs(gpuModel, apple), true);
+});
+
+test("selectModel picks the large tier on a strong machine", () => {
+ const r = selectModel("tts", strongGpu);
+ assert.equal(r.tier, "large");
+ assert.ok(r.model.id);
+});
+
+test("selectModel falls back to medium on a CPU-only machine", () => {
+ const r = selectModel("tts", cpuOnly);
+ assert.equal(r.tier, "medium");
+ assert.equal(r.model.id, "kokoro", "Kokoro is the CPU/medium default (native word timestamps)");
+});
+
+test("selectModel recommends the CLI path when no tier fits", () => {
+ const r = selectModel("tts", tiny);
+ assert.equal(r.recommend, "cli");
+ assert.ok(r.reason && /spec/i.test(r.reason));
+ assert.equal(r.model, undefined);
+});
+
+test("preferTier:'medium' avoids the large model even on a strong machine", () => {
+ const r = selectModel("tts", strongGpu, { preferTier: "medium" });
+ assert.equal(r.tier, "medium");
+});
+
+test("selectModel gates on AVAILABLE RAM, not total, when both are present", () => {
+ // 64GB total but only 6GB free right now -> the large tier must not be chosen.
+ const busy = {
+ ramMB: 64000,
+ availableRamMB: 6000,
+ appleSilicon: true,
+ gpu: { present: true, kind: "apple", vramMB: 64000 },
+ };
+ const r = selectModel("tts", busy);
+ assert.equal(r.tier, "medium", "available RAM (6GB) rules out the 16GB large tier");
+});
+
+test("imagegen is a RAM-graduated ladder; agent picks the best that fits", () => {
+ const ladder = describeModelLadder("imagegen", {
+ ramMB: 24000,
+ availableRamMB: 12000,
+ appleSilicon: true,
+ gpu: { present: true, kind: "apple", vramMB: 24000 },
+ });
+ // best-first order, each flagged with fit
+ assert.ok(ladder.length >= 3, "imagegen offers multiple RAM tiers");
+ assert.ok(
+ ladder[0].needsRamMB >= ladder[ladder.length - 1].needsRamMB,
+ "ladder is ordered best (biggest) first",
+ );
+ // on 24GB / 12GB-free the schnell --low-ram tier fits, the 32GB+ tiers do not
+ const fitting = ladder.filter((m) => m.fits);
+ assert.ok(fitting.length >= 1, "at least the low-ram tier fits a 24GB Mac");
+ assert.ok(
+ fitting.every((m) => m.needsRamMB <= 12000),
+ "only sub-budget models flagged as fitting",
+ );
+ const pick = selectModel("imagegen", {
+ ramMB: 24000,
+ availableRamMB: 12000,
+ gpu: { present: true, vramMB: 24000 },
+ });
+ assert.equal(
+ pick.model.id,
+ "flux-schnell-mflux-q4",
+ "best fit on 24GB is the low-ram schnell tier",
+ );
+});
+
+test("imagegen on a 64GB Mac steps up to the higher-quality tier", () => {
+ const pick = selectModel("imagegen", {
+ ramMB: 96000,
+ availableRamMB: 80000,
+ gpu: { present: true, vramMB: 96000 },
+ });
+ assert.equal(pick.tier, "xlarge", "80GB free unlocks the top-quality model");
+});
+
+test("ASR prefers Parakeet by rank even though it is smaller than whisper", () => {
+ // quality != size for ASR: Parakeet 0.6B beats whisper-1.5B, so `rank` wins
+ // over footprint. On a capable machine both fit; Parakeet must be chosen.
+ const capable = {
+ ramMB: 24000,
+ availableRamMB: 12000,
+ appleSilicon: true,
+ gpu: { present: true, kind: "apple", vramMB: 24000 },
+ };
+ const pick = selectModel("asr", capable);
+ assert.equal(pick.model.id, "parakeet-mlx", "Parakeet is the rank-0 preferred ASR");
+ // whisperx (rank 1, CPU-only) is the fallback when no GPU
+ const cpu = { ramMB: 16000, availableRamMB: 12000, gpu: { present: false, vramMB: 0 } };
+ assert.equal(selectModel("asr", cpu).model.id, "whisperx", "CPU-only falls back to whisperx");
+});
+
+test("ASR offers word-timestamp-capable models (better than plain whisper)", () => {
+ const asr = listModels("asr");
+ assert.ok(
+ asr.every((m) => m.wordTimestamps),
+ "every ASR model must support word timestamps",
+ );
+});
diff --git a/skills/media-use/scripts/lib/local-run.mjs b/skills/media-use/scripts/lib/local-run.mjs
new file mode 100644
index 0000000000..b8b1bc6c21
--- /dev/null
+++ b/skills/media-use/scripts/lib/local-run.mjs
@@ -0,0 +1,64 @@
+import { execFileSync } from "node:child_process";
+import { selectModel } from "./local-models.mjs";
+import { probeSpecs } from "./specs.mjs";
+
+// Run a USER-INSTALLED local model for a capability (tts/asr/upscale).
+// Picks the best tier the machine supports (selectModel), checks the tool is on
+// PATH, fills the model's invoke template, and runs it. Returns:
+// { model, tier, out } on success
+// { recommend:"install", model, command, reason } when the tool isn't installed
+// { recommend:"cli", reason } when no tier fits the machine
+// `exec` / `which` are injectable for tests.
+//
+// ponytail: "installed" = the invoke's first token is on PATH (e.g. `whisperx`,
+// `realesrgan-ncnn-vulkan`). For `python -m kokoro` this only proves python
+// exists; good enough to gate — the recommend.command names the real package.
+// Upgrade to a per-tool probe if a "python present but package missing" run ever
+// produces a confusing error instead of a clean recommend.
+
+function defaultWhich(bin) {
+ execFileSync("command", ["-v", bin], { stdio: "ignore", shell: true });
+}
+
+function defaultExec(cmd) {
+ execFileSync(cmd, { stdio: ["ignore", "pipe", "pipe"], shell: true, timeout: 600000 });
+}
+
+const fill = (tpl, vars) =>
+ tpl.replace(/\{(\w+)\}/g, (_, k) => (vars[k] != null ? String(vars[k]) : ""));
+
+export function runLocalModel(capability, opts = {}) {
+ const {
+ specs = probeSpecs(),
+ exec = defaultExec,
+ which = defaultWhich,
+ vars = {},
+ preferTier,
+ } = opts;
+ const sel = selectModel(capability, specs, { preferTier });
+ if (sel.recommend) return sel; // no tier fits -> recommend the CLI path
+
+ const { model } = sel;
+ const bin = model.invoke.split(/\s+/)[0];
+ try {
+ which(bin);
+ } catch {
+ return {
+ recommend: "install",
+ model: model.id,
+ command: model.install,
+ reason: `${model.id} not installed`,
+ };
+ }
+ try {
+ exec(fill(model.invoke, vars));
+ } catch (e) {
+ return {
+ recommend: "install",
+ model: model.id,
+ command: model.install,
+ reason: e.message || String(e),
+ };
+ }
+ return { model: model.id, tier: sel.tier, out: vars.out };
+}
diff --git a/skills/media-use/scripts/lib/local-run.test.mjs b/skills/media-use/scripts/lib/local-run.test.mjs
new file mode 100644
index 0000000000..7e9c883dbc
--- /dev/null
+++ b/skills/media-use/scripts/lib/local-run.test.mjs
@@ -0,0 +1,54 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { runLocalModel } from "./local-run.mjs";
+
+const strongCpu = { ramMB: 16000, gpu: { present: false, vramMB: 0 }, appleSilicon: false };
+const tiny = { ramMB: 512, gpu: { present: false, vramMB: 0 }, appleSilicon: false };
+const ok = () => {}; // which/exec that succeed
+
+test("recommends the CLI path when no local tier fits the machine", () => {
+ const r = runLocalModel("tts", { specs: tiny, which: ok, exec: ok });
+ assert.equal(r.recommend, "cli");
+});
+
+test("recommends install when the tool is not on PATH", () => {
+ const r = runLocalModel("tts", {
+ specs: strongCpu,
+ which: () => {
+ throw new Error("not found");
+ },
+ exec: ok,
+ vars: { text: "hi", out: "/tmp/v.wav" },
+ });
+ assert.equal(r.recommend, "install");
+ assert.equal(r.model, "kokoro");
+ assert.match(r.command, /pip install kokoro/);
+});
+
+test("runs the model and returns the output path when installed", () => {
+ let ran = "";
+ const r = runLocalModel("tts", {
+ specs: strongCpu,
+ which: ok,
+ exec: (cmd) => {
+ ran = cmd;
+ },
+ vars: { text: "hello world", voice: "af_heart", out: "/tmp/v.wav" },
+ });
+ assert.equal(r.model, "kokoro");
+ assert.equal(r.out, "/tmp/v.wav");
+ assert.match(ran, /hello world/, "invoke template filled with vars");
+ assert.match(ran, /\/tmp\/v\.wav/);
+});
+
+test("a failing run degrades to an install recommendation, never throws", () => {
+ const r = runLocalModel("upscale", {
+ specs: strongCpu,
+ which: ok,
+ exec: () => {
+ throw new Error("boom");
+ },
+ vars: { in: "a.png", out: "b.png" },
+ });
+ assert.equal(r.recommend, "install");
+});
diff --git a/skills/media-use/scripts/lib/mflux-provider.mjs b/skills/media-use/scripts/lib/mflux-provider.mjs
new file mode 100644
index 0000000000..547eddf863
--- /dev/null
+++ b/skills/media-use/scripts/lib/mflux-provider.mjs
@@ -0,0 +1,95 @@
+import { execFileSync } from "node:child_process";
+import { existsSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { probeSpecs } from "./specs.mjs";
+import { selectModel } from "./local-models.mjs";
+
+// Local image generation via mflux (FLUX-on-MLX), the Mac-native runner.
+// Spec-gated: selectModel("imagegen", specs) returns the best FLUX-class model
+// the machine's AVAILABLE RAM can actually run (medium FLUX-schnell --low-ram on
+// ~24GB, up to Qwen-Image on 64GB+). When nothing local fits, this returns null
+// so the registry falls through to the codex image upsell.
+//
+// The official FLUX repos are HF-gated, so the model entries point --path at
+// non-gated community 4-bit re-uploads; the repo is resolved to a local snapshot
+// (hf download, idempotent) because a bare repo id breaks mlx unflatten.
+
+// Tokenize the invoke template on whitespace FIRST, then substitute each token,
+// so a {prompt}/{model_path} value with spaces stays a single argv entry.
+function buildArgv(template, vars) {
+ return template
+ .trim()
+ .split(/\s+/)
+ .map((tok) => tok.replace(/\{(\w+)\}/g, (_, k) => (k in vars ? String(vars[k]) : `{${k}}`)));
+}
+
+// Resolve an HF repo to its local snapshot dir. `hf download` is idempotent and
+// prints the snapshot path as its last line.
+function resolveSnapshot(repo) {
+ const out = execFileSync("hf", ["download", repo], {
+ encoding: "utf8",
+ timeout: 1_800_000,
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ const path = out.trim().split(/\r?\n/).pop()?.trim();
+ return path && existsSync(path) ? path : null;
+}
+
+export async function mfluxImageGenerate(intent, ctx) {
+ const specs = ctx?.specs || probeSpecs();
+ const sel = selectModel("imagegen", specs, { preferTier: ctx?.preferTier });
+ if (sel.recommend) return null; // no local model fits -> codex upsell/fallback
+
+ const { model } = sel;
+ const bin = model.invoke.trim().split(/\s+/)[0];
+ // Not installed? Surface the exact enable-command FIRST (before the model
+ // download) so the agent learns the free local path is available instead of
+ // silently taking the codex upsell.
+ try {
+ execFileSync("which", [bin], { stdio: ["ignore", "ignore", "ignore"] });
+ } catch {
+ console.error(
+ `media-use: local image gen not enabled (\`${bin}\` not on PATH). Install for free on-device FLUX: ${model.install}`,
+ );
+ return null;
+ }
+
+ const outPath = join(tmpdir(), `media-use-mflux-${process.pid}-${Date.now()}.png`);
+ const width = ctx?.width || 512;
+ const height = ctx?.height || 512;
+ const seed = ctx?.seed ?? 42;
+
+ const vars = { prompt: intent, w: width, h: height, seed, out: outPath };
+ if (model.repo && model.invoke.includes("{model_path}")) {
+ const snap = model.repo ? resolveSnapshot(model.repo) : null;
+ if (!snap) return null;
+ vars.model_path = snap;
+ }
+
+ const argv = buildArgv(model.invoke, vars);
+ argv.shift(); // drop the bin (already validated)
+ try {
+ execFileSync(bin, argv, {
+ encoding: "utf8",
+ timeout: 1_800_000,
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ } catch (err) {
+ console.error(
+ `media-use: local image gen (${model.id}) failed: ${err.stderr?.toString().trim().slice(-200) || err.message}`,
+ );
+ return null;
+ }
+ if (!existsSync(outPath)) return null;
+ return {
+ localPath: outPath,
+ ext: ".png",
+ source: "generated",
+ metadata: {
+ description: intent,
+ provider: `mflux.${model.id}`,
+ provenance: { model: model.id, tier: model.tier, prompt: intent },
+ },
+ };
+}
diff --git a/skills/media-use/scripts/lib/providers.mjs b/skills/media-use/scripts/lib/providers.mjs
index f8924410d2..6220e88ee9 100644
--- a/skills/media-use/scripts/lib/providers.mjs
+++ b/skills/media-use/scripts/lib/providers.mjs
@@ -1,29 +1,5 @@
-import { sfxProvider } from "./sfx-provider.mjs";
-import { imageProvider, iconProvider } from "./image-provider.mjs";
-import { bgmProvider } from "./bgm-provider.mjs";
-import { brandProvider } from "./brand-provider.mjs";
-
-const STUB = {
- async search() {
- return null;
- },
-};
-
-const registry = {
- bgm: { ...bgmProvider, type: "bgm" },
- sfx: { ...sfxProvider, type: "sfx" },
- voice: { ...STUB, type: "voice" },
- image: { ...imageProvider, type: "image" },
- icon: { ...iconProvider, type: "icon" },
- brand: { ...brandProvider, type: "brand" },
-};
-
-export function getProvider(type) {
- const p = registry[type];
- if (!p) throw new Error(`unknown media type: ${type}`);
- return p;
-}
-
-export function listTypes() {
- return Object.keys(registry);
-}
+// Back-compat surface for the v1 provider API. The ordered, capability-based
+// registry now lives in registry.mjs; this re-exports the v1 helpers so existing
+// callers keep working. New code should import from registry.mjs directly
+// (getProviders / runCapability).
+export { getProvider, listTypes } from "./registry.mjs";
diff --git a/skills/media-use/scripts/lib/registry.mjs b/skills/media-use/scripts/lib/registry.mjs
new file mode 100644
index 0000000000..f90f737a3d
--- /dev/null
+++ b/skills/media-use/scripts/lib/registry.mjs
@@ -0,0 +1,119 @@
+// Provider registry — the v2 contract.
+//
+// Each media type maps to an ORDERED list of provider entries. Providers are
+// tried in order; the first to return a non-null result wins, which keeps
+// resolution deterministic (same request -> same provider -> same file ->
+// reproducible renders). heygen-CLI is always first for the types it serves.
+//
+// An entry exposes any of three capability methods — search / generate /
+// process — plus { name }. media-use holds no keys; each external tool owns its
+// own auth. Providers, by type:
+// - heygen CLI: catalog + TTS, first for every type it serves (sub creds)
+// - mflux: local FLUX-class image gen, spec-selected to the machine's RAM
+// (free, private, offline once cached)
+// - codex CLI: image gen on the user's ChatGPT sub — the better-quality upsell
+// and the fallback when no local model fits
+// - Kokoro (via the hyperframes CLI): local voiceover, free/private default
+// for the voice type, ahead of the paid HeyGen TTS upsell
+//
+// Generation is local-first, cloud-upsell. `ctx.provider` forces one provider
+// (e.g. "make an image with codex").
+
+import { bgmProvider } from "./bgm-provider.mjs";
+import { sfxProvider } from "./sfx-provider.mjs";
+import { imageProvider, iconProvider } from "./image-provider.mjs";
+import { brandProvider } from "./brand-provider.mjs";
+import { heygenTtsGenerate } from "./voice-provider.mjs";
+import { localTtsGenerate } from "./tts-local-provider.mjs";
+import { codexImageGenerate } from "./codex-provider.mjs";
+import { mfluxImageGenerate } from "./mflux-provider.mjs";
+
+// Provider markers: `network` = hits a remote service (skipped by --local-only).
+// `paid` = costs wallet credits (documentation for the agent's cost judgment,
+// X4: agent-initiated paid should confirm). HeyGen catalog SEARCH is free;
+// HeyGen TTS now costs credits, so it is the paid upsell behind local Kokoro.
+const A = (name, caps) => ({ name, ...caps }); // local, free
+const N = (name, caps) => ({ name, network: true, ...caps }); // remote, free
+const P = (name, caps) => ({ name, network: true, paid: true, ...caps }); // remote, paid
+
+// heygen-CLI first (and currently only). All remote providers are skipped by --local-only.
+const REGISTRY = {
+ bgm: [N("heygen.audio.sounds", { search: bgmProvider.search })],
+ sfx: [N("heygen.audio.sounds", { search: sfxProvider.search })],
+ image: [
+ N("heygen.asset.search", { search: imageProvider.search }),
+ // Catalog miss -> generate. Local first (best FLUX-class model the machine's
+ // RAM can run, spec-selected; free, private, kept under --local-only), then
+ // the codex CLI on the user's ChatGPT sub as the better-quality upsell and
+ // the fallback when no local model fits.
+ A("mflux.local", { generate: mfluxImageGenerate }),
+ N("codex.image_gen", { generate: codexImageGenerate }),
+ ],
+ icon: [N("heygen.asset.search", { search: iconProvider.search })],
+ voice: [
+ // Local Kokoro first (free, private, on-device via the hyperframes CLI, kept
+ // under --local-only), then HeyGen TTS as the higher-quality paid upsell and
+ // the fallback when Kokoro is not set up.
+ A("kokoro.local", { generate: localTtsGenerate }),
+ P("heygen.tts", { generate: heygenTtsGenerate }),
+ ],
+ brand: [
+ // Local design spec, not heygen — reads frame.md / design.md tokens.
+ A("design_spec", { search: brandProvider.search }),
+ ],
+};
+
+function listFor(type) {
+ const list = REGISTRY[type];
+ if (!list) throw new Error(`unknown media type: ${type}`);
+ return list;
+}
+
+/** Ordered providers for a type. */
+export function getProviders(type) {
+ return listFor(type);
+}
+
+/** All declared media types. */
+export function listTypes() {
+ return Object.keys(REGISTRY);
+}
+
+/**
+ * Back-compat shim for the v1 single-provider API. Returns the first declared
+ * provider for the type (tagged with `type`); throws for an unknown type.
+ * Kept for v1 callers only — new code should use getProviders/runCapability.
+ */
+export function getProvider(type) {
+ const first = listFor(type)[0] || {};
+ return { ...first, type };
+}
+
+/**
+ * Run a capability across an explicit ordered provider list. Tries each in
+ * order, returns the first non-null result, skips providers that don't expose
+ * the capability. Pure over its input — the unit-testable core of the cascade.
+ *
+ * Offline guard: a `network` provider is skipped when `ctx.localOnly` is set.
+ * Provider override: `ctx.provider` (a full name like "codex.image_gen" or a
+ * prefix like "codex") pins resolution to matching providers only — this is how
+ * a user "make an image WITH codex" forces the upsell instead of taking the
+ * free-first default. An override to a `network` provider ignores --local-only.
+ */
+export async function runProviders(providers, capability, intent, ctx) {
+ const want = ctx?.provider;
+ for (const p of providers) {
+ if (want && p.name !== want && !p.name.startsWith(`${want}.`)) continue;
+ if (p.network && ctx?.localOnly && !want) continue; // --local-only: cache + local only
+ const fn = p[capability];
+ if (typeof fn !== "function") continue;
+ const res = await fn(intent, ctx);
+ if (res) return res;
+ }
+ return null;
+}
+
+/** Run a capability over the providers for a type (deterministic, heygen-first). */
+export async function runCapability(type, capability, intent, ctx) {
+ return runProviders(getProviders(type), capability, intent, ctx);
+}
diff --git a/skills/media-use/scripts/lib/registry.test.mjs b/skills/media-use/scripts/lib/registry.test.mjs
new file mode 100644
index 0000000000..56f48e9ac4
--- /dev/null
+++ b/skills/media-use/scripts/lib/registry.test.mjs
@@ -0,0 +1,159 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { getProviders, getProvider, listTypes, runProviders, runCapability } from "./registry.mjs";
+
+// --- registry shape -------------------------------------------------------
+
+test("listTypes exposes the v2 media types", () => {
+ const types = listTypes();
+ for (const t of ["bgm", "sfx", "image", "icon", "voice", "brand"]) {
+ assert.ok(types.includes(t), `missing type: ${t}`);
+ }
+});
+
+test("heygen provider is first for every type it serves", () => {
+ for (const t of ["bgm", "sfx", "image", "icon"]) {
+ const first = getProviders(t)[0];
+ assert.ok(first, `no enabled provider for ${t}`);
+ assert.match(first.name, /^heygen/, `${t} first provider is ${first.name}`);
+ }
+});
+
+test("sanctioned providers only: heygen, local mflux/kokoro, codex, design spec", () => {
+ const allowed = /^heygen|^mflux\.local$|^kokoro\.local$|^codex\.image_gen$|^design_spec$/;
+ for (const t of listTypes()) {
+ for (const p of getProviders(t)) {
+ assert.ok(allowed.test(p.name), `${t} lists unsanctioned provider: ${p.name}`);
+ }
+ }
+});
+
+test("image cascade: heygen catalog, then local mflux, then the codex upsell", () => {
+ const ps = getProviders("image");
+ assert.match(ps[0].name, /^heygen/, "heygen catalog first");
+ const names = ps.map((p) => p.name);
+ const mflux = ps.find((p) => p.name === "mflux.local");
+ const codex = ps.find((p) => p.name === "codex.image_gen");
+ assert.ok(mflux && typeof mflux.generate === "function", "local mflux registered");
+ assert.ok(codex && typeof codex.generate === "function", "codex upsell registered");
+ assert.ok(names.indexOf("mflux.local") < names.indexOf("codex.image_gen"), "local before codex");
+ assert.ok(!mflux.network, "local mflux is kept under --local-only");
+ assert.ok(codex.network, "codex is network (skipped under --local-only)");
+});
+
+test("voice cascade: local Kokoro first (free), HeyGen TTS as the paid upsell", () => {
+ const ps = getProviders("voice");
+ assert.equal(ps[0].name, "kokoro.local", "local Kokoro comes first now (HeyGen TTS is paid)");
+ assert.ok(!ps[0].network, "local Kokoro kept under --local-only");
+ assert.ok(!ps[0].paid, "local Kokoro is free");
+ const heygen = ps.find((p) => p.name === "heygen.tts");
+ assert.ok(heygen && heygen.paid, "HeyGen TTS is the paid upsell");
+ assert.ok(heygen.network, "HeyGen TTS is network (skipped under --local-only)");
+});
+
+test("ctx.provider forces one generator (e.g. 'make an image WITH codex')", async () => {
+ const providers = [
+ { name: "heygen.asset.search", network: true, search: async () => null },
+ { name: "mflux.local", generate: async () => ({ hit: "local" }) },
+ { name: "codex.image_gen", network: true, generate: async () => ({ hit: "codex" }) },
+ ];
+ // no override: local wins (first generate to return non-null)
+ assert.deepEqual(await runProviders(providers, "generate", "x", {}), { hit: "local" });
+ // override to codex: skip local, use codex even though local would have worked
+ assert.deepEqual(await runProviders(providers, "generate", "x", { provider: "codex" }), {
+ hit: "codex",
+ });
+ // override matches the full name too
+ assert.deepEqual(
+ await runProviders(providers, "generate", "x", { provider: "codex.image_gen" }),
+ { hit: "codex" },
+ );
+ // forcing a network provider ignores --local-only (explicit user intent)
+ assert.deepEqual(
+ await runProviders(providers, "generate", "x", { provider: "codex", localOnly: true }),
+ { hit: "codex" },
+ );
+});
+
+test("getProvider returns the first provider with its type, throws for unknown", () => {
+ const p = getProvider("bgm");
+ assert.equal(p.type, "bgm");
+ assert.equal(typeof p.search, "function");
+ assert.throws(() => getProvider("unknown_type"), /unknown media type/);
+});
+
+test("getProviders throws for unknown type", () => {
+ assert.throws(() => getProviders("nope"), /unknown media type/);
+});
+
+// --- deterministic capability execution (runProviders core) ---------------
+
+test("runProviders calls providers in order and returns the first non-null", async () => {
+ const calls = [];
+ const providers = [
+ {
+ name: "a",
+ enabled: true,
+ search: async () => {
+ calls.push("a");
+ return null;
+ },
+ },
+ {
+ name: "b",
+ enabled: true,
+ search: async () => {
+ calls.push("b");
+ return { hit: "b" };
+ },
+ },
+ {
+ name: "c",
+ enabled: true,
+ search: async () => {
+ calls.push("c");
+ return { hit: "c" };
+ },
+ },
+ ];
+ const res = await runProviders(providers, "search", "x", {});
+ assert.deepEqual(res, { hit: "b" });
+ assert.deepEqual(calls, ["a", "b"], "must stop at first non-null, never call c");
+});
+
+test("runProviders skips providers missing the requested capability", async () => {
+ const providers = [
+ { name: "a", enabled: true /* no search */ },
+ { name: "b", enabled: true, search: async () => ({ hit: "b" }) },
+ ];
+ const res = await runProviders(providers, "search", "x", {});
+ assert.deepEqual(res, { hit: "b" });
+});
+
+test("runProviders returns null when no provider yields a result", async () => {
+ const providers = [{ name: "a", enabled: true, search: async () => null }];
+ assert.equal(await runProviders(providers, "search", "x", {}), null);
+});
+
+test("runCapability('bgm','process') is null — process slot is graceful when unfilled", async () => {
+ assert.equal(await runCapability("bgm", "process", "x", {}), null);
+});
+
+test("--local-only skips every network provider (even free remote ones)", async () => {
+ let remoteRan = false;
+ const providers = [
+ {
+ name: "heygen",
+ network: true,
+ search: async () => {
+ remoteRan = true;
+ return { hit: "net" };
+ },
+ },
+ { name: "local", search: async () => ({ hit: "local" }) },
+ ];
+ assert.deepEqual(await runProviders(providers, "search", "x", { localOnly: true }), {
+ hit: "local",
+ });
+ assert.equal(remoteRan, false, "the remote provider must not be called offline");
+});
diff --git a/skills/media-use/scripts/lib/search.mjs b/skills/media-use/scripts/lib/search.mjs
new file mode 100644
index 0000000000..b545b4852d
--- /dev/null
+++ b/skills/media-use/scripts/lib/search.mjs
@@ -0,0 +1,24 @@
+// Paginated text search over a manifest (project or global) by id / description
+// / entity. Plain substring match — no vector DB (B4): the agent's own file
+// search covers semantics; this just keeps result pages small enough to not
+// blow the context window.
+
+const PAGE = 10;
+
+export function searchRecords(records, query, { page = 1, pageSize = PAGE } = {}) {
+ const q = String(query || "")
+ .trim()
+ .toLowerCase();
+ const matched = q
+ ? records.filter((r) =>
+ [r.id, r.description, r.entity, r.type].some(
+ (f) => f && String(f).toLowerCase().includes(q),
+ ),
+ )
+ : records.slice();
+ const total = matched.length;
+ const pages = Math.max(1, Math.ceil(total / pageSize));
+ const p = Math.min(Math.max(1, page), pages);
+ const start = (p - 1) * pageSize;
+ return { results: matched.slice(start, start + pageSize), total, page: p, pages, pageSize };
+}
diff --git a/skills/media-use/scripts/lib/search.test.mjs b/skills/media-use/scripts/lib/search.test.mjs
new file mode 100644
index 0000000000..8d68a68821
--- /dev/null
+++ b/skills/media-use/scripts/lib/search.test.mjs
@@ -0,0 +1,32 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { searchRecords } from "./search.mjs";
+
+const recs = Array.from({ length: 23 }, (_, i) => ({
+ id: `bgm_${i}`,
+ type: i % 2 ? "bgm" : "sfx",
+ description: i === 5 ? "energetic tech whoosh" : `track ${i}`,
+}));
+
+test("matches id / description / type, case-insensitively", () => {
+ assert.equal(searchRecords(recs, "ENERGETIC").results.length, 1);
+ assert.equal(searchRecords(recs, "energetic").results[0].id, "bgm_5");
+ assert.ok(searchRecords(recs, "sfx").total > 0);
+});
+
+test("caps page size and reports pagination", () => {
+ const r = searchRecords(recs, "", { pageSize: 10 });
+ assert.equal(r.results.length, 10, "never returns more than a page");
+ assert.equal(r.total, 23);
+ assert.equal(r.pages, 3);
+ assert.equal(r.page, 1);
+});
+
+test("page navigation returns the right slice, clamps out-of-range", () => {
+ assert.equal(searchRecords(recs, "", { page: 3, pageSize: 10 }).results.length, 3);
+ assert.equal(searchRecords(recs, "", { page: 99, pageSize: 10 }).page, 3, "clamped to last page");
+});
+
+test("empty query returns everything (paginated)", () => {
+ assert.equal(searchRecords(recs, "").total, 23);
+});
diff --git a/skills/media-use/scripts/lib/specs.mjs b/skills/media-use/scripts/lib/specs.mjs
new file mode 100644
index 0000000000..831e4eb170
--- /dev/null
+++ b/skills/media-use/scripts/lib/specs.mjs
@@ -0,0 +1,81 @@
+// Machine-capability probe for the spec-gated local-model fallback.
+//
+// Local models are USER-INSTALLED and local-use-only — media-use recommends,
+// spec-checks, and assists install, but never bundles or runs them as a service.
+// This probe answers "what tier can this machine actually run?" so selection can
+// offer a medium/large local model, or fall back to recommending the CLI path.
+//
+// `osMod` and `exec` are injectable for tests. `exec(cmd)` returns the command's
+// stdout as a string, or throws / returns null on failure.
+
+import os from "node:os";
+import { execSync } from "node:child_process";
+
+function defaultExec(cmd) {
+ return execSync(cmd, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 4000 });
+}
+
+// Available (not just total) RAM — the real budget for "will this model fit
+// alongside the OS + open apps". On unified-memory Macs the model shares system
+// RAM, so a big model on a busy machine OOMs/thrashes even if total RAM looks
+// ample. macOS: vm_stat free + inactive + speculative + purgeable pages (all
+// reclaimable). Linux: /proc/meminfo MemAvailable. Fallback: total (optimistic
+// but stable when the probe is unavailable, e.g. in tests).
+function availableRamMB(platform, exec, totalMB) {
+ try {
+ if (platform === "darwin") {
+ const out = String(exec("vm_stat"));
+ const pageSize = parseInt((out.match(/page size of (\d+)/) || [])[1] || "16384", 10);
+ const pages = (name) => {
+ const m = out.match(new RegExp(`${name}:\\s+(\\d+)`));
+ return m ? parseInt(m[1], 10) : 0;
+ };
+ const reclaimable =
+ pages("Pages free") +
+ pages("Pages inactive") +
+ pages("Pages speculative") +
+ pages("Pages purgeable");
+ const mb = Math.round((reclaimable * pageSize) / (1024 * 1024));
+ if (mb > 0) return mb;
+ } else if (platform === "linux") {
+ const out = String(exec("cat /proc/meminfo"));
+ const m = out.match(/MemAvailable:\s+(\d+)\s+kB/);
+ if (m) return Math.round(parseInt(m[1], 10) / 1024);
+ }
+ } catch {
+ // probe unavailable — fall through to the total-RAM estimate
+ }
+ return totalMB;
+}
+
+function detectGpu(platform, arch, ramMB, exec) {
+ // Apple Silicon: Metal GPU with unified memory — VRAM tracks system RAM.
+ if (platform === "darwin" && arch === "arm64") {
+ return { present: true, kind: "apple", vramMB: ramMB };
+ }
+ // NVIDIA: query total VRAM. Any failure (no driver, no GPU) -> no GPU.
+ try {
+ const out = exec("nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits");
+ const mb = parseInt(String(out).trim().split(/\r?\n/)[0], 10);
+ if (Number.isFinite(mb) && mb > 0) return { present: true, kind: "nvidia", vramMB: mb };
+ } catch {
+ // fall through — no usable GPU
+ }
+ return { present: false, kind: null, vramMB: 0 };
+}
+
+export function probeSpecs({ osMod = os, exec = defaultExec } = {}) {
+ const platform = osMod.platform();
+ const arch = osMod.arch();
+ const cpuCores = osMod.cpus().length;
+ const ramMB = Math.round(osMod.totalmem() / (1024 * 1024));
+ return {
+ platform,
+ arch,
+ cpuCores,
+ ramMB,
+ availableRamMB: availableRamMB(platform, exec, ramMB),
+ appleSilicon: platform === "darwin" && arch === "arm64",
+ gpu: detectGpu(platform, arch, ramMB, exec),
+ };
+}
diff --git a/skills/media-use/scripts/lib/specs.test.mjs b/skills/media-use/scripts/lib/specs.test.mjs
new file mode 100644
index 0000000000..1c9172b318
--- /dev/null
+++ b/skills/media-use/scripts/lib/specs.test.mjs
@@ -0,0 +1,75 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { probeSpecs } from "./specs.mjs";
+
+// Fake os module + exec so the probe is deterministic across CI machines.
+const fakeOs = (over = {}) => ({
+ platform: () => over.platform ?? "linux",
+ arch: () => over.arch ?? "x64",
+ cpus: () => Array.from({ length: over.cores ?? 8 }),
+ totalmem: () => (over.ramMB ?? 16384) * 1024 * 1024,
+});
+
+test("probeSpecs reports structured caps", () => {
+ const s = probeSpecs({ osMod: fakeOs({ cores: 12, ramMB: 32768 }), exec: () => null });
+ assert.equal(s.cpuCores, 12);
+ assert.equal(s.ramMB, 32768);
+ assert.equal(s.platform, "linux");
+ assert.equal(s.gpu.present, false);
+ // probe unavailable (exec returns null) -> availableRamMB falls back to total
+ assert.equal(s.availableRamMB, 32768);
+});
+
+test("availableRamMB is read from /proc/meminfo on Linux", () => {
+ const exec = (cmd) =>
+ cmd.includes("meminfo") ? "MemTotal: 33554432 kB\nMemAvailable: 8388608 kB\n" : null;
+ const s = probeSpecs({ osMod: fakeOs({ platform: "linux", ramMB: 32768 }), exec });
+ assert.equal(s.availableRamMB, 8192, "8388608 kB -> 8192 MB");
+});
+
+test("availableRamMB is summed from reclaimable vm_stat pages on macOS", () => {
+ const vmStat =
+ "Mach Virtual Memory Statistics: (page size of 16384 bytes)\n" +
+ "Pages free: 100000.\n" +
+ "Pages inactive: 200000.\n" +
+ "Pages speculative: 50000.\n" +
+ "Pages purgeable: 10000.\n";
+ const exec = (cmd) => (cmd.includes("vm_stat") ? vmStat : null);
+ const s = probeSpecs({
+ osMod: fakeOs({ platform: "darwin", arch: "arm64", ramMB: 24576 }),
+ exec,
+ });
+ // (100000+200000+50000+10000) pages * 16384 B / 1MiB = 5625 MB
+ assert.equal(s.availableRamMB, 5625);
+});
+
+test("Apple Silicon is detected as a unified-memory GPU", () => {
+ const s = probeSpecs({
+ osMod: fakeOs({ platform: "darwin", arch: "arm64", ramMB: 24576 }),
+ exec: () => null,
+ });
+ assert.equal(s.appleSilicon, true);
+ assert.equal(s.gpu.present, true);
+ assert.equal(s.gpu.kind, "apple");
+ // unified memory: VRAM tracks system RAM
+ assert.equal(s.gpu.vramMB, 24576);
+});
+
+test("NVIDIA GPU is detected via nvidia-smi VRAM query", () => {
+ const exec = (cmd) => (cmd.includes("nvidia-smi") ? "24564" : null);
+ const s = probeSpecs({ osMod: fakeOs({ platform: "linux" }), exec });
+ assert.equal(s.gpu.present, true);
+ assert.equal(s.gpu.kind, "nvidia");
+ assert.equal(s.gpu.vramMB, 24564);
+});
+
+test("no GPU when nvidia-smi is absent / fails", () => {
+ const s = probeSpecs({
+ osMod: fakeOs({ platform: "linux" }),
+ exec: () => {
+ throw new Error("command not found");
+ },
+ });
+ assert.equal(s.gpu.present, false);
+ assert.equal(s.gpu.vramMB, 0);
+});
diff --git a/skills/media-use/scripts/lib/telemetry.mjs b/skills/media-use/scripts/lib/telemetry.mjs
new file mode 100644
index 0000000000..ed82491b28
--- /dev/null
+++ b/skills/media-use/scripts/lib/telemetry.mjs
@@ -0,0 +1,74 @@
+// Anonymous, opt-out usage tracking for media-use, mirroring the hyperframes CLI
+// telemetry (packages/cli/src/telemetry). Answers "is this actually used, and
+// which capabilities" without any PII: we send the media TYPE, the resolution
+// SOURCE, and the winning PROVIDER: never the intent text, file names, or paths.
+//
+// Same public PostHog project key as the CLI (a write-only ingestion key, safe
+// to ship), same opt-outs (DO_NOT_TRACK / HYPERFRAMES_NO_TELEMETRY / CI), and
+// $ip:null so no IP is recorded. Fire-and-forget: telemetry never blocks a
+// resolve and never throws into it.
+
+import { randomUUID } from "node:crypto";
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
+import { homedir } from "node:os";
+import { join } from "node:path";
+
+const POSTHOG_API_KEY = "phc_zjjbX0PnWxERXrMHhkEJWj9A9BhGVLRReICgsfTMmpx";
+const POSTHOG_HOST = "https://us.i.posthog.com";
+const TIMEOUT_MS = 1500;
+
+/** True when telemetry must NOT be sent (opt-out envs, CI, dev). */
+export function optedOut() {
+ return (
+ process.env.HYPERFRAMES_NO_TELEMETRY === "1" ||
+ process.env.DO_NOT_TRACK === "1" ||
+ process.env.CI === "true" ||
+ process.env.CI === "1" ||
+ process.env.NODE_ENV === "development"
+ );
+}
+
+// Stable per-machine anonymous id, persisted in the dir media-use already owns.
+function anonymousId() {
+ const dir = join(homedir(), ".media");
+ const file = join(dir, "anon-id");
+ try {
+ if (existsSync(file)) return readFileSync(file, "utf8").trim();
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
+ const id = randomUUID();
+ writeFileSync(file, id);
+ return id;
+ } catch {
+ return "anon"; // best-effort; a shared bucket is fine if the fs is read-only
+ }
+}
+
+/**
+ * Fire-and-forget a single event to PostHog. Best-effort: awaited with a short
+ * timeout so a short-lived script flushes before exit, but any failure (offline,
+ * opted out) is swallowed. `properties` must be non-PII (no intent/paths).
+ */
+export async function track(event, properties = {}) {
+ if (optedOut()) return;
+ const body = JSON.stringify({
+ api_key: POSTHOG_API_KEY,
+ batch: [
+ {
+ event,
+ properties: { ...properties, surface: "media-use", $ip: null },
+ distinct_id: anonymousId(),
+ timestamp: new Date().toISOString(),
+ },
+ ],
+ });
+ try {
+ await fetch(`${POSTHOG_HOST}/batch/`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json", Connection: "close" },
+ body,
+ signal: AbortSignal.timeout(TIMEOUT_MS),
+ });
+ } catch {
+ // telemetry is best-effort; never surface into the command
+ }
+}
diff --git a/skills/media-use/scripts/lib/telemetry.test.mjs b/skills/media-use/scripts/lib/telemetry.test.mjs
new file mode 100644
index 0000000000..ba8d24b68a
--- /dev/null
+++ b/skills/media-use/scripts/lib/telemetry.test.mjs
@@ -0,0 +1,35 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { optedOut, track } from "./telemetry.mjs";
+
+test("optedOut respects DO_NOT_TRACK / HYPERFRAMES_NO_TELEMETRY / CI", () => {
+ const saved = { ...process.env };
+ try {
+ for (const k of ["DO_NOT_TRACK", "HYPERFRAMES_NO_TELEMETRY", "CI", "NODE_ENV"])
+ delete process.env[k];
+ assert.equal(optedOut(), false, "default: tracking allowed");
+ process.env.DO_NOT_TRACK = "1";
+ assert.equal(optedOut(), true, "DO_NOT_TRACK opts out");
+ delete process.env.DO_NOT_TRACK;
+ process.env.HYPERFRAMES_NO_TELEMETRY = "1";
+ assert.equal(optedOut(), true, "HYPERFRAMES_NO_TELEMETRY opts out");
+ delete process.env.HYPERFRAMES_NO_TELEMETRY;
+ process.env.CI = "true";
+ assert.equal(optedOut(), true, "CI opts out");
+ } finally {
+ for (const k of Object.keys(process.env)) if (!(k in saved)) delete process.env[k];
+ Object.assign(process.env, saved);
+ }
+});
+
+test("track is a no-op (no network, resolves) when opted out", async () => {
+ const saved = process.env.DO_NOT_TRACK;
+ process.env.DO_NOT_TRACK = "1";
+ try {
+ // must resolve immediately without throwing or hitting the network
+ await track("media_use_resolve", { type: "bgm", source: "search" });
+ } finally {
+ if (saved === undefined) delete process.env.DO_NOT_TRACK;
+ else process.env.DO_NOT_TRACK = saved;
+ }
+});
diff --git a/skills/media-use/scripts/lib/tts-local-provider.mjs b/skills/media-use/scripts/lib/tts-local-provider.mjs
new file mode 100644
index 0000000000..e3d1544441
--- /dev/null
+++ b/skills/media-use/scripts/lib/tts-local-provider.mjs
@@ -0,0 +1,64 @@
+import { execFileSync } from "node:child_process";
+import { existsSync, statSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+// Local voiceover via the packaged Kokoro-82M TTS (the `hyperframes tts` CLI),
+// the free/private default now that HeyGen TTS costs wallet credits. Kokoro runs
+// on-device (CPU, faster-than-realtime, bundled voices, native word timestamps),
+// so no key and no per-call charge. When Kokoro is not set up, this returns null
+// and the registry falls through to the HeyGen TTS upsell.
+//
+// Delegated to the hyperframes CLI (same as transcribe / remove-background), not
+// re-implemented here. ffprobe reads the duration back for the ledger.
+
+function probeDurationSeconds(file) {
+ try {
+ const out = execFileSync(
+ "ffprobe",
+ ["-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", file],
+ { encoding: "utf8", timeout: 15000 },
+ );
+ const d = parseFloat(String(out).trim());
+ return Number.isFinite(d) ? d : undefined;
+ } catch {
+ return undefined;
+ }
+}
+
+export async function localTtsGenerate(intent, ctx) {
+ const outPath = join(tmpdir(), `media-use-kokoro-${process.pid}-${Date.now()}.wav`);
+ const argv = ["hyperframes", "tts", intent, "--output", outPath];
+ if (ctx?.voice) argv.push("--voice", ctx.voice);
+ if (ctx?.lang && ctx.lang !== "en") argv.push("--lang", ctx.lang);
+ try {
+ execFileSync("npx", argv, {
+ encoding: "utf8",
+ timeout: 300000,
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ } catch (err) {
+ // `hyperframes tts` prints its "kokoro-onnx not installed" hint to stdout
+ // (clack UI), so read both streams and surface the actionable enable-command
+ // rather than a bare "Command failed": otherwise resolve silently falls
+ // through to the PAID HeyGen TTS upsell when free local voice was one pip away.
+ const out = `${err.stdout?.toString() ?? ""}${err.stderr?.toString() ?? ""}`.trim();
+ const hint = /not installed|pip install kokoro/i.test(out)
+ ? "install for free on-device voice: pip install kokoro-onnx soundfile (or set HYPERFRAMES_PYTHON to a venv that has it)"
+ : out.slice(-200) || err.message;
+ console.error(`media-use: local voice not enabled (kokoro). ${hint}`);
+ return null;
+ }
+ if (!existsSync(outPath) || statSync(outPath).size === 0) return null;
+ return {
+ localPath: outPath,
+ ext: ".wav",
+ source: "generated",
+ metadata: {
+ description: intent,
+ provider: "kokoro.local",
+ duration: probeDurationSeconds(outPath),
+ provenance: { engine: "kokoro-82m", prompt: intent },
+ },
+ };
+}
diff --git a/skills/media-use/scripts/lib/usage.mjs b/skills/media-use/scripts/lib/usage.mjs
new file mode 100644
index 0000000000..806f146ba0
--- /dev/null
+++ b/skills/media-use/scripts/lib/usage.mjs
@@ -0,0 +1,57 @@
+import { readFileSync, readdirSync, existsSync } from "node:fs";
+import { join } from "node:path";
+
+// Asset in-use detection: which manifest assets are actually referenced by the
+// project's compositions. Answers "is this safe to prune?" from the CLI. (The
+// Studio Asset tab computes its in-use filter separately from the live timeline;
+// this is the skill-side equivalent for headless use.)
+//
+// ponytail: substring match of each asset's filename against the .html text
+// (covers src= / href= / url() / data-* without parsing HTML). False positives
+// only if a filename literally appears in prose; fine for a filter. Upgrade to
+// attribute parsing if that ever bites.
+
+function compositionHtml(projectDir) {
+ let files = [];
+ try {
+ files = readdirSync(projectDir).filter((f) => f.endsWith(".html"));
+ } catch {
+ return "";
+ }
+ const sub = join(projectDir, "compositions");
+ if (existsSync(sub)) {
+ try {
+ for (const f of readdirSync(sub))
+ if (f.endsWith(".html")) files.push(join("compositions", f));
+ } catch {
+ // ignore unreadable subdir
+ }
+ }
+ return files
+ .map((f) => {
+ try {
+ return readFileSync(join(projectDir, f), "utf8");
+ } catch {
+ return "";
+ }
+ })
+ .join("\n");
+}
+
+/** Tag each record with `inUse` (referenced by some composition). */
+export function tagUsage(records, projectDir) {
+ const html = compositionHtml(projectDir);
+ return records.map((r) => {
+ const file = r.path ? r.path.split("/").pop() : r.id;
+ return { ...r, inUse: Boolean(file) && html.includes(file) };
+ });
+}
+
+/** Split records into { used, unused } for the filter. */
+export function partitionUsage(records, projectDir) {
+ const tagged = tagUsage(records, projectDir);
+ return {
+ used: tagged.filter((r) => r.inUse),
+ unused: tagged.filter((r) => !r.inUse),
+ };
+}
diff --git a/skills/media-use/scripts/lib/usage.test.mjs b/skills/media-use/scripts/lib/usage.test.mjs
new file mode 100644
index 0000000000..271e707627
--- /dev/null
+++ b/skills/media-use/scripts/lib/usage.test.mjs
@@ -0,0 +1,54 @@
+import { strict as assert } from "node:assert";
+import { test } from "node:test";
+import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+import { tmpdir } from "node:os";
+import { tagUsage, partitionUsage } from "./usage.mjs";
+
+function project(html) {
+ const dir = mkdtempSync(join(tmpdir(), "mu-usage-"));
+ writeFileSync(join(dir, "index.html"), html);
+ return dir;
+}
+
+const records = [
+ { id: "bgm_001", path: ".media/audio/bgm/bgm_001.wav", description: "used track" },
+ { id: "bgm_002", path: ".media/audio/bgm/bgm_002.wav", description: "orphan track" },
+];
+
+test("an asset referenced by a composition is marked in-use", () => {
+ const dir = project(`<audio src="assets/bgm_001.wav"></audio>`);
+ try {
+ const tagged = tagUsage(records, dir);
+ assert.equal(tagged.find((r) => r.id === "bgm_001").inUse, true);
+ assert.equal(tagged.find((r) => r.id === "bgm_002").inUse, false);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
+
+test("partitionUsage splits used vs unused for the filter", () => {
+ const dir = project(`<img src="bgm_001.wav">`);
+ try {
+ const { used, unused } = partitionUsage(records, dir);
+ assert.deepEqual(
+ used.map((r) => r.id),
+ ["bgm_001"],
+ );
+ assert.deepEqual(
+ unused.map((r) => r.id),
+ ["bgm_002"],
+ );
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
+
+test("no compositions -> everything reads as unused (safe default)", () => {
+ const dir = mkdtempSync(join(tmpdir(), "mu-usage-"));
+ try {
+ assert.equal(partitionUsage(records, dir).used.length, 0);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/skills/media-use/scripts/lib/voice-provider.mjs b/skills/media-use/scripts/lib/voice-provider.mjs
new file mode 100644
index 0000000000..985ff718b9
--- /dev/null
+++ b/skills/media-use/scripts/lib/voice-provider.mjs
@@ -0,0 +1,67 @@
+import { execFileSync } from "node:child_process";
+
+// Voice / TTS generation via the HeyGen CLI — the only external CLI media-use
+// shells (CLI-only invariant: media-use holds no keys; the CLI owns auth).
+// Flags verified against `heygen voice speech create --help` (v0.1.6).
+
+function runJson(bin, argv, label) {
+ let out;
+ try {
+ out = execFileSync(bin, argv, {
+ encoding: "utf8",
+ timeout: 120000,
+ stdio: ["pipe", "pipe", "pipe"],
+ });
+ } catch (err) {
+ console.error(
+ `media-use: \`${bin}\` ${label} failed: ${err.stderr?.toString().trim() || err.message}`,
+ );
+ return null;
+ }
+ try {
+ return JSON.parse(out);
+ } catch {
+ return null;
+ }
+}
+
+function result(url, duration, provider, intent) {
+ if (!url) return null;
+ return {
+ url,
+ source: "generated",
+ metadata: {
+ description: intent,
+ provider,
+ ...(duration != null && { duration }),
+ provenance: { prompt: intent },
+ },
+ };
+}
+
+// HeyGen TTS requires a starfish-engine voice. Default to the first one the
+// catalog returns (deterministic order); pass ctx.voiceId to override.
+// ponytail: listed once per process; the resolved asset is frozen + cached after
+// first use, so the network list only happens on a cache miss.
+let cachedVoiceId;
+function defaultVoiceId() {
+ if (cachedVoiceId !== undefined) return cachedVoiceId;
+ const j = runJson(
+ "heygen",
+ ["voice", "list", "--engine", "starfish", "--limit", "1"],
+ "voice list",
+ );
+ cachedVoiceId = j?.data?.[0]?.voice_id || null;
+ return cachedVoiceId;
+}
+
+export async function heygenTtsGenerate(intent, ctx) {
+ const voiceId = ctx?.voiceId || defaultVoiceId();
+ if (!voiceId) return null;
+ const p = runJson(
+ "heygen",
+ ["voice", "speech", "create", "--text", intent, "--voice-id", voiceId],
+ "tts",
+ );
+ return result(p?.data?.audio_url, p?.data?.duration, "heygen.tts", intent);
+}
diff --git a/skills/media-use/scripts/lib/words.mjs b/skills/media-use/scripts/lib/words.mjs
new file mode 100644
index 0000000000..114cf766ce
--- /dev/null
+++ b/skills/media-use/scripts/lib/words.mjs
@@ -0,0 +1,18 @@
+export function normalizeWords(input) {
+ const raw = Array.isArray(input) ? input : Array.isArray(input?.words) ? input.words : [];
+ return raw
+ .map((w, index) => {
+ const text = String(w?.text ?? w?.word ?? "").trim();
+ const start = Number(w?.start);
+ const end = Number(w?.end);
+ if (!text || !Number.isFinite(start) || !Number.isFinite(end)) return null;
+ return { id: w?.id ?? `w${index}`, text, start, end };
+ })
+ .filter(Boolean);
+}
+
+export function wordListsFromMediaMeta(input) {
+ if (Array.isArray(input) || Array.isArray(input?.words)) return [normalizeWords(input)];
+ if (!Array.isArray(input?.voices)) return [];
+ return input.voices.map((voice) => normalizeWords(voice)).filter((words) => words.length > 0);
+}
diff --git a/skills/media-use/scripts/resolve.mjs b/skills/media-use/scripts/resolve.mjs
index 242b49406f..d06d5dc7d4 100644
--- a/skills/media-use/scripts/resolve.mjs
+++ b/skills/media-use/scripts/resolve.mjs
@@ -1,14 +1,15 @@
#!/usr/bin/env node
import { existsSync } from "node:fs";
-import { resolve, join, extname } from "node:path";
+import { resolve, join, extname, basename } from "node:path";
import { parseArgs } from "node:util";
import { appendRecord, findByPrompt, findByEntity, nextId, typeSubdir } from "./lib/manifest.mjs";
import { regenerateIndex } from "./lib/index-gen.mjs";
-import { cacheGet, cacheGetByEntity, importFromCache } from "./lib/cache.mjs";
-import { getProvider, listTypes } from "./lib/providers.mjs";
-import { freezeUrl, freezeLocalFile } from "./lib/freeze.mjs";
+import { cacheGet, cacheGetByEntity, importFromCache, cachePut } from "./lib/cache.mjs";
+import { runCapability, listTypes } from "./lib/registry.mjs";
+import { freezeUrl, freezeLocalFile, isDirectMediaUrl } from "./lib/freeze.mjs";
import { findExistingAsset } from "./lib/adopt.mjs";
+import { track } from "./lib/telemetry.mjs";
const { values: args } = parseArgs({
options: {
@@ -17,6 +18,9 @@ const { values: args } = parseArgs({
entity: { type: "string", short: "e" },
project: { type: "string", short: "p", default: "." },
adopt: { type: "boolean", default: false },
+ from: { type: "string" },
+ "local-only": { type: "boolean", default: false },
+ provider: { type: "string" },
json: { type: "boolean", default: false },
help: { type: "boolean", short: "h", default: false },
},
@@ -37,6 +41,7 @@ Options:
--entity, -e Entity name for cache matching (optional)
--project, -p Project directory (default: .)
--adopt Adopt all existing assets/ files into the manifest
+ --provider Force one generator (e.g. codex, mflux, kokoro, heygen)
--json Output JSON instead of one-line result
--help, -h Show this help`);
process.exit(0);
@@ -57,11 +62,22 @@ if (args.adopt) {
process.exit(0);
}
+// Ingest: freeze a user-supplied local file or direct public URL (no search).
+if (args.from) {
+ await ingest(args.from);
+ process.exit(0);
+}
+
if (!args.type || !args.intent) {
console.error("error: --type and --intent are required");
process.exit(2);
}
+if (!listTypes().includes(args.type)) {
+ console.error(`error: unknown media type: ${args.type} (known: ${listTypes().join(", ")})`);
+ process.exit(2);
+}
+
const projectDir = resolve(args.project);
const type = args.type;
const intent = args.intent;
@@ -134,31 +150,44 @@ async function run() {
}
}
- // 3. provider search
- const provider = getProvider(type);
+ // Offline guard: --local-only skips every remote provider (HeyGen catalog),
+ // leaving the project + global cache and any local provider.
+ const localOnly = args["local-only"];
+ const ctx = { entity, projectDir, localOnly, provider: args.provider };
+
+ // 3. provider search — registry tries providers in order (heygen-CLI first)
let searchResult = null;
try {
- searchResult = await provider.search(intent, { entity, projectDir });
+ searchResult = await runCapability(type, "search", intent, ctx);
} catch {
// search failed, try generate
}
- // 4. generate fallback
- if (!searchResult && provider.generate) {
+ // 4. generate fallback — same ordered cascade for the generate capability
+ if (!searchResult) {
try {
- searchResult = await provider.generate(intent, { entity, projectDir });
+ searchResult = await runCapability(type, "generate", intent, ctx);
} catch {
// generate failed too
}
}
if (!searchResult) {
+ await track("media_use_resolve_miss", {
+ type,
+ local_only: !!localOnly,
+ provider_override: !!args.provider,
+ });
+ // brand stays local: no frame.md/design.md -> upsell the HyperFrames design
+ // flow rather than reporting a generic miss (B5).
+ const msg =
+ type === "brand"
+ ? "no brand spec found — add a frame.md or design.md (colors/font/logo) to this project. Run the HyperFrames design flow to create one; brand tokens are read locally for deterministic rendering."
+ : `no provider could resolve ${type}: "${intent}"`;
if (args.json) {
- console.log(
- JSON.stringify({ ok: false, error: `no provider could resolve ${type}: "${intent}"` }),
- );
+ console.log(JSON.stringify({ ok: false, error: msg }));
} else {
- console.error(`error: no provider could resolve ${type}: "${intent}"`);
+ console.error(`error: ${msg}`);
}
process.exit(1);
}
@@ -200,16 +229,77 @@ async function run() {
appendRecord(projectDir, record);
regenerateIndex(projectDir);
+ // Auto-promote: surface every fetched asset in the global cache so it's
+ // reusable across all hyperframes projects (B3). Non-fatal; dedup by sha.
+ // ponytail: promotes search/generate/ingest assets (the ones media-use
+ // fetched), not bulk --adopt imports — add those if cross-project reuse of
+ // pre-existing project assets is wanted.
+ try {
+ cachePut(fullPath, record);
+ } catch {
+ // promotion is best-effort; a resolve still succeeds locally
+ }
return result(record, searchResult.source || "search");
}
+async function ingest(src) {
+ const projectDir = resolve(args.project);
+ const type = args.type;
+ if (!type || !listTypes().includes(type)) {
+ console.error(`error: --from requires --type (one of: ${listTypes().join(", ")})`);
+ process.exit(2);
+ }
+ const isUrl = /^https?:\/\//i.test(src);
+ if (isUrl && !isDirectMediaUrl(src)) {
+ console.error(
+ `error: --from takes a direct public media URL or a local file; "${src}" is not a direct media link (no platform pages / yt-dlp)`,
+ );
+ process.exit(2);
+ }
+ if (!isUrl && !existsSync(resolve(src))) {
+ console.error(`error: file not found: ${src}`);
+ process.exit(2);
+ }
+ const id = nextId(projectDir, type);
+ const ext = extname(isUrl ? new URL(src).pathname : src) || defaultExt(type);
+ const localPath = `.media/${typeSubdir(type)}/${id}${ext}`;
+ const fullPath = join(projectDir, localPath);
+ if (isUrl) await freezeUrl(src, fullPath);
+ else freezeLocalFile(resolve(src), fullPath);
+ const record = {
+ id,
+ type,
+ path: localPath,
+ source: "ingested",
+ description: basename(src.split("?")[0]),
+ provenance: { provider: "local", from: src },
+ };
+ appendRecord(projectDir, record);
+ regenerateIndex(projectDir);
+ try {
+ cachePut(fullPath, record); // surface ingested assets globally too (B3)
+ } catch {
+ // best-effort
+ }
+ await result(record, "ingested");
+}
+
function typesMatch(a, b) {
if (a === b) return true;
const visual = new Set(["icon", "image"]);
return visual.has(a) && visual.has(b);
}
-function result(record, source) {
+async function result(record, source) {
+ // Non-PII usage event: which media type, how it resolved, which provider won.
+ // Never the intent text or paths. Awaited so a short-lived run flushes it.
+ await track("media_use_resolve", {
+ type: record.type,
+ source,
+ provider: record.provenance?.provider,
+ local_only: !!args["local-only"],
+ provider_override: !!args.provider,
+ });
if (args.json) {
console.log(JSON.stringify({ ok: true, ...record, _source: source }));
} else {
diff --git a/skills/motion-graphics/phases/source/guide.md b/skills/motion-graphics/phases/source/guide.md
index 9ab18e0732..26297a758a 100644
--- a/skills/motion-graphics/phases/source/guide.md
+++ b/skills/motion-graphics/phases/source/guide.md
@@ -1,6 +1,6 @@
# source phase — asset sourcing (asset-first)
-Runs **only when `shot-plan.json.asset_needs` is non-empty** (the form categories never reach here). Sources each needed asset → a **frozen project-local path** + a ledger (`assets/index.md`). Uses `/hyperframes-media` (capture / asset prep) plus, **when an external asset-search skill such as media-use is installed**, its `resolve` step. If no such search capability is available, it **degrades to asset-free** (see below).
+Runs **only when `shot-plan.json.asset_needs` is non-empty** (the form categories never reach here). Sources each needed asset → a **frozen project-local path** + a ledger (`assets/index.md`). Uses `/media-use` (capture / asset prep) plus, **when an external asset-search skill such as media-use is installed**, its `resolve` step. If no such search capability is available, it **degrades to asset-free** (see below).
## Per asset_need
diff --git a/skills/music-to-video/SKILL.md b/skills/music-to-video/SKILL.md
index e7f28c5281..e23cfaddc3 100644
--- a/skills/music-to-video/SKILL.md
+++ b/skills/music-to-video/SKILL.md
@@ -24,7 +24,7 @@ Workflow: Step 0 setup → `hyperframes.json` + `assets/bgm.mp3`; Step 1 analyze
Goal: Establish the music source, create the HyperFrames project, and note any user-supplied media.
-The **music is the spine** — establish one track before anything else. This skill is tuned for **fast, high-energy BGM**: a strong beat grid drives the cuts (calm tracks work, but pace by phrase rather than beat). If the user gave you audio — a music file, or a video to pull the audio from — use it. If not, generate one: choose the mood from the user's description (e.g. "driving synthwave", "trap beat", "upbeat corporate") and produce a track via `/hyperframes-media` (`references/bgm.md` — HeyGen retrieval when credentialed, else local Lyria / MusicGen; ElevenLabs or another generator also works). Before generating, run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it)** — it shows whether BGM comes from HeyGen or local MusicGen and, if not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or continue offline with local MusicGen — before generating the track**; don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `/hyperframes-media` → Preflight for the canonical guidance. Either way the track lands at `assets/bgm.mp3`. Stage any user-supplied images or videos so frames can weave them in on the beat grid; otherwise typography carries the whole video.
+The **music is the spine** — establish one track before anything else. This skill is tuned for **fast, high-energy BGM**: a strong beat grid drives the cuts (calm tracks work, but pace by phrase rather than beat). If the user gave you audio — a music file, or a video to pull the audio from — use it. If not, generate one: choose the mood from the user's description (e.g. "driving synthwave", "trap beat", "upbeat corporate") and produce a track via `/media-use` (`references/bgm.md` — HeyGen retrieval when credentialed, else local Lyria / MusicGen; ElevenLabs or another generator also works). Before generating, run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it)** — it shows whether BGM comes from HeyGen or local MusicGen and, if not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or continue offline with local MusicGen — before generating the track**; don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `/media-use` → Preflight for the canonical guidance. Either way the track lands at `assets/bgm.mp3`. Stage any user-supplied images or videos so frames can weave them in on the beat grid; otherwise typography carries the whole video.
Initialize only if `hyperframes.json` is missing. Name `<project>` from the brief in kebab-case, such as `midnight-drive-loop` — never a timestamp. `init` checks the installed skills against the latest on GitHub and updates the global set if any are out of date.
diff --git a/skills/pr-to-video/SKILL.md b/skills/pr-to-video/SKILL.md
index f2a8b7c525..bdf89756d9 100644
--- a/skills/pr-to-video/SKILL.md
+++ b/skills/pr-to-video/SKILL.md
@@ -44,7 +44,7 @@ Initialize only if `hyperframes.json` is missing. Name `<project>` from the PR i
`npx hyperframes init "videos/<project>" --non-interactive --example=blank` — `init` checks the installed skills against the latest on GitHub and updates the global set if any are out of date.
-**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../hyperframes-media` → Preflight for the canonical guidance.
+**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../media-use` → Preflight for the canonical guidance.
**Gate:** `hyperframes.json` exists; the PR ref is captured; angle, length, aspect ratio, and language are locked; sign-in status was shown (signed in, or continuing offline).
@@ -117,7 +117,7 @@ Start audio after Step 3 approval. Run it in the background, then continue to St
`node <SKILL_DIR>/scripts/audio.mjs --script ./SCRIPT.md --storyboard ./STORYBOARD.md --hyperframes . --out ./audio_meta.json &`
-The audio script handles narration, word timings, BGM lookup from HeyGen's music library, and timing metadata. BGM mood comes from the storyboard's `music:` field. This uses the HeyGen Audio API for retrieval, not generation, and the same `~/.heygen` credential as TTS. For provider details, read `../hyperframes-media/references/tts.md`.
+The audio script handles narration, word timings, BGM lookup from HeyGen's music library, and timing metadata. BGM mood comes from the storyboard's `music:` field. This uses the HeyGen Audio API for retrieval, not generation, and the same `~/.heygen` credential as TTS. For provider details, read `../media-use/audio/references/tts.md`.
If there is no narration and no `SCRIPT.md`, skip voice generation. BGM may still run if the storyboard has a music mood.
@@ -229,7 +229,7 @@ The reusable, domain-agnostic shot shapes live in `../hyperframes-animation/blue
| `[../hyperframes-animation/blueprints-index.md](../hyperframes-animation/blueprints-index.md)` | Step 3: role→blueprint menu. Step 4: pick the shot shape. |
| `[../hyperframes-core/references/storyboard-format.md](../hyperframes-core/references/storyboard-format.md)` | Step 3: write `STORYBOARD.md`. |
| `[../hyperframes-core/references/script-format.md](../hyperframes-core/references/script-format.md)` | Step 3: write `SCRIPT.md`. |
-| `[../hyperframes-media/references/tts.md](../hyperframes-media/references/tts.md)` | Step 3.1: choose or understand TTS providers. |
+| `[../media-use/audio/references/tts.md](../media-use/audio/references/tts.md)` | Step 3.1: choose or understand TTS providers. |
| `[references/visual-design.md](references/visual-design.md)` | Step 4: write the frame's shot sequence (+ Layout vocabulary). |
| `[references/code-vocabulary.md](references/code-vocabulary.md)` | Step 4 + 5: pick + fill the `code-*` block for a code beat. |
| `[references/motion-language.md](references/motion-language.md)` | Step 4: the motion vocabulary + the motion doctrine. |
diff --git a/skills/pr-to-video/scripts/audio.mjs b/skills/pr-to-video/scripts/audio.mjs
index 121ac69e2f..864e66214f 100644
--- a/skills/pr-to-video/scripts/audio.mjs
+++ b/skills/pr-to-video/scripts/audio.mjs
@@ -1,12 +1,14 @@
#!/usr/bin/env node
-// audio.mjs — pr-to-video audio ADAPTER. The TTS / BGM / SFX implementation
+// audio.mjs — audio ADAPTER (reuses the product-launch SCRIPT.md / STORYBOARD.md
+// model; this file is intentionally identical across the reusing skills). The
+// TTS / BGM / SFX implementation
// no longer lives here: it is the shared engine at
-// ../../hyperframes-media/scripts/audio.mjs. This file only (a) maps the
-// frame model (SCRIPT.md frames + STORYBOARD.md music/sfx) into the
+// ../../media-use/audio/scripts/audio.mjs. This file only (a) maps the
+// product-launch model (SCRIPT.md frames + STORYBOARD.md music/sfx) into the
// engine's neutral audio_request.json, (b) converts the engine's id-keyed
// audio_meta back into the frame-keyed shape captions.mjs / assemble-index.mjs
// already consume, and (c) keeps the local `sync-durations` pass (it rewrites
-// STORYBOARD.md, which is this skill's concern).
+// STORYBOARD.md, which is product-launch-specific).
//
// Three modes (unchanged CLI surface):
// (default) generate — engine --only tts,bgm. BGM mode is "retrieve" (strict:
@@ -27,7 +29,7 @@ import { fileURLToPath } from "node:url";
import { parseStoryboard } from "./lib/storyboard.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
-const DEFAULT_ENGINE = join(HERE, "..", "..", "hyperframes-media", "scripts", "audio.mjs");
+const DEFAULT_ENGINE = join(HERE, "..", "..", "media-use", "audio", "scripts", "audio.mjs");
const flag = (argv, name, def) => {
const i = argv.indexOf(`--${name}`);
@@ -86,9 +88,9 @@ function runEngine({ request, hyperframesDir, neutral, only, extra = [] }, die)
if (r.status !== 0) die(`media audio engine exited ${r.status}`);
}
-// Engine neutral meta (id-keyed) → frame-keyed meta consumed by
+// Engine neutral meta (id-keyed) → product-launch meta (frame-keyed) consumed by
// captions.mjs / assemble-index.mjs. id is the zero-padded frame number.
-function toFrameKeyedMeta(neutral) {
+function toProductLaunchMeta(neutral) {
const voices = (neutral.voices ?? []).map((v) => ({
frame: Number(v.id),
path: v.path,
@@ -152,7 +154,7 @@ function runGenerate(argv) {
const neutral = neutralPath(outPath);
runEngine({ request, hyperframesDir, neutral, only: "tts,bgm" }, die);
- const meta = toFrameKeyedMeta(JSON.parse(readFileSync(neutral, "utf8")));
+ const meta = toProductLaunchMeta(JSON.parse(readFileSync(neutral, "utf8")));
writeFileSync(outPath, JSON.stringify(meta, null, 2));
console.log(
`✓ audio generate: ${meta.voices.length} voice + ${meta.bgm ? "1 bgm" : "no bgm"} → ${outPath}`,
@@ -189,7 +191,7 @@ function runFetchSfx(argv) {
// voices/bgm written by the earlier generate (--only tts,bgm) pass are preserved.
runEngine({ request, hyperframesDir, neutral, only: "sfx" }, die);
- const meta = toFrameKeyedMeta(JSON.parse(readFileSync(neutral, "utf8")));
+ const meta = toProductLaunchMeta(JSON.parse(readFileSync(neutral, "utf8")));
writeFileSync(outPath, JSON.stringify(meta, null, 2));
console.log(`✓ audio fetch-sfx: ${meta.sfx.length} SFX cue(s) → ${outPath}`);
}
diff --git a/skills/product-launch-video/SKILL.md b/skills/product-launch-video/SKILL.md
index 4b54f2199a..bbf1c35ea7 100644
--- a/skills/product-launch-video/SKILL.md
+++ b/skills/product-launch-video/SKILL.md
@@ -25,7 +25,7 @@ Initialize only if `hyperframes.json` is missing. Name `<project>` from the bran
`npx hyperframes init "videos/<project>" --non-interactive --example=blank` — `init` checks the installed skills against the latest on GitHub and updates the global set if any are out of date.
-**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../hyperframes-media` → Preflight for the canonical guidance.
+**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../media-use` → Preflight for the canonical guidance.
**Gate:** `hyperframes.json` exists, and angle, length, aspect ratio, and language are locked; sign-in status was shown (signed in, or continuing offline).
@@ -87,7 +87,7 @@ Start audio after Step 3 approval. Run it in the background, then continue to St
`node <SKILL_DIR>/scripts/audio.mjs --script ./SCRIPT.md --storyboard ./STORYBOARD.md --hyperframes . --out ./audio_meta.json &`
-The audio script handles narration, word timings, BGM lookup from HeyGen's music library, and timing metadata. BGM mood comes from the storyboard's `music:` field. This uses the HeyGen Audio API for retrieval, not generation, and uses the same `~/.heygen` credential as TTS. For provider details, read `../hyperframes-media/references/tts.md`.
+The audio script handles narration, word timings, BGM lookup from HeyGen's music library, and timing metadata. BGM mood comes from the storyboard's `music:` field. This uses the HeyGen Audio API for retrieval, not generation, and uses the same `~/.heygen` credential as TTS. For provider details, read `../media-use/audio/references/tts.md`.
If there is no narration and no `SCRIPT.md`, skip voice generation. BGM may still run if the storyboard has a music mood.
@@ -199,7 +199,7 @@ The reusable, product-agnostic shot shapes live in `../hyperframes-animation/blu
| `[../hyperframes-animation/blueprints-index.md](../hyperframes-animation/blueprints-index.md)` | Step 3: role→blueprint menu. Step 4: pick the shot shape. |
| `[../hyperframes-core/references/storyboard-format.md](../hyperframes-core/references/storyboard-format.md)` | Step 3: write `STORYBOARD.md`. |
| `[../hyperframes-core/references/script-format.md](../hyperframes-core/references/script-format.md)` | Step 3: write `SCRIPT.md`. |
-| `[../hyperframes-media/references/tts.md](../hyperframes-media/references/tts.md)` | Step 3.1: choose or understand TTS providers and voices. |
+| `[../media-use/audio/references/tts.md](../media-use/audio/references/tts.md)` | Step 3.1: choose or understand TTS providers and voices. |
| `[references/visual-design.md](references/visual-design.md)` | Step 4: write the frame's shot sequence (+ Layout vocabulary). |
| `[references/motion-language.md](references/motion-language.md)` | Step 4: the motion vocabulary + the motion doctrine. |
| `[references/cut-catalog.md](references/cut-catalog.md)` | Step 4-5: the cut catalog (worker builds within-frame seams). |
diff --git a/skills/product-launch-video/scripts/audio.mjs b/skills/product-launch-video/scripts/audio.mjs
index 5640fd1065..46a910b9b6 100644
--- a/skills/product-launch-video/scripts/audio.mjs
+++ b/skills/product-launch-video/scripts/audio.mjs
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// audio.mjs — product-launch audio ADAPTER. The TTS / BGM / SFX implementation
// no longer lives here: it is the shared engine at
-// ../../hyperframes-media/scripts/audio.mjs. This file only (a) maps the
+// ../../media-use/audio/scripts/audio.mjs. This file only (a) maps the
// product-launch model (SCRIPT.md frames + STORYBOARD.md music/sfx) into the
// engine's neutral audio_request.json, (b) converts the engine's id-keyed
// audio_meta back into the frame-keyed shape captions.mjs / assemble-index.mjs
@@ -27,7 +27,7 @@ import { fileURLToPath } from "node:url";
import { parseStoryboard } from "./lib/storyboard.mjs";
const HERE = dirname(fileURLToPath(import.meta.url));
-const DEFAULT_ENGINE = join(HERE, "..", "..", "hyperframes-media", "scripts", "audio.mjs");
+const DEFAULT_ENGINE = join(HERE, "..", "..", "media-use", "audio", "scripts", "audio.mjs");
const flag = (argv, name, def) => {
const i = argv.indexOf(`--${name}`);
diff --git a/skills/website-to-video/SKILL.md b/skills/website-to-video/SKILL.md
index ec79564830..a1b7d02880 100644
--- a/skills/website-to-video/SKILL.md
+++ b/skills/website-to-video/SKILL.md
@@ -36,7 +36,7 @@ If you find yourself reasoning "auto mode says bias toward action, so I'll skip
Capture the site, then read the extracted data to understand the **brand and product** — what it does, who it's for, what voice it speaks in, what mood it lives in. The captured assets are a brand toolkit for later, not the building blocks the video is made from.
-**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../hyperframes-media` → Preflight for the canonical guidance.
+**Show sign-in status before the brief** — run `npx hyperframes auth status` and **relay its output verbatim (don't paraphrase or rewrite it).** It reports whether voice/BGM will use HeyGen or local engines and, when not signed in, how to sign in. **If not signed in, STOP and wait for the user to choose — sign in, or say "go"/"offline" to continue with local engines — before asking the brief or anything else.** Treat it as a real decision point, not a passing note; don't fold the choice into the brief question, and don't write keys into a per-repo `.env`. (In autonomous mode, note the status and continue offline.) See `../media-use` → Preflight for the canonical guidance.
**Gate:** Site summary printed — strategy-first (what the product does, who it's for, brand voice) before the asset / color / font inventory; sign-in status was shown (signed in, or continuing offline).
diff --git a/skills/website-to-video/references/capabilities.md b/skills/website-to-video/references/capabilities.md
index 31f61f8986..f70e0e738e 100644
--- a/skills/website-to-video/references/capabilities.md
+++ b/skills/website-to-video/references/capabilities.md
@@ -667,7 +667,7 @@ Control bridge actions: play, pause, seek, set-muted, set-playback-rate, enable-
| ------------------------- | ----------------------------------------------------------------------- |
| hyperframes | Core framework skill (composition authoring) |
| hyperframes-cli | All CLI commands as an agent skill |
-| hyperframes-media | Media workflows (TTS, transcribe, captions integration) |
+| media-use | Media workflows (TTS, transcribe, captions integration) |
| hyperframes-registry | Installing blocks/components |
| hyperframes-contrast | WCAG audit (scripts/contrast-report.mjs) |
| hyperframes-animation-map | Per-tween bbox + flags report |