Visual Prompting: Visual Grammar v0 + Serialization
Product North Star
Visual prompting is a composition language: layout (arrangement + whitespace) communicates intent, and explicit marks (circles/boxes/arrows/labels) disambiguate what to edit.
This doc proposes a minimal "visual grammar v0" and the first thin-slice implementation: emit a machine-readable visual_prompt.json from the desktop canvas, plus one new annotation primitive (red circle labels).
Visual Grammar v0 (Spec)
1) Layout Rules (implicit semantics)
- Side-by-side (2-up): "blend / combine A + B"
- In Brood today: multi-canvas +
Combinequick action (/blend) is the canonical behavior.
- In Brood today: multi-canvas +
- Vertical stack: "sequential states" (A -> B -> C)
- Interpretation: treat as a timeline; compare deltas; generate next state.
- Grid (2x2 / 3x3): "variants / compare"
- Interpretation: same prompt family; prefer describing differences over fusing.
- Whitespace separation: grouping boundary
- Interpretation: distinct groups are separate tasks unless a mark/label explicitly links them.
2) Annotation Primitives (explicit semantics)
- Box (existing): bounded edit region
- Default semantic: "edit only inside" (green box).
- Circle (new): attention / "fix this"
- Default semantic: red circle = fix this area.
- Arrow (v0 concept; not implemented yet): relationship / transfer / movement
- Default semantic: "move/replace from A to B" (tail = source, head = target).
- Text label (v0 concept; partially implemented via circle label): literal instruction string
- Always treated as verbatim instruction text.
3) Color Semantics (v0)
- Red circle: "fix this"
- Green box: "edit only inside"
- Yellow lasso: subject mask candidate / selection
4) Examples (mental model)
- Two product photos side-by-side + label "blend lighting + keep logo sharp" -> combine/blend behavior.
- Screenshot stack (3-up) + red circles on each -> "fix these issues in sequence".
- Green box around background + label "make background pure white" -> edit within region only.
Visual Prompt Serialization v0 (JSON)
File location
- Written to the current run directory as:
runDir/visual_prompt.json - Produced by the desktop app (
desktop/src/canvas_app.js).
Shape (current)
Top-level fields:
schema,schema_versionvisual_grammar_versionupdated_atrun_dircanvas: mode, DPR, canvas size, active image id, tool, view transforms, and multi-layout rectsimages: image ids + paths + dimensionsmarks: normalized mark list (per-mark metadata + image-space geometry)
Mark shape:
idtype:lasso_polygon|box|circlecolor: CSS RGBA stringlabel: optional string (literal instruction/label)target_image_idimage_space: geometry in image pixel coordinatescreated_at
Notes:
multi_rects_pxare in canvas device pixels (DPR-scaled), andmulti_view.offset_*are the pan offsets applied on top.- In v0, the annotate box mark is only serialized while it exists in the UI (it is cleared after sending/canceling). Persisted box history is a next step.
Smallest Shippable Implementation Plan
- Spec-first: keep this doc updated as the "contract" for how layout + marks map to meaning.
- Always-on serialization: write
visual_prompt.jsonon key state changes (run init, image import, tool interactions, marks created/edited/deleted, pan/zoom). - One new primitive: add red circle labels:
- Create via Shift + drag (Annotate tool)
- Render as overlay + label
- Edit label via a small panel
- Delete via panel or Delete/Backspace
- Next thin slice (recommended):
- Add a
Fixaction that targets the last/selected red circle:- Convert circle -> normalized region coords
- Compose edit prompt from circle label + region
- Call engine edit path end-to-end
- Add a