/** * Writes one JSON Schema per note type to json/, with every field's title and * description. The MCP server and future editors can read these without * importing TypeScript. */ import { mkdirSync, writeFileSync } from "node:fs"; import { z } from "zod"; import { noteTypes } from "../src/types.ts"; const out = new URL("../json/", import.meta.url); mkdirSync(out, { recursive: true }); for (const def of Object.values(noteTypes)) { const schema = z.toJSONSchema(def.schema, { io: "input", unrepresentable: "any" }); const doc = { ...schema, title: def.label, description: def.description, "x-folder": typeof def.folder === "string" ? def.folder : "depends on the note", "x-body": def.body, "x-singleton": def.singleton?.fileName ?? null, }; writeFileSync(new URL(`${def.type}.schema.json`, out), `${JSON.stringify(doc, null, 2)}\n`); } console.log(`Wrote ${Object.keys(noteTypes).length} schemas to json/`);