Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@LadyBluenotes
Copy link
Contributor

@LadyBluenotes LadyBluenotes commented Jan 29, 2026

Summary by CodeRabbit

  • New Features
    • Added an LLM-optimized documentation package for TanStack Router and Start, providing streamlined and deduplicated content for AI consumption.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new @tanstack/llm-docs package that generates LLM-optimized documentation from TanStack Router and Start source files. It includes a comprehensive generation script with content transformation logic, configuration files, and documentation, and adds the package as a workspace dependency across multiple TanStack packages.

Changes

Cohort / File(s) Summary
LLM Docs Package Core
packages/llm-docs/README.md, packages/llm-docs/package.json, packages/llm-docs/project.json
New package definition with metadata, build configuration, and documentation describing purpose, usage, optimization techniques, and regeneration workflow.
LLM Docs Generation Script
packages/llm-docs/scripts/generate.mjs
Complex Node.js script implementing frontmatter stripping, content normalization, code deduplication, interface condensation, note deduplication, whitespace cleanup, and AGENT.md routing file generation for LLM-optimized docs output.
Workspace Dependencies
packages/react-router/package.json, packages/react-start/package.json, packages/router-core/package.json, packages/solid-router/package.json, packages/solid-start/package.json, packages/vue-router/package.json, packages/vue-start/package.json
Added @tanstack/llm-docs as a workspace dependency to multiple TanStack framework packages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through docs so grand,
Trimming tokens, taking a stand!
Interfaces condensed with care,
Duplicates removed everywhere,
LLM wisdom, now prepared! ✨📚

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a new LLM-optimized documentation package for router and start implementations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@nx-cloud
Copy link

nx-cloud bot commented Jan 29, 2026

View your CI Pipeline Execution ↗ for commit e1c34ff

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 9m 38s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 38s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-29 05:43:32 UTC

@LadyBluenotes LadyBluenotes marked this pull request as ready for review January 29, 2026 05:34
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 29, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6545

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6545

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6545

@tanstack/llm-docs

npm i https://pkg.pr.new/TanStack/router/@tanstack/llm-docs@6545

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6545

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6545

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6545

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6545

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6545

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6545

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6545

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6545

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6545

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6545

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6545

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6545

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6545

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6545

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6545

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6545

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6545

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6545

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6545

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6545

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6545

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6545

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6545

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6545

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6545

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6545

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6545

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6545

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6545

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6545

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6545

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6545

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6545

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6545

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6545

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6545

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6545

commit: e1c34ff

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: 3

🤖 Fix all issues with AI agents
In `@packages/llm-docs/scripts/generate.mjs`:
- Line 460: The reduction calculation can divide by zero when totalOriginal is
0; update the computation around the expression that assigns reduction (the line
using Math.round((1 - totalStripped / totalOriginal) * 100)) to guard against
totalOriginal === 0 and produce a sensible default (e.g., 0) instead of
performing the division — replace the direct expression with a conditional that
checks totalOriginal and only computes the percentage when nonzero, otherwise
sets reduction to 0.
- Around line 278-281: The reduction calculation can produce NaN/Infinity when
originalSize is 0; update the object building (where reduced value is set using
strippedSize, originalSize, reduction) to guard against division by zero by
computing reduction as 0 when originalSize is 0 (or when both originalSize and
strippedSize are 0) otherwise use Math.round((1 - strippedSize / originalSize) *
100); locate the code that returns the object with keys strippedSize,
estimatedTokens and reduction and apply this conditional check.

In `@packages/router-core/package.json`:
- Line 163: Remove "@tanstack/llm-docs" from the dependencies list in
package.json and add the same entry under devDependencies (preserve the
"workspace:*" specifier), ensuring package.json keys remain valid JSON; update
any lockfile if present (run install) and run the package tests/build to verify
nothing broke.
🧹 Nitpick comments (3)
packages/solid-router/package.json (1)

109-109: Consider moving @tanstack/llm-docs to devDependencies.

Same concern as noted in router-core/package.json — documentation tooling likely belongs in devDependencies rather than production dependencies to avoid inflating consumer installations.

packages/react-start/package.json (1)

96-96: Consider moving @tanstack/llm-docs to devDependencies.

Consistent with the other packages in this PR, this documentation tooling package likely belongs in devDependencies.

packages/llm-docs/scripts/generate.mjs (1)

474-474: Consider propagating a non-zero exit code on failure.

Currently, if main() throws, the error is logged but the process may still exit with code 0, which could cause CI pipelines to incorrectly report success.

Proposed fix
-main().catch(console.error)
+main().catch((err) => {
+  console.error(err)
+  process.exit(1)
+})

Comment on lines +278 to +281
strippedSize,
estimatedTokens,
reduction: Math.round((1 - strippedSize / originalSize) * 100),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Guard against division by zero for empty files.

If a markdown file is empty, originalSize will be 0, causing reduction to be NaN (or Infinity if strippedSize is also 0).

Proposed fix
-  const reduction = Math.round((1 - strippedSize / originalSize) * 100)
+  const reduction = originalSize > 0
+    ? Math.round((1 - strippedSize / originalSize) * 100)
+    : 0
🤖 Prompt for AI Agents
In `@packages/llm-docs/scripts/generate.mjs` around lines 278 - 281, The reduction
calculation can produce NaN/Infinity when originalSize is 0; update the object
building (where reduced value is set using strippedSize, originalSize,
reduction) to guard against division by zero by computing reduction as 0 when
originalSize is 0 (or when both originalSize and strippedSize are 0) otherwise
use Math.round((1 - strippedSize / originalSize) * 100); locate the code that
returns the object with keys strippedSize, estimatedTokens and reduction and
apply this conditional check.

fs.writeFileSync(path.join(OUTPUT_DIR, 'AGENT.md'), agentMd, 'utf-8')

// Summary
const reduction = Math.round((1 - totalStripped / totalOriginal) * 100)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Same division-by-zero edge case in summary calculation.

If no files are processed (empty docs directories), totalOriginal would be 0.

Proposed fix
-  const reduction = Math.round((1 - totalStripped / totalOriginal) * 100)
+  const reduction = totalOriginal > 0
+    ? Math.round((1 - totalStripped / totalOriginal) * 100)
+    : 0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const reduction = Math.round((1 - totalStripped / totalOriginal) * 100)
const reduction = totalOriginal > 0
? Math.round((1 - totalStripped / totalOriginal) * 100)
: 0
🤖 Prompt for AI Agents
In `@packages/llm-docs/scripts/generate.mjs` at line 460, The reduction
calculation can divide by zero when totalOriginal is 0; update the computation
around the expression that assigns reduction (the line using Math.round((1 -
totalStripped / totalOriginal) * 100)) to guard against totalOriginal === 0 and
produce a sensible default (e.g., 0) instead of performing the division —
replace the direct expression with a conditional that checks totalOriginal and
only computes the percentage when nonzero, otherwise sets reduction to 0.

},
"dependencies": {
"@tanstack/history": "workspace:*",
"@tanstack/llm-docs": "workspace:*",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, let's see the context around line 163 in package.json
echo "=== package.json context around line 163 ==="
sed -n '155,175p' packages/router-core/package.json

echo -e "\n=== Checking for runtime imports of `@tanstack/llm-docs` in router-core/src ==="
rg "@tanstack/llm-docs" packages/router-core/src/ 2>/dev/null || echo "No imports found in src"

echo -e "\n=== Checking if llm-docs is imported anywhere in the router-core directory ==="
rg "@tanstack/llm-docs" packages/router-core/ --type ts --type js --type json 2>/dev/null | grep -v node_modules || echo "No imports found"

echo -e "\n=== Checking dependencies vs devDependencies structure ==="
grep -A 2 '"dependencies"' packages/router-core/package.json | head -5
grep -A 2 '"devDependencies"' packages/router-core/package.json | head -5

Repository: TanStack/router

Length of output: 979


Move @tanstack/llm-docs to devDependencies.

The @tanstack/llm-docs package is not used in any runtime code and should not be a production dependency. This unnecessarily increases bundle size for all consumers of @tanstack/router-core.

🤖 Prompt for AI Agents
In `@packages/router-core/package.json` at line 163, Remove "@tanstack/llm-docs"
from the dependencies list in package.json and add the same entry under
devDependencies (preserve the "workspace:*" specifier), ensuring package.json
keys remain valid JSON; update any lockfile if present (run install) and run the
package tests/build to verify nothing broke.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant