chore: remove stale ralph files and tracked .DS_Store

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mike LiuandClaude Opus 4.6 committed 2026-03-03 21:05:24 +00:00
1 parent f9c6e394d9
commit 732e16ba13
4 files changed
-267

No files matched your search

-47
View File
@@ -1,47 +0,0 @@
# Ralph Loop Iteration
You are executing one story from a product requirements document. You are a fresh Claude instance with no memory of previous iterations — all context comes from the files below.
## Instructions
1. Read `prd.json` — find the first story with status `"pending"` or `"in_progress"`
2. Read `progress.txt` — learn what previous iterations tried and discovered
3. Read `guardrails.md` if it exists — avoid known pitfalls
4. Implement the story:
- Read the story's `description` carefully for specific files and steps
- Read relevant source code before making changes
- Make minimal, focused changes for this one story only
- Follow existing project conventions
5. Run the verification command specified in the story's `verify` field (or the top-level `verify` in prd.json if the story has none)
6. If verification passes:
- Update the story's `status` to `"passed"` in prd.json
- Commit all changes with message: `ralph: [story-id] [story-title]`
7. If verification fails:
- Do NOT update prd.json status — the external loop handles retry logic
- Append what you tried and what went wrong to `progress.txt`
- Be specific: include error messages, file paths, what you expected vs what happened
8. If you discover a pitfall that future iterations should avoid, append it to `guardrails.md`
## Rules
- **One story per iteration.** Do not work on multiple stories.
- **Do not modify other stories' status** in prd.json.
- **Commit only if verification passes.** No partial commits.
- **Always write to progress.txt** — on success (what worked) and failure (what went wrong). This is how future iterations learn.
- **Read before writing.** Understand existing code before changing it.
## Skill Override
You are a **lean executor**, not an interactive agent. Design, planning, and process
decisions have already been made. Do NOT invoke skills — they are for interactive sessions.
Specifically, do NOT:
- Invoke brainstorming (design is done — the story description IS the spec)
- Invoke TDD (the external loop handles verification — just run the verify command)
- Invoke writing-plans or executing-plans (the plan already exists as prd.json)
- Invoke gather-context or delegate to Codex MCP (just Read files directly)
- Invoke verification-before-completion (the external loop runs verify independently)
- Ask clarifying questions (you are non-interactive — use your best judgment)
You MAY follow project coding standards from CLAUDE.md/AGENTS.md — those are facts,
not process skills. You SHOULD follow existing test patterns if the story requires tests.
-20
View File
@@ -1,20 +0,0 @@
# Guardrails — reskin-pipeline
# Add pitfalls discovered during ralph loop iterations here.
# Format: ## Title, **Trigger/Do/Don't/Context**
## Import paths for scripts/reskin/ modules
**Trigger:** Tests or CLI scripts fail with ModuleNotFoundError
**Do:** Use sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) before imports
**Don't:** Assume scripts/reskin/ is on PYTHONPATH
**Context:** These scripts are not a proper Python package — they live under scripts/ in a C++ repo
## Playwright SharedArrayBuffer
**Trigger:** OpenRCT2 web fails to load in headless Chromium
**Do:** Launch with --enable-features=SharedArrayBuffer and serve with COOP/COEP headers
**Don't:** Use default Chromium launch — SharedArrayBuffer is gated behind cross-origin isolation
**Context:** serve-emscripten.py already sets the right headers. Playwright needs the browser args too.
## fal_client import
**Trigger:** generate_restyled.py imported in tests where fal_client may not be configured
**Do:** Handle fal_client import gracefully (set to None if ImportError)
**Don't:** Crash on import — non-API functions should be testable without FAL_KEY
-72
View File
@@ -1,72 +0,0 @@
{
"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": "passed",
"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": "passed",
"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": "passed",
"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": "passed",
"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 <dir> --output <path.png> [--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": "passed",
"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 <screenshot.png> [--reference <ref.png>] [--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 \"<prompt>\" -m gemini-3.1-pro-preview --include-directories <dir-containing-images> --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": "passed",
"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": "passed",
"retries": 0
}
]
}
-128
View File
@@ -1,128 +0,0 @@
# 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
Status: PASSED
--- Iteration 2 | story-2 | 2026-02-25 00:11:09 ---
Created scripts/reskin/batch_sprites.py adapted from ottd-reskin-pipeline/batch_env.py.
Key changes: removed NFO parsing, sprite ID extraction, subcategory batching.
Functions: load_sprites, create_batches, render_grid, render_grid_with_sprites, batch_sprites, main CLI.
Created scripts/reskin/test_batch_sprites.py with 6 tests — all pass.
Verification passed: pytest scripts/reskin/test_batch_sprites.py -v (6/6 passed).
Status: PASSED
Status: PASSED
--- Iteration 3 | story-3 | 2026-02-25 00:12:44 ---
Created scripts/reskin/generate_restyled.py adapted from ottd-reskin-pipeline/generate_restyled.py.
Key functions: load_descriptions, build_prompt, generate_with_fal, generate_all, main CLI.
Handles fal_client import gracefully (set to None if not installed).
Created scripts/reskin/test_generate_restyled.py with 4 tests — all pass.
Verification passed: pytest scripts/reskin/test_generate_restyled.py -v (4/4 passed).
Status: PASSED
Status: PASSED
--- Iteration 4 | story-4 | 2026-02-25 00:14:28 ---
Created scripts/reskin/parse_restyled.py adapted from ottd-reskin-pipeline/parse_and_replace.py.
Removed patch_sprite_sheets(), rebuild_grf(), save_png_small_idat(). Kept extract_sprites_from_grid(),
restore_alpha(), blend_tile_edges(), validate_sprite(). Added parse_restyled() main entry point.
Key change: returns (original_filename, ...) instead of (sprite_id, ...) since OpenRCT2 uses filenames.
Created scripts/reskin/test_parse_restyled.py with 7 tests — all pass.
Verification passed: pytest scripts/reskin/test_parse_restyled.py -v (7/7 passed).
Status: PASSED
Status: PASSED
--- Iteration 5 | story-5 | 2026-02-25 00:16:25 ---
Created scripts/reskin/reskin.py — orchestrator chaining batch -> generate -> parse.
Supports workspace mode (--workspace) and standalone mode (--sprites-dir).
Functions: resolve_dirs, resolve_style, resolve_tiling, resolve_description_hint, run_step, main CLI.
CLI args: --workspace|--sprites-dir, --style, --category, --tiling, --step, --through, --dry-run, --skip-existing, --list-categories.
Created scripts/reskin/test_reskin.py with 6 tests — all pass.
Verification passed: pytest scripts/reskin/test_reskin.py -v (6/6 passed) + --list-categories (6 categories).
Status: PASSED
Status: PASSED
--- Iteration 6 | story-6 | 2026-02-25 00:18:04 ---
Created scripts/reskin/screenshot_game.py — Playwright screenshot script for OpenRCT2 web.
Features: COOP/COEP server (reuses pattern from serve-emscripten.py), headless Chromium with
SharedArrayBuffer support, waits for canvas#canvas visible + #loadingWebassembly detached,
graceful error on missing serve dir.
CLI: --serve-dir, --output, --port, --wait-seconds.
Created scripts/reskin/test_screenshot_game.py with 2 tests:
- test_server_starts_and_stops: verifies COOP/COEP headers and content serving
- test_missing_serve_dir: verifies exit 1 with clear error message
Note: had to pip install playwright (browsers were pre-installed at /root/.cache/ms-playwright/).
Verification passed: pytest scripts/reskin/test_screenshot_game.py -v (2/2 passed).
Status: PASSED
Status: PASSED
--- Iteration 7 | story-7 | 2026-02-25 00:19:36 ---
Created scripts/reskin/judge_screenshot.py — Gemini CLI visual judge for game screenshots.
Features: build_prompt() for single/comparison modes with optional criteria,
parse_rating() extracts X/10 pattern, invoke_gemini() calls CLI with --include-directories,
judge() orchestrates prompt+invoke+parse, CLI with positional screenshot arg + --reference + --criteria.
Exits 0 if rating >= 5, exit 1 if < 5 or unparseable.
Created scripts/reskin/test_judge_screenshot.py with 8 tests:
- test_build_prompt_single_image, test_build_prompt_with_reference,
test_build_prompt_with_criteria, test_build_prompt_with_reference_and_criteria,
test_parse_rating_valid, test_parse_rating_missing,
test_parse_rating_ignores_out_of_range, test_parse_rating_picks_first_match
Verification passed: pytest scripts/reskin/test_judge_screenshot.py -v (8/8 passed).
Status: PASSED
Status: PASSED
--- Iteration 8 | story-8 | 2026-02-25 00:21:10 ---
Full test suite verification and CLI smoke test — all green.
- 35/35 tests passed across 7 test files (batch_sprites, generate_restyled, judge_screenshot, parse_restyled, reskin, screenshot_game)
- All 6 CLI scripts respond to --help without errors
- --list-categories shows 6 categories correctly
- No fixes needed — all prior stories left clean code.
Status: PASSED
Status: PASSED
--- FAL.ai Scale-Up Findings | 2026-02-25 ---
Scaled the reskin pipeline to process Electric Fields scenario walls (26 objects, 84 sprites)
and paths (8 objects, 468 sprites) through FAL.ai Gemini 3 Pro image edit API.
Pipeline execution:
- 36/36 FAL.ai batches succeeded (6 wall + 30 path)
- 552/552 sprites parsed and quantized to RCT2 palette
- 34 parkobj files rebuilt with correct sprite offsets
- End-to-end: batch → generate → parse → quantize → rebuild → deploy
Key findings:
1. Sprite offsets (x,y in sprites-full.json) are critical — defaulting to 0,0 causes
severe misalignment. Must export via `openrct2-cli sprite exportobject` and parse stdout.
2. Palette quantization is the primary blocker for AI-generated reskins. The ~176 usable
RCT2 palette colors cannot represent neon/cyberpunk effects (cyan, magenta, glow).
AI output gets crushed to dark muddy blocks during quantization.
3. g1.dat modification is risky: sprites >256px must be cropped, but cropping breaks the
sprite index alignment causing black/purple checkerboard artifacts in-game.
4. Mechanical palette remapping (index swap, no AI) works perfectly — proven with purple
grass tint across all 29294 g1.dat sprites.
5. Objects-only deployment (parkobjs without g1.dat changes) is safe and functional.
Recommended next steps:
- Option A: Palette-aware AI prompts ("use only these specific colors")
- Option B: Mechanical palette remap only (proven reliable, limited creative range)
- Option C: Hybrid — AI for shape/detail changes, then palette remap for color
--- COMPLETE: All stories processed ---