@senad-d/drawme 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -17,6 +17,27 @@ All notable changes to this project are documented here. The format is based on
17
17
 
18
18
  ### Changed
19
19
 
20
+ - The visual review now runs as gated passes with visually verified fixes. When the active model can view
21
+ images, three focused passes — fit and sizing, element placement, connections — each answer explicit
22
+ questions on their own preview (per page for multi-page files), followed by a holistic pass covering
23
+ typography (every label read word for word), semantics, the diagram type's review checklist, and
24
+ regressions; a pass must be clean before the next one starts, and all passes before final export. Each
25
+ pass names the concrete rendered defects to hunt (overlapping or clipped labels, text struck through by
26
+ lines, floating or buried edge endpoints, asymmetric or off-center anchors, stacked edges, unreadable
27
+ full-diagram previews, …), findings go into a numbered ledger naming the affected cells and planned fix,
28
+ and every correction is judged by comparing the replacement preview against the previous image with an
29
+ explicit fixed / not fixed / regressed verdict — an XML edit alone never counts as a fix. `drawio_export`
30
+ replacement previews prompt that before/after comparison directly in the tool result. The automatic
31
+ correction limit rises from 5 to 8 retries to give the gated passes room to actually resolve findings.
32
+ The diagram-types reference gains a per-type `Review:` checklist for the holistic pass, and the XML
33
+ authoring reference a defect→fix recipe table (including edge-label offset positioning), so vision
34
+ findings map to concrete source edits. Multi-page files are now reviewed and finally exported page by
35
+ page (`pageIndex`), closing the gap where only page 1 of e.g. a multi-page C4 file was ever inspected.
36
+ `ExportResult` gains `replacedPreview`, true whenever a preview supersedes an earlier tracked one —
37
+ including a re-export over the same output path — so the replacement-preview verdict prompt no longer
38
+ misses same-name re-exports. Models that cannot view images skip the visual passes entirely and review
39
+ structurally, as before. The golden asset baseline was intentionally refreshed for these reference
40
+ changes.
20
41
  - `/drawme` now pre-loads its context: the command handler resolves the draw.io CLI itself and embeds the
21
42
  check result plus the diagram-types, XML-authoring, and (v30+) Mermaid references directly into the
22
43
  injected workflow message. The references remain editable Markdown files under `assets/references/`;
package/README.md CHANGED
@@ -36,7 +36,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
36
36
  </table>
37
37
 
38
38
  - **Natural-language authoring:** flowcharts, architecture, UML, BPMN, ERD, C4, network, ML — as native `.drawio`, or as Mermaid with automatic layout on v30+.
39
- - **Guided workflow:** CLI detection, planning, authoring, validation, a critique-first visual review across canvas/node/connector/semantic categories, and final export run end to end from a single `/drawme` — no approval pauses.
39
+ - **Guided workflow:** CLI detection, planning, authoring, validation, a gated multi-pass visual review (fit/sizing → element placement → connections → holistic confirmation), and final export run end to end from a single `/drawme` — no approval pauses.
40
40
  - **Deterministic validation:** a structural linter catches dangling edges, duplicate/reserved ids, malformed geometry, page/container overflow, inadequate margins, conservative readability defects, overlaps, and explicit edge-routing defects before you look at a pixel.
41
41
  - **Vision-aware previews:** successful PNG previews attach the actual image only when the active model can view images — the result text says which case applies — so text-only models get an honest structural-review path instead of a placeholder; each replacement removes the previous same-source preview file so only the latest remains on disk.
42
42
  - **Exact shapes, not guesses:** search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
@@ -69,7 +69,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
69
69
  This checkout implements the DrawMe core loop as a Pi extension:
70
70
 
71
71
  - Nine model-callable tools (`drawio_check`, `drawio_export`, `drawio_validate`, `drawio_fit_canvas`, `drawio_shapesearch`, `drawio_from_mermaid`, `drawio_layout`, `drawio_explain`, `drawio_open`) and three commands (`/drawme`, `/drawme-check`, `/drawme-export`).
72
- - A guided `/drawme` workflow that steers authoring, validation after every edit, a critique-first visual review, and autonomous final multi-format export.
72
+ - A guided `/drawme` workflow that steers authoring, validation after every edit, a gated multi-pass visual review, and autonomous final multi-format export.
73
73
  - Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
74
74
  - draw.io binary resolution across macOS/Linux/Windows/WSL, headless-Linux `xvfb-run` handling, and version-gated Mermaid conversion + ELK auto-layout (draw.io v30+).
75
75
  - Validation pipeline: golden asset-integrity check, TypeScript typecheck, ESLint, a custom format check, and unit + real-CLI integration tests.
@@ -139,7 +139,7 @@ pi --no-extensions -e .
139
139
 
140
140
  | Command | Description |
141
141
  | --- | --- |
142
- | `/drawme <description>` | Kick off authoring, per-edit validation, critique-first visual review, and autonomous final export. |
142
+ | `/drawme <description>` | Kick off authoring, per-edit validation, the gated multi-pass visual review, and autonomous final export. |
143
143
  | `/drawme-check` | Report whether the draw.io CLI is available, its version, and v30+ feature support. |
144
144
  | `/drawme-export <file> [png\|svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`. |
145
145
 
@@ -179,13 +179,13 @@ The extension factory in `src/index.ts` registers the tools and commands. Render
179
179
  2. **Plan** — pick the diagram type, relationships, finite canvas, and layout direction.
180
180
  3. **Author** — write editable uncompressed XML (or Mermaid on v30+), using exact searched shapes and optional ELK layout.
181
181
  4. **Validate after every edit** — fix all errors; fix each warning or record why it is reviewed and acceptable.
182
- 5. **Visual review, critique first** — export one holistic preview; the tool result states whether the image is attached. With the image, the model walks all four categories (canvas/composition, nodes/typography, connectors, semantics) and records findings or explicit pass reasons before editing. Without it, the model reviews structurally with validation and explanation instead of describing renders.
183
- 6. **Fix and confirm** — each finding becomes a targeted edit, validation, and a focused category preview; a final holistic preview confirms no regressions. Each successful preview removes the previous preview file, leaving only the current image.
184
- 7. **Bound corrections** — the initial critique and final confirmation do not count as retries; permit at most five targeted edit → validation → replacement-preview correction retries total, then request focused feedback or offer `drawio_open`.
182
+ 5. **Visual review in gated passes** — with the preview image attached (one preview per page for multi-page files), the model runs three focused passes, each answering explicit questions on its own preview: **fit and sizing** (does the diagram fit its page; does the canvas or an element need resizing), **element placement** (is every element positioned correctly; is there a visibly better arrangement), and **connections** (is every connection correct, cleanly routed, symmetric where the layout is symmetric, and anchored to the middle of the facing element side where possible). A fourth **holistic pass** reads every label word for word, checks contrast, semantics, and the diagram type's own review checklist, and re-checks the earlier passes for regressions. Concrete defects to hunt (overlapping or clipped text, labels struck through by lines, floating endpoints, edges through unrelated shapes, …) are spelled out per pass, and each finding lands in a numbered ledger naming the affected cells and planned fix. Without the image, the model reviews structurally with validation and explanation instead of describing renders.
183
+ 6. **Fix and verify before the next pass** — a pass's findings become targeted edits, validation, and a replacement preview; the new image is compared against the previous one and every addressed finding gets an explicit verdict (fixed / not fixed / regressed) — a fix counts only when the new render shows the defect gone, and the next pass starts only when the current one is clean. Each successful preview removes the previous preview file, leaving only the current image.
184
+ 7. **Bound corrections** — pass inspection previews do not count as retries; permit at most eight targeted edit → validation → replacement-preview correction retries total. If a finding is still open at the limit, the run keeps the best validated state, finishes the remaining passes as inspection-only, continues to final export, and names the unresolved finding, its pass, and its last verdict in the report; `drawio_open` is offered afterwards for manual fine-tuning.
185
185
  8. **No human gate** — the run never pauses for approval or feedback; if the user interrupts with feedback, it is handled as new critique findings and the run continues.
186
- 9. **Final export** — immediately after the holistic confirmation, export requested embedded/editable formats, remove the one remaining latest review preview, and report deliverables (including any unresolved finding from the correction limit) plus cleanup warnings.
186
+ 9. **Final export** — immediately after the holistic confirmation, export requested embedded/editable formats (each page of a multi-page file separately), remove the one remaining latest review preview, and report deliverables (including any unresolved finding from the correction limit) plus cleanup warnings.
187
187
 
188
- Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, and conservative font/wrapping cases. Rendered clipping and wrapping, contrast, typography at full-diagram scale, visual balance, semantics, and draw.io's automatic connector routes can only be judged from the preview image, so they are critiqued when the active model can view images and reported as unverified when it cannot. A 2000px preview that makes labels unreadable requires a tighter/simpler layout, page splitting, or a focused re-export — it must never be accepted as-is.
188
+ Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, and conservative font/wrapping cases. Rendered clipping and wrapping, contrast, typography at full-diagram scale, visual balance, semantics, and draw.io's automatic connector routes can only be judged from the preview image, so they are critiqued when the active model can view images and reported as unverified when it cannot. Vision's job in the loop is to narrow every rendered defect down to specific cells (the authoring reference maps each defect to a source fix) and then to confirm from the replacement image that the defect is actually gone. A 2000px preview that makes labels unreadable requires a tighter/simpler layout, page splitting, or a focused re-export — it must never be accepted as-is.
189
189
 
190
190
  ## Bundled References and Assets
191
191
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  When the user requests a specific diagram type, apply the matching preset below for shapes, styles, and layout conventions. These presets focus on **structural** style keywords, such as ERD's `shape=table;childLayout=tableLayout`; adapt colors and typography to the user's requested visual style.
4
4
 
5
+ Each preset ends with a **Review:** line — the type-specific defects to hunt during the visual review's holistic pass, on top of the generic fit, placement, connection, and typography checks.
6
+
5
7
  Read this file when:
6
8
  - The user names one of these diagram types (ERD, UML class, sequence, C4, architecture, ML/DL model, flowchart, SysML, BPMN, network topology, cross-functional/swimlane)
7
9
  - You're choosing shape vocabulary or layout direction for a new diagram
@@ -18,6 +20,8 @@ For SQL DDL, derive tables, primary keys, foreign keys, and crow's-foot relation
18
20
  | FK relationship | Dashed edge: `dashed=1;endArrow=ERmandOne;startArrow=ERmandOne;` | Use ER notation arrows |
19
21
  | Layout | TB, tables spaced 300px apart | Group related tables vertically |
20
22
 
23
+ **Review:** every column row fully readable inside its table; relationship lines meet tables at row level on the sides, never through the title band; ER end markers visible at both ends and clear of the table border; PK/FK markers present; relationship lines don't cross tables they don't join.
24
+
21
25
  ## UML Class Diagram
22
26
 
23
27
  | Element | Style | Notes |
@@ -30,6 +34,8 @@ For SQL DDL, derive tables, primary keys, foreign keys, and crow's-foot relation
30
34
  | Aggregation | `endArrow=diamondThin;endFill=0;` | Hollow diamond |
31
35
  | Layout | TB, classes 250px apart | Interfaces above implementations |
32
36
 
37
+ **Review:** all three compartments visible with separators intact; attribute/method text left-aligned and unclipped; hollow inheritance triangles point at the parent; diamonds sit at the owning end; multiplicity labels clear of their lines and of each other.
38
+
33
39
  ## Sequence Diagram
34
40
 
35
41
  Prefer Mermaid conversion for a standard sequence diagram on draw.io 30+. Use the styles below for custom XML diagrams that require exact lifelines, activation bars, message placement, or interaction frames.
@@ -43,6 +49,8 @@ Prefer Mermaid conversion for a standard sequence diagram on draw.io 30+. Use th
43
49
  | Activation box | `shape=umlFrame;whiteSpace=wrap;` on the lifeline | Narrow rectangle on lifeline |
44
50
  | Layout | LR, lifelines spaced 200px apart | Time flows top to bottom |
45
51
 
52
+ **Review:** lifelines parallel, evenly spaced, and long enough for every message; messages horizontal with each label just above its own arrow, touching nothing; message order reads top→bottom as the described flow; activation boxes span exactly the messages they cover; returns dashed and grey.
53
+
46
54
  ## C4 Model (System Context / Container / Component)
47
55
 
48
56
  Use the styles below for C4 diagrams. A Mermaid C4 sketch works for a standard single view on draw.io 30+; use XML when exact C4 styling, multiple pages, or drill-down links are required:
@@ -60,6 +68,8 @@ Use the styles below for C4 diagrams. A Mermaid C4 sketch works for a standard s
60
68
  | Drill-down | wrap the element in `<UserObject link="data:page/id,<pageId>">` | Click jumps to the child page in draw.io / viewer |
61
69
  | Layout | TB, one `<diagram>` page per level | Export a single page with `--page-index <n>` (1-based) |
62
70
 
71
+ **Review:** every element shows its full three-line label inside the shape; relationship labels readable on their white background and clear of other lines; person shapes unclipped; one consistent color per C4 level; external systems visibly grey.
72
+
63
73
  ## Architecture Diagram
64
74
 
65
75
  | Element | Style | Notes |
@@ -72,6 +82,8 @@ Use the styles below for C4 diagrams. A Mermaid C4 sketch works for a standard s
72
82
  | External | `rounded=1;dashed=1;fillColor=#f5f5f5;strokeColor=#666666;` | Dashed border for external systems |
73
83
  | Layout | TB or LR by tier count; ≥4 tiers → TB | Hub nodes centered |
74
84
 
85
+ **Review:** every child fully inside its tier container with padding on all sides; tier titles not overlapped by children or edges; hub/bus nodes reachable with short direct edges; no edge passes through an unrelated service; colors match the legend.
86
+
75
87
  ## ML / Deep Learning Model Diagram
76
88
 
77
89
  For neural network architecture diagrams — ideal for papers targeting NeurIPS, ICML, ICLR.
@@ -91,6 +103,8 @@ For neural network architecture diagrams — ideal for papers targeting NeurIPS,
91
103
 
92
104
  **Tensor shape convention:** annotate each layer with input/output tensor dimensions in `(B, C, H, W)` or `(B, T, D)` format. Place dimensions as the second line of the label using `&#xa;`.
93
105
 
106
+ **Review:** layer blocks aligned on the flow axis; both label lines (name + tensor shape) readable in every block; skip connections curve clear of blocks and labels; encoder/decoder swimlanes don't clip their children; colors follow the layer-type mapping.
107
+
94
108
  ## SysML (Block Definition / Internal Block / Requirement / Parametric)
95
109
 
96
110
  draw.io ships a native SysML 1.x shape library (`mxgraph.sysml.*`, ~60 shapes). Call `drawio_shapesearch` with `sysml <keyword>` for any element not listed below. Stereotype labels use guillemets as the first label line: `&#171;block&#187;` (HTML entities for « »). SysML behavioral diagrams (activity, state machine, use case, sequence) reuse the UML presets above; search for `sysml activity` or `sysml state` for notation-specific variants.
@@ -137,6 +151,8 @@ draw.io ships a native SysML 1.x shape library (`mxgraph.sysml.*`, ~60 shapes).
137
151
  | Value property | `rounded=0;whiteSpace=wrap;html=1;` | Label `name : Type` |
138
152
  | Layout | LR, value properties on the outside, constraints centered | |
139
153
 
154
+ **Review (all SysML views):** guillemets render as « » (not raw `&#171;`); stereotype line visible on every element; compartment text unclipped; connector end symbols (diamonds, hollow triangles, crosshair circle) fully visible at the correct end; ports pinned on borders without overlapping labels; dashed dependency labels (`«satisfy»`, `«verify»`, …) clear of their lines.
155
+
140
156
  ## BPMN (Business Process)
141
157
 
142
158
  draw.io ships ~200 native BPMN 2.0 shapes (`mxgraph.bpmn.*`). The official styles carry a long `points=[...]` connection-point list — call `drawio_shapesearch` with `bpmn <element>` for the full string; the styles below omit it for brevity and still render correctly.
@@ -158,6 +174,8 @@ draw.io ships ~200 native BPMN 2.0 shapes (`mxgraph.bpmn.*`). The official style
158
174
  | Annotation | `html=1;shape=mxgraph.flowchart.annotation_2;align=left;labelPosition=right;` | Open bracket + dashed line |
159
175
  | Layout | LR inside lanes, events/gateways vertically centered on the flow line | Sequence flows never cross pool borders; message flows never stay inside one |
160
176
 
177
+ **Review:** event and gateway labels sit below their symbols without touching lanes or flows; every gateway branch labeled; sequence flows stay inside their pool and message flows only run between pools; lane titles readable; the flow line runs through the vertical center of events and gateways.
178
+
161
179
  ## Network Topology
162
180
 
163
181
  Generic vocabulary is the `mxgraph.networks` library — one shared style prefix, per-element `shape=`. For **vendor-specific** icons (Cisco `mxgraph.cisco19`/`cisco_safe`, rack `mxgraph.rack`, cloud vendors), call `drawio_shapesearch` with specific vendor and device keywords.
@@ -180,6 +198,8 @@ Shared prefix (every node below): `fontColor=#0066CC;verticalAlign=top;verticalL
180
198
  | Logical/VPN link | `html=1;endArrow=none;dashed=1;` | Dashed |
181
199
  | Layout | TB by tier: Internet → edge (router/firewall) → distribution (switch/LB) → servers/clients | Group each subnet in a zone container; label links with CIDR/port |
182
200
 
201
+ **Review:** device labels below their icons, fully readable, and clear of links; every zone container fully encloses its devices with padding; link labels (interface/VLAN/CIDR) beside the line, never on it; tiers read top→bottom; no link passes through a device it doesn't terminate at.
202
+
183
203
  ## Cross-Functional Flowchart (Swimlane)
184
204
 
185
205
  A flowchart split by **who does what** — one lane per role/department. Node vocabulary reuses the Flowchart preset below; only the container skeleton differs.
@@ -192,6 +212,8 @@ A flowchart split by **who does what** — one lane per role/department. Node vo
192
212
  | Handoff edge | `edgeStyle=orthogonalEdgeStyle;html=1;rounded=1;` | Edges crossing lanes are the handoffs — the diagram's point |
193
213
  | Layout | LR flow inside horizontal lanes; time flows left → right | Keep each step inside its actor's lane; ≥160px horizontal spacing |
194
214
 
215
+ **Review:** every step fully inside its own lane; lane titles readable and unobstructed; handoff edges cross lane borders cleanly instead of running along them; the flow reads left→right without backtracking; decision branches labeled.
216
+
195
217
  ## Flowchart (enhanced)
196
218
 
197
219
  | Element | Style | Notes |
@@ -203,3 +225,5 @@ A flowchart split by **who does what** — one lane per role/department. Node vo
203
225
  | Subprocess | `rounded=0;whiteSpace=wrap;html=1;fillColor=#e1d5e7;strokeColor=#9673a6;` + double border | Purple |
204
226
  | Yes/No labels | `value="Yes"` / `value="No"` on decision edges | Always label decision branches |
205
227
  | Layout | TB, 200px vertical gap | Decisions branch LR, merge back to center |
228
+
229
+ **Review:** flow reads top→bottom without backtracking; every decision has labeled Yes/No branches leaving different sides, with each label beside its own line; merge-back edges route around nodes through free corridors; start and end shapes visually distinct from process steps.
@@ -13,7 +13,7 @@ Read this when something looks wrong in the output (rendering, export, layout, e
13
13
  | Overlapping shapes | Scale spacing with complexity (200–350px) and leave routing corridors; move elements apart and run `drawio_fit_canvas` so the page grows around the content — never shrink elements to fit the page |
14
14
  | Edges crossing through shapes | Add waypoints, distribute entry/exit points, or increase spacing |
15
15
  | Arrowhead overlaps bend | Final edge segment before target must be ≥20px — increase spacing or add waypoints |
16
- | Automatic correction loop reaches its limit | The initial critique pass and the final holistic confirmation do not consume retries. Allow at most **5 correction retries total**; each retry is one targeted source edit → `drawio_validate` → replacement preview cycle. If a finding remains at the limit, stop editing, keep the best validated state, continue to final export, and name the unresolved finding and its category in the final report — never loop or wait for input. |
16
+ | Automatic correction loop reaches its limit | Pass inspection previews (the first preview of each review pass) do not consume retries. Allow at most **8 correction retries total**; each retry is one targeted source edit → `drawio_validate` → replacement preview cycle. If a finding remains at the limit, stop editing, keep the best validated state, finish the remaining passes as inspection-only, continue to final export, and name the unresolved finding and its pass in the final report — never loop or wait for input. |
17
17
  | `command not found: draw.io` after `brew install --cask drawio` | Homebrew installs the binary as `drawio` (no dot). Use `drawio --version`, not `draw.io --version`. The dot-name only exists inside the `.app` bundle (`/Applications/draw.io.app/Contents/MacOS/draw.io`) and on Windows (`draw.io.exe`). |
18
18
  | Export command not found on macOS | Try full path `/Applications/draw.io.app/Contents/MacOS/draw.io` |
19
19
  | Vision reports that the preview dimensions are too large | Re-export with `drawio_export` in preview mode and set a smaller `width`. If a 2000px full-diagram preview makes labels unreadable, tighten the canvas, simplify or split the layout, or use a focused review artifact. |
@@ -48,6 +48,34 @@ Background for manual sizing (what the fit computes): visible top-level vertex/c
48
48
  - Prefer two or three concise lines. If a label remains long, enlarge the node, shorten the wording without changing meaning, or split details into a note/legend. Never reduce important body text merely to fit existing geometry.
49
49
  - A 2000px full-diagram preview scales the entire page. If labels become unreadable at that width, simplify the layout, tighten the canvas, split the diagram into pages, or use a focused review export; never accept an unreadable full view as passing typography.
50
50
 
51
+ ### Fix recipes: visual defect → source edit
52
+
53
+ When the preview critique narrows a finding down to specific cells, apply the matching recipe — then validate, re-export, and confirm the defect is gone in the new image:
54
+
55
+ | Visual defect (seen in the preview) | Fix |
56
+ |-------------------------------------|-----|
57
+ | Two shapes (or their labels) touch or overlap | Move the shapes apart per the spacing table, then `drawio_fit_canvas` — never shrink content |
58
+ | Label text touches or crosses its own shape border | Enlarge the node per the sizing formulas above, add `spacing=10;`, or insert `&#xa;` breaks |
59
+ | Label text clipped / cut off mid-word | Same as above — the node is too small for the rendered lines |
60
+ | Edge label struck through by its own line, or hugging it | Lift the label off the line with an offset in the edge's label geometry (example below) and add `labelBackgroundColor=#ffffff;` |
61
+ | Edge label overlaps another edge, label, or shape | Slide it along the edge (geometry `x` between `-1` and `1`) toward a clear stretch, plus the offset/background above |
62
+ | Any text with a line running underneath it | Reroute the edge around the text with waypoints, or move the label — text over lines is never acceptable |
63
+ | Arrowhead buried in a bend or hidden by a shape | Keep the final segment before the target ≥20px: move the last waypoint or increase spacing |
64
+ | Edge passes through a shape it does not connect | Add waypoints around it, or move the shape out of the routing corridor |
65
+ | Two edges stacked on the same path | Spread their entry/exit points (see the distribution table below) |
66
+ | Icon shape's label overlaps the icon artwork | Move the label outside: `verticalLabelPosition=bottom;verticalAlign=top;labelBackgroundColor=#ffffff;` |
67
+ | Content touching a page edge, uneven margins, or big empty areas | Re-space the elements if needed, then run `drawio_fit_canvas` |
68
+
69
+ **Positioning an edge label** — the edge's own label is placed by its geometry: `x` runs along the edge from `-1` (source) through `0` (center) to `1` (target), and an `<mxPoint as="offset">` shifts it in page pixels (negative `y` = up):
70
+
71
+ ```xml
72
+ <mxCell id="e2" value="HTTP/REST" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;labelBackgroundColor=#ffffff;" edge="1" parent="1" source="2" target="3">
73
+ <mxGeometry x="-0.25" relative="1" as="geometry">
74
+ <mxPoint as="offset" x="0" y="-12" />
75
+ </mxGeometry>
76
+ </mxCell>
77
+ ```
78
+
51
79
  ### Shape types (vertex)
52
80
 
53
81
  | Style keyword | Use for |
package/docs/reference.md CHANGED
@@ -30,7 +30,7 @@ Commands are user-facing shortcuts. Use the model-callable tools when you need e
30
30
 
31
31
  | Command | Functionality |
32
32
  | --- | --- |
33
- | `/drawme <description>` | Starts the full autonomous workflow: check, plan, author, validate, critique-first visual review, and final export — no human intervention once started. The command pre-resolves the draw.io CLI and embeds the diagram-types, XML-authoring, and (on v30+) Mermaid references into the injected message, so the run starts without tool calls or file reads; only the troubleshooting reference is read on demand. |
33
+ | `/drawme <description>` | Starts the full autonomous workflow: check, plan, author, validate, gated multi-pass visual review (fit/sizing → element placement → connections → holistic confirmation), and final export — no human intervention once started. The command pre-resolves the draw.io CLI and embeds the diagram-types, XML-authoring, and (on v30+) Mermaid references into the injected message, so the run starts without tool calls or file reads; only the troubleshooting reference is read on demand. |
34
34
  | `/drawme-check` | Displays the detected draw.io path and version, or reports that the CLI is unavailable. |
35
35
  | `/drawme-export <file> [png\|svg\|pdf\|jpg]` | Performs a final export of an existing `.drawio`; format defaults to PNG. |
36
36
 
@@ -110,7 +110,7 @@ Additional behavior:
110
110
  - An explicit `width` replaces raster scaling.
111
111
  - `scale` is ignored in preview mode and for vector formats.
112
112
  - `transparent` has no effect outside PNG.
113
- - Preview mode defaults to unembedded output suitable for visual inspection. When the current model can view images, a successful PNG preview tool result contains its normal text/metadata block followed by an `image/png` base64 image block; otherwise the image is omitted. The result text always states which case applies, and the output path in the text stays usable either way.
113
+ - Preview mode defaults to unembedded output suitable for visual inspection. When the current model can view images, a successful PNG preview tool result contains its normal text/metadata block followed by an `image/png` base64 image block; otherwise the image is omitted. The result text always states which case applies, and the output path in the text stays usable either way. A first preview asks for a critique against the current review pass's checklist; a preview that replaces an earlier one instead asks for a before/after comparison with a fixed / not fixed / regressed verdict per addressed finding.
114
114
  - Final exports stay text-only; final PNG, SVG, and PDF default to embedded/editable output.
115
115
  - JPG cannot carry editable XML; never set `embed: true` for JPG.
116
116
  - Embedded PNG exports are checked for draw.io's known truncated IEND chunk and repaired automatically when necessary.
@@ -0,0 +1,210 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <mxfile host="drawio" version="31.1.5">
3
+ <diagram id="drawme-validation-tree" name="Validation Decision Tree">
4
+ <mxGraphModel dx="2000" dy="2400" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" math="0" shadow="0" background="#F4F7FB" pageWidth="2050" pageHeight="2448">
5
+ <root>
6
+ <mxCell id="0"/>
7
+ <mxCell id="1" parent="0"/>
8
+
9
+ <mxCell id="title" value="DrawMe validation decision tree" style="text;html=1;align=left;verticalAlign=middle;fontSize=34;fontStyle=1;fontColor=#17365D;" vertex="1" parent="1">
10
+ <mxGeometry x="40" y="40" width="1180" height="50" as="geometry"/>
11
+ </mxCell>
12
+ <mxCell id="subtitle" value="How each source revision earns a quality export — or carries an explicit, bounded exception" style="text;html=1;align=left;verticalAlign=middle;fontSize=17;fontColor=#4F6475;" vertex="1" parent="1">
13
+ <mxGeometry x="40" y="92" width="1240" height="34" as="geometry"/>
14
+ </mxCell>
15
+ <mxCell id="badge" value="VALIDATE EVERY EDIT • 4 REVIEW PASSES • MAX 8 CORRECTION RETRIES" style="rounded=1;arcSize=22;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=10;fontSize=13;fontStyle=1;fontColor=#674274;fillColor=#F4ECF7;strokeColor=#9673A6;strokeWidth=2;" vertex="1" parent="1">
16
+ <mxGeometry x="1350" y="48" width="560" height="56" as="geometry"/>
17
+ </mxCell>
18
+
19
+ <mxCell id="revalidate-junction" value="&lt;b&gt;REVALIDATE&lt;/b&gt;&lt;br&gt;restart the gate" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=13;fontColor=#405466;fillColor=#FFFFFF;strokeColor=#6C8EBF;strokeWidth=2;dashed=1;" vertex="1" parent="1">
20
+ <mxGeometry x="1830" y="200" width="180" height="90" as="geometry"/>
21
+ </mxCell>
22
+
23
+ <mxCell id="phase-structural" value="1 DETERMINISTIC STRUCTURAL GATE" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1F4E78;fillColor=#D9EAF7;strokeColor=#6C8EBF;strokeWidth=2;" vertex="1" parent="1">
24
+ <mxGeometry x="760" y="155" width="420" height="42" as="geometry"/>
25
+ </mxCell>
26
+ <mxCell id="revision" value="&lt;b&gt;&lt;font color=&quot;#1F4E78&quot;&gt;SOURCE REVISION&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Author · edit · Mermaid conversion · layout · canvas fit" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=12;fontSize=16;fontColor=#263746;fillColor=#FFFFFF;strokeColor=#6C8EBF;strokeWidth=2;shadow=1;" vertex="1" parent="1">
27
+ <mxGeometry x="680" y="225" width="580" height="96" as="geometry"/>
28
+ </mxCell>
29
+ <mxCell id="validate" value="&lt;b&gt;Run drawio_validate immediately&lt;/b&gt;&lt;br&gt;Check XML, IDs, endpoints, geometry, bounds, margins,&lt;br&gt;containment, overlaps, routes, and conservative readability" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=12;fontSize=15;fontColor=#263746;fillColor=#EEF6FC;strokeColor=#1F4E78;strokeWidth=3;" vertex="1" parent="1">
30
+ <mxGeometry x="680" y="375" width="580" height="116" as="geometry"/>
31
+ </mxCell>
32
+ <mxCell id="errors" value="Any structural&lt;br&gt;&lt;b&gt;errors&lt;/b&gt;?" style="rhombus;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=17;fontColor=#8B2E2E;fillColor=#F8CECC;strokeColor=#B85450;strokeWidth=2;" vertex="1" parent="1">
33
+ <mxGeometry x="805" y="550" width="330" height="150" as="geometry"/>
34
+ </mxCell>
35
+ <mxCell id="fix-errors" value="&lt;b&gt;&lt;font color=&quot;#8B2E2E&quot;&gt;BLOCK PREVIEW&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Repair malformed XML, duplicate/reserved IDs,&lt;br&gt;broken parents, dangling edges, or geometry" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=20;spacingRight=18;fontSize=15;fontColor=#263746;fillColor=#FFF2F1;strokeColor=#B85450;strokeWidth=2;" vertex="1" parent="1">
36
+ <mxGeometry x="1370" y="570" width="470" height="112" as="geometry"/>
37
+ </mxCell>
38
+ <mxCell id="warnings" value="Any unresolved&lt;br&gt;&lt;b&gt;warnings&lt;/b&gt;?" style="rhombus;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=17;fontColor=#9A5B13;fillColor=#FFE6CC;strokeColor=#D79B00;strokeWidth=2;" vertex="1" parent="1">
39
+ <mxGeometry x="805" y="765" width="330" height="150" as="geometry"/>
40
+ </mxCell>
41
+ <mxCell id="resolve-warning" value="&lt;b&gt;&lt;font color=&quot;#9A5B13&quot;&gt;RESOLVE EACH WARNING&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;Fix&lt;/b&gt; it and revalidate, or &lt;b&gt;record&lt;/b&gt; why it is&lt;br&gt;reviewed and acceptable. Unreviewed warnings block export." style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=20;spacingRight=18;fontSize=15;fontColor=#263746;fillColor=#FFF8ED;strokeColor=#D79B00;strokeWidth=2;" vertex="1" parent="1">
42
+ <mxGeometry x="1370" y="775" width="470" height="130" as="geometry"/>
43
+ </mxCell>
44
+ <mxCell id="structural-pass" value="&lt;b&gt;&lt;font color=&quot;#2D5E36&quot;&gt;STRUCTURAL GATE PASSES&lt;/font&gt;&lt;/b&gt;&lt;br&gt;0 errors · warnings fixed or explicitly accepted" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=12;fontSize=16;fontColor=#263746;fillColor=#EAF4E8;strokeColor=#82B366;strokeWidth=2.5;" vertex="1" parent="1">
45
+ <mxGeometry x="680" y="990" width="580" height="92" as="geometry"/>
46
+ </mxCell>
47
+
48
+ <mxCell id="phase-rendered" value="2 RENDERED + SEMANTIC QUALITY GATE" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#674274;fillColor=#E1D5E7;strokeColor=#9673A6;strokeWidth=2;" vertex="1" parent="1">
49
+ <mxGeometry x="735" y="1140" width="470" height="42" as="geometry"/>
50
+ </mxCell>
51
+ <mxCell id="preview" value="&lt;b&gt;Export a focused PNG preview&lt;/b&gt;&lt;br&gt;One page at a time · width-capped for review · latest preview retained" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=12;fontSize=16;fontColor=#263746;fillColor=#F7F0FA;strokeColor=#9673A6;strokeWidth=2.5;" vertex="1" parent="1">
52
+ <mxGeometry x="680" y="1215" width="580" height="100" as="geometry"/>
53
+ </mxCell>
54
+ <mxCell id="image-attached" value="Preview image&lt;br&gt;&lt;b&gt;attached&lt;/b&gt;?" style="rhombus;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=17;fontColor=#674274;fillColor=#E1D5E7;strokeColor=#9673A6;strokeWidth=2;" vertex="1" parent="1">
55
+ <mxGeometry x="805" y="1375" width="330" height="150" as="geometry"/>
56
+ </mxCell>
57
+ <mxCell id="fallback-review" value="&lt;b&gt;&lt;font color=&quot;#1F4E78&quot;&gt;TEXT-ONLY FALLBACK&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Cross-check validation + drawio_explain&lt;br&gt;against the request. Keep the preview for the user;&lt;br&gt;report rendered inspection as skipped." style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=20;spacingRight=18;fontSize=15;fontColor=#263746;fillColor=#EEF6FC;strokeColor=#6C8EBF;strokeWidth=2;" vertex="1" parent="1">
58
+ <mxGeometry x="70" y="1380" width="500" height="140" as="geometry"/>
59
+ </mxCell>
60
+ <mxCell id="visual-passes" value="&lt;b&gt;&lt;font color=&quot;#674274&quot;&gt;RUN 4 GATED PASSES IN ORDER&lt;/font&gt;&lt;/b&gt;&lt;br&gt;1 Fit &amp;amp; sizing → 2 Element placement&lt;br&gt;3 Connections → 4 Typography, semantics &amp;amp; regression&lt;br&gt;&lt;font color=&quot;#6B7C8A&quot;&gt;Log each defect as F1, F2, … with affected cell IDs.&lt;/font&gt;" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=20;spacingRight=18;fontSize=15;fontColor=#263746;fillColor=#F7F0FA;strokeColor=#9673A6;strokeWidth=2;" vertex="1" parent="1">
61
+ <mxGeometry x="1370" y="1370" width="500" height="160" as="geometry"/>
62
+ </mxCell>
63
+ <mxCell id="finding" value="Any unresolved&lt;br&gt;quality &lt;b&gt;finding&lt;/b&gt;?" style="rhombus;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=17;fontColor=#674274;fillColor=#E1D5E7;strokeColor=#9673A6;strokeWidth=2;" vertex="1" parent="1">
64
+ <mxGeometry x="805" y="1615" width="330" height="150" as="geometry"/>
65
+ </mxCell>
66
+ <mxCell id="retry-limit" value="Correction retries&lt;br&gt;&lt;b&gt;used &amp;lt; 8&lt;/b&gt;?" style="rhombus;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=17;fontColor=#9A5B13;fillColor=#FFE6CC;strokeColor=#D79B00;strokeWidth=2;" vertex="1" parent="1">
67
+ <mxGeometry x="1460" y="1615" width="300" height="150" as="geometry"/>
68
+ </mxCell>
69
+ <mxCell id="correction-cycle" value="&lt;b&gt;&lt;font color=&quot;#674274&quot;&gt;ONE CORRECTION RETRY&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Targeted source edit → validate → replacement preview&lt;br&gt;Compare before/after: &lt;b&gt;fixed · not fixed · regressed&lt;/b&gt;&lt;br&gt;&lt;font color=&quot;#6B7C8A&quot;&gt;A source change alone never proves a visual fix.&lt;/font&gt;" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=20;spacingRight=18;fontSize=15;fontColor=#263746;fillColor=#F7F0FA;strokeColor=#9673A6;strokeWidth=2.5;" vertex="1" parent="1">
70
+ <mxGeometry x="1350" y="1835" width="520" height="155" as="geometry"/>
71
+ </mxCell>
72
+ <mxCell id="quality-pass" value="&lt;b&gt;&lt;font color=&quot;#2D5E36&quot;&gt;QUALITY GATES COMPLETE&lt;/font&gt;&lt;/b&gt;&lt;br&gt;All findings fixed or explicitly accepted" style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=12;fontSize=16;fontColor=#263746;fillColor=#EAF4E8;strokeColor=#82B366;strokeWidth=2.5;" vertex="1" parent="1">
73
+ <mxGeometry x="680" y="1845" width="580" height="100" as="geometry"/>
74
+ </mxCell>
75
+ <mxCell id="limit-reached" value="&lt;b&gt;&lt;font color=&quot;#9A5B13&quot;&gt;LIMIT REACHED&lt;/font&gt;&lt;/b&gt;&lt;br&gt;Stop automatic editing · keep the best validated state&lt;br&gt;Finish remaining passes inspection-only and report&lt;br&gt;each unresolved finding with its last verdict." style="rounded=1;arcSize=12;whiteSpace=wrap;html=1;align=left;verticalAlign=middle;spacingLeft=20;spacingRight=18;fontSize=15;fontColor=#263746;fillColor=#FFF8ED;strokeColor=#D79B00;strokeWidth=2.5;" vertex="1" parent="1">
76
+ <mxGeometry x="70" y="1835" width="500" height="155" as="geometry"/>
77
+ </mxCell>
78
+
79
+ <mxCell id="phase-delivery" value="3 AUTONOMOUS DELIVERY" style="rounded=1;arcSize=18;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#2D5E36;fillColor=#D5E8D4;strokeColor=#82B366;strokeWidth=2;" vertex="1" parent="1">
80
+ <mxGeometry x="800" y="2055" width="340" height="42" as="geometry"/>
81
+ </mxCell>
82
+ <mxCell id="final-export" value="&lt;b&gt;&lt;font color=&quot;#2D5E36&quot;&gt;FINAL EXPORT — NO APPROVAL PAUSE&lt;/font&gt;&lt;/b&gt;&lt;br&gt;PNG by default · SVG / PDF / JPG on request · editable XML embedded&lt;br&gt;Remove the latest preview and report outputs, accepted warnings,&lt;br&gt;unresolved findings, and cleanup warnings." style="rounded=1;arcSize=14;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=14;fontSize=16;fontColor=#263746;fillColor=#EAF4E8;strokeColor=#4E8A45;strokeWidth=3;shadow=1;" vertex="1" parent="1">
83
+ <mxGeometry x="640" y="2135" width="660" height="150" as="geometry"/>
84
+ </mxCell>
85
+
86
+ <mxCell id="footer" value="&lt;b&gt;Decision rule:&lt;/b&gt; errors block preview · unreviewed warnings block export · visual findings trigger bounded correction · the final report never hides an accepted or unresolved issue" style="rounded=1;arcSize=10;whiteSpace=wrap;html=1;align=center;verticalAlign=middle;spacing=10;fontSize=14;fontColor=#405466;fillColor=#FFFFFF;strokeColor=#AAB7C4;dashed=1;strokeWidth=1.5;" vertex="1" parent="1">
87
+ <mxGeometry x="160" y="2350" width="1620" height="58" as="geometry"/>
88
+ </mxCell>
89
+
90
+ <mxCell id="edge-revision-validate" value="every source edit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#1F4E78;strokeWidth=2.5;fontSize=12;fontColor=#405466;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="revision" target="validate">
91
+ <mxGeometry relative="1" as="geometry"/>
92
+ </mxCell>
93
+ <mxCell id="edge-validate-errors" value="lint result" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#1F4E78;strokeWidth=2.5;fontSize=12;fontColor=#405466;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="validate" target="errors">
94
+ <mxGeometry relative="1" as="geometry"/>
95
+ </mxCell>
96
+ <mxCell id="edge-errors-yes" value="YES" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#B85450;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#8B2E2E;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="errors" target="fix-errors">
97
+ <mxGeometry relative="1" as="geometry"/>
98
+ </mxCell>
99
+ <mxCell id="edge-errors-no" value="NO" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#2D5E36;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#2D5E36;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="errors" target="warnings">
100
+ <mxGeometry relative="1" as="geometry"/>
101
+ </mxCell>
102
+ <mxCell id="edge-fix-errors-loop" value="edit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#B85450;strokeWidth=2;dashed=1;dashPattern=8 4;fontSize=12;fontColor=#8B2E2E;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0.25;entryY=1;" edge="1" parent="1" source="fix-errors" target="revalidate-junction">
103
+ <mxGeometry relative="1" as="geometry">
104
+ <Array as="points">
105
+ <mxPoint x="1875" y="626"/>
106
+ <mxPoint x="1875" y="310"/>
107
+ </Array>
108
+ </mxGeometry>
109
+ </mxCell>
110
+ <mxCell id="edge-warnings-yes" value="YES" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#D79B00;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#9A5B13;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="warnings" target="resolve-warning">
111
+ <mxGeometry relative="1" as="geometry"/>
112
+ </mxCell>
113
+ <mxCell id="edge-warnings-no" value="NO" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#2D5E36;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#2D5E36;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="warnings" target="structural-pass">
114
+ <mxGeometry relative="1" as="geometry"/>
115
+ </mxCell>
116
+ <mxCell id="edge-warning-fix-loop" value="FIXED · source changed" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#D79B00;strokeWidth=2;dashed=1;dashPattern=8 4;fontSize=12;fontColor=#9A5B13;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.35;entryX=0.5;entryY=1;" edge="1" parent="1" source="resolve-warning" target="revalidate-junction">
117
+ <mxGeometry relative="1" as="geometry">
118
+ <Array as="points">
119
+ <mxPoint x="1920" y="820"/>
120
+ <mxPoint x="1920" y="310"/>
121
+ </Array>
122
+ </mxGeometry>
123
+ </mxCell>
124
+ <mxCell id="edge-warning-accepted" value="ACCEPTED · reason recorded" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#9A5B13;strokeWidth=2;fontSize=12;fontColor=#9A5B13;labelBackgroundColor=#F4F7FB;exitX=0;exitY=0.75;entryX=1;entryY=0.5;" edge="1" parent="1" source="resolve-warning" target="structural-pass">
125
+ <mxGeometry relative="1" as="geometry">
126
+ <Array as="points">
127
+ <mxPoint x="1330" y="872"/>
128
+ <mxPoint x="1330" y="1036"/>
129
+ </Array>
130
+ </mxGeometry>
131
+ </mxCell>
132
+ <mxCell id="edge-pass-preview" value="safe to render" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#674274;strokeWidth=2.5;fontSize=12;fontColor=#674274;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="structural-pass" target="preview">
133
+ <mxGeometry relative="1" as="geometry"/>
134
+ </mxCell>
135
+ <mxCell id="edge-preview-attached" value="tool reports attachment state" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#674274;strokeWidth=2.5;fontSize=12;fontColor=#674274;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="preview" target="image-attached">
136
+ <mxGeometry relative="1" as="geometry"/>
137
+ </mxCell>
138
+ <mxCell id="edge-image-no" value="NO" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#1F4E78;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#1F4E78;labelBackgroundColor=#F4F7FB;exitX=0;exitY=0.5;entryX=1;entryY=0.5;" edge="1" parent="1" source="image-attached" target="fallback-review">
139
+ <mxGeometry relative="1" as="geometry"/>
140
+ </mxCell>
141
+ <mxCell id="edge-image-yes" value="YES" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#674274;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#674274;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="image-attached" target="visual-passes">
142
+ <mxGeometry relative="1" as="geometry"/>
143
+ </mxCell>
144
+ <mxCell id="edge-fallback-finding" value="structural / semantic result" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#1F4E78;strokeWidth=2;fontSize=12;fontColor=#1F4E78;labelBackgroundColor=#F4F7FB;exitX=1;exitY=1;entryX=0;entryY=0.5;" edge="1" parent="1" source="fallback-review" target="finding">
145
+ <mxGeometry relative="1" as="geometry">
146
+ <Array as="points">
147
+ <mxPoint x="620" y="1580"/>
148
+ <mxPoint x="620" y="1690"/>
149
+ </Array>
150
+ </mxGeometry>
151
+ </mxCell>
152
+ <mxCell id="edge-visual-finding" value="finding ledger" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#674274;strokeWidth=2;fontSize=12;fontColor=#674274;labelBackgroundColor=#F4F7FB;exitX=0;exitY=1;entryX=1;entryY=0.5;" edge="1" parent="1" source="visual-passes" target="finding">
153
+ <mxGeometry relative="1" as="geometry">
154
+ <Array as="points">
155
+ <mxPoint x="1320" y="1580"/>
156
+ <mxPoint x="1320" y="1690"/>
157
+ </Array>
158
+ </mxGeometry>
159
+ </mxCell>
160
+ <mxCell id="edge-finding-no" value="NO" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#2D5E36;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#2D5E36;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="finding" target="quality-pass">
161
+ <mxGeometry relative="1" as="geometry"/>
162
+ </mxCell>
163
+ <mxCell id="edge-finding-yes" value="YES" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#D79B00;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#9A5B13;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0;entryY=0.5;" edge="1" parent="1" source="finding" target="retry-limit">
164
+ <mxGeometry relative="1" as="geometry"/>
165
+ </mxCell>
166
+ <mxCell id="edge-retry-yes" value="YES" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#674274;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#674274;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.5;entryY=0;" edge="1" parent="1" source="retry-limit" target="correction-cycle">
167
+ <mxGeometry relative="1" as="geometry"/>
168
+ </mxCell>
169
+ <mxCell id="edge-retry-no" value="NO" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#D79B00;strokeWidth=2.5;fontSize=13;fontStyle=1;fontColor=#9A5B13;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0.5;entryY=0;" edge="1" parent="1" source="retry-limit" target="limit-reached">
170
+ <mxGeometry x="-0.9" y="0" relative="1" as="geometry">
171
+ <mxPoint x="8" y="-12" as="offset"/>
172
+ <Array as="points">
173
+ <mxPoint x="1900" y="1690"/>
174
+ <mxPoint x="1900" y="1795"/>
175
+ <mxPoint x="320" y="1795"/>
176
+ </Array>
177
+ </mxGeometry>
178
+ </mxCell>
179
+ <mxCell id="edge-correction-loop" value="source edit" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#674274;strokeWidth=2.5;dashed=1;dashPattern=8 4;fontSize=12;fontColor=#674274;labelBackgroundColor=#F4F7FB;exitX=1;exitY=0.5;entryX=0.75;entryY=1;" edge="1" parent="1" source="correction-cycle" target="revalidate-junction">
180
+ <mxGeometry relative="1" as="geometry">
181
+ <Array as="points">
182
+ <mxPoint x="1965" y="1913"/>
183
+ <mxPoint x="1965" y="310"/>
184
+ </Array>
185
+ </mxGeometry>
186
+ </mxCell>
187
+ <mxCell id="edge-revalidate-revision" value="run drawio_validate" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#405E78;strokeWidth=2.5;fontSize=12;fontColor=#405466;labelBackgroundColor=#F4F7FB;exitX=0;exitY=0.5;entryX=1;entryY=0.5;" edge="1" parent="1" source="revalidate-junction" target="revision">
188
+ <mxGeometry relative="1" as="geometry"/>
189
+ </mxCell>
190
+ <mxCell id="edge-quality-export" value="ship" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#2D5E36;strokeWidth=2.5;fontSize=12;fontColor=#2D5E36;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.7;entryY=0;" edge="1" parent="1" source="quality-pass" target="final-export">
191
+ <mxGeometry relative="1" as="geometry">
192
+ <Array as="points">
193
+ <mxPoint x="1190" y="2020"/>
194
+ <mxPoint x="1190" y="2115"/>
195
+ <mxPoint x="1102" y="2115"/>
196
+ </Array>
197
+ </mxGeometry>
198
+ </mxCell>
199
+ <mxCell id="edge-limit-export" value="ship with explicit exceptions" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;endArrow=blockThin;endFill=1;strokeColor=#9A5B13;strokeWidth=2.5;fontSize=12;fontColor=#9A5B13;labelBackgroundColor=#F4F7FB;exitX=0.5;exitY=1;entryX=0.25;entryY=0;" edge="1" parent="1" source="limit-reached" target="final-export">
200
+ <mxGeometry relative="1" as="geometry">
201
+ <Array as="points">
202
+ <mxPoint x="320" y="2115"/>
203
+ <mxPoint x="805" y="2115"/>
204
+ </Array>
205
+ </mxGeometry>
206
+ </mxCell>
207
+ </root>
208
+ </mxGraphModel>
209
+ </diagram>
210
+ </mxfile>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@senad-d/drawme",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Pi extension for authoring, validating, and exporting editable draw.io diagrams from natural-language descriptions.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/drawio.ts CHANGED
@@ -163,6 +163,12 @@ export interface ExportResult {
163
163
  version?: string;
164
164
  /** True if the truncated `-e` PNG IEND chunk was repaired after export. */
165
165
  repaired: boolean;
166
+ /**
167
+ * True when this preview replaced an earlier tracked preview for the same
168
+ * source — including a re-export over the same output path, where nothing is
169
+ * removed from disk. Always false for final exports.
170
+ */
171
+ replacedPreview: boolean;
166
172
  /** Superseded preview artifacts removed after this successful preview or final export. */
167
173
  removedPreviews: string[];
168
174
  /** Best-effort preview cleanup failures; the export itself still succeeded. */
@@ -186,6 +192,8 @@ function sourceKey(input: string): string {
186
192
  interface PreviewCleanup {
187
193
  removed: string[];
188
194
  warnings: string[];
195
+ /** A tracked preview for the same source existed before this export (even at the same path). */
196
+ replaced: boolean;
189
197
  }
190
198
 
191
199
  /**
@@ -215,13 +223,13 @@ async function replaceTrackedPreview(input: string, latestOutput: string): Promi
215
223
  }
216
224
 
217
225
  previewOutputs.set(key, retained);
218
- return { removed, warnings };
226
+ return { removed, warnings, replaced: previous.size > 0 };
219
227
  }
220
228
 
221
229
  async function removeTrackedPreviews(input: string, finalOutput: string): Promise<PreviewCleanup> {
222
230
  const key = sourceKey(input);
223
231
  const previews = previewOutputs.get(key);
224
- if (!previews) return { removed: [], warnings: [] };
232
+ if (!previews) return { removed: [], warnings: [], replaced: false };
225
233
 
226
234
  previewOutputs.delete(key);
227
235
  const finalPath = resolve(finalOutput);
@@ -243,7 +251,7 @@ async function removeTrackedPreviews(input: string, finalOutput: string): Promis
243
251
  }
244
252
 
245
253
  if (retry.size > 0) previewOutputs.set(key, retry);
246
- return { removed, warnings };
254
+ return { removed, warnings, replaced: false };
247
255
  }
248
256
 
249
257
  async function withSourceExportQueue<T>(input: string, action: () => Promise<T>): Promise<T> {
@@ -331,6 +339,7 @@ async function exportDiagramQueued(opts: ExportOptions): Promise<ExportResult> {
331
339
  binary: info.binary,
332
340
  version: info.version,
333
341
  repaired,
342
+ replacedPreview: cleanup.replaced,
334
343
  removedPreviews: cleanup.removed,
335
344
  previewCleanupWarnings: cleanup.warnings,
336
345
  command,
package/src/index.ts CHANGED
@@ -106,7 +106,7 @@ export default function drawme(pi: ExtensionAPI): void {
106
106
  name: "drawio_export",
107
107
  label: "draw.io: export",
108
108
  description:
109
- "Export a .drawio file to PNG/SVG/PDF/JPG via the draw.io CLI. A successful mode:'preview' PNG is clean, width-capped, and never embedded; when the current model can view images it is attached to the tool result for visual review, and the result text always states whether it was attached. Each successful preview removes the prior preview artifact for the same source, leaving only the latest file. mode:'final' creates the deliverable (embedded editable output; truncated PNG IEND is repaired) and removes the remaining preview.",
109
+ "Export a .drawio file to PNG/SVG/PDF/JPG via the draw.io CLI. A successful mode:'preview' PNG is clean, width-capped, and never embedded; when the current model can view images it is attached to the tool result for visual review, and the result text always states whether it was attached. Each successful preview removes the prior preview artifact for the same source, leaving only the latest file; a replacement preview asks for a fixed/not-fixed/regressed verdict against the prior image. mode:'final' creates the deliverable (embedded editable output; truncated PNG IEND is repaired) and removes the remaining preview.",
110
110
  promptSnippet:
111
111
  "Export a .drawio to PNG/SVG/PDF/JPG (mode:'preview' attaches the review image when the current model can view images — the result text says so — and removes the previous preview file; mode:'final' creates the deliverable and cleans the remaining preview).",
112
112
  parameters: exportParams,
@@ -123,11 +123,17 @@ export default function drawme(pi: ExtensionAPI): void {
123
123
  const versionSuffix = r.version ? ` (${r.version})` : "";
124
124
  lines.push(`binary=${r.binary}${versionSuffix}`);
125
125
  if (r.mode === "preview" && r.format === "png") {
126
- lines.push(
127
- canView
128
- ? "Preview image attached below. Critique it category by category before editing the source."
129
- : "Preview image NOT attached: the current model cannot view images. Do not describe or judge the render; review structurally with drawio_validate and drawio_explain, and share the exported path so the user can view it.",
130
- );
126
+ if (!canView) {
127
+ lines.push(
128
+ "Preview image NOT attached: the current model cannot view images. Do not describe or judge the render; review structurally with drawio_validate and drawio_explain, and share the exported path so the user can view it.",
129
+ );
130
+ } else if (r.replacedPreview) {
131
+ lines.push(
132
+ "Preview image attached below. It replaces the previous preview, whose image is still visible earlier in this conversation: compare the two at each finding you addressed and record a verdict — fixed, not fixed, or regressed — before editing further.",
133
+ );
134
+ } else {
135
+ lines.push("Preview image attached below. Critique it against the current review pass's checklist before editing the source.");
136
+ }
131
137
  }
132
138
  return exportResult(lines.join("\n"), r, canView);
133
139
  } catch (e) {
package/src/workflow.ts CHANGED
@@ -2,11 +2,11 @@ import type { DrawioInfo } from "./drawio";
2
2
 
3
3
  /**
4
4
  * Maximum number of automatic source-correction retries across the visual
5
- * review. The initial critique pass and the final holistic confirmation do not
6
- * consume retries; one targeted edit → validation → replacement preview cycle
7
- * consumes one.
5
+ * review. Pass inspection previews (the first preview of each review pass) do
6
+ * not consume retries; one targeted edit → validation → replacement-preview
7
+ * cycle consumes one.
8
8
  */
9
- export const AUTOMATIC_CORRECTION_LIMIT = 5;
9
+ export const AUTOMATIC_CORRECTION_LIMIT = 8;
10
10
 
11
11
  /**
12
12
  * Reference file contents pre-loaded by the `/drawme` command handler so the
@@ -47,12 +47,19 @@ function referenceSection(title: string, path: string, content: string | null):
47
47
  /**
48
48
  * Builds the message the `/drawme` command injects to drive the diagram
49
49
  * workflow. It steers the model through authoring, deterministic validation,
50
- * a critique-first visual review, and autonomous final export — once started,
51
- * the run never pauses for human input. The CLI check result and the topic
52
- * references are embedded, so no upfront tool calls or file reads are needed;
53
- * only the rarely needed troubleshooting reference stays on-demand. The
54
- * preview tool result states whether the review image is attached, so the
55
- * review instructions branch on that signal rather than assuming vision.
50
+ * a gated multi-pass visual review, and autonomous final export — once
51
+ * started, the run never pauses for human input. The review runs as fixed
52
+ * passes (fit/sizing → element placement → connections → holistic typography,
53
+ * semantics, and regression), each answering explicit questions on its own
54
+ * preview and each required to be clean before the next starts. Findings go
55
+ * into a numbered ledger naming the affected cells, and every fix must be
56
+ * verified by comparing the replacement preview against the previous image
57
+ * (verdict: fixed / not fixed / regressed) rather than by trusting the XML
58
+ * edit. The CLI check result and the topic references are embedded, so no
59
+ * upfront tool calls or file reads are needed; only the rarely needed
60
+ * troubleshooting reference stays on-demand. The preview tool result states
61
+ * whether the review image is attached, so the review instructions branch on
62
+ * that signal rather than assuming vision.
56
63
  */
57
64
  export function drawmeWorkflow(description: string, refDir: string, cli: DrawioInfo, refs: WorkflowReferences): string {
58
65
  const quoted = description.replaceAll("\n", "\n> ");
@@ -73,21 +80,21 @@ export function drawmeWorkflow(description: string, refDir: string, cli: DrawioI
73
80
  mermaidPlanning,
74
81
  "3. **Author** — for hand-written XML, follow the XML authoring reference below. Keep XML uncompressed; never reuse ids `0`/`1`; give every edge `<mxGeometry relative=\"1\" as=\"geometry\"/>`; use `drawio_shapesearch` rather than guessing exact vendor/UML/BPMN/cloud styles. For large graphs (>~15 nodes) on v30+, hand-write nodes and use `drawio_layout`. Space elements generously rather than packing them, then run `drawio_fit_canvas` after authoring — and again after any Mermaid conversion or layout — so the page wraps the content with a comfortable margin. Treat every write, edit, Mermaid conversion, layout, and canvas-fit result as a source edit.",
75
82
  "4. **Validate after every source edit** — call `drawio_validate` immediately after authoring and after every later XML edit, Mermaid conversion, or layout operation. Fix all errors before previewing. Every warning must be either fixed or recorded explicitly as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export.",
76
- "5. **Visual review — critique before editing** — export one holistic preview to `<name>.review.png` with `drawio_export` mode `\"preview\"`. The result text states whether the preview image is attached; follow the matching path:",
77
- " - **Image attached** — write a structured critique of the render before touching the source. Walk every category in this order and, for each one, either record findings as `category / severity / affected cell ids / fix` or state explicitly why it passes — never conclude the render is fine without walking all four:",
78
- " 1. **Canvas and composition**: page bounds, outer margins, clipping, excessive empty space, aspect ratio, major alignment, and overall balance.",
79
- " 2. **Nodes and typography**: shape overlap, label clipping/wrapping, readable font size, contrast, padding, sizing, and alignment. If the 2000px full-diagram preview makes labels unreadable, re-export a focused preview (`width`, `pageIndex`) rather than assuming the typography passes.",
80
- " 3. **Connectors**: endpoints, arrowheads, stacked lines, crossings, routes through unrelated elements, labels, and routing corridors.",
81
- " 4. **Semantics**: requested components and relationships, hierarchy, consistency, legends, and grouping.",
82
- " - **Image NOT attached** — the current model cannot view images. Do not describe or judge renders; review structurally instead: cross-check `drawio_validate` findings and a `drawio_explain` read-back against the user's request. Keep the latest `<name>.review.png` on disk so the user can view it, and state plainly in the summary that rendered inspection was skipped.",
83
- "6. **Fix and confirm** — resolve critique findings with targeted source edits: after each edit, validate, then re-export a focused preview named for the affected category (`<name>.review-canvas.png`, `<name>.review-nodes.png`, `<name>.review-connectors.png`, or `<name>.review-semantics.png`) and confirm the fix. When elements overlap, are cramped, clipped, or short on margin, never shrink or squeeze elements to fit the page — move them apart, then run `drawio_fit_canvas` to enlarge the canvas around them. When no findings remain, re-export the holistic `<name>.review.png`, re-walk all four categories to confirm nothing regressed, and retain that image for the final report. Each successful preview export automatically removes the previous preview file for the same source, so only the latest review image remains.",
84
- `7. **Correction limit** — the initial critique pass and the final holistic confirmation do not count against the limit. Across the whole automatic review, allow at most ${AUTOMATIC_CORRECTION_LIMIT} correction retries; one retry is one targeted source-edit → \`drawio_validate\` → replacement-preview cycle. Count retries explicitly. If the limit is reached with a finding unresolved, stop automatic editing, keep the best validated state, and continue to final export — name the unresolved finding and its category plainly in the final report instead of looping or waiting for input.`,
85
- "8. **No human gate** — the run is fully autonomous: once started, never pause to ask for approval, confirmation, or feedback. When the holistic confirmation is clean (or the correction limit was reached), proceed directly to final export. If the user interrupts with feedback mid-run, treat it as new critique findings: targeted edit, validate, focused confirmation, fresh holistic preview, then continue to export.",
86
- "9. **Final export** — immediately after the holistic confirmation, call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). The first successful final export removes the one remaining latest preview for the same source; do not delete previews yourself or report it as a retained output. Report the `.drawio` source and every final path, retained reviewed warnings, any unresolved finding from the correction limit, and cleanup warnings. Offer `drawio_open` for fine-tuning afterwards.",
83
+ "5. **Visual review — three focused passes, then a holistic confirmation** — run this once authoring and validation are clean. Export previews with `drawio_export` mode `\"preview\"`; every preview renders a single page, so for a multi-page file, export one preview per page with `pageIndex` and review every page (page-suffixed names, e.g. `<name>.review-p2-fit.png`). The result text states whether the preview image is attached; follow the matching path:",
84
+ " - **Image attached** — run the four passes below in order. Do not start the next pass until every finding of the current one is verified **fixed** in a fresh render or explicitly accepted with a reason. For each pass: export its preview, write a structured critique that hunts for defects — do not summarize or admire the diagram — answer the pass's questions explicitly (a bare \"yes\" is not an answer; point at the evidence in the image), and record findings in one numbered ledger kept for the rest of the run: `F1, F2, …: pass / severity / affected cell ids / what is visibly wrong and where in the image / planned fix` (pick fixes from the defect→fix recipes in the XML authoring reference). The critique's job is to narrow every problem down to specific cells so the fix step can be surgical.",
85
+ " 1. **Pass 1 — fit and sizing** (`<name>.review-fit.png`) answers: does the diagram fit its page, and does the canvas or any element need resizing? Hunt: content touching or crossing a page edge; one outer margin visibly thinner than the others; large empty regions or a page far larger than its content; elements too small for their labels — text touching or crossing its own shape border, clipped or mid-word truncated; a smallest label you cannot comfortably read at full-diagram scale (tighten the canvas with `drawio_fit_canvas`, split content across pages, or simplify the layout — never judge what you cannot read, and never treat \"too small to tell\" as a pass).",
86
+ " 2. **Pass 2 — element placement** (`<name>.review-layout.png`) answers: is every element positioned correctly, and is there a visibly better arrangement? Hunt: shapes whose borders touch or overlap; two labels touching or overlapping each other; label text lying on top of any line or unrelated shape; rows/columns that drift out of alignment; uneven gaps between peers; children poking out of their container or crowding its title; related elements far apart while unrelated ones sit adjacent. Improve, not only repair: if moving an element would shorten edges, remove crossings, or make the arrangement symmetric, record that as a finding too.",
87
+ " 3. **Pass 3 — connections** (`<name>.review-connectors.png`) answers: is every connection correct, cleanly routed, symmetric where the layout is symmetric, and anchored to the middle of the element side it faces wherever possible? Trace every edge from source to target and check it against the plan — right source, right target, right direction, right label. Hunt: an endpoint floating off its shape or plunging deep into it; an edge entering at an odd corner when a side-center anchor is available (pin `exitX`/`exitY`/`entryX`/`entryY` to the facing side's center, spreading evenly only when several edges share one side); mirrored branches routed asymmetrically; an arrowhead hidden by a shape or crushed into a bend; an edge passing through a shape it does not connect; parallel edges stacked on top of each other; an edge label sitting on its line so the text is struck through, or closer than about half a text-height to any line; crossings a reroute through a free corridor would remove.",
88
+ " 4. **Pass 4 — typography, semantics, and regression** (`<name>.review.png`) is the holistic confirmation. Read every label word for word — a label you cannot fully read is itself a finding; check text contrast against fills; confirm every requested component and relationship is present, pointing the right way, with the right label; check hierarchy, grouping, and that legend entries match the colors actually used; apply the type's `Review:` checklist from the diagram-types reference; and re-check passes 1–3 for regressions. Retain this image (every page, for a multi-page file) for the final report.",
89
+ " - **Image NOT attached** — the current model cannot view images. Skip the visual passes: do not describe or judge renders; review structurally instead by cross-checking `drawio_validate` findings and a `drawio_explain` read-back against the user's request. Keep the latest `<name>.review.png` on disk so the user can view it, and state plainly in the summary that rendered inspection was skipped.",
90
+ "6. **Fix and verify before the next pass** — resolve a pass's findings with targeted source edits: after each edit, validate, then re-export the same pass preview (for a multi-page file, the page the finding is on). The superseded preview file is deleted from disk, but its image is still visible earlier in this conversation: compare the new image against it at each addressed finding's location and record a verdict — **fixed** (the defect is gone in the new render), **not fixed** (still visible), or **regressed** (the edit introduced a new defect; log it as a new numbered finding). Never mark a finding fixed because the XML changed — only because the new image shows it fixed. When elements overlap, are cramped, clipped, or short on margin, never shrink or squeeze elements to fit the page — move them apart, then run `drawio_fit_canvas` to enlarge the canvas around them. A pass is complete only when all of its findings are fixed or explicitly accepted, and every pass must be complete before final export. If the correction limit is reached mid-pass, finish the remaining passes as inspection-only and report their findings as unresolved. Each successful preview export automatically removes the previous preview file for the same source, so only the latest review image remains.",
91
+ `7. **Correction limit** — pass inspection previews (the first preview of each pass) do not count against the limit. Across the whole review, allow at most ${AUTOMATIC_CORRECTION_LIMIT} correction retries; one retry is one targeted source-edit → \`drawio_validate\` → replacement-preview cycle, whatever its verdict. Count retries explicitly. If the limit is reached with a finding unresolved, stop automatic editing, keep the best validated state, and continue to final export — name the unresolved finding, its pass, and its last verdict plainly in the final report instead of looping or waiting for input.`,
92
+ "8. **No human gate** — the run is fully autonomous: once started, never pause to ask for approval, confirmation, or feedback. When pass 4 is clean (or the correction limit was reached), proceed directly to final export. If the user interrupts with feedback mid-run, append it to the ledger as new numbered findings: targeted edit, validate, before/after confirmation on the relevant pass preview, a fresh pass-4 holistic preview, then continue to export.",
93
+ "9. **Final export** — immediately after pass 4 is clean (or the correction limit was reached), call `drawio_export` with `mode: \"final\"` for each requested format (default PNG; SVG/PDF/JPG on request). A final export also renders a single page: for a multi-page file, export each page with `pageIndex` and a distinct `output` per page and format. The first successful final export removes the one remaining latest preview for the same source; do not delete previews yourself or report it as a retained output. Report the `.drawio` source and every final path, retained reviewed warnings, any unresolved finding from the correction limit, and cleanup warnings. Offer `drawio_open` for fine-tuning afterwards.",
87
94
  "",
88
95
  "Failure handling: several DrawMe tools report failures as a text result beginning with `Export failed`, `Layout failed`, `Mermaid conversion failed`, `Fit canvas failed`, `Explain failed`, or `Open failed` rather than a tool error — always read the result text and treat those as failures. If export fails, read `" +
89
96
  refDir +
90
- "/troubleshooting.md` (the one reference kept on-demand). On draw.io below v30, use hand-authored XML instead of Mermaid conversion or ELK layout, but keep validation, the critique-first review, requested-format handling, and final cleanup unchanged.",
97
+ "/troubleshooting.md` (the one reference kept on-demand). On draw.io below v30, use hand-authored XML instead of Mermaid conversion or ELK layout, but keep validation, the pass-based review, requested-format handling, and final cleanup unchanged.",
91
98
  "",
92
99
  "---",
93
100
  "",