agentic-mermaid 0.1.1 → 0.1.2
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/CHANGELOG.md +144 -4
- package/LICENSES/Apache-2.0.txt +202 -0
- package/README.md +25 -32
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/agent-core.d.ts +463 -0
- package/dist/agent-core.js +397 -0
- package/dist/agent.d.ts +73 -1868
- package/dist/agent.js +336 -37325
- package/dist/agentic-mermaid-mcp.js +7 -38399
- package/dist/am.js +33632 -40445
- package/dist/chunk-4QECACIA.js +4702 -0
- package/dist/chunk-CDPKJ2BQ.js +37 -0
- package/dist/chunk-QKDLMOJJ.js +3487 -0
- package/dist/chunk-WI35L7IR.js +615 -0
- package/dist/chunk-WN3YDOBG.js +149 -0
- package/dist/chunk-ZYMMKQ3I.js +62637 -0
- package/dist/index-D54dqSdC.d.ts +6777 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +310 -33014
- package/dist/mcp-cli-SBQSTJFC.js +17 -0
- package/docs/README.md +14 -6
- package/docs/schemas/style-spec.schema.json +1221 -30
- package/examples/styles/catalog.json +54 -0
- package/examples/styles/cloudflare-workers-inspired-prototype.mmd +9 -0
- package/examples/styles/cloudflare-workers-inspired-prototype.style.json +110 -0
- package/examples/styles/cupertino-prototype.mmd +10 -0
- package/examples/styles/cupertino-prototype.style.json +63 -0
- package/examples/styles/mid-century-report.style.json +2 -2
- package/examples/styles/star-chart-atlas.style.json +2 -1
- package/examples/styles/transit-route-map.style.json +2 -2
- package/examples/styles/vercel-inspired-prototype.mmd +6 -0
- package/examples/styles/vercel-inspired-prototype.style.json +87 -0
- package/package.json +68 -43
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +17 -36
- package/skills/agentic-mermaid-diagram-workflow/references/cli.md +4 -5
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +15 -31
- package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +10 -14
- package/skills/agentic-mermaid-live-editor/SKILL.md +100 -206
- package/AGENT_NATIVE.md +0 -607
- package/Instructions_for_agents.md +0 -89
- package/TODO.md +0 -684
- package/assets/hero.png +0 -0
- package/dist/index-wjRjbsP-.d.ts +0 -1102
- package/docs/agent-api-cookbook.md +0 -308
- package/docs/agent-mutation-policy.md +0 -104
- package/docs/agent-workflow-examples.md +0 -46
- package/docs/api.md +0 -211
- package/docs/ascii.md +0 -103
- package/docs/assets/improvements/box-start-connector.png +0 -0
- package/docs/assets/improvements/comment-dropped-lint.png +0 -0
- package/docs/assets/improvements/er-content-loss.png +0 -0
- package/docs/assets/improvements/fan-in-trunks.png +0 -0
- package/docs/assets/improvements/gantt-family.png +0 -0
- package/docs/assets/improvements/gantt-milestone-clamp.png +0 -0
- package/docs/assets/improvements/gantt-verify-seam.png +0 -0
- package/docs/assets/improvements/subgraph-container-edges.png +0 -0
- package/docs/assets/improvements/wrapper-frontmatter.png +0 -0
- package/docs/assets/improvements/wrapper-init-directive.png +0 -0
- package/docs/assets/improvements/wrapper-leading-comment.png +0 -0
- package/docs/assets/style-cookbook/mid-century-report.png +0 -0
- package/docs/assets/style-cookbook/star-chart-atlas.png +0 -0
- package/docs/assets/style-cookbook/transit-route-map.png +0 -0
- package/docs/comparison.md +0 -94
- package/docs/config.md +0 -105
- package/docs/contributing/adding-diagram-types.md +0 -144
- package/docs/contributing/diagram-family-citizenship.matrix.json +0 -2127
- package/docs/contributing/diagram-family-citizenship.md +0 -82
- package/docs/contributing/harvesting-upstream-tests.md +0 -126
- package/docs/contributing/lessons-learned.md +0 -276
- package/docs/contributing/releasing.md +0 -82
- package/docs/contributing/visual-review-evidence.md +0 -53
- package/docs/custom-style-cookbook.md +0 -154
- package/docs/design/families/README.md +0 -26
- package/docs/design/families/architecture-beta.md +0 -48
- package/docs/design/families/flowchart-parser-conformance.md +0 -22
- package/docs/design/families/gantt-research.md +0 -137
- package/docs/design/families/gantt.md +0 -329
- package/docs/design/families/journey-agentic-cards-before.png +0 -0
- package/docs/design/families/journey-experience-curve-implementation.png +0 -0
- package/docs/design/families/journey-mermaid-classic-implementation.png +0 -0
- package/docs/design/families/journey-mermaid-classic-prototype.png +0 -0
- package/docs/design/families/journey-mermaid-classic-prototype.svg +0 -163
- package/docs/design/families/journey-mermaid-classic-prototype.svg.png +0 -0
- package/docs/design/families/journey-migration-parity.md +0 -439
- package/docs/design/families/journey-section-overlap-after.png +0 -0
- package/docs/design/families/journey-section-overlap-before.png +0 -0
- package/docs/design/families/journey-usage-research.md +0 -423
- package/docs/design/families/journey.md +0 -153
- package/docs/design/families/xychart.md +0 -85
- package/docs/design/system/README.md +0 -45
- package/docs/design/system/abstraction-audit.md +0 -224
- package/docs/design/system/abstraction-recommendations.md +0 -655
- package/docs/design/system/architecture.mmd +0 -29
- package/docs/design/system/architecture.svg +0 -137
- package/docs/design/system/layout-guarantees-and-robustness.md +0 -351
- package/docs/design/system/layout-rubric.md +0 -138
- package/docs/design/system/route-contracts.md +0 -848
- package/docs/design/system/source-preservation-ladder.md +0 -52
- package/docs/design/system/styles-rollout.md +0 -216
- package/docs/design/system/ugly-layouts.md +0 -119
- package/docs/diagram-families.md +0 -193
- package/docs/features.md +0 -147
- package/docs/fork-differences.md +0 -130
- package/docs/getting-started.md +0 -175
- package/docs/issue-derived-test-cases.md +0 -156
- package/docs/layout-characterization/README.md +0 -245
- package/docs/layout-characterization/contact-sheet-families.md +0 -498
- package/docs/layout-characterization/contact-sheet.md +0 -638
- package/docs/layout-characterization/properties.md +0 -281
- package/docs/layout-characterization/visual-quality.md +0 -160
- package/docs/layout-characterization/visual-snapshots/architecture.svg +0 -79
- package/docs/layout-characterization/visual-snapshots/class.svg +0 -60
- package/docs/layout-characterization/visual-snapshots/er.svg +0 -61
- package/docs/layout-characterization/visual-snapshots/flowchart.svg +0 -58
- package/docs/layout-characterization/visual-snapshots/gantt.svg +0 -52
- package/docs/layout-characterization/visual-snapshots/journey.svg +0 -98
- package/docs/layout-characterization/visual-snapshots/pie.svg +0 -36
- package/docs/layout-characterization/visual-snapshots/quadrant.svg +0 -47
- package/docs/layout-characterization/visual-snapshots/sequence.svg +0 -59
- package/docs/layout-characterization/visual-snapshots/state.svg +0 -52
- package/docs/layout-characterization/visual-snapshots/timeline.svg +0 -64
- package/docs/layout-characterization/visual-snapshots/xychart.svg +0 -97
- package/docs/mcp-code-mode-rationale.md +0 -101
- package/docs/mcp-http-transport.md +0 -223
- package/docs/mermaid-layout-complaints.md +0 -837
- package/docs/mutation-testing.md +0 -206
- package/docs/project/divergences.md +0 -98
- package/docs/project/dogfooding-docs-strategy.md +0 -66
- package/docs/project/hosted-mcp-cloudflare-plan.md +0 -338
- package/docs/project/lessons-learned.md +0 -1019
- package/docs/project/remove-role-styling-plan.md +0 -176
- package/docs/quality.md +0 -215
- package/docs/react.md +0 -97
- package/docs/style-authoring.md +0 -133
- package/docs/testing-strategy.md +0 -335
- package/docs/theming.md +0 -162
- package/examples/agent-improve-auth-flow.ts +0 -206
- package/examples/agent-loop.ts +0 -53
- package/examples/mcp-vs-cli-complex-diagrams.ts +0 -133
- package/llms.txt +0 -104
- package/skill-evals/README.md +0 -77
- package/skill-evals/fixtures/architecture-cache/input.mmd +0 -5
- package/skill-evals/fixtures/class-payment/input.mmd +0 -4
- package/skill-evals/fixtures/er-orders/input.mmd +0 -10
- package/skill-evals/fixtures/flowchart-cache/input.mmd +0 -3
- package/skill-evals/fixtures/gantt-release/input.mmd +0 -7
- package/skill-evals/fixtures/journey-checkout/input.mmd +0 -6
- package/skill-evals/fixtures/pie-exports/input.mmd +0 -5
- package/skill-evals/fixtures/quadrant-priorities/input.mmd +0 -11
- package/skill-evals/fixtures/sequence-retry/input.mmd +0 -8
- package/skill-evals/fixtures/state-lifecycle/input.mmd +0 -5
- package/skill-evals/fixtures/timeline-release/input.mmd +0 -6
- package/skill-evals/fixtures/xychart-growth/input.mmd +0 -5
- package/skill-evals/shared-benchmark.json +0 -510
- package/src/agent/analyze.ts +0 -157
- package/src/agent/apply.ts +0 -146
- package/src/agent/architecture-body.ts +0 -458
- package/src/agent/certificates.ts +0 -110
- package/src/agent/class-body.ts +0 -319
- package/src/agent/core.ts +0 -207
- package/src/agent/create.ts +0 -106
- package/src/agent/describe.ts +0 -368
- package/src/agent/er-body.ts +0 -224
- package/src/agent/facts.ts +0 -360
- package/src/agent/families-builtin.ts +0 -920
- package/src/agent/families.ts +0 -232
- package/src/agent/family-layouts.ts +0 -832
- package/src/agent/flowchart-body.ts +0 -372
- package/src/agent/flowchart-unsupported.ts +0 -243
- package/src/agent/font-coverage.ts +0 -288
- package/src/agent/gantt-body.ts +0 -495
- package/src/agent/index.ts +0 -10
- package/src/agent/journey-body.ts +0 -374
- package/src/agent/label-metrics.ts +0 -28
- package/src/agent/layout-to-rendered.ts +0 -63
- package/src/agent/mutate.ts +0 -97
- package/src/agent/mutation-ops.ts +0 -51
- package/src/agent/op-schema.ts +0 -443
- package/src/agent/parse.ts +0 -223
- package/src/agent/pie-body.ts +0 -270
- package/src/agent/png.ts +0 -171
- package/src/agent/quadrant-body.ts +0 -336
- package/src/agent/quality.ts +0 -363
- package/src/agent/readability-audit.ts +0 -92
- package/src/agent/rendered-route-audit.ts +0 -61
- package/src/agent/sequence-body.ts +0 -345
- package/src/agent/serialize.ts +0 -214
- package/src/agent/state-body.ts +0 -589
- package/src/agent/structural-count.ts +0 -150
- package/src/agent/timeline-body.ts +0 -280
- package/src/agent/trace-log.ts +0 -43
- package/src/agent/types.ts +0 -995
- package/src/agent/verify.ts +0 -603
- package/src/agent/xychart-body.ts +0 -472
- package/src/architecture/config.ts +0 -282
- package/src/architecture/layout.ts +0 -496
- package/src/architecture/parser.ts +0 -375
- package/src/architecture/renderer.ts +0 -611
- package/src/architecture/types.ts +0 -113
- package/src/ascii/ansi.ts +0 -423
- package/src/ascii/architecture.ts +0 -210
- package/src/ascii/canvas.ts +0 -443
- package/src/ascii/class-diagram.ts +0 -697
- package/src/ascii/converter.ts +0 -475
- package/src/ascii/draw.ts +0 -1693
- package/src/ascii/edge-bundling.ts +0 -328
- package/src/ascii/edge-routing.ts +0 -330
- package/src/ascii/er-diagram.ts +0 -439
- package/src/ascii/gantt.ts +0 -276
- package/src/ascii/grid.ts +0 -747
- package/src/ascii/index.ts +0 -196
- package/src/ascii/journey.ts +0 -169
- package/src/ascii/meta.ts +0 -244
- package/src/ascii/multiline-utils.ts +0 -80
- package/src/ascii/pathfinder.ts +0 -301
- package/src/ascii/pie.ts +0 -67
- package/src/ascii/quadrant.ts +0 -158
- package/src/ascii/reverse.ts +0 -216
- package/src/ascii/sequence.ts +0 -499
- package/src/ascii/shapes/circle.ts +0 -27
- package/src/ascii/shapes/corners.ts +0 -143
- package/src/ascii/shapes/diamond.ts +0 -27
- package/src/ascii/shapes/hexagon.ts +0 -27
- package/src/ascii/shapes/index.ts +0 -106
- package/src/ascii/shapes/rectangle.ts +0 -168
- package/src/ascii/shapes/rounded.ts +0 -27
- package/src/ascii/shapes/special.ts +0 -332
- package/src/ascii/shapes/stadium.ts +0 -110
- package/src/ascii/shapes/state.ts +0 -192
- package/src/ascii/shapes/types.ts +0 -73
- package/src/ascii/timeline.ts +0 -141
- package/src/ascii/types.ts +0 -312
- package/src/ascii/validate.ts +0 -120
- package/src/ascii/width.ts +0 -81
- package/src/ascii/wrap.ts +0 -131
- package/src/ascii/xychart.ts +0 -919
- package/src/browser.ts +0 -29
- package/src/class/layout.ts +0 -240
- package/src/class/parser.ts +0 -332
- package/src/class/renderer.ts +0 -638
- package/src/class/types.ts +0 -129
- package/src/cli/agent-instructions.ts +0 -1
- package/src/cli/am-bin.ts +0 -6
- package/src/cli/exit-codes.ts +0 -18
- package/src/cli/index.ts +0 -1132
- package/src/cli/init-agent.ts +0 -147
- package/src/cli/run-entrypoint.ts +0 -10
- package/src/color-resolver.ts +0 -152
- package/src/elk-instance.ts +0 -114
- package/src/er/layout.ts +0 -187
- package/src/er/parser.ts +0 -226
- package/src/er/renderer.ts +0 -792
- package/src/er/types.ts +0 -99
- package/src/family-rubric.ts +0 -425
- package/src/font-manifest.ts +0 -31
- package/src/gantt/layout.ts +0 -365
- package/src/gantt/parser.ts +0 -282
- package/src/gantt/pipeline.ts +0 -27
- package/src/gantt/renderer.ts +0 -414
- package/src/gantt/schedule.ts +0 -513
- package/src/gantt/types.ts +0 -255
- package/src/index.ts +0 -368
- package/src/journey/layout.ts +0 -554
- package/src/journey/parse-core.ts +0 -251
- package/src/journey/parser.ts +0 -101
- package/src/journey/renderer.ts +0 -917
- package/src/journey/types.ts +0 -144
- package/src/layout/geometry.ts +0 -182
- package/src/layout/pass.ts +0 -142
- package/src/layout/passes/index.ts +0 -3916
- package/src/layout-engine.ts +0 -1565
- package/src/layout-rubric.ts +0 -659
- package/src/mcp/artifacts.ts +0 -137
- package/src/mcp/dynamic-harness.ts +0 -31
- package/src/mcp/dynamic-modules.d.ts +0 -7
- package/src/mcp/facade.ts +0 -608
- package/src/mcp/harness-runtime.ts +0 -203
- package/src/mcp/hosted-server.ts +0 -468
- package/src/mcp/mcp-bin.ts +0 -3
- package/src/mcp/mcp-cli.ts +0 -82
- package/src/mcp/protocol.ts +0 -13
- package/src/mcp/sandbox.ts +0 -195
- package/src/mcp/sdk-decl.ts +0 -391
- package/src/mcp/server.ts +0 -362
- package/src/mcp/tool-surface.ts +0 -146
- package/src/mermaid-source.ts +0 -655
- package/src/multiline-utils.ts +0 -228
- package/src/parser.ts +0 -1031
- package/src/pie/layout.ts +0 -168
- package/src/pie/parser.ts +0 -136
- package/src/pie/renderer.ts +0 -234
- package/src/pie/types.ts +0 -82
- package/src/quadrant/layout.ts +0 -191
- package/src/quadrant/parser.ts +0 -183
- package/src/quadrant/renderer.ts +0 -322
- package/src/quadrant/types.ts +0 -113
- package/src/render-family-hooks.ts +0 -244
- package/src/renderer.ts +0 -1099
- package/src/route-contracts.ts +0 -2723
- package/src/scene/backend.ts +0 -76
- package/src/scene/fidelity.ts +0 -183
- package/src/scene/hybrid-backend.ts +0 -174
- package/src/scene/ir.ts +0 -181
- package/src/scene/marks.ts +0 -127
- package/src/scene/rough-backend.ts +0 -378
- package/src/scene/seed.ts +0 -46
- package/src/scene/style-registry.ts +0 -556
- package/src/sequence/layout.ts +0 -456
- package/src/sequence/parser.ts +0 -255
- package/src/sequence/renderer.ts +0 -604
- package/src/sequence/types.ts +0 -154
- package/src/shape-clipping.ts +0 -351
- package/src/shared/accessibility-directives.ts +0 -22
- package/src/shared/batched.ts +0 -61
- package/src/shared/color-math.ts +0 -93
- package/src/shared/svg-a11y.ts +0 -29
- package/src/shared/syntax-error.ts +0 -17
- package/src/shared/unicode-ranges.ts +0 -135
- package/src/styles.ts +0 -318
- package/src/svg-paths.ts +0 -28
- package/src/text-metrics.ts +0 -248
- package/src/theme.ts +0 -710
- package/src/timeline/layout.ts +0 -381
- package/src/timeline/parser.ts +0 -215
- package/src/timeline/renderer.ts +0 -538
- package/src/timeline/types.ts +0 -105
- package/src/types.ts +0 -462
- package/src/website-worker-modules.d.ts +0 -18
- package/src/xychart/axis-utils.ts +0 -109
- package/src/xychart/colors.ts +0 -124
- package/src/xychart/config.ts +0 -88
- package/src/xychart/layout.ts +0 -656
- package/src/xychart/parser.ts +0 -504
- package/src/xychart/renderer.ts +0 -640
- package/src/xychart/types.ts +0 -282
package/docs/features.md
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
# Features — capability inventory
|
|
2
|
-
|
|
3
|
-
What Agentic Mermaid can do, organized by capability area. The npm import paths are `agentic-mermaid` and `agentic-mermaid/agent`; implementation history lives in [`project/divergences.md`](./project/divergences.md); active backlog is only [`../TODO.md`](../TODO.md).
|
|
4
|
-
|
|
5
|
-
## Core IR & editing loop
|
|
6
|
-
|
|
7
|
-
- **Typed `ValidDiagram` IR** — parse Mermaid into a sealed, typed value.
|
|
8
|
-
- **`parseMermaid(source)`** → `Result<ValidDiagram, ParseError[]>`. Never
|
|
9
|
-
throws on malformed input; structured errors.
|
|
10
|
-
- **`mutate(d, op)`** — family-overloaded typed mutation. Ops per family:
|
|
11
|
-
flowchart (6), state (8), sequence (5), timeline (10), class (10), ER (7),
|
|
12
|
-
journey (10), architecture (10), xychart (8), pie (7), quadrant (7), gantt (9).
|
|
13
|
-
- **`verifyMermaid(d, opts)`** — structural verification (no pixels).
|
|
14
|
-
- **`serializeMermaid(d)`** — back to canonical source.
|
|
15
|
-
- **Round-trip** — structured bodies serialize to canonical, idempotent
|
|
16
|
-
source; opaque bodies preserve original indentation/comments verbatim.
|
|
17
|
-
- **Narrowers** — `asFlowchart`/`asState`/`asSequence`/`asTimeline`/`asClass`/`asEr`/
|
|
18
|
-
`asJourney`/`asArchitecture`/`asXyChart`/`asPie`/`asQuadrant`/`asGantt`
|
|
19
|
-
return `null` on a non-matching or source-level/opaque body (steers agents
|
|
20
|
-
off the unsafe path).
|
|
21
|
-
|
|
22
|
-
## Diagram families (12)
|
|
23
|
-
|
|
24
|
-
| Family | Parse/render/round-trip | Structured mutation |
|
|
25
|
-
|---|---|---|
|
|
26
|
-
| Flowchart | ✅ | ✅ (6 ops) |
|
|
27
|
-
| State | ✅ | ✅ (8 ops via `asState`; `<<fork>>`/notes/`--`/`classDef` → opaque) |
|
|
28
|
-
| Sequence | ✅ | ✅ (5 ops; alt/loop/note ride along verbatim as segments) |
|
|
29
|
-
| Timeline | ✅ | ✅ (10 ops) |
|
|
30
|
-
| Class | ✅ | ✅ (10 ops) |
|
|
31
|
-
| ER | ✅ | ✅ (7 ops) |
|
|
32
|
-
| Journey | ✅ | ✅ (10 ops via `asJourney`) |
|
|
33
|
-
| XY chart | ✅ | ✅ (8 ops via `asXyChart`) |
|
|
34
|
-
| Architecture | ✅ | ✅ (10 ops via `asArchitecture`) |
|
|
35
|
-
| Pie | ✅ | ✅ (7 ops via `asPie`) |
|
|
36
|
-
| Quadrant | ✅ | ✅ (7 ops via `asQuadrant`) |
|
|
37
|
-
| Gantt | ✅ | ✅ (9 ops via `asGantt`; calendar directives/click/comments ride along verbatim as segments) |
|
|
38
|
-
|
|
39
|
-
**Structured-or-opaque rule:** every family either has a structured body
|
|
40
|
-
or preserves source verbatim. Constructs are never silently dropped.
|
|
41
|
-
|
|
42
|
-
## Output formats
|
|
43
|
-
|
|
44
|
-
Agentic Mermaid outputs **SVG, PNG, ASCII, Unicode, and JSON layout** from the same renderer foundation.
|
|
45
|
-
|
|
46
|
-
- **Styles** — every SVG/PNG render accepts `style`: a full look
|
|
47
|
-
(`hand-drawn`, `excalidraw`, `pen-and-ink`, `freehand`, `watercolor`,
|
|
48
|
-
`blueprint`, `tufte`, `accessible-high-contrast`, `patent-drawing`,
|
|
49
|
-
`status-dashboard`, `ops-schematic`, `chalkboard`, `risograph`,
|
|
50
|
-
`architectural-plan`, `publication-figure`), any theme name (a theme is a
|
|
51
|
-
palette-only style), an inline JSON record, or a stack merged left → right
|
|
52
|
-
(`{ style: ['hand-drawn', 'dracula'] }`). `seed` re-rolls styled ink and
|
|
53
|
-
never moves layout. CLI: `am render --style … --seed N`, `am styles`;
|
|
54
|
-
MCP render tools take `style`/`seed`; RENDER_FAILED-gated verify means a
|
|
55
|
-
clean verify proves the styled source renders. Authoring guide, schema, and
|
|
56
|
-
cookbook: `docs/style-authoring.md`, `docs/schemas/style-spec.schema.json`,
|
|
57
|
-
and `docs/custom-style-cookbook.md`.
|
|
58
|
-
|
|
59
|
-
- **SVG** — `renderMermaidSVG` (`compact`, `security:'strict'`, CSS
|
|
60
|
-
variable fonts, `idPrefix` namespacing). CLI exposes `--security strict`.
|
|
61
|
-
- **ASCII / Unicode** — `renderMermaidASCII` (CJK/emoji width, FE0F/ZWJ,
|
|
62
|
-
`maxWidth` wrapping, trunk-shared fanouts).
|
|
63
|
-
- **PNG** — `renderMermaidPNG(source, { fitTo, background, style, seed, fontDirs, loadSystemFonts, onWarning })` or `am render diagram.mmd --format png --output diagram.png` (offline `@resvg/resvg-js`; bundled Inter — the metrics font — with DejaVu fallback plus the built-in style faces,
|
|
64
|
-
cross-runtime deterministic on same-machine x86_64/ARM64 where Node + built `dist/` are present). Characters without bundled coverage (CJK, emoji) warn loudly; supply `--font-dirs <dir>` / `fontDirs` or `--system-fonts` / `loadSystemFonts: true`.
|
|
65
|
-
- **JSON layout** — `layoutMermaid` / `am render --format json`; add `--certificates` (or `layoutMermaid(d, { debug: true })`) to include opt-in graph route certificates, family edge-route certificates (class/ER/architecture/sequence), region-containment certificates (timeline/charts), V1 region/action sidecars, exact ports, and side/slot/role assignments where applicable.
|
|
66
|
-
- **ASCII with metadata** — `renderMermaidASCIIWithMeta` → `{ ascii, regions, warnings, routeParity }`
|
|
67
|
-
for TUI click-mapping.
|
|
68
|
-
- **Reverse** — `asciiToMermaid` reconstructs flowchart source from ASCII
|
|
69
|
-
(best-effort, lossy, structural round-trip).
|
|
70
|
-
|
|
71
|
-
## Verification tiers
|
|
72
|
-
|
|
73
|
-
- **Tier 1 (structural, universal):** EMPTY_DIAGRAM, EDGE_MISANCHORED,
|
|
74
|
-
OFF_CANVAS, GROUP_BREACH, UNKNOWN_SHAPE, LABEL_OVERFLOW, UNRESOLVABLE_SCHEDULE,
|
|
75
|
-
RENDER_FAILED (a clean verify proves the source actually renders).
|
|
76
|
-
- **Tier 2 (geometric — route tripwires for flowchart/state, anchor/overlap checks for class/ER):** NODE_OVERLAP, ROUTE_SELF_CROSS, and the route-contract tripwires ROUTE_HITCH, ROUTE_UNEXPLAINED_BEND, ROUTE_LABEL_ON_SHARED_TRUNK, ROUTE_CONTAINER_MISANCHOR, ROUTE_SHAPE_MISANCHOR, ROUTE_STALE_AFTER_NODE_MOVE.
|
|
77
|
-
- **Tier 3 (lint, advisory):** DUPLICATE_EDGE, UNREACHABLE_NODE, DECISION_BRANCH_UNLABELED, COMMENT_DROPPED, UNSUPPORTED_SYNTAX, CONTENT_DROPPED_ON_ROUNDTRIP, INEFFECTIVE_CONFIG.
|
|
78
|
-
- **Perceptual quality** — `measureQuality` / `checkQuality` (edge
|
|
79
|
-
crossings, label legibility, whitespace balance, …). See [`quality.md`](./quality.md).
|
|
80
|
-
|
|
81
|
-
## Accessibility
|
|
82
|
-
|
|
83
|
-
- `accTitle`→`<title>`, `accDescr`→`<desc>`, `role="img"`, `aria-labelledby`.
|
|
84
|
-
- **AX tree** — `describeMermaid(d, {format:'json'})` → `{nodes, edges,
|
|
85
|
-
entryPoints, sinks}`; prose summary in `{format:'text'}`.
|
|
86
|
-
- Auto-contrast node text on custom fills (WCAG luminance).
|
|
87
|
-
- External CSS class emission (Mermaid `classDef` assignments → SVG classes).
|
|
88
|
-
|
|
89
|
-
## Security
|
|
90
|
-
|
|
91
|
-
- **Strict mode** (`security:'strict'`) — zero external-fetch references in
|
|
92
|
-
the SVG (no Google Fonts `@import`).
|
|
93
|
-
- **`verifyNoExternalRefs(svg)`** — scanner / CI gate / agent self-check.
|
|
94
|
-
- No `<image>`/`<script>`/external-href injection; click directives
|
|
95
|
-
sanitized. See [`../SECURITY.md`](../SECURITY.md).
|
|
96
|
-
|
|
97
|
-
## CLI (`am`)
|
|
98
|
-
|
|
99
|
-
`render` (svg/ascii/unicode/json with multi-input results; png uses one
|
|
100
|
-
input plus `--output`; `--security strict`, `--watch`), `render-markdown` (skip bad blocks),
|
|
101
|
-
`parse`, `verify`, `mutate` (`--op` or `--ops`), `preview` (strict standalone HTML + optional `--open`), `format`, `describe` (text/json),
|
|
102
|
-
`capabilities --json` (including `families[].editPolicy` + `families[].mutationOps`), `batch --jsonl` (including mutate),
|
|
103
|
-
`llms-txt`, `init-agent`, `--agent-instructions`. `mutate` verifies before emitting source; `init-agent` writes a non-clobbering `AGENTS.md` section, root `skills/` bundle, and `.mcp.json` sample into a consumer repo.
|
|
104
|
-
Exit codes 0/2/3/4; parse and verify-failure errors include structured `error.details` arrays.
|
|
105
|
-
|
|
106
|
-
## MCP server
|
|
107
|
-
|
|
108
|
-
Local `agentic-mermaid-mcp` is Code Mode-first: `execute(code)` runs synchronous
|
|
109
|
-
JavaScript in a local `node:vm` sandbox with a typed `mermaid.*` SDK declaration,
|
|
110
|
-
plus narrow `render_png` and `describe` helpers. It supports stdio by default and
|
|
111
|
-
HTTP/SSE via `agentic-mermaid-mcp --transport http`; local `render_png` can
|
|
112
|
-
return base64 bytes or managed file/URL artifacts with MIME type, byte count, and
|
|
113
|
-
SHA-256 metadata.
|
|
114
|
-
|
|
115
|
-
The hosted endpoint at `https://agentic-mermaid.dev/mcp` is stateless
|
|
116
|
-
Streamable HTTP. It exposes eight bounded MCP JSON-RPC tools: `execute` in a
|
|
117
|
-
Cloudflare Dynamic Worker isolate, pure `render_svg` / `render_ascii` /
|
|
118
|
-
`render_png` / `verify` / `describe`, and declarative `mutate` / `build` for
|
|
119
|
-
structured edits. Hosted inputs are capped at 64 KB, PNG is base64-only, and the
|
|
120
|
-
endpoint is a convenience surface rather than a REST render API.
|
|
121
|
-
|
|
122
|
-
## Distribution
|
|
123
|
-
|
|
124
|
-
- npm library (`agentic-mermaid` plus the `agentic-mermaid/agent` subpath) with Node-runnable bins (`am`, `agentic-mermaid`, `agentic-mermaid-mcp`).
|
|
125
|
-
- **Single binary** — `bun run build:binary` → `dist/am`, standalone
|
|
126
|
-
executable, no runtime dependency (#1018).
|
|
127
|
-
- **llms.txt** agent-discovery digest, derived from capabilities.
|
|
128
|
-
|
|
129
|
-
## Guarantees & evidence
|
|
130
|
-
|
|
131
|
-
- **Determinism** — byte-identical across repeated runs and processes for
|
|
132
|
-
SVG layout/ASCII; full-corpus ASCII repeated-run guard; cross-runtime guards
|
|
133
|
-
exist for bun ≡ node on same-machine x86_64/ARM64 when Node + built `dist/`
|
|
134
|
-
artifacts are present.
|
|
135
|
-
- **Corpus gates** — 271-entry mermaid-js docs corpus + 132-case
|
|
136
|
-
MermaidSeqBench, gated in CI.
|
|
137
|
-
- **Benchmarks** — `eval/benchmark/RESULTS.md` (measured vs mmdc, termaid).
|
|
138
|
-
- **Agent-usage validation** — `eval/agent-usage/` scenarios,
|
|
139
|
-
anti-pattern linter, sandbox trace instrumentation, and stored Code Mode eval runner.
|
|
140
|
-
- **Unit, browser/e2e, typecheck, build, binary-build, eval, and lint gates**
|
|
141
|
-
are part of the verification contract.
|
|
142
|
-
|
|
143
|
-
## Not browser-dependent
|
|
144
|
-
|
|
145
|
-
The entire core (parse/verify/mutate/serialize/ASCII/PNG/SVG) runs with no
|
|
146
|
-
DOM, no headless browser, synchronously. This is the structural
|
|
147
|
-
differentiator vs Puppeteer-based Mermaid CLIs.
|
package/docs/fork-differences.md
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# What is different about this fork?
|
|
2
|
-
|
|
3
|
-
This document describes **Agentic Mermaid**, the `adewale/agentic-mermaid` fork, relative to upstream `lukilabs/beautiful-mermaid`. It is intentionally product/documentation focused; upstreamable changes should still be split into small PRs.
|
|
4
|
-
|
|
5
|
-
## Live site
|
|
6
|
-
|
|
7
|
-
The canonical live site is **[agentic-mermaid.dev](https://agentic-mermaid.dev/)** — a Cloudflare Workers Static Assets deployment built from [`website/`](../website):
|
|
8
|
-
|
|
9
|
-
- Home & docs: <https://agentic-mermaid.dev/>
|
|
10
|
-
- Live editor: <https://agentic-mermaid.dev/editor>
|
|
11
|
-
- Family comparisons (Mermaid vs Beautiful Mermaid vs Agentic Mermaid): <https://agentic-mermaid.dev/comparisons/>
|
|
12
|
-
|
|
13
|
-
Alongside the static surface (the public website, machine-readable manifests, schemas, recipes, and skill files), the Cloudflare Worker serves a stateless hosted MCP endpoint at `/mcp` (`https://agentic-mermaid.dev/mcp`) — eight tools: Code Mode `execute` in per-request Dynamic Worker isolates, the `render_svg`/`render_ascii`/`render_png`/`verify`/`describe` pure tools, and the declarative `mutate`/`build` structured-edit tools. There is still no REST render API: `/mcp` speaks MCP JSON-RPC only.
|
|
14
|
-
|
|
15
|
-
GitHub Pages is no longer a deployed surface; its samples-gallery generator has been retired. The live editor is served at [agentic-mermaid.dev/editor](https://agentic-mermaid.dev/editor) and built by `scripts/site/editor.ts` (also used by `website/build.ts`), and is exercised in a real browser by `e2e/browser.test.ts`.
|
|
16
|
-
|
|
17
|
-
## Agent-native workflow (largest fork-vs-upstream gap)
|
|
18
|
-
|
|
19
|
-
Agentic Mermaid is published as `agentic-mermaid` and adds a typed editing surface for AI agents under the `agentic-mermaid/agent` subpath export, plus an `am` CLI and an `agentic-mermaid-mcp` Code Mode MCP server (stdio plus opt-in HTTP/SSE transport with managed render artifacts). A render-only library forces an agent to regenerate the whole diagram to change one node; here, new diagrams are authored as source then parsed/verified/rendered, while existing structured diagrams go parse → narrow → mutate → verify → serialize.
|
|
20
|
-
|
|
21
|
-
Twelve of the twelve families are structured-when-narrowed: flowchart (6 ops), state (8 ops via a dedicated `StateBody` and `asState`), sequence (5 ops, **segment-preserving** — notes/`alt`/`loop` blocks ride along verbatim while the ops stay live), timeline (10), class (10), ER (7), journey (14, including move_task/move_section ordering and accessibility-metadata ops), XY chart (8), architecture (10), pie (7 via `asPie`), quadrant (7 via `asQuadrant`), and Gantt (9 via `asGantt`). Any unmodeled syntax still round-trips losslessly via preserved source (opaque fallback). Layout is deterministic and verified byte-identical across processes, and `verifyMermaid` returns structured warnings in three tiers (structural, geometric, lint) plus perceptual quality metrics (`measureQuality`) covering every family. See [`AGENT_NATIVE.md`](../AGENT_NATIVE.md) and [`Instructions_for_agents.md`](../Instructions_for_agents.md). Upstream has no equivalent; for a three-way functionality view including Mermaid itself, see [`comparison.md`](./comparison.md).
|
|
22
|
-
|
|
23
|
-
## New and expanded diagram support
|
|
24
|
-
|
|
25
|
-
This fork renders a wider set of Mermaid families in both the gallery and editor:
|
|
26
|
-
|
|
27
|
-
- Flowcharts and state diagrams
|
|
28
|
-
- Architecture diagrams (`architecture-beta`)
|
|
29
|
-
- Sequence diagrams
|
|
30
|
-
- Class diagrams
|
|
31
|
-
- ER diagrams
|
|
32
|
-
- Timeline diagrams (`timeline`)
|
|
33
|
-
- User Journey diagrams (`journey`)
|
|
34
|
-
- XY charts (`xychart` and `xychart-beta`)
|
|
35
|
-
- Pie charts (`pie`, with `showData`)
|
|
36
|
-
- Quadrant charts (`quadrantChart`) — not yet rendered anywhere else in the beautiful-mermaid network
|
|
37
|
-
- Gantt charts (`gantt`) with date axes, sections, dependencies, milestones, exclusions, and vertical markers
|
|
38
|
-
|
|
39
|
-
The live editor has registry-backed example coverage for every built-in family
|
|
40
|
-
(`src/__tests__/editor-examples.test.ts`). Browser E2E still spot-checks several
|
|
41
|
-
fork-added rendering paths: architecture, timeline, journey, and xychart.
|
|
42
|
-
|
|
43
|
-
## Style + Palette SVG rendering
|
|
44
|
-
|
|
45
|
-
The fork adds a consistent Style + Palette API across diagram families:
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
renderMermaidSVG(source, {
|
|
49
|
-
style: ['publication-figure', 'github-light'],
|
|
50
|
-
seed: 2,
|
|
51
|
-
})
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
A style chooses the renderer treatment — for example `hand-drawn`, `watercolor`, `publication-figure`, or `ops-schematic`. A palette-only style chooses colors — for example `github-light`, `dracula`, or a custom JSON record with `colors`. Stacks merge left to right, so agents can keep visual requests out of Mermaid source while preserving deterministic geometry.
|
|
55
|
-
|
|
56
|
-
## Mermaid config and source wrappers
|
|
57
|
-
|
|
58
|
-
This fork supports Mermaid-style source wrappers before diagram headers, including:
|
|
59
|
-
|
|
60
|
-
- YAML frontmatter
|
|
61
|
-
- `%%{init: ...}%%` directives
|
|
62
|
-
- `%%{initialize: ...}%%` directives
|
|
63
|
-
- Mermaid comments before the header
|
|
64
|
-
|
|
65
|
-
These are merged with `options.mermaidConfig` where supported. XY chart and architecture rendering use this to honor Mermaid-compatible theme/config fields.
|
|
66
|
-
|
|
67
|
-
## Showcase and editor discovery
|
|
68
|
-
|
|
69
|
-
Users can discover fork features through:
|
|
70
|
-
|
|
71
|
-
1. The [examples page](https://agentic-mermaid.dev/examples/), including supported families, Style + Palette combinations, and the richer shared examples corpus.
|
|
72
|
-
2. The [live editor](https://agentic-mermaid.dev/editor), which starts with examples for every supported diagram family.
|
|
73
|
-
3. [`README.md`](../README.md) quick starts and docs routing.
|
|
74
|
-
4. [`CHANGELOG.md`](../CHANGELOG.md) for user-facing change history.
|
|
75
|
-
|
|
76
|
-
## Layout and quality work
|
|
77
|
-
|
|
78
|
-
- A layout before/after comparison harness (`eval/layout-compare/`) and per-family `RenderedLayout` adapters so perceptual metrics gate layout changes with evidence. Debug JSON can also expose opt-in graph route certificates, family edge-route certificates, region-containment certificates, and region/action sidecars for tooling; default JSON stays compact.
|
|
79
|
-
- Still different from the current upstream release (Beautiful Mermaid 1.1.3): decision-branch routing emits a diamond's branches from facet-mid ports as mirror-symmetric routes (the layout symmetry floor), and an edge to a subgraph attaches to its container with `direction` overrides honored inside it — a case upstream 1.1.3 still mis-routes (`mermaid-js/mermaid#2509` leaves it unsolved). Both are shown side by side on the [differences page](https://agentic-mermaid.dev/comparisons/).
|
|
80
|
-
- Already upstreamed: fan-in grouping (upstream #68/#69) and labeled fan-out trunk sharing with box-start connector placement (#111/#112/#113, upstream PR #113) landed here first and now render identically in Beautiful Mermaid 1.1.3 — they are no longer fork-only.
|
|
81
|
-
- ER cardinality parsing matches Mermaid's lexer exactly; malformed relationship lines error loudly instead of being silently dropped.
|
|
82
|
-
|
|
83
|
-
## Parser and semantic divergences from Mermaid.js
|
|
84
|
-
|
|
85
|
-
- **Subgraph membership is *first-defined-wins*.** A node belongs to the subgraph
|
|
86
|
-
where it is **first defined**, and a top-level reference counts as a definition —
|
|
87
|
-
so a node referenced at the top level and then listed inside a subgraph block
|
|
88
|
-
stays at the top level. Mermaid.js instead lets the subgraph *block* claim any
|
|
89
|
-
node it lists, regardless of a prior top-level reference. In the canonical Mermaid
|
|
90
|
-
docs example:
|
|
91
|
-
|
|
92
|
-
```mermaid
|
|
93
|
-
flowchart TB
|
|
94
|
-
c1-->a2
|
|
95
|
-
subgraph one
|
|
96
|
-
a1-->a2
|
|
97
|
-
end
|
|
98
|
-
subgraph two
|
|
99
|
-
b1-->b2
|
|
100
|
-
end
|
|
101
|
-
subgraph three
|
|
102
|
-
c1-->c2
|
|
103
|
-
end
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
Mermaid.js places `a2` inside `one` and `c1` inside `three`; this fork keeps `a2`
|
|
107
|
-
and `c1` at the top level (only `a1`/`c2` are inside those subgraphs). See it both
|
|
108
|
-
ways: [open in Mermaid Live](https://mermaid.live/edit#pako:eNp10DELwjAQBeC_Et7cDjpmcBBXJ50kyzW5NoU2V9KEIqX_XbSoRXB87z44eDOsOIZG3clkPcWkrkcTlFLK7sryQPs1jLlqIg1eSeC1oe2Zg_txaZK1qZ6u-u98ZN48tF-JAj3HnloHjdkgee7ZQBs4ril3yWBBAcpJLvdgoVPMXCBKbjx0Td3IBfLgKPGppSZS_yYDhZvIJ7Jrk8TzOsRrj-UBwvBYkQ)
|
|
109
|
-
· [open in the fork editor](https://agentic-mermaid.dev/editor#eyJzb3VyY2UiOiJmbG93Y2hhcnQgVEJcbiAgICBjMS0tPmEyXG4gICAgc3ViZ3JhcGggb25lXG4gICAgYTEtLT5hMlxuICAgIGVuZFxuICAgIHN1YmdyYXBoIHR3b1xuICAgIGIxLS0+YjJcbiAgICBlbmRcbiAgICBzdWJncmFwaCB0aHJlZVxuICAgIGMxLS0+YzJcbiAgICBlbmQifQ==).
|
|
110
|
-
|
|
111
|
-
This is a deliberate divergence, not a bug: it gives deterministic
|
|
112
|
-
*definition-scope* membership with no surprising re-parenting when a node is
|
|
113
|
-
mentioned again inside a container, consistent with the fork's goal of
|
|
114
|
-
predictable, source-preserving behavior rather than Mermaid pixel/layout parity
|
|
115
|
-
(see [#38](https://github.com/adewale/agentic-mermaid/issues/38)). Mermaid's own
|
|
116
|
-
users report *its* behavior as a bug (`mermaid-js/mermaid#738`, `#2707`). The rule
|
|
117
|
-
is inherited from upstream Beautiful Mermaid (introduced in its v1.0.0 rewrite),
|
|
118
|
-
not fork-invented, and is guarded by `src/__tests__/parser.test.ts` — a node
|
|
119
|
-
genuinely defined inside one subgraph and later referenced inside another
|
|
120
|
-
likewise stays in its first subgraph (it is never re-parented by a mere
|
|
121
|
-
reference).
|
|
122
|
-
|
|
123
|
-
## What is intentionally not in this fork
|
|
124
|
-
|
|
125
|
-
- No committed `dist/` artifacts.
|
|
126
|
-
- No large bundled upstream PR: upstream contributions should remain focused and independently reviewable.
|
|
127
|
-
|
|
128
|
-
## Upstreaming strategy
|
|
129
|
-
|
|
130
|
-
The fork should continue extracting small upstreamable PRs from broad fork work. This file is not the backlog: parked fork-port ideas live only under `PARK-3` in `TODO.md` until one is promoted to a focused issue.
|
package/docs/getting-started.md
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Getting started (library)
|
|
2
|
-
|
|
3
|
-
A 5-minute guide for using `agentic-mermaid` as a plain rendering library: turn a
|
|
4
|
-
Mermaid string into **SVG**, **PNG**, or **ASCII/Unicode**. No agents, no server,
|
|
5
|
-
no browser — every function below runs synchronously in Node, Bun, or the browser.
|
|
6
|
-
|
|
7
|
-
> Editing diagrams with the typed parse → mutate → verify → serialize API is a
|
|
8
|
-
> separate surface — see the [agent API cookbook](./agent-api-cookbook.md). You do
|
|
9
|
-
> not need any of that just to render.
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install agentic-mermaid
|
|
15
|
-
# or: bun add agentic-mermaid / pnpm add agentic-mermaid
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
For repository development, install from source:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
git clone https://github.com/adewale/agentic-mermaid
|
|
22
|
-
cd agentic-mermaid && bun install && bun run build
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Render to SVG
|
|
26
|
-
|
|
27
|
-
`renderMermaidSVG` takes Mermaid source and returns a self-contained SVG string.
|
|
28
|
-
It supports all 12 diagram families (flowchart, sequence, class, ER, state, gantt,
|
|
29
|
-
pie, …) — just pass the source.
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import { renderMermaidSVG } from 'agentic-mermaid'
|
|
33
|
-
|
|
34
|
-
const svg = renderMermaidSVG(`flowchart TD
|
|
35
|
-
Start --> Stop`)
|
|
36
|
-
|
|
37
|
-
console.log(svg) // "<svg ...>...</svg>"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Write it to a file in Node/Bun:
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
import { writeFileSync } from 'node:fs'
|
|
44
|
-
import { renderMermaidSVG } from 'agentic-mermaid'
|
|
45
|
-
|
|
46
|
-
writeFileSync('diagram.svg', renderMermaidSVG('flowchart LR\n A --> B --> C'))
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Render to PNG
|
|
50
|
-
|
|
51
|
-
PNG rendering uses a bundled native rasterizer, so `renderMermaidPNG` lives on the
|
|
52
|
-
`agentic-mermaid/agent` entry point. It returns a `Uint8Array` of PNG bytes.
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import { writeFileSync } from 'node:fs'
|
|
56
|
-
import { renderMermaidPNG } from 'agentic-mermaid/agent'
|
|
57
|
-
|
|
58
|
-
const png = renderMermaidPNG(`flowchart TD
|
|
59
|
-
Start --> Stop`, {
|
|
60
|
-
fitTo: { width: 1200 }, // constrain output width (optional)
|
|
61
|
-
background: '#ffffff', // PNG has no transparency by default
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
writeFileSync('diagram.png', png)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
`PngOptions`: `scale` (default `2`, for retina), `background`, and
|
|
68
|
-
`fitTo: { width?, height? }`.
|
|
69
|
-
|
|
70
|
-
## Render to ASCII / Unicode
|
|
71
|
-
|
|
72
|
-
Great for terminals, code reviews, and plain-text logs. Unicode box-drawing is the
|
|
73
|
-
default; pass `{ useAscii: true }` for pure ASCII.
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
import { renderMermaidASCII } from 'agentic-mermaid'
|
|
77
|
-
|
|
78
|
-
const unicode = renderMermaidASCII('flowchart LR\n A --> B')
|
|
79
|
-
const ascii = renderMermaidASCII('flowchart LR\n A --> B', { useAscii: true })
|
|
80
|
-
|
|
81
|
-
console.log(unicode)
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
See [`ascii.md`](./ascii.md) for supported families and cell-to-region metadata.
|
|
85
|
-
|
|
86
|
-
## Theming
|
|
87
|
-
|
|
88
|
-
Theme from two colors, or spread one of the 21 built-in themes. Colors are applied
|
|
89
|
-
as CSS variables, so the SVG stays self-contained.
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import { renderMermaidSVG, THEMES } from 'agentic-mermaid'
|
|
93
|
-
|
|
94
|
-
// Two-color theme
|
|
95
|
-
const dark = renderMermaidSVG('flowchart TD\n A --> B', {
|
|
96
|
-
bg: '#1a1b26',
|
|
97
|
-
fg: '#a9b1d6',
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
// A built-in theme (zinc-light, tokyo-night, nord, dracula, catppuccin-mocha, …)
|
|
101
|
-
const themed = renderMermaidSVG('flowchart TD\n A --> B', {
|
|
102
|
-
...THEMES['tokyo-night'],
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
// Transparent background, for embedding on any page
|
|
106
|
-
const transparent = renderMermaidSVG('flowchart TD\n A --> B', {
|
|
107
|
-
transparent: true,
|
|
108
|
-
})
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Common `RenderOptions`: `bg`, `fg`, `font`, `transparent`, and `security`. See
|
|
112
|
-
[`theming.md`](./theming.md) for custom themes and Shiki/VS Code theme import.
|
|
113
|
-
|
|
114
|
-
### Untrusted input
|
|
115
|
-
|
|
116
|
-
If the Mermaid source is not yours, render with `security: 'strict'`. It disables
|
|
117
|
-
the web-font `@import` and strips any external-fetch references from the output, so
|
|
118
|
-
the SVG cannot phone home.
|
|
119
|
-
|
|
120
|
-
```ts
|
|
121
|
-
import { renderMermaidSVG } from 'agentic-mermaid'
|
|
122
|
-
|
|
123
|
-
const safe = renderMermaidSVG(userProvidedSource, { security: 'strict' })
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## In the browser and in frameworks
|
|
127
|
-
|
|
128
|
-
`renderMermaidSVG` is synchronous and needs no DOM, so you can render during a
|
|
129
|
-
component's render pass and drop the string straight into the markup. In React,
|
|
130
|
-
memoize it to avoid re-rendering on every paint:
|
|
131
|
-
|
|
132
|
-
```tsx
|
|
133
|
-
import { useMemo } from 'react'
|
|
134
|
-
import { renderMermaidSVG } from 'agentic-mermaid'
|
|
135
|
-
|
|
136
|
-
function Diagram({ code }: { code: string }) {
|
|
137
|
-
const svg = useMemo(() => renderMermaidSVG(code), [code])
|
|
138
|
-
return <div dangerouslySetInnerHTML={{ __html: svg }} />
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
See [`react.md`](./react.md) for the zero-flash, live-theme-switching setup.
|
|
143
|
-
|
|
144
|
-
## Which import path?
|
|
145
|
-
|
|
146
|
-
| You want | Import from |
|
|
147
|
-
|---|---|
|
|
148
|
-
| SVG | `agentic-mermaid` |
|
|
149
|
-
| ASCII / Unicode | `agentic-mermaid` |
|
|
150
|
-
| PNG (native rasterizer) | `agentic-mermaid/agent` |
|
|
151
|
-
| Themes (`THEMES`, `fromShikiTheme`) | `agentic-mermaid` |
|
|
152
|
-
| Everything in one path | `agentic-mermaid/agent` |
|
|
153
|
-
| Typed editing (parse/mutate/verify) | `agentic-mermaid/agent` |
|
|
154
|
-
|
|
155
|
-
`agentic-mermaid/agent` re-exports the renderers too, so if you would rather use a
|
|
156
|
-
single import path for all formats, import everything from there.
|
|
157
|
-
|
|
158
|
-
## Prefer the command line?
|
|
159
|
-
|
|
160
|
-
The same renderers ship as the `am` CLI — no code required:
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
am render diagram.mmd --format svg
|
|
164
|
-
am render diagram.mmd --format png --output diagram.png
|
|
165
|
-
am render diagram.mmd --ascii
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Run `am --help` for the full command set.
|
|
169
|
-
|
|
170
|
-
## Next steps
|
|
171
|
-
|
|
172
|
-
- [`diagram-families.md`](./diagram-families.md) — every supported family with examples.
|
|
173
|
-
- [`theming.md`](./theming.md) — custom themes and Shiki import.
|
|
174
|
-
- [`api.md`](./api.md) — the full option and function reference.
|
|
175
|
-
- [`agent-api-cookbook.md`](./agent-api-cookbook.md) — typed editing (parse → mutate → verify → serialize).
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
# Issue-derived test-case candidates
|
|
2
|
-
|
|
3
|
-
These are public Mermaid / Beautiful Mermaid issues worth turning into small, educational fixtures. The goal is not to clone every upstream bug; it is to keep representative examples that teach the renderer/agent surface what users actually expect.
|
|
4
|
-
|
|
5
|
-
## Already covered or newly covered
|
|
6
|
-
|
|
7
|
-
- [mermaid-js/mermaid#5227 — Backwards arrows](https://github.com/mermaid-js/mermaid/issues/5227)
|
|
8
|
-
- Why it matters: feedback edges are common in auth/retry flows and should not scramble the primary left-to-right path.
|
|
9
|
-
- Current coverage: `src/__tests__/agent-auth-flow.test.ts` builds an auth flow through Agentic Mermaid mutations and asserts `C→B` / `F→E` route backwards while the primary LR path stays source-ordered.
|
|
10
|
-
- [mermaid-js/mermaid#7645 — block loading of external images](https://github.com/mermaid-js/mermaid/issues/7645)
|
|
11
|
-
- Why it matters: agent-generated diagrams are untrusted input.
|
|
12
|
-
- Current coverage: strict SVG/security tests assert external-fetch references are removed.
|
|
13
|
-
- [mermaid-js/mermaid#7695 — Trusted Types / CSP](https://github.com/mermaid-js/mermaid/issues/7695)
|
|
14
|
-
- Why it matters: generated SVG/HTML must be embeddable in locked-down apps.
|
|
15
|
-
- Current coverage: browser CSP/Trusted Types e2e exercises enforcement and strict render paths.
|
|
16
|
-
- [mermaid-js/mermaid#5632 — screen-reader/accessibility support](https://github.com/mermaid-js/mermaid/issues/5632)
|
|
17
|
-
- Why it matters: diagrams need non-visual summaries for users and agents.
|
|
18
|
-
- Current coverage: `am describe` / `describeMermaid(...,{format:'json'})` expose an AX-style tree and docs sync tests guard the surface.
|
|
19
|
-
- [lukilabs/beautiful-mermaid#119 — CJK label alignment](https://github.com/lukilabs/beautiful-mermaid/issues/119)
|
|
20
|
-
- Why it matters: ASCII renderers often break on fullwidth text.
|
|
21
|
-
- Current coverage: CJK width tests and ASCII rendering tests.
|
|
22
|
-
- [lukilabs/beautiful-mermaid#115 — text contrast on custom fills](https://github.com/lukilabs/beautiful-mermaid/issues/115)
|
|
23
|
-
- Why it matters: themeable diagrams must remain readable.
|
|
24
|
-
- Current coverage: auto-contrast and theme/renderer contrast tests.
|
|
25
|
-
- [lukilabs/beautiful-mermaid#111/#112 — ASCII fan-out trunks and box-start connectors](https://github.com/lukilabs/beautiful-mermaid/issues/111)
|
|
26
|
-
- Why it matters: sibling fan-outs should share a readable trunk and edge labels should stay on branches rather than forcing detours or floating connectors.
|
|
27
|
-
- Current coverage: `src/__tests__/ascii-pathfinder-trunk.test.ts` covers TD/LR labeled fan-out repros and bidirectional-label separation; `src/__tests__/ascii-box-start.test.ts` covers source-border connectors; ASCII determinism tests guard repeated routing stability; golden files pin exact ASCII/Unicode output.
|
|
28
|
-
- [lukilabs/beautiful-mermaid#69 — fan-in grouping](https://github.com/lukilabs/beautiful-mermaid/pull/69)
|
|
29
|
-
- Why it matters: unrelated fan-in groups should not cross into ambiguous shared trunks.
|
|
30
|
-
- Current coverage: `src/__tests__/ascii-fan-in-grouping.test.ts` covers target-aware grouping and cycle guards.
|
|
31
|
-
- [lukilabs/beautiful-mermaid#98 — nested-subgraph layout with direction](https://github.com/lukilabs/beautiful-mermaid/pull/98)
|
|
32
|
-
- Why it matters: subgraph direction overrides and container edges should not create phantom nodes or move children outside groups.
|
|
33
|
-
- Current coverage: `src/__tests__/subgraph-direction.test.ts` covers SVG geometry, ASCII one-row inner LR layout, subgraph-id edge attachment, 7-bit ASCII mode, nested child subgraph targets, styled/labeled container edges, and multi-edge containers; golden files pin exact ASCII/Unicode output.
|
|
34
|
-
- [lukilabs/beautiful-mermaid#121 — ER/class ASCII label truncation and stray connectors](https://github.com/lukilabs/beautiful-mermaid/issues/121)
|
|
35
|
-
- Why it matters: ER/class ASCII labels and compartment text are semantic content, not decoration; long labels must not silently disappear when connectors are tight.
|
|
36
|
-
- Current coverage: exact ASCII/Unicode golden files cover class compartments/relationship labels and ER relationship labels. ER same-row layout now widens the inter-entity gap to preserve full labels.
|
|
37
|
-
|
|
38
|
-
## High-value future fixtures
|
|
39
|
-
|
|
40
|
-
- [mermaid-js/mermaid#6271 — unexpected graph direction](https://github.com/mermaid-js/mermaid/issues/6271)
|
|
41
|
-
- Suggested fixture: a graph whose author order implies a clear primary direction but whose cross/back edges tempt the layout engine to flip ranks. Assert source-order progression and bounded aspect ratio.
|
|
42
|
-
- [mermaid-js/mermaid#7785 — collapsible subgraphs via `@{ view: collapsed }`](https://github.com/mermaid-js/mermaid/pull/7785)
|
|
43
|
-
- Suggested fixture: parse/render normal nested subgraphs today; when collapse metadata appears, either model it explicitly or preserve source as opaque. Never silently drop the `@{ ... }` meaning.
|
|
44
|
-
- [Mermaid v11.3+ `@{ shape: ... }` typed node metadata](https://mermaid.js.org/syntax/flowchart.html) — **safety floor fixed as BUILD-23 / [#29](https://github.com/adewale/agentic-mermaid/issues/29); full typed-shape vocabulary remains #44**
|
|
45
|
-
- Why it matters: this syntax carries the ISO 5807/ANSI X3.5 flowchart symbol vocabulary (manual input, document, delay, preparation, …); Mermaid's docs use it extensively, so agent-generated sources will contain it.
|
|
46
|
-
- Current behavior (June 2026): the three issue #29 repro classes are pinned by `src/__tests__/flowchart-metadata.test.ts`; they no longer silently drop targets/edges or fabricate `shape`/`label` phantom nodes. Unsupported forms preserve source opaquely; supported label metadata renders as a conservative rectangle fallback.
|
|
47
|
-
- Future fixtures: #44 should model the full Mermaid v11 typed-shape vocabulary without weakening the no-silent-loss safety floor.
|
|
48
|
-
- [Mermaid frontmatter `config.layout`/`config.look`](https://mermaid.js.org/intro/syntax-reference.html) — **wrapper-fidelity gaps found by probing the official examples, fixed as BUILD-21**
|
|
49
|
-
- Why it mattered: round-tripping a diagram through the editor flattened `config:`-nested frontmatter to top-level keys Mermaid ignores (silently killing the author's layout/look request on interop), duplicated `%%{init}%%` directives into synthesized frontmatter, and dropped leading comments.
|
|
50
|
-
- Current coverage: `src/__tests__/agent-wrapper-fidelity.test.ts` pins byte-verbatim wrapper round-trip (frontmatter, directives incl. multiline, leading comments, combined), mutation wrapper preservation, canonical-mode config nesting + directive folding, and the `COMMENT_DROPPED` lint matrix.
|
|
51
|
-
|
|
52
|
-
## Fork-network layout search notes
|
|
53
|
-
|
|
54
|
-
A May 2026 GitHub issue/PR search found recurring layout-quality themes in both Mermaid and Beautiful Mermaid:
|
|
55
|
-
|
|
56
|
-
- [mermaid-js/mermaid#6049 — Flowchart ugly self linking nodes](https://github.com/mermaid-js/mermaid/issues/6049)
|
|
57
|
-
- Fixture status: `src/__tests__/aesthetic-issue-regressions.test.ts` renders a flowchart self-loop and asserts the loop has no hard geometric defects; `src/__tests__/layout-quality-heuristics.test.ts` keeps the broader self-loop clearance guard.
|
|
58
|
-
- [mermaid-js/mermaid#5060 — Avoidable overlapping curves in flow-chart](https://github.com/mermaid-js/mermaid/issues/5060)
|
|
59
|
-
- Fixture status: `src/__tests__/aesthetic-issue-regressions.test.ts` renders repeated parallel labeled edges and asserts distinct edge paths, zero crossings, no hard defects, and separated label boxes.
|
|
60
|
-
- [mermaid-js/mermaid#6046 — subgraph links should affect positioning more than inter-graph links](https://github.com/mermaid-js/mermaid/issues/6046)
|
|
61
|
-
- Fixture idea: nested subgraphs with invisible/loose links. Assert group order follows source intent and cross-group edges do not dominate internal layout.
|
|
62
|
-
- [mermaid-js/mermaid#7492 — C4 overlapping labels/text overflow/crossing arrows](https://github.com/mermaid-js/mermaid/issues/7492)
|
|
63
|
-
- Fixture idea: labels near containers. Assert text stays inside boxes and edge labels keep minimum clearance from unrelated nodes.
|
|
64
|
-
- [mermaid-js/mermaid#2792 — graph lines sometimes overlap boxes](https://github.com/mermaid-js/mermaid/issues/2792)
|
|
65
|
-
- Fixture status: `src/__tests__/aesthetic-issue-regressions.test.ts` renders a transitive route and asserts the ugly-detector reports no edge-through-node defect.
|
|
66
|
-
- [lukilabs/beautiful-mermaid#83 — TD/TB flowchart layout flipping horizontal](https://github.com/lukilabs/beautiful-mermaid/issues/83)
|
|
67
|
-
- Fixture idea: vertical process with repeated feedback edges. Assert TD/TB diagrams remain height-dominant or within a bounded aspect ratio.
|
|
68
|
-
- [lukilabs/beautiful-mermaid#68 — fan-in groups not target-aware](https://github.com/lukilabs/beautiful-mermaid/issues/68)
|
|
69
|
-
- Fixture idea: multiple roots feeding separate targets. Assert roots cluster by target and unrelated routes do not share misleading trunks.
|
|
70
|
-
- [lukilabs/beautiful-mermaid#63 — misleading edge overlap in routing](https://github.com/lukilabs/beautiful-mermaid/pull/63)
|
|
71
|
-
- Fixture idea: two fan-in edges followed by two fan-out edges. Assert an outgoing branch does not visually reuse an unrelated incoming corridor.
|
|
72
|
-
- [lukilabs/beautiful-mermaid#89 — CJK subgraph title layout drift](https://github.com/lukilabs/beautiful-mermaid/issues/89)
|
|
73
|
-
- Fixture idea: fullwidth group labels. Assert group header bounds account for CJK width.
|
|
74
|
-
- [lukilabs/beautiful-mermaid#121 — ER/class ASCII labels truncated/overlapping](https://github.com/lukilabs/beautiful-mermaid/issues/121)
|
|
75
|
-
- Fixture status: representative class/ER golden files now assert labels survive and connectors remain attached; keep this theme in the generated matrix for longer label/attribute variants.
|
|
76
|
-
|
|
77
|
-
## Aesthetic-issue coverage audit (issue-keyed)
|
|
78
|
-
|
|
79
|
-
A June 2026 audit turned the 13 layout-aesthetic complaints in
|
|
80
|
-
[`mermaid-layout-complaints.md`](./mermaid-layout-complaints.md) into an
|
|
81
|
-
explicit coverage ledger. Direct issue-keyed fixtures now guard the complaints
|
|
82
|
-
that can be expressed against supported diagram families; broader existing
|
|
83
|
-
assertions are tagged where they already covered the behavior; unsupported,
|
|
84
|
-
deferred, and policy-out-of-scope cases remain recorded below.
|
|
85
|
-
|
|
86
|
-
- **Issue-keyed regression fixtures** —
|
|
87
|
-
[`src/__tests__/aesthetic-issue-regressions.test.ts`](../src/__tests__/aesthetic-issue-regressions.test.ts)
|
|
88
|
-
renders a small repro graph per complaint and asserts, through the real
|
|
89
|
-
renderer, that Agentic Mermaid does not exhibit it: `#6476` (avoidable edge
|
|
90
|
-
crossings → 0 on a planar bipartite graph), `#5601` (planar state diagram
|
|
91
|
-
stays planar), `#5060` (parallel labeled edges use distinct rendered paths,
|
|
92
|
-
keep labels separate, and produce no geometric defects),
|
|
93
|
-
`#2792` (transitive edge does not pass through an intervening node, via the
|
|
94
|
-
ugly-detector `edge-through-node` check), `#2131` (edge labels keep
|
|
95
|
-
clearance from unrelated nodes and from each other), and `#6336`/`#6049`
|
|
96
|
-
(state and flowchart self-loops render without hard defects).
|
|
97
|
-
- **Tagged existing assertions** (now greppable by issue number): `#815`
|
|
98
|
-
(declared node/source order — `agent-auth-flow.test.ts`,
|
|
99
|
-
`layout-quality-heuristics.test.ts`), `#1984`/`#3262` (scale-collapse
|
|
100
|
-
whitespace + aspect — `agent-quality.test.ts`), `#1301` (long-range Gantt
|
|
101
|
-
axis labels stay clear of task bars — `gantt-layout.test.ts`), and `#1765` (activation/note/block
|
|
102
|
-
clearance — `sequence-layout.test.ts`).
|
|
103
|
-
- **`#7492` (C4 overlapping labels/arrows)** — no fixture yet: the C4 family
|
|
104
|
-
is not rendered. Tracked under **BUILD-6** (new upstream families); add the
|
|
105
|
-
fixture when C4 lands.
|
|
106
|
-
- **`#3723` (same-rank constraint) and `#5420` (manual node positioning)** —
|
|
107
|
-
documented **won't-do by policy**, no fixture. `#3723` is "watch-only"
|
|
108
|
-
(adopt only if Mermaid core standardizes a `config:` key — see C6); `#5420`
|
|
109
|
-
is out of scope (the agent loop is the substitute — see C1). Neither is a
|
|
110
|
-
bug we can regression-guard, because not implementing them is the decision.
|
|
111
|
-
|
|
112
|
-
These guards assert "Agentic Mermaid does not exhibit the complaint," not
|
|
113
|
-
"the upstream Mermaid bug is fixed" — every cited issue is a defect in
|
|
114
|
-
mermaid-js's own dagre renderer, which this fork does not share (see
|
|
115
|
-
[`mermaid-layout-complaints.md`](./mermaid-layout-complaints.md) R4).
|
|
116
|
-
|
|
117
|
-
## Programmatic bad-layout heuristics
|
|
118
|
-
|
|
119
|
-
Current useful heuristics:
|
|
120
|
-
|
|
121
|
-
- `verifyMermaid` warnings: `OFF_CANVAS`, `GROUP_BREACH`, `NODE_OVERLAP`, `ROUTE_SELF_CROSS`, `LABEL_OVERFLOW`, `DUPLICATE_EDGE`, `UNREACHABLE_NODE`;
|
|
122
|
-
- `measureQuality(layoutMermaid(d))` / `checkQuality(...)`: edge crossings, label legibility, whitespace balance, edge-label clearance from non-attached nodes, other edge labels, and other edge paths, and aspect ratio;
|
|
123
|
-
- issue-keyed fixtures that gate selected repro diagrams individually, including zero crossings and label-vs-label box separation for parallel edge labels;
|
|
124
|
-
- family-specific geometry assertions, such as Auth Flow's source-order progression and backward feedback-edge routing;
|
|
125
|
-
- layout-quality heuristic tests for declared-direction progress (`TD`/`BT`/`LR`/`RL`), edge-vs-node collisions excluding attached endpoints, feedback-process cleanliness, root node vs top-level subgraph source order, and self-loop clearance;
|
|
126
|
-
- PNG/SVG screenshot comparison for artifacts that layout JSON cannot see, such as rounded-fill raster artifacts.
|
|
127
|
-
|
|
128
|
-
High-value next heuristics for layout-improvement corpora:
|
|
129
|
-
|
|
130
|
-
- route corridor reuse by unrelated edge families;
|
|
131
|
-
- target-aware fan-in/fan-out clustering score;
|
|
132
|
-
- group-header text fit, especially with CJK/fullwidth labels.
|
|
133
|
-
|
|
134
|
-
Convention-derived validator candidates (from the ANSI X3.5/ISO 5807
|
|
135
|
-
drafting conventions catalogued in
|
|
136
|
-
[`mermaid-layout-complaints.md`](./mermaid-layout-complaints.md) R3 —
|
|
137
|
-
practitioner guides consistently name these as the top flowchart mistakes):
|
|
138
|
-
|
|
139
|
-
- **unlabeled decision branches**: a diamond node with two or more outgoing
|
|
140
|
-
edges where any edge lacks a label — cheap Tier 3 lint candidate
|
|
141
|
-
(`DECISION_BRANCH_UNLABELED`); complements issue #25 §8.2 diamond port
|
|
142
|
-
semantics;
|
|
143
|
-
- **entry/exit shape**: flowcharts conventionally have one start (a single
|
|
144
|
-
in-degree-0 node) and clearly marked endpoints (at least one sink) —
|
|
145
|
-
fits issue #26 workstream 14 as an analysis fact alongside the existing
|
|
146
|
-
graph entry/feedback-edge outputs, not as a hard error.
|
|
147
|
-
|
|
148
|
-
These can drive a generated fixture matrix: vary direction, feedback-edge density, self-loops, parallel edges, label length, CJK labels, nested subgraphs, fan-in/fan-out shape, and styling. Each generated case should assert semantic preservation first, then one or more layout heuristics. Screenshot tests should be reserved for cases where the visual artifact is genuinely pixel/raster-level.
|
|
149
|
-
|
|
150
|
-
## Test-design rules for issue fixtures
|
|
151
|
-
|
|
152
|
-
- Prefer smallest meaningful source examples over screenshots alone.
|
|
153
|
-
- Assert semantics first: labels, edges, groups, source-preserved metadata.
|
|
154
|
-
- Add screenshot/SVG regression only when geometry/visual polish is the bug.
|
|
155
|
-
- For unsupported Mermaid syntax, assert opaque/source-preserved fallback rather than lossy normalization.
|
|
156
|
-
- For security issues, assert both removal of dangerous refs and preservation of safe SVG output.
|