Skip to content

feat(docs): generate llms.txt from repository documentation - #1199

Merged
helpcodeai merged 20 commits into
HelpCode-ai:mainfrom
Coding-Professional:feat/1011-generated-llms-docs
Oct 27, 2026
Merged

helpcodeai merged 20 commits into
HelpCode-ai:mainfrom
Coding-Professional:feat/1011-generated-llms-docs

Conversation

@Coding-Professional

@Coding-Professional Coding-Professional commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Generate a repository documentation index and full-text bundle so AI clients can read AnythingMCP's product docs directly. CI checks freshness and coverage: every Markdown file under docs/ must be included or explicitly excluded. The generator rejects symlinked sources so local private files cannot be pulled into the bundle through documentation links.

Changes

  • Add a dependency-free Node generator for root llms.txt and llms-full.txt, with stable ordering, LF output, short descriptions and --check mode.
  • Include docs/memory.md under Reference. Explicitly exclude contributor credits (docs/AUTHORS.md) and the Cloud-only card-trial-offer.md / signup-attribution.md internals.
  • Rewrite relative prose links to absolute GitHub URLs and remove images/banner HTML. Preserve fenced/inline code verbatim, clean up prose  , and improve the tool-definition, observability and roadmap descriptions.
  • Keep CLI invocation through script symlinks working. Reject symlinks in fixed documentation paths, scanned folders/files and all ancestors below the canonical repository root; verify resolved paths stay under that root with a separator boundary. Validate package metadata and both output targets too, before writing either output.
  • Add regression cases for links to synthetic private content, inside/outside repository targets, symlinked parent directories, scanned-file links, package metadata and output files. Failed generation/checks leave existing outputs unchanged and do not print the synthetic content. Retain the code-example preservation and complete-document-inventory tests.
  • Add generator tests and a freshness check to the existing backend CI job. Document regeneration in adapter-authoring step 5, the agent test section and the contributor PR process. Mark both outputs linguist-generated and link to them from the READMEs.

The branch includes upstream main af9a8291 (v0.50.0), with generated references refreshed for the upstream response-size limit, Sentry upgrade and setup instructions. Generated counts cover 547 listed adapters. These are repository artifacts in both Cloud and self-hosted deployments; no application serving, Docker or enterprise code changes are included in the PR diff.

Type

  • New feature
  • Documentation

Testing

From the repository root on Windows, Node.js v24.17.0:

  • node scripts/generate-llms-txt.mjs: regenerated both files; repeated generation is checked for determinism by the test suite.
  • node scripts/generate-llms-txt.mjs --check: passed.
  • node --test scripts/validate-adapters.test.mjs scripts/adapter-new.test.mjs scripts/generate-llms-txt.test.mjs: 53 passed, 4 skipped. Windows file-symlink cases require privileges unavailable locally; directory-junction rejection and supported CLI invocation through a junction passed. The new directory-link regressions failed before the guard was added.
  • node scripts/validate-adapters.mjs: 561 passed, 0 failed; 1,442 existing non-blocking warnings.
  • node scripts/adapter-count.mjs --check: passed (547 listed adapters, 26 keyless, 8,397 tools).
  • git diff --check: passed.
  • npm test -w packages/backend -- --runInBand --testPathPatterns=adapters/catalog.spec.ts --silent: 10,279 passed on f757f73 before the latest main sync. The latest head's full backend CI also passed.

CI for the sync commit f5fee956 passed on Ubuntu with Node 22: script tests (including all file/directory symlink cases), generated-output checks, full backend lint/typecheck/tests/build, CLI and frontend checks passed. Frontend e2e and CodeQL also passed. After syncing, re-ran the Windows script tests (53 passed, 4 privilege-related skips), adapter validation, quoted counts, generation/freshness and whitespace checks: passed. No native macOS run was performed locally.

Checklist

  • Followed the existing style and reviewed the changes.
  • Added tests for generation, coverage, code preservation and symlink rejection.
  • Updated contributor documentation and README pointers.
  • Backend catalog test rerun complete.
  • PR CI complete for the latest sync commit.
  • This PR has a descriptive title.

Related Issues

Fixes #1011.

@Coding-Professional
Coding-Professional marked this pull request as ready for review October 22, 2026 08:32
Copilot AI balanced review requested due to automatic review settings October 22, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Comment thread scripts/generate-llms-txt.mjs Fixed
Comment thread scripts/generate-llms-txt.mjs Fixed
Comment thread scripts/generate-llms-txt.mjs Fixed
Comment thread scripts/generate-llms-txt.mjs Fixed
Comment thread scripts/generate-llms-txt.mjs Fixed

@helpcodeai helpcodeai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Coding-Professional, this is close to what I had in mind, and the tests that check every code example in the real docs survive verbatim are a nice touch. A few things before I merge, two of them are gaps in my own issue text:

  1. The main-module check in scripts/generate-llms-txt.mjs:250 compares process.argv[1] with the real path of the module. If the script is called through a symlink, it does nothing and exits 0, so --check passes without checking anything. That's also why the CLI test fails on macOS, where tmpdir() is under /var, a symlink to /private/var. Comparing with realpathSync(process.argv[1]) fixes both.

  2. My spec said docs/operations/*.md, but card-trial-offer.md and signup-attribution.md are Cloud-only internals. Nobody using or self-hosting AnythingMCP needs them, so please leave those two out.

  3. docs/memory.md landed after I wrote the issue and isn't in either file. Could you add it to Reference, and add a test that every docs/**/*.md is either included or on an explicit exclude list (docs/AUTHORS.md plus the two above)? That way the next new doc fails CI instead of quietly going missing.

  4. Adapter PRs change the count in README.md and package.json, so they will hit this check too. Please add the command to step 5 of "Add an adapter" in AGENTS.md and to the adapter section in CONTRIBUTING. I'd also move the general line out of the top of AGENTS.md and out of the AI section in CONTRIBUTING, to the test section and the PR process step about docs.

Smaller things, take them or leave them: a few descriptions in llms.txt aren't great ("Three pipelines.", "This is a living document.", the tool definition one ends with a colon), so they could go in the override map. There's a stray   from the README at line 45 of llms-full.txt. And marking both files linguist-generated in .gitattributes would collapse the big diff in future PRs.

CI is green and the workflow change is exactly what I asked for, thanks for keeping it small.

@Coding-Professional

Copy link
Copy Markdown
Collaborator Author

Thanks for the review, @helpcodeai. All requested changes and the smaller cleanup suggestions are addressed in 138e17a, with regression tests added. CI is green and the PR description is updated. Ready for another look.

@helpcodeai helpcodeai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Coding-Professional, all four points are fixed and the tests are good. I merged main into your branch and regenerated the files (517 → 529 adapters), so CI is green again on 5e4b2ed.

One last thing before I merge, and then it's done. The generator still follows symlinks for doc paths: a symlinked file in the fixed list (say docs/sso.md -> ../.env) or a symlinked folder like docs/integrations gets read and written into llms-full.txt. Only a symlinked file inside a scanned folder is skipped, and that's a side effect of Dirent.isFile(). CI's --check leaks nothing, but a maintainer running the generator locally after such a PR would commit their own file.

Could you reject symlinks explicitly? lstatSync(p).isSymbolicLink() for every fixed path and every scanned folder and file, plus a check that realpathSync(resolve(root, p)) starts with realpathSync(root) + sep. A test for a symlinked file and a symlinked folder would be great.

@Coding-Professional

Coding-Professional commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks, @helpcodeai. Addressed in f757f73 with explicit symlink rejection, repository-boundary checks, and regression tests for files and folders. Synced with main and regenerated both files. CI is green.

@helpcodeai helpcodeai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Coding-Professional, the symlink checks look right: every path part is checked with lstat, the real path must stay inside the repo, and the outputs are checked too. The tests cover files and folders. I merged main again and regenerated the two files so the check passes. Merging once CI is green.

@helpcodeai
helpcodeai enabled auto-merge (squash) October 27, 2026 09:40
@helpcodeai
helpcodeai merged commit 6d1d895 into HelpCode-ai:main Oct 27, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🎃 Generate llms.txt and llms-full.txt from the repo docs so AI agents can read them

4 participants