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

TargetOutputOfficial onlyStatusReference
wikihtml-react-wiki— (human preview)referencesrc/components/wiki
pulse-reactnpm-package✅ requiredreferencesrc/lib/codegen
mcptool-payloads✅ requiredreferencesrc/lib/ir/enforce.ts
device-simjson-profile✅ requiredreferencesrc/lib/ir/targets/device-sim.ts
c-headertokens.h✅ requiredreferencesrc/lib/ir/targets/c-header.ts
lvgllvgl-style-pack✅ requiredstub—

Build a target in a weekend

The entire contract:

#Rule
1Input: an official BlocksmithGraphV1 — validate it first with validateGraph(g, { officialOnly: true, verifyHashes: true })
2Output: your artifact + the graph's contentHash stamped inside it (traceability)
3Preserve block id + version on everything you emit — a color in your artifact must trace to token:color:accent@v3
4Never read drafts or conflicts. If you need preview semantics, you are building a wiki — different rules.
5Register in compile-targets.v1.json via PR.
40-line skeleton
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.