feat: add Codex CLI image generation bridge for non-Codex agents - #6
Closed
tznthou wants to merge 3 commits into
Closed
feat: add Codex CLI image generation bridge for non-Codex agents#6tznthou wants to merge 3 commits into
tznthou wants to merge 3 commits into
Conversation
Bridge script that calls Codex CLI's built-in image_gen (gpt-image-2) from any AI agent or CLI. Enables Claude Code and other non-Codex agents to use the same image generation pipeline. Features: - Reference image support (-i) for style matching - Output path control (-o) with auto directory creation - Size, quality, and background color options - 4-layer fallback for generated image path extraction - Soft timeout with heartbeat logging - Structured error classification - Full observability via multi-ai.log Verified end-to-end: image gen → chroma-key → frame split → QC → GIF using the existing generate2dsprite.py process pipeline.
Raw gpt-image-2 output, chroma-keyed transparent sheet, and animated GIF from the end-to-end call-codex-imagegen.sh pipeline test.
Foundation-only base map, 3x3 prop pack (raw + extracted), and layered preview from the end-to-end generate2dmap pipeline test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7
What
Adds
scripts/call-codex-imagegen.sh— a shell bridge that lets non-Codex agents (Claude Code, Cursor, etc.) call Codex CLI's built-inimage_gento generate images, then hand off to the existing postprocess scripts unchanged.Why
The skills currently require Codex's built-in
image_gen, making them Codex-only. This bridge takes a different approach from #2: instead of calling the OpenAI/Gemini API directly from Python, it wraps Codex CLI itself as the image generation backend. This means:image_genuses gpt-image-2, so generated images are identical to native Codex runs. No prompt adjustments needed.npm i -g @openai/codex), noopenaiorgoogle-genaiPython packages.generate2dsprite.py,extract_prop_pack.py, andcompose_layered_preview.pywork as-is.This is complementary to #2, not a replacement — #2 covers the "no Codex CLI" scenario (pure API), while this covers the "has Codex CLI but orchestrating from another agent" scenario.
How
Features
-i <file>reference image support (passes through tocodex exec -i)-o <path>output path with automkdir -p--size,--quality,--bgoptions--dry-runfor prompt inspection without API calls[codex-imagegen])Verified
End-to-end pipeline tested on macOS (Codex CLI 0.142.3):
call-codex-imagegen.sh→ gpt-image-2 generates 2×2 pixel art idle sprite (1024×1024, #FF00FF background)generate2dsprite.py process --rows 2 --cols 2 --shared-scale --component-mode largest→ chroma-key → frame extraction → QCedge_touch_frames: []Pipeline output
Step 1 — Raw gpt-image-2 output (via
call-codex-imagegen.sh):Step 2 — Chroma-keyed transparent sheet (via
generate2dsprite.py process):Step 3 — Animated GIF:
Map pipeline output (
generate2dmap)Also verified with the map pipeline — base map generation, 3×3 prop pack extraction (9/9 accepted, 0 rejected, 0 edge touch), and layered preview composition:
Relation to existing issues
image_gendoesn't write to the expected path.Backwards compatibility
requirements.txtunchanged.generate2dsprite.py,extract_prop_pack.py,compose_layered_preview.py, or eitherSKILL.md..gitignoreadditions (.venv/,test-output/,.claude/) are for development only.