DocsReference
The CLI
The skill runs the CLI for you, and it works on its own too: give it a diagram.json and it checks it, lays it out and writes the viewer.
Run it
With Node 22.12 or later, nothing to install first:
npx @omsimos/stackmap@0.4.0 deliver diagram.jsonThe commands below call it stackmap; with npx it is npx @omsimos/stackmap@0.4.0.
validate
stackmap validate <diagram.json> [--json]
Checks the diagram and lists every problem with a code, where it is and the fixes it allows, including card text that won’t fit. It exits 1 when the diagram has errors; warnings alone exit 0.
$ stackmap validate .stackmap/commerce-api/diagram.jsonerror refs/unknown-node /edges/6/to Unknown node "orders-db" fix: use "orders" fix: add node "orders-db" or remove the edge✗ 1 error--json
The same diagnostics, for a program to read: each one has its code, severity, subject (a JSON pointer), message, evidence and allowed fixes.
{ "ok": false, "diagnostics": [ { "code": "refs/unknown-node", "severity": "error", "subject": "/edges/0/to", "message": "Unknown node \"orders-db\"", "evidence": { "id": "orders-db", "closest": [] }, "allowedFixes": [ "add node \"orders-db\" or remove the edge" ] }, { "code": "semantics/orphan-node", "severity": "warning", "subject": "/nodes/1", "message": "Node \"db\" has no connections", "evidence": { "id": "db" }, "allowedFixes": [ "add an edge to or from \"db\"", "remove the node" ] } ]}deliver
stackmap deliver <diagram.json> [-o out.html] [--open]
Validates, lays out and writes one offline HTML file, next to the input unless you pass -o. It refuses to overwrite its input. Delivery is deterministic: the same JSON always gives the same file, byte for byte, so the receipt’s hash is worth keeping. With --open it then opens the file in your default browser; the skill passes it, so a diagram opens as soon as the agent delivers it.
$ stackmap deliver .stackmap/commerce-api/diagram.jsondelivered .stackmap/commerce-api/diagram.html · sha256 0a6f2ce5f590380e62bfcc0b9ae1537dc7140ea14b83b5ca3556009aee7c11e1 · 500770 bytesThe receipt is the only thing on stdout. Warnings go to stderr; with errors, nothing is written and the command exits 1.
serve
stackmap serve <diagram.json> [--port 4400]
A live viewer that reloads whenever the file changes, for editing a diagram by hand or watching an agent work. It binds 127.0.0.1 only and takes the next free port when 4400 is taken. When a save is invalid it keeps the last good version on screen, and it keeps your camera and selection across reloads.
$ stackmap serve diagram.jsonserving http://127.0.0.1:4400 · watching diagram.json · Ctrl-C to stop✓ diagram.json ready✗ diagram.json: 1 error; keeping the last good version✓ diagram.json reloadedOptions
| Option | For | Does |
|---|---|---|
--json | validate | Machine-readable diagnostics |
-o, --out | deliver | The output path; the default is next to the input, as .html |
--open | deliver | Open the written viewer in the default browser; when none opens, it warns and still exits 0 |
--port | serve | The port; 4400 by default, and the next free one if it is taken |
-h, --help | any | Show the help |
-v, --version | any | Show the version |
Diagnostics
Every diagnostic has the same shape, so an agent can act on it without guessing:
- Severity
errorblocks delivery;warningdoesn’t.- Code
<family>/<rule>: schema, refs, semantics or card-fit.- Subject
- A JSON pointer to the value at fault.
- Fixes
- The repairs it allows. The agent applies one, and only what is named.
The JSON doesn’t match the schema: a wrong type, a value outside an enum, an unknown key. The code is the schema check that failed.
$ stackmap validate diagram.jsonerror schema/invalid_value /nodes/1/type Invalid option: expected one of "client"|"service"|"gateway"|"database"|"cache"|"queue"|"storage"|"external"|"security"|"start"|"active"|"waiting"|"decision"|"success"|"failure"|"neutral" fix: use one of: client, service, gateway, database, cache, queue, storage, external, security, start, active, waiting, decision, success, failure, neutral✗ 1 errorAn id points at nothing: a connection to a node that doesn’t exist, a group, lane, view or phase member that isn’t there. The fix names the closest id when there is one.
$ stackmap validate diagram.jsonerror refs/unknown-node /edges/6/to Unknown node "orders-db" fix: use "orders" fix: add node "orders-db" or remove the edge✗ 1 errorValid, but not what the kind expects or a reader can use: an orphan node, an empty view, lanes on an architecture. Most are warnings.
$ stackmap validate diagram.jsonwarning semantics/orphan-node /nodes/11 Node "audit" has no connections fix: add an edge to or from "audit" fix: remove the node✓ valid with 1 warningText that won’t fit its slot, measured with the real font. Text never wraps, so this is an error, with the exact number of characters that fit.
$ stackmap validate diagram.jsonerror card-fit/overflow /nodes/0/card/subtitle "REST API for the storefront, admin and partner apps" is 297px wide; this slot fits 200px (~35 characters) fix: shorten to at most 35 characters fix: move the detail into a card row✗ 1 errorDiagnostic codes
Every code validate can report. Schema codes are named after the check that failed.
schema
schema/invalid-jsonschema/invalid_typeschema/invalid_valueschema/too_bigschema/too_smallschema/invalid_formatschema/unrecognized_keys
refs
refs/unknown-grouprefs/group-cyclerefs/unknown-brandrefs/unknown-lanerefs/unknown-phase-noderefs/unknown-phase-edgerefs/unknown-noderefs/unknown-view-node
semantics
semantics/duplicate-idsemantics/duplicate-row-labelsemantics/hidden-stats-notesemantics/large-diagramsemantics/orphan-nodesemantics/self-loopsemantics/parallel-edgesemantics/dataflow-cyclesemantics/empty-viewsemantics/empty-groupsemantics/type-for-kindsemantics/missing-lanesemantics/lane-for-kindsemantics/card-section-for-kindsemantics/tag-for-kindsemantics/density-ignoredsemantics/too-many-for-kindsemantics/missing-lanessemantics/lanes-for-kindsemantics/empty-lanesemantics/direction-ignoredsemantics/groups-for-kindsemantics/nested-group-for-kindsemantics/group-spans-lanessemantics/unmatched-returnsemantics/phase-gapsemantics/phase-overlapsemantics/phase-memberssemantics/phase-member-in-groupsemantics/unphased-nodesemantics/phase-ordersemantics/group-not-contiguous
card-fit
card-fit/overflow
Exit codes
| Code | Means |
|---|---|
0 | OK. Warnings are allowed. |
1 | The diagram has errors. This is the one the agent’s repair loop acts on. |
2 | A usage, file or internal error. Never a stack trace. |