build-catalog.mjs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. #!/usr/bin/env node
  2. // Generates references/catalog.md from design-resources/. Run: node scripts/build-catalog.mjs [--max-bytes=N] [--out=path]
  3. // Facts tied to resource names live in CONFIG; tests/design/catalog.test.ts keeps it in sync with the files.
  4. // Sections: CONFIG · resources · text helpers · catalog · main
  5. import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
  6. import { dirname, join, resolve } from "node:path";
  7. import { fileURLToPath, pathToFileURL } from "node:url";
  8. import { parseFrontmatter, splitFrontmatter } from "./frontmatter.mjs";
  9. export const MAX_BYTES = 8192;
  10. export const CONFIG = {
  11. defaults: { deck: "html-ppt-zhangzara-broadside", web: "web-prototype", app: "mobile-app" },
  12. // Skeletons kept on disk but never offered: their mandatory steps need the Open Design daemon, connectors or a
  13. // media runtime (OD_* wrappers, artifact registration, MP4 generation) that this host does not provide, so no
  14. // static workflow can follow them as written.
  15. excludeSkeletons: ["live-artifact", "live-dashboard", "hyperframes", "video-shortform"],
  16. // Every skeleton not in excludeSkeletons belongs to exactly one category; list order is priority order (former Top before Standard).
  17. categories: [
  18. {
  19. key: "deck",
  20. title: "Deck — specific need (match one to one first)",
  21. craft: [],
  22. members: [
  23. "html-ppt-pitch-deck", "html-ppt-hermes-cyber-terminal", "html-ppt-taste-brutalist", "html-ppt-course-module",
  24. "kami-deck", "open-design-landing-deck", "weekly-update", "ib-pitch-book",
  25. ],
  26. },
  27. {
  28. key: "zhangzara",
  29. title: "Deck — zhangzara family, all `self` (`html-ppt-zhangzara-<x>`; pick by mood, then use)",
  30. prefix: "html-ppt-zhangzara-",
  31. craft: [],
  32. members: [
  33. "broadside", "bold-poster", "cartesian", "coral", "editorial-tri-tone", "neo-grid-bold", "peoples-platform",
  34. "pin-and-paper", "soft-editorial", "stencil-tablet", "retro-windows", "retro-zine", "sakura-chroma",
  35. "pink-script", "8-bit-orbit", "creative-mode", "daisy-days", "biennale-yellow", "block-frame", "capsule",
  36. "grove", "mat", "monochrome", "playful", "raw-grid", "signal", "studio", "vellum",
  37. ].map((x) => `html-ppt-zhangzara-${x}`),
  38. },
  39. {
  40. key: "dashboard",
  41. title: "Dashboard",
  42. craft: ["state-coverage"],
  43. members: ["dashboard", "trading-analysis-dashboard-template", "ai-assistant-mobile-dashboard"],
  44. },
  45. {
  46. key: "web",
  47. title: "Web page",
  48. craft: [],
  49. members: [
  50. "web-prototype", "web-prototype-taste-soft", "web-prototype-taste-editorial", "web-prototype-taste-brutalist",
  51. "saas-landing", "kami-landing", "pricing-page",
  52. ],
  53. },
  54. {
  55. key: "app",
  56. title: "App",
  57. craft: ["state-coverage"],
  58. members: ["mobile-app", "kanban-board", "meeting-notes", "gamified-app", "wireframe-sketch"],
  59. },
  60. {
  61. key: "document",
  62. title: "Document / report",
  63. craft: ["typography-hierarchy"],
  64. members: [
  65. "blog-post", "docs-page", "digital-eguide", "finance-report", "dcf-valuation", "clinical-case-report",
  66. "eng-runbook", "pm-spec", "hr-onboarding", "invoice", "magazine-poster",
  67. ],
  68. },
  69. {
  70. key: "media",
  71. title: "Media / motion",
  72. craft: ["animation-discipline"],
  73. members: ["motion-frames", "sprite-animation", "social-carousel"],
  74. },
  75. {
  76. key: "utility",
  77. title: "Utility",
  78. craft: [],
  79. members: ["critique", "tweaks", "orbit-linear", "orbit-notion", "x-research"],
  80. },
  81. ],
  82. // Rows whose name says enough.
  83. nameOnly: [
  84. "weekly-update", "ib-pitch-book", "dashboard", "trading-analysis-dashboard-template", "saas-landing", "pricing-page",
  85. "mobile-app", "kanban-board", "meeting-notes", "wireframe-sketch", "blog-post", "docs-page", "digital-eguide",
  86. "finance-report", "dcf-valuation", "clinical-case-report", "eng-runbook", "pm-spec", "hr-onboarding", "invoice",
  87. "magazine-poster", "motion-frames", "sprite-animation", "social-carousel",
  88. ],
  89. // One-line text replacing the description's first sentence.
  90. override: {
  91. // YAML ends the description at " #0a0c10", so the parsed text stops at "deck —".
  92. "html-ppt-hermes-cyber-terminal": "Dark terminal deck for CLI / agent / dev-tool reviews",
  93. "kami-deck": "Print-grade kami deck: parchment, ink-blue, one serif",
  94. "kami-landing": "Print-grade kami one-pager or white paper",
  95. "open-design-landing-deck": "Atelier Zero brand deck: warm paper, collage plates",
  96. "web-prototype": "General responsive web page",
  97. critique: "5-dimension expert review of an HTML artifact",
  98. tweaks: "Side panel of live CSS controls to compare variants",
  99. "orbit-linear": "Daily digest from Linear data",
  100. "orbit-notion": "Daily digest from Notion data",
  101. "x-research": "X/Twitter sentiment research; Markdown first is fine",
  102. },
  103. // Warnings shown under the category of their first resource.
  104. notes: [
  105. {
  106. names: ["open-design-landing-deck"],
  107. text: "`scripts/compose.ts` needs sibling CSS and images that are not shipped; build from the skill, example, inputs and `schema.ts`, do not run it",
  108. },
  109. ],
  110. // Files that some SKILL.md files name but the package does not ship (paths under design-resources/).
  111. missing: [
  112. {
  113. label: "the main html-ppt skill and `full-decks.md`",
  114. usedBy: ["html-ppt-pitch-deck", "html-ppt-course-module", "html-ppt-hermes-cyber-terminal"],
  115. paths: ["design-skeletons/html-ppt/SKILL.md", "design-skeletons/html-ppt/references/full-decks.md", "skills/html-ppt"],
  116. },
  117. {
  118. label: "the `open-design-landing` CSS and images",
  119. usedBy: ["open-design-landing-deck"],
  120. paths: ["design-skeletons/open-design-landing/styles.css", "design-skeletons/open-design-landing/assets"],
  121. },
  122. ],
  123. // Skill SKILL.md files whose name differs from their directory.
  124. nameMismatch: ["infinite-canvas"],
  125. skills: {
  126. // gstack method skills: not offered for selection and not read by default.
  127. exclude: ["design-consultation", "design-review", "plan-design-review"],
  128. override: {
  129. "brand-guidelines": "Anthropic's own brand, only when the task asks for it",
  130. "frontend-design": "production-grade frontend UI",
  131. "frontend-slides": "animation-rich HTML slides",
  132. "infinite-canvas": "infinite-canvas delivery (`scripts/adapt-canvas.mjs`)",
  133. "taste-skill": "anti-slop tuning: density, motion, variance",
  134. },
  135. },
  136. // DESIGN.md `> Category:` value -> catalog group (group order = render order).
  137. systemGroups: {
  138. "Productivity & SaaS": "Tech / SaaS",
  139. "Developer Tools": "Tech / SaaS",
  140. "Design & Creative": "Tech / SaaS",
  141. "Themed & Unique": "Tech / SaaS",
  142. "Professional & Corporate": "Tech / SaaS",
  143. "Media & Consumer": "Tech / SaaS",
  144. "E-Commerce & Retail": "Tech / SaaS",
  145. "Bold & Expressive": "Style",
  146. "Creative & Artistic": "Style",
  147. "Morphism & Effects": "Style",
  148. "Layout & Structure": "Style",
  149. "Editorial & Print": "Editorial",
  150. "Editorial · Studio": "Editorial",
  151. "Fintech & Crypto": "Fintech",
  152. Automotive: "Automotive",
  153. },
  154. systemNotes: { kami: "only via kami-* skeletons" },
  155. // Short descriptions for systems without an Agent Prompt Guide (brand systems are listed by name).
  156. systemOverride: {
  157. agentic: "AI-first, delegated task flows",
  158. application: "purple app dashboard, top nav",
  159. arc: "translucent, sidebar-first",
  160. artistic: "expressive type, bold color",
  161. bento: "modular card grid",
  162. bold: "heavy type, high contrast",
  163. brutalism: "raw anti-design",
  164. glassmorphism: "frosted translucent layers",
  165. },
  166. // craft/<name>.md -> when to read. Key set must equal the craft/ directory.
  167. craft: {
  168. typography: "baseline, always",
  169. color: "baseline, always",
  170. "anti-ai-slop": "baseline, always",
  171. "accessibility-baseline": "baseline, always",
  172. "state-coverage": "apps, dashboards: loading/empty/error",
  173. "typography-hierarchy": "text-heavy pages",
  174. "typography-hierarchy-editorial": "content sites, magazine style",
  175. "animation-discipline": "any motion",
  176. "form-validation": "forms",
  177. "laws-of-ux": "highly interactive UI",
  178. "rtl-and-bidi": "Arabic/Hebrew only, even if a skeleton lists it",
  179. },
  180. craftBaseline: ["typography", "color", "anti-ai-slop", "accessibility-baseline"],
  181. craftAlias: { "motion-discipline": "animation-discipline" },
  182. craftDrop: ["typographic-rhythm", "pixel-discipline"],
  183. craftConditional: ["rtl-and-bidi"],
  184. // Triggers shared by the whole zhangzara family carry no routing signal.
  185. stopTriggers: ["html deck", "html slides", "zhangzara"],
  186. textWidth: 52,
  187. shortTextWidth: 40,
  188. };
  189. // ---------- resources ----------
  190. const byCodePoint = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
  191. function subdirsWith(dir, file) {
  192. return readdirSync(dir, { withFileTypes: true })
  193. .filter((entry) => entry.isDirectory() && existsSync(join(dir, entry.name, file)))
  194. .map((entry) => entry.name)
  195. .sort(byCodePoint);
  196. }
  197. function readFrontmatter(file) {
  198. const raw = splitFrontmatter(readFileSync(file, "utf8"));
  199. if (raw === null) throw new Error(`missing frontmatter: ${file}`);
  200. return parseFrontmatter(raw);
  201. }
  202. // DESIGN.md has no frontmatter: `# Title`, then `> Category: X` and a quoted one-liner.
  203. export function parseDesignSystem(text) {
  204. const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
  205. let i = 1;
  206. while (i < lines.length && lines[i].trim() === "") i++;
  207. const quote = [];
  208. while (i < lines.length && lines[i].startsWith(">")) quote.push(lines[i++].replace(/^>\s?/, "").trim());
  209. const category = quote[0]?.match(/^Category:\s*(.+)$/)?.[1];
  210. if (!category) throw new Error("DESIGN.md lacks a `> Category:` line");
  211. return {
  212. category,
  213. description: quote.slice(1).join(" ").replace(/\s+/g, " ").trim(),
  214. full: text.includes("Agent Prompt Guide"),
  215. };
  216. }
  217. export function collectResources(resourceRoot) {
  218. const skeletonDir = join(resourceRoot, "design-skeletons");
  219. const skillDir = join(resourceRoot, "skills");
  220. const systemDir = join(resourceRoot, "design-systems");
  221. const skeletons = new Map();
  222. for (const name of subdirsWith(skeletonDir, "SKILL.md")) {
  223. skeletons.set(name, {
  224. frontmatter: readFrontmatter(join(skeletonDir, name, "SKILL.md")),
  225. hasExample: existsSync(join(skeletonDir, name, "example.html")),
  226. });
  227. }
  228. const skills = new Map();
  229. for (const name of subdirsWith(skillDir, "SKILL.md")) {
  230. skills.set(name, { frontmatter: readFrontmatter(join(skillDir, name, "SKILL.md")) });
  231. }
  232. const systems = new Map();
  233. for (const name of subdirsWith(systemDir, "DESIGN.md")) {
  234. systems.set(name, parseDesignSystem(readFileSync(join(systemDir, name, "DESIGN.md"), "utf8")));
  235. }
  236. const craft = readdirSync(join(resourceRoot, "craft"))
  237. .filter((file) => file.endsWith(".md"))
  238. .map((file) => file.slice(0, -3))
  239. .sort(byCodePoint);
  240. return { skeletons, skills, systems, craft };
  241. }
  242. // ---------- text helpers ----------
  243. export function firstSentence(description) {
  244. const text = String(description ?? "").replace(/\s+/g, " ").trim();
  245. const end = /[。!?]|[.!?]["”']?(?=\s|$)/g;
  246. let match;
  247. while ((match = end.exec(text))) {
  248. const before = text.slice(0, match.index);
  249. if (match[0] === "." && /\b(?:e\.g|i\.e|vs|etc)$/i.test(before)) continue;
  250. return before.trim();
  251. }
  252. return text;
  253. }
  254. const charWidth = (ch) => (/[\u2E80-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/.test(ch) ? 2 : 1);
  255. const width = (s) => [...s].reduce((n, ch) => n + charWidth(ch), 0);
  256. // Shorten to `max` display columns, preferring the part before " — " when it can stand alone.
  257. export function clip(text, max) {
  258. let s = text.replace(/\*\*/g, "").replace(/["“”]/g, "").trim();
  259. const dash = s.indexOf(" — ");
  260. if (dash >= 0 && width(s.slice(0, dash)) >= 20) s = s.slice(0, dash);
  261. s = s.replace(/^An? (?=[a-z])/, "");
  262. if (width(s) <= max) return s;
  263. let out = "";
  264. let w = 0;
  265. for (const ch of s) {
  266. if (w + charWidth(ch) > max - 1) break;
  267. out += ch;
  268. w += charWidth(ch);
  269. }
  270. const atWord = out.replace(/[\s,;:/(—–-]+[^\s,;:/(—–-]*$/, "");
  271. return `${(width(atWord) > max / 2 ? atWord : out).replace(/[\s,;:/(—–-]+$/, "")}…`;
  272. }
  273. export function resolveCraft(name) {
  274. if (CONFIG.craftDrop.includes(name)) return null;
  275. return CONFIG.craftAlias[name] ?? name;
  276. }
  277. function craftExtras(frontmatter, groupCraft) {
  278. const extras = [];
  279. for (const declared of frontmatter.od?.craft?.requires ?? []) {
  280. const name = resolveCraft(declared);
  281. if (!name || CONFIG.craftBaseline.includes(name) || CONFIG.craftConditional.includes(name)) continue;
  282. if (groupCraft.includes(name) || extras.includes(name)) continue;
  283. extras.push(name);
  284. }
  285. return extras;
  286. }
  287. function zhangzaraText(name, frontmatter, prefix) {
  288. const short = name.slice(prefix.length);
  289. const triggers = (frontmatter.triggers ?? []).filter(
  290. (t) =>
  291. !CONFIG.stopTriggers.includes(t) &&
  292. !t.startsWith("zhangzara-") &&
  293. !/^[A-Z]/.test(t) &&
  294. t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") !== short,
  295. );
  296. const moods = triggers.filter((t) => !/[ /]/.test(t)).slice(0, 3);
  297. const use = triggers.find((t) => /[ /]/.test(t));
  298. return [moods.join(", "), use].filter(Boolean).join(" · ");
  299. }
  300. const code = (name) => `\`${name}\``;
  301. const anchor = (title) => title.toLowerCase().replace(/[^a-z0-9 -]/g, "").replace(/ /g, "-");
  302. // ---------- catalog ----------
  303. export function buildCatalog(resourceRoot) {
  304. const { skeletons, skills, systems, craft } = collectResources(resourceRoot);
  305. const categoryOf = new Map();
  306. for (const name of CONFIG.excludeSkeletons) {
  307. if (!skeletons.has(name)) throw new Error(`excludeSkeletons lists unknown skeleton ${name}`);
  308. }
  309. for (const category of CONFIG.categories) {
  310. for (const name of category.members) {
  311. if (!skeletons.has(name)) throw new Error(`category ${category.key} lists unknown skeleton ${name}`);
  312. if (CONFIG.excludeSkeletons.includes(name)) throw new Error(`skeleton ${name} is excluded but listed in ${category.key}`);
  313. if (categoryOf.has(name)) throw new Error(`skeleton ${name} is in two categories`);
  314. categoryOf.set(name, category);
  315. }
  316. }
  317. const unassigned = [...skeletons.keys()].filter((name) => !categoryOf.has(name) && !CONFIG.excludeSkeletons.includes(name));
  318. if (unassigned.length) throw new Error(`skeletons without a category: ${unassigned.join(", ")}`);
  319. const craftKeys = Object.keys(CONFIG.craft).sort(byCodePoint);
  320. if (craftKeys.join() !== craft.join()) throw new Error("CONFIG.craft keys differ from the craft/ directory");
  321. const body = [];
  322. const contents = [];
  323. const section = (title) => {
  324. contents.push(title);
  325. body.push(`## ${title}`);
  326. };
  327. section("Skeletons");
  328. body.push(
  329. "`design-resources/design-skeletons/<name>/SKILL.md`; `example.html` beside it unless `no example`. `self` = own visual rules, no design system needed. `+x` = extra craft. Folders not listed need a runtime this host lacks; never use them.",
  330. "",
  331. );
  332. for (const category of CONFIG.categories) {
  333. body.push(`### ${category.title}${category.craft.length ? ` (+${category.craft.join(", ")})` : ""}`);
  334. for (const name of category.members) {
  335. const { frontmatter, hasExample } = skeletons.get(name);
  336. const flags = [];
  337. const extras = craftExtras(frontmatter, category.craft);
  338. if (extras.length) flags.push(`+${extras.join(", ")}`);
  339. if (!category.prefix && frontmatter.od?.design_system?.requires === false) flags.push("self");
  340. const brands = frontmatter.od?.design_system?.recommended_brands;
  341. if (brands?.length) flags.push(`ds: ${brands.slice(0, 3).join("/")}`);
  342. if (!hasExample) flags.push("no example");
  343. let text;
  344. if (category.prefix) text = zhangzaraText(name, frontmatter, category.prefix);
  345. else if (CONFIG.override[name]) text = CONFIG.override[name];
  346. else if (!CONFIG.nameOnly.includes(name)) text = clip(firstSentence(frontmatter.description), CONFIG.textWidth);
  347. const label = category.prefix ? name.slice(category.prefix.length) : name;
  348. body.push(`- ${code(label)}${text ? ` — ${text}` : ""}${flags.length ? ` [${flags.join("; ")}]` : ""}`);
  349. }
  350. for (const note of CONFIG.notes) {
  351. if (categoryOf.get(note.names[0]) === category) body.push(`- Note, ${note.names.map(code).join(", ")}: ${note.text}.`);
  352. }
  353. body.push("");
  354. }
  355. section("Skills");
  356. body.push("`design-resources/skills/<name>/SKILL.md`; only when no skeleton fits.", "");
  357. for (const [name, { frontmatter }] of skills) {
  358. if (CONFIG.skills.exclude.includes(name)) continue;
  359. const text = CONFIG.skills.override[name] ?? clip(firstSentence(frontmatter.description), CONFIG.shortTextWidth);
  360. body.push(`- ${code(name)} — ${text}`);
  361. }
  362. body.push("");
  363. section("Design systems");
  364. body.push(
  365. "`design-resources/design-systems/<name>/DESIGN.md`; read the file, not this line. With a brand system also read [BRAND-DISCLAIMER.md](../design-resources/design-systems/BRAND-DISCLAIMER.md).",
  366. "",
  367. );
  368. const groups = new Map([...new Set(Object.values(CONFIG.systemGroups))].map((group) => [group, []]));
  369. for (const [name, system] of systems) {
  370. const group = CONFIG.systemGroups[system.category];
  371. if (!group) throw new Error(`design system ${name}: unknown category ${system.category}`);
  372. let entry = code(name);
  373. if (CONFIG.systemNotes[name]) entry += ` (${CONFIG.systemNotes[name]})`;
  374. else if (CONFIG.systemOverride[name]) entry += ` ${CONFIG.systemOverride[name]}`;
  375. else if (!system.full) entry += ` ${clip(firstSentence(system.description), CONFIG.shortTextWidth)}`;
  376. groups.get(group).push(entry);
  377. }
  378. for (const [group, entries] of groups) {
  379. if (entries.length) body.push(`- **${group}**: ${entries.join("; ")}`);
  380. }
  381. body.push("");
  382. section("Craft");
  383. const aliases = Object.entries(CONFIG.craftAlias).map(([from, to]) => `${code(from)} = ${code(to)}`);
  384. body.push(
  385. `\`design-resources/craft/<name>.md\`. Metadata names: ${aliases.join("; ")}; ${CONFIG.craftDrop.map(code).join(", ")} are not shipped.`,
  386. "",
  387. );
  388. const byWhen = new Map();
  389. for (const [name, when] of Object.entries(CONFIG.craft)) byWhen.set(when, [...(byWhen.get(when) ?? []), name]);
  390. for (const [when, names] of byWhen) body.push(`- ${names.map(code).join(", ")} — ${when}`);
  391. const { deck, web, app } = CONFIG.defaults;
  392. const missing = CONFIG.missing.map((entry) => entry.label).join("; ");
  393. const head = [
  394. "# Resource catalog",
  395. "",
  396. "<!-- Generated by scripts/build-catalog.mjs from design-resources/; do not edit. -->",
  397. "",
  398. "For CREATE; paths are relative to this skill's directory. Pick one skeleton (a skill only if none fits), read it, then a design system and craft; never bulk-read.",
  399. `Defaults: deck ${code(deck)}, web ${code(web)}, app ${code(app)}. Craft = baseline + group default + row \`+x\`.`,
  400. `Not shipped, though some SKILL.md files name them: ${missing}. Do not claim to have read or run them.`,
  401. "",
  402. `Contents: ${contents.map((title) => `[${title}](#${anchor(title)})`).join(" · ")}`,
  403. "",
  404. ];
  405. return `${[...head, ...body].join("\n").replace(/\n+$/, "")}\n`;
  406. }
  407. // Bytes per `##` / `###` section, for the over-cap report.
  408. export function sectionSizes(text) {
  409. let current = { title: "(head)", bytes: 0 };
  410. const sizes = [current];
  411. for (const line of text.replace(/\n$/, "").split("\n")) {
  412. const heading = line.match(/^#{2,3} (.+)$/);
  413. if (heading) sizes.push((current = { title: heading[1], bytes: 0 }));
  414. current.bytes += Buffer.byteLength(`${line}\n`, "utf8");
  415. }
  416. return sizes;
  417. }
  418. const skillRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
  419. export function main(argv = process.argv.slice(2)) {
  420. const option = (name) => argv.find((arg) => arg.startsWith(`--${name}=`))?.slice(name.length + 3);
  421. const maxBytes = Number(option("max-bytes") ?? MAX_BYTES);
  422. const out = option("out") ?? join(skillRoot, "references", "catalog.md");
  423. const text = buildCatalog(join(skillRoot, "design-resources"));
  424. const bytes = Buffer.byteLength(text, "utf8");
  425. if (bytes > maxBytes) {
  426. const report = sectionSizes(text).map(({ title, bytes: n }) => ` ${String(n).padStart(6)} ${title}`);
  427. process.stderr.write(`catalog is ${bytes} B, over the ${maxBytes} B cap; not written.\n${report.join("\n")}\n`);
  428. return 1;
  429. }
  430. writeFileSync(out, text);
  431. process.stdout.write(`wrote ${out}: ${bytes} B, ${text.split("\n").length - 1} lines\n`);
  432. return 0;
  433. }
  434. if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
  435. process.exitCode = main();
  436. }