{"success":true,"name":"codex-image-gen-i7","description":"Use when the user wants an AI image. Codex CLI on [PRIVATE_HOST].","category":"creative","path":"creative/codex-image-gen-i7/SKILL.md","file":"SKILL.md","content":"---\nname: codex-image-gen-i7\ndescription: \"Use when the user wants an AI image. Codex CLI on [PRIVATE_HOST].\"\nversion: 1.0.0\n---\n\n# AI images via Codex CLI on [PRIVATE_HOST]\n\nThe local Mac has no logged-in Codex. Host `[PRIVATE_HOST]` (ssh alias, user brimind) has `codex` at `~/.local/bin/codex`, logged in with ChatGPT, exposing the built-in `image_gen.imagegen` tool. Use it for photorealistic/illustrative AI images.\n\n## Where files go (always-on)\nThe user wants every agent-created file inside one owned folder per machine, and nothing agent-related elsewhere:\n- Mac: `[PATH]` (`images/`, `files/`, `scratch/`). Never use `~/Pictures`, `/tmp`, or the system temp dir. macOS `mktemp` without `-t` ignores TMPDIR, so use explicit paths in `scratch/`.\n- [PRIVATE_HOST]: `[PATH]` (`images/`, `files/`, `scratch/`). The older `[PATH]-images` on [PRIVATE_HOST] is legacy; do not write new output there.\n- Master notes live at `[PATH]`. After learning anything durable, update it, then `scp` it to `[PRIVATE_HOST]:[PATH]` so [PRIVATE_HOST] stays in sync (the user also uses [PRIVATE_HOST] directly or from another PC). If [PRIVATE_HOST] is unreachable, say so and sync next time.\n\n## Generate\nFirst check `ssh -o ConnectTimeout=8 -o BatchMode=yes [PRIVATE_HOST] true`; if unreachable, report it and offer code-drawn (SVG/HTML) images instead.\n```\nssh -o BatchMode=yes [PRIVATE_HOST] 'mkdir -p [PATH] && cd [PATH] && bash -lc '\\''codex exec --skip-git-repo-check --sandbox workspace-write -C [PATH] \"Use your image generation tool to create one <landscape|square|portrait> image: <PROMPT>. Save it as <name>.png in the current directory. Then print the absolute path and file size.\" </dev/null'\\'' 2>&1 | tail -15'\n```\nTimeout ~400s. Takes ~1 min.\n\n## Fetch and show\n```\nmkdir -p [PATH] && scp -q [PRIVATE_HOST]:[PATH]<name>.png [PATH]\n```\nDeliver with `MEDIA:[PATH]<name>.png`.\n\n## Batches / BRIMIND share-kit\n- Several images: one python driver on [PRIVATE_HOST] running `codex exec` per image, 2 in parallel ([PRIVATE_HOST] runs hot), started with `setsid nohup`; 8 images took ~9 min. Recipe: Mac `[PATH]`.\n- Share-kit art (api.brimind.pro/admin/share-kit) must match the LIVE AI Chat Prod ([PRIVATE_HOST] `[PATH]`): picker `curl [PRIVATE_HOST]/api/models/chat`, plans `/api/pricing/plans`, promo `/api/pricing/active-promotion`. Never print discounts/deadlines/hidden models (Fable) the API doesn't show.\n- Ask the image for an empty white rounded plate where the QR goes, then set `qrStyle:\"replace\"` (dark QR on white) — the default style paints white modules on a frosted plate. `plates.py` finds the plate and computes the placement; `install_vps.py` backs up and writes `config/affiliateMaterialImages.json` (global URL + qr) and `affiliateMaterials.json` (qrStyle, captions); both are read per request, no restart.\n- Share-kit style the owner wants: info-dense posters like his \"100% Tunisian\" flyer: headline block, a big central blank white QR plate with a neon border, 3 icon+label features on each side, a CTA pill, and a Tunisian night skyline. Six real facts per image, never one idea per image. Recipe: `gen_dense.py`.\n- Codex image quota: after ~10 images in a row it returns `429 Too Many Requests`. Run batches one at a time, retry the missing ones with a 3-minute pause (gen_dense.py does this), and expect about 5 minutes per image after a 429.\n- Brand assets for BRIMIND art (owner supplied): Mac `[PATH]` = [PRIVATE_HOST] `[PATH]` (brimind-logo, startup-label, clictopay). Pass them with `-i` after the prompt and Codex reproduces them faithfully. The owner wants every card to show the logo, the Startup Label + ClicToPay strip and an affiliate ribbon, with a different view per product/niche (diorama, street photo, magazine cover, pricing table, before/after…). Recipe: `gen_varied.py` + `add_varied.py`.\n- Partner logos live in the same brand folder (`issat-sousse.png` = ISSAT Sousse, \"Official partner\"). Attach them only to cards that mention the partner.\n- Codex edits often fail to fix a one-character typo (BR1MIND stayed after an edit). Fix it with PIL instead: find the glyph's columns from a dark-pixel profile, paint background over the bad parts, then draw the right stroke in the sampled text colour. It takes seconds and leaves the rest of the image untouched.\n- When Codex is unavailable (usage-limit/quota error, not just a transient 429) and the ask is a bounded, well-defined swap on a flat-design asset — replace a row of logo pills, fix a typo, swap a phone number — skip retrying image-gen and redraw the region directly with PIL instead of waiting: locate the exact pixel box with numpy (`np.where` on a `>235,>235,>235` white mask per row/column finds a pill row's top/bottom/left/right fast), repaint it with the sampled surrounding background colour, then draw rounded-rect pills/text with `ImageDraw` + `ImageFont.truetype` (`/System/Library/Fonts/Supplemental/Arial Bold.ttf` on the Mac). This is pixel-perfect, instant, and uses none of the user's ChatGPT quota — the right default for any logo/text/number swap on an existing asset with a fixed layout, not just a last resort when Codex happens to be down.\n- Before trusting which real logos/brands belong on a member's asset, don't invent a plausible set — check what that member actually uses: their S3A workspace `inbox/` (files they sent in chat) and `content/ads/` (previously generated art) usually contain a real photo of their storefront/signage or prior ad with the true partner list; read it with vision before redrawing.\n- Swapping a circular badge/icon (not a row) with the member's real logo: the badge isn't at a known coordinate, so find it by sampling pixel colors along a horizontal and vertical line through its approximate centre (`im.getpixel`) to locate where the background colour changes to the badge's fill — that gives centre and radius fast without guessing a box. Then don't paste the whole shared logo file: it usually bundles the icon with a wordmark/Arabic text/mockup photo next to it, so crop to the icon's own content bounding box first (threshold to non-white with `ImageOps`/`.point()`, `.getbbox()`) before scaling it to fit the badge — pasting the untrimmed file drags in the neighbouring text.\n\n## Pitfalls\n- Editing an existing image: put the prompt BEFORE `-i <file>` (`codex exec ... \"<prompt>\" -i img.png`). `-i` takes several values, so a prompt placed after it is swallowed and codex exits with \"No prompt provided via stdin\".\n- Model names on BRIMIND art: the Hub's top tier is GPT 6.1 Sol + Claude Opus 5.5 (fast = GPT 6 Luna/Haiku 5.5, medium = GPT 5.6 Terra/Sonnet 5.5). The owner wants the GPT 6 tier named.\n- Plain `ssh [PRIVATE_HOST] codex` fails: codex is only on PATH in a login shell. Use `bash -lc` (not `-lic`, which warns about job control).\n- Without `</dev/null` codex exec waits on stdin (\"Reading additional input from stdin\").\n- Raw output also lands in `~/.codex/generated_images/<session>/` (Codex-owned, outside the Hermes folder; leave it alone); Codex copies it to the requested name.\n- Uses the user's ChatGPT quota; generate one image per request unless asked for more.\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}