Skip to main content

scripts/generate-llms-txt.ts

Ghost doc — Real utility script at scripts/generate-llms-txt.ts.

Source

// scripts/generate-llms-txt.ts
#!/usr/bin/env bun
import { writeFileSync } from "node:fs";
import { generateLlmsFull } from "./docs-utils";

const output = generateLlmsFull();

writeFileSync("docs/llms-full.txt", output);
console.log(
  `Generated docs/llms-full.txt (${output.length} chars, ~${Math.round(output.length / 4)} tokens)`,
);

Running

bun scripts/generate-llms-txt.ts

Key Details

  • Follows the llms.txt convention: one text file containing all documentation for AI model context.
  • Reads docs/docs.json so output tracks the current navigation and API tabs.
  • Strips YAML frontmatter; converts MDX components (<Warning>, <Tip>, <Note>) to blockquotes.
  • Each section includes a source URL back to the live docs page.
  • The generator, route preview server, and browser smoke tests share the same manifest helper, so route changes cannot drift.
  • tests/docs-artifacts.test.ts keeps the committed docs/llms-full.txt in sync with the current docs manifest.
  • tests/docs-e2e.playwright.ts exercises docs routes and legacy redirects against a local preview server.