docslothregistry

mermaid

Mermaid diagram source kept readable for agents

interactive 1.0.0 Apache-2.0

Install

docsloth component add @docsloth/mermaid@1.0.0 \
  --registry https://registry.docsloth.dev

Run it in a project that has a docsloth.config.json (docsloth init writes one). The docsloth CLI is not on npm yet: it runs from a checkout of the Docsloth engine, and the quickstart shows the setup. Every official component already renders in Docsloth sites; installing one vendors its props schema and specification and pins this exact version and digest.

What the CLI checks

docsloth component add reads this entry from index.json, recomputes the package digest from the manifest and the digest of every file, and writes nothing if one differs.

index.json, lines 583–600
583    {584      "name": "@docsloth/mermaid",585      "version": "1.0.0",586      "kind": "block",587      "description": "Mermaid diagram source kept readable for agents",588      "license": "Apache-2.0",589      "engine": ">=1 <2",590      "publisher": "docsloth",591      "digest": "sha256:96b5e8ca9f6f9073fe60f842a095787824b89447f9314189b83d5505133d7a88",592      "blocks": [593        "mermaid"594      ],595      "capabilities": [596        "render.html"597      ],598      "manifest_path": "packages/@docsloth/mermaid/1.0.0/manifest.json",599      "files_base": "packages/@docsloth/mermaid/1.0.0/files"600    },

Trust signals

Runtime trust class (catalog)
interactive. Responds to the reader inside the page, such as switching tabs or filtering, with no network access and no secrets.
Install trust class
interactive, derived from the declared render.html. This is the class docsloth component add and docsloth component list report; it installs under the default policy, with no trust policy.
Package
@docsloth/mermaid, version 1.0.0
Package digest
sha256:96b5e8ca9f6f9073fe60f842a095787824b89447f9314189b83d5505133d7a88
Files
2 files, each pinned by its own sha256 digest (listed under Package files)
Capabilities declared
render.html. A declaration, never a grant; every official package declares the same.
Publisher
docsloth, a publisher id rather than a verified identity
Licence
Apache-2.0
Engine range
>=1 <2
Index signature
Not signed. Digests prove the bytes match the index, not who published them.
Tools
copy
Built from
packages/contracts/component-props/mermaid.schema.json and packages/contracts/component-specs/mermaid.md in docsloth-registry

Props

The props schema is packages/contracts/component-props/mermaid.schema.json; props it does not list are rejected.

PropTypeRequiredNotes
codestringyesmaxLength: 100000

Required: code.

Example props generated from the schema
{
  "code": "graph TD;\n  A[Start]-->B[Ship];"
}

Preview

Rendered by @docsloth/renderer from the example document block in the specification.

Document block
{
  "type": "mermaid",
  "props": {
    "code": "graph TD;\n  A[Start]-->B[Ship];"
  }
}
graph TD;
  A[Start]-->B[Ship];

This is the renderer's real HTML with this registry's styles. Links and controls in the preview are inactive.

Rendered HTML
<div class="ds-mermaid" data-component="mermaid">
<pre class="mermaid" data-ds-mermaid>graph TD;
  A[Start]-->B[Ship];</pre>
<button type="button" class="ds-mermaid-copy" data-ds-copy data-markdown-ignore="true" aria-label="Copy diagram source">Copy</button>
</div>

Specification

From packages/contracts/component-specs/mermaid.md.

Contract

Packaged: this block ships as @docsloth/mermaid@1.0.0 — an installable component package (kind block, capability render.html, Apache-2.0) whose production props schema is packages/contracts/component-props/mermaid.schema.json and whose catalog entry is in packages/contracts/component-catalog.json. No protocol manifest fixture is published (manifest_fixture: null): the fixture models a packaged protocol runtime this block does not have.

Intended behavior

Pass diagram source through unchanged so a host-configured Mermaid renderer can draw it, while every reader still sees the source. HTML emits an inert <pre class="mermaid" data-ds-mermaid> whose text is the escaped source, plus a copy control. Markdown always emits the fenced mermaid code block, so agents never lose the diagram.

Failure and fallback

A missing or non-string code prop degrades the block to the labelled fallback. Hostile source is escaped in HTML and never becomes markup; a fenced copy survives verbatim in Markdown because fences are data, not page structure.

Required acceptance cases

No diagram renderer, network call or model call may run from the renderer; until a host renders it, the block must remain readable source. Source containing backticks or HTML must not break out of the fence or the <pre>. Also test empty data, loading, denied access, browser without JS, mobile 360px, keyboard navigation, dark mode and an explicit constrained agent tool call. The server independently authorizes capability requests; a package manifest cannot grant authority.

Data and maintenance

Data bindings resolve from a specific publication/release vector and permitted fact/evidence graph. Configuration edits create versioned component patches. Update invalidation uses dependency IDs, never indiscriminate whole-page regeneration. Human-owned props survive automatic updates unless invalidated with an explicit conflict. Missing optional resources leave an honest inert/readable fallback, not a broken page or fake success.

Cost and tools

Pure/local interaction must never invoke a model by accident. Any model, remote query or executor call must reserve approved budget before dispatch. Public visitors do not inherit owner resources. The component may call only named tools in its signed manifest with valid typed inputs. A cancelled job stops polling and closes resources. No component gets platform administration, raw credentials or an unlimited execution loop.

Native renderer block

packages/renderer renders a mermaid block from the document IR. HTML emits <pre class="mermaid" data-ds-mermaid> containing the escaped source and a copy button (data-ds-copy); the copy button is the only element marked data-markdown-ignore, and it stays in the accessibility tree because it is an interactive control. Markdown emits the fenced mermaid code block (fence length grown to survive backticks in the source) so agents always get the source.

Native block props

proptyperequiredbehaviour
codestringyesMermaid diagram source. Non-empty strings render; anything else degrades the block to the labelled fallback.

Example

{
  "type": "mermaid",
  "props": { "code": "graph TD;\n  A[Start]-->B[Ship];" }
}

Package files

Served under packages/@docsloth/mermaid/1.0.0/. The package digest covers manifest.json, which lists each file with its digest.

Filesha256 digestBytes
props.schema.jsonsha256:f4d5d460a88e05bb99244e7a141d0e64e32836c14ad28cbf6a796fe340f46f2c508
spec.mdsha256:0fe71f83607bd712a284b57fee9dfbe5ba3fbb3010533f5ec4c7c1949ad95aa33336

Sources

SourceLocation
Markdown twinhttps://registry.docsloth.dev/docs/mermaid.md
JSON metadatahttps://registry.docsloth.dev/api/v1/components/mermaid.json
Specificationpackages/contracts/component-specs/mermaid.md
Props schemapackages/contracts/component-props/mermaid.schema.json
Catalogpackages/contracts/component-catalog.json