zombie-mermaid 2.0.0 → 2.2.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.
Files changed (49) hide show
  1. package/README.md +10 -5
  2. package/dist/ascii.cjs +52 -9
  3. package/dist/ascii.cjs.map +1 -1
  4. package/dist/ascii.js +3156 -1928
  5. package/dist/ascii.js.map +1 -1
  6. package/dist/cli.js +5774 -5555
  7. package/dist/index.cjs +46 -46
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +50 -0
  10. package/dist/index.d.ts +50 -0
  11. package/dist/index.js +4352 -4299
  12. package/dist/index.js.map +1 -1
  13. package/dist/mcp.cjs +5867 -5615
  14. package/dist/mcp.cjs.map +1 -1
  15. package/dist/mcp.d.cts +2 -2
  16. package/dist/mcp.d.ts +2 -2
  17. package/dist/mcp.js +5867 -5615
  18. package/dist/mcp.js.map +1 -1
  19. package/package.json +4 -1
  20. package/src/__tests__/ascii-class-label-row-collision-531.test.ts +135 -0
  21. package/src/__tests__/ascii-state-bidirectional-label-swap-530.test.ts +130 -0
  22. package/src/__tests__/cli-png.test.ts +35 -0
  23. package/src/__tests__/cli-render.test.ts +120 -0
  24. package/src/__tests__/cli-test-helpers.ts +23 -5
  25. package/src/__tests__/cli.test.ts +119 -1
  26. package/src/__tests__/mcp-check-sequence-activations-tool.test.ts +85 -0
  27. package/src/__tests__/mcp-server.test.ts +33 -3
  28. package/src/__tests__/parser.test.ts +51 -1
  29. package/src/__tests__/render-options-per-type.test.ts +174 -0
  30. package/src/__tests__/sequence-activation-check.test.ts +220 -0
  31. package/src/ascii/class-diagram.ts +130 -66
  32. package/src/ascii/draw-arrows.ts +42 -7
  33. package/src/ascii/index.ts +13 -10
  34. package/src/class/layout.ts +3 -3
  35. package/src/cli/parse-args.ts +108 -45
  36. package/src/cli/png.ts +38 -0
  37. package/src/cli/render.ts +29 -6
  38. package/src/cli.ts +17 -7
  39. package/src/diagram-registry.ts +190 -0
  40. package/src/er/layout.ts +3 -3
  41. package/src/index.ts +35 -55
  42. package/src/layout-engine.ts +7 -3
  43. package/src/mcp/server.ts +34 -6
  44. package/src/mcp/tools/check-sequence-activations.ts +89 -0
  45. package/src/parser.ts +58 -1
  46. package/src/sequence/activation-check.ts +148 -0
  47. package/src/sequence/layout.ts +2 -2
  48. package/src/types.ts +120 -0
  49. package/src/xychart/layout.ts +2 -2
package/README.md CHANGED
@@ -136,6 +136,7 @@ zombie-mermaid render diagram.mmd -o out.svg # Same — the format is
136
136
  zombie-mermaid render diagram.mmd --svg -o - | pbcopy # Write the SVG to stdout
137
137
  zombie-mermaid render diagram.mmd --ascii -o out.txt # Write the ASCII rendering to a file
138
138
  zombie-mermaid render diagram.mmd --html # Self-contained pan/zoom HTML viewer
139
+ zombie-mermaid render diagram.mmd --png # Rasterize to diagram.png
139
140
  cat diagram.mmd | zombie-mermaid render --ascii # Read from stdin
140
141
  zombie-mermaid themes # List built-in theme names
141
142
  zombie-mermaid --help # Show all options
@@ -147,9 +148,11 @@ zombie-mermaid --help # Show all options
147
148
  hyperlinks — off by default, since terminal and pager support varies (see
148
149
  [ASCII terminal hyperlinks](docs/diagrams.md#ascii-terminal-hyperlinks)).
149
150
 
150
- **Output rules.** `-o` is the destination for the run's _file_ output — SVG or HTML when `--svg`/`--html` is given, otherwise the ASCII rendering — and `-o -` sends it to stdout instead. A recognised extension (`.svg`, `.html`/`.htm`, `.txt`) picks the format on its own, so the flag can be dropped; an extension that contradicts an explicit flag (`--svg -o out.txt`) is an error, while unrecognised ones are simply used as given. `--svg`/`--html` with no `-o` writes `<input stem>.svg`/`.html` beside the input (stdin input has no name to derive from, so it must pass `-o`). `--svg` and `--html` cannot both be set — run the command twice for both. ASCII always prints to the terminal when SVG/HTML is also requested (`--ascii --svg -o out.svg`), and never carries ANSI colour codes when written to a file. **An existing output file is never overwritten unless you pass `--force`/`-f`.**
151
+ **Output rules.** `-o` is the destination for the run's _file_ output — SVG, HTML, or PNG when `--svg`/`--html`/`--png` is given, otherwise the ASCII rendering — and `-o -` sends it to stdout instead. A recognised extension (`.svg`, `.html`/`.htm`, `.txt`, `.png`) picks the format on its own, so the flag can be dropped; an extension that contradicts an explicit flag (`--svg -o out.txt`) is an error, while unrecognised ones are simply used as given. `--svg`/`--html`/`--png` with no `-o` writes `<input stem>.svg`/`.html`/`.png` beside the input (stdin input has no name to derive from, so it must pass `-o`). Only one of `--svg`/`--html`/`--png` can be set at a time — run the command twice for more than one. ASCII always prints to the terminal when one of them is also requested (`--ascii --svg -o out.svg`), and never carries ANSI colour codes when written to a file. **An existing output file is never overwritten unless you pass `--force`/`-f`.**
151
152
 
152
- **`--html`** wraps the rendered SVG in a self-contained pan/zoom viewer — one file, no server, no network — with drag/scroll pan, ctrl/cmd+scroll and pinch to zoom, fit/1:1 buttons, a light/dark toggle that follows `prefers-color-scheme`, and keyboard controls. It opens straight from disk and survives being emailed as a single attachment. This is the one place in the project that ships client-side JavaScript, and deliberately so — see [`docs/decisions/no-script-interactivity.md`](docs/decisions/no-script-interactivity.md): the library's own SVG output stays permanently script-free, and this viewer is a separate CLI artifact wrapping that output, never part of it.
153
+ **`--html`** wraps the rendered SVG in a self-contained pan/zoom viewer — one file, no server, no network — with drag/scroll pan, ctrl/cmd+scroll and pinch to zoom, fit/1:1 buttons, a light/dark toggle that follows `prefers-color-scheme`, and keyboard controls. It opens straight from disk (including over `file://`, no server needed) and survives being emailed as a single attachment — see [Using the self-contained HTML viewer](docs/guides/html-viewer.md) for the full controls reference. This is the one place in the project that ships client-side JavaScript, and deliberately so — see [`docs/decisions/no-script-interactivity.md`](docs/decisions/no-script-interactivity.md): the library's own SVG output stays permanently script-free, and this viewer is a separate CLI artifact wrapping that output, never part of it.
154
+
155
+ **`--png`** rasterizes the diagram for anywhere SVG isn't accepted — issue trackers, Slack, docs tools, email — at the SVG's own pixel dimensions (1:1, no scaling). It always resolves CSS colors first, automatically, the same substitution `--resolve-colors` does for `--svg` — a rasterizer can't evaluate `var()`/`color-mix()`, so skipping this would render the whole theme black. Rasterization is via [`@resvg/resvg-js`](https://github.com/thx/resvg-js), listed as an `optionalDependency`: a normal install pulls its native binary like any other dependency, but a platform it has no prebuilt binary for, or an install run with `--no-optional`, simply skips it — `--png` then fails with a clear error telling you how to install it explicitly, rather than breaking the rest of the CLI.
153
156
 
154
157
  ---
155
158
 
@@ -157,7 +160,7 @@ hyperlinks — off by default, since terminal and pager support varies (see
157
160
 
158
161
  > 🧪 **Experimental — shipped to gauge interest, not a finished or best-effort implementation.** This is a first cut covering the common case; the tool surface may change based on feedback. Try it and [open an issue](https://github.com/dfadler/zombie-mermaid/issues/new) with what you'd want from it.
159
162
 
160
- `zombie-mermaid mcp` starts a [Model Context Protocol](https://modelcontextprotocol.io/) server on stdio, exposing the library's rendering as two tools: `render_mermaid_svg` and `render_mermaid_ascii`. Point an MCP client (Claude Desktop, Claude Code, or anything else that speaks MCP) at it to render Mermaid diagrams directly in a conversation, without shelling out to the CLI or importing the library.
163
+ `zombie-mermaid mcp` starts a [Model Context Protocol](https://modelcontextprotocol.io/) server on stdio, exposing the library's rendering as three tools: `render_mermaid_svg`, `render_mermaid_ascii`, and `check_mermaid_sequence_activations`. Point an MCP client (Claude Desktop, Claude Code, or anything else that speaks MCP) at it to render Mermaid diagrams directly in a conversation, without shelling out to the CLI or importing the library.
161
164
 
162
165
  Example Claude Desktop / Claude Code MCP server config:
163
166
 
@@ -172,7 +175,9 @@ Example Claude Desktop / Claude Code MCP server config:
172
175
  }
173
176
  ```
174
177
 
175
- Both tools accept a `diagram` string plus a handful of rendering options (`theme`, `transparent`, `font` for SVG; `useAscii`, `paddingX`/`paddingY`/`boxBorderPadding` for ASCII) — see each tool's `inputSchema` for the full, current list. Invalid Mermaid syntax comes back as a normal tool error (`isError: true`) rather than crashing the connection.
178
+ All three tools accept a `diagram` string. The two render tools also take a handful of rendering options (`theme`, `transparent`, `font` for SVG; `useAscii`, `paddingX`/`paddingY`/`boxBorderPadding` for ASCII) — see each tool's `inputSchema` for the full, current list. Invalid Mermaid syntax comes back as a normal tool error (`isError: true`) rather than crashing the connection.
179
+
180
+ `check_mermaid_sequence_activations` is a mechanical, deterministic check — no LLM judgment involved — for a specific gap in existing Mermaid validators: every `activate X` (or `+` arrow shorthand) in a `sequenceDiagram` must be closed by a matching `deactivate X` (`-` shorthand) before the diagram ends. It returns a JSON report (`{ ok, issues }`) rather than rendering anything, and errors (`isError: true`) if given a non-sequence diagram.
176
181
 
177
182
  To embed the server in your own process instead of running it as a subcommand, import `zombie-mermaid/mcp` and connect it to any [MCP `Transport`](https://modelcontextprotocol.io/) yourself:
178
183
 
@@ -188,7 +193,7 @@ await server.connect(new StdioServerTransport())
188
193
 
189
194
  ## Docs
190
195
 
191
- - [Guides](docs/guides/) — task-oriented walkthroughs: [browsing the samples](docs/guides/samples.md), [choosing a theme](docs/guides/theming.md)
196
+ - [Guides](docs/guides/) — task-oriented walkthroughs: [browsing the samples](docs/guides/samples.md), [choosing a theme](docs/guides/theming.md), [using the HTML viewer](docs/guides/html-viewer.md)
192
197
  - [Accessibility](docs/accessibility.md) — conformance statement: what's guaranteed (and CI-enforced), what's implemented but unverified by automation, and what isn't covered
193
198
  - [Theming](docs/theming.md) — the two-color foundation, enriched mode, built-in themes, custom themes, Shiki compatibility
194
199
  - [Supported Diagrams](docs/diagrams.md) — syntax for every diagram type, XY chart styling, and ASCII rendering options