diff --git a/prd.json b/prd.json
new file mode 100644
index 0000000000..ad558ac6ac
--- /dev/null
+++ b/prd.json
@@ -0,0 +1,72 @@
+{
+ "name": "reskin-pipeline",
+ "branchName": "ralph/reskin-pipeline",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/ -v",
+ "maxRetries": 2,
+ "stories": [
+ {
+ "id": "story-1",
+ "title": "categories.py — style preset definitions",
+ "description": "Create scripts/reskin/categories.py with OpenRCT2 sprite category presets. Reference /workspace/ottd-reskin-pipeline/env_categories.py for the pattern but remove all sprite ID ranges (OpenRCT2 discovers sprites from the filesystem). Define 6 categories: scenery_small, scenery_large, scenery_wall, terrain, footpath, ride. Each has: tiling (bool), style_prompt (str), description_hint (str). See docs/plans/2026-02-25-reskin-pipeline.md Task 1 for exact code. Verify by importing: python3 -c \"import sys; sys.path.insert(0, 'scripts/reskin'); from categories import CATEGORIES; assert len(CATEGORIES) == 6\"",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -c \"import sys; sys.path.insert(0, 'scripts/reskin'); from categories import CATEGORIES; assert len(CATEGORIES) == 6; print('OK')\"",
+ "status": "passed",
+ "retries": 0
+ },
+ {
+ "id": "story-2",
+ "title": "batch_sprites.py — grid batching with tests",
+ "description": "Create scripts/reskin/batch_sprites.py adapted from /workspace/ottd-reskin-pipeline/batch_env.py. Key changes: no NFO parsing, no sprite ID extraction (use filenames as-is), no subcategory batching. Functions: load_sprites(dir), create_batches(sprites), render_grid_with_sprites(batch, batch_id, sprites_dir), batch_sprites(sprites_dir, batch_dir, style_prompt, description_hint, tiling). Also a main() CLI with --sprites-dir, --batch-dir, --style, --description-hint, --tiling args. Also create scripts/reskin/test_batch_sprites.py with 6 tests: test_load_sprites, test_load_sprites_ignores_non_png, test_create_batches_single_bucket, test_create_batches_splits_at_16, test_create_batches_separates_sizes, test_batch_sprites_end_to_end. See docs/plans/2026-02-25-reskin-pipeline.md Task 2 for exact code.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_batch_sprites.py -v",
+ "status": "pending",
+ "retries": 0
+ },
+ {
+ "id": "story-3",
+ "title": "generate_restyled.py — FAL.ai generation with tests",
+ "description": "Create scripts/reskin/generate_restyled.py adapted from /workspace/ottd-reskin-pipeline/generate_restyled.py. Keep all FAL.ai logic identical. Key functions: load_descriptions(dir, batch_id), build_prompt(batch_meta, style_desc, descriptions_dir), generate_with_fal(prompt, condition_path, output_path, retries), generate_all(manifest_path, restyled_dir, style, descriptions_dir, skip_existing, batch_id_filter). Handle fal_client import gracefully (set to None if not installed). Also create scripts/reskin/test_generate_restyled.py with 4 tests: test_build_prompt_no_descriptions, test_build_prompt_with_descriptions, test_load_descriptions_missing_dir, test_load_descriptions_missing_file. See docs/plans/2026-02-25-reskin-pipeline.md Task 3 for exact code.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_generate_restyled.py -v",
+ "status": "pending",
+ "retries": 0
+ },
+ {
+ "id": "story-4",
+ "title": "parse_restyled.py — sprite extraction with tests",
+ "description": "Create scripts/reskin/parse_restyled.py adapted from /workspace/ottd-reskin-pipeline/parse_and_replace.py. Remove patch_sprite_sheets(), rebuild_grf(), save_png_small_idat(). Keep: extract_sprites_from_grid(), restore_alpha(), blend_tile_edges(), validate_sprite(). Add parse_restyled() main entry point that writes individual PNGs to output_dir. CLI: --manifest, --sprites-dir, --restyled-dir, --output-dir, --tiling, --no-tiling, --dry-run. Also create scripts/reskin/test_parse_restyled.py with 7 tests: test_restore_alpha, test_restore_alpha_transparent_original, test_blend_tile_edges, test_blend_tile_edges_tiny_sprite, test_validate_sprite_different, test_validate_sprite_too_similar, test_validate_sprite_transparent. See docs/plans/2026-02-25-reskin-pipeline.md Task 4 for exact code.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_parse_restyled.py -v",
+ "status": "pending",
+ "retries": 0
+ },
+ {
+ "id": "story-5",
+ "title": "reskin.py — orchestrator with tests",
+ "description": "Create scripts/reskin/reskin.py that chains batch -> generate -> parse. Supports workspace mode (--workspace, reads sprites/ subdir, writes back there) and standalone mode (--sprites-dir). Uses sys.path.insert to import sibling modules. Functions: resolve_dirs(args), resolve_style(args), resolve_tiling(args), resolve_description_hint(args), run_step(step, ...). CLI: --workspace|--sprites-dir, --style, --category, --tiling, --step, --through, --dry-run, --skip-existing, --list-categories. Also create scripts/reskin/test_reskin.py with 6 tests: test_resolve_dirs_workspace, test_resolve_dirs_standalone, test_resolve_style_explicit, test_resolve_style_from_category, test_resolve_tiling_explicit, test_resolve_tiling_from_category. See docs/plans/2026-02-25-reskin-pipeline.md Task 5 for exact code.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_reskin.py -v && python3 scripts/reskin/reskin.py --list-categories",
+ "status": "pending",
+ "retries": 0
+ },
+ {
+ "id": "story-6",
+ "title": "Playwright screenshot skill for OpenRCT2 web",
+ "description": "Create scripts/reskin/screenshot_game.py — a Playwright script that:\n1. Starts the OpenRCT2 web server (scripts/serve-emscripten.py) pointing at a directory containing the built wasm output\n2. Launches headless Chromium with SharedArrayBuffer support (args: --enable-features=SharedArrayBuffer)\n3. Navigates to index.html, waits for the canvas to appear (selector: canvas#canvas with display != none)\n4. Waits for the game to load (the #loadingWebassembly element gets removed when loading completes — wait for it to be detached)\n5. Takes a screenshot and saves to a specified output path\n6. Shuts down browser and server\n\nCLI: python3 screenshot_game.py --serve-dir
--output [--port 8000] [--wait-seconds 10]\n\nUse playwright.sync_api (Python sync API). The server needs COOP/COEP headers (serve-emscripten.py handles this).\n\nIMPORTANT: The script must handle the case where no wasm build exists gracefully — print a clear error message and exit 1. Do NOT try to build the wasm.\n\nTest: Create scripts/reskin/test_screenshot_game.py with at least 2 tests:\n- test_server_starts_and_stops: verify the COOP/COEP server can start on a temp dir and respond to requests\n- test_missing_serve_dir: verify graceful error when dir doesn't exist\n\nDo NOT test the full Playwright flow in unit tests (requires wasm build). The integration test is manual.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_screenshot_game.py -v",
+ "status": "pending",
+ "retries": 0
+ },
+ {
+ "id": "story-7",
+ "title": "Gemini visual judge script",
+ "description": "Create scripts/reskin/judge_screenshot.py — invokes Gemini CLI to visually judge a game screenshot.\n\nCLI: python3 judge_screenshot.py [--reference ] [--criteria 'text']\n\nBehavior:\n1. Takes a screenshot path (required) and optional reference image path\n2. Builds a prompt asking Gemini to evaluate the screenshot:\n - If reference provided: 'Compare these two screenshots. The first is the original, the second is reskinned. Evaluate: (1) Did the reskin change the visual style? (2) Are game elements still recognizable? (3) Is the overall quality acceptable? Rate 1-10 and explain.'\n - If no reference: 'Evaluate this game screenshot. Is it rendering correctly? Are there visual artifacts, black screens, or missing textures? Rate quality 1-10 and explain.'\n - If --criteria provided, append it to the prompt\n3. Invokes: gemini -p \"\" -m gemini-3.1-pro-preview --include-directories --yolo --output-format text 2>/dev/null\n4. Prints the Gemini response\n5. Parses the rating (look for 'X/10' pattern) and exits 0 if >= 5, exit 1 if < 5 or unparseable\n\nTest: Create scripts/reskin/test_judge_screenshot.py with tests:\n- test_build_prompt_single_image: verify prompt construction without reference\n- test_build_prompt_with_reference: verify prompt includes comparison language\n- test_build_prompt_with_criteria: verify custom criteria is appended\n- test_parse_rating_valid: verify '7/10' parses to 7\n- test_parse_rating_missing: verify None returned when no rating found\n\nKeep the Gemini invocation in a separate function so tests don't need the CLI.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/test_judge_screenshot.py -v",
+ "status": "pending",
+ "retries": 0
+ },
+ {
+ "id": "story-8",
+ "title": "Full test suite verification and CLI smoke test",
+ "description": "Run the complete test suite across all scripts/reskin/ test files. Verify all 4 CLI scripts print help without errors:\n- python3 scripts/reskin/batch_sprites.py --help\n- python3 scripts/reskin/generate_restyled.py --help\n- python3 scripts/reskin/parse_restyled.py --help\n- python3 scripts/reskin/reskin.py --help\n- python3 scripts/reskin/screenshot_game.py --help\n- python3 scripts/reskin/judge_screenshot.py --help\n- python3 scripts/reskin/reskin.py --list-categories (should list 6 categories)\n\nIf any tests fail, fix them. If any --help fails, fix the argparse setup. This is a cleanup/validation story.",
+ "verify": "cd /workspace/OpenRCT2-Web && python3 -m pytest scripts/reskin/ -v && python3 scripts/reskin/reskin.py --list-categories && python3 scripts/reskin/batch_sprites.py --help > /dev/null && python3 scripts/reskin/judge_screenshot.py --help > /dev/null",
+ "status": "pending",
+ "retries": 0
+ }
+ ]
+}
diff --git a/progress.txt b/progress.txt
new file mode 100644
index 0000000000..500ca17258
--- /dev/null
+++ b/progress.txt
@@ -0,0 +1,20 @@
+# Progress Log — reskin-pipeline
+# Generated from docs/plans/2026-02-25-reskin-pipeline.md
+# Started: 2026-02-25
+
+## Context
+- Adapting /workspace/ottd-reskin-pipeline/ (AI sprite reskinning for OpenTTD) to OpenRCT2
+- OpenRCT2 uses .parkobj files (zip with object.json + images.dat), not GRF/NFO
+- Existing shell scripts handle extraction/repackaging: init-reskin-object-workspace.sh, rebuild-object.sh, build-reskin-upload.sh
+- New Python pipeline slots between extraction and rebuild: batch -> generate (FAL.ai) -> parse
+- Also adding Playwright screenshot and Gemini CLI visual judging capabilities
+- All new files go under scripts/reskin/
+- Python deps available: Pillow, numpy, fal-client
+- Playwright installed with Chromium at /root/.cache/ms-playwright/chromium-1208
+- Gemini CLI available at /usr/local/share/npm-global/bin/gemini
+- Existing workspace example at tmp/reskin-workbench/support-structure-half/ with 4 sprites
+--- Iteration 1 | story-1 | 2026-02-25 00:10:08 ---
+Created scripts/reskin/categories.py with 6 category presets (scenery_small, scenery_large, scenery_wall, terrain, footpath, ride).
+Each has tiling (bool), style_prompt (str), description_hint (str). No sprite ID ranges — OpenRCT2 discovers sprites from filesystem.
+Verification passed: import + assert len(CATEGORIES) == 6.
+Status: PASSED
diff --git a/scripts/reskin/categories.py b/scripts/reskin/categories.py
new file mode 100644
index 0000000000..7926dfd4fa
--- /dev/null
+++ b/scripts/reskin/categories.py
@@ -0,0 +1,63 @@
+"""OpenRCT2 sprite category presets for AI restyling.
+
+Categories define style prompts, tiling flags, and description hints.
+Unlike the ottd pipeline, these do NOT define sprite ID ranges —
+OpenRCT2 sprites are discovered from the filesystem.
+"""
+
+CATEGORIES = {
+ "scenery_small": {
+ "tiling": False,
+ "style_prompt": (
+ "Cartoony hand-painted fantasy scenery. Bold outlines, bright saturated "
+ "colors, warm lighting. Rich detail, painterly textures. "
+ "Think Warcraft III or Clash of Clans decorations."
+ ),
+ "description_hint": "small scenery object sprite (bench, lamp, fence, planter, etc.)",
+ },
+ "scenery_large": {
+ "tiling": False,
+ "style_prompt": (
+ "Cartoony hand-painted fantasy scenery. Bold outlines, bright saturated "
+ "colors, warm lighting. Large decorative structures with rich detail. "
+ "Think theme park attractions in a fantasy art style."
+ ),
+ "description_hint": "large scenery object sprite (building, tower, statue, etc.)",
+ },
+ "scenery_wall": {
+ "tiling": True,
+ "style_prompt": (
+ "Cartoony hand-painted fantasy walls and fences. Bold outlines, "
+ "warm browns for wood, gray for stone, vibrant colors for decorative walls. "
+ "Painterly textures. Think medieval fantasy theme park barriers."
+ ),
+ "description_hint": "wall or fence segment sprite",
+ },
+ "terrain": {
+ "tiling": True,
+ "style_prompt": (
+ "Cartoony hand-painted fantasy terrain. Rich vibrant greens and warm "
+ "earth tones. Bold color gradients. Painterly brushstroke textures. "
+ "Keep isometric diamond shape and edge pixels unchanged."
+ ),
+ "description_hint": "isometric terrain ground tile",
+ },
+ "footpath": {
+ "tiling": True,
+ "style_prompt": (
+ "Cartoony hand-painted fantasy footpaths. Warm cobblestone or "
+ "wooden plank textures. Bold outlines between stones/planks. "
+ "Medieval fantasy style path tiles. Keep exact shape and edges."
+ ),
+ "description_hint": "footpath or queue surface tile",
+ },
+ "ride": {
+ "tiling": False,
+ "style_prompt": (
+ "Cartoony hand-painted fantasy ride vehicle. Bold outlines, bright "
+ "saturated colors, warm lighting. Keep exact silhouette and proportions. "
+ "Think whimsical theme park ride in fantasy art style."
+ ),
+ "description_hint": "ride vehicle or track piece sprite",
+ },
+}