From d40242c71aecd836b9e591da9f9b562182cc6d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Ara=C3=BAjo?= Date: Fri, 27 Feb 2026 09:45:48 -0300 Subject: [PATCH] feat: expose llms.txt --- scripts/utils/addSymlinksToDirectoryCache.mjs | 13 ++++++++----- src/constants/fileSymlinks.json | 3 ++- src/middleware/r2Middleware.ts | 3 ++- src/routes/index.ts | 3 +++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/utils/addSymlinksToDirectoryCache.mjs b/scripts/utils/addSymlinksToDirectoryCache.mjs index b682d569..1d4239cf 100644 --- a/scripts/utils/addSymlinksToDirectoryCache.mjs +++ b/scripts/utils/addSymlinksToDirectoryCache.mjs @@ -129,9 +129,10 @@ export async function addStaticFileSymlinksToCache( // 2. It's handled specially and is technically in the root directory, // which we should never be listing thus don't need to add it to the // directory cache. - // So, let's remove it then add it back once we're done handling the rest of - // the static file symlinks. + // So, let's remove them then add them back once we're done handling the rest + // of the static file symlinks. fileSymlinks['node-config-schema.json'] = undefined; + fileSymlinks['llms.txt'] = undefined; // Add the symlinks to the directory cache for (const symlink of Object.keys(fileSymlinks)) { @@ -171,10 +172,11 @@ export async function addStaticFileSymlinksToCache( }); } - // Update the node-config-schema.json file symlink to point to the latest - // version + // Update the node-config-schema.json and llms.txt file symlinks to point to + // the latest version fileSymlinks['node-config-schema.json'] = `${RELEASE_DIR}${latestVersion}/docs/node-config-schema.json`; + fileSymlinks['llms.txt'] = `${RELEASE_DIR}${latestVersion}/docs/llms.txt`; // Update file so it can be used in the worker await writeFile( @@ -201,10 +203,11 @@ export async function addStaticFileSymlinksToCache( * * We use symlinks to point to both files and directories. * - * The file symlinks are more or less static. There are only two that are + * The file symlinks are more or less static. There are only a few that are * constantly updated with each release: * - `nodejs/release/node-latest.tar.gz` * - `node-config-schema.json` + * - `llms.txt` * * The directory symlinks are dynamic with a few exceptions for a select number * of directories in `nodejs/docs/` diff --git a/src/constants/fileSymlinks.json b/src/constants/fileSymlinks.json index 026aab36..25711408 100644 --- a/src/constants/fileSymlinks.json +++ b/src/constants/fileSymlinks.json @@ -68,5 +68,6 @@ "nodejs/release/v0.1.15/node-v0.1.15.tar.gz": "nodejs/release/node-v0.1.15.tar.gz", "nodejs/release/v0.4.12/node-v0.4.12.tar.gz": "nodejs/release/node-v0.4.12.tar.gz", "nodejs/release/v0.1.32/node-v0.1.32.tar.gz": "nodejs/release/node-v0.1.32.tar.gz", - "node-config-schema.json": "nodejs/release/v26.3.0/docs/node-config-schema.json" + "node-config-schema.json": "nodejs/release/v26.3.0/docs/node-config-schema.json", + "llms.txt": "nodejs/release/v26.3.0/docs/llms.txt" } diff --git a/src/middleware/r2Middleware.ts b/src/middleware/r2Middleware.ts index d26000f3..1b81912c 100644 --- a/src/middleware/r2Middleware.ts +++ b/src/middleware/r2Middleware.ts @@ -170,7 +170,8 @@ function getR2Path({ } } else if ( pathname.startsWith('/metrics') || - pathname === '/node-config-schema.json' + pathname === '/node-config-schema.json' || + pathname === '/llms.txt' ) { // Substring to cut off the leading / return pathname.substring(1); diff --git a/src/routes/index.ts b/src/routes/index.ts index 882ba646..253b20ac 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -49,6 +49,9 @@ export function registerRoutes(router: Router): void { router.head('/node-config-schema.json', r2Middleware); router.get('/node-config-schema.json', r2Middleware); + router.head('/llms.txt', r2Middleware); + router.get('/llms.txt', r2Middleware); + router.head('/dist/?:filePath+', r2Middleware, originMiddleware); router.get('/dist/?:filePath+', cachedR2Middleware, originMiddleware);