@diagrammo/dgmo 0.34.0 → 0.35.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.
Files changed (55) hide show
  1. package/.claude/commands/dgmo.md +17 -32
  2. package/.github/copilot-instructions.md +1 -1
  3. package/README.md +7 -1
  4. package/SKILL.md +1 -1
  5. package/dist/advanced.cjs +462 -465
  6. package/dist/advanced.d.cts +2 -51
  7. package/dist/advanced.d.ts +2 -51
  8. package/dist/advanced.js +462 -466
  9. package/dist/auto.cjs +463 -142
  10. package/dist/auto.js +91 -91
  11. package/dist/auto.mjs +463 -142
  12. package/dist/cli.cjs +143 -326
  13. package/dist/index.cjs +462 -141
  14. package/dist/index.js +462 -141
  15. package/docs/ai-integration.md +46 -26
  16. package/docs/language-reference.md +2 -2
  17. package/package.json +2 -2
  18. package/src/advanced.ts +0 -12
  19. package/src/c4/parser.ts +15 -6
  20. package/src/chart.ts +1 -1
  21. package/src/class/parser.ts +6 -2
  22. package/src/cli-banner.ts +2 -3
  23. package/src/cli.ts +539 -1223
  24. package/src/cycle/parser.ts +4 -1
  25. package/src/dgmo-router.ts +16 -2
  26. package/src/diagnostics.ts +0 -0
  27. package/src/echarts.ts +5 -1
  28. package/src/er/parser.ts +5 -1
  29. package/src/gantt/parser.ts +13 -4
  30. package/src/graph/flowchart-parser.ts +5 -1
  31. package/src/graph/state-parser.ts +5 -1
  32. package/src/infra/parser.ts +10 -6
  33. package/src/journey-map/parser.ts +5 -2
  34. package/src/kanban/parser.ts +6 -2
  35. package/src/map/context-labels.ts +29 -19
  36. package/src/map/layout.ts +403 -108
  37. package/src/map/legend-band.ts +28 -0
  38. package/src/map/parser.ts +13 -4
  39. package/src/map/renderer.ts +74 -23
  40. package/src/map/resolver.ts +2 -2
  41. package/src/org/parser.ts +8 -2
  42. package/src/pyramid/parser.ts +4 -1
  43. package/src/raci/parser.ts +4 -1
  44. package/src/ring/parser.ts +4 -1
  45. package/src/sequence/parser.ts +6 -3
  46. package/src/sitemap/parser.ts +12 -3
  47. package/src/tech-radar/parser.ts +6 -3
  48. package/src/utils/parsing.ts +2 -2
  49. package/src/utils/tag-groups.ts +3 -3
  50. package/src/visualizations/parse.ts +9 -3
  51. package/src/migrate/data-comma.ts +0 -117
  52. package/src/migrate/embedded.ts +0 -238
  53. package/src/migrate/index.ts +0 -295
  54. package/src/migrate/line-classifier.ts +0 -128
  55. package/src/migrate/line-transformer.ts +0 -218
@@ -4,44 +4,56 @@ Use AI coding tools to generate `.dgmo` diagrams. This guide covers Claude Code,
4
4
 
5
5
  ---
6
6
 
7
- ## MCP Server (recommended for Claude)
7
+ ## One-step setup (recommended)
8
8
 
9
- `@diagrammo/dgmo-mcp` provides an MCP server that gives Claude the ability to render, share, and look up DGMO diagrams directly — no file management needed.
9
+ Install the `dgmo` CLI, then run one command:
10
10
 
11
- **5 tools:** `render_diagram`, `share_diagram`, `open_in_app`, `list_chart_types`, `get_language_reference`
11
+ ```bash
12
+ brew install diagrammo/dgmo/dgmo # or: npm install -g @diagrammo/dgmo
13
+ dgmo install # auto-detects every AI assistant you have
14
+ ```
12
15
 
13
- Add to `~/.claude/settings.json` (global) or `.claude/settings.local.json` (project):
16
+ `dgmo install` with **no target** scans for Claude Code, Codex, Claude Desktop, Cursor, Windsurf, and Copilot, then configures each one non-interactively — no prompts, no second package to install. The only binary you ever need is `dgmo`; it provides the MCP server through its own `dgmo mcp` subcommand.
14
17
 
15
- ```json
16
- {
17
- "mcpServers": {
18
- "dgmo": {
19
- "command": "npx",
20
- "args": ["-y", "@diagrammo/dgmo-mcp"]
21
- }
22
- }
23
- }
18
+ Target a single assistant, or pick a scope, when you want to:
19
+
20
+ ```bash
21
+ dgmo install claude-code # just one surface
22
+ dgmo install codex --scope project # write config into the current repo
23
+ dgmo install --dry-run # preview every change, write nothing
24
24
  ```
25
25
 
26
- See `dgmo-mcp/README.md` for full configuration options.
26
+ For Claude Code this copies the `/dgmo` skill into `~/.claude/commands/` (full dgmo context — all chart types, CLI flags, workflow, and tips) and adds the MCP server to `~/.claude/settings.json`. Restart the assistant afterward.
27
+
28
+ **Keeping it current:**
29
+ - **Homebrew** bundles the MCP server, so `brew upgrade dgmo` upgrades the CLI *and* the server together. Re-run `dgmo install` afterward only to refresh the **skill files** (those are copies in your home dir).
30
+ - **npm global**: a plain `dgmo` upgrade doesn't touch the server or skill copies — re-run `dgmo install`, which overwrites the skills and upgrades the server to the latest.
31
+ - Either way, `DGMO_MCP_LATEST=1` in the environment makes `dgmo mcp` always fetch the newest server at launch (network round-trip on start), so it's never stale.
27
32
 
28
33
  ---
29
34
 
30
- ## Claude Code — Skill (slash command)
35
+ ## Manual MCP configuration
31
36
 
32
- Installs a `/dgmo` slash command that gives Claude full dgmo context — all chart types, CLI flags, workflow, and tips.
37
+ `dgmo install` is the easy path. To wire the MCP server by hand, point any MCP client at the `dgmo` binary's `mcp` subcommand:
33
38
 
34
- ```bash
35
- dgmo --install-claude-skill
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "dgmo": {
43
+ "command": "dgmo",
44
+ "args": ["mcp"]
45
+ }
46
+ }
47
+ }
36
48
  ```
37
49
 
38
- This copies a skill file into `~/.claude/commands/`, making `/dgmo` available in every Claude Code session.
50
+ **5 tools:** `render_diagram`, `share_diagram`, `open_in_app`, `list_chart_types`, `get_language_reference`. `dgmo mcp` execs the installed server, or fetches it on demand via `npx` if it isn't installed yet — so no separate `dgmo-mcp` step is required. (If you'd rather not install the CLI at all, `{ "command": "npx", "args": ["-y", "@diagrammo/dgmo-mcp"] }` still works.) See `dgmo-mcp/README.md` for full options.
39
51
 
40
52
  ---
41
53
 
42
54
  ## Claude Code — CLAUDE.md snippet
43
55
 
44
- To teach Claude about DGMO in a specific project without the global skill, paste the generated core below into your `CLAUDE.md`. It is the same single-sourced anti-patterns + 45-type index that every DGMO AI surface carries (see "How the AI core is generated"). Render with `dgmo file.dgmo` (PNG) or `dgmo file.dgmo -o url` (shareable link); full per-type syntax lives in `node_modules/@diagrammo/dgmo/docs/language-reference.md`.
56
+ To teach Claude about DGMO in a specific project without the global skill, paste the generated core below into your `CLAUDE.md`. It is the same single-sourced anti-patterns + 45-type index that every DGMO AI surface carries (see "How the AI core is generated"). Render with `dgmo file.dgmo` (PNG) or `dgmo share file.dgmo` (shareable link); full per-type syntax lives in `node_modules/@diagrammo/dgmo/docs/language-reference.md`.
45
57
 
46
58
  <!-- GENERATED by dgmo/scripts/gen-ai-core.mjs from docs/language-reference.md — DO NOT EDIT between the DGMO-AI-CORE markers; run `node scripts/gen-ai-core.mjs` (or sync-language-ref.sh) to regenerate. -->
47
59
  <!-- DGMO-AI-CORE:START -->
@@ -477,7 +489,15 @@ DGMO ships context files for popular AI coding tools, included in the npm packag
477
489
  | `.cursorrules` | Cursor | Auto-loaded when present in project root |
478
490
  | `.windsurfrules` | Windsurf | Auto-loaded when present in project root (byte-identical to `.cursorrules`) |
479
491
 
480
- Copy the relevant file into your project root:
492
+ The easiest way to set these up is `dgmo install` — it does the right thing per tool:
493
+
494
+ ```bash
495
+ dgmo install cursor # wires MCP (~/.cursor/mcp.json) + drops .cursorrules
496
+ dgmo install windsurf # wires MCP (~/.codeium/windsurf/mcp_config.json) + .windsurfrules
497
+ dgmo install copilot # writes ./.github/copilot-instructions.md (Copilot has no MCP)
498
+ ```
499
+
500
+ Cursor and Windsurf speak MCP, so `dgmo install` gives them the full render/share tools (pointed at `dgmo mcp`), plus the inline rules file. Copilot is guidance-only. `dgmo install` with no target also writes Copilot's file automatically when the current repo has a `.github` directory. To set the context files up by hand instead:
481
501
 
482
502
  ```bash
483
503
  # From node_modules (if installed as a dependency)
@@ -510,14 +530,14 @@ Regeneration runs inside `sync-language-ref.sh`; a Vitest gate parses every emit
510
530
  ```bash
511
531
  dgmo diagram.dgmo # PNG output
512
532
  dgmo diagram.dgmo -o output.svg # SVG output
513
- dgmo diagram.dgmo -o url # Shareable diagrammo.app URL
514
- dgmo diagram.dgmo -o url --copy # URL copied to clipboard
515
- dgmo --chart-types # List all supported chart types
516
- dgmo --chart-types --json # Machine-readable chart type list
533
+ dgmo share diagram.dgmo # Shareable diagrammo.app URL (copied to clipboard)
534
+ dgmo share diagram.dgmo --no-copy # Print URL without touching the clipboard
535
+ dgmo types # List all supported chart types
536
+ dgmo types --json # Machine-readable chart type list
517
537
  ```
518
538
 
519
539
  ---
520
540
 
521
541
  ## Supported chart types
522
542
 
523
- Run `dgmo --chart-types` for the full, authoritative list, call the MCP `list_chart_types` tool, or see the 45-type index in `docs/language-reference.md` (§0 AI Core). The list is intentionally not duplicated here — it drifts every time a chart type is added.
543
+ Run `dgmo types` for the full, authoritative list, call the MCP `list_chart_types` tool, or see the 45-type index in `docs/language-reference.md` (§0 AI Core). The list is intentionally not duplicated here — it drifts every time a chart type is added.
@@ -3188,7 +3188,7 @@ Markers in cells are always **rendered in canonical alphabet order** (`R A C I`,
3188
3188
  <!-- TYPE:map -->
3189
3189
 
3190
3190
  <!-- TIPS start -->
3191
- **Styling tips:** the zero-config map already looks good — name places and stop. When POIs fall into categories, tag them so each category gets its own color; keep place labels to the place name; leave region colorize and coastlines on unless the user asks to hide them. **For flights and airport routes, use IATA codes, not city names** — `LHR ~> JFK`, `LHR ~> DXB`, `LHR ~> SIN`, `LHR ~> HND` — the bundled airport set (large international hubs + all US commercial airports) resolves them to the right coordinates and labels them with the code. **For cities, use the exact canonical name**: "New York City" (NOT "New York"), "Washington, D.C.", etc. — a name the gazetteer doesn't have **silently drops that point** and the map just reframes around the rest, so it looks fine but is wrong. When unsure of the exact token, look it up: `dgmo map search "<place>"` (or the `lookup_map_location` MCP tool) returns the city name or airport code to paste; fall back to coordinates (`poi Name as 40.71,-74.0`) for anything not found. **For routes/flows from a hub** (an airport's daily flights, a distribution center's shipments), write ONE edge per line and repeat the origin — never indented edges (those error). Use **arcs** (`~>`) for flights and long-haul links so the spokes separate; the connector label carries the relationship (`~daily~>`, `~2x daily~>`). Endpoints auto-create POIs, so don't add separate `poi` lines for places already in an edge. Reach for a `route` block only when the trip is an **ordered voyage** that continues stop→stop (a cruise itinerary), not a set of independent routes from one origin.
3191
+ **Styling tips:** the zero-config map already looks good — name places and stop. When POIs fall into categories, tag them so each category gets its own color; keep place labels to the place name; leave region colorize and coastlines on unless the user asks to hide them. **For flights and airport routes, use IATA codes, not city names** — `LHR ~> JFK`, `LHR ~> DXB`, `LHR ~> SIN`, `LHR ~> HND` — the bundled airport set (large international hubs + all US commercial airports) resolves them to the right coordinates and labels them with the code. **For cities, use the exact canonical name**: "New York City" (NOT "New York"), "Washington, D.C.", etc. — a name the gazetteer doesn't have **silently drops that point** and the map just reframes around the rest, so it looks fine but is wrong. When unsure of the exact token, look it up: `dgmo map-search "<place>"` (or the `lookup_map_location` MCP tool) returns the city name or airport code to paste; fall back to coordinates (`poi Name as 40.71,-74.0`) for anything not found. **For routes/flows from a hub** (an airport's daily flights, a distribution center's shipments), write ONE edge per line and repeat the origin — never indented edges (those error). Use **arcs** (`~>`) for flights and long-haul links so the spokes separate; the connector label carries the relationship (`~daily~>`, `~2x daily~>`). Endpoints auto-create POIs, so don't add separate `poi` lines for places already in an edge. Reach for a `route` block only when the trip is an **ordered voyage** that continues stop→stop (a cruise itinerary), not a set of independent routes from one origin.
3192
3192
  <!-- TIPS end -->
3193
3193
 
3194
3194
  Geographic concept maps: highlight/shade political subdivisions, drop points of interest (POIs), and connect them with routes or edges. For "share a concept" business maps, not cartography. Renders at a fixed, auto-fit position — no pan/zoom. Basemap and viewport are **inferred from the content you reference** — most maps need no directives. v1 boundaries: world countries + US states.
@@ -3332,7 +3332,7 @@ cove -> hav l: March # the LINE turns green
3332
3332
  - The redundant `Georgia US-GA` still works but isn't needed (a mismatched code like `Georgia US-CA` is rejected). A bare ambiguous `Georgia` follows the inferred US-scope signal and warns with both fixes named.
3333
3333
  - **IATA airport codes** resolve to airport coordinates — `poi JFK`, `route JFK -> LAX` — with no new syntax (large international hubs + all US scheduled-commercial airports). Case-insensitive (`jfk`/`JFK`). Airports are the **lowest-precedence** identifier: a token that is both a city and a code resolves to the **city** (`Ufa` → the city, not UFA airport), with a hint naming the airport. Resolution is by **code only** (never by airport name); the POI label is the typed code. An unknown three-letter code errors with an `as <CODE>` coordinates hint.
3334
3334
  - **A city name must match the gazetteer's canonical form** — `New York City`, not `New York`; `Washington, D.C.`, not `Washington`. An unrecognized name is dropped (with a did-you-mean note) and the map reframes around the places that *did* resolve, so the result can look complete but be missing a point. Use the exact name or coordinates.
3335
- - **Discover the exact token** with the lookup surface rather than guessing — `dgmo map search "<place>"` (CLI; `--json` for machine output) or the `lookup_map_location` MCP tool. It substring-searches cities **and** the bundled airports and returns the precise token to paste (e.g. `york` → `New York City`; `heathrow` → `LHR`). There is intentionally **no exhaustive printed list** — the gazetteer holds thousands of cities plus ~1,500 airports; search is the interface.
3335
+ - **Discover the exact token** with the lookup surface rather than guessing — `dgmo map-search "<place>"` (CLI; `--json` for machine output) or the `lookup_map_location` MCP tool. It substring-searches cities **and** the bundled airports and returns the precise token to paste (e.g. `york` → `New York City`; `heathrow` → `LHR`). There is intentionally **no exhaustive printed list** — the gazetteer holds thousands of cities plus ~1,500 airports; search is the interface.
3336
3336
  - Positional coordinates are the escape hatch for anything missing/ambiguous (including forcing an airport over a colliding city: `poi 54.56 55.87 as UFA`).
3337
3337
 
3338
3338
  ### Directives & reserved keys
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagrammo/dgmo",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "DGMO diagram markup language — parser, renderer, and color system",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -140,7 +140,7 @@
140
140
  "check:publish": "publint",
141
141
  "check:size": "pnpm build && du -sh dist/ && echo '---' && ls -lh dist/*.js dist/*.cjs",
142
142
  "check:types": "attw --pack . --ignore-rules no-resolution false-export-default",
143
- "postinstall": "node -e \"console.log('\\n💡 Claude Code user? Run: dgmo --install-claude-skill\\n')\"",
143
+ "postinstall": "node -e \"console.log('\\n💡 Claude Code user? Run: dgmo install claude-code\\n')\"",
144
144
  "prepare": "husky"
145
145
  },
146
146
  "dependencies": {
package/src/advanced.ts CHANGED
@@ -797,15 +797,3 @@ export { themes, type Theme } from './themes';
797
797
 
798
798
  // Public-API alias for parseDgmo (also exported from the public root as `validate`)
799
799
  export { parseDgmo as validate } from './dgmo-router';
800
-
801
- // `dgmo migrate` — programmatic access to the 0.18.0 legacy `|` → §1.4
802
- // migration. Consumed by `@diagrammo/dgmo-mcp`'s `migrate_diagram` tool
803
- // and by external authoring tools that want to offer in-place migration.
804
- export {
805
- migrateContent,
806
- formatLineDiff,
807
- isLegacyMetadataLine,
808
- findUnsafePipePositions,
809
- transformLine,
810
- } from './migrate';
811
- export type { ContentMigration, TransformResult } from './migrate';
package/src/c4/parser.ts CHANGED
@@ -516,7 +516,7 @@ export function parseC4(content: string, palette?: PaletteColors): ParsedC4 {
516
516
  } else {
517
517
  pushError(
518
518
  lineNumber,
519
- `"container ${refName}" must be inside a deployment node`
519
+ `"container ${refName}" must be indented under a deployment node (e.g. under 'Prod is a deployment-node')`
520
520
  );
521
521
  }
522
522
  continue;
@@ -585,7 +585,10 @@ export function parseC4(content: string, palette?: PaletteColors): ParsedC4 {
585
585
  indent,
586
586
  });
587
587
  } else {
588
- pushError(lineNumber, `"${sectionType}" must be inside an element`);
588
+ pushError(
589
+ lineNumber,
590
+ `"${sectionType}" must be indented under an element (e.g. under 'Web App is a container')`
591
+ );
589
592
  }
590
593
  continue;
591
594
  }
@@ -618,7 +621,10 @@ export function parseC4(content: string, palette?: PaletteColors): ParsedC4 {
618
621
  indent,
619
622
  });
620
623
  } else {
621
- pushError(lineNumber, `Group [${groupName}] must be inside an element`);
624
+ pushError(
625
+ lineNumber,
626
+ `Group [${groupName}] must be indented under an element (e.g. under 'Web App is a container')`
627
+ );
622
628
  }
623
629
  continue;
624
630
  }
@@ -1049,7 +1055,10 @@ export function parseC4(content: string, palette?: PaletteColors): ParsedC4 {
1049
1055
  }
1050
1056
  desc.push(descResult.text);
1051
1057
  } else {
1052
- pushError(lineNumber, `Unexpected content: "${trimmed}"`);
1058
+ pushError(
1059
+ lineNumber,
1060
+ `Unexpected content: "${trimmed}". Expected an element ('Web App is a container'), a relationship ('-Uses-> Database'), indented metadata ('tech: React'), or a group ('[Backend]'). (§8)`
1061
+ );
1053
1062
  }
1054
1063
  }
1055
1064
 
@@ -1154,7 +1163,7 @@ function validateRelationshipTargets(
1154
1163
  for (const el of elements) {
1155
1164
  for (const rel of el.relationships) {
1156
1165
  if (!knownNames.has(normalizeName(rel.target))) {
1157
- let msg = `Relationship target "${rel.target}" not found`;
1166
+ let msg = `Relationship target "${rel.target}" not found — declare it first (e.g. '${rel.target} is a container'), then reference it in the arrow`;
1158
1167
  const hint = suggest(normalizeName(rel.target), allNames);
1159
1168
  if (hint) msg += `. ${hint}`;
1160
1169
  pushWarning(rel.lineNumber, msg, 'warning');
@@ -1193,7 +1202,7 @@ function validateDeploymentRefs(
1193
1202
  for (const node of nodes) {
1194
1203
  for (const ref of node.containerRefs) {
1195
1204
  if (!knownNames.has(normalizeName(ref))) {
1196
- let msg = `Deployment reference "container ${ref}" not found`;
1205
+ let msg = `Deployment reference "container ${ref}" not found — declare the container element first, then reference it under the deployment node`;
1197
1206
  const hint = suggest(normalizeName(ref), allNames);
1198
1207
  if (hint) msg += `. ${hint}`;
1199
1208
  pushWarning(node.lineNumber, msg, 'warning');
package/src/chart.ts CHANGED
@@ -174,7 +174,7 @@ export function parseChart(
174
174
  result.diagnostics.push(
175
175
  makeDgmoError(
176
176
  lineNumber,
177
- `'${trimmed}' — ## syntax is no longer supported. Use [Group] containers instead`
177
+ `'${trimmed}' removed — use a bracket container '[${trimmed.replace(/^#+\s*/, '')}]' instead (## headers are no longer supported).`
178
178
  )
179
179
  );
180
180
  continue;
@@ -308,7 +308,7 @@ export function parseClassDiagram(
308
308
  result.diagnostics.push(
309
309
  makeDgmoError(
310
310
  lineNumber,
311
- '"no-auto-color" has been removed.',
311
+ '"no-auto-color" was removed — colors are always auto-assigned from the palette; delete this line.',
312
312
  'warning'
313
313
  )
314
314
  );
@@ -458,7 +458,11 @@ export function parseClassDiagram(
458
458
 
459
459
  // Catch-all: nothing matched this line
460
460
  result.diagnostics.push(
461
- makeDgmoError(lineNumber, `Unexpected line: '${trimmed}'.`, 'warning')
461
+ makeDgmoError(
462
+ lineNumber,
463
+ `Unexpected line: '${trimmed}'. Classes start uppercase at indent 0 ('Ship'); members are indented and colon-typed ('+ name: string', '+ sail(): void'); relationships are indented arrows ('--|> Vessel'). (§10)`,
464
+ 'warning'
465
+ )
462
466
  );
463
467
  }
464
468
 
package/src/cli-banner.ts CHANGED
@@ -7,9 +7,8 @@
7
7
  // sampled from the default `slate` palette (corporate blue → teal →
8
8
  // steel cyan) so the wordmark matches the brand.
9
9
  //
10
- // Honors the same guards as `dgmo cat`: color only when stdout is a TTY
11
- // and NO_COLOR is unset; otherwise prints plain ASCII so pipes/CI stay
12
- // clean.
10
+ // Color only when stdout is a TTY and NO_COLOR is unset; otherwise prints
11
+ // plain ASCII so pipes/CI stay clean.
13
12
 
14
13
  import { getPalette } from './palettes';
15
14