#!/usr/bin/env node // Writes skills/atcli/reference.md from the command tree: every command, its // arguments and options, as the parser knows them. Generated so that it cannot // drift from the CLI; `npm test` fails when it is out of date. // // node tools/reference.ts write it // node tools/reference.ts --check exit 1 if it is not current import * as FS from 'node:fs'; import * as PATH from 'node:path'; import { reference } from '../src/reference.ts'; const FILE = PATH.resolve(import.meta.dirname, '..', 'skills', 'atcli', 'reference.md'); const text = reference(); if (process.argv.includes('--check')) { const current = FS.existsSync(FILE) ? FS.readFileSync(FILE, 'utf-8') : ''; if (current !== text) { console.error(`${PATH.relative(process.cwd(), FILE)} is out of date: run 'node tools/reference.ts'`); process.exit(1); } } else { FS.writeFileSync(FILE, text); console.error(`* wrote ${PATH.relative(process.cwd(), FILE)}`); }