@diagrammo/dgmo 0.2.26 → 0.2.28
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/.claude/skills/dgmo-chart/SKILL.md +107 -0
- package/.claude/skills/dgmo-flowchart/SKILL.md +61 -0
- package/.claude/skills/dgmo-generate/SKILL.md +58 -0
- package/.claude/skills/dgmo-sequence/SKILL.md +83 -0
- package/.cursorrules +117 -0
- package/.github/copilot-instructions.md +117 -0
- package/.windsurfrules +117 -0
- package/README.md +10 -3
- package/dist/cli.cjs +116 -108
- package/dist/index.cjs +563 -356
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -24
- package/dist/index.d.ts +39 -24
- package/dist/index.js +560 -355
- package/dist/index.js.map +1 -1
- package/docs/ai-integration.md +125 -0
- package/docs/language-reference.md +784 -0
- package/package.json +10 -3
- package/src/c4/parser.ts +90 -74
- package/src/c4/renderer.ts +13 -12
- package/src/c4/types.ts +6 -4
- package/src/chart.ts +3 -2
- package/src/class/parser.ts +2 -10
- package/src/class/types.ts +1 -1
- package/src/cli.ts +135 -19
- package/src/d3.ts +1 -1
- package/src/dgmo-mermaid.ts +1 -1
- package/src/dgmo-router.ts +1 -1
- package/src/echarts.ts +33 -13
- package/src/er/parser.ts +34 -43
- package/src/er/types.ts +1 -1
- package/src/graph/flowchart-parser.ts +2 -25
- package/src/graph/types.ts +1 -1
- package/src/index.ts +5 -0
- package/src/initiative-status/parser.ts +57 -11
- package/src/initiative-status/types.ts +1 -1
- package/src/kanban/parser.ts +32 -53
- package/src/kanban/renderer.ts +9 -8
- package/src/kanban/types.ts +6 -14
- package/src/org/parser.ts +47 -87
- package/src/org/resolver.ts +11 -12
- package/src/sequence/parser.ts +97 -15
- package/src/sequence/renderer.ts +62 -69
- package/src/utils/arrows.ts +75 -0
- package/src/utils/inline-markdown.ts +75 -0
- package/src/utils/parsing.ts +67 -0
- package/src/utils/tag-groups.ts +76 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dgmo-chart
|
|
3
|
+
description: Generate a DGMO data chart (bar, line, pie, scatter, heatmap, etc.) from data or metrics.
|
|
4
|
+
argument-hint: <data description or chart type>
|
|
5
|
+
allowed-tools: Read, Write, Bash, Glob, Grep
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Generate DGMO Data Chart
|
|
9
|
+
|
|
10
|
+
Generate a data visualization chart from metrics, data, or a description.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Understand the data and visualization goal from `$ARGUMENTS`
|
|
15
|
+
2. If referencing data files, read them to extract the values
|
|
16
|
+
3. Choose the best chart type:
|
|
17
|
+
- Categorical comparisons → `bar` or `bar-stacked`
|
|
18
|
+
- Trends over time → `line` or `area`
|
|
19
|
+
- Proportions → `pie` or `doughnut`
|
|
20
|
+
- Multi-dimensional → `radar`
|
|
21
|
+
- Correlations → `scatter`
|
|
22
|
+
- Matrix data → `heatmap`
|
|
23
|
+
- Flows/allocations → `sankey`
|
|
24
|
+
- Conversion funnels → `funnel`
|
|
25
|
+
- Before/after → `slope`
|
|
26
|
+
- Math functions → `function`
|
|
27
|
+
- Set overlaps → `venn`
|
|
28
|
+
- Priority matrices → `quadrant`
|
|
29
|
+
4. Generate valid DGMO syntax
|
|
30
|
+
|
|
31
|
+
## Chart Syntax Examples
|
|
32
|
+
|
|
33
|
+
**Bar chart**:
|
|
34
|
+
```
|
|
35
|
+
chart: bar
|
|
36
|
+
title: Revenue by Region
|
|
37
|
+
series: Revenue
|
|
38
|
+
xlabel: Region
|
|
39
|
+
ylabel: USD
|
|
40
|
+
|
|
41
|
+
North: 850
|
|
42
|
+
South: 620
|
|
43
|
+
East: 1100
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Multi-series line**:
|
|
47
|
+
```
|
|
48
|
+
title: Quarterly Performance
|
|
49
|
+
series: Sales(red), Costs(blue)
|
|
50
|
+
|
|
51
|
+
Q1: 100, 50
|
|
52
|
+
Q2: 120, 55
|
|
53
|
+
Q3: 110, 60
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Pie chart**:
|
|
57
|
+
```
|
|
58
|
+
chart: pie
|
|
59
|
+
title: Market Share
|
|
60
|
+
labels: percent
|
|
61
|
+
|
|
62
|
+
Company A: 40
|
|
63
|
+
Company B: 35
|
|
64
|
+
Company C: 25
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Scatter plot** (with categories):
|
|
68
|
+
```
|
|
69
|
+
chart: scatter
|
|
70
|
+
title: Performance
|
|
71
|
+
xlabel: Experience
|
|
72
|
+
ylabel: Output
|
|
73
|
+
|
|
74
|
+
## Senior(blue)
|
|
75
|
+
Alice: 7, 92
|
|
76
|
+
Bob: 9, 88
|
|
77
|
+
|
|
78
|
+
## Junior(green)
|
|
79
|
+
Carol: 2, 70
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Heatmap**:
|
|
83
|
+
```
|
|
84
|
+
chart: heatmap
|
|
85
|
+
title: Activity
|
|
86
|
+
columns: Mon, Tue, Wed, Thu, Fri
|
|
87
|
+
|
|
88
|
+
Team A: 5, 4, 5, 3, 4
|
|
89
|
+
Team B: 2, 3, 2, 4, 3
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Common patterns
|
|
93
|
+
|
|
94
|
+
- `series: Name1(color1), Name2(color2)` — multi-series with colors
|
|
95
|
+
- `Label(color): value` — per-item colors
|
|
96
|
+
- `labels: percent` — show percentages on pie/doughnut
|
|
97
|
+
- `orientation: horizontal` — rotate bar charts
|
|
98
|
+
- Data is always `Label: value` or `Label: v1, v2, v3` for multi-series
|
|
99
|
+
|
|
100
|
+
## Output
|
|
101
|
+
|
|
102
|
+
Write to a descriptive `.dgmo` file, then check if `dgmo` CLI is available (`command -v dgmo`). If not installed, tell the user:
|
|
103
|
+
- `brew install diagrammo/dgmo/dgmo` (macOS, recommended)
|
|
104
|
+
- `npm install -g @diagrammo/dgmo`
|
|
105
|
+
- Or: `npx @diagrammo/dgmo <file>.dgmo`
|
|
106
|
+
|
|
107
|
+
If available, offer to render: `dgmo <file>.dgmo -o <file>.svg` or `dgmo <file>.dgmo -o url`
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dgmo-flowchart
|
|
3
|
+
description: Generate a DGMO flowchart from a process description, decision tree, or code logic.
|
|
4
|
+
argument-hint: <process or logic to diagram>
|
|
5
|
+
allowed-tools: Read, Write, Bash, Glob, Grep
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Generate DGMO Flowchart
|
|
9
|
+
|
|
10
|
+
Analyze a process, decision tree, or code logic and generate a `.dgmo` flowchart.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Understand the process from `$ARGUMENTS`
|
|
15
|
+
2. If referencing code, explore the codebase to understand the logic
|
|
16
|
+
3. Generate a valid DGMO flowchart
|
|
17
|
+
|
|
18
|
+
## Flowchart Syntax
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
chart: flowchart
|
|
22
|
+
title: Process Name
|
|
23
|
+
|
|
24
|
+
(Start) -> <Decision?>
|
|
25
|
+
-yes-> [Process A] -> [[Subroutine]]
|
|
26
|
+
-no-> /Get Input/ -> <Decision?>
|
|
27
|
+
[[Subroutine]] -> [Document~] -> (Done)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Node shapes**:
|
|
31
|
+
- `(Terminal)` — oval (start/end)
|
|
32
|
+
- `[Process]` — rectangle
|
|
33
|
+
- `<Decision?>` — diamond
|
|
34
|
+
- `/Input Output/` — parallelogram
|
|
35
|
+
- `[[Subroutine]]` — double-bordered rectangle
|
|
36
|
+
- `[Document~]` — document shape (wavy bottom, note the `~`)
|
|
37
|
+
|
|
38
|
+
**Arrows**:
|
|
39
|
+
- `-label-> Target` — labeled connection
|
|
40
|
+
- `-yes->`, `-no->` — decision branches
|
|
41
|
+
- `-(red)-> Target` — colored arrow
|
|
42
|
+
- `-label(red)-> Target` — labeled + colored
|
|
43
|
+
|
|
44
|
+
**Colors**: Append `(colorname)` to nodes: `[Process(blue)]`
|
|
45
|
+
|
|
46
|
+
**Chaining**: Multiple nodes on one line: `(Start) -> [A] -> [B] -> (End)`
|
|
47
|
+
|
|
48
|
+
**Key rules**:
|
|
49
|
+
- Use indentation for decision branches
|
|
50
|
+
- Each decision branch starts with `-label->`
|
|
51
|
+
- Node names can contain spaces
|
|
52
|
+
- Use named colors only (not hex)
|
|
53
|
+
|
|
54
|
+
## Output
|
|
55
|
+
|
|
56
|
+
Write to a descriptive `.dgmo` file, then check if `dgmo` CLI is available (`command -v dgmo`). If not installed, tell the user:
|
|
57
|
+
- `brew install diagrammo/dgmo/dgmo` (macOS, recommended)
|
|
58
|
+
- `npm install -g @diagrammo/dgmo`
|
|
59
|
+
- Or: `npx @diagrammo/dgmo <file>.dgmo`
|
|
60
|
+
|
|
61
|
+
If available, offer to render: `dgmo <file>.dgmo -o <file>.svg` or `dgmo <file>.dgmo -o url`
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dgmo-generate
|
|
3
|
+
description: Generate a DGMO diagram from a natural language description. Picks the best chart/diagram type automatically.
|
|
4
|
+
argument-hint: <description of what to diagram>
|
|
5
|
+
allowed-tools: Read, Write, Bash
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Generate DGMO Diagram
|
|
9
|
+
|
|
10
|
+
Generate a `.dgmo` diagram file based on the user's description. Pick the best diagram type for what they're describing.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Read the user's description from `$ARGUMENTS`
|
|
15
|
+
2. Read the full DGMO language reference at `docs/language-reference.md` (relative to the repo root of the `dgmo` package, or find it via `npm root -g`/`node_modules/@diagrammo/dgmo/docs/language-reference.md`)
|
|
16
|
+
3. Choose the best chart/diagram type based on the description:
|
|
17
|
+
- Interactions between services/people → `sequence`
|
|
18
|
+
- Decision trees, processes → `flowchart`
|
|
19
|
+
- Hierarchies, org structures → `org`
|
|
20
|
+
- Database schemas → `er`
|
|
21
|
+
- Class/type hierarchies → `class`
|
|
22
|
+
- System architecture → `c4`
|
|
23
|
+
- Task boards → `kanban`
|
|
24
|
+
- Project roadmaps → `initiative-status`
|
|
25
|
+
- Comparisons, data → `bar`, `line`, `pie`, etc.
|
|
26
|
+
- Flows, allocations → `sankey`
|
|
27
|
+
- Relationships → `arc` or `chord`
|
|
28
|
+
- Timelines → `timeline`
|
|
29
|
+
- Set overlaps → `venn`
|
|
30
|
+
- Priority matrices → `quadrant`
|
|
31
|
+
4. Generate valid DGMO syntax following the language reference exactly
|
|
32
|
+
5. Write the output to a descriptive `.dgmo` file (e.g., `auth-flow.dgmo`, `db-schema.dgmo`)
|
|
33
|
+
|
|
34
|
+
## After generating
|
|
35
|
+
|
|
36
|
+
Check if `dgmo` CLI is available:
|
|
37
|
+
```bash
|
|
38
|
+
command -v dgmo 2>/dev/null
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If **not installed**, tell the user how to install it:
|
|
42
|
+
- `brew install diagrammo/dgmo/dgmo` (macOS, recommended)
|
|
43
|
+
- `npm install -g @diagrammo/dgmo`
|
|
44
|
+
- Or run without installing: `npx @diagrammo/dgmo <file>.dgmo`
|
|
45
|
+
|
|
46
|
+
If available (or after install), offer to render:
|
|
47
|
+
```bash
|
|
48
|
+
dgmo <file>.dgmo -o <file>.svg
|
|
49
|
+
dgmo <file>.dgmo -o url # shareable link
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Common mistakes to avoid
|
|
53
|
+
|
|
54
|
+
- Don't use `#` for comments — use `//`
|
|
55
|
+
- Don't use `async` keyword — use `~>` for async messages
|
|
56
|
+
- Don't use `end` in sequence blocks — indentation closes blocks
|
|
57
|
+
- Don't use hex colors in section headers — use named colors
|
|
58
|
+
- Always include `chart:` directive when the type can't be inferred from content
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dgmo-sequence
|
|
3
|
+
description: Generate a DGMO sequence diagram by analyzing a code flow, API interaction, or process description.
|
|
4
|
+
argument-hint: <flow or module to diagram>
|
|
5
|
+
allowed-tools: Read, Write, Bash, Glob, Grep
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Generate DGMO Sequence Diagram
|
|
9
|
+
|
|
10
|
+
Analyze a code flow, API interaction, or process and generate a `.dgmo` sequence diagram.
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Understand what to diagram from `$ARGUMENTS` — this could be:
|
|
15
|
+
- A description of an interaction ("the login flow")
|
|
16
|
+
- A reference to code ("trace the checkout process in src/")
|
|
17
|
+
- An API flow ("POST /orders end-to-end")
|
|
18
|
+
2. If referencing code, explore the codebase to trace the actual flow
|
|
19
|
+
3. Generate a valid DGMO sequence diagram
|
|
20
|
+
|
|
21
|
+
## Sequence Diagram Syntax
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
chart: sequence
|
|
25
|
+
title: Flow Title
|
|
26
|
+
|
|
27
|
+
// Participant declarations (optional — auto-inferred from messages)
|
|
28
|
+
User is an actor
|
|
29
|
+
API is a service
|
|
30
|
+
DB is a database
|
|
31
|
+
Queue is a queue
|
|
32
|
+
|
|
33
|
+
// Messages
|
|
34
|
+
User -Login-> API
|
|
35
|
+
API -Find user-> DB
|
|
36
|
+
DB -> API: <- user record
|
|
37
|
+
|
|
38
|
+
// Async messages
|
|
39
|
+
API ~event~> Queue
|
|
40
|
+
|
|
41
|
+
// Notes
|
|
42
|
+
note on DB:
|
|
43
|
+
Indexed lookup on email column
|
|
44
|
+
|
|
45
|
+
// Conditional blocks (indentation-scoped, no "end" needed)
|
|
46
|
+
if credentials valid
|
|
47
|
+
API -> User: <- 200 OK
|
|
48
|
+
else
|
|
49
|
+
API -> User: <- 401 Unauthorized
|
|
50
|
+
|
|
51
|
+
// Loops
|
|
52
|
+
loop retry 3 times
|
|
53
|
+
API -> ExternalService: request
|
|
54
|
+
|
|
55
|
+
// Sections (phase dividers)
|
|
56
|
+
== Phase 2 ==
|
|
57
|
+
|
|
58
|
+
// Visual groups
|
|
59
|
+
## Authentication
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Participant types**: `actor`, `service`, `database`, `queue`, `cache`, `gateway`, `external`, `networking`, `frontend`
|
|
63
|
+
|
|
64
|
+
**Arrow types**:
|
|
65
|
+
- Sync: `A -> B: label` or `A -label-> B`
|
|
66
|
+
- Async: `A ~> B: label` or `A ~label~> B`
|
|
67
|
+
- Return: `B -> A: <- response`
|
|
68
|
+
- Bidirectional: `A <-> B: label`
|
|
69
|
+
|
|
70
|
+
**Key rules**:
|
|
71
|
+
- Indentation closes blocks (no `end` keyword)
|
|
72
|
+
- Use `//` for comments (not `#`)
|
|
73
|
+
- `aka` for display names: `PaymentGW aka Payment Gateway`
|
|
74
|
+
- `at position N` for ordering: `DB at position 3`
|
|
75
|
+
|
|
76
|
+
## Output
|
|
77
|
+
|
|
78
|
+
Write to a descriptive `.dgmo` file, then check if `dgmo` CLI is available (`command -v dgmo`). If not installed, tell the user:
|
|
79
|
+
- `brew install diagrammo/dgmo/dgmo` (macOS, recommended)
|
|
80
|
+
- `npm install -g @diagrammo/dgmo`
|
|
81
|
+
- Or: `npx @diagrammo/dgmo <file>.dgmo`
|
|
82
|
+
|
|
83
|
+
If available, offer to render: `dgmo <file>.dgmo -o <file>.svg` or `dgmo <file>.dgmo -o url`
|
package/.cursorrules
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# DGMO Diagram Language
|
|
2
|
+
|
|
3
|
+
When the user asks for a diagram, visualization, or chart, generate a `.dgmo` file. DGMO is a text-based diagram markup language that renders to SVG/PNG.
|
|
4
|
+
|
|
5
|
+
## When to suggest DGMO
|
|
6
|
+
|
|
7
|
+
- Architecture diagrams, sequence diagrams, flowcharts
|
|
8
|
+
- Data charts (bar, line, pie, scatter, heatmap, etc.)
|
|
9
|
+
- ER diagrams, class diagrams, org charts
|
|
10
|
+
- Project roadmaps, kanban boards, timelines
|
|
11
|
+
|
|
12
|
+
## Quick syntax reference
|
|
13
|
+
|
|
14
|
+
### Sequence diagram
|
|
15
|
+
```
|
|
16
|
+
chart: sequence
|
|
17
|
+
title: Auth Flow
|
|
18
|
+
|
|
19
|
+
User -Login-> API
|
|
20
|
+
API -Find user-> DB
|
|
21
|
+
DB -> API: <- user
|
|
22
|
+
if valid
|
|
23
|
+
API -> User: <- 200 OK
|
|
24
|
+
else
|
|
25
|
+
API -> User: <- 401
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Flowchart
|
|
29
|
+
```
|
|
30
|
+
chart: flowchart
|
|
31
|
+
title: Process
|
|
32
|
+
|
|
33
|
+
(Start) -> <Valid?>
|
|
34
|
+
-yes-> [Process] -> (Done)
|
|
35
|
+
-no-> /Get Input/ -> <Valid?>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Bar chart
|
|
39
|
+
```
|
|
40
|
+
chart: bar
|
|
41
|
+
title: Revenue
|
|
42
|
+
series: USD
|
|
43
|
+
|
|
44
|
+
North: 850
|
|
45
|
+
South: 620
|
|
46
|
+
East: 1100
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### ER diagram
|
|
50
|
+
```
|
|
51
|
+
chart: er
|
|
52
|
+
title: Schema
|
|
53
|
+
|
|
54
|
+
users
|
|
55
|
+
id: int [pk]
|
|
56
|
+
email: varchar [unique]
|
|
57
|
+
|
|
58
|
+
posts
|
|
59
|
+
id: int [pk]
|
|
60
|
+
user_id: int [fk]
|
|
61
|
+
|
|
62
|
+
users 1--* posts : writes
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Org chart
|
|
66
|
+
```
|
|
67
|
+
chart: org
|
|
68
|
+
|
|
69
|
+
CEO
|
|
70
|
+
VP Engineering
|
|
71
|
+
Team Lead A
|
|
72
|
+
Team Lead B
|
|
73
|
+
VP Marketing
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### C4 architecture
|
|
77
|
+
```
|
|
78
|
+
chart: c4
|
|
79
|
+
title: System
|
|
80
|
+
|
|
81
|
+
person User
|
|
82
|
+
system App | description: Main application
|
|
83
|
+
-Uses-> User
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## All 29 chart types
|
|
87
|
+
|
|
88
|
+
bar, line, multi-line, area, pie, doughnut, radar, polar-area, bar-stacked, scatter, sankey, chord, function, heatmap, funnel, slope, wordcloud, arc, timeline, venn, quadrant, sequence, flowchart, class, er, org, kanban, c4, initiative-status
|
|
89
|
+
|
|
90
|
+
## Common patterns
|
|
91
|
+
|
|
92
|
+
- `chart: type` — explicit chart type (auto-detected if unambiguous)
|
|
93
|
+
- `title: text` — diagram title
|
|
94
|
+
- `// comment` — only `//` comments (not `#`)
|
|
95
|
+
- `(colorname)` — inline colors: `Label(red): 100`
|
|
96
|
+
- `series: A(red), B(blue)` — multi-series with colors
|
|
97
|
+
- `tag: Group alias g` — tag groups for metadata
|
|
98
|
+
|
|
99
|
+
## Rendering
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
dgmo file.dgmo -o output.svg # SVG
|
|
103
|
+
dgmo file.dgmo -o url # shareable link
|
|
104
|
+
dgmo file.dgmo --json # structured JSON output
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Install: `brew install diagrammo/dgmo/dgmo` or `npm install -g @diagrammo/dgmo`
|
|
108
|
+
|
|
109
|
+
## Mistakes to avoid
|
|
110
|
+
|
|
111
|
+
- Don't use `#` for comments — use `//`
|
|
112
|
+
- Don't use `end` to close sequence blocks — indentation closes them
|
|
113
|
+
- Don't use hex colors in section headers — use named colors
|
|
114
|
+
- Don't forget `chart:` directive when content is ambiguous
|
|
115
|
+
- Sequence arrows: `->` (sync), `~>` (async), `<->` (bidirectional)
|
|
116
|
+
|
|
117
|
+
Full reference: `docs/language-reference.md`
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# DGMO Diagram Language
|
|
2
|
+
|
|
3
|
+
When the user asks for a diagram, visualization, or chart, generate a `.dgmo` file. DGMO is a text-based diagram markup language that renders to SVG/PNG.
|
|
4
|
+
|
|
5
|
+
## When to suggest DGMO
|
|
6
|
+
|
|
7
|
+
- Architecture diagrams, sequence diagrams, flowcharts
|
|
8
|
+
- Data charts (bar, line, pie, scatter, heatmap, etc.)
|
|
9
|
+
- ER diagrams, class diagrams, org charts
|
|
10
|
+
- Project roadmaps, kanban boards, timelines
|
|
11
|
+
|
|
12
|
+
## Quick syntax reference
|
|
13
|
+
|
|
14
|
+
### Sequence diagram
|
|
15
|
+
```
|
|
16
|
+
chart: sequence
|
|
17
|
+
title: Auth Flow
|
|
18
|
+
|
|
19
|
+
User -Login-> API
|
|
20
|
+
API -Find user-> DB
|
|
21
|
+
DB -> API: <- user
|
|
22
|
+
if valid
|
|
23
|
+
API -> User: <- 200 OK
|
|
24
|
+
else
|
|
25
|
+
API -> User: <- 401
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Flowchart
|
|
29
|
+
```
|
|
30
|
+
chart: flowchart
|
|
31
|
+
title: Process
|
|
32
|
+
|
|
33
|
+
(Start) -> <Valid?>
|
|
34
|
+
-yes-> [Process] -> (Done)
|
|
35
|
+
-no-> /Get Input/ -> <Valid?>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Bar chart
|
|
39
|
+
```
|
|
40
|
+
chart: bar
|
|
41
|
+
title: Revenue
|
|
42
|
+
series: USD
|
|
43
|
+
|
|
44
|
+
North: 850
|
|
45
|
+
South: 620
|
|
46
|
+
East: 1100
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### ER diagram
|
|
50
|
+
```
|
|
51
|
+
chart: er
|
|
52
|
+
title: Schema
|
|
53
|
+
|
|
54
|
+
users
|
|
55
|
+
id: int [pk]
|
|
56
|
+
email: varchar [unique]
|
|
57
|
+
|
|
58
|
+
posts
|
|
59
|
+
id: int [pk]
|
|
60
|
+
user_id: int [fk]
|
|
61
|
+
|
|
62
|
+
users 1--* posts : writes
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Org chart
|
|
66
|
+
```
|
|
67
|
+
chart: org
|
|
68
|
+
|
|
69
|
+
CEO
|
|
70
|
+
VP Engineering
|
|
71
|
+
Team Lead A
|
|
72
|
+
Team Lead B
|
|
73
|
+
VP Marketing
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### C4 architecture
|
|
77
|
+
```
|
|
78
|
+
chart: c4
|
|
79
|
+
title: System
|
|
80
|
+
|
|
81
|
+
person User
|
|
82
|
+
system App | description: Main application
|
|
83
|
+
-Uses-> User
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## All 29 chart types
|
|
87
|
+
|
|
88
|
+
bar, line, multi-line, area, pie, doughnut, radar, polar-area, bar-stacked, scatter, sankey, chord, function, heatmap, funnel, slope, wordcloud, arc, timeline, venn, quadrant, sequence, flowchart, class, er, org, kanban, c4, initiative-status
|
|
89
|
+
|
|
90
|
+
## Common patterns
|
|
91
|
+
|
|
92
|
+
- `chart: type` — explicit chart type (auto-detected if unambiguous)
|
|
93
|
+
- `title: text` — diagram title
|
|
94
|
+
- `// comment` — only `//` comments (not `#`)
|
|
95
|
+
- `(colorname)` — inline colors: `Label(red): 100`
|
|
96
|
+
- `series: A(red), B(blue)` — multi-series with colors
|
|
97
|
+
- `tag: Group alias g` — tag groups for metadata
|
|
98
|
+
|
|
99
|
+
## Rendering
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
dgmo file.dgmo -o output.svg # SVG
|
|
103
|
+
dgmo file.dgmo -o url # shareable link
|
|
104
|
+
dgmo file.dgmo --json # structured JSON output
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Install: `brew install diagrammo/dgmo/dgmo` or `npm install -g @diagrammo/dgmo`
|
|
108
|
+
|
|
109
|
+
## Mistakes to avoid
|
|
110
|
+
|
|
111
|
+
- Don't use `#` for comments — use `//`
|
|
112
|
+
- Don't use `end` to close sequence blocks — indentation closes them
|
|
113
|
+
- Don't use hex colors in section headers — use named colors
|
|
114
|
+
- Don't forget `chart:` directive when content is ambiguous
|
|
115
|
+
- Sequence arrows: `->` (sync), `~>` (async), `<->` (bidirectional)
|
|
116
|
+
|
|
117
|
+
Full reference: `docs/language-reference.md`
|
package/.windsurfrules
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# DGMO Diagram Language
|
|
2
|
+
|
|
3
|
+
When the user asks for a diagram, visualization, or chart, generate a `.dgmo` file. DGMO is a text-based diagram markup language that renders to SVG/PNG.
|
|
4
|
+
|
|
5
|
+
## When to suggest DGMO
|
|
6
|
+
|
|
7
|
+
- Architecture diagrams, sequence diagrams, flowcharts
|
|
8
|
+
- Data charts (bar, line, pie, scatter, heatmap, etc.)
|
|
9
|
+
- ER diagrams, class diagrams, org charts
|
|
10
|
+
- Project roadmaps, kanban boards, timelines
|
|
11
|
+
|
|
12
|
+
## Quick syntax reference
|
|
13
|
+
|
|
14
|
+
### Sequence diagram
|
|
15
|
+
```
|
|
16
|
+
chart: sequence
|
|
17
|
+
title: Auth Flow
|
|
18
|
+
|
|
19
|
+
User -Login-> API
|
|
20
|
+
API -Find user-> DB
|
|
21
|
+
DB -> API: <- user
|
|
22
|
+
if valid
|
|
23
|
+
API -> User: <- 200 OK
|
|
24
|
+
else
|
|
25
|
+
API -> User: <- 401
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Flowchart
|
|
29
|
+
```
|
|
30
|
+
chart: flowchart
|
|
31
|
+
title: Process
|
|
32
|
+
|
|
33
|
+
(Start) -> <Valid?>
|
|
34
|
+
-yes-> [Process] -> (Done)
|
|
35
|
+
-no-> /Get Input/ -> <Valid?>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Bar chart
|
|
39
|
+
```
|
|
40
|
+
chart: bar
|
|
41
|
+
title: Revenue
|
|
42
|
+
series: USD
|
|
43
|
+
|
|
44
|
+
North: 850
|
|
45
|
+
South: 620
|
|
46
|
+
East: 1100
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### ER diagram
|
|
50
|
+
```
|
|
51
|
+
chart: er
|
|
52
|
+
title: Schema
|
|
53
|
+
|
|
54
|
+
users
|
|
55
|
+
id: int [pk]
|
|
56
|
+
email: varchar [unique]
|
|
57
|
+
|
|
58
|
+
posts
|
|
59
|
+
id: int [pk]
|
|
60
|
+
user_id: int [fk]
|
|
61
|
+
|
|
62
|
+
users 1--* posts : writes
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Org chart
|
|
66
|
+
```
|
|
67
|
+
chart: org
|
|
68
|
+
|
|
69
|
+
CEO
|
|
70
|
+
VP Engineering
|
|
71
|
+
Team Lead A
|
|
72
|
+
Team Lead B
|
|
73
|
+
VP Marketing
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### C4 architecture
|
|
77
|
+
```
|
|
78
|
+
chart: c4
|
|
79
|
+
title: System
|
|
80
|
+
|
|
81
|
+
person User
|
|
82
|
+
system App | description: Main application
|
|
83
|
+
-Uses-> User
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## All 29 chart types
|
|
87
|
+
|
|
88
|
+
bar, line, multi-line, area, pie, doughnut, radar, polar-area, bar-stacked, scatter, sankey, chord, function, heatmap, funnel, slope, wordcloud, arc, timeline, venn, quadrant, sequence, flowchart, class, er, org, kanban, c4, initiative-status
|
|
89
|
+
|
|
90
|
+
## Common patterns
|
|
91
|
+
|
|
92
|
+
- `chart: type` — explicit chart type (auto-detected if unambiguous)
|
|
93
|
+
- `title: text` — diagram title
|
|
94
|
+
- `// comment` — only `//` comments (not `#`)
|
|
95
|
+
- `(colorname)` — inline colors: `Label(red): 100`
|
|
96
|
+
- `series: A(red), B(blue)` — multi-series with colors
|
|
97
|
+
- `tag: Group alias g` — tag groups for metadata
|
|
98
|
+
|
|
99
|
+
## Rendering
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
dgmo file.dgmo -o output.svg # SVG
|
|
103
|
+
dgmo file.dgmo -o url # shareable link
|
|
104
|
+
dgmo file.dgmo --json # structured JSON output
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Install: `brew install diagrammo/dgmo/dgmo` or `npm install -g @diagrammo/dgmo`
|
|
108
|
+
|
|
109
|
+
## Mistakes to avoid
|
|
110
|
+
|
|
111
|
+
- Don't use `#` for comments — use `//`
|
|
112
|
+
- Don't use `end` to close sequence blocks — indentation closes them
|
|
113
|
+
- Don't use hex colors in section headers — use named colors
|
|
114
|
+
- Don't forget `chart:` directive when content is ambiguous
|
|
115
|
+
- Sequence arrows: `->` (sync), `~>` (async), `<->` (bidirectional)
|
|
116
|
+
|
|
117
|
+
Full reference: `docs/language-reference.md`
|
package/README.md
CHANGED
|
@@ -197,7 +197,13 @@ renderSequenceDiagram(container, parsed, colors, false, (lineNum) => {
|
|
|
197
197
|
**Sequence syntax:**
|
|
198
198
|
|
|
199
199
|
- `A -> B: message` — synchronous call
|
|
200
|
+
- `A -message-> B` — inline label (same result, label sits in the arrow)
|
|
200
201
|
- `A ~> B: message` — async/fire-and-forget
|
|
202
|
+
- `A ~message~> B` — async with inline label
|
|
203
|
+
- `A <-> B: message` — bidirectional synchronous
|
|
204
|
+
- `A <-message-> B` — bidirectional with inline label
|
|
205
|
+
- `A <~> B: message` — bidirectional async
|
|
206
|
+
- `A <~message~> B` — bidirectional async with inline label
|
|
201
207
|
- `A -> B: method(): returnValue` — call with return
|
|
202
208
|
- `B -> A: <- response` — explicit return
|
|
203
209
|
- `if condition` / `else` / `end` — conditional blocks
|
|
@@ -303,7 +309,7 @@ const content = `
|
|
|
303
309
|
chart: org
|
|
304
310
|
title: Engineering
|
|
305
311
|
|
|
306
|
-
|
|
312
|
+
tag: Location
|
|
307
313
|
NY(blue)
|
|
308
314
|
SF(green)
|
|
309
315
|
|
|
@@ -359,16 +365,17 @@ Containers can nest and carry their own metadata (key: value pairs). Children ar
|
|
|
359
365
|
**Tag groups** — define color coding for metadata values. Must appear before org content:
|
|
360
366
|
|
|
361
367
|
```
|
|
362
|
-
|
|
368
|
+
tag: Location alias l
|
|
363
369
|
NY(blue)
|
|
364
370
|
SF(green)
|
|
365
371
|
Remote(purple) default
|
|
366
372
|
```
|
|
367
373
|
|
|
368
|
-
-
|
|
374
|
+
- `tag: GroupName` starts a tag group; `alias` provides a shorthand for metadata keys
|
|
369
375
|
- `Value(color)` maps a metadata value to a color
|
|
370
376
|
- `default` marks the fallback value for nodes without that metadata
|
|
371
377
|
- Nodes whose metadata matches a tag group value get color-coded automatically
|
|
378
|
+
- `##` syntax is deprecated but still accepted — use `tag:` for new diagrams
|
|
372
379
|
|
|
373
380
|
**Options:**
|
|
374
381
|
|