@diagrammo/dgmo 0.8.5 → 0.8.7

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 (65) hide show
  1. package/.claude/commands/dgmo.md +34 -27
  2. package/.cursorrules +20 -2
  3. package/.github/copilot-instructions.md +20 -2
  4. package/.windsurfrules +20 -2
  5. package/AGENTS.md +23 -3
  6. package/README.md +0 -1
  7. package/dist/cli.cjs +189 -190
  8. package/dist/editor.cjs +3 -18
  9. package/dist/editor.cjs.map +1 -1
  10. package/dist/editor.js +3 -18
  11. package/dist/editor.js.map +1 -1
  12. package/dist/highlight.cjs +4 -21
  13. package/dist/highlight.cjs.map +1 -1
  14. package/dist/highlight.js +4 -21
  15. package/dist/highlight.js.map +1 -1
  16. package/dist/index.cjs +2791 -2999
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +56 -56
  19. package/dist/index.d.ts +56 -56
  20. package/dist/index.js +2786 -2992
  21. package/dist/index.js.map +1 -1
  22. package/docs/ai-integration.md +1 -1
  23. package/docs/language-reference.md +112 -121
  24. package/gallery/fixtures/boxes-and-lines.dgmo +64 -0
  25. package/package.json +1 -1
  26. package/src/boxes-and-lines/collapse.ts +78 -0
  27. package/src/boxes-and-lines/layout.ts +319 -0
  28. package/src/boxes-and-lines/parser.ts +697 -0
  29. package/src/boxes-and-lines/renderer.ts +848 -0
  30. package/src/boxes-and-lines/types.ts +40 -0
  31. package/src/c4/parser.ts +10 -5
  32. package/src/c4/renderer.ts +232 -56
  33. package/src/chart.ts +9 -4
  34. package/src/cli.ts +6 -5
  35. package/src/completion.ts +25 -33
  36. package/src/d3.ts +26 -27
  37. package/src/dgmo-router.ts +3 -7
  38. package/src/echarts.ts +38 -2
  39. package/src/editor/keywords.ts +4 -19
  40. package/src/er/parser.ts +10 -4
  41. package/src/gantt/parser.ts +10 -4
  42. package/src/gantt/renderer.ts +3 -5
  43. package/src/index.ts +17 -26
  44. package/src/infra/parser.ts +10 -5
  45. package/src/infra/renderer.ts +2 -2
  46. package/src/kanban/parser.ts +10 -5
  47. package/src/kanban/renderer.ts +43 -18
  48. package/src/org/parser.ts +7 -4
  49. package/src/org/renderer.ts +40 -29
  50. package/src/sequence/parser.ts +11 -5
  51. package/src/sequence/renderer.ts +114 -45
  52. package/src/sitemap/parser.ts +8 -4
  53. package/src/sitemap/renderer.ts +137 -57
  54. package/src/utils/legend-svg.ts +44 -20
  55. package/src/utils/parsing.ts +1 -1
  56. package/src/utils/tag-groups.ts +59 -15
  57. package/gallery/fixtures/initiative-status-full.dgmo +0 -46
  58. package/gallery/fixtures/initiative-status-phases.dgmo +0 -29
  59. package/gallery/fixtures/initiative-status.dgmo +0 -9
  60. package/src/initiative-status/collapse.ts +0 -76
  61. package/src/initiative-status/filter.ts +0 -63
  62. package/src/initiative-status/layout.ts +0 -650
  63. package/src/initiative-status/parser.ts +0 -629
  64. package/src/initiative-status/renderer.ts +0 -1199
  65. package/src/initiative-status/types.ts +0 -57
@@ -105,4 +105,4 @@ dgmo --chart-types --json # Machine-readable chart type list
105
105
 
106
106
  Run `dgmo --chart-types` for the full list, or see `docs/language-reference.md`.
107
107
 
108
- 29 types: bar, line, area, multi-line, 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, infra.
108
+ 33 types: bar, line, area, multi-line, pie, doughnut, radar, polar-area, bar-stacked, scatter, sankey, chord, function, heatmap, funnel, slope, wordcloud, arc, timeline, venn, quadrant, sequence, flowchart, state, class, er, org, kanban, c4, sitemap, infra, gantt, boxes-and-lines.
@@ -1,40 +1,6 @@
1
- # DGMO Language Reference
2
-
3
- DGMO is a text-based diagram markup language. Files use the `.dgmo` extension. Render with the `dgmo` CLI, the Diagrammo desktop app, or the `@diagrammo/dgmo` npm library.
4
-
5
- ## Migration Guide
6
-
7
- Syntax changes introduced in the consistency cleanup. Old forms now produce errors.
8
-
9
- | Old Syntax | New Syntax | Chart Types |
10
- |---|---|---|
11
- | `chart: TYPE` + `title: Text` | `TYPE Text` (single first line) | All |
12
- | `chart: TYPE` (alone) | `TYPE` | All |
13
- | `directive: value` | `directive value` (no colon) | All |
14
- | `Label: value` (ECharts data) | `Label value` | bar, line, pie, etc. |
15
- | `era YYYY->YYYY: Label` | `era YYYY->YYYY Label` | line, timeline, gantt |
16
- | `marker YYYY: Label` | `marker YYYY Label` | timeline, gantt |
17
- | `## Group` | `tag Group` | All |
18
- | `== Column ==` | `[Column]` | Kanban |
19
- | `person Name` | `Name is a person` | C4 |
20
- | `-> Target : Desc [tech]` | `-Desc-> Target \| tech: val` | C4 |
21
- | `A <-> B` | Two lines: `A -> B` + `B -> A` | C4 |
22
- | `-> Target x5` | `-> Target \| fanout: 5` | Infra |
23
- | `lag: 5d` / `lead: 3d` | `offset: 5d` / `offset: -3d` | Gantt |
24
- | `Name(color)` | Use `tag` groups | Sequence |
25
- | `scenario:` | (removed) | Infra |
26
- | `wip` | `doing` (wip still accepted) | Init-status |
27
- | `#ff0000` hex colors | Named colors only | All |
28
- | `show-sub-node-count: yes` | `show-sub-node-count` (flag) | Org |
29
- | `import: path` | `import path` | Org |
30
- | `tags: path` | `tags path` | Org |
31
- | `xlabel` | `x-label` | Data charts, function |
32
- | `ylabel` | `y-label` | Data charts, function |
33
- | `sizelabel` | `size-label` | Scatter/bubble |
34
- | `x-axis` | `x-label` | Quadrant |
35
- | `y-axis` | `y-label` | Quadrant |
1
+ # DGMO Language Specification
36
2
 
37
- ---
3
+ > **Authoritative reference** for the DGMO diagram language. This document describes what is valid syntax. If it is not in this document, it is not valid DGMO.
38
4
 
39
5
  ## Table of Contents
40
6
 
@@ -48,9 +14,9 @@ Syntax changes introduced in the consistency cleanup. Old forms now produce erro
48
14
  8. [Entity-Relationship Diagrams](#8-entity-relationship-diagrams)
49
15
  9. [Class Diagrams](#9-class-diagrams)
50
16
  10. [Kanban Boards](#10-kanban-boards)
51
- 11. [Initiative-Status Diagrams](#11-initiative-status-diagrams)
52
- 12. [Sitemap Diagrams](#12-sitemap-diagrams)
53
- 13. [Gantt Charts](#13-gantt-charts)
17
+ 11. [Sitemap Diagrams](#11-sitemap-diagrams)
18
+ 12. [Gantt Charts](#12-gantt-charts)
19
+ 13. [Boxes and Lines Diagrams](#13-boxes-and-lines-diagrams)
54
20
  14. [Timeline Diagrams](#14-timeline-diagrams)
55
21
  15. [Data Charts](#15-data-charts)
56
22
  16. [Visualizations](#16-visualizations)
@@ -95,7 +61,7 @@ tag GroupName [alias X]
95
61
  - First entry is default unless another is marked `default`
96
62
  - Must appear before diagram content
97
63
 
98
- **Diagram types that support tags**: sequence, infra, org, c4, er, kanban, gantt, initiative-status, sitemap, timeline
64
+ **Diagram types that support tags**: sequence, infra, org, c4, er, kanban, gantt, sitemap, timeline, boxes-and-lines
99
65
 
100
66
  ### 1.4 Pipe Metadata
101
67
 
@@ -637,7 +603,7 @@ abstract Vessel
637
603
  interface Serializable
638
604
  Ship extends Vessel
639
605
  Galleon implements Serializable
640
- ShipType enum
606
+ enum ShipType
641
607
  ```
642
608
 
643
609
  ### 9.3 Members (Indented, Colon for Types)
@@ -660,7 +626,7 @@ Visibility: `+` public, `-` private, `#` protected
660
626
 
661
627
  **Enum values:**
662
628
  ```
663
- ShipType enum
629
+ enum ShipType
664
630
  Galleon
665
631
  Sloop
666
632
  ```
@@ -724,72 +690,15 @@ kanban [Title]
724
690
 
725
691
  ---
726
692
 
727
- ## 11. Initiative-Status Diagrams
693
+ ## 11. Sitemap Diagrams
728
694
 
729
695
  ### 11.1 Declaration
730
696
 
731
- ```
732
- initiative-status [Title]
733
- ```
734
-
735
- ### 11.2 Nodes
736
-
737
- ```
738
- NodeLabel | status, key: value
739
- NodeLabel | done, t: Team1
740
- ```
741
-
742
- Status values and equivalences:
743
-
744
- | User writes | Canonical | Display |
745
- |------------|-----------|---------|
746
- | `done` | `done` | Done |
747
- | `doing` | `doing` | In Progress |
748
- | `wip` | `doing` | In Progress |
749
- | `blocked` | `blocked` | Blocked |
750
- | `paused` | `blocked` | Blocked |
751
- | `waiting` | `blocked` | Blocked |
752
- | `todo` | `todo` | To Do |
753
- | `na` | `na` | N/A |
754
- | (omitted) | `na` | N/A |
755
-
756
- ### 11.3 Edges
757
-
758
- ```
759
- Source -> Target
760
- Source -label-> Target
761
- Source -> Target | status
762
- ```
763
-
764
- Indented shorthand (source from preceding node):
765
- ```
766
- Captain | t: Bridge
767
- -issueOrders-> CrewApp | na
768
- ```
769
-
770
- ### 11.4 Groups
771
-
772
- ```
773
- [Group Name]
774
- indented nodes...
775
- ```
776
-
777
- ### 11.5 Options
778
-
779
- - `active-tag GroupName`
780
- - `hide phase:Planning, phase:Review` (colon syntax for tag:value)
781
-
782
- ---
783
-
784
- ## 12. Sitemap Diagrams
785
-
786
- ### 12.1 Declaration
787
-
788
697
  ```
789
698
  sitemap [Title]
790
699
  ```
791
700
 
792
- ### 12.2 Pages (Indentation = Hierarchy)
701
+ ### 11.2 Pages (Indentation = Hierarchy)
793
702
 
794
703
  ```
795
704
  Home
@@ -799,7 +708,7 @@ Home
799
708
  Blog
800
709
  ```
801
710
 
802
- ### 12.3 Arrows
711
+ ### 11.3 Arrows
803
712
 
804
713
  ```
805
714
  Home
@@ -807,28 +716,28 @@ Home
807
716
  -login-> Login
808
717
  ```
809
718
 
810
- ### 12.4 Containers
719
+ ### 11.4 Containers
811
720
 
812
721
  ```
813
722
  [Marketing]
814
723
  Pricing | Auth: Public
815
724
  ```
816
725
 
817
- ### 12.5 Options
726
+ ### 11.5 Options
818
727
 
819
728
  - `direction-tb` (boolean; default is LR)
820
729
 
821
730
  ---
822
731
 
823
- ## 13. Gantt Charts
732
+ ## 12. Gantt Charts
824
733
 
825
- ### 13.1 Declaration
734
+ ### 12.1 Declaration
826
735
 
827
736
  ```
828
737
  gantt [Title]
829
738
  ```
830
739
 
831
- ### 13.2 Options (Space-Separated, NO Colon)
740
+ ### 12.2 Options (Space-Separated, NO Colon)
832
741
 
833
742
  ```
834
743
  start 2026-03-15
@@ -839,7 +748,7 @@ no-dependencies
839
748
  sort tag:Team
840
749
  ```
841
750
 
842
- ### 13.3 Holidays
751
+ ### 12.3 Holidays
843
752
 
844
753
  ```
845
754
  holiday
@@ -847,7 +756,7 @@ holiday
847
756
  2024-05-27 -> 2024-05-29 Memorial Weekend
848
757
  ```
849
758
 
850
- ### 13.4 Workweek
759
+ ### 12.4 Workweek
851
760
 
852
761
  ```
853
762
  workweek mon-fri
@@ -856,7 +765,7 @@ workweek sun-thu
856
765
 
857
766
  Top-level directive (not nested under `holiday`).
858
767
 
859
- ### 13.5 Eras
768
+ ### 12.5 Eras
860
769
 
861
770
  **Flat form:**
862
771
  ```
@@ -870,7 +779,7 @@ era
870
779
  2026-06-01 -> 2026-06-05 Sprint Review (blue)
871
780
  ```
872
781
 
873
- ### 13.6 Markers
782
+ ### 12.6 Markers
874
783
 
875
784
  **Flat form:**
876
785
  ```
@@ -884,7 +793,7 @@ marker
884
793
  2026-06-15 Release (green)
885
794
  ```
886
795
 
887
- ### 13.7 Groups (Swimlanes)
796
+ ### 12.7 Groups (Swimlanes)
888
797
 
889
798
  ```
890
799
  [Backend] | t: Engineering
@@ -892,7 +801,7 @@ marker
892
801
 
893
802
  Bracket syntax only.
894
803
 
895
- ### 13.8 Tasks
804
+ ### 12.8 Tasks
896
805
 
897
806
  ```
898
807
  20bd Database Schema | p: Foundation, 100%
@@ -905,7 +814,7 @@ Duration units: `min`, `h`, `d`, `bd` (business days), `w`, `m`, `q`, `y`
905
814
  Uncertain: `10bd?` (trailing `?`)
906
815
  Progress: `| 80%` in pipe metadata
907
816
 
908
- ### 13.9 Dependencies (Indented Under Tasks)
817
+ ### 12.9 Dependencies (Indented Under Tasks)
909
818
 
910
819
  ```
911
820
  10bd API Integration
@@ -913,7 +822,7 @@ Progress: `| 80%` in pipe metadata
913
822
  -> Launch Day | offset: 10bd
914
823
  ```
915
824
 
916
- ### 13.10 Parallel Block
825
+ ### 12.10 Parallel Block
917
826
 
918
827
  ```
919
828
  parallel
@@ -925,6 +834,89 @@ parallel
925
834
 
926
835
  ---
927
836
 
837
+ ## 13. Boxes and Lines Diagrams
838
+
839
+ ### 13.1 Declaration
840
+
841
+ ```
842
+ boxes-and-lines [Title]
843
+ ```
844
+
845
+ Requires explicit first line — no heuristic detection. Default direction is left-to-right.
846
+
847
+ ### 13.2 Nodes
848
+
849
+ ```
850
+ NodeLabel
851
+ NodeLabel | key: value, key2: value2
852
+ NodeLabel | description: Some text here
853
+ ```
854
+
855
+ Nodes are created explicitly or implicitly (when referenced in edges). All nodes render as uniform rounded rectangles.
856
+
857
+ The `description` key is extracted as a dedicated field and not stored in metadata.
858
+
859
+ ### 13.3 Edges
860
+
861
+ ```
862
+ Source -> Target
863
+ Source -> Target | key: value
864
+ Source -label-> Target
865
+ Source <-> Target
866
+ Source <-label-> Target
867
+ ```
868
+
869
+ Indented shorthand (source from preceding node):
870
+ ```
871
+ API | description: Main gateway
872
+ -routes-> UserService
873
+ -routes-> ProductService
874
+ ```
875
+
876
+ Pipe metadata on edges:
877
+ ```
878
+ A -reads-> DB | frequency: High
879
+ ```
880
+
881
+ ### 13.4 Groups
882
+
883
+ ```
884
+ [Group Name]
885
+ indented nodes...
886
+
887
+ [Group Name] | key: value
888
+ indented nodes...
889
+ ```
890
+
891
+ Nested groups (max depth 2):
892
+ ```
893
+ [AWS]
894
+ [us-east-1]
895
+ API
896
+ DB
897
+ ```
898
+
899
+ Group metadata cascades to children (node metadata overrides). Nodes already declared above can be referenced inside groups to assign membership.
900
+
901
+ ### 13.5 Group-to-Group Edges
902
+
903
+ ```
904
+ [Region A] -> [Region B]
905
+ [Region A] <-> [Region B]
906
+ [Region A] -VPN-> [Region B]
907
+ ```
908
+
909
+ ### 13.6 Directives
910
+
911
+ - `direction TB` — top-to-bottom layout (default: `LR`)
912
+
913
+ ### 13.7 Options
914
+
915
+ - `active-tag GroupName` — set active tag group for coloring
916
+ - `hide team:Backend, team:Frontend` — hide nodes with matching tag values (colon syntax for tag:value)
917
+
918
+ ---
919
+
928
920
  ## 14. Timeline Diagrams
929
921
 
930
922
  ### 14.1 Declaration
@@ -1223,14 +1215,13 @@ top-left Train (yellow)
1223
1215
  bottom-left Maroon (red)
1224
1216
  bottom-right Watch Closely (purple)
1225
1217
 
1226
- Quartermaster 0.9, 0.95
1227
- Navigator 0.85, 0.8
1218
+ Quartermaster 0.9 0.95
1219
+ Navigator 0.85 0.8
1228
1220
  ```
1229
1221
 
1230
- - Axis labels: `x-label Low, High` — space-separated
1222
+ - Axis labels: `x-label Low, High` — comma-separated
1231
1223
  - Position labels: `top-right Label` — space-separated
1232
- - Data points: `Label x, y` — space-separated, comma between coordinates
1233
- - Thousands commas supported in values
1224
+ - Data points: `Label x y` or `Label x, y` — comma or space between coordinates
1234
1225
 
1235
1226
  ---
1236
1227
 
@@ -1246,7 +1237,7 @@ Navigator 0.85, 0.8
1246
1237
  | Class field types | class | `+ name: string` |
1247
1238
  | Class method returns | class | `+ sail(): void` |
1248
1239
  | Function expressions | function | `f(x): x^2 + 1` |
1249
- | Hide tag values | initiative-status | `hide phase:Planning` |
1240
+ | Hide tag values | boxes-and-lines | `hide phase:Planning` |
1250
1241
 
1251
1242
  ### Colons OPTIONAL
1252
1243
 
@@ -0,0 +1,64 @@
1
+ boxes-and-lines E-Commerce Platform
2
+
3
+ tag Team t Backend(blue), Frontend(green), Platform(purple)
4
+ tag Priority p High(red), Medium(orange), Low(gray)
5
+
6
+ active-tag Team
7
+ hide priority:Low
8
+
9
+ direction LR
10
+
11
+ // --- Services ---
12
+ API Gateway | t: Backend, description: Main entry point for all requests
13
+ -routes-> UserService
14
+ -routes-> ProductService
15
+ -routes-> OrderService
16
+
17
+ UserService | t: Backend, description: Handles auth and profiles
18
+ -reads-> UserDB
19
+ -checks-> SessionCache
20
+
21
+ ProductService | t: Frontend, description: Product catalog and search
22
+ -queries-> ProductDB
23
+ -invalidates-> ProductCache
24
+
25
+ OrderService | t: Backend, description: Order processing pipeline
26
+ -writes-> OrderDB
27
+ -publishes-> OrderQueue
28
+
29
+ // --- Data Stores ---
30
+ UserDB | t: Platform
31
+ ProductDB | t: Platform
32
+ OrderDB | t: Platform
33
+ SessionCache | t: Platform
34
+ ProductCache | t: Platform
35
+ OrderQueue | t: Platform
36
+
37
+ // --- External ---
38
+ PaymentGateway | t: Backend, description: Stripe integration
39
+ OrderService -charges-> PaymentGateway
40
+
41
+ // --- Consumer ---
42
+ WebApp | t: Frontend
43
+ WebApp -> API Gateway
44
+
45
+ Admin | t: Backend
46
+ Admin -> API Gateway
47
+
48
+ // --- Groups ---
49
+ [AWS us-east-1]
50
+ [Compute]
51
+ API Gateway
52
+ UserService
53
+ ProductService
54
+ OrderService
55
+ [Data]
56
+ UserDB
57
+ ProductDB
58
+ OrderDB
59
+
60
+ // --- Group edge ---
61
+ OrderQueue -> PaymentGateway
62
+
63
+ // --- Bidirectional ---
64
+ SessionCache <-syncs-> ProductCache | p: Medium
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagrammo/dgmo",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "description": "DGMO diagram markup language — parser, renderer, and color system",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -0,0 +1,78 @@
1
+ // ============================================================
2
+ // Boxes and Lines — Collapse/Expand Transform
3
+ // ============================================================
4
+
5
+ import type { ParsedBoxesAndLines, BLGroup } from './types';
6
+
7
+ export interface BLCollapseResult {
8
+ parsed: ParsedBoxesAndLines;
9
+ collapsedChildCounts: Map<string, number>;
10
+ originalGroups: BLGroup[];
11
+ }
12
+
13
+ /**
14
+ * Pure transform: returns a new ParsedBoxesAndLines with collapsed groups
15
+ * removed from the diagram content.
16
+ *
17
+ * - Children of collapsed groups removed from nodes
18
+ * - Edges redirected: endpoints in collapsed groups → group ID
19
+ * - Internal edges (both in same collapsed group) dropped
20
+ * - Duplicate edges (same source, target, label) deduplicated
21
+ * - Collapsed groups removed from groups[] (layout handles as nodes)
22
+ */
23
+ export function collapseBoxesAndLines(
24
+ parsed: ParsedBoxesAndLines,
25
+ collapsedGroups: Set<string>
26
+ ): BLCollapseResult {
27
+ const originalGroups = parsed.groups;
28
+
29
+ if (collapsedGroups.size === 0) {
30
+ return { parsed, collapsedChildCounts: new Map(), originalGroups };
31
+ }
32
+
33
+ // Build group lookup by label
34
+ const groupByLabel = new Map<string, BLGroup>();
35
+ for (const group of parsed.groups) {
36
+ groupByLabel.set(group.label, group);
37
+ }
38
+
39
+ // Build node → collapsed group lookup
40
+ const nodeToGroup = new Map<string, string>();
41
+ const collapsedChildCounts = new Map<string, number>();
42
+
43
+ for (const groupLabel of collapsedGroups) {
44
+ const group = groupByLabel.get(groupLabel);
45
+ if (!group) continue;
46
+ const groupId = `__group_${groupLabel}`;
47
+
48
+ for (const child of group.children) {
49
+ nodeToGroup.set(child, groupId);
50
+ }
51
+ collapsedChildCounts.set(groupLabel, group.children.length);
52
+ }
53
+
54
+ // Filter nodes: remove children of collapsed groups
55
+ const nodes = parsed.nodes.filter((n) => !nodeToGroup.has(n.label));
56
+
57
+ // Remap and deduplicate edges
58
+ const edgeKeys = new Set<string>();
59
+ const edges: typeof parsed.edges = [];
60
+ for (const edge of parsed.edges) {
61
+ const src = nodeToGroup.get(edge.source) ?? edge.source;
62
+ const tgt = nodeToGroup.get(edge.target) ?? edge.target;
63
+ if (src === tgt) continue;
64
+ const key = `${src}|${tgt}|${edge.label ?? ''}`;
65
+ if (edgeKeys.has(key)) continue;
66
+ edgeKeys.add(key);
67
+ edges.push({ ...edge, source: src, target: tgt });
68
+ }
69
+
70
+ // Keep only groups that are not collapsed
71
+ const groups = parsed.groups.filter((g) => !collapsedGroups.has(g.label));
72
+
73
+ return {
74
+ parsed: { ...parsed, nodes, edges, groups },
75
+ collapsedChildCounts,
76
+ originalGroups,
77
+ };
78
+ }