Skip to content

Conversation

@lukeocodes
Copy link

@lukeocodes lukeocodes commented Feb 11, 2026

Summary

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

Supported routes

Route Example Preview
Root discovery /llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/llms.txt
Unscoped package /package/nuxt/llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/package/nuxt/llms.txt
Unscoped versioned /package/nuxt/v/3.15.0/llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/package/nuxt/v/3.15.0/llms.txt
Scoped package /package/@deepgram/sdk/llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/package/@deepgram/sdk/llms.txt
Scoped versioned /package/@deepgram/sdk/v/4.0.0/llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/package/@deepgram/sdk/v/4.0.0/llms.txt
Org listing /package/@deepgram/llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/package/@deepgram/llms.txt
Full (with agent files) /package/nuxt/llms_full.txt https://npmx-qlxo11tl4-npmx.vercel.app/package/nuxt/llms_full.txt
Shorthand redirect /nuxt/llms.txt/package/nuxt/llms.txt https://npmx-qlxo11tl4-npmx.vercel.app/nuxt/llms.txt
Shorthand versioned /nuxt/v/3.15.0/llms.txt/package/nuxt/v/3.15.0/llms.txt https://npmx-qlxo11tl4-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.)

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
  • Unit tests pass (888/888)

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.
@vercel
Copy link

vercel bot commented Feb 11, 2026

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

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Feb 12, 2026 2:15pm
npmx.dev Ready Ready Preview, Comment Feb 12, 2026 2:15pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Feb 12, 2026 2:15pm

Request Review

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

This PR implements end-to-end llms.txt generation for npm packages. It adds a utility module for discovering agent instruction files from jsDelivr CDN, fetching their content, and generating structured llms.txt documents with package metadata, README content, and agent instructions. A new middleware routes llms.txt requests at multiple levels (root, organisation-level, package-level with optional versioning). Type definitions and canonical redirects are updated to support the feature, along with comprehensive unit tests.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • alexdln
  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing llms.txt and llms_full.txt support implementation across multiple package URL patterns with specific examples and test coverage.

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

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

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
server/utils/llms-txt.ts (1)

297-300: Remove no-op string replacement.

Line 298's pkg.replace('/', '/') replaces a forward slash with itself, which has no effect. This appears to be leftover code or an incomplete implementation.

♻️ Suggested fix
   for (const pkg of packages) {
-    const encodedPkg = pkg.replace('/', '/')
-    lines.push(`- [${pkg}](${baseUrl}/package/${encodedPkg}/llms.txt)`)
+    lines.push(`- [${pkg}](${baseUrl}/package/${pkg}/llms.txt)`)
   }

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

@lukeocodes lukeocodes marked this pull request as draft February 11, 2026 13:51
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.
Test route pattern inclusion, example links, base URL substitution,
and trailing newline for the root /llms.txt discovery page output.
Vercel ISR glob rules (/package/**/llms.txt) create catch-all serverless
functions that intercept requests before Nitro's file-based routes can
resolve them, breaking scoped packages and versioned paths. Move all
llms.txt/llms_full.txt handling into the middleware, remove ISR route
rules, and delete file-based route files.
@lukeocodes lukeocodes changed the title feat(llms-txt): add llms.txt generation for npm packages feat(ui): add llms.txt generation for npm packages Feb 12, 2026
Fix strict TypeScript errors: add fallback for split()[0] possibly
undefined, narrow regex match group types, use non-null assertions
for Record lookups after in-check, and use Nuxt's auto-generated
Packument type instead of @npm/types import.
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.

1 participant