A Claude Code plugin that turns a story into a finished anime
Ruby
add seedance as option via fal ai
Francesco 'makevoid' Canessa458182b216b9
diff --git a/README.md b/README.mdindex 53905fe..7a8df06 100644--- a/README.md+++ b/README.md@@ -69,6 +69,8 @@ Claude reads the story, writes a production plan (cast, voices, shot list, everyReference photos are optional: original characters are designed from text. Use photos of real people only with their consent.+MiniMax H3 remains the default video model. Ask explicitly for **Seedance** to use Seedance 2.5 US, defaulting to **480p** unless you specify another resolution. It supports image-to-video, reference-to-video and optional draft completion at 1080p. See [Seedance settings and drafts](skills/make-an-anime/references/seedance.md).+## How a scene is madeEach stage reads prompts from `prompts/<run>/` and writes to `output/<run>/`, so everything can be inspected and redone on its own.diff --git a/docs/seedance-integration.md b/docs/seedance-integration.mdnew file mode 100644index 0000000..c5cbd56--- /dev/null+++ b/docs/seedance-integration.md@@ -0,0 +1,26 @@+# Seedance integration++## Behavior++MiniMax H3 remains the default at 768P. Seedance 2.5 US is an explicit selection and defaults to 480p. Native Seedance requests are rounded up to whole seconds with a four-second minimum and a 30-second maximum; the edit keeps its requested frame count. Draft completion is explicitly selected and only supports 1080p.++See the maintained [usage reference](../skills/make-an-anime/references/seedance.md) for YAML, scene/environment precedence, reference audio, drafts and commands.++## Architecture and implementation++- `Fal::Models::SeedanceImageToVideo`, `SeedanceReferenceToVideo` and `SeedanceDraftComplete` wrap the three requested queue endpoints. They share the existing approval, receipt cache and download client. OpenAPI discovery includes all three.+- `Pipeline::VideoGeneration` translates provider-specific inputs for `Shots`, `Clips` and `Video`. H3 keeps target audio and pinned end frames. Seedance reference mode receives audio references and explicitly rejects pinned end frames; image mode rejects unsupported seeds. No implicit provider fallback or draft completion occurs.+- Item manifests retain endpoint, request ID, exact input, returned seed and draft ID. Drafts can be completed in the existing shot workflow, preserving archived takes, or through `seedance:complete[input.json,out.mp4]` with a standalone manifest. The credential-scoped MCP task interface supports provider selection and completion.+- `seedance_live` is a separate paid test profile for one four-second 480p request, a three-second local trim, a contact sheet, queue receipts and probe evidence. It does not run other paid tests or retry with fresh inputs.++## Validation status — 2026-11-08++The three current Fal OpenAPI schemas were fetched and inspected. Core regressions cover default H3 behavior, explicit provider/resolution selection, string durations, reference audio mapping, rejected unsupported combinations, completion payloads, single-video routing and standalone completion receipts. The media regression assembles a simulated four-second Seedance source into an exact three-second, 72-frame edit.++The full offline suite passed: **111 examples, 0 failures**, including real FFmpeg, Python, p5 and Swift checks. After the live result exposed dimension rounding, the focused core suite passed **67 examples, 0 failures**, including the added rounding regression. Logs are `work/seedance-test.log` and `work/seedance-core-test.log`. Markdown reference checks and `git diff --check` also pass.++The user supplied an existing credential-file path for this session; its value was injected only into the child process environment. The live smoke **passed** with one paid image-to-video request: `01a1ba60-aa91-79b1-bcda-5c785e562eed`. Requested settings were four seconds, 480p, H.264, no generated audio. The returned clip is 4.042 seconds, 856×478, 24 fps, 97 frames. The locally trimmed sample is exactly three seconds and 72 frames. Its contact sheet was inspected: the snowy scene, person and robot remain recognizable across the sample with camera/motion changes. This is API/media and sampled-frame verification, not a lip-sync or full creative-quality evaluation.++The provider's nominal 480p tier rounded the dimensions to 856×478. The initial exact-height assertion caught this; the test and video review now allow up to eight pixels of tier rounding. Re-running the test reused the same completed queue receipt, making no additional paid generation. The live log is `work/seedance-live-test.log`; video, contact sheet, provider response and probe evidence are in `skills/make-an-anime/scripts/tmp/seedance-live/`. Live reference-to-video and draft completion remain unverified; their routing and payloads have offline coverage.++The repository's Markdown metadata/link tests pass. The generic Codex skill validator rejects the pre-existing Claude skill `compatibility` frontmatter field; this integration preserves that existing field.diff --git a/skills/make-an-anime/SKILL.md b/skills/make-an-anime/SKILL.mdindex 69c9a48..19d27a5 100644--- a/skills/make-an-anime/SKILL.md+++ b/skills/make-an-anime/SKILL.md@@ -25,6 +25,8 @@ Available executable: **`${CLAUDE_SKILL_DIR}/scripts/mv.rb`** (relative location## 1. Intake+**Video provider:** use MiniMax H3 Max unless the user explicitly requests Seedance. When requested, use Seedance 2.5 US at **480p** unless the user specifies another resolution; retain H3's existing 768P default otherwise. Read [seedance.md](references/seedance.md) for provider selection, reference media, audio differences and draft completion. Seedance accepts 4–30 whole seconds, so generate at least 4 seconds and trim shorter shots locally. Completing a draft is a separate paid operation and only supports 1080p.+On invocation, ask for the **story** (a story bible, treatment or script) if it was not supplied. **Character reference photos** are optional: original characters are designed from text alone. Use photos of real people only with their consent. Optional: which part to produce (a pilot, an act, the whole film), target length, language, voice preferences, aspect ratio, a soundtrack the user owns, audience, budget. Default to English dialogue, 16:9, 24fps, 768P H3 shots delivered at 1080p.Read [anime.md](references/anime.md), [planning.md](references/planning.md) and [tasks.md](references/tasks.md). Initialize an isolated project:@@ -65,7 +67,7 @@ Order of work, each step reviewed before the next:2. **Voices** (`Steps::Dialogue`): cast one distinct ElevenLabs Eleven v4 voice per character in `config/cast.yml`; generate the scene's lines; `review:dialogue` verifies each line with Whisper. Line timings set the shot lengths, so do this before animating, and run `dialogue:timeline` after any voice or shot change.3. **Score** (`Steps::Music` with `03_score.json`): ElevenLabs Music v2.5 composition plan whose chunks follow the scene's beats, instrumental, exactly scene length. Then `Steps::Mix` ducks it under the dialogue.4. **Keyframes** (`Steps::Keyframes`): one composed first frame per shot, edited from the cast/location sheets (`base: false`, `refs: [...]`).-5. **Shots** (`Steps::Shots`): H3 Max animates each keyframe at **768P** by default, with the shot's camera move written as its own `camera:` direction and the speaking character's mouth track as target audio. Still holds and solid inserts cost nothing. `review:camera` measures the move each shot actually made, and `review:believable` checks the prompts and takes for action on green and treadmill runs (`gen:clips` and `gen:shots` refuse the written failures before any paid call).+5. **Shots** (`Steps::Shots`): H3 Max animates each keyframe at **768P** by default, with the shot's camera move written as its own `camera:` direction and the speaking character's mouth track as target audio. Explicitly requested Seedance uses **480p** and its reference endpoint for audio guidance; see [seedance.md](references/seedance.md). Still holds and solid inserts cost nothing. `review:camera` measures the move each shot actually made, and `review:believable` checks the prompts and takes for action on green and treadmill runs (`gen:clips` and `gen:shots` refuse the written failures before any paid call).6. **Panels and layers, only for people who stay put** (`Steps::Clips`): two people far apart talk on one screen through painted panels with a paper cut (`key: none`, `Anim.paperCutPanels`), see [believable-motion.md](references/believable-motion.md). A keyed green performance is the last resort, for a still figure with no action; read [layered-scenes.md](references/layered-scenes.md) first.7. **Overlay** (`Steps::Overlay`): p5 draws screens, UI, title cards, subtitles and transitions over the plate, using `tools/p5/lib/screens.js` (code editor, typing, subtitles, place cards) and `tools/p5/lib/battle.js` (title slam, speed lines, impacts, camera roll). For animation asset sheets and portrait collages, see [animation-assets.md](references/animation-assets.md); for deterministic particles and light-only glow, see [particles-and-glow.md](references/particles-and-glow.md). Bake a scene light pass with `vfx:bake[run]` before `sfx:mix` when configured, or finish to a distinct VFX output.diff --git a/skills/make-an-anime/references/animation-audio-vfx.md b/skills/make-an-anime/references/animation-audio-vfx.mdindex 4ed9c06..bf5d895 100644--- a/skills/make-an-anime/references/animation-audio-vfx.md+++ b/skills/make-an-anime/references/animation-audio-vfx.md@@ -1,5 +1,7 @@# Animation, audio and effects recipes+H3 is the default provider in these recipes. When the user explicitly requests Seedance, apply [Seedance's input and audio rules](seedance.md) and its 480p default; keep the same local editing and finishing workflow.+## Separation of workH3 supplies the characters and their world together, in one full-frame take; p5 supplies exact timing, panels, text, diagrams and layer order on top. Action is never keyed (see [believable-motion.md](believable-motion.md)). Keyed characters are for explainers and paper-style pieces with no realistic world, and for a still figure as a last resort. Python removes backgrounds, measures audio and composites sound. Swift applies final frame-cued camera, light and signal effects. Ruby services own all execution and manifests.diff --git a/skills/make-an-anime/references/credentials.md b/skills/make-an-anime/references/credentials.mdindex 7cb0861..a4895f0 100644--- a/skills/make-an-anime/references/credentials.md+++ b/skills/make-an-anime/references/credentials.md@@ -37,3 +37,5 @@ ruby .claude/skills/make-an-anime/scripts/mv.rb --project /absolute/video-projec```The same variable works when launching `scripts/mcp.rb` directly in a developer MCP configuration. The installed plugin's server also falls back to it when the plugin option is unset; a configured option takes precedence. `FAL_KEY` and the old home-directory key file are no longer supported. Keep real keys out of prompts, source files, command arguments, and commits.++For explicitly requested Seedance, MCP task options also accept `VIDEO_MODEL: "seedance"` and `VIDEO_RES: "480p"` (or a requested 720p/1080p). `seedance:complete[input.json,out.mp4]` is a supported paid task using the same approval and credentials. Per-shot and scene settings are described in [seedance.md](seedance.md).diff --git a/skills/make-an-anime/references/seedance.md b/skills/make-an-anime/references/seedance.mdnew file mode 100644index 0000000..1f27a74--- /dev/null+++ b/skills/make-an-anime/references/seedance.md@@ -0,0 +1,88 @@+# Seedance 2.5 US++Use Seedance only when the user explicitly requests it. Otherwise use MiniMax H3 Max at its existing 768P default. Seedance generation defaults to 480p; do not copy Fal's 720p default. Both providers use the existing Fal queue, approval, receipts, downloads and manifests.++## Select the provider++Set `model: seedance` on a shot in `04_shots.yml` or a clip in `04_clips.yml`:++```yaml+- name: breeze+ model: seedance+ image: rooftop+ frames: 72+ seconds: 3+ prompt: A gentle breeze moves her hair. Keep the same character and painted setting.+ camera: slow dolly-in+ # resolution: 720p # only when requested; default is 480p+ # end_image: rooftop_end+```++Seedance accepts 4–30 whole seconds encoded as strings. The toolkit rounds up fractional durations and uses at least four seconds; the shot edit still uses the exact `frames` requested. A three-second shot requests a four-second source and trims it to 72 frames. Durations over 30 seconds fail rather than silently truncating. Do not retime dialogue. `gen:shots` still assembles the finished plate at 1080p; that local upscale does not change the provider's native resolution.++Fal's resolution tiers may round dimensions slightly: the verified 480p sample returned 856×478. Review checks allow eight pixels of rounding while retaining the requested tier in the manifest.++For a whole scene, add `video: { model: "seedance" }` to its `scene(...)` configuration. Alternatively, use `VIDEO_MODEL=seedance` with `gen:shots`, `gen:clips` or `gen:video`. Selection precedence is per-item `model`, scene `video.model`, `VIDEO_MODEL`, then MiniMax. Resolution precedence is per-item `resolution`, scene `video.resolution`, `VIDEO_RES`, then the provider default. Use `model: minimax` (or `h3`) for an explicit H3 override.++Cached paid takes keep the existing reuse behavior. After editing provider/settings, use `ONLY=breeze FORCE=1` to replace an existing take. The previous take is archived; identical inputs resume the existing queue receipt instead of charging again.++## Image, reference media and audio++The [image-to-video API](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=bytedance/seedance-2.5/us/image-to-video) supports a starting `image`, optional pinned `end_image`, and only `aspect_ratio: auto`. It has no input seed and no target-audio field. Do not set `SEED` for this mode; use reference mode if you need a seed.++The [reference-to-video API](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=bytedance/seedance-2.5/us/reference-to-video) is selected by `mode: reference`, reference URL arrays, or a shot's `audio:` track. It accepts:++```yaml+- name: response+ model: seedance+ mode: reference+ image: hero_closeup+ frames: 96+ audio: hero+ prompt: "The person in @Image1 speaks softly, with restrained expression."+ camera: locked close-up+ # image_urls: [https://.../character.png, https://.../location.png]+ # video_urls: [https://.../motion.mp4]+ # audio_urls: [https://.../ambience.wav]+ # aspect_ratio: "16:9"+```++`image_urls` replaces the single keyframe reference when supplied. `video_urls` and `audio_urls` add hosted references; local files can be uploaded with `media:upload`. Address references in the prompt as `@Image1`, `@Video1`, `@Audio1`, etc. `audio:` cuts/uploads the existing character mouth track and appends it to `audio_urls`; the toolkit adds a prompt identifying that audio reference. This guides performance and is not H3's pinned `target_audio_url` or a guarantee of lip-sync. Review mouth timing; the final edit still uses the clean scene soundtrack.++Reference mode cannot pin an end frame; combining it with `end_image` fails. `gen:video` uses reference mode because that step always supplies the song, and omits its H3-only automatic end-frame pin. Image-only Seedance generation defaults to `generate_audio: false`; a supplied mouth track enables audio generation unless explicitly overridden. You can request `generate_audio: true` for native generated sound, but `gen:shots` replaces it with the scene mix in the final edit. The raw take retains the generated sound.++Limits: up to 30 images, 10 videos and 10 audio files, 50 files total. Reference audio is MP3/WAV, 1.8–30.2 seconds each, at most 15 MB each and 30.2 seconds combined. Videos are MP4/MOV, 1.8–30.2 seconds each, at most 200 MB each and 30.2 seconds combined. Fal enforces file-content limits. Reference `task` supports `reference` (default), `auto`, `editing` and `extension`; editing lets the provider choose duration and aspect ratio, so inspect the returned duration before planning an exact edit.++## Draft preview and completion++Add `draft: true` to an image or reference shot at 480p. The item manifest saves its `draft_id`, request, endpoint, input and returned seed. A regular 480p take is not automatically a draft. Inspect the draft before choosing to complete it.++The [draft completion API](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=bytedance/seedance-2.5/us/draft/complete) only produces 1080p. US draft IDs expire after seven days and must be completed by the original caller. There is no automatic completion or paid upscale.++To replace a draft shot, copy its saved ID into that shot as `draft_id: <saved-id>`, keep `model: seedance`, `frames`, and any trim settings, then run `ONLY=breeze FORCE=1 ... gen:shots`. Completion sends only the draft ID and completion settings; it does not regenerate the prompt. The old draft is archived. Remove `draft_id` when you intend to generate a new take.++For a standalone completion, write `complete.json`:++```json+{"draft_id": "the saved draft_id"}+```++Run through the approved project's Ruby CLI or the anime MCP `run_task`:++```sh+ruby mv.rb 'seedance:complete[complete.json,output/completed.mp4]'+```++This stores the video and `output/completed.mp4.json` with the completion receipt. Completion always uses 1080p, independently of `VIDEO_RES`. The ordinary generation default remains 480p.++## Verification++`openapi:fetch` includes all three Seedance endpoints. The offline core/media tests cover routing, default and explicit resolution, duration conversion, reference-audio mapping, draft metadata/completion and a three-second assembled shot.++The separate live smoke makes one paid four-second image-to-video request and trims a three-second sample:++```sh+LIVE_FAL=1 LIVE_IMAGE=/absolute/reference.png PROFILE=seedance_live ruby scripts/mv.rb test+```++Provide `FAL_AI_API_KEY` in the environment. Results, the queue receipt, input/output, a contact sheet and probe evidence stay in `scripts/tmp/seedance-live/`. Repeating unchanged inputs reuses the receipt. This smoke does not pay for reference-to-video or draft completion and does not prove their live behavior.diff --git a/skills/make-an-anime/references/tasks.md b/skills/make-an-anime/references/tasks.mdindex cb0cf8a..87157e7 100644--- a/skills/make-an-anime/references/tasks.md+++ b/skills/make-an-anime/references/tasks.md@@ -1,5 +1,7 @@# Ruby entry points and task recipes+MiniMax H3 is the default animation provider. For explicitly requested Seedance 2.5 US, see [Seedance](seedance.md): `model: seedance` or `VIDEO_MODEL=seedance`, 480p by default, reference media/audio, and `seedance:complete[input.json,out.mp4]` for a saved draft at 1080p. The same shot/clip generation and review tasks apply.+## Directory layers```textdiff --git a/skills/make-an-anime/references/testing.md b/skills/make-an-anime/references/testing.mdindex 0ba73d3..f10414a 100644--- a/skills/make-an-anime/references/testing.md+++ b/skills/make-an-anime/references/testing.md@@ -30,6 +30,8 @@ Production regression examples cover source-length rejection before assembly, sk## Paid live E2E+For the separate, one-call Seedance smoke, use `LIVE_FAL=1 LIVE_IMAGE=/absolute/reference.png PROFILE=seedance_live ruby scripts/mv.rb test` with `FAL_AI_API_KEY` in the environment. It generates the API minimum of four seconds at 480p, saves the raw take and a locally trimmed three-second sample, and verifies the media dimensions/durations. See [Seedance verification](seedance.md#verification). This profile does not run the H3/music tests or pay for draft completion.+Live tests are excluded from routine runs. They require an explicit opt-in plus a real song excerpt and recognizable lyric words. This test invocation authorizes the listed test calls; it does not approve a new production plan.```shdiff --git a/skills/make-an-anime/scripts/lib/fal/models/seedance_draft_complete.rb b/skills/make-an-anime/scripts/lib/fal/models/seedance_draft_complete.rbnew file mode 100644index 0000000..eec195b--- /dev/null+++ b/skills/make-an-anime/scripts/lib/fal/models/seedance_draft_complete.rb@@ -0,0 +1,22 @@+require_relative "base"++module Fal+ module Models+ class SeedanceDraftComplete < Base+ ENDPOINT = "bytedance/seedance-2.5/us/draft/complete".freeze+ DEFAULTS = { resolution: "1080p", codec: "H264" }.freeze++ def complete(draft_id:, **opts) = call(draft_id: draft_id, **opts)++ private++ def validate!(input)+ raise ArgumentError, "draft_id is required" unless input[:draft_id].is_a?(String) && !input[:draft_id].strip.empty?+ raise ArgumentError, "Seedance draft completion only supports 1080p" unless input[:resolution] == "1080p"+ unknown = input.keys - %i[draft_id resolution codec]+ raise ArgumentError, "Unsupported draft completion params: #{unknown.join(', ')}" if unknown.any?+ super+ end+ end+ end+enddiff --git a/skills/make-an-anime/scripts/lib/fal/models/seedance_image_to_video.rb b/skills/make-an-anime/scripts/lib/fal/models/seedance_image_to_video.rbnew file mode 100644index 0000000..5df2a4d--- /dev/null+++ b/skills/make-an-anime/scripts/lib/fal/models/seedance_image_to_video.rb@@ -0,0 +1,49 @@+require_relative "base"++module Fal+ module Models+ class SeedanceImageToVideo < Base+ ENDPOINT = "bytedance/seedance-2.5/us/image-to-video".freeze+ DEFAULT_RES = "480p".freeze+ DEFAULTS = { resolution: DEFAULT_RES, generate_audio: false, codec: "H264" }.freeze+ PARAMS = %i[prompt image_url end_image_url resolution draft duration aspect_ratio generate_audio bitrate_mode codec end_user_id].freeze++ # Seedance takes whole seconds, encoded as strings. The timeline can trim+ # the four-second minimum down to a shorter shot without retiming it.+ def self.duration(seconds)+ return "auto" if seconds == "auto"+ value = Float(seconds)+ raise ArgumentError, "Seedance duration must be positive and at most 30 seconds" unless value.finite? && value > 0 && value <= 30+ [4, value.ceil].max.to_s+ end++ def animate(prompt:, image_url:, duration:, **opts)+ call(prompt: prompt, image_url: image_url, duration: duration, **opts)+ end++ def call(**input)+ input[:duration] = self.class.duration(input[:duration]) if input.key?(:duration)+ input[:resolution] = input[:resolution].downcase if input[:resolution].is_a?(String)+ super(**input)+ end++ private++ # Keep basic validation active even before openapi:fetch has been run.+ def validate!(input)+ unknown = input.keys - self.class::PARAMS+ raise ArgumentError, "#{self.class.endpoint}: unsupported params #{unknown.join(', ')}" if unknown.any?+ raise ArgumentError, "Seedance resolution must be 480p, 720p or 1080p" unless %w[480p 720p 1080p].include?(input[:resolution])+ %i[draft generate_audio].each do |key|+ raise ArgumentError, "#{key} must be true or false" if input.key?(key) && ![true, false].include?(input[key])+ end+ raise ArgumentError, "Seedance drafts require resolution: 480p" if input[:draft] && input[:resolution] != "480p"+ if self.class == SeedanceImageToVideo+ raise ArgumentError, "Seedance image-to-video needs image_url" if input[:image_url].to_s.empty?+ raise ArgumentError, "Seedance image-to-video aspect_ratio must be auto" if input[:aspect_ratio] && input[:aspect_ratio] != "auto"+ end+ super+ end+ end+ end+enddiff --git a/skills/make-an-anime/scripts/lib/fal/models/seedance_reference_to_video.rb b/skills/make-an-anime/scripts/lib/fal/models/seedance_reference_to_video.rbnew file mode 100644index 0000000..6dc32bc--- /dev/null+++ b/skills/make-an-anime/scripts/lib/fal/models/seedance_reference_to_video.rb@@ -0,0 +1,27 @@+require_relative "seedance_image_to_video"++module Fal+ module Models+ class SeedanceReferenceToVideo < SeedanceImageToVideo+ ENDPOINT = "bytedance/seedance-2.5/us/reference-to-video".freeze+ PARAMS = %i[prompt image_urls video_urls audio_urls resolution draft duration aspect_ratio generate_audio bitrate_mode codec seed end_user_id task].freeze++ def animate(prompt:, duration:, image_urls: [], video_urls: [], audio_urls: [], **opts)+ call(prompt: prompt, duration: duration, image_urls: image_urls, video_urls: video_urls, audio_urls: audio_urls, **opts)+ end++ private++ def validate!(input)+ total = 0+ { image_urls: 30, video_urls: 10, audio_urls: 10 }.each do |key, limit|+ values = input.fetch(key, [])+ raise ArgumentError, "#{key} must be an array of up to #{limit} URLs" unless values.is_a?(Array) && values.size <= limit && values.all? { |v| v.is_a?(String) && !v.empty? }+ total += values.size+ end+ raise ArgumentError, "Seedance needs 1 to 50 reference files" unless (1..50).cover?(total)+ super+ end+ end+ end+enddiff --git a/skills/make-an-anime/scripts/lib/fal_mv_gen.rb b/skills/make-an-anime/scripts/lib/fal_mv_gen.rbindex 7e7ffa9..895bac9 100644--- a/skills/make-an-anime/scripts/lib/fal_mv_gen.rb+++ b/skills/make-an-anime/scripts/lib/fal_mv_gen.rb@@ -9,6 +9,7 @@ require "pipeline/project"require "pipeline/step"require "pipeline/items_step"require "pipeline/generation_config"+require "pipeline/video_generation"Dir[File.join(__dir__, "pipeline", "steps", "*.rb")].sort.each { |f| require f }module PipelineDEFAULT_RUN = "s01"diff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rbindex 57e7ba6..64ada1c 100644--- a/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/clips.rb@@ -71,19 +71,24 @@ module Pipeline# RECUT=1: cut the already-downloaded H3 clip again (new box/key/frames) instead of calling fal.prev = project[key]&.dig("items", name)if ENV["RECUT"] == "1" && prev&.dig("url") && File.exist?(local = project.path("04_clip_#{name}.mp4"))- return [local, prev.slice("request_id", "input", "url").transform_keys(&:to_sym)]+ return [local, prev.slice("endpoint", "request_id", "input", "url", "draft_id", "seed").transform_keys(&:to_sym)]end- seconds = spec.fetch("seconds", 5)- audio = if spec["audio"] && spec["audio_at"] then stem_url(name, spec, seconds)+ generation = VideoGeneration.new(project: project, spec: spec.merge("audio" => !!spec["audio_at"]), client: client)+ seconds = generation.seconds(spec.fetch("seconds", 5))+ result = if generation.completion?+ generation.generate+ else+ audio = if spec["audio"] && spec["audio_at"] then stem_url(name, spec, seconds)elsif spec["audio_at"] then song_url(name, spec["audio_at"], seconds)end- result = MODEL.new(client: client).animate(- prompt: Shots.h3_prompt(project, spec), image_url: keyframe_url(spec.fetch("image")),- end_image_url: spec["end_image"]&.then { |k| keyframe_url(k) }, target_audio_url: audio,- duration: seconds, seed: seed, resolution: ENV.fetch("VIDEO_RES", MODEL::DEFAULT_RES)- )+ generation.generate(+ prompt: Shots.h3_prompt(project, spec), image_url: spec["image"]&.then { |k| keyframe_url(k) },+ end_image_url: spec["end_image"]&.then { |k| keyframe_url(k) }, audio_url: audio,+ duration: seconds, seed: seed+ )+ endurl = result.output.fetch("video")["url"]- [download(url, "04_clip_#{name}.mp4"), { request_id: result.request_id, input: result.input, url: url }]+ [download(url, "04_clip_#{name}.mp4"), generation.metadata(result).merge(url: url)]end# `seconds` of a full-song-aligned track (spec audio:) from this section's audio_at, as H3's target audio: the section's song offsetdiff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rbindex 0df1aee..55d0212 100644--- a/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/shots.rb@@ -93,17 +93,22 @@ module Pipelinereturn { source: spec["still"] || spec["color"], path: out, spec: local_spec(spec) }endraise ArgumentError, "Never retime a talking or singing shot" if spec["audio"] && spec["retime"]- seconds = spec.fetch("seconds") { default_seconds(spec) }+ generation = VideoGeneration.new(project: project, spec: spec, client: client)+ seconds = generation.seconds(spec.fetch("seconds") { default_seconds(spec) })raise ArgumentError, "shot #{name} needs more source frames (#{spec["frames"]} > #{seconds}s)" if !spec["retime"] && (spec["source_frames"] || spec["frames"]) + spec.fetch("skip_frames", 0) > (seconds * FPS).roundraise ArgumentError, "shot #{name}: source_frames #{spec["source_frames"]} < frames #{spec["frames"]} needs retime: true" if spec["source_frames"] && !spec["retime"] && spec["source_frames"] < spec["frames"]- audio = audio_url(name, spec, seconds) if spec["audio"]- result = MODEL.new(client: client).animate(- prompt: self.class.h3_prompt(project, spec), image_url: keyframe_url(spec.fetch("image")),- end_image_url: spec["end_image"]&.then { |k| keyframe_url(k) }, target_audio_url: audio,- duration: seconds, seed: seed, resolution: ENV.fetch("VIDEO_RES", MODEL::DEFAULT_RES)- )+ result = if generation.completion?+ generation.generate+ else+ audio = audio_url(name, spec, seconds) if spec["audio"]+ generation.generate(+ prompt: self.class.h3_prompt(project, spec), image_url: spec["image"]&.then { |k| keyframe_url(k) },+ end_image_url: spec["end_image"]&.then { |k| keyframe_url(k) }, audio_url: audio,+ duration: seconds, seed: seed+ )+ endurl = result.output.fetch("video")["url"]- { request_id: result.request_id, input: result.input, url: url, path: download(url, "04_shot_#{name}.mp4") }+ generation.metadata(result).merge(url: url, path: download(url, "04_shot_#{name}.mp4"))end# The H3 prompt: the shot prompt ({{STYLE}} expanded), then the camera direction as its own paragraph.diff --git a/skills/make-an-anime/scripts/lib/pipeline/steps/video.rb b/skills/make-an-anime/scripts/lib/pipeline/steps/video.rbindex 6f3ada1..95d7d15 100644--- a/skills/make-an-anime/scripts/lib/pipeline/steps/video.rb+++ b/skills/make-an-anime/scripts/lib/pipeline/steps/video.rb@@ -9,21 +9,21 @@ module Pipeline# END_KEYFRAME=0 disables pinning the last frame to the reference# (without it H3 drifts away from the reference style, e.g. "heals" run1's torn paper).def submit+ return generation.generate if generation.completion?ref = project.fetch!(source, :url)- MODEL.new(client: client).animate(+ generation.generate(prompt: project.prompt("04_video"),image_url: ref,- end_image_url: (ref unless ENV["END_KEYFRAME"] == "0"),- target_audio_url: project.fetch!(:music, :url),- duration: project.duration, seed: seed,- resolution: ENV.fetch("VIDEO_RES", MODEL::DEFAULT_RES)+ end_image_url: (ref unless generation.seedance? || ENV["END_KEYFRAME"] == "0"),+ audio_url: project.fetch!(:music, :url),+ duration: generation.seconds(project.duration), seed: seed)enddef materialize(result)video = result.output.fetch("video")raw = download(video["url"], "04_video_raw.mp4")- base_data(result).merge(+ generation.metadata(result).merge(url: video["url"], raw_path: raw, path: ffmpeg.mux(raw, project[:music]["path"], project.path("final.mp4")),source: source, expanded_prompt: result.output["expanded_prompt"], timings: result.output["timings"])@@ -41,6 +41,10 @@ module Pipelinedrift = (monos.max - monos.min).round(1)mono_gap = (split["mean_mono_pct"] - ref["mono_pct"]).round(1)sat_gap = (sats.sum / sats.size - ref["mean_saturation"]).round(3)+ requested_height = project[key].dig("input", "resolution").to_s.to_i+ requested_height = generation.seedance? ? 480 : 720 unless requested_height.positive?+ # Seedance's nominal resolution tiers can round down a few pixels.+ minimum_height = requested_height - (generation.seedance? ? 8 : 0){summary: summary, contact_sheet: sheet,style: { ref_mono_pct: ref["mono_pct"], frame_mono_pct: monos, mean: split["mean_mono_pct"], drift: drift,@@ -48,7 +52,7 @@ module Pipeline**verdict("duration ~#{project.duration}s" => [(summary[:duration] - project.duration).abs < 0.6, "#{summary[:duration]}s"],"master audio muxed" => [summary.dig(:audio, :codec) == "aac" && summary.dig(:audio, :rate) == 44_100, summary[:audio].inspect],- "resolution >= 720p" => [summary.dig(:video, :h).to_i >= 720, "#{summary.dig(:video, :w)}x#{summary.dig(:video, :h)}"],+ "resolution >= requested tier" => [[summary.dig(:video, :w), summary.dig(:video, :h)].map(&:to_i).min >= minimum_height, "#{summary.dig(:video, :w)}x#{summary.dig(:video, :h)}"],"reference style kept" => [mono_gap.abs <= [10, ref["mono_pct"] * 0.4].max, "frames #{split["mean_mono_pct"]}% mono vs ref #{ref["mono_pct"]}% (#{mono_gap}pp)"],"palette kept" => [sat_gap.abs < 0.08, "mean saturation #{sat_gap.positive? ? "+" : ""}#{sat_gap} vs ref #{ref["mean_saturation"]}"],"style stable" => [drift < 20, "mono drift #{drift}pp across frames"]@@ -58,6 +62,9 @@ module Pipelineprivate+ def generation = @generation ||= VideoGeneration.new(project: project, spec: { "audio" => true }, client: client)+ def endpoint = generation.model.endpoint+# The frame H3 animates: run1's torn-paper collage, otherwise the base image.def source = project.step?(RefTorn) ? :ref_torn : :ref_baseenddiff --git a/skills/make-an-anime/scripts/lib/pipeline/video_generation.rb b/skills/make-an-anime/scripts/lib/pipeline/video_generation.rbnew file mode 100644index 0000000..bfb36d1--- /dev/null+++ b/skills/make-an-anime/scripts/lib/pipeline/video_generation.rb@@ -0,0 +1,68 @@+module Pipeline+ # Provider selection and input translation shared by shots, clips and video.+ # Selecting Seedance is explicit; existing projects keep their H3 behavior.+ class VideoGeneration+ attr_reader :spec++ def initialize(project:, spec: {}, client: nil)+ @spec = project.generation.fetch(:video, {}).transform_keys(&:to_s).merge(spec)+ @client = client+ @provider = @spec.fetch("model") { ENV.fetch("VIDEO_MODEL", "minimax") }+ raise ArgumentError, "video model must be minimax, h3 or seedance" unless %w[minimax h3 seedance].include?(@provider)+ raise ArgumentError, "Seedance options require model: seedance" if !seedance? && (seedance_options? || @spec["draft_id"])+ end++ def seedance? = @provider == "seedance"+ def completion? = seedance? && !!spec["draft_id"]+ def reference? = seedance? && (spec["mode"] == "reference" || spec["audio"] || %w[image_urls video_urls audio_urls].any? { |k| spec.key?(k) })+ def seconds(value)+ return value unless seedance?+ raise ArgumentError, "Seedance timeline shots need numeric seconds, not auto" if value == "auto"+ Fal::Models::SeedanceImageToVideo.duration(value).to_i+ end++ def model+ return Fal::Models::H3MaxImageToVideo unless seedance?+ return Fal::Models::SeedanceDraftComplete if completion?+ reference? ? Fal::Models::SeedanceReferenceToVideo : Fal::Models::SeedanceImageToVideo+ end++ def generate(prompt: nil, image_url: nil, end_image_url: nil, audio_url: nil, duration: nil, seed: nil)+ adapter = model.new(client: @client || Fal::Client.new)+ return adapter.complete(draft_id: spec.fetch("draft_id"), **spec.slice("codec").transform_keys(&:to_sym)) if completion?+ resolution = spec.fetch("resolution") { ENV.fetch("VIDEO_RES", model::DEFAULT_RES) }+ unless seedance?+ return adapter.animate(prompt: prompt, image_url: image_url, end_image_url: end_image_url,+ target_audio_url: audio_url, duration: duration, seed: seed, resolution: resolution)+ end+ raise ArgumentError, "Seedance mode must be image or reference" if spec["mode"] && !%w[image reference].include?(spec["mode"])+ raise ArgumentError, "Seedance image mode does not support reference audio/media; use mode: reference" if spec["mode"] == "image" && reference?+ options = spec.slice("draft", "generate_audio", "aspect_ratio", "codec", "bitrate_mode", "task", "end_user_id").transform_keys(&:to_sym)+ options.merge!(resolution: resolution, duration: duration, prompt: prompt)+ if reference?+ raise ArgumentError, "Seedance reference mode has no pinned end frame; use image mode without audio" if end_image_url+ images = spec.fetch("image_urls") { Array(image_url) }+ audios = Array(spec["audio_urls"]) + Array(audio_url)+ if audio_url+ options[:prompt] = "#{prompt}\n\nUse @Audio#{audios.size} for the performance timing and speech."+ options[:generate_audio] = spec.fetch("generate_audio", true)+ end+ adapter.animate(**options, image_urls: images, video_urls: spec.fetch("video_urls", []), audio_urls: audios, seed: seed)+ else+ raise ArgumentError, "Seedance image-to-video has no seed input; use reference mode for a seed" if seed+ adapter.animate(**options, image_url: image_url, end_image_url: end_image_url)+ end+ end++ def metadata(result)+ { endpoint: model.endpoint, request_id: result.request_id, input: result.input,+ draft_id: result.output["draft_id"], seed: result.output["seed"] }.compact+ end++ private++ def seedance_options?+ %w[mode image_urls video_urls audio_urls draft task generate_audio].any? { |k| spec.key?(k) }+ end+ end+enddiff --git a/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb b/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rbindex c6d19dc..afd21ee 100644--- a/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb+++ b/skills/make-an-anime/scripts/lib/toolkit/mcp_server.rb@@ -10,9 +10,9 @@ module Toolkit# editing, and recording the user's approval stay in the ordinary Ruby CLI.class CredentialTasksTASKS = %w[doctor audio:transcribe media:stems media:upload sfx:gen- pipeline:all adopt gen:ref_base gen:ref_torn gen:keyframes gen:video+ pipeline:all adopt seedance:complete gen:ref_base gen:ref_torn gen:keyframes gen:videogen:shots gen:clips gen:music gen:dialogue gen:mix gen:overlay review:music review:dialogue review:likeness review:camera review:believable dialogue:timeline scene:new episode:preview].freeze- OPTIONS = %w[RUN ONLY FORCE RECUT NEW_REQUEST VIDEO_RES SFX VFX REFRESH_UPLOAD].freeze+ OPTIONS = %w[RUN ONLY FORCE RECUT NEW_REQUEST VIDEO_RES VIDEO_MODEL SFX VFX REFRESH_UPLOAD].freezeOUTPUT_LIMIT = 20_000MAX_RUNNING = 10PLUGIN_KEY = "FAL_AI_API_KEY_PLUGIN"diff --git a/skills/make-an-anime/scripts/lib/toolkit/operations.rb b/skills/make-an-anime/scripts/lib/toolkit/operations.rbindex 383ccf1..61eda17 100644--- a/skills/make-an-anime/scripts/lib/toolkit/operations.rb+++ b/skills/make-an-anime/scripts/lib/toolkit/operations.rb@@ -16,6 +16,7 @@ module Toolkit"fonts:copy" => "Copy selected fonts into this video project: [selection.json] (local)","openapi:fetch" => "Fetch current Fal input schemas (no generation)","openapi:summary" => "Print saved Fal schema summaries",+ "seedance:complete" => "Complete a saved Seedance draft at 1080p: [input.json,out.mp4] (paid)","plan:approve" => "Record actual user approval: NOTE='approved wording'","audio:seams" => "Report abrupt audio: every scene join in a film and the score joints inside scenes: [film,episode] (local)","work:next" => "Allocate/resume next dependency-ready wave; SIZE=2/3..4/4..8/6..10",@@ -75,7 +76,7 @@ module Toolkit"adopt" => "Recover completed Fal request [step,request_id]","pick" => "Restore archived request [step,index]","import" => "Copy step from another run [step,source_run]",- "test" => "Run RSpec suite; PROFILE=all|core|media|swift|live"+ "test" => "Run RSpec suite; PROFILE=all|core|media|swift|live|seedance_live"}.freezedef ff = @ff ||= Media::FFmpeg.newdef py = @py ||= Media::Python.new@@ -96,6 +97,16 @@ module Toolkitwhen "fonts:copy" then required(a, 1); emit Fonts.new.copy(a[0])when "openapi:fetch" then endpoints.each { |id| Fal::OpenAPI.fetch(id); warn "fetched #{id}" }when "openapi:summary" then endpoints.each { |id| puts Fal::OpenAPI.load(id).summary if File.file?(Fal::OpenAPI.spec_path(id)) }+ when "seedance:complete"+ required(a, 2)+ input = JSON.parse(File.read(a[0]), symbolize_names: true)+ client = Fal::Client.new+ result = Fal::Models::SeedanceDraftComplete.new(client: client).complete(**input)+ FileUtils.mkdir_p(File.dirname(a[1]))+ metadata = { endpoint: Fal::Models::SeedanceDraftComplete.endpoint, request_id: result.request_id, input: result.input, output: result.output }+ File.write("#{a[1]}.json", JSON.pretty_generate(metadata))+ client.download(result.output.fetch("video").fetch("url"), a[1])+ emit(path: a[1], manifest: "#{a[1]}.json", request_id: result.request_id)when "review:likeness" then emit AnimeReview.new.likeness(a)when "review:camera" then emit AnimeReview.new.camerawhen "review:believable" then emit AnimeReview.new.believablediff --git a/skills/make-an-anime/scripts/lib/toolkit/test_runner.rb b/skills/make-an-anime/scripts/lib/toolkit/test_runner.rbindex 015d25c..afda1c3 100644--- a/skills/make-an-anime/scripts/lib/toolkit/test_runner.rb+++ b/skills/make-an-anime/scripts/lib/toolkit/test_runner.rb@@ -3,15 +3,19 @@ module Toolkitclass TestRunnerdef runprofile = ENV.fetch("PROFILE", "all")- raise "PROFILE must be all, core, media, swift or live" unless %w[all core media swift live].include?(profile)+ raise "PROFILE must be all, core, media, swift, live or seedance_live" unless %w[all core media swift live seedance_live].include?(profile)if profile == "live"raise "Paid tests require LIVE_FAL=1, LIVE_SONG=/path/to/song.wav and LIVE_LYRICS='recognizable words'" unless ENV["LIVE_FAL"] == "1" && File.file?(ENV["LIVE_SONG"].to_s) && !ENV["LIVE_LYRICS"].to_s.strip.empty?end+ if profile == "seedance_live"+ raise "Paid Seedance smoke requires LIVE_FAL=1 and LIVE_IMAGE=/path/to/reference.png" unless ENV["LIVE_FAL"] == "1" && File.file?(ENV["LIVE_IMAGE"].to_s)+ end# Specs chdir into temporary workspaces; pin the toolkit's own venv so Python helpers keep numpy/PIL.venv = File.expand_path(".venv/bin/python3")ENV["MV_PYTHON"] ||= venv if File.file?(venv)args = [RbConfig.ruby, "-S", "rspec", "spec", "--format", "documentation"]args += profile == "all" ? ["--tag", "~live"] : ["--tag", profile]+ args += ["--tag", "~seedance_live"] if profile == "live"ok = system(*args)raise "RSpec failed for PROFILE=#{profile}; see failures above" unless okenddiff --git a/skills/make-an-anime/scripts/spec/seedance_live_spec.rb b/skills/make-an-anime/scripts/spec/seedance_live_spec.rbnew file mode 100644index 0000000..4420bd5--- /dev/null+++ b/skills/make-an-anime/scripts/spec/seedance_live_spec.rb@@ -0,0 +1,35 @@+require_relative "spec_helper"++RSpec.describe "Paid Seedance smoke", :live, :seedance_live do+ it "generates a real minimum-length 480p take and a three-second review clip" do+ raise "Set LIVE_FAL=1 and LIVE_IMAGE to a local reference image" unless ENV["LIVE_FAL"] == "1" && File.file?(ENV["LIVE_IMAGE"].to_s)+ reference = File.expand_path(ENV.fetch("LIVE_IMAGE"))+ dir = File.join(RT, "tmp", "seedance-live")+ FileUtils.mkdir_p(dir)+ Dir.chdir(dir) do+ FileUtils.mkdir_p("docs")+ File.write("docs/PLAN.md", "Seedance API smoke: upload the supplied reference; one 4-second image-to-video request at 480p without audio, then locally trim to 3 seconds. No paid retries, image generation, or draft completion.\n")+ Workflow::Approval.new.record!("User requested: make sure you test a short clip of 2-3s to make sure seedance works. API minimum is 4s; deliver a local 3s trim.")+ model = Fal::Models::SeedanceImageToVideo+ Fal::OpenAPI.fetch(model.endpoint)+ client = Fal::Client.new+ result = model.new(client: client).animate(+ prompt: "Animate this exact scene as one continuous anime shot. A gentle breeze moves loose fabric and hair, soft natural blinking and subtle breathing. Slow camera push in. Preserve the characters, setting and painted style. No cuts, no new objects, no text.",+ image_url: client.upload(reference), duration: 4)+ json("result.json", endpoint: model.endpoint, request_id: result.request_id, input: result.input, output: result.output)+ client.download(result.output.fetch("video").fetch("url"), "seedance-4s.mp4")+ summary = ff.summary("seedance-4s.mp4")+ expect(summary[:duration]).to be_between(3.9, 4.2)+ # Fal's 480p tier preserves source aspect ratio with rounded dimensions+ # (the live 16:9 fixture returns 856x478 rather than an exact 480 rows).+ expect(result.input[:resolution]).to eq("480p")+ expect([summary.dig(:video, :w), summary.dig(:video, :h)].min).to be_within(8).of(480)+ ff.run("ffmpeg", "-y", "-v", "error", "-i", "seedance-4s.mp4", "-t", "3", "-an", "-c:v", "libx264", "-pix_fmt", "yuv420p", "seedance-3s.mp4")+ sample = ff.summary("seedance-3s.mp4")+ expect(sample[:duration]).to be_within(0.05).of(3)+ ff.contact_sheet("seedance-3s.mp4", "contact-sheet.jpg", cols: 3, rows: 2)+ json("verification.json", source: summary, sample: sample, request_id: result.request_id)+ puts "Seedance artifacts: #{dir}"+ end+ end+enddiff --git a/skills/make-an-anime/scripts/spec/seedance_spec.rb b/skills/make-an-anime/scripts/spec/seedance_spec.rbnew file mode 100644index 0000000..786ebf3--- /dev/null+++ b/skills/make-an-anime/scripts/spec/seedance_spec.rb@@ -0,0 +1,151 @@+require_relative "spec_helper"++RSpec.describe "Seedance routing and contracts", :core do+ let(:client) { double("Fal client") }+ let(:project) { double("project", generation: {}) }+ let(:output) { { "video" => { "url" => "https://fixture/video.mp4" }, "draft_id" => "draft-fixture", "seed" => 10 } }++ def generation(spec = {})+ Pipeline::VideoGeneration.new(project: project, spec: spec, client: client)+ end++ it "keeps H3 and 768P when no provider is selected" do+ expect(client).to receive(:run).with("minimax/h3-max/image-to-video", hash_including(resolution: "768P", duration: 2.5, target_audio_url: "audio", seed: 12)).and_return(["h3", output])+ generation.generate(prompt: "move", image_url: "image", duration: 2.5, audio_url: "audio", seed: 12)+ end++ it "uses 480p Seedance, whole string seconds and no H3-only inputs" do+ expect(client).to receive(:run).with(Fal::Models::SeedanceImageToVideo.endpoint,+ { resolution: "480p", generate_audio: false, codec: "H264", prompt: "move", image_url: "image", end_image_url: "end", duration: "4", draft: true }).and_return(["seedance", output])+ g = generation("model" => "seedance", "draft" => true)+ result = g.generate(prompt: "move", image_url: "image", end_image_url: "end", duration: 2.5)+ expect(g.metadata(result)).to include(endpoint: Fal::Models::SeedanceImageToVideo.endpoint, draft_id: "draft-fixture", seed: 10)+ expect(g.seconds(4.1)).to eq(5)+ end++ it "honors scene and per-shot overrides and the environment selector" do+ ENV["VIDEO_MODEL"] = "seedance"+ expect(generation.model).to eq(Fal::Models::SeedanceImageToVideo)+ allow(project).to receive(:generation).and_return(video: { model: "seedance", resolution: "720p" })+ expect(client).to receive(:run).with(Fal::Models::SeedanceImageToVideo.endpoint, hash_including(resolution: "1080p")).and_return(["s", output])+ generation("resolution" => "1080P").generate(prompt: "move", image_url: "image", duration: 4)+ expect(generation("model" => "h3").model).to eq(Fal::Models::H3MaxImageToVideo)+ end++ it "maps dialogue to reference audio and keeps image/video references and seed" do+ expect(client).to receive(:run).with(Fal::Models::SeedanceReferenceToVideo.endpoint,+ hash_including(image_urls: ["image"], video_urls: ["video"], audio_urls: ["ambience", "voice"], seed: 42,+ duration: "4", resolution: "480p", generate_audio: true, prompt: "@Image1 speaks\n\nUse @Audio2 for the performance timing and speech.")).and_return(["r", output])+ generation("model" => "seedance", "audio" => "hero", "video_urls" => ["video"], "audio_urls" => ["ambience"]).generate(+ prompt: "@Image1 speaks", image_url: "image", audio_url: "voice", duration: 3, seed: 42)+ end++ it "completes only the saved draft at 1080p without resubmitting generation inputs" do+ ENV["VIDEO_RES"] = "480p"+ expect(client).to receive(:run).with(Fal::Models::SeedanceDraftComplete.endpoint,+ { draft_id: "draft-fixture", resolution: "1080p", codec: "H264" }).and_return(["c", output])+ generation("model" => "seedance", "draft_id" => "draft-fixture").generate+ end++ it "rejects unsupported input before a paid request even without downloaded schemas" do+ expect(client).not_to receive(:run)+ expect { generation("model" => "typo") }.to raise_error(ArgumentError, /model/)+ expect { generation("draft" => true) }.to raise_error(ArgumentError, /model: seedance/)+ expect { generation("model" => "seedance").generate(prompt: "move", image_url: "image", duration: 4, seed: 2) }.to raise_error(ArgumentError, /no seed input/)+ expect { generation("model" => "seedance", "audio" => true).generate(end_image_url: "end") }.to raise_error(ArgumentError, /no pinned end frame/)+ adapter = Fal::Models::SeedanceImageToVideo.new(client: client)+ [0, -1, 30.1, Float::INFINITY].each do |duration|+ expect { adapter.animate(prompt: "move", image_url: "image", duration: duration) }.to raise_error(ArgumentError, /duration/)+ end+ expect { adapter.animate(prompt: "move", image_url: "image", duration: 4, target_audio_url: "audio") }.to raise_error(ArgumentError, /unsupported params/)+ expect { adapter.animate(prompt: "move", image_url: "image", duration: 4, draft: true, resolution: "720p") }.to raise_error(ArgumentError, /drafts require/)+ expect { Fal::Models::SeedanceDraftComplete.new(client: client).complete(draft_id: "d", resolution: "480p") }.to raise_error(ArgumentError, /only supports 1080p/)+ expect { Fal::Models::SeedanceReferenceToVideo.new(client: client).animate(prompt: "move", duration: 4) }.to raise_error(ArgumentError, /reference files/)+ end++ it "registers all three schemas and exposes completion and provider selection through MCP" do+ require_relative "../lib/toolkit/mcp_server"+ expect(Toolkit::Operations.new.endpoints).to include(*%w[image-to-video reference-to-video draft/complete].map { |s| "bytedance/seedance-2.5/us/#{s}" })+ expect(Toolkit::CredentialTasks::TASKS).to include("seedance:complete")+ expect(Toolkit::CredentialTasks::OPTIONS).to include("VIDEO_MODEL")+ end++ it "routes single-video soundtrack guidance through the reference endpoint without H3's end-frame pin" do+ allow(project).to receive(:generation).and_return(video: { model: "seedance" })+ allow(project).to receive(:step?).with(Pipeline::Steps::RefTorn).and_return(false)+ allow(project).to receive(:fetch!).with(:ref_base, :url).and_return("image")+ allow(project).to receive(:fetch!).with(:music, :url).and_return("song")+ allow(project).to receive(:prompt).with("04_video").and_return("@Image1 sings")+ allow(project).to receive(:duration).and_return(3)+ expect(client).to receive(:run).with(Fal::Models::SeedanceReferenceToVideo.endpoint,+ hash_including(image_urls: ["image"], audio_urls: ["song"], duration: "4", resolution: "480p")).and_return(["video", output])+ Pipeline::Steps::Video.new(project: project, client: client).submit+ end++ it "completes a draft shot without requiring the original image or prompt" do+ allow(project).to receive(:generation).and_return(video: { model: "seedance" })+ allow(project).to receive(:path).with("04_shot_wave.mp4").and_return("wave.mp4")+ expect(client).to receive(:run).with(Fal::Models::SeedanceDraftComplete.endpoint,+ hash_including(draft_id: "saved", resolution: "1080p")).and_return(["complete", output])+ expect(client).to receive(:download).with("https://fixture/video.mp4", "wave.mp4").and_return("wave.mp4")+ item = Pipeline::Steps::Shots.new(project: project, client: client).generate("wave", { "frames" => 72, "draft_id" => "saved" })+ expect(item).to include(endpoint: Fal::Models::SeedanceDraftComplete.endpoint, request_id: "complete")+ end++ it "saves a standalone completion receipt and downloads its output" do+ with_workspace do+ json("complete.json", draft_id: "saved")+ allow(Fal::Client).to receive(:new).and_return(client)+ expect(client).to receive(:run).with(Fal::Models::SeedanceDraftComplete.endpoint,+ hash_including(draft_id: "saved")).and_return(["complete", output])+ expect(client).to receive(:download).with("https://fixture/video.mp4", "output/full.mp4")+ operation = Toolkit::Operations.new+ expect(operation).to receive(:emit).with(hash_including(request_id: "complete"))+ operation.call("seedance:complete", ["complete.json", "output/full.mp4"])+ expect(JSON.parse(File.read("output/full.mp4.json"))).to include("request_id" => "complete", "input" => hash_including("resolution" => "1080p"))+ end+ end++ it "accepts the observed 478-pixel 480p output in video review" do+ allow(project).to receive(:generation).and_return(video: { model: "seedance" })+ allow(project).to receive(:duration).and_return(3)+ allow(project).to receive(:step?).with(Pipeline::Steps::RefTorn).and_return(false)+ allow(project).to receive(:[]).with(:video).and_return("path" => "final", "input" => { "resolution" => "480p" })+ allow(project).to receive(:[]).with(:ref_base).and_return("path" => "reference")+ allow(project).to receive(:review_path).and_return("review")+ ffmpeg = double("FFmpeg", summary: { duration: 3, video: { w: 856, h: 478 }, audio: { codec: "aac", rate: 44_100 } },+ contact_sheet: "sheet", extract_frames: ["frame1", "frame2"])+ stats = { "images" => [{ "mono_pct" => 20, "mean_saturation" => 0.4 }], "mean_mono_pct" => 20 }+ python = double("Python", style_split: stats)+ step = Pipeline::Steps::Video.new(project: project, client: client)+ allow(step).to receive(:ffmpeg).and_return(ffmpeg)+ allow(step).to receive(:python).and_return(python)+ expect(step.review[:verdict]).to eq("PASS")+ allow(ffmpeg).to receive(:summary).and_return(duration: 3, video: { w: 640, h: 360 }, audio: { codec: "aac", rate: 44_100 })+ expect(step.review[:verdict]).to eq("REVIEW")+ end+end++RSpec.describe "Seedance shot assembly", :media do+ it "requests the four-second minimum, retains draft metadata and cuts exactly three seconds" do+ with_workspace do |dir|+ stub_const("Pipeline::ROOT", dir)+ stub_const("Pipeline::GENERATIONS", "seedance" => { frames: 72, steps: [Pipeline::Steps::Shots] })+ project = Pipeline::Project.new("seedance")+ project.record(:keyframes, items: { start: { url: "https://fixture/image.png" } })+ project.record(:music, path: tone(duration: 3))+ FileUtils.mkdir_p("prompts/seedance")+ File.write("prompts/seedance/04_shots.yml", YAML.dump([{ "name" => "wave", "model" => "seedance", "image" => "start",+ "frames" => 72, "seconds" => 3, "draft" => true, "prompt" => "A little robot waves.", "camera" => "locked" }]))+ source = ff.still_video(file("seedance-source.mp4"), frames: 96, fps: 24, color: "#112233")+ client = double("Fal client")+ expect(client).to receive(:run).with(Fal::Models::SeedanceImageToVideo.endpoint,+ hash_including(duration: "4", resolution: "480p", prompt: "A little robot waves.\n\nCamera: locked")).and_return([+ "draft-request", { "video" => { "url" => "fixture://video" }, "draft_id" => "draft-id" }])+ allow(client).to receive(:download) { |_, path| FileUtils.cp(source, path); path }+ Pipeline::Steps::Shots.new(project: project, client: client).run!+ expect(project[:shots]["items"]["wave"]).to include("draft_id" => "draft-id", "endpoint" => Fal::Models::SeedanceImageToVideo.endpoint)+ expect(ff.summary(project[:shots]["path"])).to include(duration: 3.0, video: hash_including(frames: 72, h: 1080))+ end+ end+enddiff --git a/skills/make-an-anime/scripts/spec/spec_helper.rb b/skills/make-an-anime/scripts/spec/spec_helper.rbindex 459f486..d038bda 100644--- a/skills/make-an-anime/scripts/spec/spec_helper.rb+++ b/skills/make-an-anime/scripts/spec/spec_helper.rb@@ -57,7 +57,7 @@ RSpec.configure do |c|c.order = :definedc.before do@saved_env = ENV.to_h- %w[RUN ONLY FORCE RECUT NEW_REQUEST VIDEO_RES].each { |k| ENV.delete(k) }+ %w[RUN ONLY FORCE RECUT NEW_REQUEST VIDEO_RES VIDEO_MODEL SEED].each { |k| ENV.delete(k) }endc.after doENV.replace(@saved_env)