agentic-mermaid 0.1.1 → 0.2.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 (340) hide show
  1. package/AGENT_NATIVE.md +155 -91
  2. package/CHANGELOG.md +163 -4
  3. package/Instructions_for_agents.md +10 -10
  4. package/LICENSES/Apache-2.0.txt +202 -0
  5. package/README.md +31 -38
  6. package/THIRD_PARTY_NOTICES.md +29 -0
  7. package/assets/hero.png +0 -0
  8. package/dist/agent-core.d.ts +463 -0
  9. package/dist/agent-core.js +397 -0
  10. package/dist/agent.d.ts +73 -1868
  11. package/dist/agent.js +336 -37325
  12. package/dist/agentic-mermaid-mcp.js +7 -38399
  13. package/dist/am.js +33626 -40446
  14. package/dist/chunk-2P5FKUQC.js +3485 -0
  15. package/dist/chunk-2S3VSS6I.js +149 -0
  16. package/dist/chunk-2SILJDW2.js +37 -0
  17. package/dist/chunk-BJYMBT4I.js +61963 -0
  18. package/dist/chunk-FDM43XU7.js +615 -0
  19. package/dist/chunk-MYPDVZCO.js +4702 -0
  20. package/dist/index-DWPa2MJs.d.ts +6780 -0
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +310 -33014
  23. package/dist/mcp-cli-5J47WEY3.js +17 -0
  24. package/docs/README.md +39 -31
  25. package/docs/agent-api-cookbook.md +44 -35
  26. package/docs/agent-mutation-policy.md +1 -1
  27. package/docs/agent-workflow-examples.md +2 -2
  28. package/docs/api.md +284 -77
  29. package/docs/ascii.md +26 -16
  30. package/docs/code-mode-impact.md +214 -0
  31. package/docs/comparison.md +23 -11
  32. package/docs/computational-aesthetics-prototype-plan.md +252 -0
  33. package/docs/config.md +26 -10
  34. package/docs/custom-fonts.md +265 -0
  35. package/docs/custom-style-cookbook.md +130 -9
  36. package/docs/diagram-families.md +48 -23
  37. package/docs/features.md +59 -52
  38. package/docs/fork-differences.md +6 -3
  39. package/docs/getting-started.md +23 -16
  40. package/docs/issue-derived-test-cases.md +29 -22
  41. package/docs/mcp-code-mode-rationale.md +13 -6
  42. package/docs/mcp-http-transport.md +20 -13
  43. package/docs/mermaid-layout-complaints.md +66 -52
  44. package/docs/mutation-testing.md +145 -66
  45. package/docs/quality.md +23 -14
  46. package/docs/react.md +2 -2
  47. package/docs/schemas/style-spec.schema.json +1221 -30
  48. package/docs/style-authoring.md +241 -38
  49. package/docs/svg-semantic-contract.md +49 -0
  50. package/docs/testing-strategy.md +166 -58
  51. package/docs/theming.md +19 -32
  52. package/examples/styles/catalog.json +54 -0
  53. package/examples/styles/cloudflare-workers-inspired-prototype.mmd +9 -0
  54. package/examples/styles/cloudflare-workers-inspired-prototype.style.json +110 -0
  55. package/examples/styles/cupertino-prototype.mmd +10 -0
  56. package/examples/styles/cupertino-prototype.style.json +63 -0
  57. package/examples/styles/mid-century-report.style.json +2 -2
  58. package/examples/styles/star-chart-atlas.style.json +2 -1
  59. package/examples/styles/transit-route-map.style.json +2 -2
  60. package/examples/styles/vercel-inspired-prototype.mmd +6 -0
  61. package/examples/styles/vercel-inspired-prototype.style.json +87 -0
  62. package/package.json +85 -45
  63. package/server.json +2 -2
  64. package/skills/agentic-mermaid-diagram-workflow/SKILL.md +17 -36
  65. package/skills/agentic-mermaid-diagram-workflow/references/cli.md +4 -5
  66. package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +15 -31
  67. package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +10 -14
  68. package/skills/agentic-mermaid-live-editor/SKILL.md +100 -206
  69. package/TODO.md +0 -684
  70. package/dist/index-wjRjbsP-.d.ts +0 -1102
  71. package/docs/assets/improvements/box-start-connector.png +0 -0
  72. package/docs/assets/improvements/comment-dropped-lint.png +0 -0
  73. package/docs/assets/improvements/er-content-loss.png +0 -0
  74. package/docs/assets/improvements/fan-in-trunks.png +0 -0
  75. package/docs/assets/improvements/gantt-family.png +0 -0
  76. package/docs/assets/improvements/gantt-milestone-clamp.png +0 -0
  77. package/docs/assets/improvements/gantt-verify-seam.png +0 -0
  78. package/docs/assets/improvements/subgraph-container-edges.png +0 -0
  79. package/docs/assets/improvements/wrapper-frontmatter.png +0 -0
  80. package/docs/assets/improvements/wrapper-init-directive.png +0 -0
  81. package/docs/assets/improvements/wrapper-leading-comment.png +0 -0
  82. package/docs/assets/style-cookbook/mid-century-report.png +0 -0
  83. package/docs/assets/style-cookbook/star-chart-atlas.png +0 -0
  84. package/docs/assets/style-cookbook/transit-route-map.png +0 -0
  85. package/docs/contributing/adding-diagram-types.md +0 -144
  86. package/docs/contributing/diagram-family-citizenship.matrix.json +0 -2127
  87. package/docs/contributing/diagram-family-citizenship.md +0 -82
  88. package/docs/contributing/harvesting-upstream-tests.md +0 -126
  89. package/docs/contributing/lessons-learned.md +0 -276
  90. package/docs/contributing/releasing.md +0 -82
  91. package/docs/contributing/visual-review-evidence.md +0 -53
  92. package/docs/design/families/README.md +0 -26
  93. package/docs/design/families/architecture-beta.md +0 -48
  94. package/docs/design/families/flowchart-parser-conformance.md +0 -22
  95. package/docs/design/families/gantt-research.md +0 -137
  96. package/docs/design/families/gantt.md +0 -329
  97. package/docs/design/families/journey-agentic-cards-before.png +0 -0
  98. package/docs/design/families/journey-experience-curve-implementation.png +0 -0
  99. package/docs/design/families/journey-mermaid-classic-implementation.png +0 -0
  100. package/docs/design/families/journey-mermaid-classic-prototype.png +0 -0
  101. package/docs/design/families/journey-mermaid-classic-prototype.svg +0 -163
  102. package/docs/design/families/journey-mermaid-classic-prototype.svg.png +0 -0
  103. package/docs/design/families/journey-migration-parity.md +0 -439
  104. package/docs/design/families/journey-section-overlap-after.png +0 -0
  105. package/docs/design/families/journey-section-overlap-before.png +0 -0
  106. package/docs/design/families/journey-usage-research.md +0 -423
  107. package/docs/design/families/journey.md +0 -153
  108. package/docs/design/families/xychart.md +0 -85
  109. package/docs/design/system/README.md +0 -45
  110. package/docs/design/system/abstraction-audit.md +0 -224
  111. package/docs/design/system/abstraction-recommendations.md +0 -655
  112. package/docs/design/system/architecture.mmd +0 -29
  113. package/docs/design/system/architecture.svg +0 -137
  114. package/docs/design/system/layout-guarantees-and-robustness.md +0 -351
  115. package/docs/design/system/layout-rubric.md +0 -138
  116. package/docs/design/system/route-contracts.md +0 -848
  117. package/docs/design/system/source-preservation-ladder.md +0 -52
  118. package/docs/design/system/styles-rollout.md +0 -216
  119. package/docs/design/system/ugly-layouts.md +0 -119
  120. package/docs/layout-characterization/README.md +0 -245
  121. package/docs/layout-characterization/contact-sheet-families.md +0 -498
  122. package/docs/layout-characterization/contact-sheet.md +0 -638
  123. package/docs/layout-characterization/properties.md +0 -281
  124. package/docs/layout-characterization/visual-quality.md +0 -160
  125. package/docs/layout-characterization/visual-snapshots/architecture.svg +0 -79
  126. package/docs/layout-characterization/visual-snapshots/class.svg +0 -60
  127. package/docs/layout-characterization/visual-snapshots/er.svg +0 -61
  128. package/docs/layout-characterization/visual-snapshots/flowchart.svg +0 -58
  129. package/docs/layout-characterization/visual-snapshots/gantt.svg +0 -52
  130. package/docs/layout-characterization/visual-snapshots/journey.svg +0 -98
  131. package/docs/layout-characterization/visual-snapshots/pie.svg +0 -36
  132. package/docs/layout-characterization/visual-snapshots/quadrant.svg +0 -47
  133. package/docs/layout-characterization/visual-snapshots/sequence.svg +0 -59
  134. package/docs/layout-characterization/visual-snapshots/state.svg +0 -52
  135. package/docs/layout-characterization/visual-snapshots/timeline.svg +0 -64
  136. package/docs/layout-characterization/visual-snapshots/xychart.svg +0 -97
  137. package/docs/project/divergences.md +0 -98
  138. package/docs/project/dogfooding-docs-strategy.md +0 -66
  139. package/docs/project/hosted-mcp-cloudflare-plan.md +0 -338
  140. package/docs/project/lessons-learned.md +0 -1019
  141. package/docs/project/remove-role-styling-plan.md +0 -176
  142. package/examples/agent-improve-auth-flow.ts +0 -206
  143. package/examples/agent-loop.ts +0 -53
  144. package/examples/mcp-vs-cli-complex-diagrams.ts +0 -133
  145. package/llms.txt +0 -104
  146. package/skill-evals/README.md +0 -77
  147. package/skill-evals/fixtures/architecture-cache/input.mmd +0 -5
  148. package/skill-evals/fixtures/class-payment/input.mmd +0 -4
  149. package/skill-evals/fixtures/er-orders/input.mmd +0 -10
  150. package/skill-evals/fixtures/flowchart-cache/input.mmd +0 -3
  151. package/skill-evals/fixtures/gantt-release/input.mmd +0 -7
  152. package/skill-evals/fixtures/journey-checkout/input.mmd +0 -6
  153. package/skill-evals/fixtures/pie-exports/input.mmd +0 -5
  154. package/skill-evals/fixtures/quadrant-priorities/input.mmd +0 -11
  155. package/skill-evals/fixtures/sequence-retry/input.mmd +0 -8
  156. package/skill-evals/fixtures/state-lifecycle/input.mmd +0 -5
  157. package/skill-evals/fixtures/timeline-release/input.mmd +0 -6
  158. package/skill-evals/fixtures/xychart-growth/input.mmd +0 -5
  159. package/skill-evals/shared-benchmark.json +0 -510
  160. package/src/agent/analyze.ts +0 -157
  161. package/src/agent/apply.ts +0 -146
  162. package/src/agent/architecture-body.ts +0 -458
  163. package/src/agent/certificates.ts +0 -110
  164. package/src/agent/class-body.ts +0 -319
  165. package/src/agent/core.ts +0 -207
  166. package/src/agent/create.ts +0 -106
  167. package/src/agent/describe.ts +0 -368
  168. package/src/agent/er-body.ts +0 -224
  169. package/src/agent/facts.ts +0 -360
  170. package/src/agent/families-builtin.ts +0 -920
  171. package/src/agent/families.ts +0 -232
  172. package/src/agent/family-layouts.ts +0 -832
  173. package/src/agent/flowchart-body.ts +0 -372
  174. package/src/agent/flowchart-unsupported.ts +0 -243
  175. package/src/agent/font-coverage.ts +0 -288
  176. package/src/agent/gantt-body.ts +0 -495
  177. package/src/agent/index.ts +0 -10
  178. package/src/agent/journey-body.ts +0 -374
  179. package/src/agent/label-metrics.ts +0 -28
  180. package/src/agent/layout-to-rendered.ts +0 -63
  181. package/src/agent/mutate.ts +0 -97
  182. package/src/agent/mutation-ops.ts +0 -51
  183. package/src/agent/op-schema.ts +0 -443
  184. package/src/agent/parse.ts +0 -223
  185. package/src/agent/pie-body.ts +0 -270
  186. package/src/agent/png.ts +0 -171
  187. package/src/agent/quadrant-body.ts +0 -336
  188. package/src/agent/quality.ts +0 -363
  189. package/src/agent/readability-audit.ts +0 -92
  190. package/src/agent/rendered-route-audit.ts +0 -61
  191. package/src/agent/sequence-body.ts +0 -345
  192. package/src/agent/serialize.ts +0 -214
  193. package/src/agent/state-body.ts +0 -589
  194. package/src/agent/structural-count.ts +0 -150
  195. package/src/agent/timeline-body.ts +0 -280
  196. package/src/agent/trace-log.ts +0 -43
  197. package/src/agent/types.ts +0 -995
  198. package/src/agent/verify.ts +0 -603
  199. package/src/agent/xychart-body.ts +0 -472
  200. package/src/architecture/config.ts +0 -282
  201. package/src/architecture/layout.ts +0 -496
  202. package/src/architecture/parser.ts +0 -375
  203. package/src/architecture/renderer.ts +0 -611
  204. package/src/architecture/types.ts +0 -113
  205. package/src/ascii/ansi.ts +0 -423
  206. package/src/ascii/architecture.ts +0 -210
  207. package/src/ascii/canvas.ts +0 -443
  208. package/src/ascii/class-diagram.ts +0 -697
  209. package/src/ascii/converter.ts +0 -475
  210. package/src/ascii/draw.ts +0 -1693
  211. package/src/ascii/edge-bundling.ts +0 -328
  212. package/src/ascii/edge-routing.ts +0 -330
  213. package/src/ascii/er-diagram.ts +0 -439
  214. package/src/ascii/gantt.ts +0 -276
  215. package/src/ascii/grid.ts +0 -747
  216. package/src/ascii/index.ts +0 -196
  217. package/src/ascii/journey.ts +0 -169
  218. package/src/ascii/meta.ts +0 -244
  219. package/src/ascii/multiline-utils.ts +0 -80
  220. package/src/ascii/pathfinder.ts +0 -301
  221. package/src/ascii/pie.ts +0 -67
  222. package/src/ascii/quadrant.ts +0 -158
  223. package/src/ascii/reverse.ts +0 -216
  224. package/src/ascii/sequence.ts +0 -499
  225. package/src/ascii/shapes/circle.ts +0 -27
  226. package/src/ascii/shapes/corners.ts +0 -143
  227. package/src/ascii/shapes/diamond.ts +0 -27
  228. package/src/ascii/shapes/hexagon.ts +0 -27
  229. package/src/ascii/shapes/index.ts +0 -106
  230. package/src/ascii/shapes/rectangle.ts +0 -168
  231. package/src/ascii/shapes/rounded.ts +0 -27
  232. package/src/ascii/shapes/special.ts +0 -332
  233. package/src/ascii/shapes/stadium.ts +0 -110
  234. package/src/ascii/shapes/state.ts +0 -192
  235. package/src/ascii/shapes/types.ts +0 -73
  236. package/src/ascii/timeline.ts +0 -141
  237. package/src/ascii/types.ts +0 -312
  238. package/src/ascii/validate.ts +0 -120
  239. package/src/ascii/width.ts +0 -81
  240. package/src/ascii/wrap.ts +0 -131
  241. package/src/ascii/xychart.ts +0 -919
  242. package/src/browser.ts +0 -29
  243. package/src/class/layout.ts +0 -240
  244. package/src/class/parser.ts +0 -332
  245. package/src/class/renderer.ts +0 -638
  246. package/src/class/types.ts +0 -129
  247. package/src/cli/agent-instructions.ts +0 -1
  248. package/src/cli/am-bin.ts +0 -6
  249. package/src/cli/exit-codes.ts +0 -18
  250. package/src/cli/index.ts +0 -1132
  251. package/src/cli/init-agent.ts +0 -147
  252. package/src/cli/run-entrypoint.ts +0 -10
  253. package/src/color-resolver.ts +0 -152
  254. package/src/elk-instance.ts +0 -114
  255. package/src/er/layout.ts +0 -187
  256. package/src/er/parser.ts +0 -226
  257. package/src/er/renderer.ts +0 -792
  258. package/src/er/types.ts +0 -99
  259. package/src/family-rubric.ts +0 -425
  260. package/src/font-manifest.ts +0 -31
  261. package/src/gantt/layout.ts +0 -365
  262. package/src/gantt/parser.ts +0 -282
  263. package/src/gantt/pipeline.ts +0 -27
  264. package/src/gantt/renderer.ts +0 -414
  265. package/src/gantt/schedule.ts +0 -513
  266. package/src/gantt/types.ts +0 -255
  267. package/src/index.ts +0 -368
  268. package/src/journey/layout.ts +0 -554
  269. package/src/journey/parse-core.ts +0 -251
  270. package/src/journey/parser.ts +0 -101
  271. package/src/journey/renderer.ts +0 -917
  272. package/src/journey/types.ts +0 -144
  273. package/src/layout/geometry.ts +0 -182
  274. package/src/layout/pass.ts +0 -142
  275. package/src/layout/passes/index.ts +0 -3916
  276. package/src/layout-engine.ts +0 -1565
  277. package/src/layout-rubric.ts +0 -659
  278. package/src/mcp/artifacts.ts +0 -137
  279. package/src/mcp/dynamic-harness.ts +0 -31
  280. package/src/mcp/dynamic-modules.d.ts +0 -7
  281. package/src/mcp/facade.ts +0 -608
  282. package/src/mcp/harness-runtime.ts +0 -203
  283. package/src/mcp/hosted-server.ts +0 -468
  284. package/src/mcp/mcp-bin.ts +0 -3
  285. package/src/mcp/mcp-cli.ts +0 -82
  286. package/src/mcp/protocol.ts +0 -13
  287. package/src/mcp/sandbox.ts +0 -195
  288. package/src/mcp/sdk-decl.ts +0 -391
  289. package/src/mcp/server.ts +0 -362
  290. package/src/mcp/tool-surface.ts +0 -146
  291. package/src/mermaid-source.ts +0 -655
  292. package/src/multiline-utils.ts +0 -228
  293. package/src/parser.ts +0 -1031
  294. package/src/pie/layout.ts +0 -168
  295. package/src/pie/parser.ts +0 -136
  296. package/src/pie/renderer.ts +0 -234
  297. package/src/pie/types.ts +0 -82
  298. package/src/quadrant/layout.ts +0 -191
  299. package/src/quadrant/parser.ts +0 -183
  300. package/src/quadrant/renderer.ts +0 -322
  301. package/src/quadrant/types.ts +0 -113
  302. package/src/render-family-hooks.ts +0 -244
  303. package/src/renderer.ts +0 -1099
  304. package/src/route-contracts.ts +0 -2723
  305. package/src/scene/backend.ts +0 -76
  306. package/src/scene/fidelity.ts +0 -183
  307. package/src/scene/hybrid-backend.ts +0 -174
  308. package/src/scene/ir.ts +0 -181
  309. package/src/scene/marks.ts +0 -127
  310. package/src/scene/rough-backend.ts +0 -378
  311. package/src/scene/seed.ts +0 -46
  312. package/src/scene/style-registry.ts +0 -556
  313. package/src/sequence/layout.ts +0 -456
  314. package/src/sequence/parser.ts +0 -255
  315. package/src/sequence/renderer.ts +0 -604
  316. package/src/sequence/types.ts +0 -154
  317. package/src/shape-clipping.ts +0 -351
  318. package/src/shared/accessibility-directives.ts +0 -22
  319. package/src/shared/batched.ts +0 -61
  320. package/src/shared/color-math.ts +0 -93
  321. package/src/shared/svg-a11y.ts +0 -29
  322. package/src/shared/syntax-error.ts +0 -17
  323. package/src/shared/unicode-ranges.ts +0 -135
  324. package/src/styles.ts +0 -318
  325. package/src/svg-paths.ts +0 -28
  326. package/src/text-metrics.ts +0 -248
  327. package/src/theme.ts +0 -710
  328. package/src/timeline/layout.ts +0 -381
  329. package/src/timeline/parser.ts +0 -215
  330. package/src/timeline/renderer.ts +0 -538
  331. package/src/timeline/types.ts +0 -105
  332. package/src/types.ts +0 -462
  333. package/src/website-worker-modules.d.ts +0 -18
  334. package/src/xychart/axis-utils.ts +0 -109
  335. package/src/xychart/colors.ts +0 -124
  336. package/src/xychart/config.ts +0 -88
  337. package/src/xychart/layout.ts +0 -656
  338. package/src/xychart/parser.ts +0 -504
  339. package/src/xychart/renderer.ts +0 -640
  340. package/src/xychart/types.ts +0 -282
package/docs/features.md CHANGED
@@ -1,40 +1,36 @@
1
1
  # Features — capability inventory
2
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).
3
+ What Agentic Mermaid can do, organized by capability area. The npm import paths are `agentic-mermaid` and `agentic-mermaid/agent`; audit and trusted host-resource helpers remain repository tooling. Implementation history lives in [`project/divergences.md`](./project/divergences.md); active backlog is only [`../TODO.md`](../TODO.md).
4
4
 
5
5
  ## Core IR & editing loop
6
6
 
7
7
  - **Typed `ValidDiagram` IR** — parse Mermaid into a sealed, typed value.
8
- - **`parseMermaid(source)`** → `Result<ValidDiagram, ParseError[]>`. Never
8
+ - **`parseRegisteredMermaid(source)`** → `Result<ValidDiagram, ParseError[]>`. Never
9
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).
10
+ - **`mutate(d, op)`** — family-overloaded typed mutation. The generated
11
+ `am capabilities --json` response and SDK declaration expose the authoritative
12
+ operation menu for every registered family.
13
+ - **`verifyMermaid(d, opts)`** — structural and geometric verification plus a
14
+ strict render-parity gate, with deterministic semantic facts available for
15
+ meaning-level checks.
14
16
  - **`serializeMermaid(d)`** — back to canonical source.
15
17
  - **Round-trip** — structured bodies serialize to canonical, idempotent
16
18
  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) |
19
+ - **Narrowers** — each family descriptor owns its generated SDK narrower;
20
+ discover the current names through `am capabilities --json`. A narrower
21
+ returns `null` on a non-matching or source-level/opaque body, steering agents
22
+ off the unsafe path without maintaining a second family roster here.
23
+
24
+ ## Diagram families
25
+
26
+ The canonical `FamilyDescriptor` registry owns headers, discovery, examples,
27
+ operations, rendering hooks, positioned projections, semantic roles, and
28
+ capability evidence. Run `am capabilities --json` for the current roster and
29
+ per-family operation shapes; the generated Section A matrix records native,
30
+ source-preserved, diagnosed, and not-applicable capabilities without a copied
31
+ table. `absent` belongs to the validation vocabulary but is rejected from the
32
+ shipped syntax ledger:
33
+ [`project/section-a-capability-report.md`](./project/section-a-capability-report.md).
38
34
 
39
35
  **Structured-or-opaque rule:** every family either has a structured body
40
36
  or preserves source verbatim. Constructs are never silently dropped.
@@ -43,27 +39,33 @@ or preserves source verbatim. Constructs are never silently dropped.
43
39
 
44
40
  Agentic Mermaid outputs **SVG, PNG, ASCII, Unicode, and JSON layout** from the same renderer foundation.
45
41
 
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
42
+ - **Styles** — every SVG/PNG render accepts `style`: any registered Look or
43
+ Palette discovered through `knownStyleDescriptors()`, an inline JSON record,
44
+ or a stack merged left → right
52
45
  (`{ style: ['hand-drawn', 'dracula'] }`). `seed` re-rolls styled ink and
53
46
  never moves layout. CLI: `am render --style … --seed N`, `am styles`;
54
47
  MCP render tools take `style`/`seed`; RENDER_FAILED-gated verify means a
55
48
  clean verify proves the styled source renders. Authoring guide, schema, and
56
49
  cookbook: `docs/style-authoring.md`, `docs/schemas/style-spec.schema.json`,
57
- and `docs/custom-style-cookbook.md`.
50
+ and `docs/custom-style-cookbook.md`. Custom font selection and resolution:
51
+ `docs/custom-fonts.md`.
58
52
 
59
53
  - **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 }`
54
+ variable fonts, all-family semantic `data-id`/`data-role` identities, typed
55
+ relation ARIA, and `idPrefix` namespacing for markers, filters, clip paths,
56
+ paints, hrefs, and ARIA references). CLI exposes `--security strict`.
57
+ - **ASCII / Unicode** — `renderMermaidASCII` uses grapheme/display-cell geometry
58
+ across every family. `targetWidth` is a hard bound with typed impossible-width
59
+ errors; deprecated `maxWidth` remains best-effort only.
60
+ - **PNG** — `renderMermaidPNG(source, { ...sharedRenderOptions, fitTo, background, 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,
61
+ cross-runtime deterministic on same-machine x86_64/ARM64 where Node + built `dist/` are present; explicit sRGB + cICP metadata with no conflicting ICC profile). Characters without bundled coverage (CJK, emoji) warn loudly; supply `--font-dirs <dir>` / `fontDirs` or `--system-fonts` / `loadSystemFonts: true`.
62
+ Trusted hosts can bind one registered graphical backend across SVG, native
63
+ PNG, and browser PNG with `createMermaidRenderer`,
64
+ `createMermaidPNGRenderer`, and `createMermaidBrowserPNGRenderer`; backend
65
+ selection is host policy and cannot be smuggled through serializable render
66
+ options or Styles.
67
+ - **JSON layout** — `layoutMermaid` / `am render --format layout`; 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.
68
+ - **ASCII with metadata** — `renderMermaidASCIIWithMeta` → `{ ascii, regions, actions, warnings, routeParity }`
67
69
  for TUI click-mapping.
68
70
  - **Reverse** — `asciiToMermaid` reconstructs flowchart source from ASCII
69
71
  (best-effort, lossy, structural round-trip).
@@ -73,8 +75,8 @@ Agentic Mermaid outputs **SVG, PNG, ASCII, Unicode, and JSON layout** from the s
73
75
  - **Tier 1 (structural, universal):** EMPTY_DIAGRAM, EDGE_MISANCHORED,
74
76
  OFF_CANVAS, GROUP_BREACH, UNKNOWN_SHAPE, LABEL_OVERFLOW, UNRESOLVABLE_SCHEDULE,
75
77
  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
+ - **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_SELF_LOOP_OCCUPANCY, ROUTE_CONTAINER_MISANCHOR, ROUTE_SHAPE_MISANCHOR, ROUTE_STALE_AFTER_NODE_MOVE.
79
+ - **Tier 3 (lint and inspect-only policy):** DUPLICATE_EDGE, UNREACHABLE_NODE, DECISION_BRANCH_UNLABELED, COMMENT_DROPPED, UNSUPPORTED_SYNTAX, CONTENT_DROPPED_ON_ROUNDTRIP, INEFFECTIVE_CONFIG, LOW_CONTRAST, BRAND_CONSTRAINT_WARNING, BRAND_CONSTRAINT_ERROR. Brand constraints inspect final contrast, accent area, or monochrome role paint without repainting/relayout; only the caller-selected `action: "error"` code flips `verify.ok`.
78
80
  - **Perceptual quality** — `measureQuality` / `checkQuality` (edge
79
81
  crossings, label legibility, whitespace balance, …). See [`quality.md`](./quality.md).
80
82
 
@@ -89,7 +91,8 @@ Agentic Mermaid outputs **SVG, PNG, ASCII, Unicode, and JSON layout** from the s
89
91
  ## Security
90
92
 
91
93
  - **Strict mode** (`security:'strict'`) — zero external-fetch references in
92
- the SVG (no Google Fonts `@import`).
94
+ the SVG (no Google Fonts `@import`) after one shared transform plus residual
95
+ verification policy.
93
96
  - **`verifyNoExternalRefs(svg)`** — scanner / CI gate / agent self-check.
94
97
  - No `<image>`/`<script>`/external-href injection; click directives
95
98
  sanitized. See [`../SECURITY.md`](../SECURITY.md).
@@ -99,7 +102,9 @@ Agentic Mermaid outputs **SVG, PNG, ASCII, Unicode, and JSON layout** from the s
99
102
  `render` (svg/ascii/unicode/json with multi-input results; png uses one
100
103
  input plus `--output`; `--security strict`, `--watch`), `render-markdown` (skip bad blocks),
101
104
  `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),
105
+ `capabilities --json` (including `families[].editPolicy`,
106
+ `families[].mutationOps`, and the machine-readable `sectionA` contract matrix),
107
+ `batch --jsonl` (including mutate),
103
108
  `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
109
  Exit codes 0/2/3/4; parse and verify-failure errors include structured `error.details` arrays.
105
110
 
@@ -107,21 +112,23 @@ Exit codes 0/2/3/4; parse and verify-failure errors include structured `error.de
107
112
 
108
113
  Local `agentic-mermaid-mcp` is Code Mode-first: `execute(code)` runs synchronous
109
114
  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
115
+ plus narrow `describe_sdk`, `render_png`, and `describe` helpers. The initial
116
+ Code Mode declaration carries only the core SDK; `describe_sdk` returns one
117
+ family's mutation schema on demand. It supports stdio by default and
111
118
  HTTP/SSE via `agentic-mermaid-mcp --transport http`; local `render_png` can
112
119
  return base64 bytes or managed file/URL artifacts with MIME type, byte count, and
113
120
  SHA-256 metadata.
114
121
 
115
122
  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
123
+ Streamable HTTP. It exposes nine bounded MCP JSON-RPC tools: `execute` in a
124
+ Cloudflare Dynamic Worker isolate, pure `describe_sdk` / `render_svg` /
125
+ `render_ascii` / `render_png` / `verify` / `describe`, and declarative `mutate` / `build` for
119
126
  structured edits. Hosted inputs are capped at 64 KB, PNG is base64-only, and the
120
127
  endpoint is a convenience surface rather than a REST render API.
121
128
 
122
129
  ## Distribution
123
130
 
124
- - npm library (`agentic-mermaid` plus the `agentic-mermaid/agent` subpath) with Node-runnable bins (`am`, `agentic-mermaid`, `agentic-mermaid-mcp`).
131
+ - npm library (`agentic-mermaid` and `agentic-mermaid/agent`) with Node-runnable bins (`am`, the package-runner alias `agentic-mermaid`, and `agentic-mermaid-mcp`).
125
132
  - **Single binary** — `bun run build:binary` → `dist/am`, standalone
126
133
  executable, no runtime dependency (#1018).
127
134
  - **llms.txt** agent-discovery digest, derived from capabilities.
@@ -132,8 +139,8 @@ endpoint is a convenience surface rather than a REST render API.
132
139
  SVG layout/ASCII; full-corpus ASCII repeated-run guard; cross-runtime guards
133
140
  exist for bun ≡ node on same-machine x86_64/ARM64 when Node + built `dist/`
134
141
  artifacts are present.
135
- - **Corpus gates** — 271-entry mermaid-js docs corpus + 132-case
136
- MermaidSeqBench, gated in CI.
142
+ - **Corpus gates** — pinned Mermaid documentation and MermaidSeqBench corpora,
143
+ gated in CI; their manifests, rather than this prose, own current counts.
137
144
  - **Benchmarks** — `eval/benchmark/RESULTS.md` (measured vs mmdc, termaid).
138
145
  - **Agent-usage validation** — `eval/agent-usage/` scenarios,
139
146
  anti-pattern linter, sandbox trace instrumentation, and stored Code Mode eval runner.
@@ -10,7 +10,7 @@ The canonical live site is **[agentic-mermaid.dev](https://agentic-mermaid.dev/)
10
10
  - Live editor: <https://agentic-mermaid.dev/editor>
11
11
  - Family comparisons (Mermaid vs Beautiful Mermaid vs Agentic Mermaid): <https://agentic-mermaid.dev/comparisons/>
12
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.
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`) — registry-checked tools: Code Mode `execute` in per-request Dynamic Worker isolates, `describe_sdk` for one family's mutation schema on demand, 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
14
 
15
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
16
 
@@ -18,7 +18,7 @@ GitHub Pages is no longer a deployed surface; its samples-gallery generator has
18
18
 
19
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
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).
21
+ Every registered family is structured when narrowed; segment-preserving families retain unsupported statements in source order, and any whole-body fallback round-trips losslessly. Layout is deterministic and verified byte-identical across processes, and `verifyMermaid` returns structured structural, geometric, and lint warnings plus perceptual quality metrics 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
22
 
23
23
  ## New and expanded diagram support
24
24
 
@@ -35,6 +35,9 @@ This fork renders a wider set of Mermaid families in both the gallery and editor
35
35
  - Pie charts (`pie`, with `showData`)
36
36
  - Quadrant charts (`quadrantChart`) — not yet rendered anywhere else in the beautiful-mermaid network
37
37
  - Gantt charts (`gantt`) with date axes, sections, dependencies, milestones, exclusions, and vertical markers
38
+ - Mindmaps (`mindmap`) with indentation-sensitive hierarchy, shapes, icons, and classes
39
+ - Git graphs (`gitGraph`) with deterministic replayed commits, branches, merges, and cherry-picks
40
+ - Radar charts (`radar-beta`) — spider/star charts plotting multivariate profiles across equi-angular axes from a shared center
38
41
 
39
42
  The live editor has registry-backed example coverage for every built-in family
40
43
  (`src/__tests__/editor-examples.test.ts`). Browser E2E still spot-checks several
@@ -106,7 +109,7 @@ Users can discover fork features through:
106
109
  Mermaid.js places `a2` inside `one` and `c1` inside `three`; this fork keeps `a2`
107
110
  and `c1` at the top level (only `a1`/`c2` are inside those subgraphs). See it both
108
111
  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==).
112
+ · [open in the fork editor](https://agentic-mermaid.dev/editor/#deflate:q1Yqzi8tSk5VslJKy8kvT85ILCpRCHGKyVNQUFBINtTVtUs0gnCKS5PSixILMhTy81IhIonI0ql5KWjqSsrzISJJIHVJuNVlFKVCTQRbmIxQqVQLAA).
110
113
 
111
114
  This is a deliberate divergence, not a bug: it gives deterministic
112
115
  *definition-scope* membership with no surprising re-parenting when a node is
@@ -25,8 +25,8 @@ cd agentic-mermaid && bun install && bun run build
25
25
  ## Render to SVG
26
26
 
27
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.
28
+ It supports every registered diagram family (including flowchart, sequence,
29
+ class, ER, state, Gantt, Mindmap, and GitGraph) — just pass the source.
30
30
 
31
31
  ```ts
32
32
  import { renderMermaidSVG } from 'agentic-mermaid'
@@ -64,8 +64,11 @@ const png = renderMermaidPNG(`flowchart TD
64
64
  writeFileSync('diagram.png', png)
65
65
  ```
66
66
 
67
- `PngOptions`: `scale` (default `2`, for retina), `background`, and
68
- `fitTo: { width?, height? }`.
67
+ Portable PNG controls are `scale` (default `2`, for retina), `background`, and
68
+ the mutually exclusive `fitTo: { width? }` / `fitTo: { height? }`; the same
69
+ controls are available through the browser adapter, CLI, and local/hosted MCP.
70
+ Node/Bun additionally accepts trusted-host `fontDirs`, `loadSystemFonts`, and
71
+ the library-only `onWarning` callback.
69
72
 
70
73
  ## Render to ASCII / Unicode
71
74
 
@@ -85,21 +88,22 @@ See [`ascii.md`](./ascii.md) for supported families and cell-to-region metadata.
85
88
 
86
89
  ## Theming
87
90
 
88
- Theme from two colors, or spread one of the 21 built-in themes. Colors are applied
91
+ Build a palette from two colors, or select one discovered through
92
+ `knownStyleDescriptors()` or `am styles`. Colors are applied
89
93
  as CSS variables, so the SVG stays self-contained.
90
94
 
91
95
  ```ts
92
- import { renderMermaidSVG, THEMES } from 'agentic-mermaid'
96
+ import { renderMermaidSVG } from 'agentic-mermaid'
93
97
 
94
- // Two-color theme
98
+ // Two-color palette
95
99
  const dark = renderMermaidSVG('flowchart TD\n A --> B', {
96
100
  bg: '#1a1b26',
97
101
  fg: '#a9b1d6',
98
102
  })
99
103
 
100
- // A built-in theme (zinc-light, tokyo-night, nord, dracula, catppuccin-mocha, …)
104
+ // A built-in palette (zinc-light, tokyo-night, nord, dracula, catppuccin-mocha, …)
101
105
  const themed = renderMermaidSVG('flowchart TD\n A --> B', {
102
- ...THEMES['tokyo-night'],
106
+ style: 'tokyo-night',
103
107
  })
104
108
 
105
109
  // Transparent background, for embedding on any page
@@ -109,7 +113,7 @@ const transparent = renderMermaidSVG('flowchart TD\n A --> B', {
109
113
  ```
110
114
 
111
115
  Common `RenderOptions`: `bg`, `fg`, `font`, `transparent`, and `security`. See
112
- [`theming.md`](./theming.md) for custom themes and Shiki/VS Code theme import.
116
+ [`theming.md`](./theming.md) for custom Palettes and Shiki/VS Code theme import.
113
117
 
114
118
  ### Untrusted input
115
119
 
@@ -148,7 +152,7 @@ See [`react.md`](./react.md) for the zero-flash, live-theme-switching setup.
148
152
  | SVG | `agentic-mermaid` |
149
153
  | ASCII / Unicode | `agentic-mermaid` |
150
154
  | PNG (native rasterizer) | `agentic-mermaid/agent` |
151
- | Themes (`THEMES`, `fromShikiTheme`) | `agentic-mermaid` |
155
+ | Palettes (`knownStyleDescriptors`, `fromShikiTheme`) | `agentic-mermaid` |
152
156
  | Everything in one path | `agentic-mermaid/agent` |
153
157
  | Typed editing (parse/mutate/verify) | `agentic-mermaid/agent` |
154
158
 
@@ -157,15 +161,18 @@ single import path for all formats, import everything from there.
157
161
 
158
162
  ## Prefer the command line?
159
163
 
160
- The same renderers ship as the `am` CLI — no code required:
164
+ The same renderers ship as the `am` CLI — no code required. After the local
165
+ install above, use the package runner so the command resolves without a global
166
+ install:
161
167
 
162
168
  ```bash
163
- am render diagram.mmd --format svg
164
- am render diagram.mmd --format png --output diagram.png
165
- am render diagram.mmd --ascii
169
+ npx --no-install agentic-mermaid render diagram.mmd --format svg
170
+ npx --no-install agentic-mermaid render diagram.mmd --format png --output diagram.png
171
+ npx --no-install agentic-mermaid render diagram.mmd --format ascii
166
172
  ```
167
173
 
168
- Run `am --help` for the full command set.
174
+ Run `npx --no-install agentic-mermaid --help` for the full command set. Inside
175
+ an npm script, the shorter `am …` binary name is available automatically.
169
176
 
170
177
  ## Next steps
171
178
 
@@ -1,6 +1,13 @@
1
- # Issue-derived test-case candidates
1
+ # Issue-derived coverage evidence
2
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.
3
+ Status: evidence and coverage inventory, not a fixture backlog. Root `TODO.md` is
4
+ the sole authority for scheduled work. Uncovered fixture and heuristic ideas
5
+ below are unscheduled unless a stable root TODO item promotes them.
6
+
7
+ These public Mermaid / Beautiful Mermaid issues explain what the existing
8
+ fixtures cover and preserve candidate evidence for future decisions. The goal is
9
+ not to clone every upstream bug; it is to retain representative examples that
10
+ teach the renderer/agent surface what users actually expect.
4
11
 
5
12
  ## Already covered or newly covered
6
13
 
@@ -35,7 +42,7 @@ These are public Mermaid / Beautiful Mermaid issues worth turning into small, ed
35
42
  - 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
43
  - 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
44
 
38
- ## High-value future fixtures
45
+ ## Candidate fixture evidence (unscheduled)
39
46
 
40
47
  - [mermaid-js/mermaid#6271 — unexpected graph direction](https://github.com/mermaid-js/mermaid/issues/6271)
41
48
  - 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.
@@ -44,7 +51,7 @@ These are public Mermaid / Beautiful Mermaid issues worth turning into small, ed
44
51
  - [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
52
  - 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
53
  - 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.
54
+ - Candidate coverage: #44 records the full Mermaid v11 typed-shape vocabulary without weakening the no-silent-loss safety floor; this ledger does not schedule it.
48
55
  - [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
56
  - 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
57
  - 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.
@@ -58,19 +65,17 @@ A May 2026 GitHub issue/PR search found recurring layout-quality themes in both
58
65
  - [mermaid-js/mermaid#5060 — Avoidable overlapping curves in flow-chart](https://github.com/mermaid-js/mermaid/issues/5060)
59
66
  - 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
67
  - [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.
68
+ - Candidate fixture evidence: nested subgraphs with invisible/loose links; group order follows source intent and cross-group edges do not dominate internal layout.
64
69
  - [mermaid-js/mermaid#2792 — graph lines sometimes overlap boxes](https://github.com/mermaid-js/mermaid/issues/2792)
65
70
  - 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
71
  - [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.
72
+ - Candidate fixture evidence: vertical process with repeated feedback edges; TD/TB diagrams remain height-dominant or within a bounded aspect ratio.
68
73
  - [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.
74
+ - Candidate fixture evidence: multiple roots feeding separate targets; roots cluster by target and unrelated routes do not share misleading trunks.
70
75
  - [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.
76
+ - Candidate fixture evidence: two fan-in edges followed by two fan-out edges; an outgoing branch does not visually reuse an unrelated incoming corridor.
72
77
  - [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.
78
+ - Candidate fixture evidence: fullwidth group labels; group header bounds account for CJK width.
74
79
  - [lukilabs/beautiful-mermaid#121 — ER/class ASCII labels truncated/overlapping](https://github.com/lukilabs/beautiful-mermaid/issues/121)
75
80
  - 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
81
 
@@ -100,14 +105,11 @@ deferred, and policy-out-of-scope cases remain recorded below.
100
105
  whitespace + aspect — `agent-quality.test.ts`), `#1301` (long-range Gantt
101
106
  axis labels stay clear of task bars — `gantt-layout.test.ts`), and `#1765` (activation/note/block
102
107
  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.
108
+ - **`#3723` (same-rank constraint)** — planned under `BUILD-24` as typed
109
+ request/mutation metadata, not new Mermaid syntax; its fixture lands with
110
+ that implementation. **`#5420` (manual node positioning)** remains out of
111
+ scope: arbitrary coordinates and dragging are distinct from structural
112
+ auto-layout constraints. There is therefore no #5420 regression fixture.
111
113
 
112
114
  These guards assert "Agentic Mermaid does not exhibit the complaint," not
113
115
  "the upstream Mermaid bug is fixed" — every cited issue is a defect in
@@ -125,7 +127,7 @@ Current useful heuristics:
125
127
  - 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
128
  - PNG/SVG screenshot comparison for artifacts that layout JSON cannot see, such as rounded-fill raster artifacts.
127
129
 
128
- High-value next heuristics for layout-improvement corpora:
130
+ Candidate heuristic evidence (unscheduled):
129
131
 
130
132
  - route corridor reuse by unrelated edge families;
131
133
  - target-aware fan-in/fan-out clustering score;
@@ -145,12 +147,17 @@ practitioner guides consistently name these as the top flowchart mistakes):
145
147
  fits issue #26 workstream 14 as an analysis fact alongside the existing
146
148
  graph entry/feedback-edge outputs, not as a hard error.
147
149
 
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.
150
+ If promoted through root `TODO.md`, these could drive a generated fixture matrix
151
+ varying direction, feedback-edge density, self-loops, parallel edges, label
152
+ length, CJK labels, nested subgraphs, fan-in/fan-out shape, and styling. Each
153
+ case would assert semantic preservation first, then one or more layout
154
+ heuristics; screenshot tests would be reserved for genuinely pixel/raster-level
155
+ artifacts.
149
156
 
150
157
  ## Test-design rules for issue fixtures
151
158
 
152
159
  - Prefer smallest meaningful source examples over screenshots alone.
153
160
  - Assert semantics first: labels, edges, groups, source-preserved metadata.
154
- - Add screenshot/SVG regression only when geometry/visual polish is the bug.
161
+ - Use screenshot/SVG regression only when geometry/visual polish is the bug.
155
162
  - For unsupported Mermaid syntax, assert opaque/source-preserved fallback rather than lossy normalization.
156
163
  - For security issues, assert both removal of dangerous refs and preservation of safe SVG output.
@@ -1,8 +1,8 @@
1
1
  # MCP Code Mode rationale
2
2
 
3
- Local `agentic-mermaid-mcp` is intentionally Code Mode first. Its primary tool is `execute(code)`, which runs synchronous JavaScript against the typed `mermaid.*` SDK in a local `node:vm` sandbox. This is a local implementation inspired by Code Mode as a product shape; it is not Cloudflare Codemode, not backed by `@cloudflare/codemode`, and not an OS/container security boundary. The local helper tools (`render_png` and `describe`) are narrow conveniences, not a second full authoring API.
3
+ Local `agentic-mermaid-mcp` is intentionally Code Mode first. Its primary tool is `execute(code)`, which runs synchronous JavaScript against the typed `mermaid.*` SDK in a local `node:vm` sandbox. This is a local implementation inspired by Code Mode as a product shape; it is not Cloudflare Codemode, not backed by `@cloudflare/codemode`, and not an OS/container security boundary. The local helper tools (`describe_sdk`, `render_png`, and `describe`) are narrow conveniences, not a second full authoring API.
4
4
 
5
- There is now also a **hosted** MCP at `https://agentic-mermaid.dev/mcp` (stateless Streamable HTTP; see [`docs/project/hosted-mcp-cloudflare-plan.md`](./project/hosted-mcp-cloudflare-plan.md)). It keeps `execute` but runs agent code in a per-request Cloudflare Dynamic Worker isolate (`globalOutbound: null`, empty env, `cpuMs` budget) instead of a local `node:vm` — there the isolate configuration *is* the security boundary — and adds direct `render_svg`/`render_ascii`/`render_png`/`verify`/`describe` tools so the common render/verify paths avoid a billable isolate, plus the declarative `mutate`/`build` tools (see below). Both share the same hardened `mermaid.*` facade; their semantics are pinned against each other by a differential test suite.
5
+ There is now also a **hosted** MCP at `https://agentic-mermaid.dev/mcp` (stateless Streamable HTTP; see the [as-built record](./project/archive/hosted-mcp-cloudflare-plan.md)). It keeps `execute` but runs agent code in a per-request Cloudflare Dynamic Worker isolate (`globalOutbound: null`, empty env, `cpuMs` budget) instead of a local `node:vm` — there the isolate configuration *is* the security boundary — and adds `describe_sdk` plus direct `render_svg`/`render_ascii`/`render_png`/`verify`/`describe` tools so schema discovery and common render/verify paths avoid a billable isolate, plus the declarative `mutate`/`build` tools (see below). Both share the same hardened `mermaid.*` facade; their semantics are pinned against each other by a differential test suite, with one explicit host-policy divergence: both hosted `renderMermaidSVG*` execute methods and the direct `render_svg` tool force `security: 'strict'` and `embedFontImport: false`, even if agent code asks for weaker values. Local Code Mode retains the library's caller-selectable policy.
6
6
 
7
7
  ## Why the MCP server exists
8
8
 
@@ -41,14 +41,21 @@ gets wrong through `execute`. For everything richer, use `execute`, the CLI
41
41
 
42
42
  ## What the non-Code-Mode MCP tools are for
43
43
 
44
- Local MCP keeps only two helpers:
44
+ Local MCP keeps only three helpers:
45
45
 
46
- - `render_png(source)` exists because PNG is binary output and returning base64 from a dedicated MCP tool is simpler than putting binary handling into Code Mode snippets. For clients that cannot comfortably carry large base64 payloads, `render_png({source, output:"file"})` writes a managed local artifact and `output:"url"` returns an HTTP-served artifact when the server runs with HTTP/SSE transport.
46
+ - `describe_sdk({ family, detail })` returns version-matched mutation operations for one family without running Code Mode. `detail: "signatures"` returns a compact menu; `detail: "fields"` returns the exact field schema. The initial `execute` declaration stays limited to the core SDK, while `mermaid.describeOps` and `mermaid.opSignatures` expose the same registry inside an execution.
47
+
48
+ - `render_png(source)` exists because PNG is binary output and returning base64 from a dedicated MCP tool is simpler than putting binary handling into Code Mode snippets. Local and hosted tools share portable `scale`, `background`, and mutually exclusive `fitTo.width`/`fitTo.height` controls; local additionally accepts trusted-host `fontDirs`/`loadSystemFonts` remedies and returns deterministic configuration/font-coverage warnings. For clients that cannot comfortably carry large base64 payloads, `render_png({source, output:"file"})` writes a managed local artifact and `output:"url"` returns an HTTP-served artifact when the server runs with HTTP/SSE transport. Because those modes create managed files, the local tool is annotated as non-read-only and non-idempotent.
47
49
  - `describe(source)` exists because one-shot natural-language summaries are common for screen readers, docs, and context compaction.
48
50
 
49
- The hosted endpoint adds direct pure tools (`render_svg`, `render_ascii`, `render_png`, `verify`, `describe`) because every hosted `execute` spins a Dynamic Worker isolate; common render/verify calls should be ordinary Worker invocations and edge-cacheable. Hosted `mutate` and `build` are the only declarative authoring tools, and they exist to apply typed op lists with the verify-before-emit contract without asking a weaker model to write JavaScript. They do not introduce a separate mutation engine.
51
+ The hosted endpoint adds the same direct discovery tool and direct pure tools (`render_svg`, `render_ascii`, `render_png`, `verify`, `describe`) because every hosted `execute` contacts a Dynamic Worker; schema discovery and common render/verify calls should be ordinary Worker invocations eligible for the private compute cache. Hosted `mutate` and `build` are the only declarative authoring tools, and they exist to apply typed op lists with the verify-before-emit contract without asking a weaker model to write JavaScript. They do not introduce a separate mutation engine.
52
+
53
+ Direct render tools accept shared render fields only through the canonical
54
+ nested `options` object, generated from the shared RenderOptions descriptors.
55
+ Palette selection uses `options.style`; `theme` and top-level
56
+ `bg`/`fg`/`style`/`seed` are not tool inputs.
50
57
 
51
- Local managed artifacts are generated under the server artifact directory with safe names, size limits, TTL cleanup, MIME type, byte count, and SHA-256 metadata; they are not arbitrary user-chosen file writes. Hosted `render_png` returns base64 only.
58
+ Local managed artifacts are generated under one exclusively owned server artifact directory with safe names, per-file and aggregate limits, persisted TTL cleanup, MIME type, byte count, and SHA-256 integrity metadata; they are not arbitrary user-chosen file writes. A second live owner fails closed instead of racing a stale manifest. Hosted `render_png` returns base64 only.
52
59
 
53
60
  ## Equivalence example
54
61
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  `agentic-mermaid-mcp` defaults to stdio for local MCP clients. Use HTTP/SSE only when a client needs a reachable endpoint or when PNG artifacts should be fetched by file/URL instead of returned as large base64 strings.
4
4
 
5
- > Looking for a zero-setup endpoint? A **hosted** MCP already runs at `https://agentic-mermaid.dev/mcp` (`claude mcp add --transport http agentic-mermaid https://agentic-mermaid.dev/mcp`). It is a different implementation — stateless Streamable HTTP, Cloudflare-backed, tools `execute`/`render_svg`/`render_ascii`/`render_png`/`verify`/`describe`/`mutate`/`build`, inputs capped at 64KB, and no file/URL PNG artifacts (base64 only). See [`docs/project/hosted-mcp-cloudflare-plan.md`](./project/hosted-mcp-cloudflare-plan.md). Run the local server below when you need file/URL artifacts, larger inputs, offline use, or your own auth.
5
+ > Looking for a zero-setup endpoint? A **hosted** MCP already runs at `https://agentic-mermaid.dev/mcp` (`claude mcp add --transport http agentic-mermaid https://agentic-mermaid.dev/mcp`). It is a different implementation — stateless Streamable HTTP, Cloudflare-backed, tools `execute`/`describe_sdk`/`render_svg`/`render_ascii`/`render_png`/`verify`/`describe`/`mutate`/`build`, inputs capped at 64KB, and no file/URL PNG artifacts (base64 only). See the [as-built record](./project/archive/hosted-mcp-cloudflare-plan.md). Run the local server below when you need file/URL artifacts, larger inputs, offline use, or your own auth.
6
6
  >
7
- > **Privacy:** every hosted call (`execute`, `render_*`, `verify`, `describe`, `mutate`, `build`) sends your diagram source or code to the agentic-mermaid.dev server, and successful responses are edge-cached for up to a day. For diagrams that must not leave your machine, use the library, the CLI, or the local stdio/HTTP server on this page — the pipeline is fully local and needs no network.
7
+ > **Privacy and caching:** every hosted call (`execute`, `render_*`, `verify`, `describe`, `mutate`, `build`) sends your diagram source or code to the agentic-mermaid.dev server. Successful deterministic pure-tool results may be reused by a private server-side Workers Cache for up to 24 hours; `execute`, `mutate`, and `build` bypass it. The JSON-RPC HTTP response itself is always `cache-control: no-store`; `x-agentic-mermaid-compute-cache` reports `hit`, `miss`, `mixed`, `bypass`, or `disabled`. For diagrams that must not leave your machine, use the library, the CLI, or the local stdio/HTTP server on this page — the pipeline is fully local and needs no network.
8
8
 
9
9
  ## Which endpoint returns plain JSON?
10
10
 
@@ -40,11 +40,11 @@ HTTP endpoints:
40
40
  |---|---|
41
41
  | `GET /health` | Readiness probe, returns `{ "ok": true }`. |
42
42
  | `GET /sse` | MCP SSE session endpoint. First event contains the `/message?sessionId=...` URL. |
43
- | `POST /message?sessionId=...` | JSON-RPC requests for an SSE session. The HTTP response is just `202 {"ok":true}`; the JSON-RPC response is emitted on the SSE stream as `event: message` / `data:` frames. |
43
+ | `POST /message?sessionId=...` | JSON-RPC requests for an SSE session. Requests get `202 {"ok":true}` while the JSON-RPC response is emitted on the SSE stream; notifications get an empty `202` and no stream frame. |
44
44
  | `POST /rpc` | Direct JSON-RPC endpoint for tests/scripts/simple integrations. Replies with plain `application/json` (no SSE framing). |
45
45
  | `GET /artifacts/<name>` | Fetch managed artifacts returned by `render_png` `output: "url"`. |
46
46
 
47
- `/rpc` and `/message` require `content-type: application/json`; browser-simple `text/plain` form posts are rejected. Non-loopback hosts require `Authorization: Bearer <token>`.
47
+ `/rpc` and `/message` require `content-type: application/json`; browser-simple `text/plain` form posts are rejected. Non-loopback hosts require `Authorization: Bearer <token>` on `/rpc`, `/sse`, `/message`, and `/artifacts/*`, and the same Origin check covers those routes. SSE sessions are capped (32 by default); an exhausted server returns `503` instead of retaining another session.
48
48
 
49
49
  ## Direct JSON-RPC examples: `render_png`
50
50
 
@@ -60,7 +60,9 @@ Request:
60
60
  "params": {
61
61
  "name": "render_png",
62
62
  "arguments": {
63
- "source": "flowchart TD\n A --> B"
63
+ "source": "flowchart TD\n A --> B",
64
+ "fontDirs": ["./fonts"],
65
+ "loadSystemFonts": false
64
66
  }
65
67
  }
66
68
  }
@@ -84,7 +86,7 @@ Response shape:
84
86
  "content": [
85
87
  {
86
88
  "type": "text",
87
- "text": "{\"ok\":true,\"png_base64\":\"iVBORw0KGgo...\"}"
89
+ "text": "{\"ok\":true,\"png_base64\":\"iVBORw0KGgo...\",\"warnings\":[]}"
88
90
  }
89
91
  ],
90
92
  "isError": false
@@ -92,6 +94,8 @@ Response shape:
92
94
  }
93
95
  ```
94
96
 
97
+ `warnings` always appears. `PNG_FONT_COVERAGE` names missing CJK/emoji coverage and points to `fontDirs`/`loadSystemFonts`; source configuration diagnostics use the same deterministic warning envelope.
98
+
95
99
  ### File output
96
100
 
97
101
  Request:
@@ -166,7 +170,7 @@ Fetch the artifact:
166
170
  curl -L -o diagram.png 'http://127.0.0.1:3000/artifacts/<name>.png'
167
171
  ```
168
172
 
169
- If the server is behind a reverse proxy, set `--public-url https://example.com/artifacts` so returned URLs are externally reachable.
173
+ If the server is behind a reverse proxy, set `--public-url https://example.com/artifacts` so returned URLs are externally reachable. The URL must be absolute HTTP(S); its origin (here `https://example.com`) is also accepted by the `/rpc`, `/sse`, `/message`, and `/artifacts/*` browser-origin guard. Other browser origins remain forbidden.
170
174
 
171
175
  ## Sample SSE flow
172
176
 
@@ -202,14 +206,16 @@ data: {"jsonrpc":"2.0","id":4,"result":{}}
202
206
 
203
207
  | Option | Default | Purpose |
204
208
  |---|---:|---|
205
- | `--transport stdio\|http` | `stdio` | Select stdio or HTTP/SSE transport. `--http` is an alias for `--transport http`. |
209
+ | `--transport stdio\|http` | `stdio` | Select stdio or HTTP transport. |
206
210
  | `--host <host>` | `127.0.0.1` | HTTP bind host. Non-loopback hosts require `--auth-token`. |
207
211
  | `--port <port>` | `3000` | HTTP bind port. Use `0` for an ephemeral test port. |
208
212
  | `--artifact-dir <dir>` | OS temp dir | Directory for managed file/URL artifacts. Files use generated safe names. |
209
- | `--public-url <url>` | `http://<host>:<port>/artifacts` | URL prefix returned by `output: "url"`; useful behind reverse proxies. |
210
- | `--auth-token <token>` | unset | Bearer token required for `/rpc` and `/message` when binding non-loopback. Optional on loopback. |
213
+ | `--public-url <url>` | `http://<host>:<port>/artifacts` | Absolute HTTP(S) prefix returned by `output: "url"`; its origin is accepted by the HTTP/SSE browser-origin guard. |
214
+ | `--auth-token <token>` | unset | Bearer token required for every non-health HTTP route when binding non-loopback. Optional on loopback. |
211
215
  | `--max-artifact-bytes <n>` | `20971520` | Maximum bytes for a single managed artifact. |
212
- | `--artifact-ttl-ms <n>` | `3600000` | How long managed artifacts remain fetchable by this server process. |
216
+ | `--max-artifact-total-bytes <n>` | `209715200` | Aggregate byte budget for unexpired managed artifacts. |
217
+ | `--max-artifacts <n>` | `1000` | Maximum number of unexpired managed artifacts. |
218
+ | `--artifact-ttl-ms <n>` | `3600000` | How long managed artifacts remain fetchable. |
213
219
  | `--max-rpc-body-bytes <n>` | `1048576` | Maximum HTTP JSON-RPC request body size. |
214
220
  | `--max-sandbox-timeout-ms <n>` | `30000` | Maximum `execute` timeout accepted over any transport. |
215
221
 
@@ -217,7 +223,8 @@ data: {"jsonrpc":"2.0","id":4,"result":{}}
217
223
 
218
224
  - HTTP binds to loopback by default.
219
225
  - Non-loopback binding requires `--auth-token`.
220
- - `/rpc` and `/message` reject non-JSON content types and cross-origin browser posts.
226
+ - `/rpc` and `/message` reject non-JSON content types; every non-health route rejects browser origins other than the internal server or configured public origin.
221
227
  - Request bodies and artifact sizes are bounded.
222
- - URL/file artifacts are generated under a managed store, served only if the current process created and still tracks them, and checked against TTL on read.
228
+ - URL/file artifacts use a persisted, integrity-checked manifest; aggregate quotas and TTL survive clean restarts, and cache headers never outlive the stored expiry.
229
+ - Exactly one live store owns an artifact directory. A second server fails before reading or writing state, preventing stale-manifest quota bypass. After an unclean stop, remove `.agentic-mermaid-artifacts-v1.lock` only after confirming no server still uses that directory.
223
230
  - `execute(code)` still runs in local `node:vm`, not an OS/container security boundary. Do not expose HTTP/SSE to hostile users without an outer isolation layer.