Skip to content

Conversation

@yerzhansa
Copy link

Description

This PR adds automatic generation of llms-full.txt, an LLM-optimized documentation file that aggregates all Fastify documentation into a single text file suitable for consumption by Large Language Models.

Changes include:

  • New script scripts/generate-llms-txt.js that combines versioned docs into a single file
  • Integration into the build pipeline via scripts/build-website.sh
  • Updated .gitignore to exclude generated .txt files
  • Generates static/generated/llms-full.txt with metadata, guides, and API reference documentation

The generated file includes proper structure with metadata headers, versioning info, and organized sections for better LLM comprehension.

Related Issues

Fixes #288

Check List

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Co-authored-by: Frazer Smith <[email protected]>
Signed-off-by: Yerzhan <[email protected]>
Copy link
Contributor

@ilteoood ilteoood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be maybe great to have a sort of test for this script?
Just to make it more maintainable in the future.

try {
const versionsContent = await fs.readFile(VERSIONS_FILE, 'utf8')
versions = JSON.parse(versionsContent)
if (!versions || versions.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!versions || versions.length === 0) {
if (!versions?.length) {

Comment on lines +154 to +157
let output = ''

// Add metadata header
output += generateMetadata(latestVersion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let output = ''
// Add metadata header
output += generateMetadata(latestVersion)
// Add metadata header
let output = generateMetadata(latestVersion)


output += '## Introduction\n\n'
output += cleaned
output += '\n\n---\n\n'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you extract this in a const?
named something like SECTION_SEPARATOR or whatever you think is best, so you can reuse it in the whole file without repetitions

@ilteoood
Copy link
Contributor

ilteoood commented Dec 17, 2025

I was reading this issue related to the same topic.
Can we consider using a plugin like this one instead of implementing a custom solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a llms-full.txt for the Fastify Docs.

5 participants