# Sprite Pipeline

This pipeline turns the current Anime Fighter Pro notes/admin data into per-character sprite packets, validates them, builds image-generation jobs, and imports finished PNGs back into the local app data.

## Commands

```bash
cd /Users/jason/Projects/anime-fighter-pro-organizer

npm run sprite:export -- --all
npm run sprite:validate -- --all
npm run sprite:build-jobs -- --character <character-slug>
npm run sprite:import -- --character <character-slug>
```

Optional flags:

```bash
--copy-refs            # copy attached image refs into the packet folder
--include-prototypes   # include placeholder prototype characters
--pending-ui           # import UI art without auto-approving it
--root <path>          # override packet root
--json                 # print JSON output only
```

## Packet Location

By default, packets are written under:

```text
storage/sprite-pipeline/characters/<slug>/
```

Each character packet contains:
- `packet.json`
- `validation-report.json`
- `generated/keyframes/`
- `generated/ui/`
- `jobs/`

## Packet Editing Rules

Fill these before generation:
- `input.main_canon_ref_id`
- `input.personality`
- `input.body_type`
- `input.outfit`
- `input.proportions`
- `input.signature_props`
- `input.palette`
- every move's `action`, `pose`, and `feel`

Optional but recommended:
- `input.full_body_ref_id`
- `input.facing_direction`
- UI target `brief` fields

## Generation Outputs

Expected output files:
- `generated/ui/portrait.png`
- `generated/ui/select_art.png`
- `generated/ui/unlock_art.png`
- `generated/ui/stock_icon.png`
- `generated/keyframes/<move>.png`

The generated files should be:
- transparent PNG
- character only
- no hit sparks
- no slash trails
- no baked energy effects

## Import Behavior

Import does two things:
- UI PNGs become character assets in the admin DB (`portrait`, `select_art`, `unlock_art`, `stock_icon`)
- move PNGs become `moveset_media` entries for the matching move section

After import, `runApplyToGodot()` will export the latest move keyframe PNGs to:

```text
assets/content/characters/<slug>/sprites/keyframes/<move>.png
```

and include them in generated character JSON under `attack_keyframes`.

## OpenAI Image Generation

Live generation still requires `OPENAI_API_KEY` to be set locally.
The packet builder creates:
- JSONL files for `generate-batch`
- shell scripts for `edit` runs using the selected canon reference
