Compile out
Compile targets
A target compiles the official graph into a runtime artifact: a wiki, an npm package, agent tool payloads, a device profile, a C header. Same block ids, same versions, same hashes — different emitter. The manifest below is machine-readable: compile-targets.v1 schema.
Target registry
| Target | Output | Official only | Status | Reference |
|---|---|---|---|---|
wiki | html-react-wiki | — (human preview) | reference | src/components/wiki |
pulse-react | npm-package | ✅ required | reference | src/lib/codegen |
mcp | tool-payloads | ✅ required | reference | src/lib/ir/enforce.ts |
device-sim | json-profile | ✅ required | reference | src/lib/ir/targets/device-sim.ts |
c-header | tokens.h | ✅ required | reference | src/lib/ir/targets/c-header.ts |
lvgl | lvgl-style-pack | ✅ required | stub | — |
Build a target in a weekend
The entire contract:
| # | Rule |
|---|---|
| 1 | Input: an official BlocksmithGraphV1 — validate it first with validateGraph(g, { officialOnly: true, verifyHashes: true }) |
| 2 | Output: your artifact + the graph's contentHash stamped inside it (traceability) |
| 3 | Preserve block id + version on everything you emit — a color in your artifact must trace to token:color:accent@v3 |
| 4 | Never read drafts or conflicts. If you need preview semantics, you are building a wiki — different rules. |
| 5 | Register in compile-targets.v1.json via PR. |
import { validateGraph } from "@blocksmith/protocol";
import type { BlocksmithGraphV1 } from "@blocksmith/protocol";
export function compileMyTarget(graph: BlocksmithGraphV1): string {
const v = validateGraph(graph, { officialOnly: true, verifyHashes: true });
if (!v.ok) throw new Error(v.errors.map(e => e.message).join("; "));
const lines = [`/* graph ${graph.contentHash} */`];
for (const b of graph.blocks) {
if (b.type !== "token") continue;
lines.push(`--${b.id.split(":").pop()}: ${b.content.value}; /* ${b.id}@v${b.version} */`);
}
return lines.join("\n");
}Worked examples to crib from: device-sim (~200 lines, includes a semantic-loss metric) and c-header (~100 lines, every #define commented with block@version (hash)) in src/lib/ir/targets/.
The next rung on the hardware ladder is
lvgl (style packs for embedded UIs) — stubbed in the manifest and open for a weekend build. Automotive clusters, kiosks, and watches don't run React; they still deserve a design system with version semantics.