@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.
- package/AGENTS.md +15 -20
- package/README.md +56 -58
- package/dist/cli.cjs +188 -181
- package/dist/index.cjs +3522 -1072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +196 -43
- package/dist/index.d.ts +196 -43
- package/dist/index.js +3509 -1072
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +629 -289
- package/package.json +1 -1
- package/src/c4/layout.ts +6 -9
- package/src/c4/parser.ts +189 -83
- package/src/c4/renderer.ts +8 -9
- package/src/chart.ts +296 -83
- package/src/class/parser.ts +54 -37
- package/src/class/renderer.ts +8 -8
- package/src/cli.ts +8 -8
- package/src/colors.ts +4 -1
- package/src/completion.ts +757 -10
- package/src/d3.ts +324 -78
- package/src/dgmo-router.ts +63 -8
- package/src/echarts.ts +735 -241
- package/src/er/parser.ts +94 -76
- package/src/er/renderer.ts +6 -5
- package/src/gantt/parser.ts +144 -69
- package/src/gantt/renderer.ts +50 -14
- package/src/gantt/types.ts +3 -3
- package/src/graph/flowchart-parser.ts +97 -37
- package/src/graph/flowchart-renderer.ts +4 -3
- package/src/graph/state-parser.ts +50 -31
- package/src/graph/state-renderer.ts +4 -3
- package/src/index.ts +14 -5
- package/src/infra/compute.ts +1 -0
- package/src/infra/layout.ts +3 -0
- package/src/infra/parser.ts +291 -92
- package/src/infra/renderer.ts +172 -30
- package/src/infra/types.ts +5 -0
- package/src/initiative-status/layout.ts +1 -1
- package/src/initiative-status/parser.ts +121 -47
- package/src/initiative-status/renderer.ts +42 -23
- package/src/initiative-status/types.ts +10 -2
- package/src/kanban/parser.ts +60 -37
- package/src/kanban/renderer.ts +2 -2
- package/src/kanban/types.ts +1 -0
- package/src/org/layout.ts +9 -9
- package/src/org/parser.ts +39 -40
- package/src/org/renderer.ts +5 -6
- package/src/org/resolver.ts +26 -19
- package/src/render.ts +1 -1
- package/src/sequence/parser.ts +304 -95
- package/src/sequence/renderer.ts +9 -9
- package/src/sitemap/layout.ts +3 -4
- package/src/sitemap/parser.ts +57 -49
- package/src/sitemap/renderer.ts +6 -7
- package/src/utils/arrows.ts +25 -6
- package/src/utils/duration.ts +43 -7
- package/src/utils/legend-constants.ts +26 -0
- package/src/utils/legend-svg.ts +167 -0
- package/src/utils/parsing.ts +247 -7
- package/src/utils/tag-groups.ts +160 -15
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
series: USD
|
|
59
|
+
bar Revenue
|
|
60
|
+
series USD
|
|
64
61
|
|
|
65
|
-
North
|
|
66
|
-
South
|
|
67
|
-
East
|
|
62
|
+
North 850
|
|
63
|
+
South 620
|
|
64
|
+
East 1100
|
|
68
65
|
```
|
|
69
66
|
|
|
70
67
|
### ER diagram
|
|
71
68
|
```
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
-
direction
|
|
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
|
-
- `
|
|
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)
|
|
130
|
-
- `series
|
|
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
|
|
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
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
163
|
-
title: Energy Flow
|
|
168
|
+
sankey Energy Flow
|
|
164
169
|
|
|
165
170
|
Coal (orange)
|
|
166
|
-
Electricity
|
|
171
|
+
Electricity 50
|
|
167
172
|
Gas (blue)
|
|
168
|
-
Electricity
|
|
169
|
-
Electricity -> Industry
|
|
170
|
-
Electricity -> Homes
|
|
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
|
-
|
|
187
|
-
title: Project Milestones
|
|
191
|
+
timeline Project Milestones
|
|
188
192
|
|
|
189
|
-
2024-01
|
|
190
|
-
2024-03 -> 2024-06
|
|
191
|
-
2024-07
|
|
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
|
-
|
|
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
|
|
239
|
-
- `tag
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
- `
|
|
312
|
-
- `
|
|
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
|
-
|
|
334
|
-
title: Engineering
|
|
334
|
+
org Engineering
|
|
335
335
|
|
|
336
|
-
tag
|
|
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
|
-
- `
|
|
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
|
|
391
|
+
tag Location alias l
|
|
393
392
|
NY(blue)
|
|
394
393
|
SF(green)
|
|
395
394
|
Remote(purple) default
|
|
396
395
|
```
|
|
397
396
|
|
|
398
|
-
- `tag
|
|
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
|
|
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
|
-
| `
|
|
409
|
-
| `sub-node-label
|
|
410
|
-
| `show-sub-node-count
|
|
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
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
|
457
|
-
Label (color)
|
|
458
|
-
Label
|
|
454
|
+
Label value
|
|
455
|
+
Label (color) value
|
|
456
|
+
Label value1, value2
|
|
459
457
|
|
|
460
458
|
# Connections (sankey, chord, arc)
|
|
461
|
-
Source -> Target
|
|
462
|
-
Source (color) -> Target (color)
|
|
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)
|
|
464
|
+
Target (color) weight (linkcolor)
|
|
467
465
|
|
|
468
466
|
# Groups
|
|
469
467
|
## Category Name
|
|
470
|
-
Item1
|
|
471
|
-
Item2
|
|
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.
|