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.json

The 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 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.

stackmap validate diagram.json --jsonstdout
{  "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 deliver .stackmap/commerce-api/diagram.jsondelivered .stackmap/commerce-api/diagram.html · sha256 0a6f2ce5f590380e62bfcc0b9ae1537dc7140ea14b83b5ca3556009aee7c11e1 · 500770 bytes

The 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
$ 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 reloaded

Options

OptionForDoes
--jsonvalidateMachine-readable diagnostics
-o, --outdeliverThe output path; the default is next to the input, as .html
--opendeliverOpen the written viewer in the default browser; when none opens, it warns and still exits 0
--portserveThe port; 4400 by default, and the next free one if it is taken
-h, --helpanyShow the help
-v, --versionanyShow the version

Diagnostics

Every diagnostic has the same shape, so an agent can act on it without guessing:

error refs/unknown-node /edges/6/to
Unknown node "orders-db"
fix: use "orders"
fix: add node "orders-db" or remove the edge
Severity
error blocks delivery; warning doesn’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.json
$ 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 error

Diagnostic codes

Every code validate can report. Schema codes are named after the check that failed.

schema

  • schema/invalid-json
  • schema/invalid_type
  • schema/invalid_value
  • schema/too_big
  • schema/too_small
  • schema/invalid_format
  • schema/unrecognized_keys

refs

  • refs/unknown-group
  • refs/group-cycle
  • refs/unknown-brand
  • refs/unknown-lane
  • refs/unknown-phase-node
  • refs/unknown-phase-edge
  • refs/unknown-node
  • refs/unknown-view-node

semantics

  • semantics/duplicate-id
  • semantics/duplicate-row-label
  • semantics/hidden-stats-note
  • semantics/large-diagram
  • semantics/orphan-node
  • semantics/self-loop
  • semantics/parallel-edge
  • semantics/dataflow-cycle
  • semantics/empty-view
  • semantics/empty-group
  • semantics/type-for-kind
  • semantics/missing-lane
  • semantics/lane-for-kind
  • semantics/card-section-for-kind
  • semantics/tag-for-kind
  • semantics/density-ignored
  • semantics/too-many-for-kind
  • semantics/missing-lanes
  • semantics/lanes-for-kind
  • semantics/empty-lane
  • semantics/direction-ignored
  • semantics/groups-for-kind
  • semantics/nested-group-for-kind
  • semantics/group-spans-lanes
  • semantics/unmatched-return
  • semantics/phase-gap
  • semantics/phase-overlap
  • semantics/phase-members
  • semantics/phase-member-in-group
  • semantics/unphased-node
  • semantics/phase-order
  • semantics/group-not-contiguous

card-fit

  • card-fit/overflow

Exit codes

CodeMeans
0OK. Warnings are allowed.
1The diagram has errors. This is the one the agent’s repair loop acts on.
2A usage, file or internal error. Never a stack trace.