Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

docs(video): play modes — how a motion plays and its own words are request values; named states are presets

Soohong Kim1f44da88f6be
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d83f6a4..1442b9c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,9 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
## Unreleased
+- **New: a motion plays as its request says — `--play loop|once-return|once-hold|lifetime` — and `video-set --motion` gives each state or item its own motion text.** A state's name used to fix its sentence, its end-frame pin, its cut and whether its strip loops, so every new motion (a punch, typing at a desk, a block, a tool swing) was a change to the engine. `video-set --play STATE=MODE` or `ITEM=MODE` and `video-prompt --play MODE` take the mode as a value of the request, and `video-set --motion STATE=TEXT` or `ITEM=TEXT` the caller's words in place of the state's sentence (an item's own value wins over its state's; a key that names neither, a key given twice or a mode the state cannot play is refused before any clip). A word the engine does not name is filmed under that name in that mode: a once-return is pinned to end on its first frame, asked for as one action that returns to the first pose, and cut whole by the new `video-loop --cycle once-return` (every frame, the last too, gated by the pin), its `strip.json` saying `loop: false`, `hold_last: false`, `returns: true` with the first pose in its first and last cells; a once-hold is cut at its held pose (`once`); a lifetime is framed and filmed as an effect whatever its name; a loop asked for is searched as a loop (`periodic`) and never failed over to a single play. Named states are presets: without `--play` every state is filmed, prompted and cut as before, and an attack played once-return is the same prompt and the same pinned clip, cut whole and played once. `effect`, the six terminal states and the cyclic states refuse any other mode. `set.report.json` records each item's `play` (and `motion`); `video-prompt --json` records `play`. Not measured on a clip model: the sentences for a motion of your own ([video-pipeline](docs/video-pipeline.md#play-modes)).
+- **Tests** — `tests/video/test_play.py` (every named state given no mode is pinned, prompted and cut as before, and the same when its preset is named, save that a loop asked for is never failed over; a mode a state cannot play is refused; a once-return asked for pinned with its return sentence and cut whole, or searched where the source cannot pin; the attack played once-return is the attack's prompt; a named state played another way takes the mode's sentence; a once-hold with its end frame; a lifetime filmed as an effect whatever its name; a loop of your own; `video-set` modes and texts per state and per item, refused before any clip when a key or mode is wrong; a once-return that does not come back refused; a once-return cut subsampled with both ends kept and played once; the CLIs) and the once-return item filmed end to end in `tests/video/test_clip_prompt.py`, its strip's first and last cells the first pose. Synthetic fixtures only.
+
- **Behavior change: `pixel-draw` runs on your Claude subscription first, and on `ANTHROPIC_API_KEY` only without one** — the order `codex` and `grok` keep. When `claude auth status` says Claude Code is signed in with a subscription (`claude.ai` or `oauth_token`), every call — the drawings, the row repairs, the pick — goes through the unmodified `claude` binary in print mode, from an empty directory, with no tool, no session written and no CLAUDE.md, hook, skill, plugin or MCP server loaded, and costs nothing per call: `report.json` says `auth_source: claude-login`, each call's `mode` is `subscription` and its `cost_usd` `0`, its usage kept. The child never sees `ANTHROPIC_API_KEY`, which print mode would use instead of the login. Without a subscription login the run uses the key as before, billed per call and said on stderr; with neither it is refused naming both, before the run folder is made. A login that refuses a call, has expired or has reached its usage limit fails the call; the run never switches to the key on its own. `--batch` is the API's Message Batches and runs on the key even when signed in. An answer the binary continues past the output cap is read whole from every message, not from its `result`, which holds only the last part; one it cannot finish is read as `stop_reason: max_tokens`, so the one redraw one effort lower happens on either route. One call may take up to `SPRITE_GEN_CLAUDE_CALL_TIMEOUT_SECONDS` (1800). When candidates ask at once, none of their requests leaves before the billing line has been printed. `report.json`'s `auth_source` is what the calls ran on by their records, `mixed` (with `auth_sources`) for a run resumed under the other credential. A `--resume` that reads every call back no longer prints the billing line ([pixel-draw](docs/pixel-draw.md#which-credential-a-call-runs-on)).
- **Behavior change: every metered call says so on the terminal, and every report names what a call ran on.** How codex is signed in is one reading, `codex_provider.codex_login` (`codex login status`), for the default provider resolution, `gen --provider codex`, the codex facing check and `workflow`: a codex signed in with an API key used to run with no word about it and the workflow called it a subscription; it now prints the per-call charge line before `codex exec` runs, its report records `extra.auth_source: codex-api-key` (`codex-login` on ChatGPT), and `workflow` asks to confirm the API credit. A codex that is not signed in is refused with the reason before it runs. `gen-set` and `video-set` keep each item's output in its log, but a child's billing line and a default provider switch now also print on the terminal as they happen (`base.run_logged`), each `gen-set` row records `auth_source`, and each `video-set` clip result too. `sound` prints the same billing line as every other metered route (it printed its own) and its receipt records `auth_source`. One function reads a provider key from the environment (`base.env_api_key`: a key, none, or a refusal of an empty one) for Anthropic, OpenAI, xAI and ElevenLabs; one function says what to do when xAI rejects a credential (`xai.rejected_fix`), so `gen --provider grok` now gives the same `grok models` refresh as `video`. `workflow` probes a provider once for its images and videos (they share one credential) and asks the API-credit question by that provider's name rather than always about Grok video. Docs: the credential table in the README, grok's `XAI_API_KEY` route in the help and SKILL.md, the sound billing line, `SPRITE_GEN_GEN_TIMEOUT_SECONDS` and `SPRITE_GEN_CLAUDE_READ_TIMEOUT_SECONDS`, and `gen-set --provider` (`codex` or `grok`).
- **Tests** — `tests/gen/test_claude_login.py` (the login before the key, the key only without a login, neither refused naming both, a batch on the key without asking the login, an unreadable status refused rather than read as no login, the child's environment without a key or the calling session, a message mapped onto the binary's flags and stdin with its image and schema, the stream-json answer, a cut answer read as max_tokens, a refused or limited login an error and not a switch to the key, no result, a timeout and a missing binary), the subscription, batch and read-back cases in `tests/gen/test_pixel_draw.py`, and `gen.base.env_api_key` in `tests/gen/test_gen.py`; `tests/gen/test_codex_login.py` (ChatGPT, an API key and not signed in; the default resolution, `generate` and `workflow` read the same login; an API-key login announces the charge and records it), `base.run_logged` in `tests/gen/test_gen.py`, the ElevenLabs billing line and key refusals in `tests/audio/test_sound.py`.
diff --git a/SKILL.md b/SKILL.md
index 2b65979..a38eca5 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -77,6 +77,7 @@ it never changes the requested direction. Image correction requires explicit opt
| `gen --direction`, `--handed`; `video-prompt` / `video-set --handed` | a view; `"<item>=<left\|right> [part]"` | An item on one of the character's own sides: the still and clip prompts say where it is in each view, and mirroring is refused. |
| `video-prompt` / `video-set` / `gen --direction` / `prepare --body-plan` | `biped` (default), `quadruped`, `legless`; or `"<figure>=<plan>"` per figure of a scene | What the subject stands on: no clip, attack, redraw, still view or sheet row prompt names a part it lacks (a horse is not walked on a person's legs, stood up, given arms in a walk sheet or told to strike with its hands), and a scene says it per figure. |
| `video --facing-fix`, `video-set --facing-fix` | `none` (default), `mirror` | Record the observation; opt into mirroring an observed opposite in a copy. Batch side inspection is enabled by default. |
+| `video-set --play`, `--motion`; `video-prompt --play`, `--motion` | `loop`, `once-return`, `once-hold`, `lifetime`; in `video-set` `"<state>=…"` or `"<item>=…"` | How a motion plays, and its own words: a word the engine does not name (`punch`, `type_at_desk`) is filmed in that mode; a once-return strip plays once and ends on its first pose (`loop: false`, `returns: true`). Without `--play` a named state plays as its preset ([play modes](docs/video-pipeline.md#play-modes)). |
Direction is requested through the generation and motion prompts, which cannot guarantee model compliance.
The detector can be wrong even at high confidence: review the still before choosing `mirror` or `regen`.
diff --git a/docs/states-and-frames.md b/docs/states-and-frames.md
index c8a1325..6399b3f 100644
--- a/docs/states-and-frames.md
+++ b/docs/states-and-frames.md
@@ -10,6 +10,8 @@ Video path defaults apply strictly to the video path, independent of component-r
Six states automatically select `once` across `sprite-gen video-prompt`, `sprite-gen video-set`, and `sprite-gen video-loop --cycle auto`. Defaults for `idle`, `walk`, `run`, `jump`, and `attack` remain unchanged. Cyclic states (`idle`, `walk`, `run`, `talk`, `blink`, `breathe`) reject explicit `--cycle once`, but overrides allow `jump`, `attack`, or custom actions.
+These defaults are presets. `--play loop|once-return|once-hold|lifetime` (`video-set`, `video-prompt`) films a motion in the mode the request names — a named state, or a word of your own described with `--motion` (a punch, typing at a desk, a block) — and the end-frame pin, the prompt's ending, the cut and the strip's `loop` follow it. The six states below play once-hold only, `effect` lifetime only, and the cyclic states loop only. See [play modes](video-pipeline.md#play-modes).
+
Motion prompts request a 0.4 s hold. Anatomy is preserved across body plans (`quadruped`, `legless`). Headroom requires symmetric side margins for `death` and `hurt_hold`, overhead room for `cast` and `transform`, and descent room for `land`; border contact is refused. Candidate end pose geometry requires median end-window height <= 80% of initial height for `death` and `fall`, while other `once` states require changed geometry (conservative geometric screen; inspect semantic pose visually). Root displacement metadata is omitted. See [video-pipeline.md](video-pipeline.md) for gate and metadata details.
| State | End Pose |
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index 8ff1e0f..986e16b 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -1003,6 +1003,14 @@ re-render noise of the pinned frame as a jump; a clip that ends in another pose
with its own message (`the pinned clip does not end on its first frame`). The report says
`kind = "pinned"` and records `pin_error` and `pin_tolerance`.
+`--cycle once-return` is for a clip pinned to end on its first frame that plays once (`video-set
+--play once-return`, [play modes](#play-modes)). It keeps every frame, the last too, so the strip
+starts and ends on the first pose and a game plays it once and goes on from the pose it started in.
+The gate is the pin, as for `pinned` (`the once-return clip does not end on its first frame … it does
+not return to its first pose`). The strip is sampled with both ends kept, the previews play once as a
+`once` cut's do (WebP `loop=1`, no GIF loop extension), and `strip.json` says `loop: false`,
+`hold_last: false`, `returns: true`, `end_frame` and a `motion_peak` event (the clip's largest step).
+
Outputs:
- `cycle/frame-NNN.png` — the cycle frames, RGB under alpha 0 scrubbed, detached specks
@@ -1124,6 +1132,58 @@ where both apply). Two cases skip the alignment with a warning instead of failin
that may hold more than one cycle (`cycle-suspects`, the loops under `suspects`; count them, then
`video-cycle-align --cycles <loop>=<k>`). See [loop repair](loop-repair.md) section 4.
+### Play modes
+
+A state's name used to decide everything about its clip: its sentence, whether the clip is pinned to
+end on its first frame, how it is cut and whether its strip loops, so every new motion was a change to
+the engine. `--play` gives how a motion plays as a value of the request, and `--motion` gives the
+motion's own words, so a motion the engine has no state for — a punch, typing at a desk, a block — is
+filmed under a name of your own. The modes and the presets are `sprite_gen/video/play.py`.
+
+```bash
+sprite-gen video-set --base side=side.png --base front=front.png --states idle,punch,type_at_desk,slash \
+ --play punch=once-return --motion "punch=It throws one straight punch with its front fist and pulls it back." \
+ --play type_at_desk=loop --motion "type_at_desk=It sits at a desk and types on a keyboard." \
+ --play slash=lifetime --motion "slash=A white crescent arcs from left to right." --out-dir set/
+```
+
+| `--play` | the clip | the prompt asks for | the cut (`video-loop --cycle`) | `strip.json` |
+|---|---|---|---|---|
+| `loop` | as the state is filmed: an idle or attack pinned to its first frame, a walk or run pinned in a diagonal view, any other unpinned | an evenly paced repeat, or the return to the first pose where pinned | `pinned` for an idle or attack, otherwise `periodic` | `loop: true` |
+| `once-return` | pinned to end on its first frame | one action, then the first pose again (after your text: `It does this once, then returns to the exact pose of the first frame.`) | `once-return`: the whole clip, its last frame too, gated by the pin | `loop: false`, `hold_last: false`, `returns: true`; the first and last cells are the first pose |
+| `once-hold` | unpinned (`--end-frame ITEM=PATH` pins a terminal pose) | one action, its last pose held still for 0.4 s | `once` | `loop: false`, `hold_last: true` |
+| `lifetime` | framed as an effect and pinned to an empty black frame | an effect that appears and is gone | `lifetime` | `loop: false`, `blend: add` |
+
+`STATE=…` applies to every view of that state and `ITEM=…` (`side-punch=…`) to one item, whose own
+value wins over its state's. A key that names neither, a key given twice, an empty value or a mode the
+state cannot play is refused before any clip is made. `set.report.json` records each item's `play`
+and, where given, its `motion`.
+
+Named states are presets. Without `--play` every state is filmed, prompted and cut as before: `effect`
+as a lifetime, the six terminal states (`death`, `fall`, `land`, `cast`, `hurt_hold`, `transform`) as a
+once-hold and every other state as a loop, each with its own sentence, canvas row and cut (the prompts
+are unchanged, `tests/gen/test_prompt_freeze.py`). A state of one nature plays only that mode — `effect`
+a lifetime, a terminal state a once-hold, a cyclic state (`idle`, `walk`, `run`, `talk`, `blink`,
+`breathe`) a loop — and another motion is filmed under a name of its own. A named state's sentence is
+used in its preset mode, and the attack's (one strike, then a recovery to the exact starting stance) in
+once-return as well: the same prompt and the same pinned clip, cut whole and played once. In any other
+mode, and for a word the engine does not name, the mode's own sentence names the motion (`performs the
+'punch' action once in place, then returns to the exact starting stance.`) unless `--motion` gives one.
+
+A mode the request names is the cut's: a `loop` asked for is searched as a loop (`periodic`) and
+refused when it does not repeat, never failed over to a single play the way a preset's `auto` cut of a
+`jump` or of an unnamed state may be ([one-shot actions](#one-shot-actions--cycle-autoperiodicone-shot)).
+The canvas row is the state's (a motion of your own films on the square default; `--shape` widens
+every canvas of the set), except that a lifetime is framed as an effect whatever its name.
+
+`video-prompt --play MODE` does the same for a clip made elsewhere: the record's `play`, `last_frame`,
+`cycle` and commands follow the mode. A source with no end frame films a once-return only with
+`--unpinned`, as a searched return (`--cycle one-shot`: rest, action, rest; `loop: false`), and
+refuses a lifetime.
+
+Not measured on a clip model: the sentences for a motion of your own (`PLAY_TEXT`, `RETURN_TEXT`).
+The once-return template is the one an attack is filmed with (`ACTION_COMMON_TEXT`).
+
## 6. Follow-through — `video-follow`
A clip model draws a walk's body moving, but a soft part hanging off it (a chest, a belly, a