Expand description
AD.2: the catalog as JSON — the plugin API for a reader that wants structure rather than prose (an agent, a code generator, an editor integration).
Hand-written rather than serde: this crate’s contract is ZERO runtime
dependencies (lattice-host links it, and whatever it depends on the host
inherits), and the shape is small and fixed. Output is pretty-printed with
stable key order so the checked-in file diffs line by line when the WIT
moves.
Shape (every field that can be absent is null, never omitted, so a
consumer can rely on the keys):
{ "package": "lattice:plugin-host@0.1.0",
"interfaces": [ { "name", "doc", "direction", "capability",
"examples": [ EXAMPLE ],
"functions": [ { "name", "display_name", "kind", "resource",
"async", "params": [ {"name","type"} ],
"result", "signature", "doc",
"examples": [ EXAMPLE ] } ],
"types": [ { "name", "kind", "doc", "definition",
"members": [ {"name","type","doc"} ],
"examples": [ EXAMPLE ] } ],
"uses": [ { "name", "from", "original" } ] } ],
"worlds": [ { "name", "doc", "imports", "exports",
"export_functions": [ FUNCTION ],
"import_functions": [ FUNCTION ] } ] }
FUNCTION = { "name", "display_name", "kind", "resource", "async",
"params", "result", "signature", "doc", "examples" }
EXAMPLE = { "id", "caption", "source", "language", "code" }Examples sit on the item they illustrate (a method’s on the method, a resource-level one on the resource’s type entry), so a consumer reading a function has its examples without a second lookup.
Functions§
- to_json
- The whole catalog as pretty-printed JSON, newline-terminated.
examplesis the guest scan, orNoneto emit emptyexamplesarrays.