@diagrammo/dgmo 0.7.3 → 0.8.1

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 (62) hide show
  1. package/AGENTS.md +15 -20
  2. package/README.md +56 -58
  3. package/dist/cli.cjs +188 -181
  4. package/dist/index.cjs +3522 -1072
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +196 -43
  7. package/dist/index.d.ts +196 -43
  8. package/dist/index.js +3509 -1072
  9. package/dist/index.js.map +1 -1
  10. package/docs/language-reference.md +629 -289
  11. package/package.json +1 -1
  12. package/src/c4/layout.ts +6 -9
  13. package/src/c4/parser.ts +189 -83
  14. package/src/c4/renderer.ts +8 -9
  15. package/src/chart.ts +296 -83
  16. package/src/class/parser.ts +54 -37
  17. package/src/class/renderer.ts +8 -8
  18. package/src/cli.ts +8 -8
  19. package/src/colors.ts +4 -1
  20. package/src/completion.ts +757 -10
  21. package/src/d3.ts +324 -78
  22. package/src/dgmo-router.ts +63 -8
  23. package/src/echarts.ts +735 -241
  24. package/src/er/parser.ts +94 -76
  25. package/src/er/renderer.ts +6 -5
  26. package/src/gantt/parser.ts +144 -69
  27. package/src/gantt/renderer.ts +50 -14
  28. package/src/gantt/types.ts +3 -3
  29. package/src/graph/flowchart-parser.ts +97 -37
  30. package/src/graph/flowchart-renderer.ts +4 -3
  31. package/src/graph/state-parser.ts +50 -31
  32. package/src/graph/state-renderer.ts +4 -3
  33. package/src/index.ts +14 -5
  34. package/src/infra/compute.ts +1 -0
  35. package/src/infra/layout.ts +3 -0
  36. package/src/infra/parser.ts +291 -92
  37. package/src/infra/renderer.ts +172 -30
  38. package/src/infra/types.ts +5 -0
  39. package/src/initiative-status/layout.ts +1 -1
  40. package/src/initiative-status/parser.ts +121 -47
  41. package/src/initiative-status/renderer.ts +42 -23
  42. package/src/initiative-status/types.ts +10 -2
  43. package/src/kanban/parser.ts +60 -37
  44. package/src/kanban/renderer.ts +2 -2
  45. package/src/kanban/types.ts +1 -0
  46. package/src/org/layout.ts +9 -9
  47. package/src/org/parser.ts +39 -40
  48. package/src/org/renderer.ts +5 -6
  49. package/src/org/resolver.ts +26 -19
  50. package/src/render.ts +1 -1
  51. package/src/sequence/parser.ts +304 -95
  52. package/src/sequence/renderer.ts +9 -9
  53. package/src/sitemap/layout.ts +3 -4
  54. package/src/sitemap/parser.ts +57 -49
  55. package/src/sitemap/renderer.ts +6 -7
  56. package/src/utils/arrows.ts +25 -6
  57. package/src/utils/duration.ts +43 -7
  58. package/src/utils/legend-constants.ts +26 -0
  59. package/src/utils/legend-svg.ts +167 -0
  60. package/src/utils/parsing.ts +247 -7
  61. package/src/utils/tag-groups.ts +160 -15
  62. package/src/utils/title-constants.ts +9 -0
package/AGENTS.md CHANGED
@@ -34,8 +34,7 @@ When the `dgmo` MCP server is configured, use these tools directly:
34
34
 
35
35
  ### Sequence diagram
36
36
  ```
37
- chart: sequence
38
- title: Auth Flow
37
+ sequence Auth Flow
39
38
 
40
39
  User -Login-> API
41
40
  API -Find user-> DB
@@ -48,8 +47,7 @@ DB -user-> API
48
47
 
49
48
  ### Flowchart
50
49
  ```
51
- chart: flowchart
52
- title: Process
50
+ flowchart Process
53
51
 
54
52
  (Start) -> <Valid?>
55
53
  -yes-> [Process] -> (Done)
@@ -58,19 +56,17 @@ title: Process
58
56
 
59
57
  ### Bar chart
60
58
  ```
61
- chart: bar
62
- title: Revenue
63
- series: USD
59
+ bar Revenue
60
+ series USD
64
61
 
65
- North: 850
66
- South: 620
67
- East: 1100
62
+ North 850
63
+ South 620
64
+ East 1100
68
65
  ```
69
66
 
70
67
  ### ER diagram
71
68
  ```
72
- chart: er
73
- title: Schema
69
+ er Schema
74
70
 
75
71
  users
76
72
  id: int [pk]
@@ -85,7 +81,7 @@ users 1--* posts : writes
85
81
 
86
82
  ### Org chart
87
83
  ```
88
- chart: org
84
+ org
89
85
 
90
86
  CEO
91
87
  VP Engineering
@@ -96,8 +92,8 @@ CEO
96
92
 
97
93
  ### Infra chart
98
94
  ```
99
- chart: infra
100
- direction: LR
95
+ infra
96
+ direction LR
101
97
 
102
98
  edge
103
99
  rps: 10000
@@ -123,11 +119,10 @@ bar, line, multi-line, area, pie, doughnut, radar, polar-area, bar-stacked, scat
123
119
 
124
120
  ## Common patterns
125
121
 
126
- - `chart: type` — explicit chart type (auto-detected if unambiguous)
127
- - `title: text` — diagram title
122
+ - `type` — chart type as first line, optionally followed by title: `bar Revenue`
128
123
  - `// comment` — only `//` comments (not `#`)
129
- - `(colorname)` — inline colors: `Label(red): 100`
130
- - `series: A(red), B(blue)` — multi-series with colors
124
+ - `(colorname)` — inline colors: `Label(red) 100`
125
+ - `series A(red), B(blue)` — multi-series with colors
131
126
 
132
127
  ## Rendering via CLI
133
128
 
@@ -142,7 +137,7 @@ dgmo file.dgmo --json # structured JSON output
142
137
  - Don't use `#` for comments — use `//`
143
138
  - Don't use `end` to close sequence blocks — indentation closes them
144
139
  - Don't use hex colors in section headers — use named colors
145
- - Don't forget `chart:` directive when content is ambiguous
140
+ - Don't forget chart type on the first line when content is ambiguous
146
141
  - Sequence arrows: `->` (sync), `~>` (async) — always left-to-right
147
142
 
148
143
  Full reference: call `get_language_reference` MCP tool or visit diagrammo.app/docs
package/README.md CHANGED
@@ -4,6 +4,13 @@ A diagram markup language — parser, config builder, renderer, and color system
4
4
 
5
5
  Write plain-text `.dgmo` files and render them as charts, diagrams, and visualizations. Supports 26 chart types — data charts, structural diagrams, and sequence diagrams. Ships as both a library and a standalone CLI.
6
6
 
7
+ ## Language Reference
8
+
9
+ Full syntax documentation for every chart type, directive, and option:
10
+
11
+ - **Online:** [diagrammo.app/reference](https://diagrammo.app/reference)
12
+ - **Local:** [`docs/language-reference.md`](docs/language-reference.md)
13
+
7
14
  ## Install
8
15
 
9
16
  ### As a library
@@ -112,7 +119,7 @@ dgmo diagram.dgmo --theme dark --palette catppuccin
112
119
 
113
120
  ## How it works
114
121
 
115
- Every `.dgmo` file is plain text with a `chart: <type>` header followed by metadata and data. The library parses each chart type and gives you either:
122
+ Every `.dgmo` file is plain text with a `<type>` header line (optionally followed by a title) and then metadata and data. The library parses each chart type and gives you either:
116
123
 
117
124
  - A **config object** you render yourself
118
125
  - A **rendered SVG** directly
@@ -134,15 +141,14 @@ import * as echarts from 'echarts';
134
141
  const colors = getPalette('nord').light;
135
142
 
136
143
  const content = `
137
- chart: bar
138
- title: Revenue by Quarter
139
- xlabel: Quarter
140
- ylabel: Revenue ($M)
141
-
142
- Q1: 12
143
- Q2: 19
144
- Q3: 15
145
- Q4: 22
144
+ bar Revenue by Quarter
145
+ xlabel Quarter
146
+ ylabel Revenue ($M)
147
+
148
+ Q1 12
149
+ Q2 19
150
+ Q3 15
151
+ Q4 22
146
152
  `;
147
153
 
148
154
  const parsed = parseChart(content, colors);
@@ -159,15 +165,14 @@ import * as echarts from 'echarts';
159
165
  const colors = getPalette('nord').light;
160
166
 
161
167
  const content = `
162
- chart: sankey
163
- title: Energy Flow
168
+ sankey Energy Flow
164
169
 
165
170
  Coal (orange)
166
- Electricity: 50
171
+ Electricity 50
167
172
  Gas (blue)
168
- Electricity: 30
169
- Electricity -> Industry: 45
170
- Electricity -> Homes: 35
173
+ Electricity 30
174
+ Electricity -> Industry 45
175
+ Electricity -> Homes 35
171
176
  `;
172
177
 
173
178
  const parsed = parseExtendedChart(content);
@@ -183,12 +188,11 @@ import { parseVisualization, renderTimeline, getPalette } from '@diagrammo/dgmo'
183
188
  const colors = getPalette('nord').light;
184
189
 
185
190
  const content = `
186
- chart: timeline
187
- title: Project Milestones
191
+ timeline Project Milestones
188
192
 
189
- 2024-01: Kickoff
190
- 2024-03 -> 2024-06: Development
191
- 2024-07: Launch
193
+ 2024-01 Kickoff
194
+ 2024-03 -> 2024-06 Development
195
+ 2024-07 Launch
192
196
  `;
193
197
 
194
198
  const parsed = parseVisualization(content, colors);
@@ -205,7 +209,7 @@ import { parseSequenceDgmo, renderSequenceDiagram, getPalette } from '@diagrammo
205
209
  const colors = getPalette('nord').light;
206
210
 
207
211
  const content = `
208
- title: Login Flow
212
+ sequence Login Flow
209
213
 
210
214
  User -login(email, pass)-> AuthService
211
215
  AuthService -findByEmail(email)-> UserDB
@@ -235,8 +239,8 @@ renderSequenceDiagram(container, parsed, colors, false, (lineNum) => {
235
239
  - `[GroupName]` — participant grouping
236
240
  - `Name is a database` — explicit type declaration
237
241
  - `Name position 0` — explicit ordering
238
- - `activations: off` — disable activation bars
239
- - `tag: Name` + `Value(color)` entries — color-coded metadata dimensions with interactive legend
242
+ - `activations off` — disable activation bars
243
+ - `tag Name` + `Value(color)` entries — color-coded metadata dimensions with interactive legend
240
244
  - `| key: value` — attach tag metadata to participants, messages, or groups
241
245
 
242
246
  **Participant type inference** — 104 rules map names to shapes automatically:
@@ -262,8 +266,7 @@ import { parseFlowchart, layoutGraph, renderFlowchart, getPalette } from '@diagr
262
266
  const colors = getPalette('nord').dark;
263
267
 
264
268
  const content = `
265
- chart: flowchart
266
- title: Decision Flow
269
+ flowchart Decision Flow
267
270
 
268
271
  (Start) -> /Get Input/ -> <Valid?>
269
272
  -yes-> [Process Data] -> (Done)
@@ -285,8 +288,7 @@ import { parseERDiagram, layoutERDiagram, renderERDiagram, getPalette } from '@d
285
288
  const colors = getPalette('nord').light;
286
289
 
287
290
  const content = `
288
- chart: er
289
- title: Blog Platform
291
+ er Blog Platform
290
292
 
291
293
  users
292
294
  id: int [pk]
@@ -308,9 +310,8 @@ renderERDiagram(container, parsed, layout, colors, false);
308
310
 
309
311
  **ER diagram syntax:**
310
312
 
311
- - `chart: er` — chart type header
312
- - `title: Text` — optional title
313
- - `notation: labels` — use text labels instead of crow's foot markers
313
+ - `er` — chart type (first line), optionally followed by title: `er Blog Platform`
314
+ - `notation labels` — use text labels instead of crow's foot markers
314
315
  - Table declaration: unindented name (e.g. `users`, `order_items`)
315
316
  - Column: indented `name: type [constraints]`
316
317
  - Constraints: `[pk]`, `[fk]`, `[unique]`, `[nullable]`, or combined `[pk, unique]`
@@ -330,10 +331,9 @@ import { parseOrg, renderOrg, getPalette } from '@diagrammo/dgmo';
330
331
  const colors = getPalette('nord').light;
331
332
 
332
333
  const content = `
333
- chart: org
334
- title: Engineering
334
+ org Engineering
335
335
 
336
- tag: Location
336
+ tag Location
337
337
  NY(blue)
338
338
  SF(green)
339
339
 
@@ -354,8 +354,7 @@ renderOrg(container, parsed, colors, false);
354
354
 
355
355
  **Org chart syntax:**
356
356
 
357
- - `chart: org` — chart type header (required)
358
- - `title: Text` — optional title
357
+ - `org` — chart type (first line), optionally followed by title: `org Engineering`
359
358
  - Indentation defines parent-child hierarchy (2 or 4 spaces, consistent within file)
360
359
  - Multiple root nodes supported (e.g., co-CEOs at top level)
361
360
 
@@ -389,25 +388,25 @@ Containers can nest and carry their own metadata (key: value pairs). Children ar
389
388
  **Tag groups** — define color coding for metadata values. Must appear before org content:
390
389
 
391
390
  ```
392
- tag: Location alias l
391
+ tag Location alias l
393
392
  NY(blue)
394
393
  SF(green)
395
394
  Remote(purple) default
396
395
  ```
397
396
 
398
- - `tag: GroupName` starts a tag group; `alias` provides a shorthand for metadata keys
397
+ - `tag GroupName` starts a tag group; `alias` provides a shorthand for metadata keys
399
398
  - `Value(color)` maps a metadata value to a color
400
399
  - `default` marks the fallback value for nodes without that metadata
401
400
  - Nodes whose metadata matches a tag group value get color-coded automatically
402
- - `##` syntax is deprecated but still accepted — use `tag:` for new diagrams
401
+ - `##` syntax is deprecated but still accepted — use `tag` for new diagrams
403
402
 
404
403
  **Options:**
405
404
 
406
405
  | Option | Description |
407
406
  |--------|-------------|
408
- | `title: Text` | Chart title |
409
- | `sub-node-label: Text` | Label for child count badges (e.g., "Crew", "Reports") |
410
- | `show-sub-node-count: yes` | Show descendant count on nodes |
407
+ | `org Title Text` | Chart title (on first line after chart type) |
408
+ | `sub-node-label Text` | Label for child count badges (e.g., "Crew", "Reports") |
409
+ | `show-sub-node-count` | Show descendant count on nodes |
411
410
 
412
411
  **Comments:**
413
412
 
@@ -433,42 +432,41 @@ if (isExtendedChartType(chartType)) {
433
432
  }
434
433
  ```
435
434
 
436
- Content with `->` arrows and no `chart:` header is automatically detected as a sequence diagram.
435
+ Content with `->` arrows and no chart type header is automatically detected as a sequence diagram.
437
436
 
438
437
  ## .dgmo file format
439
438
 
440
439
  Plain text. Lines starting with `#` or `//` are comments. Empty lines are ignored.
441
440
 
442
441
  ```
443
- chart: <type>
444
- title: Optional Title
445
- xlabel: X Axis
446
- ylabel: Y Axis
447
- series: Series1, Series2
448
- orientation: horizontal
442
+ <type> Optional Title
443
+ xlabel X Axis
444
+ ylabel Y Axis
445
+ series Series1, Series2
446
+ orientation horizontal
449
447
 
450
448
  # Multi-line values (alternative to comma-separated)
451
- series:
449
+ series
452
450
  Series1
453
451
  Series2
454
452
 
455
453
  # Data section
456
- Label: value
457
- Label (color): value
458
- Label: value1, value2
454
+ Label value
455
+ Label (color) value
456
+ Label value1, value2
459
457
 
460
458
  # Connections (sankey, chord, arc)
461
- Source -> Target: weight
462
- Source (color) -> Target (color): weight (linkcolor)
459
+ Source -> Target weight
460
+ Source (color) -> Target (color) weight (linkcolor)
463
461
 
464
462
  # Indentation syntax (sankey)
465
463
  Source (color)
466
- Target (color): weight (linkcolor)
464
+ Target (color) weight (linkcolor)
467
465
 
468
466
  # Groups
469
467
  ## Category Name
470
- Item1: value
471
- Item2: value
468
+ Item1 value
469
+ Item2 value
472
470
  ```
473
471
 
474
472
  Colors can be specified inline as named colors (`red`, `blue`, `teal`, etc.) or hex values (`#ff6b6b`). They resolve against the active palette.