@senad-d/drawme 0.1.4 → 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 +54 -0
- package/README.md +27 -20
- package/assets/references/diagram-types.md +24 -0
- package/assets/references/troubleshooting.md +2 -2
- package/assets/references/xml-authoring.md +33 -9
- package/docs/{agent-guide.md → reference.md} +47 -126
- package/docs/visual-review-implementation-tasks.md +1 -1
- package/example/drawme-extension-waterfall-overview.drawio +72 -0
- package/example/drawme-how-it-works.drawio +124 -80
- package/example/drawme-installation-guide.drawio +95 -67
- package/example/drawme-validation-decision-tree.drawio +210 -0
- package/package.json +1 -1
- package/src/drawio.ts +12 -3
- package/src/fitcanvas.ts +172 -0
- package/src/geometry.ts +259 -0
- package/src/index.ts +94 -14
- package/src/validate.ts +18 -225
- package/src/workflow.ts +89 -32
package/CHANGELOG.md
CHANGED
|
@@ -6,8 +6,62 @@ All notable changes to this project are documented here. The format is based on
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- New `drawio_fit_canvas` tool: deterministically resizes each page's canvas to its visible content plus
|
|
12
|
+
a margin (default 40px) and shifts content to the margin origin — the fix for cramped pages where
|
|
13
|
+
elements overlap because they were squeezed into a too-small canvas. The workflow now defers page
|
|
14
|
+
dimensions until content exists (author with generous spacing → fit the canvas), and validation/docs
|
|
15
|
+
direct overlap and bounds findings to "spread elements, then refit" instead of shrinking content.
|
|
16
|
+
Shared `.drawio` geometry moved into `src/geometry.ts`.
|
|
17
|
+
|
|
9
18
|
### Changed
|
|
10
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.
|
|
41
|
+
- `/drawme` now pre-loads its context: the command handler resolves the draw.io CLI itself and embeds the
|
|
42
|
+
check result plus the diagram-types, XML-authoring, and (v30+) Mermaid references directly into the
|
|
43
|
+
injected workflow message. The references remain editable Markdown files under `assets/references/`;
|
|
44
|
+
they are just no longer read via tool calls at run start. Only the rarely needed troubleshooting
|
|
45
|
+
reference stays on-demand.
|
|
46
|
+
|
|
47
|
+
- `drawio_export` previews are now vision-aware: the PNG image block is attached only when the active
|
|
48
|
+
model can view images (checked per call via the extension context, failing open for unknown models),
|
|
49
|
+
the result text always states whether it was attached, and `details.imageAttached` reports the outcome.
|
|
50
|
+
- Replaced the five mandatory visual passes with a critique-first review: one holistic preview with a
|
|
51
|
+
structured all-category critique, focused re-previews only for categories with findings, and a final
|
|
52
|
+
holistic confirmation. Models that cannot view images get an explicit structural-review path
|
|
53
|
+
(`drawio_validate` + `drawio_explain`) instead of a silent image placeholder.
|
|
54
|
+
- Rewrote the packaged extension reference and workflow text in second person without agent terminology.
|
|
55
|
+
- The `/drawme` run is now fully autonomous: the human approval gate before final export is removed.
|
|
56
|
+
After the holistic confirmation (or on hitting the five-retry correction limit, reporting the unresolved
|
|
57
|
+
finding), the workflow proceeds straight to final export; mid-run user feedback is treated as new
|
|
58
|
+
critique findings rather than a pause point. Docs, packaged troubleshooting guidance, and the example
|
|
59
|
+
diagrams were updated to match, and the golden asset baseline was intentionally refreshed.
|
|
60
|
+
- The `/drawme` workflow no longer instructs a mandatory reference read: the injected message plus the
|
|
61
|
+
registered tool descriptions are self-contained (the failure-text and compressed-page rules moved into
|
|
62
|
+
them), saving a file read and several thousand tokens per run. `docs/agent-guide.md` became
|
|
63
|
+
`docs/reference.md`, a pure command/tool catalog for other projects; topic references under
|
|
64
|
+
`assets/references/` are still read on demand.
|
|
11
65
|
- Added focused visual quality passes, stronger deterministic canvas/edge/readability checks, attached PNG
|
|
12
66
|
previews, warning-resolution gates, and explicit approval before final export.
|
|
13
67
|
- Intentionally re-baselined the golden asset hash after adding finite-page sizing, typography, preview
|
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 every source revision,
|
|
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, critiques the rendered preview when the active model can view images, and exports the final deliverable — fully autonomously, with no human intervention once started.
|
|
21
21
|
|
|
22
22
|
<table align="center">
|
|
23
23
|
<tr>
|
|
@@ -28,12 +28,17 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
|
|
|
28
28
|
<img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/drawme-how-it-works.drawio.png" alt="DrawMe: from a prompt to an editable diagram" title="DrawMe" width="820">
|
|
29
29
|
</td>
|
|
30
30
|
</tr>
|
|
31
|
+
<tr>
|
|
32
|
+
<td align="center">
|
|
33
|
+
<img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/drawme-installation-guide.drawio.png" alt="DrawMe: Installation guide" title="DrawMe" width="820">
|
|
34
|
+
</td>
|
|
35
|
+
</tr>
|
|
31
36
|
</table>
|
|
32
37
|
|
|
33
38
|
- **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,
|
|
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.
|
|
35
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.
|
|
36
|
-
- **
|
|
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.
|
|
37
42
|
- **Exact shapes, not guesses:** search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
|
|
38
43
|
- **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.
|
|
39
44
|
|
|
@@ -42,7 +47,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
|
|
|
42
47
|
## Table of Contents
|
|
43
48
|
|
|
44
49
|
- [Implementation Status](#implementation-status)
|
|
45
|
-
- [
|
|
50
|
+
- [Extension Reference](#extension-reference)
|
|
46
51
|
- [Quick Start](#quick-start)
|
|
47
52
|
- [Installation](#installation)
|
|
48
53
|
- [Commands](#commands)
|
|
@@ -63,15 +68,15 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
|
|
|
63
68
|
|
|
64
69
|
This checkout implements the DrawMe core loop as a Pi extension:
|
|
65
70
|
|
|
66
|
-
-
|
|
67
|
-
- A guided `/drawme` workflow that steers authoring, validation after every edit,
|
|
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 gated multi-pass visual review, and autonomous final multi-format export.
|
|
68
73
|
- Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
|
|
69
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+).
|
|
70
75
|
- Validation pipeline: golden asset-integrity check, TypeScript typecheck, ESLint, a custom format check, and unit + real-CLI integration tests.
|
|
71
76
|
|
|
72
|
-
##
|
|
77
|
+
## Extension Reference
|
|
73
78
|
|
|
74
|
-
[`docs/
|
|
79
|
+
[`docs/reference.md`](docs/reference.md) catalogs the extension's public surface — every command, tool option, default, output behavior, and functional limitation — for other projects and integrations that use DrawMe. It is documentation, not runtime input: the `/drawme` workflow and the registered tool descriptions carry the complete operational instructions themselves.
|
|
75
80
|
|
|
76
81
|
## Quick Start
|
|
77
82
|
|
|
@@ -108,7 +113,7 @@ Inside Pi:
|
|
|
108
113
|
/drawme a flowchart of a user login: enter credentials, validate, then success or retry
|
|
109
114
|
```
|
|
110
115
|
|
|
111
|
-
Pi checks the CLI, plans and writes the `.drawio`, validates every revision,
|
|
116
|
+
Pi checks the CLI, plans and writes the `.drawio`, validates every revision, critiques the rendered preview when the active model can view images (or reviews structurally when it cannot), and exports the final editable deliverable — all in one run, without asking for approval along the way.
|
|
112
117
|
|
|
113
118
|
### Run from a source checkout
|
|
114
119
|
|
|
@@ -134,7 +139,7 @@ pi --no-extensions -e .
|
|
|
134
139
|
|
|
135
140
|
| Command | Description |
|
|
136
141
|
| --- | --- |
|
|
137
|
-
| `/drawme <description>` | Kick off authoring, per-edit validation,
|
|
142
|
+
| `/drawme <description>` | Kick off authoring, per-edit validation, the gated multi-pass visual review, and autonomous final export. |
|
|
138
143
|
| `/drawme-check` | Report whether the draw.io CLI is available, its version, and v30+ feature support. |
|
|
139
144
|
| `/drawme-export <file> [png\|svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`. |
|
|
140
145
|
|
|
@@ -145,8 +150,9 @@ Registered for the model to call directly.
|
|
|
145
150
|
| Tool | Purpose |
|
|
146
151
|
| --- | --- |
|
|
147
152
|
| `drawio_check` | Resolve the draw.io binary, version, and whether it supports Mermaid import / `--layout` (v30+). |
|
|
148
|
-
| `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `mode:"preview"` → clean width-capped PNG returned as text/metadata
|
|
153
|
+
| `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `mode:"preview"` → clean width-capped PNG returned as text/metadata, with the image block attached when the active model can view images (the text states which); 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
154
|
| `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. |
|
|
155
|
+
| `drawio_fit_canvas` | Fit each page's canvas to its content plus a margin (default 40px): grows cramped pages, tightens oversized ones, and shifts content to the margin origin — instead of shrinking or cramming elements. Deterministic, no CLI. |
|
|
150
156
|
| `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. |
|
|
151
157
|
| `drawio_from_mermaid` | Convert Mermaid text (inline or a `.mmd`) to a native `.drawio` with automatic layout. Requires draw.io **v30+**. |
|
|
152
158
|
| `drawio_layout` | Re-place nodes / route edges with an ELK preset (`verticalFlow`, `horizontalFlow`, `verticalTree`, `horizontalTree`, `radialTree`, `organic`) for large graphs. Requires draw.io **v30+**. |
|
|
@@ -167,24 +173,25 @@ The extension factory in `src/index.ts` registers the tools and commands. Render
|
|
|
167
173
|
|
|
168
174
|
## The /drawme Workflow
|
|
169
175
|
|
|
170
|
-
`/drawme` injects a guided
|
|
176
|
+
`/drawme` injects a guided nine-step workflow that the model follows using the tools above:
|
|
171
177
|
|
|
172
|
-
1. **Check** —
|
|
178
|
+
1. **Check** — the command itself resolves the CLI and embeds the result plus the authoring references into the workflow message (v30+ unlocks Mermaid conversion and ELK layout), so the run starts with everything in context — no upfront tool calls or file reads.
|
|
173
179
|
2. **Plan** — pick the diagram type, relationships, finite canvas, and layout direction.
|
|
174
180
|
3. **Author** — write editable uncompressed XML (or Mermaid on v30+), using exact searched shapes and optional ELK layout.
|
|
175
181
|
4. **Validate after every edit** — fix all errors; fix each warning or record why it is reviewed and acceptable.
|
|
176
|
-
5. **
|
|
177
|
-
6. **
|
|
178
|
-
7. **
|
|
179
|
-
8. **
|
|
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
|
+
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 (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.
|
|
180
187
|
|
|
181
|
-
Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, and conservative font/wrapping cases.
|
|
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.
|
|
182
189
|
|
|
183
190
|
## Bundled References and Assets
|
|
184
191
|
|
|
185
|
-
|
|
192
|
+
These stay plain Markdown files for easy editing. `/drawme` embeds the diagram-types, XML-authoring, and (on v30+) Mermaid references directly into its workflow message, so the model starts with them in context; the troubleshooting reference is read on demand when an export fails.
|
|
186
193
|
|
|
187
|
-
- `docs/
|
|
194
|
+
- `docs/reference.md` — catalog of commands, tool options, defaults, output behavior, and limitations (documentation only; not read at runtime).
|
|
188
195
|
- `assets/references/xml-authoring.md` — `.drawio` skeleton, cell/edge forms, containers, palette, spacing.
|
|
189
196
|
- `assets/references/diagram-types.md` — per-type presets (ERD, UML, sequence, C4, architecture, ML, flowchart, SysML, BPMN, network, swimlane).
|
|
190
197
|
- `assets/references/mermaid-authoring.md` — Mermaid authoring for the v30+ conversion path.
|
|
@@ -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 `
`.
|
|
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: `«block»` (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 `«`); 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.
|
|
@@ -10,10 +10,10 @@ Read this when something looks wrong in the output (rendering, export, layout, e
|
|
|
10
10
|
| `--` inside XML comments | Illegal per XML spec — use single hyphens or rephrase |
|
|
11
11
|
| Special characters in `value` | Use XML entities: `&` `<` `>` `"` |
|
|
12
12
|
| Literal `\n` in label text | Use `
` for line breaks in `value` attributes |
|
|
13
|
-
| Overlapping shapes | Scale spacing with complexity (200–350px)
|
|
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 |
|
|
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. |
|
|
@@ -33,15 +33,11 @@ Read this **before hand-writing any `.drawio` XML** (workflow step 3). Skip it w
|
|
|
33
33
|
|
|
34
34
|
### Canvas sizing and content bounds
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
The page follows from the layout, never the reverse: author elements with generous spacing first, then run `drawio_fit_canvas` to resize `pageWidth`/`pageHeight` to the visible content plus a margin (default 40px) and shift content to the margin origin. Run it again after every move, resize, container change, layout pass, legend addition, or waypoint edit, and treat each run as a source edit to validate.
|
|
37
37
|
|
|
38
|
-
|
|
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.
|
|
38
|
+
When elements overlap or cannot fit, do not shrink or cram them to preserve the current page: move them apart with proper spacing and refit the canvas so the page grows around them. The reverse problem — a page much larger than content — creates unreadable full-diagram previews and an excessive-empty-space warning; the same fit run tightens it.
|
|
43
39
|
|
|
44
|
-
|
|
40
|
+
Background for manual sizing (what the fit computes): visible top-level vertex/container rectangles as `(x, y, x + width, y + height)` with ancestor container offsets added for nested children, expanded by separately sized edge labels and explicit waypoints; content shifted so minimum `x`/`y` sit at the margin (DrawMe warns below the **20px minimum**); `pageWidth`/`pageHeight` set to the bounds plus the margin on each side. Automatic edge routes still need preview inspection, and invisible helpers or intentional relative border ports never count as page-extending content.
|
|
45
41
|
|
|
46
42
|
### Typography, padding, and labels
|
|
47
43
|
|
|
@@ -50,7 +46,35 @@ Example: content spanning `x=40..1160` and `y=40..720` should normally use `page
|
|
|
50
46
|
- 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
47
|
- 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
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.
|
|
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;
|
|
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
|
+
|
|
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 `
` 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
|
+
```
|
|
54
78
|
|
|
55
79
|
### Shape types (vertex)
|
|
56
80
|
|
|
@@ -210,7 +234,7 @@ Rules: swatch colors come from the active palette (preset or the table above) wi
|
|
|
210
234
|
**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.
|
|
211
235
|
|
|
212
236
|
**General rules:**
|
|
213
|
-
-
|
|
237
|
+
- Run `drawio_fit_canvas` after every layout change so `pageWidth`/`pageHeight` track the content; it keeps the recommended 40px outer margin (DrawMe warns below the 20px minimum)
|
|
214
238
|
- Plan a grid before assigning x/y coordinates — sketch node positions on paper/mentally first
|
|
215
239
|
- Group related nodes in the same horizontal or vertical band
|
|
216
240
|
- Use `swimlane` cells for logical grouping with visible borders
|