@senad-d/drawme 0.1.8 → 0.1.10

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,8 +6,39 @@ All notable changes to this project are documented here. The format is based on
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.10] - 2026-10-27
10
+
11
+ ### Fixed
12
+
13
+ - Headless Linux exports size the Xvfb screen to the requested raster (floor 1280x1024, cap 8192) instead of a fixed 1280x1024: a final PNG wider than the screen made draw.io fail with `UnknownVizError` and hang until the timeout.
14
+ - A timed-out export now ends its whole process tree (xvfb-run, Xvfb, draw.io) instead of leaving orphans, and the failure message keeps draw.io's stderr next to the timeout reason.
15
+
16
+ ## [0.1.9] - 2026-10-11
17
+
18
+ ### Fixed
19
+
20
+ - Resolved Sonar maintainability findings by splitting motion, animation, export, and label-route validation into focused helpers, preserving deterministic preview-cleanup receipts while deleting independent artifacts concurrently. Documented browser-only `dataset` false positives for xmldom XML elements.
21
+ - Added animation orchestration, SVG color/margin, and retained-preview cleanup regression tests.
22
+
9
23
  ### Added
10
24
 
25
+ - `drawio_animate`: an animation-only tool for an existing page. Typed steps (`fadeIn`, `fadeOut`, `dim`, `popIn`, `slideIn`, `drawIn`, `highlight`, `travel`, `wait`) with `stagger` and `parallel` timing are validated against the page, stored on the page root cell as `drawmeMotion`, compiled to CSS keyframes and SMIL connector dots with a reduced-motion fallback, and injected into a draw.io SVG export. A storyboard PNG shows each step's end state for review. `drawio_validate` checks stored motion.
26
+ - Theme reference (`style-presets.md`): Light is the default; Dark and Multi-color are used only on explicit request. It includes ready-made styles, composition rules, and motion design guidance. `/drawme` pre-loads it, and diagram-type and classic palette colors now yield to the active theme.
27
+
28
+ ### Changed
29
+
30
+ - Every SVG export (static, animated, and `drawio_animate`) is pinned to its authored colors: draw.io's `light-dark()` adaptive colors are resolved, so dark-mode viewers no longer invert the diagram and SVG, PNG, PDF, previews, and storyboards always show the same theme. `drawio_animate` defaults its highlight and dot accent to the page theme.
31
+ - TypeScript is pinned to `~6.0.3` (and Dependabot ignores `>=6.1.0`) because `typescript-eslint` does not support TypeScript 7; `npm ci` resolves cleanly again.
32
+
33
+ - Exports default to a 40-unit outer margin instead of 10px, matching `drawio_fit_canvas`: draw.io crops output to the content, so this border is the image's only margin. The margin is now even on every side: draw.io's own border is lopsided for scaled rasters (left/top get border × scale) and SVG (the canvas grows by 3 × border), so final PNG/JPG exports are sized with `--width` from the page's content width, and SVG is exported borderless and padded by DrawMe.
34
+ - `drawio_validate` warns when a connector label's estimated box lands on a bend or another segment of its own connector (typically after an offset), or on another explicitly routed connector. Collinear waypoints, sub-2px jogs, and the L-shaped corners draw.io adds to orthogonal edges are taken into account. The validation decision tree example is fixed for the overlaps this found.
35
+
36
+ ### Security
37
+
38
+ - Upgraded `@xmldom/xmldom` to `^0.9.12` and the `@earendil-works/pi-coding-agent` dev dependency to `^1.1.0`, and refreshed transitive `undici`, `brace-expansion`, and `source-map-js`; `npm audit` reports no vulnerabilities.
39
+
40
+ - Verified standalone animated SVG export. `drawio_export` accepts `animated:true` (final SVG only), preserves and checks native connector flow animation, and compiles portable page-root visibility/opacity/fade/wait sequences into self-contained SVG CSS with loop, parallel-step, and reduced-motion support. Animation-aware validation catches malformed JSON, dangling targets, invalid flow/timing controls, and viewer-only effects before export; `/drawme-export ... animated-svg`, the autonomous workflow, authoring reference, and public docs expose the feature. Static PNG review/fallback remains separate; GIF, video, and network-loaded HTML viewers are intentionally out of scope.
41
+
11
42
  - `drawio_validate` no longer stays silent about what it cannot see: auto-routed edges (no explicit
12
43
  waypoints) are reported as an actionable warning naming each edge, because the renderer routes them
13
44
  blindly and the route-through/crossing checks skip them — the main way visibly broken routing used to
@@ -111,5 +142,7 @@ Initial release: DrawMe as a native Pi extension for authoring, validating, and
111
142
  - Tooling: ESLint flat config, custom `format:check`, `check:golden` asset-integrity check, Vitest suite
112
143
  with real-CLI integration tests, CI, SonarCloud, and release workflows.
113
144
 
114
- [Unreleased]: https://github.com/senad-d/DrawMe/compare/v0.0.1...HEAD
145
+ [Unreleased]: https://github.com/senad-d/DrawMe/compare/v0.1.10...HEAD
146
+ [0.1.10]: https://github.com/senad-d/DrawMe/compare/v0.1.9...v0.1.10
147
+ [0.1.9]: https://github.com/senad-d/DrawMe/compare/v0.0.1...v0.1.9
115
148
  [0.0.1]: https://github.com/senad-d/DrawMe/releases/tag/v0.0.1
package/README.md CHANGED
@@ -12,7 +12,7 @@
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 with the native draw.io desktop CLI — 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 — entirely on your machine.
16
16
  </p>
17
17
 
18
18
  ---
@@ -25,12 +25,12 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
25
25
  </tr>
26
26
  <tr>
27
27
  <td align="center">
28
- <img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/drawme-how-it-works.drawio.png" alt="DrawMe: from a prompt to an editable diagram" title="DrawMe" width="820">
28
+ <img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/drawme-how-it-works.drawio.png" alt="DrawMe user flow: author, validate, review in four passes, correct, and export, with CLI and vision fallbacks" title="DrawMe user flow" width="820">
29
29
  </td>
30
30
  </tr>
31
31
  <tr>
32
32
  <td align="center">
33
- <img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/drawme-installation-guide.drawio.png" alt="DrawMe: Installation guide" title="DrawMe" width="820">
33
+ <img src="https://raw.githubusercontent.com/senad-d/DrawMe/main/example/drawme-installation-guide.drawio.png" alt="Install DrawMe: prerequisites, personal/project/one-invocation scope, CLI check, and first request" title="DrawMe installation" width="820">
34
34
  </td>
35
35
  </tr>
36
36
  </table>
@@ -40,6 +40,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
40
40
  - **Deterministic validation:** a structural linter catches dangling edges, duplicate/reserved ids, malformed geometry, page/container overflow, inadequate margins, conservative readability defects, overlaps, and explicit edge-routing defects before you look at a pixel.
41
41
  - **Vision-aware previews:** successful PNG previews attach the actual image only when the active model can view images — the result text says which case applies — so text-only models get an honest structural-review path instead of a placeholder; each replacement removes the previous same-source preview file so only the latest remains on disk.
42
42
  - **Exact shapes, not guesses:** search 10k+ official AWS/Azure/GCP/Cisco/Kubernetes/UML/BPMN styles from a bundled local index.
43
+ - **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.
43
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.
44
45
 
45
46
  > **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.
@@ -68,7 +69,7 @@ DrawMe is a native Pi **extension** for diagram authoring. Describe a diagram an
68
69
 
69
70
  This checkout implements the DrawMe core loop as a Pi extension:
70
71
 
71
- - Nine model-callable tools (`drawio_check`, `drawio_export`, `drawio_validate`, `drawio_fit_canvas`, `drawio_shapesearch`, `drawio_from_mermaid`, `drawio_layout`, `drawio_explain`, `drawio_open`) and three commands (`/drawme`, `/drawme-check`, `/drawme-export`).
72
+ - 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`).
72
73
  - A guided `/drawme` workflow that steers authoring, validation after every edit, a gated multi-pass visual review, and autonomous final multi-format export.
73
74
  - Pure-TypeScript structural linting, `-e` PNG IEND repair, shape search over a bundled index, and diagram-to-Markdown description — no Python runtime required.
74
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+).
@@ -141,7 +142,7 @@ pi --no-extensions -e .
141
142
  | --- | --- |
142
143
  | `/drawme <description>` | Kick off authoring, per-edit validation, the gated multi-pass visual review, and autonomous final export. |
143
144
  | `/drawme-check` | Report whether the draw.io CLI is available, its version, and v30+ feature support. |
144
- | `/drawme-export <file> [png\|svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`. |
145
+ | `/drawme-export <file> [png\|svg\|animated-svg\|pdf\|jpg]` | One-shot final export of an existing `.drawio`; `animated-svg` requires and verifies motion. |
145
146
 
146
147
  ## Tools
147
148
 
@@ -150,7 +151,8 @@ Registered for the model to call directly.
150
151
  | Tool | Purpose |
151
152
  | --- | --- |
152
153
  | `drawio_check` | Resolve the draw.io binary, version, and whether it supports Mermaid import / `--layout` (v30+). |
153
- | `drawio_export` | Export a `.drawio` to PNG/SVG/PDF/JPG. `mode:"preview"` → clean width-capped PNG returned as text/metadata, with the image block attached when the active model can view images (the text states which); each successful preview removes the previous same-source preview file so only the latest remains. `mode:"final"` → embedded editable deliverable, with truncated PNG repair and cleanup of the remaining preview. |
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. |
154
156
  | `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. |
155
157
  | `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. |
156
158
  | `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. |
@@ -166,7 +168,7 @@ Natural-language request
166
168
  └── Pi agent
167
169
  └── DrawMe extension (check · validate · export · shape search · Mermaid · layout · explain · open)
168
170
  └── draw.io desktop CLI (renders and exports, local process)
169
- └── Deliverables: .drawio source + PNG / SVG / PDF / JPG
171
+ └── Deliverables: .drawio source + PNG / SVG (static or animated) / PDF / JPG
170
172
  ```
171
173
 
172
174
  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.
@@ -176,14 +178,14 @@ The extension factory in `src/index.ts` registers the tools and commands. Render
176
178
  `/drawme` injects a guided nine-step workflow that the model follows using the tools above:
177
179
 
178
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.
179
- 2. **Plan** — pick the diagram type, relationships, finite canvas, and layout direction.
180
- 3. **Author** — write editable uncompressed XML (or Mermaid on v30+), using exact searched shapes and optional ELK layout.
181
- 4. **Validate after every edit** — fix all errors; fix each warning or record why it is reviewed and acceptable.
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.
182
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.
183
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.
184
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.
185
187
  8. **No human gate** — the run never pauses for approval or feedback; if the user interrupts with feedback, it is handled as new critique findings and the run continues.
186
- 9. **Final export** — immediately after the holistic confirmation, export requested embedded/editable formats (each page of a multi-page file separately), remove the one remaining latest review preview, and report deliverables (including any unresolved finding from the correction limit) plus cleanup warnings.
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.
187
189
 
188
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.
189
191
 
@@ -213,11 +215,24 @@ install only packages you trust. See [`SECURITY.md`](SECURITY.md) for runtime an
213
215
 
214
216
  ## Examples
215
217
 
216
- Sample diagrams authored with DrawMe live in [`example/`](example/):
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.
217
219
 
218
- - [`drawme-how-it-works.drawio`](example/drawme-how-it-works.drawio) — the workflow/architecture overview shown above.
219
- - [`drawme-installation-guide.drawio`](example/drawme-installation-guide.drawio) — an installation walkthrough.
220
- - [`git-graph-example.drawio`](example/git-graph-example.drawio) — a branching release-history example.
220
+ | Example | Editable source | Render |
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) |
228
+
229
+ ### Animated example — Dark
230
+
231
+ <p align="center">
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
+ </p>
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.
221
236
 
222
237
  ## Development
223
238
 
@@ -242,7 +257,8 @@ Source layout:
242
257
 
243
258
  - `src/index.ts` — registers the tools and commands.
244
259
  - `src/drawio.ts` — binary resolution, a pure/testable export planner, the CLI runner, Mermaid conversion, ELK layout, and file-open.
245
- - `src/validate.ts` — structural linter.
260
+ - `src/animation.ts` — native animation analysis, portable page-sequence compilation, reduced-motion CSS, and animated-SVG verification.
261
+ - `src/validate.ts` — structural and animation linter.
246
262
  - `src/shapesearch.ts` — shape search over the bundled index.
247
263
  - `src/explain.ts` — diagram-to-Markdown describer.
248
264
  - `src/dom.ts` — shared xmldom helpers used by `validate`/`explain`.
@@ -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 focus on **structural** style keywords, such as ERD's `shape=table;childLayout=tableLayout`; adapt colors and typography to the user's requested visual style.
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`. The colors in these tables are notation defaults: replace them with the active theme's colors from the style presets reference (Light unless the user asks for Dark or Multi-color), and keep them only when the user explicitly asks for that notation's standard colors.
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
 
@@ -0,0 +1,94 @@
1
+ # Style presets
2
+
3
+ Every diagram uses exactly one theme, and every output of it (preview PNG, final PNG/SVG/PDF/JPG, animated SVG, storyboard) shows that same theme.
4
+
5
+ | Theme | When to use |
6
+ |-------|-------------|
7
+ | **Light** | The default. Use it whenever the user does not explicitly ask for something else. |
8
+ | **Dark** | Only when the user explicitly asks for a dark theme, dark background, or dark mode. |
9
+ | **Multi-color** | Only when the user explicitly asks for multiple colors, color-coded roles, or a colorful diagram. It applies on Light, or on Dark when the user asks for both. |
10
+
11
+ Never switch themes on your own because a diagram type, a slide, or a README seems to suit one. A request for a "modern" or "clean" look is still Light. Diagram-type presets and the classic palette in the XML authoring reference contribute structural style keys only (`shape=`, `swimlane`, arrows, `dashed`); replace their colors with the active theme's colors unless the user asks for that notation's standard colors.
12
+
13
+ ## Applying a theme
14
+
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.
26
+
27
+ ## Light (default)
28
+
29
+ Page background `#FFFFFF`. Title `#0F172A`, body text `#1E293B`, muted text `#64748B`. Accent `#2563EB`.
30
+
31
+ | Element | fillColor | strokeColor | fontColor |
32
+ |---------|-----------|-------------|-----------|
33
+ | Node | `#FFFFFF` | `#CBD5E1` | `#0F172A` |
34
+ | Focus node (the one or two the diagram is about) | `#EFF6FF` | `#2563EB` | `#1E3A8A` |
35
+ | External / secondary node | `#F8FAFC` | `#CBD5E1` | `#475569` |
36
+ | Container / zone | `#F8FAFC` | `#E2E8F0` | `#64748B` |
37
+ | Edge | — | `#94A3B8` | `#475569` |
38
+ | Main-path edge | — | `#2563EB` | `#475569` |
39
+ | Badge | `#2563EB` | `none` | `#FFFFFF` |
40
+
41
+ Ready-to-use styles:
42
+
43
+ ```text
44
+ Node: rounded=1;absoluteArcSize=1;arcSize=12;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=14;spacing=12;strokeWidth=1.5;fillColor=#FFFFFF;strokeColor=#CBD5E1;fontColor=#0F172A;
45
+ Focus node: same as Node with fillColor=#EFF6FF;strokeColor=#2563EB;fontColor=#1E3A8A;
46
+ Database: shape=cylinder3;size=12;boundedLbl=1;whiteSpace=wrap;html=1;fontFamily=Helvetica;fontSize=14;strokeWidth=1.5;fillColor=#FFFFFF;strokeColor=#CBD5E1;fontColor=#0F172A;
47
+ Container: rounded=1;absoluteArcSize=1;arcSize=16;whiteSpace=wrap;html=1;container=1;pointerEvents=0;verticalAlign=top;align=left;spacingLeft=16;spacingTop=10;fontFamily=Helvetica;fontSize=13;fontStyle=1;strokeWidth=1.5;fillColor=#F8FAFC;strokeColor=#E2E8F0;fontColor=#64748B;
48
+ Edge: edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#94A3B8;strokeWidth=1.5;endArrow=blockThin;endFill=1;endSize=6;fontFamily=Helvetica;fontSize=12;fontColor=#475569;labelBackgroundColor=#FFFFFF;
49
+ Main edge: same as Edge with strokeColor=#2563EB;strokeWidth=2;
50
+ Badge: ellipse;aspect=fixed;html=1;fillColor=#2563EB;strokeColor=none;fontColor=#FFFFFF;fontStyle=1;fontSize=13;
51
+ Title: text;html=1;align=left;verticalAlign=middle;fontFamily=Helvetica;fontSize=28;fontStyle=1;fontColor=#0F172A;
52
+ Subtitle: text;html=1;align=left;verticalAlign=middle;fontFamily=Helvetica;fontSize=16;fontColor=#64748B;
53
+ ```
54
+
55
+ ## Dark (on request)
56
+
57
+ Page background `#0B1220`. Title `#F8FAFC`, body text `#E2E8F0`, muted text `#94A3B8`. Accent `#60A5FA`.
58
+
59
+ | Element | fillColor | strokeColor | fontColor |
60
+ |---------|-----------|-------------|-----------|
61
+ | Node | `#111827` | `#334155` | `#F1F5F9` |
62
+ | Focus node | `#0F1E3D` | `#60A5FA` | `#DBEAFE` |
63
+ | External / secondary node | `#0F172A` | `#334155` | `#94A3B8` |
64
+ | Container / zone | `#0F172A` | `#1F2937` | `#94A3B8` |
65
+ | Edge | — | `#475569` | `#CBD5E1` |
66
+ | Main-path edge | — | `#60A5FA` | `#CBD5E1` |
67
+ | Badge | `#3B82F6` | `none` | `#FFFFFF` |
68
+
69
+ Use the Light styles with these colors and `labelBackgroundColor=#0B1220;` on edges. Muted label detail lines use `color="#94A3B8"`.
70
+
71
+ ## Multi-color (on request)
72
+
73
+ Keep the Light or Dark base (background, text, edges, containers, badges) and color nodes by role. Use at most four roles per diagram and add a legend of exactly the roles used.
74
+
75
+ | Role | Light fill / stroke / font | Dark fill / stroke / font |
76
+ |------|----------------------------|---------------------------|
77
+ | Service / client | `#EFF6FF` / `#3B82F6` / `#1E3A8A` | `#0F1E3D` / `#60A5FA` / `#DBEAFE` |
78
+ | API / gateway | `#EEF2FF` / `#6366F1` / `#312E81` | `#1A1B3D` / `#818CF8` / `#E0E7FF` |
79
+ | Data / storage | `#ECFDF5` / `#10B981` / `#064E3B` | `#0B2A22` / `#34D399` / `#D1FAE5` |
80
+ | Queue / event | `#FFFBEB` / `#F59E0B` / `#78350F` | `#2A2110` / `#FBBF24` / `#FEF3C7` |
81
+ | Security / auth | `#F5F3FF` / `#8B5CF6` / `#4C1D95` | `#221A3D` / `#A78BFA` / `#EDE9FE` |
82
+ | Error / alert | `#FEF2F2` / `#EF4444` / `#7F1D1D` | `#2D1416` / `#F87171` / `#FEE2E2` |
83
+ | External / neutral | `#F8FAFC` / `#94A3B8` / `#334155` | `#1E293B` / `#64748B` / `#CBD5E1` |
84
+
85
+ ## Motion design
86
+
87
+ 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
+
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.
90
+ - **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.
92
+ - **Focus by dimming.** `dim` everything except the part being explained, then `fadeIn` it back.
93
+ - **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.
@@ -94,19 +94,21 @@ For **vendor/branded icons** (AWS/Azure/GCP/Cisco/Kubernetes) and any non-trivia
94
94
 
95
95
  ### Required properties
96
96
 
97
+ The examples use Light theme colors; swap in the active theme's colors.
98
+
97
99
  ```xml
98
100
  <!-- Rectangle / rounded box -->
99
- <mxCell id="2" value="Label" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" vertex="1" parent="1">
101
+ <mxCell id="2" value="Label" style="rounded=1;absoluteArcSize=1;arcSize=12;whiteSpace=wrap;html=1;strokeWidth=1.5;fillColor=#FFFFFF;strokeColor=#CBD5E1;fontColor=#0F172A;" vertex="1" parent="1">
100
102
  <mxGeometry x="100" y="100" width="160" height="60" as="geometry" />
101
103
  </mxCell>
102
104
 
103
105
  <!-- Cylinder (database) -->
104
- <mxCell id="3" value="DB" style="shape=cylinder3;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;fontColor=#333333;" vertex="1" parent="1">
106
+ <mxCell id="3" value="DB" style="shape=cylinder3;whiteSpace=wrap;html=1;strokeWidth=1.5;fillColor=#FFFFFF;strokeColor=#CBD5E1;fontColor=#0F172A;" vertex="1" parent="1">
105
107
  <mxGeometry x="350" y="100" width="120" height="80" as="geometry" />
106
108
  </mxCell>
107
109
 
108
110
  <!-- Diamond (decision) -->
109
- <mxCell id="4" value="Check?" style="rhombus;whiteSpace=wrap;html=1;fillColor=#fff2cc;strokeColor=#d6b656;" vertex="1" parent="1">
111
+ <mxCell id="4" value="Check?" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=1.5;fillColor=#EFF6FF;strokeColor=#2563EB;fontColor=#1E3A8A;" vertex="1" parent="1">
110
112
  <mxGeometry x="100" y="220" width="160" height="80" as="geometry" />
111
113
  </mxCell>
112
114
  ```
@@ -165,13 +167,89 @@ For architecture diagrams with nested elements, use draw.io's parent-child conta
165
167
  ```
166
168
 
167
169
  **Edge style rules:**
168
- - **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;..."`
170
+ - **Animated connectors:** add `flowAnimation=1;` to an edge style to show moving dashes from source to target. Optional controls are `flowAnimationDuration=500;` (positive milliseconds; larger is slower), `flowAnimationTimingFunction=linear;` (`linear`, `ease`, `ease-in`, `ease-out`, or `ease-in-out`), and `flowAnimationDirection=normal;` (`normal`, `reverse`, `alternate`, or `alternate-reverse`). Example: `style="edgeStyle=orthogonalEdgeStyle;flowAnimation=1;flowAnimationDuration=1200;flowAnimationDirection=normal;rounded=1;..."`. A verified animated SVG preserves this motion; PNG/PDF/JPG remain static.
169
171
  - **Always** include `rounded=1;orthogonalLoop=1;jettySize=auto` — these enable smart routing that avoids overlaps
170
172
  - 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.
171
173
  - Add `<Array as="points">` waypoints when an edge must detour around an intermediate shape
172
174
  - **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
173
175
  - **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.
174
176
 
177
+ ### Motion with `drawio_animate`
178
+
179
+ Use `drawio_animate` for any animation beyond continuous connector flow. Author and review the static diagram first, then pass ordered steps that reference cell ids:
180
+
181
+ | Effect | Targets | Result |
182
+ |--------|---------|--------|
183
+ | `fadeIn` / `fadeOut` | any cell | Fade to fully visible / hidden (fadeIn also restores a dimmed cell) |
184
+ | `dim` | any cell | Fade to `value` (default 0.25) to push it into the background |
185
+ | `popIn` | hidden cell | Scale up from 60% with a slight overshoot while fading in |
186
+ | `slideIn` | hidden cell | Move 32px in `direction` (default `up`) while fading in |
187
+ | `drawIn` | hidden solid connector | Draw the line from source to target, then show its arrowhead and label |
188
+ | `highlight` | visible cell | Brief glow (and a 4% scale on shapes) in `color` |
189
+ | `travel` | visible connector | A dot runs along the connector in `color` |
190
+ | `wait` | none | Pause for `duration` ms |
191
+
192
+ - Steps run one after another; `parallel: true` starts a step with the previous one. `stagger` offsets consecutive cells of one step for a cascade.
193
+ - A cell whose first effect is an entrance (`fadeIn`, `popIn`, `slideIn`, `drawIn`) starts hidden. Everything else is visible from the start.
194
+ - `drawIn` needs a solid connector without `flowAnimation=1`; use `fadeIn` for dashed or flowing connectors.
195
+ - `loop` (default true) repeats the sequence after `hold` ms (default 1600) on the final state.
196
+ - The tool stores the steps on the page root cell (`drawmeMotion`), so a later call without `steps` re-exports the same motion after layout edits. `drawio_validate` checks the stored steps against the page.
197
+ - It writes `<name>.animated.svg` and a `<name>.storyboard.png` with one captioned frame per step. Use the storyboard to confirm order and visibility; it does not show easing or dot movement.
198
+ - The motion plays in browsers and wherever the SVG is shown as an image (for example a README). draw.io itself does not play it.
199
+
200
+ Example: reveal a three-hop flow, run traffic through it, then focus on the service.
201
+
202
+ ```json
203
+ { "steps": [
204
+ { "effect": "fadeIn", "cells": ["title", "subtitle"], "stagger": 150 },
205
+ { "effect": "popIn", "cells": ["client"] },
206
+ { "effect": "drawIn", "cells": ["e1"] },
207
+ { "effect": "popIn", "cells": ["api"] },
208
+ { "effect": "drawIn", "cells": ["e2"] },
209
+ { "effect": "slideIn", "cells": ["db", "queue"], "direction": "left", "stagger": 120 },
210
+ { "effect": "wait", "duration": 400 },
211
+ { "effect": "travel", "cells": ["e1"], "duration": 900 },
212
+ { "effect": "travel", "cells": ["e2"], "duration": 900 },
213
+ { "effect": "highlight", "cells": ["api"] }
214
+ ] }
215
+ ```
216
+
217
+ ### Timed page animation in standalone SVG
218
+
219
+ Use this native draw.io sequence only when draw.io's own viewer must play the animation; otherwise prefer `drawio_animate`. A page cannot carry both.
220
+
221
+ Use a page sequence when elements should appear, disappear, or fade in a defined order. The sequence is native draw.io animation JSON stored on a `UserObject` that wraps root cell `0`. Replace the normal `<mxCell id="0" />` with the wrapper — never include both:
222
+
223
+ ```xml
224
+ <UserObject label="" id="0" animation="{&quot;animation&quot;:{&quot;loop&quot;:true,&quot;steps&quot;:[{&quot;opacity&quot;:{&quot;cells&quot;:[&quot;service&quot;,&quot;edge-1&quot;],&quot;value&quot;:0}},{&quot;fadeIn&quot;:{&quot;cells&quot;:[&quot;service&quot;],&quot;delay&quot;:500}},{&quot;wait&quot;:300},{&quot;fadeIn&quot;:{&quot;cells&quot;:[&quot;edge-1&quot;],&quot;delay&quot;:500}}]}}">
225
+ <mxCell />
226
+ </UserObject>
227
+ <mxCell id="1" parent="0" />
228
+ ```
229
+
230
+ `drawio_export` with `animated: true` and `mode: "final"` compiles the portable sequence into standalone SVG CSS, verifies that motion exists, and keeps the editable diagram embedded by default. Animated mode defaults to SVG when `format` is omitted. It rejects non-SVG formats, preview mode, malformed or dangling animation references, and effects that cannot be represented reliably without draw.io's JavaScript viewer.
231
+
232
+ **Portable standalone-SVG actions:**
233
+
234
+ | JSON action | Required fields | Result |
235
+ |-------------|-----------------|--------|
236
+ | `opacity` | `cells`, `value` from 0 to 1 | Set opacity immediately |
237
+ | `show` / `hide` / `toggle` | `cells` | Change visibility immediately |
238
+ | `fadeIn` / `fadeOut` | `cells`, optional `delay` in ms | Fade to visible/hidden; default 1000ms |
239
+ | `fadeTo` | `cells`, `value`, optional `delay` | Fade to a specific opacity |
240
+ | `wait` | non-negative milliseconds | Delay the next sequential step |
241
+
242
+ Rules:
243
+
244
+ - `cells` is an array of cell ids. `"*"` selects all vertices and edges; `excludeCells` removes ids from that selection.
245
+ - Steps run sequentially. Add `"immediate":true` to a following step to run it in parallel with the previous step. Do not target the same cell twice in one parallel batch.
246
+ - `loop` and `enabled` default to `true`. Set `loop:false` for a one-shot sequence or `enabled:false` to retain but disable it.
247
+ - Use `opacity` to establish an initially hidden state. Do **not** set `visible="0"`: draw.io omits that cell from SVG, so it cannot be revealed later.
248
+ - Always specify explicit fade delays for deliberate pacing. Keep labels visible long enough to read and avoid fast flashing.
249
+ - Standalone SVG intentionally rejects draw.io viewer-only actions such as wipe/pop, highlight, dynamic flow toggles, style changes, navigation, tags, layers, and links. Use persistent `flowAnimation=1;` on an edge for connector motion.
250
+ - The generated SVG includes a `prefers-reduced-motion` fallback that stops motion and shows sequenced cells. Export a static PNG fallback too unless the user requests SVG only.
251
+ - PNG previews are static geometry reviews. Cross-check sequence order, targets, timing, direction, and loop settings structurally; only a verified final animated-SVG result proves the export retained animation.
252
+
175
253
  ### Distributing connections on a shape
176
254
 
177
255
  When multiple edges connect to the same shape, assign different entry/exit points to prevent stacking:
@@ -202,7 +280,7 @@ Before spreading multiple edges on one side, pick the side that faces the peer.
202
280
 
203
281
  ### Color palette (fillColor / strokeColor)
204
282
 
205
- *Used only when no user style preset is active (see `references/style-presets.md` → "Applying a preset").*
283
+ *Classic draw.io palette. Use it only when the user explicitly asks for the classic draw.io colors; otherwise use the active theme from `references/style-presets.md` (Light unless the user asks for Dark or Multi-color).*
206
284
 
207
285
  | Color name | fillColor | strokeColor | Use for |
208
286
  |-----------|-----------|-------------|---------|
@@ -216,7 +294,7 @@ Before spreading multiple edges on one side, pick the side that faces the peer.
216
294
 
217
295
  ### Legend (auto-generate from the palette)
218
296
 
219
- When a diagram uses 3+ semantic colors, add a legend so the color coding is self-explanatory. Generate it mechanically from the roles actually present — never invent legend entries that aren't in the diagram:
297
+ When a Multi-color (or explicitly requested classic) diagram uses 3+ semantic colors, add a legend so the color coding is self-explanatory. Generate it mechanically from the roles actually present — never invent legend entries that aren't in the diagram:
220
298
 
221
299
  ```xml
222
300
  <!-- Legend container: place in a corner clear of the diagram (e.g. below-left) -->