@diagrammo/dgmo 0.7.2 → 0.8.0
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 +3529 -1061
- 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 +3516 -1061
- 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 +312 -73
- package/src/dgmo-router.ts +63 -8
- package/src/echarts.ts +726 -231
- 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 +82 -31
- 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/src/dgmo-router.ts
CHANGED
|
@@ -17,26 +17,79 @@ import { looksLikeInitiativeStatus, parseInitiativeStatus } from './initiative-s
|
|
|
17
17
|
import { looksLikeSitemap, parseSitemap } from './sitemap/parser';
|
|
18
18
|
import { parseInfra } from './infra/parser';
|
|
19
19
|
import { parseGantt } from './gantt/parser';
|
|
20
|
+
import { ALL_CHART_TYPES, parseFirstLine } from './utils/parsing';
|
|
20
21
|
import type { DgmoError } from './diagnostics';
|
|
21
22
|
|
|
23
|
+
// ============================================================
|
|
24
|
+
// Content-based chart type inference helpers
|
|
25
|
+
// ============================================================
|
|
26
|
+
|
|
27
|
+
/** Gantt duration patterns: `10bd Task` or `10bd: Task` (with or without colon) */
|
|
28
|
+
const GANTT_DURATION_RE = /^\d+(?:\.\d+)?(?:min|bd|d|w|m|q|y|h)(?:\?)?\s*:?\s+/;
|
|
29
|
+
/** Gantt date patterns: `2025-01-01 Task` or `2025-01-01: Task` (with or without colon) */
|
|
30
|
+
const GANTT_DATE_RE = /^\d{4}-\d{2}-\d{2}(?:\s\d{2}:\d{2})?\s*:?\s+/;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if content looks like a gantt chart.
|
|
34
|
+
* Detects duration patterns like `10bd: Task` or `5d: Task`.
|
|
35
|
+
*/
|
|
36
|
+
export function looksLikeGantt(content: string): boolean {
|
|
37
|
+
const lines = content.split('\n');
|
|
38
|
+
for (const line of lines) {
|
|
39
|
+
const trimmed = line.trim();
|
|
40
|
+
if (!trimmed || trimmed.startsWith('//')) continue;
|
|
41
|
+
if (GANTT_DURATION_RE.test(trimmed) || GANTT_DATE_RE.test(trimmed)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** C4 `Name is a person/system/container/component` pattern */
|
|
49
|
+
const C4_TYPE_RE = /\bis\s+an?\s+(person|system|container|component)\b/i;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Returns true if content looks like a C4 diagram.
|
|
53
|
+
* Detects `Name is a person/system/container/component` declarations.
|
|
54
|
+
* Does NOT match bare words like `container` at line start.
|
|
55
|
+
*/
|
|
56
|
+
export function looksLikeC4(content: string): boolean {
|
|
57
|
+
const lines = content.split('\n');
|
|
58
|
+
for (const line of lines) {
|
|
59
|
+
const trimmed = line.trim();
|
|
60
|
+
if (!trimmed || trimmed.startsWith('//')) continue;
|
|
61
|
+
if (C4_TYPE_RE.test(trimmed)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
22
68
|
/**
|
|
23
|
-
* Extracts the
|
|
24
|
-
*
|
|
25
|
-
* (e.g
|
|
69
|
+
* Extracts the chart type from raw file content.
|
|
70
|
+
* First tries the first non-empty, non-comment line as a bare chart type name
|
|
71
|
+
* (e.g., `gantt Product Launch`). Falls back to old `chart: type` syntax.
|
|
72
|
+
* Falls back to inference when no explicit chart type is found.
|
|
26
73
|
*/
|
|
27
74
|
export function parseDgmoChartType(content: string): string | null {
|
|
28
75
|
const lines = content.split('\n');
|
|
76
|
+
|
|
77
|
+
// Find first non-empty, non-comment line
|
|
29
78
|
for (const line of lines) {
|
|
30
79
|
const trimmed = line.trim();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
80
|
+
if (!trimmed || trimmed.startsWith('//')) continue;
|
|
81
|
+
|
|
82
|
+
// Try new first-line detection (bare chart type name)
|
|
83
|
+
const firstLineResult = parseFirstLine(trimmed);
|
|
84
|
+
if (firstLineResult) return firstLineResult.chartType;
|
|
85
|
+
|
|
86
|
+
// Not a chart type on the first line — stop looking for explicit declaration
|
|
87
|
+
break;
|
|
36
88
|
}
|
|
37
89
|
|
|
38
90
|
// Infer chart type from content patterns (sequence before flowchart —
|
|
39
91
|
// both use `->` but sequence uses bare names while flowchart uses shape delimiters)
|
|
92
|
+
// C4 must come AFTER sequence (both use `is a` but with different type nouns)
|
|
40
93
|
if (looksLikeSequence(content)) return 'sequence';
|
|
41
94
|
if (looksLikeFlowchart(content)) return 'flowchart';
|
|
42
95
|
if (looksLikeClassDiagram(content)) return 'class';
|
|
@@ -45,6 +98,8 @@ export function parseDgmoChartType(content: string): string | null {
|
|
|
45
98
|
if (looksLikeState(content)) return 'state';
|
|
46
99
|
if (looksLikeSitemap(content)) return 'sitemap';
|
|
47
100
|
if (looksLikeOrg(content)) return 'org';
|
|
101
|
+
if (looksLikeC4(content)) return 'c4';
|
|
102
|
+
if (looksLikeGantt(content)) return 'gantt';
|
|
48
103
|
|
|
49
104
|
return null;
|
|
50
105
|
}
|