Enrich known.ts with element/role details, inline specs, and dice notation, and render them from reference.ts. Add gen:skill-reference and ~ expansion in --out so the skill copy can be regenerated. The skill's reference.md is now generated; its extra authoring content moved to layout.md, yaml-tag.md, csv.md, and markdown.md.
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
#!/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}`);
|