@diagrammo/dgmo 0.8.3 → 0.8.5

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 (122) hide show
  1. package/.claude/commands/dgmo-diagram-this.md +60 -0
  2. package/.claude/commands/dgmo-document-project.md +128 -0
  3. package/.claude/commands/dgmo.md +452 -50
  4. package/.cursorrules +32 -37
  5. package/.github/copilot-instructions.md +35 -44
  6. package/.windsurfrules +32 -37
  7. package/README.md +4 -4
  8. package/dist/cli.cjs +188 -185
  9. package/dist/editor.cjs +338 -0
  10. package/dist/editor.cjs.map +1 -0
  11. package/dist/editor.d.cts +27 -0
  12. package/dist/editor.d.ts +27 -0
  13. package/dist/editor.js +307 -0
  14. package/dist/editor.js.map +1 -0
  15. package/dist/highlight.cjs +560 -0
  16. package/dist/highlight.cjs.map +1 -0
  17. package/dist/highlight.d.cts +32 -0
  18. package/dist/highlight.d.ts +32 -0
  19. package/dist/highlight.js +530 -0
  20. package/dist/highlight.js.map +1 -0
  21. package/dist/index.cjs +3467 -1078
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +22 -1
  24. package/dist/index.d.ts +22 -1
  25. package/dist/index.js +3466 -1078
  26. package/dist/index.js.map +1 -1
  27. package/docs/language-reference.md +46 -37
  28. package/gallery/fixtures/arc.dgmo +18 -0
  29. package/gallery/fixtures/area.dgmo +19 -0
  30. package/gallery/fixtures/bar-stacked.dgmo +10 -0
  31. package/gallery/fixtures/bar.dgmo +10 -0
  32. package/gallery/fixtures/c4-full.dgmo +52 -0
  33. package/gallery/fixtures/c4.dgmo +17 -0
  34. package/gallery/fixtures/chord.dgmo +12 -0
  35. package/gallery/fixtures/class-basic.dgmo +14 -0
  36. package/gallery/fixtures/class-full.dgmo +43 -0
  37. package/gallery/fixtures/doughnut.dgmo +8 -0
  38. package/gallery/fixtures/flowchart-basic.dgmo +3 -0
  39. package/gallery/fixtures/flowchart-colors.dgmo +5 -0
  40. package/gallery/fixtures/flowchart-complex.dgmo +17 -0
  41. package/gallery/fixtures/flowchart-decision.dgmo +5 -0
  42. package/gallery/fixtures/flowchart-full.dgmo +13 -0
  43. package/gallery/fixtures/flowchart-groups.dgmo +10 -0
  44. package/gallery/fixtures/flowchart-loop.dgmo +7 -0
  45. package/gallery/fixtures/flowchart-nested.dgmo +7 -0
  46. package/gallery/fixtures/flowchart-shapes.dgmo +5 -0
  47. package/gallery/fixtures/function.dgmo +8 -0
  48. package/gallery/fixtures/funnel.dgmo +7 -0
  49. package/gallery/fixtures/gantt-full.dgmo +49 -0
  50. package/gallery/fixtures/gantt.dgmo +42 -0
  51. package/gallery/fixtures/heatmap.dgmo +8 -0
  52. package/gallery/fixtures/infra-full.dgmo +78 -0
  53. package/gallery/fixtures/infra-overload.dgmo +25 -0
  54. package/gallery/fixtures/infra.dgmo +47 -0
  55. package/gallery/fixtures/initiative-status-full.dgmo +46 -0
  56. package/gallery/fixtures/initiative-status-phases.dgmo +29 -0
  57. package/gallery/fixtures/initiative-status.dgmo +9 -0
  58. package/gallery/fixtures/line.dgmo +19 -0
  59. package/gallery/fixtures/multi-line.dgmo +11 -0
  60. package/gallery/fixtures/org-basic.dgmo +16 -0
  61. package/gallery/fixtures/org-full.dgmo +69 -0
  62. package/gallery/fixtures/org-teams.dgmo +25 -0
  63. package/gallery/fixtures/pie.dgmo +9 -0
  64. package/gallery/fixtures/polar-area.dgmo +8 -0
  65. package/gallery/fixtures/quadrant.dgmo +18 -0
  66. package/gallery/fixtures/radar.dgmo +8 -0
  67. package/gallery/fixtures/sankey.dgmo +31 -0
  68. package/gallery/fixtures/scatter.dgmo +21 -0
  69. package/gallery/fixtures/sequence-tags-protocols.dgmo +45 -0
  70. package/gallery/fixtures/sequence-tags.dgmo +41 -0
  71. package/gallery/fixtures/sequence.dgmo +35 -0
  72. package/gallery/fixtures/sitemap-basic.dgmo +12 -0
  73. package/gallery/fixtures/sitemap-full.dgmo +156 -0
  74. package/gallery/fixtures/slope.dgmo +9 -0
  75. package/gallery/fixtures/spr-eras.dgmo +62 -0
  76. package/gallery/fixtures/state.dgmo +30 -0
  77. package/gallery/fixtures/timeline-intraday.dgmo +14 -0
  78. package/gallery/fixtures/timeline.dgmo +32 -0
  79. package/gallery/fixtures/venn.dgmo +10 -0
  80. package/gallery/fixtures/wordcloud.dgmo +24 -0
  81. package/package.json +71 -2
  82. package/src/c4/layout.ts +372 -90
  83. package/src/c4/parser.ts +100 -55
  84. package/src/chart.ts +91 -28
  85. package/src/class/parser.ts +41 -12
  86. package/src/cli.ts +211 -62
  87. package/src/completion.ts +378 -183
  88. package/src/d3.ts +1044 -303
  89. package/src/dgmo-mermaid.ts +16 -13
  90. package/src/dgmo-router.ts +69 -23
  91. package/src/echarts.ts +646 -153
  92. package/src/editor/dgmo.grammar +69 -0
  93. package/src/editor/dgmo.grammar.d.ts +2 -0
  94. package/src/editor/dgmo.grammar.js +18 -0
  95. package/src/editor/dgmo.grammar.terms.d.ts +5 -0
  96. package/src/editor/dgmo.grammar.terms.js +35 -0
  97. package/src/editor/highlight-api.ts +444 -0
  98. package/src/editor/highlight.ts +36 -0
  99. package/src/editor/index.ts +28 -0
  100. package/src/editor/keywords.ts +222 -0
  101. package/src/editor/tokens.ts +30 -0
  102. package/src/er/parser.ts +48 -14
  103. package/src/er/renderer.ts +112 -53
  104. package/src/gantt/calculator.ts +91 -29
  105. package/src/gantt/parser.ts +197 -71
  106. package/src/gantt/renderer.ts +1120 -350
  107. package/src/graph/flowchart-parser.ts +46 -25
  108. package/src/graph/state-parser.ts +47 -17
  109. package/src/index.ts +96 -31
  110. package/src/infra/parser.ts +157 -53
  111. package/src/infra/renderer.ts +723 -271
  112. package/src/initiative-status/parser.ts +138 -44
  113. package/src/kanban/parser.ts +25 -14
  114. package/src/org/layout.ts +111 -44
  115. package/src/org/parser.ts +69 -22
  116. package/src/palettes/index.ts +3 -2
  117. package/src/sequence/parser.ts +193 -61
  118. package/src/sitemap/parser.ts +65 -29
  119. package/src/utils/arrows.ts +2 -22
  120. package/src/utils/duration.ts +39 -21
  121. package/src/utils/legend-constants.ts +0 -2
  122. package/src/utils/parsing.ts +75 -31
@@ -0,0 +1,60 @@
1
+ # /dgmo-diagram-this — Generate Diagrams from Code
2
+
3
+ You are reading the user's code and generating DGMO diagrams that document what it does. Don't ask what kind of diagram — figure it out from the code.
4
+
5
+ ## Prerequisites
6
+
7
+ Verify DGMO MCP tools are available by calling `mcp__dgmo__list_chart_types`. If not available, tell the user to run `/dgmo` first to set up the MCP server.
8
+
9
+ ## Step 1 — Determine Scope
10
+
11
+ The user may provide:
12
+ - **A file path** — diagram that specific file
13
+ - **A function/class name** — diagram that specific piece
14
+ - **A directory** — diagram the module/package
15
+ - **Nothing** — look at the current working directory and diagram the overall project structure
16
+
17
+ If scope is unclear, read the project root (`package.json`, `README.md`, `src/` listing) and pick the most interesting thing to diagram.
18
+
19
+ ## Step 2 — Read the Code
20
+
21
+ Read the relevant source files. Look for:
22
+ - Function signatures and call chains
23
+ - API endpoints and request handlers
24
+ - Database models, schemas, ORM entities
25
+ - State machines, status enums, workflow transitions
26
+ - Service-to-service calls, message passing
27
+ - Infrastructure config (Docker, k8s, terraform)
28
+ - Import graphs and module dependencies
29
+
30
+ ## Step 3 — Pick the Diagram Type
31
+
32
+ | What you found | Diagram type |
33
+ |---|---|
34
+ | API handler calling other services/DB | `sequence` |
35
+ | Multiple models with relationships | `er` |
36
+ | Service/module dependency graph | `c4` (container level) |
37
+ | State enum, FSM, workflow transitions | `state` |
38
+ | Decision logic, branching control flow | `flowchart` |
39
+ | Docker/k8s/cloud infra config | `infra` |
40
+ | Class hierarchy with methods | `class` |
41
+ | Team/org structure data | `org` |
42
+
43
+ If a single file contains multiple diagrammable things (e.g., models AND an API handler), generate multiple diagrams.
44
+
45
+ ## Step 4 — Generate
46
+
47
+ 1. Call `mcp__dgmo__get_language_reference("<type>")` for syntax.
48
+ 2. Call `mcp__dgmo__get_examples("<type>")` for idiomatic patterns.
49
+ 3. Write the DGMO using **real names from the code** — actual function names, model names, service names, field types.
50
+ 4. Call `mcp__dgmo__validate_diagram(dgmo)` — fix any errors.
51
+ 5. Call `mcp__dgmo__preview_diagram([{dgmo, title}])` to show the result.
52
+ 6. Save to `<descriptive-name>.dgmo` in the project.
53
+
54
+ ## Rules
55
+
56
+ - **Use real names** — `UserService`, `orders` table, `POST /api/auth/login` — not generic placeholders
57
+ - **Keep it focused** — a sequence diagram with 5-8 messages is better than one with 30. Show the main flow, not every edge case.
58
+ - **Lean on inference** — don't declare `PostgresDB is a database` (the name auto-infers). Only use `is a` when the name doesn't match.
59
+ - **No colons in directives** — `sequence Auth Flow`, not `chart: sequence`
60
+ - **Multiple diagrams are fine** — if the code has both a schema and an API flow, generate both and use `preview_diagram` with multiple entries
@@ -0,0 +1,128 @@
1
+ # /dgmo-document-project — Generate Diagrams for a Codebase
2
+
3
+ You are generating a suite of DGMO diagrams that document the user's project. Your goal is to read the codebase, understand its architecture, and produce 3–6 diagrams that capture how the system works.
4
+
5
+ ## Prerequisites
6
+
7
+ Before starting, verify that the DGMO MCP tools are available by calling `mcp__dgmo__list_chart_types`. If the tools are not available, tell the user to run `/dgmo` first to set up the MCP server, then come back to this command.
8
+
9
+ ## Step 1 — Understand the Project
10
+
11
+ Read these files (skip any that don't exist):
12
+
13
+ 1. **README.md** or **README** — project purpose and overview
14
+ 2. **package.json** / **Cargo.toml** / **go.mod** / **pyproject.toml** / **requirements.txt** — tech stack and dependencies
15
+ 3. **docker-compose.yml** / **Dockerfile** / **k8s/** / **terraform/** — infrastructure
16
+ 4. **src/** or **app/** directory listing — code structure
17
+ 5. **.env.example** or config files — external services and integrations
18
+
19
+ From this, determine:
20
+ - What the project does (one sentence)
21
+ - The tech stack (language, framework, database, message broker, etc.)
22
+ - Key modules or services
23
+ - External dependencies and integrations
24
+ - Data models (if database-backed)
25
+
26
+ ## Step 2 — Decide Which Diagrams to Generate
27
+
28
+ Pick 3–6 diagrams based on what the project actually has. Don't force a diagram type that doesn't fit. Use this decision matrix:
29
+
30
+ | Signal in codebase | Diagram type | What to show |
31
+ |---|---|---|
32
+ | Multiple services, APIs, or modules | **c4** (context or container) | System components and their relationships |
33
+ | REST/GraphQL endpoints, API handlers | **sequence** | 1–2 key request flows (e.g., auth, main business operation) |
34
+ | Database models, ORM entities, schema files | **er** | Entity relationships and key fields |
35
+ | Docker, k8s, cloud infra, load balancers | **infra** | Traffic flow and infrastructure components |
36
+ | State machines, workflow engines, status fields | **state** | Key state transitions |
37
+ | Multiple packages or layers | **flowchart** | Request lifecycle or data flow |
38
+ | Microservices with message queues | **sequence** | Async event flow between services |
39
+
40
+ **Rules:**
41
+ - Always include a C4 context or container diagram — every project benefits from a high-level view
42
+ - Prefer sequence diagrams for showing **behavior** (how things interact at runtime)
43
+ - Prefer ER diagrams only if there's a real database schema to document
44
+ - Don't generate infra diagrams for projects without infrastructure config
45
+ - Don't generate more than 2 sequence diagrams — pick the most important flows
46
+
47
+ ## Step 3 — Get Syntax Help
48
+
49
+ For each diagram type you'll generate, call:
50
+
51
+ ```
52
+ mcp__dgmo__get_language_reference("<type>")
53
+ ```
54
+
55
+ Also call `mcp__dgmo__get_examples("<type>")` to see real examples of that chart type. Use these as patterns — they show idiomatic DGMO style.
56
+
57
+ ## Step 4 — Generate the Diagrams
58
+
59
+ Write the DGMO markup for each diagram. Follow these rules:
60
+
61
+ - **Keep diagrams focused** — a C4 diagram with 5–8 components is better than one with 20
62
+ - **Use real names from the codebase** — actual service names, model names, endpoint paths
63
+ - **Lean on inference** — don't declare participant types unless the name doesn't match (e.g., `User` auto-infers as actor, `PostgresDB` as database)
64
+ - **Add tags for color coding** when there are natural groupings (teams, domains, layers)
65
+ - **Title every diagram** — the title goes on the first line after the chart type
66
+
67
+ ### Syntax reminders (no colons in directives or data):
68
+ ```
69
+ sequence Auth Flow // first line: type + title
70
+ tag Layer alias l // tag declaration (no colon)
71
+ Frontend(blue)
72
+ Backend(green)
73
+
74
+ User -POST /login-> API // sync arrow
75
+ API ~publish~> Queue // async arrow
76
+ note Validates JWT // note (no colon)
77
+ ```
78
+
79
+ ## Step 5 — Validate Before Rendering
80
+
81
+ For each diagram, call `mcp__dgmo__validate_diagram(dgmo)` to check for errors. Fix any issues before proceeding.
82
+
83
+ ## Step 6 — Generate the Report
84
+
85
+ Once all diagrams validate, bundle them into a report:
86
+
87
+ ```
88
+ mcp__dgmo__generate_report({
89
+ title: "<Project Name> — Architecture Diagrams",
90
+ subtitle: "Auto-generated from codebase analysis",
91
+ sections: [
92
+ { title: "System Context (C4)", description: "High-level view of ...", dgmo: "..." },
93
+ { title: "Auth Flow", description: "How authentication works", dgmo: "..." },
94
+ ...
95
+ ],
96
+ theme: "dark",
97
+ palette: "nord",
98
+ include_source: true,
99
+ open: true
100
+ })
101
+ ```
102
+
103
+ ## Step 7 — Save Source Files
104
+
105
+ Write each diagram to a `diagrams/` directory in the project root:
106
+
107
+ - `diagrams/c4-context.dgmo`
108
+ - `diagrams/sequence-auth.dgmo`
109
+ - `diagrams/er-schema.dgmo`
110
+ - etc.
111
+
112
+ Use descriptive filenames. Create the `diagrams/` directory if it doesn't exist.
113
+
114
+ ## Step 8 — Report to the User
115
+
116
+ Summarize what was generated:
117
+
118
+ 1. List each diagram with a one-line description
119
+ 2. Mention the HTML report was opened in the browser
120
+ 3. Note the saved `.dgmo` files in `diagrams/`
121
+ 4. Suggest which diagrams might be worth expanding or adding next
122
+
123
+ ## Important Notes
124
+
125
+ - This skill works with **any** project — not just TypeScript or JavaScript
126
+ - Don't ask the user what diagrams to generate — make the decision based on what you find in the code. They can request changes after.
127
+ - If the project is very small (single file, script), generate just 1–2 diagrams instead of forcing 6
128
+ - If you can't determine the project structure, ask the user to point you at the main source directory