Skip to main content

scripts/generate-llms-txt.ts

Ghost doc — This is a real utility script found at scripts/generate-llms-txt.ts in the Smithers repository. It generates the llms-full.txt file used to give LLMs full documentation context.

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

What This Demonstrates

  • llms.txt convention — Generates a single text file containing all documentation, following the llms.txt standard for giving AI models project context.
  • Shared docs manifest — The generator, route preview server, and browser smoke tests all read the same manifest helper, so route changes do not drift across tooling.
  • MDX to Markdown conversion — Strips YAML frontmatter and converts MDX components (<Warning>, <Tip>, <Note>) to markdown blockquotes.
  • Navigation-driven sync — Reads docs/docs.json so the exported context tracks the current API tabs and shared sections.
  • Source URL attribution — Each section includes a source URL back to the live docs page.
  • tests/docs-artifacts.test.ts keeps the committed docs/llms-full.txt output in sync with the current docs manifest.
  • tests/docs-e2e.playwright.ts exercises docs routes and legacy redirects against a local preview server built from the same source data.