agentic-mermaid 0.1.2 → 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.
- package/AGENT_NATIVE.md +671 -0
- package/CHANGELOG.md +19 -0
- package/Instructions_for_agents.md +89 -0
- package/README.md +8 -8
- package/assets/hero.png +0 -0
- package/dist/agent-core.d.ts +2 -2
- package/dist/agent-core.js +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +4 -4
- package/dist/agentic-mermaid-mcp.js +5 -5
- package/dist/am.js +8 -15
- package/dist/{chunk-QKDLMOJJ.js → chunk-2P5FKUQC.js} +7 -9
- package/dist/{chunk-WN3YDOBG.js → chunk-2S3VSS6I.js} +4 -4
- package/dist/{chunk-CDPKJ2BQ.js → chunk-2SILJDW2.js} +2 -2
- package/dist/{chunk-ZYMMKQ3I.js → chunk-BJYMBT4I.js} +299 -973
- package/dist/{chunk-WI35L7IR.js → chunk-FDM43XU7.js} +2 -2
- package/dist/{chunk-4QECACIA.js → chunk-MYPDVZCO.js} +19 -19
- package/dist/{index-D54dqSdC.d.ts → index-DWPa2MJs.d.ts} +7 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp-cli-5J47WEY3.js +17 -0
- package/docs/README.md +34 -34
- package/docs/agent-api-cookbook.md +317 -0
- package/docs/agent-mutation-policy.md +104 -0
- package/docs/agent-workflow-examples.md +46 -0
- package/docs/api.md +418 -0
- package/docs/ascii.md +113 -0
- package/docs/code-mode-impact.md +214 -0
- package/docs/comparison.md +106 -0
- package/docs/computational-aesthetics-prototype-plan.md +252 -0
- package/docs/config.md +121 -0
- package/docs/custom-fonts.md +265 -0
- package/docs/custom-style-cookbook.md +275 -0
- package/docs/diagram-families.md +218 -0
- package/docs/features.md +154 -0
- package/docs/fork-differences.md +133 -0
- package/docs/getting-started.md +182 -0
- package/docs/issue-derived-test-cases.md +163 -0
- package/docs/mcp-code-mode-rationale.md +108 -0
- package/docs/mcp-http-transport.md +230 -0
- package/docs/mermaid-layout-complaints.md +851 -0
- package/docs/mutation-testing.md +285 -0
- package/docs/quality.md +224 -0
- package/docs/react.md +97 -0
- package/docs/style-authoring.md +336 -0
- package/docs/svg-semantic-contract.md +49 -0
- package/docs/testing-strategy.md +443 -0
- package/docs/theming.md +149 -0
- package/package.json +21 -6
- package/server.json +2 -2
- package/skills/agentic-mermaid-live-editor/SKILL.md +1 -1
- package/dist/mcp-cli-SBQSTJFC.js +0 -17
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# Custom style cookbook
|
|
2
|
+
|
|
3
|
+
Custom styles are JSON files. Put the file under version control, pass it to
|
|
4
|
+
`--style`, and add a `seed` when you want reproducible sketch variation.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
am render diagram.mmd --format svg --style examples/styles/transit-route-map.style.json --seed 11 > diagram.svg
|
|
8
|
+
am render diagram.mmd --format png --style examples/styles/transit-route-map.style.json --seed 11 --output diagram.png
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The schema is published in this repo as
|
|
12
|
+
[`docs/schemas/style-spec.schema.json`](./schemas/style-spec.schema.json) and
|
|
13
|
+
from the package as `agentic-mermaid/style-spec.schema.json`. Example files use
|
|
14
|
+
`$schema` so editors can offer field completion. The renderer ignores that
|
|
15
|
+
field.
|
|
16
|
+
|
|
17
|
+
Runtime validation still matters. A schema catches the file shape; the renderer
|
|
18
|
+
uses `validateStyleSpec` before accepting untrusted records.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { readFileSync } from 'node:fs'
|
|
22
|
+
import { validateStyleSpec } from 'agentic-mermaid'
|
|
23
|
+
|
|
24
|
+
const style = JSON.parse(readFileSync('examples/styles/transit-route-map.style.json', 'utf8'))
|
|
25
|
+
const problems = validateStyleSpec(style)
|
|
26
|
+
if (problems.length) throw new Error(problems.join('\n'))
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The `font` field names a family; the output environment still has to provide
|
|
30
|
+
that face. See [Fonts in custom styles](./custom-fonts.md) for SVG behavior,
|
|
31
|
+
PNG `fontDirs`, system fonts, fallbacks, and browser usage.
|
|
32
|
+
|
|
33
|
+
## Public brand-inspired prototypes — documentation only
|
|
34
|
+
|
|
35
|
+
These three files are the highest supported non-built-in form of a Style probe:
|
|
36
|
+
version-controlled public `StyleSpec` records with schema validation, executable
|
|
37
|
+
fixtures, deterministic screenshot gates, strict rendering, inspect-only
|
|
38
|
+
constraints, and optional process-local registration. The reviewed image hashes
|
|
39
|
+
are pinned in
|
|
40
|
+
[`eval/style-prototype-evidence/visual-approval.json`](../eval/style-prototype-evidence/visual-approval.json).
|
|
41
|
+
They are not package-owned built-ins, installed BrandPacks, claims of pixel
|
|
42
|
+
equivalence, or endorsements.
|
|
43
|
+
|
|
44
|
+
### Cupertino-inspired prototype
|
|
45
|
+
|
|
46
|
+
Complete file:
|
|
47
|
+
[`examples/styles/cupertino-prototype.style.json`](../examples/styles/cupertino-prototype.style.json).
|
|
48
|
+
|
|
49
|
+
This is an implementation example, not a built-in Style. Agentic Mermaid ships
|
|
50
|
+
the opt-in file but does not register `cupertino`, give it a package-owned
|
|
51
|
+
runtime identity, expose it in a built-in catalog or picker, or retain a
|
|
52
|
+
registered short name. Load the JSON explicitly when you want to study or
|
|
53
|
+
adapt the prototype:
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
am render examples/styles/cupertino-prototype.mmd --format svg \
|
|
59
|
+
--style examples/styles/cupertino-prototype.style.json \
|
|
60
|
+
--options '{"shadow":true}' \
|
|
61
|
+
--output diagram.svg
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Library hosts can opt into a reusable name without creating a built-in registry
|
|
65
|
+
identity. Registration is explicit, process-local, and disposable:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { readFileSync } from 'node:fs'
|
|
69
|
+
import { registerStyle, renderMermaidSVG, validateStyleSpec } from 'agentic-mermaid'
|
|
70
|
+
|
|
71
|
+
const prototype = JSON.parse(
|
|
72
|
+
readFileSync('examples/styles/cupertino-prototype.style.json', 'utf8'),
|
|
73
|
+
)
|
|
74
|
+
const source = readFileSync('examples/styles/cupertino-prototype.mmd', 'utf8')
|
|
75
|
+
const problems = validateStyleSpec(prototype)
|
|
76
|
+
if (problems.length) throw new Error(problems.join('\n'))
|
|
77
|
+
|
|
78
|
+
const unregister = registerStyle(prototype)
|
|
79
|
+
try {
|
|
80
|
+
const svg = renderMermaidSVG(source, {
|
|
81
|
+
style: 'look:cupertino-prototype',
|
|
82
|
+
shadow: true,
|
|
83
|
+
})
|
|
84
|
+
} finally {
|
|
85
|
+
unregister()
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The public `StyleSpec` expresses the prototype's palette, font, weight-based
|
|
90
|
+
role typography, surface-first border policy, padding, geometry, and inspect-only
|
|
91
|
+
contrast/accent-area constraints. Its 10-unit node corners, 26-unit group
|
|
92
|
+
corners, and 16-unit connector bend radius make the intended Cupertino-inspired
|
|
93
|
+
curve discipline directly inspectable; `shadow` remains the shared render option
|
|
94
|
+
supplying elevation. The file still does not claim pixel equivalence with an
|
|
95
|
+
Apple interface: it uses bundled Inter rather than licensed SF Pro, has no
|
|
96
|
+
motion/spring system, and provides no designed dark companion.
|
|
97
|
+
|
|
98
|
+
Agentic Mermaid is independent of and not affiliated with Apple Inc.;
|
|
99
|
+
“Cupertino” describes the prototype's design inspiration, not an Apple product
|
|
100
|
+
or endorsed implementation.
|
|
101
|
+
|
|
102
|
+
### Vercel-inspired prototype
|
|
103
|
+
|
|
104
|
+
Complete file:
|
|
105
|
+
[`examples/styles/vercel-inspired-prototype.style.json`](../examples/styles/vercel-inspired-prototype.style.json).
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
am verify examples/styles/vercel-inspired-prototype.mmd \
|
|
111
|
+
--style examples/styles/vercel-inspired-prototype.style.json
|
|
112
|
+
am render examples/styles/vercel-inspired-prototype.mmd --format svg \
|
|
113
|
+
--style examples/styles/vercel-inspired-prototype.style.json > diagram.svg
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
This static prototype uses the public palette and role records for dark surfaces,
|
|
117
|
+
hairlines, compact typography, and restrained geometry. Its executable XYChart
|
|
118
|
+
fixture exercises `bar-0` and `line-0` category bindings through named semantic
|
|
119
|
+
slots; contrast and accent-area policy remains inspect-only. It deliberately
|
|
120
|
+
does not imitate Geist assets, Vercel motion, live application chrome, or a
|
|
121
|
+
complete product design system.
|
|
122
|
+
|
|
123
|
+
Agentic Mermaid is independent of and not affiliated with Vercel Inc.;
|
|
124
|
+
“Vercel-inspired” describes visual research, not a Vercel product or endorsed
|
|
125
|
+
implementation.
|
|
126
|
+
|
|
127
|
+
### Cloudflare Workers-inspired prototype
|
|
128
|
+
|
|
129
|
+
Complete file:
|
|
130
|
+
[`examples/styles/cloudflare-workers-inspired-prototype.style.json`](../examples/styles/cloudflare-workers-inspired-prototype.style.json).
|
|
131
|
+
|
|
132
|
+

|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
am verify examples/styles/cloudflare-workers-inspired-prototype.mmd \
|
|
136
|
+
--style examples/styles/cloudflare-workers-inspired-prototype.style.json
|
|
137
|
+
am render examples/styles/cloudflare-workers-inspired-prototype.mmd --format svg \
|
|
138
|
+
--style examples/styles/cloudflare-workers-inspired-prototype.style.json > diagram.svg
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This static prototype combines warm surface tokens, sans/mono role typography,
|
|
142
|
+
Gantt section-category bindings, and visible `outline`/`pattern` cues. The cues
|
|
143
|
+
survive no-color terminal projection where that family supports them; contrast
|
|
144
|
+
and accent-area rules diagnose without repainting. It does not reproduce
|
|
145
|
+
Cloudflare application chrome, motion, tinted multi-layer shadow systems, or a
|
|
146
|
+
complete Workers design system.
|
|
147
|
+
|
|
148
|
+
Agentic Mermaid is independent of and not affiliated with Cloudflare, Inc.;
|
|
149
|
+
“Cloudflare Workers-inspired” describes visual research, not a Cloudflare
|
|
150
|
+
product or endorsed implementation.
|
|
151
|
+
|
|
152
|
+
## Transit route map
|
|
153
|
+
|
|
154
|
+
Complete file:
|
|
155
|
+
[`examples/styles/transit-route-map.style.json`](../examples/styles/transit-route-map.style.json).
|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
This style is a good route-map example because it stresses brand colors and
|
|
160
|
+
connector weight. It also shows the current limit: JSON styles can set a
|
|
161
|
+
route-map palette, but they cannot yet assign stable route colors or station-dot
|
|
162
|
+
glyphs per path.
|
|
163
|
+
|
|
164
|
+
Use it when you want to test whether a style keeps connectors readable:
|
|
165
|
+
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"$schema": "https://agentic-mermaid.dev/schemas/style-spec.schema.json",
|
|
169
|
+
"name": "look:transit-route-map",
|
|
170
|
+
"colors": {
|
|
171
|
+
"bg": "#fbfbf8",
|
|
172
|
+
"fg": "#171923",
|
|
173
|
+
"line": "#d22630",
|
|
174
|
+
"accent": "#0067a8",
|
|
175
|
+
"surface": "#ffffff"
|
|
176
|
+
},
|
|
177
|
+
"font": "DejaVu Sans",
|
|
178
|
+
"stroke": "crisp",
|
|
179
|
+
"strokeWidth": 4
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Mid-century report
|
|
184
|
+
|
|
185
|
+
Complete file:
|
|
186
|
+
[`examples/styles/mid-century-report.style.json`](../examples/styles/mid-century-report.style.json).
|
|
187
|
+
|
|
188
|
+

|
|
189
|
+
|
|
190
|
+
This is the easiest uncovered cluster to teach with today's StyleSpec. It is
|
|
191
|
+
mostly palette, typography, and page treatment. No new backend capability is
|
|
192
|
+
needed.
|
|
193
|
+
|
|
194
|
+
Use it when you want a report figure with visible section bands and square
|
|
195
|
+
technical connectors:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"$schema": "https://agentic-mermaid.dev/schemas/style-spec.schema.json",
|
|
200
|
+
"name": "look:mid-century-report",
|
|
201
|
+
"colors": {
|
|
202
|
+
"bg": "#f4ead8",
|
|
203
|
+
"fg": "#24211d",
|
|
204
|
+
"line": "#2f4858",
|
|
205
|
+
"accent": "#d49a2a",
|
|
206
|
+
"surface": "#78a69b"
|
|
207
|
+
},
|
|
208
|
+
"font": "DejaVu Sans",
|
|
209
|
+
"stroke": "crisp",
|
|
210
|
+
"strokeWidth": 1.6
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Star chart atlas
|
|
215
|
+
|
|
216
|
+
Complete file:
|
|
217
|
+
[`examples/styles/star-chart-atlas.style.json`](../examples/styles/star-chart-atlas.style.json).
|
|
218
|
+
|
|
219
|
+

|
|
220
|
+
|
|
221
|
+
This example exercises the page axis: dark host, grid backdrop, pale strokes,
|
|
222
|
+
serif labels, and lightly rough geometry. It is useful because it reveals
|
|
223
|
+
hard-coded light fills quickly.
|
|
224
|
+
|
|
225
|
+
Use it when you need a dark page style that still keeps labels readable:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"$schema": "https://agentic-mermaid.dev/schemas/style-spec.schema.json",
|
|
230
|
+
"name": "look:star-chart-atlas",
|
|
231
|
+
"colors": {
|
|
232
|
+
"bg": "#0b1026",
|
|
233
|
+
"fg": "#ece4c4",
|
|
234
|
+
"line": "#8a96c0",
|
|
235
|
+
"accent": "#f0d98a",
|
|
236
|
+
"surface": "#101733"
|
|
237
|
+
},
|
|
238
|
+
"font": "EB Garamond",
|
|
239
|
+
"stroke": "jittered",
|
|
240
|
+
"roughness": 0.35,
|
|
241
|
+
"fill": "none",
|
|
242
|
+
"backdrop": "grid"
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Which uncovered clusters belong in guides
|
|
247
|
+
|
|
248
|
+
Three clusters make good cookbook examples now:
|
|
249
|
+
|
|
250
|
+
- **Transit/route-map semantics.** It teaches thick connector palettes and the
|
|
251
|
+
difference between a global palette and a true route identity system.
|
|
252
|
+
- **Retro editorial palettes.** Bauhaus, mid-century, and report figures fit
|
|
253
|
+
the current fields well: color tokens, solid fills, and typography.
|
|
254
|
+
- **Star-chart/page treatments.** Dark pages and grid backdrops test whether
|
|
255
|
+
every family routes text and strokes through style tokens.
|
|
256
|
+
|
|
257
|
+
Three clusters should wait for new capabilities:
|
|
258
|
+
|
|
259
|
+
- **Stained glass, ukiyo-e, and codex.** They need material backdrops, spot
|
|
260
|
+
palettes, and stronger fill texture rules than the public JSON fields expose.
|
|
261
|
+
- **Glass, CRT amber, and neon arcade.** They need compositor/filter fields:
|
|
262
|
+
glow, blur, translucent panels, and static-export fallbacks.
|
|
263
|
+
- **Graffiti or spray paint.** They need spray, overspray, layered text
|
|
264
|
+
outlines, and drip/splatter operators before the result is more than a bright
|
|
265
|
+
marker style.
|
|
266
|
+
|
|
267
|
+
## Regenerate the screenshots
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
bun run scripts/docs/custom-style-cookbook.ts
|
|
271
|
+
bun run scripts/docs/custom-style-cookbook.ts --check
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
The generator renders the same flowchart through each JSON file. If a
|
|
275
|
+
screenshot changes, inspect it before committing the new PNG.
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Diagram families
|
|
2
|
+
|
|
3
|
+
Agentic Mermaid supports Mermaid's common diagram families through a split pipeline: parse source, layout typed structures, render SVG/PNG/ASCII, and verify structural warnings.
|
|
4
|
+
|
|
5
|
+
## Capability authority
|
|
6
|
+
|
|
7
|
+
The checked roster and per-family capability states are generated from `FamilyDescriptor` in the [Section A capability report](./project/section-a-capability-report.md). Agents can discover the live roster and operation shapes through `am capabilities --json`; its compact Section A summary links to the exhaustive audit. Library and Code Mode callers can use `describeOps(family)` for the exact mutation schema. This guide keeps examples and family-specific caveats, not a second inventory.
|
|
8
|
+
|
|
9
|
+
Opaque fallback does not mean unsupported: those bodies parse, render, verify, and round-trip losslessly, but agents should edit preserved source deliberately instead of calling `mutate`.
|
|
10
|
+
|
|
11
|
+
## Flowchart
|
|
12
|
+
|
|
13
|
+
```mermaid
|
|
14
|
+
flowchart TD
|
|
15
|
+
API --> DB
|
|
16
|
+
API --> Cache
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Structured ops include node and edge add/remove/rename/set-label operations. Use `asFlowchart(parsed.value)` before mutation.
|
|
20
|
+
|
|
21
|
+
## State
|
|
22
|
+
|
|
23
|
+
```mermaid
|
|
24
|
+
stateDiagram-v2
|
|
25
|
+
[*] --> Idle
|
|
26
|
+
Idle --> Running
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
State diagrams own a dedicated `StateBody`: narrow with `asState`. States, transitions, start/end, composites, concurrency regions, fork/join/choice and history pseudostates, notes, declarations, direction, and paint are modeled. Use `describeOps('state')` for the current mutation schema; malformed or otherwise unmodeled syntax falls back losslessly and stays source-level. Verify runs the full Tier 1 + Tier 2 geometric path by projecting the body to a graph.
|
|
30
|
+
|
|
31
|
+
## Sequence
|
|
32
|
+
|
|
33
|
+
```mermaid
|
|
34
|
+
sequenceDiagram
|
|
35
|
+
participant User
|
|
36
|
+
participant API
|
|
37
|
+
User->>API: Login
|
|
38
|
+
API-->>User: Session
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Participants and messages are structured. Rich statements such as notes, `alt`, `loop`, and activation syntax remain ordered verbatim segments while participant/message operations stay live; only un-segmentable input falls back to a whole opaque body.
|
|
42
|
+
|
|
43
|
+
## Timeline
|
|
44
|
+
|
|
45
|
+
```mermaid
|
|
46
|
+
timeline
|
|
47
|
+
title Release plan
|
|
48
|
+
section Build
|
|
49
|
+
Parser : complete
|
|
50
|
+
Renderer : polish
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Structured ops cover title, section, period, and event changes.
|
|
54
|
+
|
|
55
|
+
## Class
|
|
56
|
+
|
|
57
|
+
```mermaid
|
|
58
|
+
classDiagram
|
|
59
|
+
class User {
|
|
60
|
+
+string id
|
|
61
|
+
+login()
|
|
62
|
+
}
|
|
63
|
+
User --> Session
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Structured ops cover classes, members, relations, notes, and renames.
|
|
67
|
+
|
|
68
|
+
## ER
|
|
69
|
+
|
|
70
|
+
```mermaid
|
|
71
|
+
erDiagram
|
|
72
|
+
CUSTOMER ||--o{ ORDER : places
|
|
73
|
+
ORDER ||--|{ LINE_ITEM : contains
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Structured ops cover entities, attributes, relation add/remove, and renames.
|
|
77
|
+
|
|
78
|
+
## Journey
|
|
79
|
+
|
|
80
|
+
```mermaid
|
|
81
|
+
journey
|
|
82
|
+
title Checkout
|
|
83
|
+
section Cart
|
|
84
|
+
Add item: 5: Customer
|
|
85
|
+
Pay: 3: Customer, Gateway
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Journey diagrams narrow via `asJourney`; discover the exact section, task, score, actor, ordering, and accessibility operation schema with `describeOps('journey')`. Documented Mermaid accessibility directives (`accTitle`, inline `accDescr`, and block `accDescr { ... }`) stay structured and round-trip through canonical serialization. Malformed or unknown Journey syntax falls back to a lossless opaque body.
|
|
89
|
+
|
|
90
|
+
SVG rendering uses Mermaid's left-to-right Journey metaphor rather than the older Agentic card layout: sections span task columns, actors appear in a left legend, per-task actor dots show participation, and scores map to sentiment markers on a progression baseline. Mermaid `journey` config fields for actor colors, section fills/text colors, task/title fonts, task spacing, and actor label width are honored. Agentic Mermaid `style` and palette colors also reach Journey-specific surfaces such as section spans, actor dots, score markers, and the baseline.
|
|
91
|
+
|
|
92
|
+
## XY chart
|
|
93
|
+
|
|
94
|
+
```mermaid
|
|
95
|
+
xychart-beta
|
|
96
|
+
title "Latency"
|
|
97
|
+
x-axis [p50, p95, p99]
|
|
98
|
+
y-axis "ms" 0 --> 500
|
|
99
|
+
line [50, 180, 420]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The modeled title, axes, orientation, and bar/line series are structurally mutable through `asXyChart`; use `describeOps('xychart')` for the exact schema. Unmodeled or malformed syntax falls back losslessly and stays source-level. See [`design/families/xychart.md`](./design/families/xychart.md) for compatibility details and layout notes.
|
|
103
|
+
|
|
104
|
+
## Pie
|
|
105
|
+
|
|
106
|
+
```mermaid
|
|
107
|
+
pie showData
|
|
108
|
+
title Pets adopted by volunteers
|
|
109
|
+
"Dogs" : 386
|
|
110
|
+
"Cats" : 85
|
|
111
|
+
"Rats" : 15
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Pie charts accept the `pie` header with optional `showData`, an optional `title`, and `"label" : value` entries with positive numeric values. Slices render clockwise in source order. `showData` adds the raw value beside each legend label; the legend always shows the computed percentage. Malformed entries (negative/zero values, missing colon, unquoted labels) fall back to a lossless opaque body — never silently dropped — and the renderer still surfaces the loud error at render time. The ASCII renderer draws a proportional bar list. Pie is structured when narrowed through `asPie`; slices are addressed by their unique label. The operation schema is generated from the registry rather than duplicated here.
|
|
115
|
+
|
|
116
|
+
## Quadrant
|
|
117
|
+
|
|
118
|
+
```mermaid
|
|
119
|
+
quadrantChart
|
|
120
|
+
title Reach and engagement of campaigns
|
|
121
|
+
x-axis Low Reach --> High Reach
|
|
122
|
+
y-axis Low Engagement --> High Engagement
|
|
123
|
+
quadrant-1 We should expand
|
|
124
|
+
quadrant-2 Need to promote
|
|
125
|
+
quadrant-3 Re-evaluate
|
|
126
|
+
quadrant-4 May be improved
|
|
127
|
+
Campaign A: [0.3, 0.6]
|
|
128
|
+
Campaign B: [0.45, 0.23]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Quadrant charts accept the `quadrantChart` header, an optional `title`, `x-axis <left> --> <right>` and `y-axis <bottom> --> <top>` axis labels (the far side is optional), four `quadrant-1..quadrant-4 <label>` region labels, and `<Label>: [x, y]` points with coordinates in `[0, 1]`. Quadrant numbering follows Mermaid core: **1 = top-right, 2 = top-left, 3 = bottom-left, 4 = bottom-right**. The SVG renderer draws a square plot split into four theme-tinted quadrants with the points as circles; the ASCII renderer draws a bordered grid with a coordinate legend. Official point style metadata (`radius`, `color`, `stroke-color`, `stroke-width`), `classDef` lines, and class assignments are modeled for rendering and typed mutation. Malformed lines — out-of-range/non-numeric coordinates, missing brackets, duplicate point labels, and unknown point style metadata — fall back to a lossless opaque body, never silently dropped, and the renderer still surfaces the loud error at render time. Quadrant is structured when narrowed through `asQuadrant`; points are addressed by their unique label and coordinates stay in `[0, 1]`. The operation schema is generated from the registry rather than duplicated here.
|
|
132
|
+
|
|
133
|
+
## Radar
|
|
134
|
+
|
|
135
|
+
```mermaid
|
|
136
|
+
radar-beta
|
|
137
|
+
title Skills
|
|
138
|
+
axis speed["Speed"], power["Power"], range["Range"]
|
|
139
|
+
curve now["Current"]{4, 3, 5}
|
|
140
|
+
curve goal["Target"]{5, 5, 4}
|
|
141
|
+
max 5
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Radar (spider) chart — multivariate profiles compared across equi-angular axes from a shared center; one closed translucent area per entity. The `radar-beta` header takes an optional `title`, `axis <id>["Label"], …` declarations, one `curve <id>["Label"]{v1, v2, …}` per entity (one value per axis, in axis order), and optional `max`/`min`/config lines. The SVG renderer draws the axis spokes, concentric grid, and per-curve polygons; the ASCII renderer draws a grouped proportional-bar table like pie. Malformed lines fall back to a lossless opaque body, never silently dropped. Radar is structured when narrowed through `asRadar`; axes and curves are addressed by their unique id. The operation schema is generated from the registry rather than duplicated here.
|
|
145
|
+
|
|
146
|
+
## Gantt
|
|
147
|
+
|
|
148
|
+
```mermaid
|
|
149
|
+
gantt
|
|
150
|
+
title A Gantt Diagram
|
|
151
|
+
dateFormat YYYY-MM-DD
|
|
152
|
+
excludes weekends
|
|
153
|
+
section Section
|
|
154
|
+
A task :a1, 2014-01-01, 30d
|
|
155
|
+
Another task :after a1, 20d
|
|
156
|
+
section Another
|
|
157
|
+
Task in Another :2014-01-12, 12d
|
|
158
|
+
another task :24d
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Gantt charts accept the `gantt` header, `title`, calendar directives (`dateFormat`, `axisFormat`, `tickInterval`, `inclusiveEndDates`, `topAxis`, multiple `excludes`/`includes` lines, `weekend friday|saturday`, `weekday <day>`, `todayMarker`), `section` lines, and task lines `Label :[tags,] [id,] [start,] end` where tags are `active`/`done`/`crit`/`milestone`/`vert`, start is a date or `after id…`, and end is a date, a duration token (`ms s m h d w M y`, decimals allowed), or `until id…`. Dependencies resolve in a pure scheduler ([design/families/gantt.md](./design/families/gantt.md)): `after` starts at the latest referenced end, `until` ends at the earliest referenced start, working durations extend over excluded days, `includes` overrides `excludes`, and dependency cycles / unknown references / invalid dates are named structured errors (`GANTT_*`), never wall-clock fallbacks. Rendering is deterministic: the `todayMarker` draws only when the caller passes `ganttToday` (a date in the diagram's `dateFormat`), and `todayMarker off` always wins. `displayMode: compact` (frontmatter or `config.gantt`) packs non-overlapping tasks of a section into shared rows; `vert` markers draw a full-height line without consuming a task row. `click … href` is sanitized under strict security and `click … call` is parsed but never executed. Gantt is structured when narrowed and segment-preserving: `asGantt` edits title/sections/tasks while calendar directives, click lines, and comments ride along verbatim as opaque segments; duplicate task ids or an unclosed `accDescr` block fall back to a lossless whole-opaque body.
|
|
162
|
+
|
|
163
|
+
## Mindmap
|
|
164
|
+
|
|
165
|
+
```mermaid
|
|
166
|
+
mindmap
|
|
167
|
+
root((Product))
|
|
168
|
+
Research
|
|
169
|
+
Evidence
|
|
170
|
+
Delivery
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Mindmap uses indentation for parentage and supports Mermaid node shapes, `::icon(...)`, `:::class`, accessibility directives, deterministic tree layout, and structured mutation through `asMindmap`. Duplicate semantic ids are rejected. Use `describeOps('mindmap')` for the exact operation schema; see [`design/families/mindmap.md`](./design/families/mindmap.md).
|
|
174
|
+
|
|
175
|
+
## GitGraph
|
|
176
|
+
|
|
177
|
+
```mermaid
|
|
178
|
+
gitGraph
|
|
179
|
+
commit id:"base"
|
|
180
|
+
branch feature
|
|
181
|
+
commit id:"work"
|
|
182
|
+
checkout main
|
|
183
|
+
merge feature id:"merge"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
GitGraph replays commits and branch movement in source order and exposes structured mutation through `asGitGraph`. Generated ids are deterministic `c<N>` values and duplicate custom ids are rejected. Use `describeOps('gitgraph')` for the exact operation schema; see [`design/families/gitgraph.md`](./design/families/gitgraph.md).
|
|
187
|
+
|
|
188
|
+
## Architecture
|
|
189
|
+
|
|
190
|
+
```mermaid
|
|
191
|
+
architecture-beta
|
|
192
|
+
group api(cloud)[API]
|
|
193
|
+
service web(server)[Web] in api
|
|
194
|
+
service db(database)[DB]
|
|
195
|
+
web:R --> L:db
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
See [`design/families/architecture-beta.md`](./design/families/architecture-beta.md) for parser/layout/render notes.
|
|
199
|
+
|
|
200
|
+
## Output formats
|
|
201
|
+
|
|
202
|
+
All families use the same public output paths:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { renderMermaidSVG, renderMermaidPNG, renderMermaidASCII } from 'agentic-mermaid/agent'
|
|
206
|
+
|
|
207
|
+
const svg = renderMermaidSVG(source, { security: 'strict' })
|
|
208
|
+
const png = renderMermaidPNG(source, { fitTo: { width: 1200 }, background: '#fff' })
|
|
209
|
+
const text = renderMermaidASCII(source)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
CLI equivalents:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
am render diagram.mmd --format svg > diagram.svg
|
|
216
|
+
am render diagram.mmd --format png --output diagram.png
|
|
217
|
+
am render diagram.mmd --format ascii > diagram.txt
|
|
218
|
+
```
|
package/docs/features.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
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`; 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
|
+
|
|
5
|
+
## Core IR & editing loop
|
|
6
|
+
|
|
7
|
+
- **Typed `ValidDiagram` IR** — parse Mermaid into a sealed, typed value.
|
|
8
|
+
- **`parseRegisteredMermaid(source)`** → `Result<ValidDiagram, ParseError[]>`. Never
|
|
9
|
+
throws on malformed input; structured errors.
|
|
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.
|
|
16
|
+
- **`serializeMermaid(d)`** — back to canonical source.
|
|
17
|
+
- **Round-trip** — structured bodies serialize to canonical, idempotent
|
|
18
|
+
source; opaque bodies preserve original indentation/comments verbatim.
|
|
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).
|
|
34
|
+
|
|
35
|
+
**Structured-or-opaque rule:** every family either has a structured body
|
|
36
|
+
or preserves source verbatim. Constructs are never silently dropped.
|
|
37
|
+
|
|
38
|
+
## Output formats
|
|
39
|
+
|
|
40
|
+
Agentic Mermaid outputs **SVG, PNG, ASCII, Unicode, and JSON layout** from the same renderer foundation.
|
|
41
|
+
|
|
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
|
|
45
|
+
(`{ style: ['hand-drawn', 'dracula'] }`). `seed` re-rolls styled ink and
|
|
46
|
+
never moves layout. CLI: `am render --style … --seed N`, `am styles`;
|
|
47
|
+
MCP render tools take `style`/`seed`; RENDER_FAILED-gated verify means a
|
|
48
|
+
clean verify proves the styled source renders. Authoring guide, schema, and
|
|
49
|
+
cookbook: `docs/style-authoring.md`, `docs/schemas/style-spec.schema.json`,
|
|
50
|
+
and `docs/custom-style-cookbook.md`. Custom font selection and resolution:
|
|
51
|
+
`docs/custom-fonts.md`.
|
|
52
|
+
|
|
53
|
+
- **SVG** — `renderMermaidSVG` (`compact`, `security:'strict'`, CSS
|
|
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 }`
|
|
69
|
+
for TUI click-mapping.
|
|
70
|
+
- **Reverse** — `asciiToMermaid` reconstructs flowchart source from ASCII
|
|
71
|
+
(best-effort, lossy, structural round-trip).
|
|
72
|
+
|
|
73
|
+
## Verification tiers
|
|
74
|
+
|
|
75
|
+
- **Tier 1 (structural, universal):** EMPTY_DIAGRAM, EDGE_MISANCHORED,
|
|
76
|
+
OFF_CANVAS, GROUP_BREACH, UNKNOWN_SHAPE, LABEL_OVERFLOW, UNRESOLVABLE_SCHEDULE,
|
|
77
|
+
RENDER_FAILED (a clean verify proves the source actually renders).
|
|
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`.
|
|
80
|
+
- **Perceptual quality** — `measureQuality` / `checkQuality` (edge
|
|
81
|
+
crossings, label legibility, whitespace balance, …). See [`quality.md`](./quality.md).
|
|
82
|
+
|
|
83
|
+
## Accessibility
|
|
84
|
+
|
|
85
|
+
- `accTitle`→`<title>`, `accDescr`→`<desc>`, `role="img"`, `aria-labelledby`.
|
|
86
|
+
- **AX tree** — `describeMermaid(d, {format:'json'})` → `{nodes, edges,
|
|
87
|
+
entryPoints, sinks}`; prose summary in `{format:'text'}`.
|
|
88
|
+
- Auto-contrast node text on custom fills (WCAG luminance).
|
|
89
|
+
- External CSS class emission (Mermaid `classDef` assignments → SVG classes).
|
|
90
|
+
|
|
91
|
+
## Security
|
|
92
|
+
|
|
93
|
+
- **Strict mode** (`security:'strict'`) — zero external-fetch references in
|
|
94
|
+
the SVG (no Google Fonts `@import`) after one shared transform plus residual
|
|
95
|
+
verification policy.
|
|
96
|
+
- **`verifyNoExternalRefs(svg)`** — scanner / CI gate / agent self-check.
|
|
97
|
+
- No `<image>`/`<script>`/external-href injection; click directives
|
|
98
|
+
sanitized. See [`../SECURITY.md`](../SECURITY.md).
|
|
99
|
+
|
|
100
|
+
## CLI (`am`)
|
|
101
|
+
|
|
102
|
+
`render` (svg/ascii/unicode/json with multi-input results; png uses one
|
|
103
|
+
input plus `--output`; `--security strict`, `--watch`), `render-markdown` (skip bad blocks),
|
|
104
|
+
`parse`, `verify`, `mutate` (`--op` or `--ops`), `preview` (strict standalone HTML + optional `--open`), `format`, `describe` (text/json),
|
|
105
|
+
`capabilities --json` (including `families[].editPolicy`,
|
|
106
|
+
`families[].mutationOps`, and the machine-readable `sectionA` contract matrix),
|
|
107
|
+
`batch --jsonl` (including mutate),
|
|
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.
|
|
109
|
+
Exit codes 0/2/3/4; parse and verify-failure errors include structured `error.details` arrays.
|
|
110
|
+
|
|
111
|
+
## MCP server
|
|
112
|
+
|
|
113
|
+
Local `agentic-mermaid-mcp` is Code Mode-first: `execute(code)` runs synchronous
|
|
114
|
+
JavaScript in a local `node:vm` sandbox with a typed `mermaid.*` SDK declaration,
|
|
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
|
|
118
|
+
HTTP/SSE via `agentic-mermaid-mcp --transport http`; local `render_png` can
|
|
119
|
+
return base64 bytes or managed file/URL artifacts with MIME type, byte count, and
|
|
120
|
+
SHA-256 metadata.
|
|
121
|
+
|
|
122
|
+
The hosted endpoint at `https://agentic-mermaid.dev/mcp` is stateless
|
|
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
|
|
126
|
+
structured edits. Hosted inputs are capped at 64 KB, PNG is base64-only, and the
|
|
127
|
+
endpoint is a convenience surface rather than a REST render API.
|
|
128
|
+
|
|
129
|
+
## Distribution
|
|
130
|
+
|
|
131
|
+
- npm library (`agentic-mermaid` and `agentic-mermaid/agent`) with Node-runnable bins (`am`, the package-runner alias `agentic-mermaid`, and `agentic-mermaid-mcp`).
|
|
132
|
+
- **Single binary** — `bun run build:binary` → `dist/am`, standalone
|
|
133
|
+
executable, no runtime dependency (#1018).
|
|
134
|
+
- **llms.txt** agent-discovery digest, derived from capabilities.
|
|
135
|
+
|
|
136
|
+
## Guarantees & evidence
|
|
137
|
+
|
|
138
|
+
- **Determinism** — byte-identical across repeated runs and processes for
|
|
139
|
+
SVG layout/ASCII; full-corpus ASCII repeated-run guard; cross-runtime guards
|
|
140
|
+
exist for bun ≡ node on same-machine x86_64/ARM64 when Node + built `dist/`
|
|
141
|
+
artifacts are present.
|
|
142
|
+
- **Corpus gates** — pinned Mermaid documentation and MermaidSeqBench corpora,
|
|
143
|
+
gated in CI; their manifests, rather than this prose, own current counts.
|
|
144
|
+
- **Benchmarks** — `eval/benchmark/RESULTS.md` (measured vs mmdc, termaid).
|
|
145
|
+
- **Agent-usage validation** — `eval/agent-usage/` scenarios,
|
|
146
|
+
anti-pattern linter, sandbox trace instrumentation, and stored Code Mode eval runner.
|
|
147
|
+
- **Unit, browser/e2e, typecheck, build, binary-build, eval, and lint gates**
|
|
148
|
+
are part of the verification contract.
|
|
149
|
+
|
|
150
|
+
## Not browser-dependent
|
|
151
|
+
|
|
152
|
+
The entire core (parse/verify/mutate/serialize/ASCII/PNG/SVG) runs with no
|
|
153
|
+
DOM, no headless browser, synchronously. This is the structural
|
|
154
|
+
differentiator vs Puppeteer-based Mermaid CLIs.
|