#!/usr/bin/env node /** * Regenerate `docs/reference.md` from the `known.ts` catalog. * * npm run gen:reference * npm run gen:reference -- --out ~/.agents/skills/tttk-authoring/reference.md */ import { mkdirSync, writeFileSync } from "fs"; import { homedir } from "os"; import { dirname, resolve } from "path"; import { renderReference } from "../src/cli/validate/reference.js"; function argValue(flag: string): string | undefined { const index = process.argv.indexOf(flag); return index >= 0 ? process.argv[index + 1] : undefined; } /** Expand a leading `~` so the skill copy can be targeted cross-platform. */ function expandHome(path: string): string { if (path === "~") return homedir(); if (path.startsWith("~/") || path.startsWith("~\\")) { return resolve(homedir(), path.slice(2)); } return path; } const out = resolve(expandHome(argValue("--out") ?? "docs/reference.md")); mkdirSync(dirname(out), { recursive: true }); writeFileSync(out, renderReference(), "utf-8"); console.log(`wrote ${out}`);