Files
Genarrative/.codex/skills/gpt-image-2-apimart/SKILL.md
高物 548db78ca7 Update Match3D/image-generation docs & code
Adds/updates documentation, assets and implementation for Match3D and puzzle image generation workflows. Key changes: decision logs and pitfalls updated to prefer VectorEngine Gemini for Match3D material sheets and to require edits (multipart) for 1:1 container reference images; guidance added for when to use APIMart vs VectorEngine. .env.example clarified APIMart/Responses config. Many new public assets and PPT visuals added. Code changes across frontend and backend: updated shared contracts, server-rs match3d/puzzle/image-generation handlers, VectorEngine/OpenAI image generation clients, and multiple React components/tests to handle UI/background/container image signing, edits workflow, and puzzle UI background resolution. Added src/services/puzzle-runtime/puzzleUiBackgroundSource.ts and related test updates. Includes notes about multipart HTTP/1.1 requirement and test/verification commands in docs.
2026-05-14 20:34:45 +08:00

106 lines
3.6 KiB
Markdown

---
name: gpt-image-2-apimart
description: Generate or inspect project image assets through this repository's VectorEngine gpt-image-2 workflow. Use when Codex needs to create puzzle template sample images, reproduce the server-rs gpt-image-2 request body, dry-run image prompts, batch-generate local project thumbnails, or debug VECTOR_ENGINE_BASE_URL / VECTOR_ENGINE_API_KEY image-generation configuration without exposing secrets. The directory name is historical.
---
# gpt-image-2 VectorEngine
Use this skill for project-local image asset generation that must match the repository's `server-rs` VectorEngine `gpt-image-2-all` path. The folder still contains `apimart` in its name for compatibility with existing local plugin references.
## Workflow
1. Read the local task and decide whether the image is project-bound.
2. Prefer `scripts/generate-template-samples.mjs` for puzzle template thumbnails or small batches.
3. Run dry-run first:
```powershell
node .codex/skills/gpt-image-2-apimart/scripts/generate-template-samples.mjs --dry-run
```
4. If dry-run looks correct and the user asked for real assets, run live generation with a small limit:
```powershell
node .codex/skills/gpt-image-2-apimart/scripts/generate-template-samples.mjs --live --limit 6
```
5. Save final project assets under `public/` or another explicitly requested workspace path.
6. Never print `VECTOR_ENGINE_API_KEY`. Report only whether configuration exists.
## Request Contract
The repository image path uses:
```text
POST {VECTOR_ENGINE_BASE_URL}/v1/images/generations
Authorization: Bearer {VECTOR_ENGINE_API_KEY}
Content-Type: application/json
```
Default body:
```json
{
"model": "gpt-image-2-all",
"prompt": "<prompt>",
"n": 1,
"size": "1024x1024"
}
```
For weak visual references in text-to-image generation, add:
```json
{
"image": ["data:image/png;base64,..."]
}
```
For image-to-image work that must follow a reference image closely, use the VectorEngine edits endpoint instead of the generations `image` array:
```text
POST {VECTOR_ENGINE_BASE_URL}/v1/images/edits
Authorization: Bearer {VECTOR_ENGINE_API_KEY}
Content-Type: multipart/form-data
```
Multipart fields:
```text
model=gpt-image-2
prompt=<prompt>
n=1
size=1024x1024
image=@reference.png
```
Prefer edits for workflows where the reference image controls composition, pose, container shape, or layout. In this repository, Match3D container UI generation uses edits with `public/match3d-background-references/pot-fused-reference.png` as the `image` part.
Accept image output from `data[].url`, `data[].b64_json`, or direct nested `url` fields. VectorEngine GPT-image-2-all currently returns synchronously; do not poll APIMart task endpoints.
## Environment
Load environment values from process env first, then `.env.secrets.local`, `.env.local`, and `.env.example`.
Required for live generation:
- `VECTOR_ENGINE_BASE_URL`
- `VECTOR_ENGINE_API_KEY`
Optional:
- `VECTOR_ENGINE_IMAGE_REQUEST_TIMEOUT_MS`
If the key or base URL is missing, stop after dry-run or explain the missing configuration. Do not ask the user to paste the key in chat.
## Prompt Rules
- Use Chinese prompts when generating project puzzle templates.
- Keep template samples square, clear, image-only, and suitable for puzzle thumbnails.
- Avoid text, watermark, UI chrome, buttons, borders, and tutorial overlays.
- Include local negative constraints in the prompt instead of relying on provider-specific negative prompt fields.
## Resources
- `scripts/generate-template-samples.mjs`: dry-run or live-generate puzzle template sample thumbnails.
- `assets/puzzle-template-prompts.json`: default prompt list consumed by the script.