Skip to content

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

Merge main into the anchor fit: the follow-ups and PR #107 landed

Soohong Kim5b008598f7b5
diff --cc CHANGELOG.md
index d69a0be,032b51a..cc2f034
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -4,8 -4,21 +4,22 @@@ All notable public changes to `sprite-g
## Unreleased
+- **Fix: the poses of one image row keep one size and stay on their anchor.** Each pose of a row was shrunk into its cell on its own, so a raised or extended weapon shrank that pose's body (PR #107 gave the row one shrink ratio). That ratio fitted the widest pose by its own width, and `fit_to_cell` then placed it with its `align_x` anchor (the legs, by default) on the cell's centre line: a weapon held far out crossed the cell and the pose was pushed back in, body and all, so the body jumped back in that frame alone (a greatsword thrust: 39 px in a 256 cell). The ratio is now one function, `fit_scale`, which keeps every pose inside the safe area where its anchor puts it; `fit_to_cell` takes it for a frame alone, the row takes it over every pose, and `qa/inspect` fits a row the same way instead of pose by pose. With `bbox-center` nothing changes. A weapon held far to one side now costs size in a square cell: give such a row a wider cell ([pixel-unfake](docs/pixel-unfake.md)). Test: `tests/frames/test_row_scale.py`.
+ - **Fix: the test suite runs on Windows.** `pyproject.toml` named pytest-timeout's `signal` method, and Windows has no SIGALRM, so pytest stopped with an internal error before its first test unless `-o timeout_method=thread` was given. The method is now left to pytest-timeout, which takes `signal` where SIGALRM exists (Linux, macOS: unchanged) and `thread` on Windows. Test: `tests/packaging/test_project_metadata.py`. `tests/video/test_one_step_cut.py` skips where img2webp is missing, as the other loop tests do, instead of failing all twelve of its tests.
+ - **Fix: `sprite-gen prepare --request` keeps the request's `style`.** The subcommand declared its own copy of prepare's options, with `--style` defaulting to the default style sentence and `--cell-size` to 256, so a flag nobody gave counted as given: the request's `style` was replaced by the default sentence under a note that `--style, --cell-size` were given both ways (`scripts/prepare_sprite_run.py` and `prepare.run` were right). The subcommand now takes prepare's own declaration (`prepare.add_arguments`), which also gives it `--directions` and `--mirror`, missing until now. A request with no style and no cell still gets the default sentence and 256. Test: `tests/gen/test_flags_over_spec.py` (through `sprite-gen prepare`: a request alone keeps its style and cell with no note, a given `--style` wins and says so, the subcommand takes every option prepare declares).
+ - **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`.
- **New: `background-tile --axis xy` makes one tile seamless in both directions and measures both joins.** It quilts along x, then along y with a cyclic seam: the second seam's two ends, which meet across the x wrap, may differ by one step at most, so the second quilt cannot break the first one's join. The report measures the finished tile on both axes (`axes.x`, `axes.y`, each with its join, quilt seam, `status` and reasons); the top-level `status` is `needs-review` when either axis is, and each reason names its axis. Two separate one-axis runs had no such rule, and the second run's report measured only its own axis. `inspect_tile_xy(image)` measures both joins of any tile ([asset-tools](docs/asset-tools.md#both-axes-a-ground-tile)).
+ - **New: `pixel-draw` draws a set of up to 64 frames, four a call.** One call still draws at most four frames, so the frames of one answer share a palette and a design; a longer set — a hand-drawn motion of several seconds — is drawn four at a time, one call after another. Every call's prompt names all the frames and which ones it draws; each call after the first writes the first call's palette again — a colour it adds is refused and the rows that use it go to the row repair, a colour it changes is put back, both recorded in G1's `recovered` (`palette_added`, `palette_changed`) — and is shown the first frame and the four just before its own, as the grid it writes (about 6,000 input tokens at 48 px, by the characters a token Opus's own answers wrote). The row repair and the one redraw are each call's own (`c1-part2-gen1`, `c1-part2-gen1-fix1`, `c1-part2-gen2`), the gates run once every frame is drawn, `--resume` reads every call back, and stderr says before the first request how many calls and tokens the set may take. A `--spec` frame may be `{"name": ..., "pose": ...}`, which puts that pose on the frame's own line of its call's prompt. Previews put the frames in rows of eight, and a pick sheet larger than Claude reads unscaled (2576 px on the long edge, 4784 patches, read off Claude's vision page on 2026-10-15) is drawn at the largest smaller whole enlargement that fits, nearest-neighbour, instead of being blurred by the API's downscale. The report's candidates carry `parts`. An effect stays 2–8 frames in one call ([pixel-draw](docs/pixel-draw.md#more-than-four-frames)).
+ - **New: `pixel-draw --style TEXT` draws in a style of your own.** It takes the place of the kind's style sentence (a sprite's "a dark (not pure black) outline around the silhouette, 2-3 shades per material, light from the top-left …") and of nothing else: the transparent background, the safe area and the floor row, a tile's seams and an effect's centre stay. The pick judges craft against the same words in place of its fixed "clean silhouette and outline". Without `--style` both prompts are byte for byte what they were. Same name and meaning as `prepare --style`; spec key `style`; `request.style` in the report ([pixel-draw](docs/pixel-draw.md#the-style)).
+ - **New: `pixel-draw --motion TEXT`: the frames, in their order, are one motion.** The prompt says so in your words, and G6 takes the rule of one motion, written once in the header of `pixel_gates.py`: a frame off the ground row still fails, but a height that changes (an arm raised over the head, a blade swung past it) is asked whether the body changed size or only its pose, by the reading `video-loop --body-height` already makes of a cut (`video.gait_fallback.size_change` on height, mass and breadth) — a pose is an info line, a body drawn at another size warns — and a frame drawn twice is a hold, an info line. `gates.G6` then has `rule: "motion"`, `size_change`, `resized`, `posed` and `holds`. Same name and meaning as `video-prompt --motion`; spec key `motion`; also on `--grid` ([pixel-draw](docs/pixel-draw.md#gates)).
+ - **Behavior change: a `pixel-draw --walk-cycle` is one motion.** Its two passing frames drawn alike, or a height that changes by more than a pixel with the pose, no longer fail G6: they are info lines, and a body drawn at another size warns. A walk cycle still fails off the ground row, and still warns when its legs barely change sides.
+ - **New: `pixel-draw --duration-ms N` times `anim.gif`** (and an effect's `delay_ms`), 150 ms by default as before, at least 10; spec key `duration_ms`, also on `--grid`. Same name and meaning as `compose-cycle --duration-ms`.
+ - **Docs: `pixel-draw`'s note that only effort xhigh spent every token thinking and wrote nothing is corrected** — a set of four 48 px frames at effort high did too (2026-10-14).
+ - **Tests** — `tests/gen/test_pixel_draw_frames.py` (a set of six drawn in two calls, the second holding the first's palette with a colour it added refused and repaired, shown the frames before it and carrying its frames' poses, read back whole on `--resume`; a later call shown the first frame and the four just before its own; a call drawn again on its own one effort lower; a call that fails ending its candidate; each call its own batch; spec frames refused; `--style` in the drawing and the pick of every kind with the structure kept; the default drawing and pick prompts frozen byte for byte from before; `--motion` refused for one frame and for an effect; a synthetic 48 px set of 46 frames of one motion — an arm raised for ten frames and held for four — passing `--grid` with `--motion`, and failing without it; `--duration-ms` in `anim.gif` and an effect's strip; a pick sheet of 46 frames for two candidates drawn at ×3 within Claude's unscaled size), `tests/gen/test_pixel_gates.py` (G6 of one motion lets a raised arm and a hold through, fails a frame off the ground and warns a body drawn larger; a walk cycle is one motion) and `tests/gen/test_pixel_grid.py` (a palette held, with a colour added and one changed; parts joined; previews in rows of eight).
+ - **Fix: a `pixel-draw` answer that writes its block more than once is read from the last block that reads whole.** An answer sometimes writes a first try — the palette and `END` with no frame — then "Corrected:" and the whole block (seen 2026-10-15 on a 16 px icon); G1 read the first block, found the frame missing and drew the candidate again. Now every block is read and the last one that reads whole is the answer (when none does, the last whose rows the row repair can fix), recorded in G1's `recovered` as `block_many` with which block was read. An answer of one block is read as before.
+ - **Tests** — `tests/gen/test_pixel_grid.py` (several blocks read from the last whole one, or the last with rows to repair; one block as before) and an answer of two blocks drawn once in `tests/gen/test_pixel_draw.py`.
- **New: alpha haze cleanup for transparent sheets (`frames.alpha_floor.clear_haze`).** Pixels at or above a floor, and faint pixels within a few pixels of them (an object's anti-aliased edge), are kept byte for byte; every other faint pixel becomes fully transparent. The report measures the haze share before and after and counts the solid and edge pixels that changed (`0`). Used by `ui-kit` (on by default) and `slice-sheet --alpha-floor N` (off by default; writes `<prefix>alpha-cleanup.json`). `slice-sheet --chroma-key none` cuts a sheet that is already transparent on its own alpha ([sheet-slicing](docs/sheet-slicing.md#transparent-sheets)).
- **New verb: `ui-kit` splits a game UI kit sheet into nine-slice elements.** `gen --layout-guide ui-kit` attaches a fixed square layout (panel, button, pressed button, card frame, HP and XP bar frames, timer badge) and asks for each element in its box. `ui-kit --sheet uikit.png --out-dir ui/` clears the haze, assigns parts to boxes by centroid, and writes each element's PNG and `ui-kit.json` (or `--report PATH`, which must end in `.json`; each element's `file` is its PNG's path from the report's directory, so a report written outside `--out-dir` still finds its elements): its rectangle, its stretch (`xy`, `x` for the bars, `none` for the badge), nine-slice insets measured so that every corner ornament and end cap lies in a fixed slice, and the content padding (a bar frame's track, a panel's text area). An ornament in the middle of an edge, an empty box or a stray part is reported or refused ([ui-kit](docs/ui-kit.md)). `--layout-guide` alone is still the one-slot figure guide.
- **New: `game-pack` request and manifest version 2 with `images`, `tiles` and `ui`.** Single images (props) are atlas frames with an anchor and an optional footprint (`"base"` measures where the image meets the ground); tiles are their own PNG and WebP files with their stored and on-screen sizes; `ui.kit` reads a `ui-kit` report into nine-slice entries (frame, size, stretch, insets, padding) and `ui.icons` adds fixed icons. Every number is in pixels of the stored image. A version 1 request is packed byte for byte as before, and a version 1 request naming the new sections is refused ([game-pack](docs/game-pack.md#version-2-images-tiles-and-ui)).