Use this skill when the selected Cowart canvas shape is an AI 图片 holder created by the Cowart toolbar.
Preconditions
The Cowart service should be running for the user's active project, usually at:
http://127.0.0.1:43217
New holders are tldraw frame shapes with:
{
"type": "frame",
"meta": {
"cowartAiImageHolder": true
}
}
Older canvases may still contain legacy geo rectangle holders with the same
meta flag. Support both shapes.
Workflow
-
Read the selected shape from Cowart:
curl -s http://127.0.0.1:43217/api/selectionYou can also use the Cowart MCP
get_cowart_selectiontool if it is available. -
Continue only when exactly one selected shape has either:
isAiImageHolder: trueor:
meta.cowartAiImageHolder: trueIf not, ask the user to select an
AI 图片holder. -
Use the selected holder's
props.wandprops.has the size contract. The generated image should match the holder aspect ratio as closely as possible.If the holder
typeisframe, insert the generated image as a child of the frame:parentId: holder shape idx:0y:0rotation:0props.w,props.h: same as holder
This makes the generated image move with the frame.
If the holder is a legacy
georectangle, keep using the legacy placement contract: samex,y,rotation,parentId,props.w, andprops.has the holder. -
Generate the bitmap with the built-in
imagegenskill unless the user explicitly requests another image path. If the requested asset needs visible copy, labels, poster text, ad text, UI text, or typography, include that text directly in the image generation prompt and let the image model produce the final bitmap. Do not default to generating a text-free background and then adding text locally unless the user explicitly asks for local typography, deterministic text overlay, SVG/vector output, or another non-imagegen layout step.For project-bound output, copy the selected generated image from
$CODEX_HOME/generated_images/...into the selected page's asset folder:canvas/pages/<page-id-without-page-prefix>/assets/ -
Insert the generated image as a new tldraw image shape exactly over the holder:
type:imageparentId: holder id for frame holders, same as holder parent for legacy geo holdersx,y,rotation:0,0,0for frame holders, same as holder for legacy geo holdersprops.w,props.h: same as holderprops.assetId: the new image asset idmeta.cowartGeneratedForAiImageHolder: holder shape id
-
Do not delete the holder unless the user explicitly asks for replacement. Keeping the holder lets Codex identify the intended slot again later.
-
Save through Cowart's API or edit the page snapshot carefully:
curl -s http://127.0.0.1:43217/api/canvasPrefer page-local asset URLs in the image asset:
/page-assets/<page-id-without-page-prefix>/<filename> -
Refresh or let the browser hot-reload, then confirm the inserted shape id, holder id, final dimensions, and saved asset path.
Notes
- If the holder is a legacy rotated
georectangle, preserve the samerotationon the image. Forframeholders, the frame owns placement and the child image should stay unrotated inside it. - If the same holder already contains a generated image and the user says 替换 (replace), update or remove that generated shape instead of adding another copy.
- Never overwrite an existing asset file without an explicit replace request; use a timestamped filename.