Skip to content

feat(ui): add llms.txt generation for npm packages - #1382

Open
lukeocodes wants to merge 22 commits into
npmx-dev:mainfrom
lukeocodes:feat/llms-txt
Open

feat(ui): add llms.txt generation for npm packages#1382
lukeocodes wants to merge 22 commits into
npmx-dev:mainfrom
lukeocodes:feat/llms-txt

Conversation

@lukeocodes

@lukeocodeslukeocodes commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds llms.txt and llms_full.txt support across all package URL patterns.

Supported llms.txt routes

RouteExamplePreview
Root discovery/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/llms.txt
Unscoped package/package/nuxt/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/package/nuxt/llms.txt
Unscoped versioned/package/nuxt/v/3.15.0/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/package/nuxt/v/3.15.0/llms.txt
Scoped package/package/@deepgram/sdk/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/package/@deepgram/sdk/llms.txt
Scoped versioned/package/@deepgram/sdk/v/4.0.0/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/package/@deepgram/sdk/v/4.0.0/llms.txt
Org listing/package/@deepgram/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/package/@deepgram/llms.txt
Full (with agent files)/package/nuxt/llms_full.txthttps://npmx-9wsqop19f-npmx.vercel.app/package/nuxt/llms_full.txt
Shorthand redirect/nuxt/llms.txt/package/nuxt/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/nuxt/llms.txt
Shorthand versioned/nuxt/v/3.15.0/llms.txt/package/nuxt/v/3.15.0/llms.txthttps://npmx-9wsqop19f-npmx.vercel.app/nuxt/v/3.15.0/llms.txt
  • llms.txt — README + metadata only
  • llms_full.txt — README + metadata + agent instruction files (CLAUDE.md, .cursorrules, etc.)

Supported .md routes

RouteExamplePreview
Unscoped package/package/nuxt.mdhttps://npmx-9wsqop19f-npmx.vercel.app/package/nuxt.md
Scoped package/package/@deepgram/sdk.mdhttps://npmx-9wsqop19f-npmx.vercel.app/package/@deepgram/sdk.md
Shorthand redirect/nuxt.md/package/nuxt.mdhttps://npmx-9wsqop19f-npmx.vercel.app/nuxt.md
  • .md — README only

Test plan

  • Root /llms.txt returns 200 with text/markdown content type
  • Unscoped and scoped package routes return 200
  • Versioned package routes return 200 (not 404)
  • Org listing route returns package list with full llms.txt URLs
  • llms_full.txt includes agent instruction files, llms.txt does not
  • Shorthand URLs (e.g. /nuxt/llms.txt) redirect 301 to canonical paths
  • Existing package page routes are unaffected
  • Tests pass

@vercel

vercelBot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
npmx.devReadyReadyPreview, CommentMar 5, 2026 1:01pm
2 Skipped Deployments
ProjectDeploymentActionsUpdated (UTC)
docs.npmx.devIgnoredIgnoredPreviewMar 5, 2026 1:01pm
npmx-lunariaIgnoredIgnoredMar 5, 2026 1:01pm

Request Review

@codecov

codecovBot commented Feb 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
app/pages/package/[[org]]/[name].vue0.00%11 Missing and 2 partials ⚠️
app/pages/index.vue0.00%1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitaiBot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds end-to-end LLM documentation support: new shared types (AgentFile, LlmsTxtResult) and a re-export in shared/types/index.ts; server utilities to discover and fetch agent files, assemble llms.txt/llms_full.txt and package README content; a new middleware (server/middleware/llm-docs.ts) to serve package, org and root llms routes and raw README .md; vitest test alias for #server; comprehensive unit tests for the llm-docs utilities; and a smoke-test script for the new routes. Also updates canonical redirect middleware to preserve optional suffixes.

Possibly related issues

Suggested reviewers

  • danielroe
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description check✅ PassedThe pull request description comprehensively details the llms.txt and llms_full.txt feature addition with supported routes, examples, test plan, and implementation notes.
Merge Conflict Detection✅ Passed✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 2

Comment threadserver/utils/llm-docs.ts
Comment threadserver/utils/llm-docs.ts

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 1

Comment threadserver/utils/llm-docs.ts
@lukeocodes

Copy link
Copy Markdown
ContributorAuthor

@danielroe when merging please add @BYK as a co-author from #151

@coderabbitaicoderabbitaiBot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
server/middleware/llm-docs.ts (1)

35-135: Split the middleware into smaller helpers.
This handler covers multiple routes and behaviours in one block and is well over the “~50 lines” guideline. Consider extracting .md handling, root handling, org handling, and package parsing into dedicated functions.

As per coding guidelines: Keep functions focused and manageable (generally under 50 lines).

Comment threadscripts/smoke-test-llm-docs.sh
Comment threadserver/middleware/canonical-redirects.global.ts
Comment threadserver/utils/llm-docs.ts
Add AgentFile and LlmsTxtResult interfaces for llms.txt generation
and export from the shared types barrel.
Add discoverAgentFiles, fetchAgentFiles, generateLlmsTxt, and
handleLlmsTxt orchestrator for llms.txt generation from npm packages.
Serve llms.txt at /api/registry/llms-txt/[...pkg] following existing
registry API patterns with cached event handler and SWR.
Cover discoverAgentFiles, fetchAgentFiles, and generateLlmsTxt
including root files, directory scanning, graceful failures,
scoped packages, and full/minimal output generation.
Use Nitro server routes at /package/.../llms.txt instead of an API
route with middleware rewriting. Single handler re-exported across
four route files for unscoped, scoped, and versioned URL patterns.
…txt content
Add createPackageLlmsTxtHandler factory for DRY route creation.
handleLlmsTxt now accepts includeAgentFiles option to control whether
agent instruction files are included (llms_full.txt) or omitted (llms.txt).
Add handleOrgLlmsTxt for org-level package listings and
generateRootLlmsTxt for the root /llms.txt discovery page.
Simplify route handlers to single-line factory calls.
Add server middleware to handle llms.txt routes that Nitro's radix3
file-based router cannot resolve (parameterized intermediate segments
don't match literal children). Handles versioned package paths,
org-level package listings, and root /llms.txt discovery page.
Remove broken versioned route files and add llms_full.txt routes.
Extend canonical redirect regexes with optional /llms.txt and
/llms_full.txt suffix capture groups so shorthand URLs like
/nuxt/llms.txt redirect to /package/nuxt/llms.txt. Add explicit
/llms.txt root path skip to prevent it matching as a package name.
Add ISR rules for llms_full.txt and root /llms.txt routes in
nuxt.config.ts. Add #server alias to vitest config for resolving
server utility imports in unit tests.
@lukeocodes

Copy link
Copy Markdown
ContributorAuthor

@danielroe@patak-cat ticky ticky bang bang? <3

Add <link rel="alternate"> tags to HTML head for LLM-friendly document
discovery on homepage, org pages, and package pages.
@shi-gg

Copy link
Copy Markdown
Member

From what I can see, there is no llms.txt for a packages API docs, right?

i.e.: https://npmx.dev/package-docs/linkdave/v/0.1.2

@lukeocodes

Copy link
Copy Markdown
ContributorAuthor

From what I can see, there is no llms.txt for a packages API docs, right?

i.e.: https://npmx.dev/package-docs/linkdave/v/0.1.2

Nope, that seems out of scope for a initial version though

@shi-gg

Copy link
Copy Markdown
Member

fair enough — though I would love to see that in the future

@lukeocodes

Copy link
Copy Markdown
ContributorAuthor

fair enough — though I would love to see that in the future

yeh me too, this felt a little invasive for me for a single PR so i thought i'd limit it much more than what i've done

@shi-ggshi-gg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, but

const full = path.endsWith('/llms-full.txt')
const suffix = full ? '/llms-full.txt' : '/llms.txt'

// Root /llms.txt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

a thing that I personally dislike is the amount of comments that explain very simple statements.

If a comment is needed, the code should be made more readable.

@danielroedanielroe self-assigned this Mar 5, 2026
@shi-gg

shi-gg commented Mar 5, 2026

Copy link
Copy Markdown
Member

I just noticed this happening on paths that I haven't opened before

Screencast.From.2026-03-05.17-49-51.webm
image

@serhalpserhalp added the needs review This PR is waiting for a review from a maintainer label Mar 15, 2026
@serhalp

Copy link
Copy Markdown
Member

@danielroe you're assigned to this one — is that stale? 🤔

@serhalp

Copy link
Copy Markdown
Member

@lukeocodes are you still up for seeing this one through?

@lukeocodes

Copy link
Copy Markdown
ContributorAuthor

@lukeocodes are you still up for seeing this one through?

yup i need to find time to do the follow ups. this is creeping a bit

@serhalpserhalp added the stale This has become stale and may be closed soon label Apr 10, 2026
@serhalpserhalp added this to the Up Next milestone Apr 10, 2026
@github-actionsgithub-actionsBot removed the stale This has become stale and may be closed soon label Apr 18, 2026

@gameromangameroman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lukeocodes

Copy link
Copy Markdown
ContributorAuthor

@danielroe you can close or find someone to pick this one up, it was a little too stop-start trying to get this out for me.

i think my feedback in the discord was that we're expecting these PRs to be perfect at the point of release, instead of introducing them as good and iterating

@github-actionsgithub-actionsBot added stale This has become stale and may be closed soon and removed stale This has become stale and may be closed soon labels May 31, 2026
@github-actionsgithub-actionsBot added the stale This has become stale and may be closed soon label Jul 2, 2026
@ghostdevvghostdevv removed the stale This has become stale and may be closed soon label Jul 6, 2026
@gameromangameroman added the needs discussion An idea that needs more discussion to understand the scope and impact. label Aug 4, 2026
@github-actionsgithub-actionsBot added the stale This has become stale and may be closed soon label Sep 4, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs discussionAn idea that needs more discussion to understand the scope and impact.needs reviewThis PR is waiting for a review from a maintainerstaleThis has become stale and may be closed soon

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

6 participants

@lukeocodes@shi-gg@serhalp@gameroman@danielroe@ghostdevv