From 8838161729d55804fd55bcd57229dadbd0f73579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jim=20Liu=20=E5=AE=9D=E7=8E=89?= Date: Mon, 25 May 2026 00:18:32 -0500 Subject: [PATCH] docs(baoyu-cover-image): redirect codex-imagegen invocation through baoyu-image-gen --provider codex-cli Replace the long inline `scripts/codex-imagegen.sh` invocation block in SKILL.md with a pointer to references/codex-imagegen.md. The reference documents the preferred `baoyu-image-gen --provider codex-cli` path and keeps the direct-wrapper fallback for runtimes without baoyu-image-gen. --- skills/baoyu-cover-image/SKILL.md | 18 +---- .../references/codex-imagegen.md | 65 +++++++++++++++++++ 2 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 skills/baoyu-cover-image/references/codex-imagegen.md diff --git a/skills/baoyu-cover-image/SKILL.md b/skills/baoyu-cover-image/SKILL.md index 1d18aea..c116141 100644 --- a/skills/baoyu-cover-image/SKILL.md +++ b/skills/baoyu-cover-image/SKILL.md @@ -1,7 +1,7 @@ --- name: baoyu-cover-image description: Generates article cover images with 5 dimensions (type, palette, rendering, text, mood) combining 11 color palettes and 7 rendering styles. Supports cinematic (2.35:1), widescreen (16:9), and square (1:1) aspects. Use when user asks to "generate cover image", "create article cover", or "make cover". -version: 1.117.4 +version: 1.117.5 metadata: openclaw: homepage: https://github.com/JimLiu/baoyu-skills#baoyu-cover-image @@ -29,19 +29,7 @@ When this skill needs to render an image, resolve the backend in this order: 2. **Saved preference** — if `EXTEND.md` sets `preferred_image_backend` to a backend available right now, use it. 3. **Auto-select** (when the preference is `auto`, unset, or the pinned backend isn't available): - **Codex (`imagegen`)** — first, inspect your available-skills / tool inventory. If a skill named `imagegen` is listed, you are running inside Codex and MUST use it: invoke via the `Skill` tool with `skill: "imagegen"`, passing the saved prompt file's content (plus output path and aspect ratio per Codex `imagegen`'s own args). Codex `imagegen` is the official raster backend in that runtime and outranks any non-native skill (e.g., `baoyu-image-gen`) unless the user has explicitly pinned a different `preferred_image_backend`. - - **Codex via `codex exec` (`codex-imagegen`)** — if the current runtime does NOT expose a native `imagegen` skill but the `codex` CLI is on `PATH` and `codex login` is active (e.g., Claude Code with Codex CLI installed), invoke the `codex-imagegen` wrapper. **Path resolution**: `scripts/codex-imagegen.sh` lives at the plugin/repo root, NOT relative to your shell cwd. From this `SKILL.md`'s base directory, the wrapper is at `../../scripts/codex-imagegen.sh` — resolve to an absolute path before invoking. Command shape: - ```bash - /scripts/codex-imagegen.sh \ - --image \ - --prompt-file \ - --aspect \ - [--ref ]... \ - [--timeout ] \ - [--cache-dir ~/.cache/baoyu-codex-imagegen] \ - [--log-file ] - ``` - `--timeout` defaults to 300000 (5 min) per codex exec attempt; raise it (e.g. `--timeout 600000` for 10 min) on slow networks or large prompts. - All input paths to the wrapper are auto-resolved against the wrapper's `process.cwd()` if you pass relative ones, but agents should pass absolute paths to be robust against cwd drift. Parse the single-line JSON on stdout. On `{"status":"ok",...}` proceed to Step 5. On `{"status":"error","error_kind":...}` report the `error_kind` to the user and (if retryable) ask whether to retry or fall back to another backend. The wrapper uses the user's Codex subscription — no `OPENAI_API_KEY` needed. + - **Codex via `codex exec` (`codex-imagegen`)** — if the current runtime exposes no native `imagegen` skill but the `codex` CLI is on `PATH` with an active `codex login`, route through `baoyu-image-gen --provider codex-cli` (preferred), or — if baoyu-image-gen is unavailable — invoke the bundled wrapper directly. Details, parameters, and the runtime-discovery procedure live in [references/codex-imagegen.md](references/codex-imagegen.md) — load that file only when this branch is selected. - **Other runtime-native tools** — if the runtime exposes a different native image tool (e.g., Hermes `image_generate`), use it the same way. - Otherwise, if exactly one non-native backend is installed (e.g., `baoyu-image-gen`), use it. - Otherwise (multiple non-native backends with no runtime-native tool), ask the user once — batch with any other initial questions. @@ -228,7 +216,7 @@ Save to `prompts/cover.md`. Template: [references/workflow/prompt-template.md](r - `direct` usage → pass via `--ref` (use ref-capable backend) - `style`/`palette` → extract traits, append to prompt 5. **Generate**: Call the chosen backend with the prompt file, output path, aspect ratio. - - **`codex-imagegen`**: invoke `/scripts/codex-imagegen.sh` (NOT a cwd-relative `./scripts/...` — resolve the absolute path from this skill's base directory: `../../scripts/codex-imagegen.sh`) with `--image ` `--prompt-file ` `--aspect ` (add `--ref ` per reference, `--cache-dir ~/.cache/baoyu-codex-imagegen` to enable the idempotency cache, `--timeout ` to override the default 300000 / 5-min per-attempt limit on slow networks). All input paths to the wrapper are auto-resolved against its `process.cwd()` if relative, but passing absolutes is more robust. Read the stdout JSON; act on `status` and `error_kind`. + - **`codex-imagegen`**: see [references/codex-imagegen.md](references/codex-imagegen.md) for the invocation contract (preferred `baoyu-image-gen --provider codex-cli` path, runtime wrapper discovery, parameter notes, stdout schema, batch semantics). - **Codex `imagegen` (native)** or other runtime-native tools / `baoyu-image-gen` skill: per the rule in `## Image Generation Tools` above. 6. On failure: auto-retry once diff --git a/skills/baoyu-cover-image/references/codex-imagegen.md b/skills/baoyu-cover-image/references/codex-imagegen.md new file mode 100644 index 0000000..757a417 --- /dev/null +++ b/skills/baoyu-cover-image/references/codex-imagegen.md @@ -0,0 +1,65 @@ +# `codex-imagegen` Wrapper Invocation + +Load this reference only when the [Image Generation Tools](../SKILL.md#image-generation-tools) rule has resolved to `codex-imagegen` — i.e., the current runtime exposes no native `imagegen` skill but `codex` CLI is on `PATH` with an active `codex login`. + +## Preferred path: route through `baoyu-image-gen` + +If the `baoyu-image-gen` skill is available in this runtime, **always** invoke through it rather than calling the wrapper directly. It handles retry/cache/batch/EXTEND.md preferences uniformly with every other provider. + +```bash +${BUN_X} /scripts/main.ts \ + --provider codex-cli \ + --image \ + --promptfiles \ + --ar \ + [--ref ]... +``` + +Resolve `` the same way you resolve any sibling skill — through your runtime's skill registry (`Skill` tool, plugin marketplace, or `$HOME/.baoyu-skills/baoyu-image-gen/`). + +## Fallback: spawn the wrapper directly + +Only when `baoyu-image-gen` is NOT installed in the current runtime. Discover the wrapper's location at runtime — do NOT hard-code `../../packages/...` from this skill: + +1. **Honor explicit override**: if `$BAOYU_CODEX_IMAGEGEN_BIN` is set and points to a real file, use that path. It may be `.ts` (spawn `bun `) or `.sh`/binary (spawn directly). +2. **Search the plugin root**: walk up from this skill's directory looking for `packages/baoyu-codex-imagegen/src/main.ts`. If found, that is the wrapper. Spawn it with `bun`. +3. **Last resort**: tell the user that `codex-imagegen` is not available in this runtime and ask whether to install the `baoyu-skills` plugin (or set `BAOYU_CODEX_IMAGEGEN_BIN`) or pick another backend. + +Once located, the invocation shape is: + +```bash +bun /main.ts \ + --image \ + --prompt-file \ + --aspect \ + [--ref ]... \ + [--timeout ] \ + [--cache-dir ~/.cache/baoyu-codex-imagegen] \ + [--log-file ] +``` + +If `bun` is missing, `npx -y bun /main.ts ...` works as a fallback. + +## Parameter notes + +- **All filesystem inputs** are auto-resolved against `process.cwd()` when relative, but agents should pass absolute paths to be robust against cwd drift. +- **`--timeout`** defaults to `300000` (5 min) per `codex exec` attempt. Raise (e.g. `--timeout 600000` for 10 min) on slow networks or large prompts. +- **`--cache-dir`** is off by default. Enable for repeatable runs to skip redundant generations of the same prompt+aspect+refs. +- **Authentication**: the wrapper uses the user's Codex subscription — no `OPENAI_API_KEY` is read or sent. + +## Stdout contract + +Single JSON line: + +- Success: `{"status":"ok","path":"...","bytes":N,"elapsed_seconds":N,"thread_id":"...","attempts":N,"cached":bool,...}` +- Failure: `{"status":"error","path":"...","bytes":0,"error":"...","error_kind":"..."}` + +`error_kind` values: `codex_not_installed`, `invalid_args`, `prompt_file_missing`, `spawn_failed`, `timeout`, `no_image_gen_tool_use`, `output_missing`, `invalid_png`, `agent_refused`, `lock_busy`. + +On retryable errors (timeout, spawn_failed, no_image_gen_tool_use, output_missing, invalid_png, agent_refused), ask the user whether to retry or fall back to another backend. + +## Batch semantics + +- Codex `image_gen` returns **one image per call** (`n=1` only). Multi-image jobs must dispatch one wrapper call per image. +- The wrapper does NOT accept a `--sessionId` flag. Chain/scene consistency must come from `--ref` reference images. +- `--size` and `--quality` are silently ignored — Codex picks pixel dimensions from `--aspect`.