@senad-d/drawme 0.1.3 → 0.1.4
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 +6 -2
- package/README.md +20 -16
- package/assets/references/troubleshooting.md +2 -2
- package/assets/references/xml-authoring.md +25 -1
- package/docs/agent-guide.md +53 -48
- package/docs/visual-review-implementation-tasks.md +271 -0
- package/example/drawme-how-it-works.drawio +32 -26
- package/example/drawme-installation-guide.drawio +27 -21
- package/package.json +1 -1
- package/src/drawio.ts +67 -15
- package/src/index.ts +26 -8
- package/src/validate.ts +516 -127
- package/src/workflow.ts +27 -12
package/CHANGELOG.md
CHANGED
|
@@ -8,8 +8,12 @@ All notable changes to this project are documented here. The format is based on
|
|
|
8
8
|
|
|
9
9
|
### Changed
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
|
|
11
|
+
- Added focused visual quality passes, stronger deterministic canvas/edge/readability checks, attached PNG
|
|
12
|
+
previews, warning-resolution gates, and explicit approval before final export.
|
|
13
|
+
- Intentionally re-baselined the golden asset hash after adding finite-page sizing, typography, preview
|
|
14
|
+
readability, and five-retry correction guidance to the packaged authoring references.
|
|
15
|
+
- Each successful preview now removes the previous preview file for the same `.drawio` source, leaving only
|
|
16
|
+
the latest review artifact; final export removes that remaining preview.
|
|
13
17
|
- Refocused the documentation on DrawMe's current diagram-authoring workflow and removed obsolete
|
|
14
18
|
guidance inherited from the earlier documentation set.
|
|
15
19
|
- Improved npm and Pi gallery metadata, packaged linked diagram examples, and added a package-content
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram and Pi plans it, writes editable `.drawio` XML (or Mermaid on draw.io v30+), lints
|
|
20
|
+
DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram and Pi plans it, writes editable `.drawio` XML (or Mermaid on draw.io v30+), lints every source revision, runs ordered visual quality passes, and exports only after approval.
|
|
21
21
|
|
|
22
22
|
<table align="center">
|
|
23
23
|
<tr>
|
|
@@ -31,10 +31,11 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
|
|
|
31
31
|
</table>
|
|
32
32
|
|
|
33
33
|
- **Natural-language authoring:** flowcharts, architecture, UML, BPMN, ERD, C4, network, ML — as native `.drawio`, or as Mermaid with automatic layout on v30+.
|
|
34
|
-
- **Guided workflow:** CLI detection, planning, authoring, validation,
|
|
35
|
-
- **Deterministic validation:** a structural linter catches dangling edges, duplicate/reserved ids,
|
|
34
|
+
- **Guided workflow:** CLI detection, planning, authoring, validation, focused canvas/node/connector/semantic passes, holistic regression review, approval, and final export are coordinated from `/drawme`.
|
|
35
|
+
- **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.
|
|
36
|
+
- **Preview in the tool result:** successful PNG previews return text/metadata plus the actual image; each replacement removes the previous same-source preview file so only the latest remains on disk.
|
|
36
37
|
- **Exact shapes, not guesses:** search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
|
|
37
|
-
- **Editable source of truth:** final PNG/SVG/PDF exports embed the diagram XML, the truncated `-e` PNG chunk is auto-repaired, and
|
|
38
|
+
- **Editable source of truth:** final PNG/SVG/PDF exports embed the diagram XML, the truncated `-e` PNG chunk is auto-repaired, and final export removes the one remaining latest preview.
|
|
38
39
|
|
|
39
40
|
> **Security:** Pi packages run with your full system permissions. DrawMe reads and writes diagram files and can launch the draw.io CLI or your OS file opener. Review [`SECURITY.md`](SECURITY.md) before installation.
|
|
40
41
|
|
|
@@ -63,7 +64,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
|
|
|
63
64
|
This checkout implements the DrawMe core loop as a Pi extension:
|
|
64
65
|
|
|
65
66
|
- Eight model-callable tools (`drawio_check`, `drawio_export`, `drawio_validate`, `drawio_shapesearch`, `drawio_from_mermaid`, `drawio_layout`, `drawio_explain`, `drawio_open`) and three commands (`/drawme`, `/drawme-check`, `/drawme-export`).
|
|
66
|
-
- A guided `/drawme` workflow that steers authoring, validation,
|
|
67
|
+
- A guided `/drawme` workflow that steers authoring, validation after every edit, five focused visual passes, human approval, and final multi-format export.
|
|
67
68
|
- Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
|
|
68
69
|
- 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+).
|
|
69
70
|
- Validation pipeline: golden asset-integrity check, TypeScript typecheck, ESLint, a custom format check, and unit + real-CLI integration tests.
|
|
@@ -107,7 +108,7 @@ Inside Pi:
|
|
|
107
108
|
/drawme a flowchart of a user login: enter credentials, validate, then success or retry
|
|
108
109
|
```
|
|
109
110
|
|
|
110
|
-
Pi checks the CLI, plans and writes the `.drawio`, validates
|
|
111
|
+
Pi checks the CLI, plans and writes the `.drawio`, validates every revision, inspects focused preview PNGs, performs a holistic regression check, and — only after your explicit approval — exports the final editable deliverable.
|
|
111
112
|
|
|
112
113
|
### Run from a source checkout
|
|
113
114
|
|
|
@@ -133,7 +134,7 @@ pi --no-extensions -e .
|
|
|
133
134
|
|
|
134
135
|
| Command | Description |
|
|
135
136
|
| --- | --- |
|
|
136
|
-
| `/drawme <description>` | Kick off
|
|
137
|
+
| `/drawme <description>` | Kick off authoring, per-edit validation, focused quality passes, holistic review, approval, and final export. |
|
|
137
138
|
| `/drawme-check` | Report whether the draw.io CLI is available, its version, and v30+ feature support. |
|
|
138
139
|
| `/drawme-export <file> [png\|svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`. |
|
|
139
140
|
|
|
@@ -144,8 +145,8 @@ Registered for the model to call directly.
|
|
|
144
145
|
| Tool | Purpose |
|
|
145
146
|
| --- | --- |
|
|
146
147
|
| `drawio_check` | Resolve the draw.io binary, version, and whether it supports Mermaid import / `--layout` (v30+). |
|
|
147
|
-
| `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `mode:"preview"` → clean width-capped PNG
|
|
148
|
-
| `drawio_validate` | Deterministic
|
|
148
|
+
| `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `mode:"preview"` → clean width-capped PNG returned as text/metadata plus an image block; each successful preview removes the previous same-source preview file so only the latest remains. `mode:"final"` → embedded editable deliverable, with truncated PNG repair and cleanup of the remaining preview. |
|
|
149
|
+
| `drawio_validate` | Deterministic lint: dangling edges, duplicate/reserved ids, broken parents, malformed vertex/edge geometry; warnings for page/container bounds, margins, conservative readability, overlap, and explicit routes through/crossing shapes; observations and readability score are reported separately. |
|
|
149
150
|
| `drawio_shapesearch` | Exact official `style=` strings for 10k+ AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN shapes, from a bundled local index. Use instead of guessing a style. |
|
|
150
151
|
| `drawio_from_mermaid` | Convert Mermaid text (inline or a `.mmd`) to a native `.drawio` with automatic layout. Requires draw.io **v30+**. |
|
|
151
152
|
| `drawio_layout` | Re-place nodes / route edges with an ELK preset (`verticalFlow`, `horizontalFlow`, `verticalTree`, `horizontalTree`, `radialTree`, `organic`) for large graphs. Requires draw.io **v30+**. |
|
|
@@ -166,15 +167,18 @@ The extension factory in `src/index.ts` registers the tools and commands. Render
|
|
|
166
167
|
|
|
167
168
|
## The /drawme Workflow
|
|
168
169
|
|
|
169
|
-
`/drawme` injects a guided
|
|
170
|
+
`/drawme` injects a guided eight-step workflow that the model follows using the tools above:
|
|
170
171
|
|
|
171
172
|
1. **Check** — resolve the CLI and note the version (v30+ unlocks Mermaid conversion and ELK layout).
|
|
172
|
-
2. **Plan** — pick the diagram type,
|
|
173
|
-
3. **Author** — write editable
|
|
174
|
-
4. **Validate** —
|
|
175
|
-
5. **
|
|
176
|
-
6. **
|
|
177
|
-
7. **
|
|
173
|
+
2. **Plan** — pick the diagram type, relationships, finite canvas, and layout direction.
|
|
174
|
+
3. **Author** — write editable uncompressed XML (or Mermaid on v30+), using exact searched shapes and optional ELK layout.
|
|
175
|
+
4. **Validate after every edit** — fix all errors; fix each warning or record why it is reviewed and acceptable.
|
|
176
|
+
5. **Focused quality passes** — inspect one named preview at a time: canvas/composition, nodes/typography, connectors, semantics/final polish, then a holistic regression check. Each successful pass preview removes the previous preview file, leaving only the current image.
|
|
177
|
+
6. **Bound corrections** — the five required inspections 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`.
|
|
178
|
+
7. **Human review** — feedback returns through validation, the affected focused pass, and a holistic preview; obtain explicit approval.
|
|
179
|
+
8. **Final export** — only after approval, export requested embedded/editable formats, remove the one remaining latest review preview, and report deliverables plus cleanup warnings.
|
|
180
|
+
|
|
181
|
+
Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, and conservative font/wrapping cases. Vision remains responsible for rendered clipping and wrapping, contrast, typography at full-diagram scale, visual balance, semantics, and draw.io's automatic connector routes. A 2000px preview that makes labels unreadable requires a tighter/simpler layout, page splitting, or focused review—not automatic approval.
|
|
178
182
|
|
|
179
183
|
## Bundled References and Assets
|
|
180
184
|
|
|
@@ -13,10 +13,10 @@ Read this when something looks wrong in the output (rendering, export, layout, e
|
|
|
13
13
|
| Overlapping shapes | Scale spacing with complexity (200–350px); leave routing corridors |
|
|
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
|
-
|
|
|
16
|
+
| Automatic correction loop reaches its limit | The five required focused inspection passes 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, stop, identify its review category, request focused user feedback, and offer `drawio_open`. |
|
|
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
|
-
| Vision reports that the preview dimensions are too large | Re-export with `drawio_export` in preview mode and set a smaller `width`. |
|
|
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. |
|
|
20
20
|
| Linux: blank/error output headlessly | Prefix command with `xvfb-run -a` |
|
|
21
21
|
| Linux: `--no-sandbox` placed before input file (parsed as filename) | Move `--no-sandbox` to the very end of the command (drawio-desktop#249, #1056) |
|
|
22
22
|
| Linux: `Failed to get 'appData' path` / `Home directory not accessible` | `export HOME=/tmp` before invoking drawio (drawio-desktop#127) |
|
|
@@ -9,7 +9,7 @@ Read this **before hand-writing any `.drawio` XML** (workflow step 3). Skip it w
|
|
|
9
9
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
10
10
|
<mxfile host="drawio" version="26.0.0">
|
|
11
11
|
<diagram name="Page-1">
|
|
12
|
-
<mxGraphModel>
|
|
12
|
+
<mxGraphModel grid="1" gridSize="10" page="1" pageScale="1" pageWidth="1200" pageHeight="800">
|
|
13
13
|
<root>
|
|
14
14
|
<mxCell id="0" />
|
|
15
15
|
<mxCell id="1" parent="0" />
|
|
@@ -28,6 +28,29 @@ Read this **before hand-writing any `.drawio` XML** (workflow step 3). Skip it w
|
|
|
28
28
|
- **Never use `--` inside XML comments** — it's illegal per XML spec and causes parse errors
|
|
29
29
|
- Escape special characters in attribute values: `&`, `<`, `>`, `"`
|
|
30
30
|
- **Multi-line text in labels:** use `
` for line breaks inside `value` attributes (not literal `\n`). Example: `value="Line 1
Line 2"`
|
|
31
|
+
- Keep `page="1"` and `pageScale="1"` for a normal finite page, and resize `pageWidth`/`pageHeight` to the finished content. Use `page="0"` only when the user explicitly wants an infinite/non-page canvas; deterministic page-boundary, outer-margin, and empty-space checks are then intentionally skipped.
|
|
32
|
+
- If `pageWidth` or `pageHeight` is omitted, DrawMe still validates cells and containment but records that page-boundary, outer-margin, and empty-space checks were skipped. Prefer explicit dimensions for deliverables.
|
|
33
|
+
|
|
34
|
+
### Canvas sizing and content bounds
|
|
35
|
+
|
|
36
|
+
Choose the page from the layout rather than leaving a large default canvas:
|
|
37
|
+
|
|
38
|
+
1. Compute every visible top-level vertex/container rectangle as `(x, y, x + width, y + height)`. For a nested child, add every ancestor container's `x` and `y` to the child's local coordinates.
|
|
39
|
+
2. Expand the bounds for separately sized edge labels and explicit waypoints when their positions are known. Automatic edge routes still need preview inspection.
|
|
40
|
+
3. Shift top-level content so the minimum `x` and `y` leave a **40px recommended outer margin**; DrawMe warns below the **20px minimum**.
|
|
41
|
+
4. Set `pageWidth` to the rightmost visible coordinate plus 40px and `pageHeight` to the bottommost visible coordinate plus 40px. Round both up to a multiple of 10. Keep `pageScale="1"` unless a deliberately scaled page is required.
|
|
42
|
+
5. After every move, resize, container change, layout pass, legend addition, or waypoint edit, recalculate the bounds and resize the page. A page much larger than content creates unreadable full-diagram previews and triggers an excessive-empty-space warning.
|
|
43
|
+
|
|
44
|
+
Example: content spanning `x=40..1160` and `y=40..720` should normally use `pageWidth="1200"` and `pageHeight="760"`. Do not count invisible helpers or intentional relative border ports as page-extending content.
|
|
45
|
+
|
|
46
|
+
### Typography, padding, and labels
|
|
47
|
+
|
|
48
|
+
- Use at least **12px for body/node labels** and **10px for connector labels**. Headings usually need 16px or more. Compact border ports and notation-mandated annotations may use 8–9px when their short labels remain legible; record the exception during review.
|
|
49
|
+
- Add `whiteSpace=wrap;html=1;` to labeled nodes. Use about 10–16px visual padding (`spacing=10;` or directional spacing) between text and shape borders.
|
|
50
|
+
- Size a node for the rendered lines, not only character count. A conservative height is `line count × (fontSize × 1.25) + top/bottom padding`; allow additional room for container title bands and icon shapes.
|
|
51
|
+
- Estimate width from the longest line (`characters × fontSize × 0.6 + left/right padding`), then verify by preview. Insert deliberate `
` breaks for long labels rather than forcing a very wide node.
|
|
52
|
+
- 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.
|
|
53
|
+
- 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; do not treat an unreadable full view as typography approval.
|
|
31
54
|
|
|
32
55
|
### Shape types (vertex)
|
|
33
56
|
|
|
@@ -187,6 +210,7 @@ Rules: swatch colors come from the active palette (preset or the table above) wi
|
|
|
187
210
|
**Grid alignment:** snap all `x`, `y`, `width`, `height` values to **multiples of 10** — this ensures shapes align cleanly on draw.io's default grid and makes manual editing easier.
|
|
188
211
|
|
|
189
212
|
**General rules:**
|
|
213
|
+
- Recalculate visible content bounds and update `pageWidth`/`pageHeight` after every layout change; retain at least the 20px minimum outer margin (40px recommended)
|
|
190
214
|
- Plan a grid before assigning x/y coordinates — sketch node positions on paper/mentally first
|
|
191
215
|
- Group related nodes in the same horizontal or vertical band
|
|
192
216
|
- Use `swimlane` cells for logical grouping with visible borders
|
package/docs/agent-guide.md
CHANGED
|
@@ -13,10 +13,12 @@ This document defines the extension's public functionality, options, defaults, d
|
|
|
13
13
|
3. Use DrawMe tools for draw.io CLI operations; do not invoke `drawio` through a shell.
|
|
14
14
|
4. Use `drawio_shapesearch` instead of guessing official shape styles.
|
|
15
15
|
5. Keep hand-authored XML uncompressed and structurally valid.
|
|
16
|
-
6. Run `drawio_validate`
|
|
17
|
-
7.
|
|
18
|
-
8.
|
|
19
|
-
9.
|
|
16
|
+
6. Run `drawio_validate` after every source edit. Fix every error; fix each warning or explicitly record why it was reviewed and accepted.
|
|
17
|
+
7. Inspect one visual category at a time in this order: canvas/composition, nodes/typography, connectors, semantics/polish, then a holistic regression check.
|
|
18
|
+
8. Use `drawio_export` with `mode: "preview"` for visual inspection. A successful PNG preview returns both text/metadata and the actual image; the text path remains the fallback when a model or run mode cannot consume images.
|
|
19
|
+
9. Require explicit user approval before `mode: "final"`. Each successful preview export removes the previous preview file for the same source, leaving only the latest; a successful final export removes that remaining preview. Cleanup warnings do not invalidate the new export.
|
|
20
|
+
10. Inspect every tool's text result. Several tools return failure text rather than throwing a tool-call error.
|
|
21
|
+
11. Offer `drawio_open` for manual fine-tuning; call it only when the user wants a desktop application opened.
|
|
20
22
|
|
|
21
23
|
## Functional availability
|
|
22
24
|
|
|
@@ -41,7 +43,7 @@ Commands are user-facing shortcuts. Agents should use model-callable tools when
|
|
|
41
43
|
|
|
42
44
|
| Command | Functionality |
|
|
43
45
|
| --- | --- |
|
|
44
|
-
| `/drawme <description>` | Starts the full
|
|
46
|
+
| `/drawme <description>` | Starts the full workflow: check, plan, author, validate, focused quality passes, holistic regression review, approval, and final export. |
|
|
45
47
|
| `/drawme-check` | Displays the detected draw.io path and version, or reports that the CLI is unavailable. |
|
|
46
48
|
| `/drawme-export <file> [png\|svg\|pdf\|jpg]` | Performs a final export of an existing `.drawio`; format defaults to PNG. |
|
|
47
49
|
|
|
@@ -121,11 +123,11 @@ Additional behavior:
|
|
|
121
123
|
- An explicit `width` replaces raster scaling.
|
|
122
124
|
- `scale` is ignored in preview mode and for vector formats.
|
|
123
125
|
- `transparent` has no effect outside PNG.
|
|
124
|
-
- Preview mode defaults to unembedded output suitable for vision inspection.
|
|
125
|
-
- Final PNG, SVG, and PDF default to embedded/editable output.
|
|
126
|
+
- Preview mode defaults to unembedded output suitable for vision inspection. A successful PNG preview tool result contains its normal text/metadata block followed by an `image/png` base64 image block. Text-only models and non-image run modes still receive the usable output path.
|
|
127
|
+
- Final exports stay text-only; final PNG, SVG, and PDF default to embedded/editable output.
|
|
126
128
|
- JPG cannot carry editable XML; never set `embed: true` for JPG.
|
|
127
129
|
- Embedded PNG exports are checked for draw.io's known truncated IEND chunk and repaired automatically when necessary.
|
|
128
|
-
- Every successful preview output is tracked, including explicit `output` paths.
|
|
130
|
+
- Every successful preview output is tracked, including explicit `output` paths. After a replacement preview exists, the tool automatically removes the previous preview file for the same source, so only the latest artifact remains. The first successful final export removes that remaining preview. Cleanup failures are returned as warnings without invalidating the new export.
|
|
129
131
|
- Headless Linux handling is automatic, including `xvfb-run`, GPU disabling, and the root sandbox flag.
|
|
130
132
|
|
|
131
133
|
#### Use
|
|
@@ -151,7 +153,7 @@ drawio_export({
|
|
|
151
153
|
})
|
|
152
154
|
```
|
|
153
155
|
|
|
154
|
-
Use a distinct `output` for each format or page. Never present a preview artifact as the final deliverable when a final export was requested. Do not manually delete
|
|
156
|
+
Use a distinct `output` for each format or page. Never present a preview artifact as the final deliverable when a final export was requested. Do not manually delete superseded or final-review previews; the tool replaces and cleans them automatically.
|
|
155
157
|
|
|
156
158
|
---
|
|
157
159
|
|
|
@@ -173,34 +175,39 @@ Errors include:
|
|
|
173
175
|
- vertices or edges reusing reserved root IDs `0` or `1`;
|
|
174
176
|
- references to missing parents;
|
|
175
177
|
- edge references to missing sources or targets;
|
|
176
|
-
- missing or invalid vertex geometry
|
|
178
|
+
- missing or invalid vertex geometry;
|
|
179
|
+
- missing edge geometry, or edge geometry without both `relative="1"` and `as="geometry"`.
|
|
177
180
|
|
|
178
|
-
|
|
181
|
+
Actionable warnings include:
|
|
179
182
|
|
|
180
|
-
- non-positive vertex dimensions;
|
|
181
|
-
- negative vertex positions;
|
|
183
|
+
- non-positive vertex dimensions and negative vertex positions;
|
|
182
184
|
- overlapping sibling leaf vertices;
|
|
183
|
-
-
|
|
184
|
-
-
|
|
185
|
+
- visible children extending outside parent containers (relative ports and edge labels are excluded);
|
|
186
|
+
- content outside finite page boundaries or below the 20px minimum outer margin;
|
|
187
|
+
- a canvas conservatively detected as substantially larger than its visible content;
|
|
188
|
+
- very small explicit label fonts and long labels in narrow nodes without wrapping;
|
|
189
|
+
- explicitly waypointed edges routed through unrelated vertices or crossing one another;
|
|
185
190
|
- compressed pages that cannot be inspected.
|
|
186
191
|
|
|
187
|
-
|
|
192
|
+
Informational observations identify checks intentionally skipped for infinite canvases or omitted/invalid page dimensions. All normal-page diagnostics are page-specific. Content bounds account for nested container offsets, visible nodes/containers, explicit waypoints, and separately sized edge labels on resolvable explicit routes where practical.
|
|
193
|
+
|
|
194
|
+
The result text and details also include a readability score:
|
|
188
195
|
|
|
189
196
|
- route through vertex: 20 points;
|
|
190
197
|
- edge crossing: 10 points;
|
|
191
198
|
- overlap: 5 points.
|
|
192
199
|
|
|
193
|
-
Lower is better, but scores are meaningful only when comparing layout variants of the same graph.
|
|
200
|
+
Lower is better, but scores are meaningful only when comparing layout variants of the same graph. Canvas, containment, and typography warnings do not change this established score. The text result separately reports error, unresolved-warning, and observation counts.
|
|
194
201
|
|
|
195
202
|
#### Use
|
|
196
203
|
|
|
197
|
-
Fix every error and rerun validation.
|
|
204
|
+
Fix every error and rerun validation. Fix each warning or record an explicit reviewed-and-acceptable reason before final export. Informational observations do not require correction.
|
|
198
205
|
|
|
199
206
|
```text
|
|
200
207
|
drawio_validate({ "input": "architecture.drawio" })
|
|
201
208
|
```
|
|
202
209
|
|
|
203
|
-
Validation is structural rather than
|
|
210
|
+
Validation is structural rather than rendered. Its static typography checks are deliberately conservative: it cannot guarantee label fit, correct semantic content, valid rendering of a guessed shape, color contrast, visual balance, or clear auto-routed edges. It does not replace focused preview inspection.
|
|
204
211
|
|
|
205
212
|
---
|
|
206
213
|
|
|
@@ -247,7 +254,7 @@ drawio_from_mermaid({
|
|
|
247
254
|
})
|
|
248
255
|
```
|
|
249
256
|
|
|
250
|
-
Continue with validation,
|
|
257
|
+
Continue with validation, the ordered focused visual passes, holistic regression review, explicit approval, and final export.
|
|
251
258
|
|
|
252
259
|
---
|
|
253
260
|
|
|
@@ -396,7 +403,7 @@ Choose:
|
|
|
396
403
|
- groups or containers;
|
|
397
404
|
- top-to-bottom or left-to-right direction;
|
|
398
405
|
- Mermaid or XML authoring mode;
|
|
399
|
-
- source path, pages, and final formats.
|
|
406
|
+
- source path, finite page dimensions (or an intentional infinite canvas), pages, and final formats.
|
|
400
407
|
|
|
401
408
|
Call `drawio_shapesearch` during planning whenever an exact library shape is required.
|
|
402
409
|
|
|
@@ -410,6 +417,7 @@ For XML, use an uncompressed `<mxGraphModel>`. The minimum authoring contract is
|
|
|
410
417
|
- reserve IDs `0` and `1` for those root cells;
|
|
411
418
|
- assign every other cell a unique ID and valid parent;
|
|
412
419
|
- assign every vertex positive geometry;
|
|
420
|
+
- use explicit `page="1"`, `pageScale="1"`, `pageWidth`, and `pageHeight` for deliverables, sized to visible content with at least 20px outer margin (40px recommended); use `page="0"` only for an intentional infinite canvas;
|
|
413
421
|
- assign every edge valid source and target IDs;
|
|
414
422
|
- include `<mxGeometry relative="1" as="geometry" />` in every edge;
|
|
415
423
|
- escape XML attribute characters and use `
` for label line breaks;
|
|
@@ -418,40 +426,36 @@ For XML, use an uncompressed `<mxGraphModel>`. The minimum authoring contract is
|
|
|
418
426
|
|
|
419
427
|
For large XML graphs on draw.io 30+, run `drawio_layout` and continue using its returned path.
|
|
420
428
|
|
|
421
|
-
### 4. Validate
|
|
429
|
+
### 4. Validate after every source edit
|
|
422
430
|
|
|
423
|
-
Run `drawio_validate`
|
|
431
|
+
Run `drawio_validate` immediately after initial authoring, Mermaid conversion, layout, and every later XML/source edit. Fix every error before previewing. Every warning must be fixed or explicitly recorded as reviewed and acceptable with a reason; unresolved or unreviewed warnings block final export.
|
|
424
432
|
|
|
425
|
-
### 5.
|
|
433
|
+
### 5. Focused visual quality passes
|
|
426
434
|
|
|
427
|
-
|
|
435
|
+
Inspect exactly one category at a time and keep this order. For each pass, export its predictable PNG, inspect only its listed acceptance checks, make a targeted source correction if needed, validate, then replace/re-export that pass preview before advancing:
|
|
428
436
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
437
|
+
1. **Canvas and composition** — `<name>.review-canvas.png`: page bounds, margins, clipping, excessive empty space, aspect ratio, major alignment, and balance.
|
|
438
|
+
2. **Nodes and typography** — `<name>.review-nodes.png`: overlap, clipping, wrapping, font readability, contrast, padding, sizing, and alignment.
|
|
439
|
+
3. **Connectors** — `<name>.review-connectors.png`: endpoints, arrowheads, line stacking, crossings, routes through unrelated elements, connector labels, and routing corridors.
|
|
440
|
+
4. **Semantics and final polish** — `<name>.review-semantics.png`: requested components/relationships, hierarchy, consistency, legends, grouping, and remaining regressions.
|
|
441
|
+
5. **Holistic regression check** — `<name>.review.png`: recheck all prior categories and confirm later fixes introduced no regression. This is the one review image retained for approval.
|
|
432
442
|
|
|
433
|
-
|
|
443
|
+
A successful PNG preview result already includes the image block. If the selected model/run mode cannot consume it, use the text path to read or present the artifact. When a new preview for the same source succeeds, the prior preview file is removed automatically; at any point only the latest review artifact should remain. A full-diagram preview is capped at 2000px; if that scaling makes labels unreadable, tighten/simplify the layout, split pages, or use focused review rather than approving unreadable typography.
|
|
434
444
|
|
|
435
|
-
|
|
436
|
-
- labels are readable and not clipped;
|
|
437
|
-
- nodes do not overlap or leave the canvas;
|
|
438
|
-
- edges connect the intended endpoints;
|
|
439
|
-
- arrowheads and decision labels are visible;
|
|
440
|
-
- edges do not stack, cross unnecessarily, or route through unrelated nodes;
|
|
441
|
-
- grouping, alignment, spacing, contrast, and hierarchy are clear.
|
|
445
|
+
The five required inspection passes do not consume correction retries. Allow at most **5 automatic correction retries total** across the workflow. One retry is exactly one targeted source edit → `drawio_validate` → replacement preview cycle. Count retries explicitly. At the limit, stop automatic editing, identify the unresolved category, request focused feedback, and offer `drawio_open` instead of looping.
|
|
442
446
|
|
|
443
|
-
|
|
447
|
+
### 6. Human approval and final export
|
|
444
448
|
|
|
445
|
-
|
|
449
|
+
Present the holistic preview, validation status, and reasons for any reviewed/accepted warnings. User feedback triggers a targeted edit, validation, the affected focused pass, and another holistic regression preview. Receive explicit user approval before calling `drawio_export` with `mode: "final"`.
|
|
446
450
|
|
|
447
|
-
After
|
|
451
|
+
After approval, export each requested format and page. The first successful final export automatically removes the one remaining latest preview for that source. Report:
|
|
448
452
|
|
|
449
453
|
- source `.drawio` path;
|
|
450
|
-
- validation status and retained warnings;
|
|
451
|
-
-
|
|
454
|
+
- validation status and reasons for retained reviewed warnings;
|
|
455
|
+
- focused-pass and holistic-regression outcomes;
|
|
452
456
|
- every final output path and format;
|
|
453
457
|
- whether each output embeds editable XML;
|
|
454
|
-
- any unavailable or skipped functionality.
|
|
458
|
+
- preview cleanup warnings, plus any unavailable or skipped functionality.
|
|
455
459
|
|
|
456
460
|
## Existing-diagram workflows
|
|
457
461
|
|
|
@@ -468,9 +472,9 @@ Use `drawio_validate` directly. A CLI check is unnecessary unless an export will
|
|
|
468
472
|
1. Preserve the original unless replacement was requested.
|
|
469
473
|
2. Explain and inspect the source.
|
|
470
474
|
3. Make the smallest targeted XML change.
|
|
471
|
-
4. Validate the edited source.
|
|
472
|
-
5.
|
|
473
|
-
6.
|
|
475
|
+
4. Validate the edited source and resolve/review every warning.
|
|
476
|
+
5. Rerun the affected focused preview, then a holistic regression preview.
|
|
477
|
+
6. Obtain explicit approval and export to a new path unless in-place replacement was requested.
|
|
474
478
|
|
|
475
479
|
Do not blindly edit compressed pages. The validator and explainer cannot inspect them; they must first be saved as uncompressed XML through a compatible editor.
|
|
476
480
|
|
|
@@ -487,7 +491,7 @@ Use `drawio_layout` only for XML-authored or existing native diagrams on draw.io
|
|
|
487
491
|
- `.drawio` is always the canonical editable source.
|
|
488
492
|
- Final PNG, SVG, and PDF embed XML by default and can be reopened in draw.io where supported.
|
|
489
493
|
- JPG cannot embed XML.
|
|
490
|
-
- Preview PNG is intentionally clean and unembedded for vision compatibility
|
|
494
|
+
- Preview PNG is intentionally clean and unembedded for vision compatibility. Its successful tool result includes the actual image plus a text-path fallback. Each successful replacement removes the prior same-source preview file, and final export removes the latest remaining preview.
|
|
491
495
|
- A final embedded PNG normally uses the `.drawio.png` double extension.
|
|
492
496
|
- Multi-page exports should use `pageIndex` and explicit unique output names.
|
|
493
497
|
- `drawio_explain` returns Markdown as text; it does not write a documentation file.
|
|
@@ -498,8 +502,9 @@ Use `drawio_layout` only for XML-authored or existing native diagrams on draw.io
|
|
|
498
502
|
|
|
499
503
|
- Validation cannot inspect compressed pages.
|
|
500
504
|
- Explanation cannot describe compressed pages.
|
|
501
|
-
-
|
|
502
|
-
-
|
|
505
|
+
- Deterministic validation cannot replace focused visual inspection; rendered clipping, wrapping, contrast, and automatic routes remain vision concerns.
|
|
506
|
+
- Removing a superseded preview file does not rewrite Pi session history: image blocks already stored in earlier tool-result messages can remain visible in the transcript even though only the latest preview file remains on disk.
|
|
507
|
+
- Route-through and crossing analysis is limited to edges with explicit waypoints; dense auto-routed graphs can validate without connector-route warnings.
|
|
503
508
|
- Shape search covers bundled official draw.io shapes, not arbitrary third-party logos.
|
|
504
509
|
- Mermaid conversion cannot express all draw.io styles, containers, routing, or multi-page behavior.
|
|
505
510
|
- ELK layout accepts only the six registered presets; arbitrary JSON layouts are not exposed.
|