@diagrammo/dgmo 0.8.23 → 0.8.25

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 (72) hide show
  1. package/.claude/commands/dgmo.md +60 -72
  2. package/dist/cli.cjs +119 -114
  3. package/dist/editor.cjs +0 -2
  4. package/dist/editor.cjs.map +1 -1
  5. package/dist/editor.js +0 -2
  6. package/dist/editor.js.map +1 -1
  7. package/dist/highlight.cjs +0 -2
  8. package/dist/highlight.cjs.map +1 -1
  9. package/dist/highlight.js +0 -2
  10. package/dist/highlight.js.map +1 -1
  11. package/dist/index.cjs +690 -278
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +105 -18
  14. package/dist/index.d.ts +105 -18
  15. package/dist/index.js +680 -277
  16. package/dist/index.js.map +1 -1
  17. package/dist/internal.cjs +348 -51
  18. package/dist/internal.cjs.map +1 -1
  19. package/dist/internal.d.cts +93 -5
  20. package/dist/internal.d.ts +93 -5
  21. package/dist/internal.js +334 -38
  22. package/dist/internal.js.map +1 -1
  23. package/docs/guide/chart-area.md +17 -17
  24. package/docs/guide/chart-bar-stacked.md +12 -12
  25. package/docs/guide/chart-doughnut.md +10 -10
  26. package/docs/guide/chart-funnel.md +9 -9
  27. package/docs/guide/chart-heatmap.md +10 -10
  28. package/docs/guide/chart-kanban.md +2 -0
  29. package/docs/guide/chart-line.md +19 -19
  30. package/docs/guide/chart-multi-line.md +16 -16
  31. package/docs/guide/chart-pie.md +11 -11
  32. package/docs/guide/chart-polar-area.md +10 -10
  33. package/docs/guide/chart-radar.md +9 -9
  34. package/docs/guide/chart-scatter.md +24 -27
  35. package/docs/guide/index.md +3 -3
  36. package/docs/language-reference.md +46 -25
  37. package/fonts/Inter-Bold.ttf +0 -0
  38. package/fonts/Inter-Regular.ttf +0 -0
  39. package/fonts/LICENSE-Inter.txt +92 -0
  40. package/gallery/fixtures/bar-stacked.dgmo +12 -6
  41. package/gallery/fixtures/heatmap.dgmo +12 -6
  42. package/gallery/fixtures/multi-line.dgmo +11 -7
  43. package/gallery/fixtures/quadrant.dgmo +8 -8
  44. package/gallery/fixtures/scatter.dgmo +12 -12
  45. package/package.json +4 -2
  46. package/src/boxes-and-lines/parser.ts +13 -2
  47. package/src/boxes-and-lines/renderer.ts +22 -13
  48. package/src/chart-type-scoring.ts +162 -0
  49. package/src/chart-types.ts +437 -0
  50. package/src/cli.ts +147 -66
  51. package/src/completion.ts +0 -4
  52. package/src/d3.ts +9 -2
  53. package/src/dgmo-router.ts +85 -130
  54. package/src/editor/keywords.ts +0 -2
  55. package/src/fonts.ts +3 -2
  56. package/src/gantt/parser.ts +5 -1
  57. package/src/index.ts +24 -1
  58. package/src/infra/parser.ts +1 -1
  59. package/src/internal.ts +6 -2
  60. package/src/journey-map/layout.ts +7 -3
  61. package/src/journey-map/parser.ts +5 -1
  62. package/src/kanban/parser.ts +5 -1
  63. package/src/org/collapse.ts +1 -4
  64. package/src/org/parser.ts +1 -1
  65. package/src/org/renderer.ts +26 -17
  66. package/src/sequence/parser.ts +2 -2
  67. package/src/sequence/participant-inference.ts +0 -1
  68. package/src/sequence/renderer.ts +95 -263
  69. package/src/sharing.ts +0 -1
  70. package/src/sitemap/parser.ts +1 -1
  71. package/src/utils/tag-groups.ts +35 -5
  72. package/src/wireframe/parser.ts +3 -1
@@ -89,25 +89,18 @@ For **examples** of real diagrams, call `mcp__dgmo__get_examples("<type>")` —
89
89
 
90
90
  ### Creating a new diagram
91
91
 
92
- 1. **Pick the right chart type** — don't ask the user. Use these heuristics:
93
- - "show our API" / "how does X work" → `sequence`
94
- - "architecture" / "system overview" → `c4`
95
- - "database" / "schema" / "models" → `er`
96
- - "infrastructure" / "deployment" / "traffic" → `infra`
97
- - "process" / "decision" / "flow" → `flowchart`
98
- - "states" / "lifecycle" / "transitions" → `state`
99
- - "org" / "team" / "hierarchy" → `org`
100
- - "roadmap" / "project status" → `gantt`
101
- - "boxes" / "nodes and edges" / "general diagram" → `boxes-and-lines`
102
- - "compare" / "metrics" / "data" → `bar`, `line`, `pie`, etc.
103
- - If genuinely ambiguous, suggest your best guess with a one-line rationale.
92
+ 1. **Pick the right chart type** — always call `mcp__dgmo__suggest_chart_type({ prompt: <user's request> })` first. It returns up to 3 ranked candidates with a confidence banner and matched trigger phrases. Use the top match unless you have a strong reason to override it. If the MCP tool is unavailable (Setup Check fallback path), run `dgmo --chart-types` in a terminal to list supported types and pick from that list.
104
93
  2. **Get syntax + examples** — call `mcp__dgmo__get_language_reference("<type>")` and `mcp__dgmo__get_examples("<type>")`.
105
94
  3. **Write the `.dgmo` content** — compose the markup.
106
95
  4. **Validate first** — call `mcp__dgmo__validate_diagram(dgmo)` to catch syntax errors before rendering. If errors come back, fix them and validate again.
107
- 5. **Open in browser** — call `mcp__dgmo__preview_diagram([{dgmo, title}])` without asking. This is always the right default.
96
+ 5. **Open on online.diagrammo.app** — the **default** visual output. Call `mcp__dgmo__share_diagram(dgmo)` to get a URL, then immediately run `open <url>` in the shell. This lands the user on the web editor where they see the chart AND the code side-by-side, can tweak the markup interactively, and can share the link as-is. Do NOT just print the URL — always `open` it.
97
+
98
+ **Exception — image-output intent detected:** if the user's prompt explicitly asks for an image or saved file (phrases like "save as PNG", "export to SVG", "make an image", "render to a file", "give me a png", "I need an SVG"), skip the share URL and go straight to `mcp__dgmo__render_diagram` (see "Image output" below). The detection is intent-based, not keyword-strict — if in doubt, default to share URL and offer "Want me to save as PNG/SVG instead?"
99
+
100
+ **Side-by-side variants** still use `mcp__dgmo__preview_diagram` (multi-diagram preview is its killer feature). See "Side-by-side variants" below.
108
101
  6. **Save the source file** (if working in a project) — write it to `<name>.dgmo` so the user has an editable copy.
109
102
 
110
- Do not ask the user how they want to view the diagram. Just open it. They can ask for other formats if they want.
103
+ Do not ask the user how they want to view the diagram. Just open the share URL. They can ask for other formats if they want.
111
104
 
112
105
  ### Editing an existing diagram
113
106
 
@@ -117,7 +110,7 @@ When the user asks to modify a `.dgmo` file or says "update this diagram":
117
110
  2. **Understand it** — identify the chart type, key elements, and structure.
118
111
  3. **Make the change** — edit the file using the Edit tool. Preserve the user's style and organization.
119
112
  4. **Validate** — call `mcp__dgmo__validate_diagram(dgmo)` on the updated content.
120
- 5. **Preview** — call `mcp__dgmo__preview_diagram` so the user sees the result immediately.
113
+ 5. **Preview** — call `mcp__dgmo__share_diagram(dgmo)` and `open <url>` so the user sees the result on online.diagrammo.app. (Image-output intent exception applies — if the user asked for a PNG/SVG file explicitly, render to file instead.)
121
114
 
122
115
  Keep the diff minimal — don't rewrite the whole file when adding one element.
123
116
 
@@ -142,7 +135,7 @@ When `validate_diagram` or `render_diagram` returns errors:
142
135
  1. **Read the error messages** — they include line numbers and descriptions.
143
136
  2. **Fix the specific issues** — don't regenerate from scratch unless there are many errors.
144
137
  3. **Validate again** — loop until clean.
145
- 4. **Then render** — only call `preview_diagram` or `render_diagram` after validation passes.
138
+ 4. **Then render** — only call `share_diagram` (default), `preview_diagram` (variants), or `render_diagram` (files) after validation passes.
146
139
 
147
140
  Common fixes:
148
141
  - "Unknown directive" → check spelling, remove colons from directives
@@ -165,17 +158,26 @@ This opens a single page with both diagrams. Use this for:
165
158
  - Different levels of detail
166
159
  - Alternative structures for the same data
167
160
 
168
- ### Other output options (only when explicitly requested)
161
+ ### Image output (when the user explicitly asks for an image/file)
169
162
 
170
- | What the user wants | How to do it |
163
+ Trigger phrases: "save as PNG", "export to SVG", "make an image", "render to a file", "give me a PNG", "I need an SVG", "generate an image". For these, skip the share URL and go straight to file output:
164
+
165
+ | Intent | How to do it |
171
166
  |---|---|
172
- | **Quick look in the desktop app** | `mcp__dgmo__open_in_app(dgmo)` — opens directly in Diagrammo (macOS) |
173
- | **View in macOS Preview** | `mcp__dgmo__render_diagram(dgmo, format:"png", theme:"dark", palette:"nord")` → get temp path → `open <path>` |
174
167
  | **Save as PNG** | `mcp__dgmo__render_diagram(dgmo, format:"png", theme:"dark", palette:"nord")` → returns temp path; offer to copy to their preferred location. Or CLI: `dgmo file.dgmo -o out.png --theme dark --palette nord` |
175
168
  | **Save as SVG** | `mcp__dgmo__render_diagram(dgmo, format:"svg", theme:"dark", palette:"nord")` returns SVG text — write it to the desired path. Or CLI: `dgmo file.dgmo -o out.svg --theme dark --palette nord` |
176
- | **Shareable URL** | `mcp__dgmo__share_diagram(dgmo)` → returns a URL; immediately run `open <url>` — do NOT just display the URL |
169
+ | **View in macOS Preview** | `mcp__dgmo__render_diagram(dgmo, format:"png", theme:"dark", palette:"nord")` → get temp path `open <path>` |
170
+
171
+ ### Other output options (when explicitly requested)
172
+
173
+ | What the user wants | How to do it |
174
+ |---|---|
175
+ | **Quick look in the desktop app** | `mcp__dgmo__open_in_app(dgmo)` — opens directly in Diagrammo (macOS) |
176
+ | **Local HTML preview (not online.diagrammo.app)** | `mcp__dgmo__preview_diagram([{dgmo, title}])` — useful when the user specifically wants a local file or is offline |
177
177
  | **Copy markup to clipboard** | Run `echo '<dgmo markup>' \| pbcopy` |
178
178
 
179
+ (The share URL — `mcp__dgmo__share_diagram` + `open` — is the DEFAULT visual output, not an alternative. See "Creating a new diagram → step 5" above.)
180
+
179
181
  ### Embedding diagrams in docs
180
182
 
181
183
  When the user wants a diagram in a README, PR description, or markdown file:
@@ -199,15 +201,15 @@ for f in diagrams/*.dgmo; do dgmo "$f" -o "${f%.dgmo}.png" --theme dark --palett
199
201
 
200
202
  Or for SVG: replace `.png` with `.svg` in the output.
201
203
 
202
- ### Share link to clipboard
204
+ ### Share link to clipboard (when the user asks for the URL without opening)
203
205
 
204
- After generating a share link, always copy it to the clipboard automatically:
206
+ If the user wants the link in clipboard rather than opened (e.g., they want to paste it into Slack themselves), after generating the share link:
205
207
 
206
208
  ```bash
207
209
  echo '<url>' | pbcopy
208
210
  ```
209
211
 
210
- Then tell the user it's been copied.
212
+ Then tell the user it's been copied. Otherwise, the default is always `open <url>` — that's what step 5 of the main workflow does.
211
213
 
212
214
  ## CLI Reference
213
215
 
@@ -222,42 +224,11 @@ Key options:
222
224
  - `--theme <theme>` — `light` (default), `dark`, `transparent`
223
225
  - `--palette <name>` — `nord` (default), `solarized`, `catppuccin`, `rose-pine`, `gruvbox`, `tokyo-night`, `one-dark`, `bold`
224
226
  - `--copy` — copy the URL to clipboard (use with `-o url`)
225
- - `--no-branding` — omit diagrammo.app branding from exports
226
227
  - `--chart-types` — list all supported chart types
227
228
 
228
229
  ## Supported Chart Types
229
230
 
230
- | Type | Use case |
231
- |------|----------|
232
- | `bar` | Categorical comparisons |
233
- | `line` / `multi-line` / `area` | Trends over time |
234
- | `pie` / `doughnut` | Part-to-whole |
235
- | `radar` / `polar-area` | Multi-dimensional metrics |
236
- | `bar-stacked` | Multi-series categorical |
237
- | `scatter` | 2D data points or bubble chart |
238
- | `sankey` | Flow / allocation |
239
- | `chord` | Circular flow relationships |
240
- | `function` | Mathematical expressions |
241
- | `heatmap` | Matrix intensity |
242
- | `funnel` | Conversion pipeline |
243
- | `slope` | Change between two periods |
244
- | `wordcloud` | Term frequency |
245
- | `arc` | Network relationships |
246
- | `timeline` | Events, eras, date ranges |
247
- | `venn` | Set overlaps |
248
- | `quadrant` | 2x2 positioning matrix |
249
- | `sequence` | Message / interaction flows |
250
- | `flowchart` | Decision trees, process flows |
251
- | `state` | State machine / lifecycle |
252
- | `class` | UML class hierarchies |
253
- | `er` | Database schemas |
254
- | `org` | Hierarchical tree structures |
255
- | `kanban` | Task / workflow columns |
256
- | `c4` | System architecture (context → container → component → deployment) |
257
- | `sitemap` | Website / app navigation structure |
258
- | `infra` | Infrastructure traffic flow with rps computation |
259
- | `gantt` | Project scheduling with dependencies |
260
- | `boxes-and-lines` | General-purpose node-edge diagrams with groups and tags |
231
+ Call `mcp__dgmo__list_chart_types` to see every supported type with descriptions, or `dgmo --chart-types` in a terminal as a CLI fallback. When picking for a new diagram, use `mcp__dgmo__suggest_chart_type` — it scores the full list against the user's prompt (see "Creating a new diagram → step 1").
261
232
 
262
233
  ## Key Syntax Patterns
263
234
 
@@ -317,17 +288,24 @@ Shapes: `(oval)` `[rect]` `<diamond>` `/parallelogram/` `[[subroutine]]` `[docum
317
288
 
318
289
  ### bar / line / pie (data charts)
319
290
 
291
+ **Data-chart conventions (apply to every chart under §15 of the spec):**
292
+ - Data rows are **space-separated**. Commas between values are tolerated for back-compat but not idiomatic — do not generate them.
293
+ - Multi-series `series` declarations use the **indented one-per-line form** when there's more than one series; it's easier to read and reviewers prefer it.
294
+
320
295
  ```
321
- // bar
296
+ // bar (single series)
322
297
  bar Revenue by Region
323
298
  series Revenue
324
299
  North 850
325
300
  South 620
326
301
 
327
- // line (multi-series)
328
- series Sales(red), Costs(blue)
329
- Q1 100, 50
330
- Q2 120, 55
302
+ // line (multi-series — use indented series block + space-separated values)
303
+ line Quarterly Numbers
304
+ series
305
+ Sales (red)
306
+ Costs (blue)
307
+ Q1 100 50
308
+ Q2 120 55
331
309
 
332
310
  // pie
333
311
  pie Market Share
@@ -543,14 +521,14 @@ top-right Major Projects
543
521
  bottom-left Fill-ins
544
522
  bottom-right Avoid(red)
545
523
 
546
- Dark Mode (blue) 0.25, 0.85
547
- API v2 0.8, 0.9
548
- Fix Typos 0.1, 0.15
524
+ Dark Mode (blue) 0.25 0.85
525
+ API v2 0.8 0.9
526
+ Fix Typos 0.1 0.15
549
527
  ```
550
528
 
551
- - Axis labels: `x-label Low, High` and `y-label Low, High`
529
+ - Axis labels: `x-label Low, High` and `y-label Low, High` (comma is the low/high delimiter here by design, not a data-row delimiter)
552
530
  - Quadrant labels: `top-left`, `top-right`, `bottom-left`, `bottom-right`
553
- - Data: `Label (color) x, y` where x,y are 0–1
531
+ - Data points: `Label (color) x y` space-separated per §15 Rule A (comma-form tolerated for back-compat but not idiomatic)
554
532
 
555
533
  ### sankey / chord
556
534
 
@@ -610,15 +588,15 @@ x-label Funding ($M)
610
588
  y-label Revenue ($M)
611
589
 
612
590
  [SaaS](blue)
613
- Acme 12, 8.5
614
- DataSync 5.2, 3.1
591
+ Acme 12 8.5
592
+ DataSync 5.2 3.1
615
593
 
616
594
  [Fintech](green)
617
- PayFlow 45, 32
618
- LendTech 18, 12.5
595
+ PayFlow 45 32
596
+ LendTech 18 12.5
619
597
  ```
620
598
 
621
- - Data: `Label x, y` or `Label x, y, size` (bubble chart)
599
+ - Data: `Label x y` or `Label x y size` (bubble chart) — space-separated per §15 Rule A
622
600
  - Groups: `[Category](color)` headers
623
601
  - Options: `labels on`, `xlabel`, `ylabel`, `sizelabel`
624
602
 
@@ -671,13 +649,23 @@ tag: Group ❌ use `tag Group` (no colon)
671
649
  note: text ❌ use `note text` (no colon)
672
650
  ```
673
651
 
652
+ **Data-chart style (back-compat tolerated, but not idiomatic — don't generate these):**
653
+
654
+ ```
655
+ Q1 100, 200, 300 ⚠ prefer space-separated: `Q1 100 200 300`
656
+ series A (red), B (blue), C (green) ⚠ for ≥2 series, prefer the indented block:
657
+ series
658
+ A (red)
659
+ B (blue)
660
+ C (green)
661
+ ```
662
+
674
663
  ## Tips
675
664
 
676
665
  - Default theme: `dark`, default palette: `nord` — use these unless the user requests otherwise.
677
666
  - Always validate before rendering — `validate_diagram` is much faster than a failed render.
678
667
  - Always call `get_examples` before generating an unfamiliar chart type — real examples beat guessing.
679
668
  - Stdin mode for quick renders: `echo "..." | dgmo -o out.png`
680
- - For C4, `--c4-level` drills from context → containers → components → deployment.
681
669
  - When auto-detection picks the wrong chart type, add an explicit type as the first word on the first line.
682
670
  - `mcp__dgmo__preview_diagram` accepts multiple diagrams at once — useful for showing variants side by side.
683
671
  - When the user says "diagram this" while looking at code, read the code first and pick the chart type yourself — don't ask.