Files
hyperframes/scripts/check-docs-cli-commands.mjs
T
Ular KimsanovandClaude Opus 5.5 1b1a576d52 docs(cli): document every command, and check it in CI (#5938)
* docs(cli): document media-use and usage commands

Both command groups are registered and visible but had no section in the CLI reference.

- media-use: subcommands, resolve flags, the per-type source order, where files land,
  which sources need a HeyGen sign-in or can cost money, and telemetry.
- usage: flags, the known and unknown result shapes, which logins it reads, and that it
  sends no telemetry.
- Add both to the "Find your command" table.

The from, reuse, and params subcommands cannot take their value in this release, so the
page points to the working resolve --from, --reuse, and --params forms instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cli): drop the media-use bug workaround note

The bugs go to the media-use owner instead of living in the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(cli): list every command in the finder, and check it in CI

A ~20-line check fails the docs workflow when a CLI command is missing
from "Find your command". On main it finds media-use, usage, models,
clean and events. AGENTS.md and CLAUDE.md ask agents to ship docs with
the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: format the docs command check

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:45:53 +00:00

26 lines
1.1 KiB
JavaScript

// Every CLI command must be listed in "Find your command" in docs/packages/cli.mdx, so a new command
// cannot ship undocumented (media-use and usage did). Commands are read from cli.ts's commandLoaders.
import { readFileSync } from "node:fs";
const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), "utf8");
const cli = read("packages/cli/src/cli.ts");
const start = cli.indexOf("const commandLoaders = {");
const commands = [
...cli.slice(start, cli.indexOf("\n};", start)).matchAll(/^ {2}"?([a-z][a-z-]*)"?:/gm),
].map((m) => m[1]);
if (commands.length === 0)
throw new Error("cli.ts no longer declares `const commandLoaders = { ... };`");
const docs = read("docs/packages/cli.mdx");
const from = docs.indexOf("## Find your command");
const finder = docs.slice(from, docs.indexOf("\n## ", from + 1));
const missing = commands.filter((command) => !finder.includes(`\`${command}\``));
if (missing.length > 0) {
console.error(
`Add these commands to "Find your command" in docs/packages/cli.mdx, with a section: ${missing.join(", ")}`,
);
process.exit(1);
}
console.log(`All ${commands.length} CLI commands are listed in the docs.`);