Library API (@agentmark/core)
@agentmark/core is the canonical implementation — a pure, dependency-free, deterministic library.
It's the same code the editor and CLI use, and the reference the Python/Go/C ports mirror.
Surface
| Export | Purpose |
|---|---|
parse(source) |
text → AgentMarkDocument (frontmatter, nodes, edges, blocks, diagnostics) |
lint(doc, { strict? }) |
well-formedness checks → Diagnostic[] |
profileOf(doc) |
conformance profile: "sketch" | "spec" | "decision" |
stale(doc, today) |
temporal-validity / invalidation report |
viewNames(doc) / projectView(doc, view) |
discover + project views |
layout(graph, { direction }) |
deterministic node/edge placement |
renderSvg(doc, opts) / renderMermaid(doc, opts) |
render to SVG / Mermaid |
EXAMPLES / exampleBySlug(slug) |
built-in examples |
Parse → lint → stale
import { parse, lint, stale, profileOf } from "@agentmark/core";
const doc = parse(source);
console.log(profileOf(doc)); // "decision"
const problems = lint(doc); // Diagnostic[]: { severity, code, message, line }
const errors = problems.filter((d) => d.severity === "error");
const report = stale(doc, "2026-07-01"); // pass today — the core never reads the clock
console.log(report.lines);
Render
import { parse, renderSvg, renderMermaid } from "@agentmark/core";
const doc = parse(source);
// SVG: choose a view, direction, background and theme.
const svg = renderSvg(doc, {
view: "topology",
direction: "TB", // "LR" (default) | "TB"
background: "transparent", // a colour | "transparent" | null (default white)
theme: "dark", // "light" (default) | "dark" — canvas-level text colour
});
// Mermaid flowchart string.
const mmd = renderMermaid(doc, { view: "decision", direction: "LR" });
Work with the model
import { parse } from "@agentmark/core";
const doc = parse("[human#me: Me] <->[via Telegram] [harness#h: Hermes]");
doc.edges[0]; // { from: "human#me", to: "harness#h", arrow: "<->", label: "via Telegram" }
doc.byKey.get("harness#h"); // the resolved node, with its label + props
Cross-language note
The model is intentionally primitive (string | number | boolean), there are no Node APIs, and
nothing reads the clock — which is what lets the parser/linter/renderers be ported 1:1 to Go and C.
The tests in packages/core/src/*.test.ts are the conformance suite every port must pass.