Extract the edit requirements from each screenshot.
Read visible 批注 labels, arrows, and nearby edit notes from the screenshot itself. Use the arrow tip or marked region to understand where each note applies.
Ignore editor chrome such as toolbars, blue selection outlines, resize handles, cursor icons, and unrelated neighboring images.
Choose the source image for generation.
Use the clean underlying image content visible in the provided screenshot as the visual base whenever possible.
If the screenshot is too cropped, obstructed, or low-resolution to serve as a good image base, ask the user for the original image export or a cleaner screenshot of that specific image.
Do not read the current Cowart canvas to discover edit intent. Use the screenshot for the requested changes. Cowart state may be read later only to place the generated result without covering existing content.
Generate and place the revised image beside the original.
Preferred: use the Cowart MCP generate_cowart_image tool with a beside
placement and editSourceFromAnchor: true. With that flag it performs true
image-to-image: it sends the anchor's existing image to the /images/edits
endpoint so the result preserves the original's subject/composition and only
applies the annotated changes (it falls back to text-to-image if the anchor has
no local image or edits are unsupported). It sizes to the anchor's aspect ratio
(no cropping), saves into the page-local assets folder, and places the result
next to the anchor without touching the original image or its annotations.
Anchor on the original image (not the AI 图片 frame) whenever possible, so
the source image is available for the edit.
{
"prompt": "<revised-image instructions from the annotations, with all annotation artifacts removed>",
"projectDir": "/absolute/path/to/user/codex-project",
"cowartUrl": "http://127.0.0.1:43217",
"anchorShapeId": "<original generated image id; prefer the image over the frame>",
"placement": "right",
"margin": 40,
"editSourceFromAnchor": true,
"altText": "Revised image generated from Cowart annotation screenshot",
"shapeMeta": { "cowartGeneratedFromAnnotationEdit": true }
}
The tool requires an image provider key in the local environment (usually
COWART_IMAGE_API_KEY; GAISC_API_KEY / OPENAI_API_KEY also work).
Anchor selection:
- If the user selected the original image or its
AI 图片 frame, use it as anchorShapeId.
- If the screenshot clearly maps to a unique image or
AI 图片 frame on the current page, use that as the anchor without asking the user to select it.
- If there are multiple screenshots/outputs and the matching anchors are not uniquely identifiable, ask the user to select each corresponding anchor or provide an explicit placement order.
- Place to the right by default; older revision outputs often live to the left, so prefer the right of the currently annotated source.
- If the source is inside an
AI 图片 frame, anchor on the frame so the new image is placed as a sibling beside it, never inside it.
Fallback (no provider configured, or generate_cowart_image is unavailable):
generate the bitmap with the built-in imagegen flow, save it with a
timestamped filename such as annotation-edit-20260620-153012.png (do not
overwrite the source), then insert it beside the anchor with the
insert_cowart_image tool using placement: "right", matchAnchor: true,
and fit: "cover" (non-destructive; do not crop or pad the bitmap locally).
Do not hand-write tldraw asset / shape records or fractional index keys
unless both tools are unavailable.
Either path must add a new image asset and a new image shape only. Never
update, remove, hide, reparent, or reorder the original image, the original
AI 图片 frame, or any annotation shapes.