@senad-d/drawme 0.1.11 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,11 +6,30 @@ All notable changes to this project are documented here. The format is based on
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Changed
10
+
11
+ - `/drawme` guides Pi to read relevant implementation sources before drawing and check the result against them. The bundled purpose guide helps choose and review a composition for an architecture overview, request flow, data model, deployment, or user flow. The reply identifies key sources and any gaps instead of filling them with guesses.
12
+
13
+ ### Fixed
14
+
15
+ - Explicit raster sizes are now subject to the 6,000,000-pixel budget, including the border. `drawio_export` exposes `width` only; `height` is internal. See the [export reference](docs/reference.md#drawio_export) for format-specific sizing.
16
+
17
+ ## [0.3.0] - 2026-12-02
18
+
19
+ - The README now illustrates how a prompt becomes an editable diagram and shareable exports, with the image and source included in the package.
20
+ - The package now includes a testing guide listing repository checks, their commands, and what they verify.
21
+ - DrawMe grounds code diagrams in relevant source and offers layouts tailored to five diagram purposes.
22
+
23
+ ## [0.2.0] - 2026-12-01
24
+
25
+ - Linux rendering requires an unprivileged user, explicit page selection requires draw.io 32.4.1 or later, and nondefault animation outputs use page-specific storyboard names.
26
+ - The five tools no longer accept a `binary` option; set `DRAWME_DRAWIO_BINARY` in Pi’s launch environment for a custom CLI, and use the desktop opener only for supported documents. `drawio_animate` rejects an exported SVG instead of reporting verified flow when a declared connector is missing or lacks the native animation marker.
27
+
9
28
  ## [0.1.11] - 2026-11-09
10
29
 
11
30
  ### Fixed
12
31
 
13
- - Final PNG/JPG exports use the selected page's content width and height to lower the raster scale when needed, targeting a six-million-pixel budget to avoid draw.io `UnknownVizError` failures. Explicit width and height requests remain unchanged.
32
+ - Final PNG/JPG exports use the selected page's content width and height to lower the raster scale when needed, targeting a six-million-pixel budget to avoid draw.io `UnknownVizError` failures. That release left explicit sizing requests unchanged; only width was exposed by the registered tool.
14
33
 
15
34
  ## [0.1.10] - 2026-10-27
16
35
 
package/README.md CHANGED
@@ -12,12 +12,14 @@
12
12
 
13
13
  <p align="center">
14
14
  Natural-language diagrams for <a href="https://pi.dev">pi</a>.
15
- <br />Turns a description into editable <code>.drawio</code> XML and exports it to PNG / SVG / PDF / JPG, including verified standalone animated SVG — entirely on your machine.
15
+ <br />Turns a description into editable <code>.drawio</code> XML and exports it to PNG / SVG / PDF / JPG, including verified standalone animated SVG, with local rendering.
16
16
  </p>
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, critiques the rendered preview when the active model can view images, and exports the final deliverable — fully autonomously, with no human intervention once started.
20
+ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram and Pi plans it, writes editable `.drawio` XML (or Mermaid when the CLI supports conversion), 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
+
22
+ > **Privacy:** DrawMe renders diagrams locally. Your request, project source that Pi reads during authoring, and any attached preview or storyboard images may enter Pi's model context and be sent to your configured hosted model provider. A text-only model, or one whose image support is unknown, gets no image attachment.
21
23
 
22
24
  <table align="center">
23
25
  <tr>
@@ -35,13 +37,13 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
35
37
  </tr>
36
38
  </table>
37
39
 
38
- - **Natural-language authoring:** flowcharts, architecture, UML, BPMN, ERD, C4, network, ML — as native `.drawio`, or as Mermaid with automatic layout on v30+.
40
+ - **Natural-language authoring:** flowcharts, architecture, UML, BPMN, ERD, C4, network, ML — as native `.drawio`, or as Mermaid with automatic layout on supported renderers.
39
41
  - **Guided workflow:** CLI detection, planning, authoring, validation, a gated multi-pass visual review (fit/sizing → element placement → connections → holistic confirmation), and final export run end to end from a single `/drawme` — no approval pauses.
40
42
  - **Deterministic validation:** a structural linter catches dangling edges, duplicate/reserved ids, malformed geometry, page/container overflow, inadequate margins, conservative readability defects, overlaps, and explicit edge-routing defects before you look at a pixel.
41
- - **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.
43
+ - **Vision-aware previews:** verified PNG previews attach an image only when the active model can view it. Otherwise, review is structural. An image in the transcript is not a promise that its preview file remains on disk.
42
44
  - **Exact shapes, not guesses:** search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
43
45
  - **Animated SVG:** pop/slide entrances, connector draw-in, travelling dots, highlights, staggered cascades, persistent connector flow, and portable page sequences export as verified standalone SVG animation, with a storyboard, reduced-motion handling, and a static PNG fallback.
44
- - **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.
46
+ - **Editable source of truth:** final PNG/SVG/PDF exports embed the diagram XML by default (JPG never does). DrawMe can repair an otherwise valid PNG with a truncated end chunk.
45
47
 
46
48
  > **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.
47
49
 
@@ -72,8 +74,8 @@ This checkout implements the DrawMe core loop as a Pi extension:
72
74
  - Ten model-callable tools (`drawio_check`, `drawio_export`, `drawio_animate`, `drawio_validate`, `drawio_fit_canvas`, `drawio_shapesearch`, `drawio_from_mermaid`, `drawio_layout`, `drawio_explain`, `drawio_open`) and three commands (`/drawme`, `/drawme-check`, `/drawme-export`).
73
75
  - A guided `/drawme` workflow that steers authoring, validation after every edit, a gated multi-pass visual review, and autonomous final multi-format export.
74
76
  - Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
75
- - 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+).
76
- - Validation pipeline: golden asset-integrity check, TypeScript typecheck, ESLint, a custom format check, and unit + real-CLI integration tests.
77
+ - Native draw.io binary resolution across macOS/Linux/Windows/WSL, headless-Linux `xvfb-run` handling, and version-gated Mermaid conversion and ELK auto-layout.
78
+ - Development gate: golden asset check, lint (including type and format checks), tests, and package contents check.
77
79
 
78
80
  ## Extension Reference
79
81
 
@@ -133,7 +135,7 @@ pi --no-extensions -e .
133
135
  | Global | `pi install npm:@senad-d/drawme` | Loads in every trusted Pi project. |
134
136
  | Project-local | `pi install npm:@senad-d/drawme -l` | Writes to `.pi/settings.json` in the current project. |
135
137
  | One run | `pi -e npm:@senad-d/drawme` | Try without changing settings. |
136
- | Git | `pi install git:senad-d/DrawMe` | Install from Git; pin a tag or commit for a fixed version. |
138
+ | Git | `pi install git:github.com/senad-d/DrawMe` | Install from Git; pin a tag or commit for a fixed version. |
137
139
  | Local checkout | `pi --no-extensions -e .` | Develop or test this repository. |
138
140
 
139
141
  ## Commands
@@ -141,8 +143,8 @@ pi --no-extensions -e .
141
143
  | Command | Description |
142
144
  | --- | --- |
143
145
  | `/drawme <description>` | Kick off authoring, per-edit validation, the gated multi-pass visual review, and autonomous final export. |
144
- | `/drawme-check` | Report whether the draw.io CLI is available, its version, and v30+ feature support. |
145
- | `/drawme-export <file> [png\|svg\|animated-svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`; `animated-svg` requires and verifies motion. |
146
+ | `/drawme-check` | Report the detected CLI path, version, and Mermaid import and `--layout` support, or explain why the CLI is unavailable. |
147
+ | `/drawme-export <file> [png\|svg\|animated-svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`. `animated-svg` verifies native connector flow or a portable native page sequence. For stored DrawMe motion, use `drawio_animate` with `input` and omit `steps`. |
146
148
 
147
149
  ## Tools
148
150
 
@@ -150,26 +152,22 @@ Registered for the model to call directly.
150
152
 
151
153
  | Tool | Purpose |
152
154
  | --- | --- |
153
- | `drawio_check` | Resolve the draw.io binary, version, and whether it supports Mermaid import / `--layout` (v30+). |
154
- | `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `animated:true` requires a final SVG, preserves connector flow, compiles portable page sequences, and verifies that the result actually contains animation. `mode:"preview"` → clean width-capped static 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. |
155
- | `drawio_animate` | Add motion to an existing page (pop and slide entrances, connector draw-in, travelling dots, highlights, dimming, staggered cascades) from typed steps, store it on the page, and export a verified animated SVG plus a storyboard PNG of each step. |
155
+ | `drawio_check` | Resolve the draw.io binary, version, and whether it supports Mermaid import and `--layout`. |
156
+ | `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `animated:true` requires a final SVG, preserves connector flow, compiles portable page sequences, and verifies that the result actually contains animation. `mode:"preview"` gives a static, unembedded review PNG that fits within 2000px on both axes, with an image attachment when eligible. `mode:"final"` gives the deliverable (editable by default for PNG/SVG/PDF). See the [export reference](docs/reference.md#mode-and-naming-behavior) for sizing, naming, and cleanup rules. |
157
+ | `drawio_animate` | Add motion to an existing page (pop and slide entrances, connector draw-in, travelling dots, highlights, dimming, staggered cascades) from typed steps, store it on the page, and export a verified animated SVG plus a storyboard PNG sampled from visual batch end states. |
156
158
  | `drawio_validate` | Deterministic lint for XML structure, geometry, page/container bounds, margins, overlap, explicit route-through/crossings, anchors facing away from their route, edge-label collisions, labels on connector lines, small fonts, and unchecked auto-routes. Likely direct-path obstructions for auto-routed edges are preview-review observations. The readability score reports route-through, crossings, overlaps, and anchors separately. |
157
159
  | `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. |
158
160
  | `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. |
159
- | `drawio_from_mermaid` | Convert Mermaid text (inline or a `.mmd`) to a native `.drawio` with automatic layout. Requires draw.io **v30+**. |
160
- | `drawio_layout` | Re-place nodes / route edges with an ELK preset (`verticalFlow`, `horizontalFlow`, `verticalTree`, `horizontalTree`, `radialTree`, `organic`) for large graphs. Requires draw.io **v30+**. |
161
+ | `drawio_from_mermaid` | Convert exactly one Mermaid source (inline text or a `.mmd` file) to a native `.drawio` with automatic layout. Requires draw.io **30.2.4 or newer**. |
162
+ | `drawio_layout` | Re-place nodes / route edges with an ELK preset (`verticalFlow`, `horizontalFlow`, `verticalTree`, `horizontalTree`, `radialTree`, `organic`) for large graphs. Requires draw.io **30.2.4 or newer**. |
161
163
  | `drawio_explain` | Describe an existing `.drawio` as structured Markdown (components by container, relations) — for READMEs/PR summaries or model read-back. |
162
164
  | `drawio_open` | Open a `.drawio`/export in the OS default app (draw.io desktop) for fine-tuning. |
163
165
 
164
166
  ## Architecture
165
167
 
166
- ```text
167
- Natural-language request
168
- └── Pi agent
169
- └── DrawMe extension (check · validate · export · shape search · Mermaid · layout · explain · open)
170
- └── draw.io desktop CLI (renders and exports, local process)
171
- └── Deliverables: .drawio source + PNG / SVG (static or animated) / PDF / JPG
172
- ```
168
+ ![DrawMe architecture: Pi turns a plain-language prompt into editable .drawio source. The DrawMe extension validates the diagram and uses draw.io Desktop to render shareable files locally.](docs/diagrams/drawme-architecture-overview.png)
169
+
170
+ [Editable draw.io source](docs/diagrams/drawme-architecture-overview.drawio)
173
171
 
174
172
  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.
175
173
 
@@ -177,54 +175,56 @@ The extension factory in `src/index.ts` registers the tools and commands. Render
177
175
 
178
176
  `/drawme` injects a guided nine-step workflow that the model follows using the tools above:
179
177
 
180
- 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.
181
- 2. **Plan** — pick the diagram type, relationships, finite canvas, and layout direction; motion requests plan an animated SVG plus a static fallback.
182
- 3. **Author** — write editable uncompressed XML (or Mermaid on v30+), using exact searched shapes and optional ELK layout. Animation may use persistent connector flow and portable page-root JSON sequences.
183
- 4. **Validate after every edit** — fix all errors; fix each warning or record why it is reviewed and acceptable. Malformed animation, dangling targets, invalid timing, and standalone-SVG-incompatible effects are diagnosed before export.
184
- 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.
185
- 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.
186
- 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.
178
+ 1. **Check** — the command resolves the CLI and sends one follow-up with the result, including conversion and layout support, and the packaged authoring references. Pi need not reread references already in the message; they do not contain project source.
179
+ 2. **Plan** — honor the requested view or choose one using the [reader's question](assets/references/diagram-types.md#choose-a-view). For an existing implementation, read the relevant source before drawing and record the source location for each claim. Plan only a meaningful supported subset, note omissions, and explain what is missing instead of drawing if no useful subset is supported. For a conceptual diagram, work from the description without unrelated file reads. Motion requests plan an animated SVG plus a static fallback.
180
+ 3. **Author** — write editable uncompressed XML, or use supported Mermaid conversion or ELK layout when it preserves the chosen composition. Fit the finite canvas after authoring, conversion, or layout. Animation may use stored DrawMe motion, persistent connector flow, or portable native page sequences.
181
+ 4. **Validate after every edit** — fix all errors; fix each warning or record why it is reviewed and acceptable. An incomplete report is not clean. Malformed animation, dangling targets, invalid timing, and standalone-SVG-incompatible effects are diagnosed before export.
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 an image, use validation and `drawio_explain`, then inspect the editable XML for relevant facts the explanation omits; report anything the file cannot establish without claiming visual review. On either path, compare implementation claims with the source before final export. Correct or remove unsupported claims and re-check affected claims after edits; if no validated version passes this check, report the limitation without delivering an implementation diagram, even at the correction limit.
183
+ 6. **Fix and verify before the next pass** — make a targeted edit and validate it. For visual findings, inspect a replacement preview; compare it with a prior image only when the tool reports a comparable attachment for that page. Without an image, repeat the structural checks instead. Record each verdict (fixed / not fixed / regressed). Start the next pass only when the current findings are fixed or explicitly accepted, except at the correction limit.
184
+ 7. **Bound corrections** — inspection previews do not count as retries. Allow at most eight edit → validation → verification cycles across the review. At the limit, stop editing, finish the remaining passes as inspection-only, and report each unresolved finding, its pass, and its last verdict.
187
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.
188
- 9. **Final export** — immediately after the holistic confirmation, export requested embedded/editable formats (each page of a multi-page file separately). Motion requests use `animated:true` for a verified SVG and normally include a static PNG fallback. Final export removes the latest review preview and reports deliverables, animation verification, unresolved findings, and cleanup warnings.
186
+ 9. **Final export** — after review, export the requested formats when supported (each page of a multi-page file separately). Without a renderer, deliver validated editable XML and report that no preview or final export was produced. Use `drawio_animate` for DrawMe motion or `animated:true` for native motion, and normally include a static PNG fallback. The final reply reports deliverables, animation verification, unresolved findings, and preview cleanup warnings. For an implementation view, it also names key source locations and relevant gaps.
187
+
188
+ Review each page, but don't count on keeping a file per page: a successful preview or final export may retire tracked previews for the same source, including other pages. DrawMe does not reconstruct preview tracking after restart. Transcript attachments are separate from files; see [preview behavior](docs/reference.md#preview-attachments-and-cleanup).
189
189
 
190
- Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, edge-label placement, conservative font/wrapping cases, and pinned anchors that face away from their adjacent waypoint or auto-routed peer. Auto-routed edges remain renderer-dependent: validation warns that their route is unchecked and adds a focused observation when the direct connection line pierces a shape, but the preview remains the final arbiter. 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.
190
+ Deterministic checks cover XML contracts, IDs/references, finite page and container bounds, outer margins, overlaps, explicit waypoint routes, edge-label placement, conservative font/wrapping cases, and pinned anchors that face away from their adjacent waypoint or auto-routed peer. Auto-routed edges remain renderer-dependent: validation warns that their route is unchecked and adds a focused observation when the direct connection line pierces a shape, but the preview remains the final arbiter. Rendered clipping and wrapping, contrast, typography at full-diagram scale, visual balance, and draw.io's automatic connector routes need rendered inspection, so the model critiques them only if a preview image is attached and reports them as unverified otherwise. 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.
191
191
 
192
192
  ## Bundled References and Assets
193
193
 
194
- 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.
194
+ These stay plain Markdown files for easy editing. `/drawme` embeds the diagram-types, XML-authoring, style presets, and (when conversion is supported) 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.
195
195
 
196
196
  - `docs/reference.md` — catalog of commands, tool options, defaults, output behavior, and limitations (documentation only; not read at runtime).
197
197
  - `assets/references/xml-authoring.md` — `.drawio` skeleton, cell/edge forms, containers, palette, spacing.
198
- - `assets/references/diagram-types.md` — per-type presets (ERD, UML, sequence, C4, architecture, ML, flowchart, SysML, BPMN, network, swimlane).
199
- - `assets/references/mermaid-authoring.md` — Mermaid authoring for the v30+ conversion path.
198
+ - `assets/references/diagram-types.md` — purpose-led compositions and per-type notation presets.
199
+ - `assets/references/mermaid-authoring.md` — Mermaid authoring for supported renderers.
200
200
  - `assets/references/troubleshooting.md` — export/render failure recovery.
201
201
  - `assets/data/shape-index.json.gz` — the vendored draw.io shape index behind `drawio_shapesearch` (see its notice).
202
202
 
203
203
  ## Requirements and Compatibility
204
204
 
205
205
  - **Node.js** ≥ 22.19.
206
- - **draw.io desktop CLI** on PATH (or a known app path); resolved automatically on macOS (`.app`), Linux, Windows, and WSL. Pass an explicit `binary` to any tool to override.
207
- - **draw.io v30+** for `drawio_from_mermaid` and `drawio_layout`; on older versions those tools return a clear "needs v30+" message and everything else works normally.
208
- - **Headless Linux:** exports are wrapped in `xvfb-run` automatically when no display is present.
206
+ - **draw.io desktop CLI** on PATH (or a known app path). On WSL, install a native Linux draw.io renderer inside WSL; the Windows executable is not supported there. See [CLI discovery](docs/reference.md#drawio_check) for custom installations.
207
+ - **draw.io 30.2.4 or newer** for Mermaid conversion and ELK layout; **32.4.1 or newer** for exports or animations that explicitly pass `pageIndex`. The indexed-export requirement does not apply when `pageIndex` is omitted.
208
+ - **Headless Linux:** install Xvfb (`xvfb-run`) if no display is present. Run Pi as an unprivileged user; DrawMe refuses to run the renderer as root.
209
209
 
210
210
  ## Security
211
211
 
212
212
  DrawMe works with diagram files and may launch the draw.io CLI, `xvfb-run` on headless Linux, or the OS
213
- file opener (`open`/`xdg-open`/`start`). Pi extensions inherit the permissions of the Pi process, so
213
+ [file opener](docs/reference.md#drawio_open). Pi extensions inherit the permissions of the Pi process, so
214
214
  install only packages you trust. See [`SECURITY.md`](SECURITY.md) for runtime and dependency details.
215
215
 
216
216
  ## Examples
217
217
 
218
- Editable sources and rendered examples live in [`example/`](example/README.md). The showcase spans three presets: **Multi-color** for the user journey (blue authoring, purple quality, green delivery), **Dark** for the animated AWS architecture, and **Light** for the installation and reference diagrams. All use deliberate typography, native shapes, generous spacing, and explicitly routed connectors.
218
+ Editable sources and rendered examples live in [`example/`](https://github.com/senad-d/DrawMe/tree/main/example). The showcase spans three presets: **Multi-color** for the user journey (blue authoring, purple quality, green delivery), **Dark** for the animated AWS architecture, and **Light** for the installation and reference diagrams. All use deliberate typography, native shapes, generous spacing, and explicitly routed connectors.
219
219
 
220
220
  | Example | Editable source | Render |
221
221
  | --- | --- | --- |
222
- | Multi-color user journey, four review passes, and CLI/vision fallbacks | [Source](example/drawme-how-it-works.drawio) | [PNG](example/drawme-how-it-works.drawio.png) |
223
- | Light installation guide: scopes, trust, CLI check, and first request | [Source](example/drawme-installation-guide.drawio) | [PNG](example/drawme-installation-guide.drawio.png) |
224
- | Architecture and responsibilities of all ten tools | [Source](example/drawme-architecture.drawio) | [PNG](example/drawme-architecture.drawio.png) |
225
- | Structural gates and bounded, pass-by-pass correction | [Source](example/drawme-validation-decision-tree.drawio) | [PNG](example/drawme-validation-decision-tree.drawio.png) |
226
- | Dark AWS architecture: transactional outbox, SNS/SQS fan-out, consumers, and dead letters | [Source](example/event-driven-orders.drawio) | [Animated SVG](example/event-driven-orders.animated.svg) · [PNG](example/event-driven-orders.drawio.png) · [Storyboard](example/event-driven-orders.storyboard.png) |
227
- | Git branching and merges (classic, retained example) | [Source](example/git-graph-example.drawio) | [PNG](example/git-graph-example.drawio.png) |
222
+ | Multi-color user journey, four review passes, and CLI/vision fallbacks | [Source](example/drawme-how-it-works.drawio) | [PNG](https://github.com/senad-d/DrawMe/blob/main/example/drawme-how-it-works.drawio.png) |
223
+ | Light installation guide: scopes, trust, CLI check, and first request | [Source](example/drawme-installation-guide.drawio) | [PNG](https://github.com/senad-d/DrawMe/blob/main/example/drawme-installation-guide.drawio.png) |
224
+ | Architecture and responsibilities of all ten tools | [Source](example/drawme-architecture.drawio) | [PNG](https://github.com/senad-d/DrawMe/blob/main/example/drawme-architecture.drawio.png) |
225
+ | Structural gates and bounded, pass-by-pass correction | [Source](example/drawme-validation-decision-tree.drawio) | [PNG](https://github.com/senad-d/DrawMe/blob/main/example/drawme-validation-decision-tree.drawio.png) |
226
+ | Dark AWS architecture: transactional outbox, SNS/SQS fan-out, consumers, and dead letters | [Source](example/event-driven-orders.drawio) | [Animated SVG](https://github.com/senad-d/DrawMe/blob/main/example/event-driven-orders.animated.svg) · [PNG](https://github.com/senad-d/DrawMe/blob/main/example/event-driven-orders.drawio.png) · [Storyboard](https://github.com/senad-d/DrawMe/blob/main/example/event-driven-orders.storyboard.png) |
227
+ | Git branching and merges (classic, retained example) | [Source](example/git-graph-example.drawio) | [PNG](https://github.com/senad-d/DrawMe/blob/main/example/git-graph-example.drawio.png) |
228
228
 
229
229
  ### Animated example — Dark
230
230
 
@@ -232,15 +232,17 @@ Editable sources and rendered examples live in [`example/`](example/README.md).
232
232
  <img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/event-driven-orders.animated.svg" alt="Animated order processing: publish committed outbox events, fan out to fulfillment and notifications, then persist shipments and send email" width="900">
233
233
  </p>
234
234
 
235
- This Dark-theme showcase uses 13 official AWS4 components across four zones, including API Gateway, Lambda, DynamoDB, SNS, SQS, and SES. Its verified standalone SVG demonstrates pop/slide entrances, connector draw-in, travelling dots, highlights, and staggered reveals in a 12.56-second loop. Reduced-motion viewers see the static diagram. If your SVG host sanitizes animation, use the [PNG fallback](example/event-driven-orders.drawio.png). The [storyboard](example/event-driven-orders.storyboard.png) shows step order and visibility, not temporal playback.
235
+ This Dark-theme showcase uses 13 official AWS4 components across four zones, including API Gateway, Lambda, DynamoDB, SNS, SQS, and SES. Its verified standalone SVG demonstrates pop/slide entrances, connector draw-in, travelling dots, highlights, and staggered reveals in a 12.56-second loop. Reduced-motion viewers see the static diagram. If your SVG host sanitizes animation, use the [PNG fallback](https://github.com/senad-d/DrawMe/blob/main/example/event-driven-orders.drawio.png). The [storyboard](https://github.com/senad-d/DrawMe/blob/main/example/event-driven-orders.storyboard.png) shows sampled visual states, not temporal playback.
236
236
 
237
237
  ## Development
238
238
 
239
239
  ```bash
240
240
  npm ci --ignore-scripts # install the locked dependency set
241
- npm run validate # golden check + lint + tests
241
+ npm run validate # golden check + lint + tests + package contents check
242
242
  ```
243
243
 
244
+ See the [contributor guide](https://github.com/senad-d/DrawMe/blob/main/CONTRIBUTING.md) for the full gate and asset-update conventions.
245
+
244
246
  Individual checks:
245
247
 
246
248
  ```bash
@@ -249,6 +251,7 @@ npm run lint:eslint # eslint . --max-warnings=0
249
251
  npm run format:check # LF endings, no trailing whitespace, final newline, valid JSON
250
252
  npm run check:golden # SHA-256 integrity of bundled assets (--update to re-baseline)
251
253
  npm test # vitest run
254
+ npm run check:pack # verify package contents
252
255
  npm run coverage # vitest run --coverage
253
256
  pi --no-extensions -e . # load this checkout in Pi
254
257
  ```
@@ -256,7 +259,8 @@ pi --no-extensions -e . # load this checkout in Pi
256
259
  Source layout:
257
260
 
258
261
  - `src/index.ts` — registers the tools and commands.
259
- - `src/drawio.ts` — binary resolution, a pure/testable export planner, the CLI runner, Mermaid conversion, ELK layout, and file-open.
262
+ - `src/drawio.ts` — export orchestration and the facade for renderer, export policy, and editable import.
263
+ - `src/renderer.ts`, `src/export-plan.ts`, `src/editable-import.ts` — CLI discovery and invocation, export planning, and Mermaid conversion/ELK layout.
260
264
  - `src/animation.ts` — native animation analysis, portable page-sequence compilation, reduced-motion CSS, and animated-SVG verification.
261
265
  - `src/validate.ts` — structural and animation linter.
262
266
  - `src/shapesearch.ts` — shape search over the bundled index.
@@ -267,16 +271,9 @@ Source layout:
267
271
 
268
272
  ## Publishing
269
273
 
270
- DrawMe publishes to npm as `@senad-d/drawme`. Run from a clean working tree after validation.
271
-
272
- ```bash
273
- npm login
274
- npm run validate
275
- npm version <version>
276
- npm publish --access public
277
- ```
274
+ DrawMe publishes to npm as `@senad-d/drawme` through the [Publish to npm workflow](https://github.com/senad-d/DrawMe/blob/main/.github/workflows/publish.yml). Run it from the repository's exact default branch, not from a tag.
278
275
 
279
- Push the release commit and tag after the package is published.
276
+ Before a release, a repository administrator must verify in GitHub settings that the `npm` environment uses **Selected branches and tags** with exactly one branch rule: the literal default branch name. Do not allow tag rules, wildcards, or other branches. The workflow's `environment: npm` declaration does not verify those settings.
280
277
 
281
278
  ## License
282
279
 
package/SECURITY.md CHANGED
@@ -9,7 +9,7 @@ launch:
9
9
 
10
10
  - the **draw.io desktop CLI** for conversion, layout, rendering, and export;
11
11
  - **`xvfb-run`** for draw.io on headless Linux;
12
- - the **OS file opener** (`open` / `xdg-open` / `start`) when `drawio_open` is requested.
12
+ - the **[OS file opener](docs/reference.md#drawio_open)** when `drawio_open` is requested for a supported document.
13
13
 
14
14
  Child processes are invoked with argument lists rather than through a shell. Shape lookup uses the
15
15
  bundled `assets/data/shape-index.json.gz` file.
@@ -4,23 +4,30 @@ When the user requests a specific diagram type, apply the matching preset below
4
4
 
5
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
6
 
7
- Read this file when:
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)
9
- - You're choosing shape vocabulary or layout direction for a new diagram
7
+ ## Choose a view
8
+
9
+ Honor an explicitly requested view or notation, including the other presets in this catalogue. Otherwise use the primary question to choose one composition; don't try to answer all five in one drawing. For an implementation view, use the relevant code, schema, or configuration to establish what belongs in it. For a conceptual view, work from the description without claiming it depicts an implementation.
10
+
11
+ - What is each part responsible for, and how do the parts interact? [Architecture overview](#architecture-diagram)
12
+ - What happens during this request, and in what order? [Request/sequence flow](#sequence-diagram)
13
+ - What records exist, and how do they relate? [Data model](#erd-entity-relationship-diagram)
14
+ - Where does this run, and how are the running parts connected? [Deployment](#deployment)
15
+ - What can the person do, and what do they see next? [User flow](#user-flow)
10
16
 
11
17
  ## ERD (Entity-Relationship Diagram)
12
18
 
13
- 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.
19
+ Show the entities, fields, and associations that answer the question. Put the entity name in a strong header, then left-align field names and relevant types in evenly spaced rows. Keep related cards near each other, with aligned tops and a clear side corridor for field-level connectors. Omit irrelevant fields rather than shrinking text. The layout is structural: do not impose a time axis, flow arrows, or an accent path.
20
+
21
+ Derive key roles, optionality, and multiplicity from constraints the schema actually establishes. Connect the relevant field rows on the facing sides when the relationship is field-based. For non-relational models or where a supported association has no established key or multiplicity, use a named association without those markers. Use Mermaid ER conversion only if supported and it preserves the needed field placement and end markers; otherwise place the cells in XML.
14
22
 
15
23
  | Element | Style | Notes |
16
24
  |---------|-------|-------|
17
- | Table | `shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;strokeColor=#6c8ebf;fillColor=#dae8fc;` | Each table is a container |
18
- | Row (column) | `shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;fontSize=12;` | Child of table, `parent=tableId` |
19
- | PK column | Bold text: `fontStyle=1` on the row | Mark with `PK` prefix or key icon |
20
- | FK relationship | Dashed edge: `dashed=1;endArrow=ERmandOne;startArrow=ERmandOne;` | Use ER notation arrows |
21
- | Layout | TB, tables spaced 300px apart | Group related tables vertically |
25
+ | Table | `shape=table;startSize=30;container=1;collapsible=1;childLayout=tableLayout;fixedRows=1;rowLines=0;fontStyle=1;` | Each table is a container |
26
+ | Field row | `shape=tableRow;horizontal=0;startSize=0;swimlaneHead=0;swimlaneBody=0;fillColor=none;collapsible=0;dropTarget=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;align=left;fontSize=12;` | Child of table, `parent=tableId` |
27
+ | Key field | `fontStyle=1` on the row | Mark supported roles with `PK` or `FK` text |
28
+ | Association | `startArrow=none;endArrow=none;` for a named association without cardinality | For crow's-foot notation, set each supported end marker independently |
22
29
 
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.
30
+ **Review:** trace both relationship ends to the correct entity or field and each key or multiplicity marker to its constraint. Check for misleading one-to-one defaults, lines through headers, and obscured end markers; all field rows must be readable.
24
31
 
25
32
  ## UML Class Diagram
26
33
 
@@ -38,22 +45,23 @@ For SQL DDL, derive tables, primary keys, foreign keys, and crow's-foot relation
38
45
 
39
46
  ## Sequence Diagram
40
47
 
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.
48
+ Show the participants and messages needed to trace this request, not the complete component map. Put the initiator first, with participant headers aligned across the top on parallel lifelines. Give each evidenced interaction one horizontal message row; time runs top to bottom. Repeat the row gap, increasing it as needed for wrapped labels above their own arrows. Align calls from sender to recipient and show a return back to the caller only when the trace supports it. Label the action or meaningful payload/result, not just “request” or “response.”
49
+
50
+ Use the lifelines and row positions to show order, not numbered badges. If emphasis helps, accent the interaction the question turns on; distinguish returns by dash and direction, not hue. Preserve the participant columns and message rows if using supported Mermaid conversion. If they cannot be preserved, place the editable XML directly; do not re-layout a sequence with ELK.
42
51
 
43
52
  | Element | Style | Notes |
44
53
  |---------|-------|-------|
45
54
  | Actor/Object | `shape=umlLifeline;perimeter=lifelinePerimeter;whiteSpace=wrap;html=1;container=1;collapsible=0;recursiveResize=0;outlineConnect=0;portConstraint=eastwest;` | Lifeline with dashed vertical line |
46
- | Sync message | `html=1;verticalAlign=bottom;endArrow=block;` | Solid line, filled arrowhead |
47
- | Async message | `html=1;verticalAlign=bottom;endArrow=open;dashed=1;` | Dashed line, open arrowhead |
48
- | Return message | `html=1;verticalAlign=bottom;endArrow=open;dashed=1;strokeColor=#999999;` | Grey dashed |
49
- | Activation box | `shape=umlFrame;whiteSpace=wrap;` on the lifeline | Narrow rectangle on lifeline |
50
- | Layout | LR, lifelines spaced 200px apart | Time flows top to bottom |
55
+ | Sync message | `html=1;verticalAlign=bottom;endArrow=block;endFill=1;` | Solid line, filled arrowhead |
56
+ | Async message | `html=1;verticalAlign=bottom;endArrow=open;dashed=0;` | Solid line, open arrowhead |
57
+ | Return message | `html=1;verticalAlign=bottom;endArrow=open;dashed=1;` | Dashed line back to the caller |
58
+ | Activation box | `shape=umlFrame;whiteSpace=wrap;` on the lifeline | Narrow rectangle; use only for the supported activation span |
51
59
 
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.
60
+ **Review:** follow the request and its supported result down the page. Look for out-of-order rows, a call aimed at the wrong recipient, or an invented or reversed return. Each horizontal arrow should have a clear label above it and meet its lifelines at the intended row.
53
61
 
54
62
  ## C4 Model (System Context / Container / Component)
55
63
 
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:
64
+ Use the styles below for C4 diagrams. A Mermaid C4 sketch works for a standard single view if the CLI reports Mermaid support (draw.io 30.2.4 or newer); use XML if conversion is unavailable or exact C4 styling, multiple pages, or drill-down links are required:
57
65
 
58
66
  | Element | Style | Notes |
59
67
  |---------|-------|-------|
@@ -72,17 +80,19 @@ Use the styles below for C4 diagrams. A Mermaid C4 sketch works for a standard s
72
80
 
73
81
  ## Architecture Diagram
74
82
 
83
+ Show the components that matter, what each owns, and how they collaborate. Put the entry point or consumer where the reader starts, then collaborating components and their dependencies in a clear left-to-right or top-to-bottom arrangement. Align peers inside labeled responsibility boundaries and keep known external dependencies outside. Group only by real boundaries; don't impose Client / API / Service / Data tiers or turn an overview into a numbered execution trace. Use [C4](#c4-model-system-context--container--component) when that notation is requested.
84
+
85
+ Label boxes with a name and a short responsibility. Label directional connectors with domain verbs such as “queues jobs” or “reads settings” when those are the actual interactions. Use simple shapes and neutral groups; reserve emphasis for the component or interaction the reader came to understand.
86
+
75
87
  | Element | Style | Notes |
76
88
  |---------|-------|-------|
77
- | Layer/tier | `swimlane;startSize=30;` | Containers for grouping: Client / API / Service / Data |
78
- | Service | `rounded=1;whiteSpace=wrap;html=1;` + tier color | Use color palette by tier |
79
- | Database | `shape=cylinder3;whiteSpace=wrap;html=1;` | Green palette |
80
- | Queue/Bus | `rounded=1;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;` | Yellow — place centrally for hub pattern |
81
- | Gateway/LB | `shape=mxgraph.aws4.resourceIcon;` or `rounded=1;` with orange | Orange palette |
82
- | External | `rounded=1;dashed=1;fillColor=#f5f5f5;strokeColor=#666666;` | Dashed border for external systems |
83
- | Layout | TB or LR by tier count; ≥4 tiers → TB | Hub nodes centered |
89
+ | Responsibility boundary | `swimlane;startSize=30;` | Label the responsibility and keep the title band clear |
90
+ | Component | `rounded=1;whiteSpace=wrap;html=1;` | Align peers and repeat their gaps |
91
+ | Database | `shape=cylinder3;whiteSpace=wrap;html=1;` | Use only for an actual data store |
92
+ | Queue/Bus | `rounded=1;whiteSpace=wrap;html=1;` | Center an actual hub when it shortens routes |
93
+ | External | `rounded=1;dashed=1;` | Label it as external; don't depend on fill color |
84
94
 
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.
95
+ **Review:** can you explain what each boundary means in the source and what each arrow says the components do? Look for a plausible-looking but unsupported tier, a peer in the wrong group, or an arrow that substitutes proximity for a real interaction.
86
96
 
87
97
  ## ML / Deep Learning Model Diagram
88
98
 
@@ -200,6 +210,14 @@ Shared prefix (every node below): `fontColor=#0066CC;verticalAlign=top;verticalL
200
210
 
201
211
  **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
212
 
213
+ ## Deployment
214
+
215
+ Show deployable workloads and the configured connections that answer where they run. Use labeled containers for the actual environment, host, cluster, or service boundaries at the level the configuration establishes. Nest workloads as editable children of the correct boundary, with aligned peers, even insets, and a clear title band. A flat manifest gives you peers, not invented regions or tiers. Put known externals outside the boundary with a dashed border and an explicit label. Use [Network Topology](#network-topology) for supplementary device and zone notation if needed; vendor icons are optional.
216
+
217
+ Use workload names and relevant runtime roles, not source directories or function calls. Leave routing space between boundaries and label each configured link with the established binding, endpoint, or protocol. Show direction only where the configuration establishes it; don't infer a port or draw a dependency as a live connection. Emphasize placement and any cross-boundary link central to the question, not a chronological main path.
218
+
219
+ **Review:** verify each workload's containment and each configured link against its manifest or runtime configuration. Look for siblings shown as nested, environment boundaries that don't exist, and labels that add an unconfigured endpoint or port.
220
+
203
221
  ## Cross-Functional Flowchart (Swimlane)
204
222
 
205
223
  A flowchart split by **who does what** — one lane per role/department. Node vocabulary reuses the Flowchart preset below; only the container skeleton differs.
@@ -227,3 +245,11 @@ A flowchart split by **who does what** — one lane per role/department. Node vo
227
245
  | Layout | TB, 200px vertical gap | Decisions branch LR, merge back to center |
228
246
 
229
247
  **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.
248
+
249
+ ## User Flow
250
+
251
+ Show one clear entry, the person's actions, what they see next, and the supported outcomes. Keep the primary journey on a single left-to-right or top-to-bottom axis with short action verbs and aligned, evenly spaced steps. Omit implementation hops and backend swimlanes unless requested. Borrow start/end, action, and decision shapes from [Flowchart](#flowchart-enhanced); use their shapes and labels to distinguish them even in Light.
252
+
253
+ Put real decisions on the primary path. Route alternatives in separate side lanes, with each actual condition or outcome beside its own outgoing line. Rejoin only where the journeys really converge; otherwise give each its own named end state. Use arrowheads to show the next step and accent the primary journey when it helps it stand out. Keep a linear journey linear instead of inventing a branch or failure state.
254
+
255
+ **Review:** start where the person starts and trace the primary path and each supported alternative to what they see next or where they end. Look for an unlabeled exit, a branch tied to the wrong condition, or an artificial merge that hides a distinct outcome.
@@ -1,10 +1,11 @@
1
1
  # Mermaid authoring → native .drawio
2
2
 
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.
3
+ Use Mermaid when the diagram is a standard type with no custom styling requirements and the CLI
4
+ supports Mermaid conversion (draw.io 30.2.4 or newer), and only when conversion can preserve the
5
+ [chosen view](diagram-types.md#choose-a-view). Mermaid keeps the input focused on structure while
6
+ draw.io supplies the initial layout.
6
7
 
7
- Call `drawio_check` first, then convert with:
8
+ Use the workflow's CLI status (or call `drawio_check` if it is not already known), then convert with:
8
9
 
9
10
  ```text
10
11
  drawio_from_mermaid({
@@ -13,7 +14,7 @@ drawio_from_mermaid({
13
14
  })
14
15
  ```
15
16
 
16
- On draw.io 29 or older, skip Mermaid conversion and author uncompressed `.drawio` XML instead.
17
+ Provide exactly one nonblank source: inline `mermaid` or an `input` `.mmd` file. If conversion isn't supported, author uncompressed `.drawio` XML instead.
17
18
 
18
19
  ## When to prefer each authoring mode
19
20
 
@@ -21,7 +22,11 @@ On draw.io 29 or older, skip Mermaid conversion and author uncompressed `.drawio
21
22
  |---|---|---|
22
23
  | **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
24
  | **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
+ | **XML → `drawio_layout`** | Large or graph-heavy hand-authored diagrams when the CLI supports layout and the view permits repositioning | Repositions nodes and routes edges with an allowlisted ELK preset |
26
+
27
+ Use hand placement when conversion or auto-layout would lose sequence message order or lifeline
28
+ columns, entity-row anchors or end markers, workload containment, or decision labels on their
29
+ branches. Do not apply generic ELK layout to a sequence.
25
30
 
26
31
  If the user requests Mermaid source rather than a `.drawio` deliverable, do not convert it unless they
27
32
  also ask for a draw.io file.
@@ -40,12 +45,16 @@ also ask for a draw.io file.
40
45
  - Match label language to the user's language.
41
46
  - Never apply `drawio_layout` to a Mermaid-converted file; conversion already lays it out.
42
47
 
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.
48
+ After conversion, treat the `.drawio` as the source of truth. Apply the active theme's colors and
49
+ typography without changing notation or direction. Check the editable structure against the chosen
50
+ composition; correct it by hand or author directly in XML if conversion lost essential details.
51
+ Fit the finite canvas with `drawio_fit_canvas`, validate again, review a preview when available,
52
+ then create the requested final exports.
45
53
 
46
54
  ## ELK layout for XML-authored diagrams
47
55
 
48
- For rough XML geometry on draw.io 30 or newer, use `drawio_layout` with one of these presets:
56
+ For rough XML geometry, use `drawio_layout` only when the CLI reports `--layout` support
57
+ (draw.io 30.2.4 or newer), with one of these presets:
49
58
 
50
59
  | Preset | Layout |
51
60
  |---|---|
@@ -13,16 +13,15 @@ Never switch themes on your own because a diagram type, a slide, or a README see
13
13
  ## Applying a theme
14
14
 
15
15
  - **Set the page background** on the model, for example `<mxGraphModel background="#FFFFFF" ...>`. Every export, the animated SVG, and the storyboard read it. DrawMe pins exported SVGs to the authored colors, so a viewer in dark mode never inverts a Light diagram or brightens a Dark one.
16
- - **One primary path.** Draw the main flow with the accent edge style (thicker, accent color) and every secondary connection with the neutral edge style. The reader should see the story before reading a label.
17
- - **Accent with restraint.** In Light and Dark, the accent marks only the main path, numbered step badges, and the one or two nodes the diagram is about. Everything else is neutral.
18
- - **Hierarchy through type.** Put a title (28px bold) and a one-line subtitle (16px, muted) top-left as `text` cells. Node labels use a bold name plus a muted detail line: `value="&lt;b&gt;API&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:12px&quot; color=&quot;#64748B&quot;&gt;Process request&lt;/font&gt;"` (use the theme's muted color).
19
- - **Shape language.** Rounded corners with a fixed radius (`absoluteArcSize=1;arcSize=12;`), 1.5px strokes, no `shadow=1` (draw.io's shadow is heavy and dated), generous inner padding (`spacing=12;`). Keep peer nodes the same size.
20
- - **Containers recede.** Zones and groups use a near-background tint, a hairline stroke, and a small title at the top-left. They never compete with the nodes they hold.
21
- - **Numbered steps.** For a sequence, put a 28×28 accent badge with the number beside each step instead of numbering inside the label.
22
- - **Whitespace is part of the design.** Keep the spacing table from the XML authoring reference, align everything to a 10px grid, and run `drawio_fit_canvas`.
23
- - **Edge labels** use the page background as `labelBackgroundColor` so they sit cleanly on lines.
24
- - **Icons.** Prefer official vendor icons from `drawio_shapesearch` at a consistent size (48×48 inside or beside a node). Never mix icon families in one diagram.
25
- - **Legend.** Light and Dark need none unless the accent needs explaining. Multi-color lists exactly the roles used.
16
+ - **Accent with restraint.** Follow the view in [Diagram Type Presets](diagram-types.md#choose-a-view). Accent the subject, a key relationship, or a genuine primary journey; keep other connections neutral. Do not invent a main path for a data model or deployment map. Preserve structural connector styles such as dashed returns and ER end markers when applying theme colors.
17
+ - **Hierarchy through type.** Use one family (Helvetica by default). Put a title (28px bold) and, when useful, a one-line subtitle (16px, muted) top-left as `text` cells. Lead node labels with the name (14px); add detail only if useful (12px), e.g. `value="&lt;b&gt;API&lt;/b&gt;&lt;br&gt;&lt;font style=&quot;font-size:12px&quot; color=&quot;#64748B&quot;&gt;Process request&lt;/font&gt;"` (use the theme's muted color).
18
+ - **Shape language.** Use rounded corners (`absoluteArcSize=1;arcSize=12;`) for ordinary boxes, 1.5px strokes, no `shadow=1`, and generous inner padding (`spacing=12;`). Keep notation-specific shapes and size peers consistently without clipping their labels.
19
+ - **Containers recede.** Zones and groups use a near-background tint, a hairline stroke, and a small title at the top-left. Distinguish groups by boundary and label, not tint alone.
20
+ - **Numbered steps.** A 28×28 accent badge can mark an explicitly numbered step in a flow. Leave badges off sequence messages: row position shows their order.
21
+ - **Whitespace is part of the design.** Follow [XML layout tips](xml-authoring.md#layout-tips) for grid alignment, spacing, and fitting the canvas to the selected composition.
22
+ - **Edge labels.** Offset text from the line and set `labelBackgroundColor` to the actual background behind the label (page or container). Inspect muted detail and edge labels for contrast; do not rely on color alone for meaning.
23
+ - **Icons.** When icons help, prefer official vendor icons from `drawio_shapesearch` at a consistent size (48×48 inside or beside a node). Never mix icon families in one diagram.
24
+ - **Legend.** Light and Dark need none unless a visual convention needs explaining. Multi-color lists exactly the roles used.
26
25
 
27
26
  ## Light (default)
28
27
 
@@ -86,9 +85,9 @@ Keep the Light or Dark base (background, text, edges, containers, badges) and co
86
85
 
87
86
  Motion follows the theme: `drawio_animate` uses the theme accent for `highlight` and `travel` by default (`#2563EB` on a light page, `#60A5FA` on a dark one). Pass `color` only to match a Multi-color role. The motion should explain the diagram, not decorate it:
88
87
 
89
- - **Tell the story in order.** Reveal the title, then the first actor, then each hop of the main path: `popIn` or `slideIn` the node, `drawIn` the connector to the next node, `popIn` that node. Reveal containers before their children.
88
+ - **Reveal structure before detail.** Reveal the title and containers before their children. For a real flow, use its established order: `popIn` or `slideIn` the node, `drawIn` its connector, then `popIn` the next node. For a structural view, reveal groups and associations without implying execution order.
90
89
  - **Cascade peers.** Reveal a row of similar nodes in one step with `stagger` 80–150ms rather than one step per node.
91
- - **Show traffic after structure.** Once everything is visible, `travel` dots along the main path (use `parallel` to run several hops as a pipeline), then `highlight` the focus node.
90
+ - **Show traffic only where it exists.** Once everything is visible, `travel` dots along the actual flow (use `parallel` for concurrent hops), then `highlight` the focus node. Do not animate traffic along a structural association.
92
91
  - **Focus by dimming.** `dim` everything except the part being explained, then `fadeIn` it back.
93
92
  - **Pace for reading.** Entrances 400–700ms, connector draw-in 600–1000ms, a 300–600ms `wait` after each logical group, and a loop `hold` of 1500–2500ms so the final state can be read. Keep one full loop under about 15 seconds.
94
- - **Restraint.** Animate the primary path and its nodes; leave legends and annotations static or reveal them once at the end.
93
+ - **Restraint.** Animate only the part being explained; leave legends and annotations static or reveal them once at the end.