@senad-d/drawme 0.1.2 → 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 +42 -0
- package/README.md +29 -29
- package/SECURITY.md +33 -0
- package/assets/data/SHAPE-INDEX-NOTICE.md +2 -2
- package/assets/references/diagram-types.md +7 -7
- package/assets/references/mermaid-authoring.md +50 -39
- package/assets/references/troubleshooting.md +3 -18
- package/assets/references/xml-authoring.md +29 -5
- package/docs/agent-guide.md +55 -51
- package/docs/visual-review-implementation-tasks.md +271 -0
- package/example/drawme-how-it-works.drawio +124 -0
- package/example/drawme-installation-guide.drawio +107 -0
- package/example/git-graph-example.drawio +209 -0
- package/package.json +22 -9
- package/src/dom.ts +2 -2
- package/src/drawio.ts +116 -8
- package/src/explain.ts +4 -5
- package/src/index.ts +36 -13
- package/src/png.ts +2 -3
- package/src/shapesearch.ts +6 -8
- package/src/validate.ts +517 -129
- package/src/workflow.ts +28 -14
- package/tsconfig.json +17 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format is based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
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.
|
|
17
|
+
- Refocused the documentation on DrawMe's current diagram-authoring workflow and removed obsolete
|
|
18
|
+
guidance inherited from the earlier documentation set.
|
|
19
|
+
- Improved npm and Pi gallery metadata, packaged linked diagram examples, and added a package-content
|
|
20
|
+
validation gate for releases.
|
|
21
|
+
|
|
22
|
+
## [0.0.1]
|
|
23
|
+
|
|
24
|
+
Initial release: DrawMe as a native Pi extension for authoring, validating, and exporting diagrams.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Commands: `/drawme`, `/drawme-check`, `/drawme-export`.
|
|
29
|
+
- Tools: `drawio_check`, `drawio_export`, `drawio_validate`, `drawio_shapesearch`, `drawio_from_mermaid`,
|
|
30
|
+
`drawio_layout`, `drawio_explain`, `drawio_open`.
|
|
31
|
+
- Guided seven-step `/drawme` workflow (check → plan → author → validate → preview & self-check → review
|
|
32
|
+
→ final export).
|
|
33
|
+
- Deterministic structural linter, `-e` PNG IEND repair, shape search over a bundled index, and a
|
|
34
|
+
diagram-to-Markdown describer — all pure TypeScript.
|
|
35
|
+
- draw.io binary resolution (macOS/Linux/Windows/WSL), headless-Linux `xvfb-run` handling, and
|
|
36
|
+
version-gated Mermaid conversion + ELK auto-layout (draw.io v30+).
|
|
37
|
+
- Bundled authoring references and the vendored draw.io shape index.
|
|
38
|
+
- Tooling: ESLint flat config, custom `format:check`, `check:golden` asset-integrity check, Vitest suite
|
|
39
|
+
with real-CLI integration tests, CI, SonarCloud, and release workflows.
|
|
40
|
+
|
|
41
|
+
[Unreleased]: https://github.com/senad-d/DrawMe/compare/v0.0.1...HEAD
|
|
42
|
+
[0.0.1]: https://github.com/senad-d/DrawMe/releases/tag/v0.0.1
|
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<a href="https://github.com/senad-d/DrawMe/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/senad-d/DrawMe/actions/workflows/ci.yml/badge.svg" /></a>
|
|
9
9
|
<a href="https://sonarcloud.io/summary/new_code?id=senad-d_DrawMe"><img alt="Quality Gate Status" src="https://sonarcloud.io/api/project_badges/measure?project=senad-d_DrawMe&metric=alert_status" /></a>
|
|
10
10
|
<a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" /></a>
|
|
11
|
-
<a href="#security"><img alt="network" src="https://img.shields.io/badge/network-none-brightgreen?style=flat-square" /></a>
|
|
12
11
|
</p>
|
|
13
12
|
|
|
14
13
|
<p align="center">
|
|
@@ -18,7 +17,7 @@
|
|
|
18
17
|
|
|
19
18
|
---
|
|
20
19
|
|
|
21
|
-
DrawMe is a native Pi **extension**
|
|
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.
|
|
22
21
|
|
|
23
22
|
<table align="center">
|
|
24
23
|
<tr>
|
|
@@ -32,12 +31,13 @@ DrawMe is a native Pi **extension** that exposes the diagram-authoring workflow
|
|
|
32
31
|
</table>
|
|
33
32
|
|
|
34
33
|
- **Natural-language authoring:** flowcharts, architecture, UML, BPMN, ERD, C4, network, ML — as native `.drawio`, or as Mermaid with automatic layout on v30+.
|
|
35
|
-
- **
|
|
36
|
-
- **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.
|
|
37
37
|
- **Exact shapes, not guesses:** search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
|
|
38
|
-
- **Editable source of truth:** final PNG/SVG/PDF exports embed the diagram XML,
|
|
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.
|
|
39
39
|
|
|
40
|
-
> **Security:** Pi packages run with your full system permissions. DrawMe reads
|
|
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.
|
|
41
41
|
|
|
42
42
|
## Table of Contents
|
|
43
43
|
|
|
@@ -64,8 +64,8 @@ DrawMe is a native Pi **extension** that exposes the diagram-authoring workflow
|
|
|
64
64
|
This checkout implements the DrawMe core loop as a Pi extension:
|
|
65
65
|
|
|
66
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`).
|
|
67
|
-
- A guided `/drawme` workflow that steers authoring, validation,
|
|
68
|
-
- Pure-TypeScript
|
|
67
|
+
- A guided `/drawme` workflow that steers authoring, validation after every edit, five focused visual passes, human approval, and final multi-format export.
|
|
68
|
+
- Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
|
|
69
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+).
|
|
70
70
|
- Validation pipeline: golden asset-integrity check, TypeScript typecheck, ESLint, a custom format check, and unit + real-CLI integration tests.
|
|
71
71
|
|
|
@@ -108,7 +108,7 @@ Inside Pi:
|
|
|
108
108
|
/drawme a flowchart of a user login: enter credentials, validate, then success or retry
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
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.
|
|
112
112
|
|
|
113
113
|
### Run from a source checkout
|
|
114
114
|
|
|
@@ -134,7 +134,7 @@ pi --no-extensions -e .
|
|
|
134
134
|
|
|
135
135
|
| Command | Description |
|
|
136
136
|
| --- | --- |
|
|
137
|
-
| `/drawme <description>` | Kick off
|
|
137
|
+
| `/drawme <description>` | Kick off authoring, per-edit validation, focused quality passes, holistic review, approval, and final export. |
|
|
138
138
|
| `/drawme-check` | Report whether the draw.io CLI is available, its version, and v30+ feature support. |
|
|
139
139
|
| `/drawme-export <file> [png\|svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`. |
|
|
140
140
|
|
|
@@ -145,8 +145,8 @@ Registered for the model to call directly.
|
|
|
145
145
|
| Tool | Purpose |
|
|
146
146
|
| --- | --- |
|
|
147
147
|
| `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
|
|
149
|
-
| `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. |
|
|
150
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. |
|
|
151
151
|
| `drawio_from_mermaid` | Convert Mermaid text (inline or a `.mmd`) to a native `.drawio` with automatic layout. Requires draw.io **v30+**. |
|
|
152
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+**. |
|
|
@@ -163,23 +163,26 @@ Natural-language request
|
|
|
163
163
|
└── Deliverables: .drawio source + PNG / SVG / PDF / JPG
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
The extension factory in `src/index.ts`
|
|
166
|
+
The extension factory in `src/index.ts` registers the tools and commands. Rendering, conversion, and layout launch the draw.io CLI on demand with an argument list rather than a shell; validation, shape search, and explanation run directly in the extension.
|
|
167
167
|
|
|
168
168
|
## The /drawme Workflow
|
|
169
169
|
|
|
170
|
-
`/drawme` injects a guided
|
|
170
|
+
`/drawme` injects a guided eight-step workflow that the model follows using the tools above:
|
|
171
171
|
|
|
172
172
|
1. **Check** — resolve the CLI and note the version (v30+ unlocks Mermaid conversion and ELK layout).
|
|
173
|
-
2. **Plan** — pick the diagram type,
|
|
174
|
-
3. **Author** — write editable
|
|
175
|
-
4. **Validate** —
|
|
176
|
-
5. **
|
|
177
|
-
6. **
|
|
178
|
-
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.
|
|
179
182
|
|
|
180
183
|
## Bundled References and Assets
|
|
181
184
|
|
|
182
|
-
The model reads these
|
|
185
|
+
The model reads these packaged references and assets on demand.
|
|
183
186
|
|
|
184
187
|
- `docs/agent-guide.md` — official agent-facing command, tool, option, workflow, output, and limitation reference.
|
|
185
188
|
- `assets/references/xml-authoring.md` — `.drawio` skeleton, cell/edge forms, containers, palette, spacing.
|
|
@@ -197,12 +200,9 @@ The model reads these on demand; all are network-free and ship in the package.
|
|
|
197
200
|
|
|
198
201
|
## Security
|
|
199
202
|
|
|
200
|
-
DrawMe
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
is ever sent anywhere. The source `drawio-skill` was audited before porting; its only outbound calls
|
|
204
|
-
(`aiicons.py` icon-CDN downloads and a browser-fallback URL builder) were **not** ported. See
|
|
205
|
-
[`SECURITY.md`](SECURITY.md).
|
|
203
|
+
DrawMe works with diagram files and may launch the draw.io CLI, `xvfb-run` on headless Linux, or the OS
|
|
204
|
+
file opener (`open`/`xdg-open`/`start`). Pi extensions inherit the permissions of the Pi process, so
|
|
205
|
+
install only packages you trust. See [`SECURITY.md`](SECURITY.md) for runtime and dependency details.
|
|
206
206
|
|
|
207
207
|
## Examples
|
|
208
208
|
|
|
@@ -210,12 +210,12 @@ Sample diagrams authored with DrawMe live in [`example/`](example/):
|
|
|
210
210
|
|
|
211
211
|
- [`drawme-how-it-works.drawio`](example/drawme-how-it-works.drawio) — the workflow/architecture overview shown above.
|
|
212
212
|
- [`drawme-installation-guide.drawio`](example/drawme-installation-guide.drawio) — an installation walkthrough.
|
|
213
|
-
- [`
|
|
213
|
+
- [`git-graph-example.drawio`](example/git-graph-example.drawio) — a branching release-history example.
|
|
214
214
|
|
|
215
215
|
## Development
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
|
-
npm ci --ignore-scripts #
|
|
218
|
+
npm ci --ignore-scripts # install the locked dependency set
|
|
219
219
|
npm run validate # golden check + lint + tests
|
|
220
220
|
```
|
|
221
221
|
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
> Pi packages run with your full system permissions. Only install extensions from sources you trust.
|
|
4
|
+
|
|
5
|
+
## Runtime behavior
|
|
6
|
+
|
|
7
|
+
DrawMe reads and writes diagram files requested by the user. Depending on the selected tool, it may
|
|
8
|
+
launch:
|
|
9
|
+
|
|
10
|
+
- the **draw.io desktop CLI** for conversion, layout, rendering, and export;
|
|
11
|
+
- **`xvfb-run`** for draw.io on headless Linux;
|
|
12
|
+
- the **OS file opener** (`open` / `xdg-open` / `start`) when `drawio_open` is requested.
|
|
13
|
+
|
|
14
|
+
Child processes are invoked with argument lists rather than through a shell. Shape lookup uses the
|
|
15
|
+
bundled `assets/data/shape-index.json.gz` file.
|
|
16
|
+
|
|
17
|
+
## Dependency audit
|
|
18
|
+
|
|
19
|
+
The published package depends only on `@xmldom/xmldom`, with Pi and `typebox` declared as peer
|
|
20
|
+
dependencies. It ships `src/`, `assets/`, and `docs/`.
|
|
21
|
+
|
|
22
|
+
Audit the production dependency tree with:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm audit --omit=dev
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Development dependencies are not included in the published extension. Review `package.json` and
|
|
29
|
+
`package-lock.json` for the current dependency versions and audit results.
|
|
30
|
+
|
|
31
|
+
## Reporting
|
|
32
|
+
|
|
33
|
+
Please report suspected vulnerabilities privately to the maintainer rather than opening a public issue.
|
|
@@ -8,8 +8,8 @@ libraries. Both upstream sources are licensed under the **Apache License 2.0**.
|
|
|
8
8
|
- Each entry is `{style, w, h, title, tags, type}` for one palette shape.
|
|
9
9
|
- 10,446 shapes spanning AWS, Azure, GCP, Cisco, Kubernetes, UML, BPMN, P&ID,
|
|
10
10
|
electrical, flowchart, network, and the general shape sets.
|
|
11
|
-
- Used read-only by `
|
|
12
|
-
|
|
11
|
+
- Used read-only by `drawio_shapesearch` to resolve exact official style strings instead of
|
|
12
|
+
hand-guessing them.
|
|
13
13
|
|
|
14
14
|
To refresh against a newer draw.io release, regenerate upstream with
|
|
15
15
|
`shape-search/generate-index.js` in the drawio-mcp repo, then re-gzip:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Diagram Type Presets
|
|
2
2
|
|
|
3
|
-
When the user requests a specific diagram type, apply the matching preset below for shapes, styles, and layout conventions. These presets
|
|
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
5
|
Read this file when:
|
|
6
6
|
- 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)
|
|
@@ -8,7 +8,7 @@ Read this file when:
|
|
|
8
8
|
|
|
9
9
|
## ERD (Entity-Relationship Diagram)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
For SQL DDL, derive tables, primary keys, foreign keys, and crow's-foot relations from the schema before authoring. Mermaid ER conversion is suitable for a standard ERD on draw.io 30+; use XML with the styles below when exact table styling or placement is required.
|
|
12
12
|
|
|
13
13
|
| Element | Style | Notes |
|
|
14
14
|
|---------|-------|-------|
|
|
@@ -32,7 +32,7 @@ Read this file when:
|
|
|
32
32
|
|
|
33
33
|
## Sequence Diagram
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
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.
|
|
36
36
|
|
|
37
37
|
| Element | Style | Notes |
|
|
38
38
|
|---------|-------|-------|
|
|
@@ -45,7 +45,7 @@ Read this file when:
|
|
|
45
45
|
|
|
46
46
|
## C4 Model (System Context / Container / Component)
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
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:
|
|
49
49
|
|
|
50
50
|
| Element | Style | Notes |
|
|
51
51
|
|---------|-------|-------|
|
|
@@ -93,7 +93,7 @@ For neural network architecture diagrams — ideal for papers targeting NeurIPS,
|
|
|
93
93
|
|
|
94
94
|
## SysML (Block Definition / Internal Block / Requirement / Parametric)
|
|
95
95
|
|
|
96
|
-
draw.io ships a native SysML 1.x shape library (`mxgraph.sysml.*`, ~60 shapes)
|
|
96
|
+
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.
|
|
97
97
|
|
|
98
98
|
### Block Definition Diagram (bdd)
|
|
99
99
|
|
|
@@ -139,7 +139,7 @@ draw.io ships a native SysML 1.x shape library (`mxgraph.sysml.*`, ~60 shapes)
|
|
|
139
139
|
|
|
140
140
|
## BPMN (Business Process)
|
|
141
141
|
|
|
142
|
-
draw.io ships ~200 native BPMN 2.0 shapes (`mxgraph.bpmn.*`). The official styles carry a long `points=[...]` connection-point list —
|
|
142
|
+
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.
|
|
143
143
|
|
|
144
144
|
| Element | Style | Notes |
|
|
145
145
|
|---------|-------|-------|
|
|
@@ -160,7 +160,7 @@ draw.io ships ~200 native BPMN 2.0 shapes (`mxgraph.bpmn.*`). The official style
|
|
|
160
160
|
|
|
161
161
|
## Network Topology
|
|
162
162
|
|
|
163
|
-
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),
|
|
163
|
+
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.
|
|
164
164
|
|
|
165
165
|
Shared prefix (every node below): `fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;`
|
|
166
166
|
|
|
@@ -1,56 +1,67 @@
|
|
|
1
1
|
# Mermaid authoring → native .drawio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use Mermaid when the diagram is a standard type with no custom styling requirements and the draw.io
|
|
4
|
+
CLI is version 30 or newer. Mermaid keeps the input focused on structure while draw.io supplies the
|
|
5
|
+
initial layout.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Call `drawio_check` first, then convert with:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
drawio_from_mermaid({
|
|
11
|
+
"mermaid": "flowchart LR\n A[Client] --> B[Service]",
|
|
12
|
+
"output": "diagram.drawio"
|
|
13
|
+
})
|
|
9
14
|
```
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
On draw.io 29 or older, skip Mermaid conversion and author uncompressed `.drawio` XML instead.
|
|
12
17
|
|
|
13
|
-
## When to prefer
|
|
18
|
+
## When to prefer each authoring mode
|
|
14
19
|
|
|
15
20
|
| Author as | Best for | Why |
|
|
16
21
|
|---|---|---|
|
|
17
|
-
| **Mermaid →
|
|
18
|
-
| **XML
|
|
19
|
-
| **
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
22
|
+
| **Mermaid → `drawio_from_mermaid`** | Flowchart, sequence, class, state, ER, gantt, mind map, timeline, journey, and similar standard diagrams | Concise structure and automatic initial layout |
|
|
23
|
+
| **Uncompressed XML** | Official vendor icons, exact UML/BPMN notation, custom styling, swimlanes, containers, precise routing, or multi-page output | Full control over draw.io cells, styles, geometry, and pages |
|
|
24
|
+
| **XML → `drawio_layout`** | Large or graph-heavy hand-authored diagrams | Repositions nodes and routes edges with an allowlisted ELK preset |
|
|
25
|
+
|
|
26
|
+
If the user requests Mermaid source rather than a `.drawio` deliverable, do not convert it unless they
|
|
27
|
+
also ask for a draw.io file.
|
|
28
|
+
|
|
29
|
+
## Mermaid quirks that matter for draw.io conversion
|
|
30
|
+
|
|
31
|
+
- The first non-directive line selects the diagram type. Common headers include `flowchart TD`,
|
|
32
|
+
`sequenceDiagram`, `classDiagram`, `stateDiagram-v2`, `erDiagram`, `gantt`, `mindmap`, `timeline`,
|
|
33
|
+
`journey`, `pie`, `gitGraph`, and `c4Context`.
|
|
34
|
+
- Node IDs are identifiers such as `A` or `node_1`. Put display text in brackets or quotes and avoid
|
|
35
|
+
reserved words such as `end`, `class`, and `subgraph`.
|
|
36
|
+
- Keep one statement per line. Quote labels containing punctuation or non-ASCII text.
|
|
37
|
+
- Only `<br>`, `<b>`, `<i>`, and `<u>` are consistently reliable in labels; prefer hex colors.
|
|
38
|
+
- Style a node with `style A fill:#f9f,stroke:#333`, reusable classes with `classDef`, and edges with
|
|
39
|
+
`linkStyle`.
|
|
33
40
|
- Match label language to the user's language.
|
|
41
|
+
- Never apply `drawio_layout` to a Mermaid-converted file; conversion already lays it out.
|
|
34
42
|
|
|
35
|
-
After
|
|
43
|
+
After conversion, treat the `.drawio` as the source of truth. Validate it, export a preview, inspect the
|
|
44
|
+
result, and then create the requested final exports.
|
|
36
45
|
|
|
37
|
-
## ELK
|
|
46
|
+
## ELK layout for XML-authored diagrams
|
|
38
47
|
|
|
39
|
-
For XML
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# in-place re-layout (reading and overwriting the same path is supported)
|
|
43
|
-
drawio -x -f xml --layout verticalFlow -o diagram.drawio diagram.drawio
|
|
44
|
-
# or layout + export in one call
|
|
45
|
-
drawio -x -f png -e -b 10 --layout verticalFlow -o diagram.drawio.png diagram.drawio
|
|
46
|
-
```
|
|
48
|
+
For rough XML geometry on draw.io 30 or newer, use `drawio_layout` with one of these presets:
|
|
47
49
|
|
|
48
50
|
| Preset | Layout |
|
|
49
51
|
|---|---|
|
|
50
|
-
| `verticalFlow` / `horizontalFlow` |
|
|
51
|
-
| `verticalTree` / `horizontalTree`
|
|
52
|
-
| `
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
| `verticalFlow` / `horizontalFlow` | Layered flowcharts and pipelines |
|
|
53
|
+
| `verticalTree` / `horizontalTree` | Hierarchies and organization charts |
|
|
54
|
+
| `radialTree` | Trees arranged around a center |
|
|
55
|
+
| `organic` | Force-directed topologies and mind maps |
|
|
56
|
+
|
|
57
|
+
Use a distinct output path to preserve the rough source unless in-place replacement was requested:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
drawio_layout({
|
|
61
|
+
"input": "diagram-rough.drawio",
|
|
62
|
+
"preset": "horizontalFlow",
|
|
63
|
+
"output": "diagram.drawio"
|
|
64
|
+
})
|
|
65
|
+
```
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
Continue with the layout tool's returned path and validate it again.
|
|
@@ -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
|
|
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) |
|
|
@@ -24,10 +24,9 @@ Read this when something looks wrong in the output (rendering, export, layout, e
|
|
|
24
24
|
| PDF export fails | Ensure Chromium is available (draw.io bundles it on desktop) |
|
|
25
25
|
| Background color wrong in CLI export | Known CLI bug; add `--transparent` flag or set background via style |
|
|
26
26
|
| Vision returns 400 "Could not process image" on draft PNG | Re-export the preview without `-e` (issue #8). Root cause is a truncated IEND chunk in `-e` PNGs, not the `zTXt` chunk itself — but skipping `-e` for the preview is the simplest fix. |
|
|
27
|
-
| Final
|
|
27
|
+
| Final embedded PNG won't open in image viewers | Export it again with `drawio_export` in final mode. The tool automatically repairs draw.io's truncated IEND chunk. SVG/PDF are unaffected. |
|
|
28
28
|
| WSL2: `drawio` / `draw.io` not found | The CLI lives on the Windows side. Use the Windows desktop exe via `/mnt/c`: `"/mnt/c/Program Files/draw.io/draw.io.exe"` (or per-user `"/mnt/c/Users/<you>/AppData/Local/Programs/draw.io/draw.io.exe"`). |
|
|
29
29
|
| WSL2: opening an exported file fails with a `/mnt/c/...`-style path | `cmd.exe` can't resolve WSL paths — convert first: `cmd.exe /c start "" "$(wslpath -w diagram.drawio.png)"`. The empty `""` after `start` is the (required) window title. |
|
|
30
|
-
| Browser URL opens to a blank/empty diagram (Windows/WSL2) | `cmd.exe`'s `start` treats `&` as a separator and drops everything after `#` — so the `#R…`/`#create=…` fragment (the whole diagram) is lost. Never pass the URL straight to `start`. Write a `.url` shortcut file and open *that* (see "WSL2 / Windows" below). |
|
|
31
30
|
|
|
32
31
|
## WSL2 / Windows specifics
|
|
33
32
|
|
|
@@ -47,17 +46,3 @@ follow `/mnt/c/...`:
|
|
|
47
46
|
```bash
|
|
48
47
|
cmd.exe /c start "" "$(wslpath -w diagram.drawio.png)"
|
|
49
48
|
```
|
|
50
|
-
|
|
51
|
-
**Open a browser-fallback URL.** `cmd.exe /c start` strips the URL fragment
|
|
52
|
-
(`&` ends the command, `#…` is dropped) — and the fragment carries the entire
|
|
53
|
-
diagram. Write a `.url` shortcut and open it instead, so the URL survives intact:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
URL=$(python3 <this-skill-dir>/scripts/encode_drawio_url.py --edit diagram.drawio)
|
|
57
|
-
TMP=$(mktemp --suffix=.url)
|
|
58
|
-
printf '[InternetShortcut]\r\nURL=%s\r\n' "$URL" > "$TMP"
|
|
59
|
-
cmd.exe /c start "" "$(wslpath -w "$TMP")"
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
On native Windows the same `.url`-file trick applies (`start "" "%TEMP%\d.url"`).
|
|
63
|
-
On macOS/Linux just `open "$URL"` / `xdg-open "$URL"` — no workaround needed.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Authoring .drawio XML
|
|
2
2
|
|
|
3
|
-
Read this **before hand-writing any `.drawio` XML** (workflow step 3). Skip it when
|
|
3
|
+
Read this **before hand-writing any `.drawio` XML** (workflow step 3). Skip it when `drawio_from_mermaid` creates the source for you.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### File skeleton
|
|
@@ -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
|
|
|
@@ -41,7 +64,7 @@ Read this **before hand-writing any `.drawio` XML** (workflow step 3). Skip it w
|
|
|
41
64
|
| `shape=cylinder3;` | cylinder — databases |
|
|
42
65
|
| `swimlane;` | group/container with title bar |
|
|
43
66
|
|
|
44
|
-
For **vendor/branded icons** (AWS/Azure/GCP/Cisco/Kubernetes) and any non-trivial shape, don't guess the `shape=mxgraph.*` name — a wrong name renders as a blank box.
|
|
67
|
+
For **vendor/branded icons** (AWS/Azure/GCP/Cisco/Kubernetes) and any non-trivial shape, don't guess the `shape=mxgraph.*` name — a wrong name renders as a blank box. Call `drawio_shapesearch` with specific vendor and component keywords, then copy the returned official style and recommended dimensions. If the bundled index has no suitable logo, use a clearly labeled standard shape or ask the user for an image asset.
|
|
45
68
|
|
|
46
69
|
### Required properties
|
|
47
70
|
|
|
@@ -118,10 +141,10 @@ For architecture diagrams with nested elements, use draw.io's parent-child conta
|
|
|
118
141
|
**Edge style rules:**
|
|
119
142
|
- **Animated connectors:** add `flowAnimation=1;` to any edge style to show a moving dot animation along the arrow. Works in SVG export and draw.io desktop — ideal for data-flow and pipeline diagrams. Example: `style="edgeStyle=orthogonalEdgeStyle;flowAnimation=1;rounded=1;..."`
|
|
120
143
|
- **Always** include `rounded=1;orthogonalLoop=1;jettySize=auto` — these enable smart routing that avoids overlaps
|
|
121
|
-
- Pin `exitX/exitY/entryX/entryY` on every edge when a node has 2+ connections
|
|
144
|
+
- Pin `exitX/exitY/entryX/entryY` on every edge when a node has 2+ connections. Pick the side facing each peer and spread that side's edges over evenly spaced slots so they do not stack or cross at the boundary.
|
|
122
145
|
- Add `<Array as="points">` waypoints when an edge must detour around an intermediate shape
|
|
123
146
|
- **Leave room for arrowheads:** the final straight segment between the last bend and the target shape must be ≥20px long. If too short, the arrowhead overlaps the bend and looks broken. Fix by increasing node spacing or adding explicit waypoints
|
|
124
|
-
- **
|
|
147
|
+
- **Obstacle-avoiding routing (draw.io ≥ 30):** the desktop editor can recompute connectors around shapes without moving nodes. This is an interactive editor feature, not a `drawio_layout` preset. If a dense diagram still has crossings after preview, offer to open the `.drawio` in draw.io desktop for manual routing.
|
|
125
148
|
|
|
126
149
|
### Distributing connections on a shape
|
|
127
150
|
|
|
@@ -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
|