@agentshouse/mdmodel
Typed Markdown documents: MD Types declared in JSON Schema, whose values a Document writes in its Markdown body, a reader, a writer and validator of them, the deterministic application of one structured change to a Document, and one query language answered in SQL over a collection or in memory over one Document, plus a conformance fixture corpus.
It runs in the browser and in Node, makes no network call, and reads no
filesystem on its own. It ships one ESM artifact that Node 24.22.1 and later
loads through import or require.
Install
npm install @agentshouse/mdmodel
Usage
import { apply, parse, serialize, validate, verify } from '@agentshouse/mdmodel';
const checked = verify('task:\n properties:\n title: { type: string, title: Title }\n');
if (checked.verdict === 'accept') {
const task = checked.model.types.task;
validate({ 'one.md': '---\ntype: task\n---\n- **Title**: Ship\n' }, undefined, checked.model);
const parsed = parse('---\ntype: task\n---\n- **Title**: Hello\n', 'one.md', task);
if (parsed.ok) {
const change = { kind: 'field', name: 'title', value: 'World', prior: 'Hello' } as const;
const next = apply(parsed.document, [change], task);
if (next.outcome === 'applied') serialize(next.document);
}
}
API
| Export | Purpose |
|---|---|
verify | Verify one schema text into a model of MD Types |
validate | Validate a text Library; returns acceptance or one refusal |
parse, serialize | Read and write one Document |
apply | Apply field, section, preamble, link and reference changes at once |
links, target, retarget | Inventory and rewrite link destinations |
escapePointer | Write one key as a JSON Pointer token |
project, divide | Embedding projection input and its division into Spans |
facts, candidateOf | A Document as one change saw it, matched as one query candidate |
planOf, matches, sql | Check a query, answer it over one Document or compile it to SQL |
VERSION | The MD model version |
MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD | The frontmatter keys validation counts as declared beyond a type's |
MEDIA_TYPES, servedMediaType | The media types House writes and the one table of file extensions |
The full reference is in API.md. The conformance corpus and its
verdict format and rule ids are described in fixtures/README.md.
License
MIT