-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add /llm.txt path for LLM-friendly documentation access.
#5269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@emaadali is attempting to deploy a commit to the Gruntwork Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a new docs-starlight module that converts the site's sidebar into starlight-llms custom sets, registers it as a plugin in the Astro config (invoked with the existing Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
docs-starlight/astro.config.mjs(2 hunks)docs-starlight/llms.ts(1 hunks)docs-starlight/package.json(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
docs-starlight/llms.ts (1)
docs-starlight/astro.config.mjs (2)
sidebar(18-91)sidebar(18-91)
🔇 Additional comments (8)
docs-starlight/astro.config.mjs (2)
13-13: LGTM: Import follows Astro conventions.The extensionless import from
"./llms"follows Astro/Vite module resolution conventions for TypeScript files.
208-208: LGTM: Plugin registration is correct.The plugin is properly initialized with the sidebar configuration and registered in the plugins array.
docs-starlight/llms.ts (5)
3-24: LGTM: Type definitions are well-structured.The type definitions accurately model the sidebar structure with proper support for nested items and autogeneration patterns.
26-30: LGTM: Prefix stripping logic is correct.The function properly strips numeric prefixes from directory paths using regex, which aligns with the directory naming convention used in the sidebar configuration.
32-46: LGTM: Path collection logic is correct.The recursive function properly traverses the sidebar structure and collects paths from slugs and autogenerated directories. The use of glob patterns (
**) for autogenerated directories is appropriate.
48-64: LGTM: Sidebar conversion logic is well-implemented.The function correctly transforms sidebar sections into custom sets with proper path collection and deduplication. The explicit return type enhances type safety.
69-72: TherawContent: trueconfiguration is appropriate for LLM training.Raw Markdown provides cleaner, more structured content for language model consumption compared to compiled output. This setting is the correct choice for generating llms.txt files intended to train LLMs on your documentation.
docs-starlight/package.json (1)
28-28: Verify starlight-llms-txt package version and security status.The current version ^0.6.0 specification should be verified against the npm registry to confirm it is the latest stable release. No known security vulnerabilities were detected in available sources, but a direct npm registry audit is recommended.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs-starlight/llms.ts (1)
3-24: Consider using types from the library or framework if available.The manual type definitions work correctly, but if
starlight-llms-txtor Starlight exports types for sidebar structures, using those would improve maintainability and reduce drift.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs-starlight/llms.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
docs-starlight/llms.ts (1)
docs-starlight/astro.config.mjs (2)
sidebar(18-91)sidebar(18-91)
🔇 Additional comments (5)
docs-starlight/llms.ts (5)
26-30: LGTM!The prefix-stripping logic correctly handles multi-segment paths and cleanly removes numeric prefixes like "01-" or "02-" from each segment.
32-46: LGTM!The recursive path collection correctly handles direct slugs, autogenerate directories (with proper prefix stripping), and nested items. The nullish coalescing provides appropriate safety.
48-64: LGTM!The transformation logic is sound. The function correctly aggregates paths from both autogenerate directories and nested items, with appropriate deduplication.
66-71: LGTM!The integration correctly composes the sidebar transformation with the
starlightLlmsTxtcall. The previous debug logging issue has been resolved.
1-1: Library validity confirmed, but version and API options require direct npm registry check.The
starlight-llms-txtlibrary is actively maintained and listed in the official Starlight plugins. However, verify version 0.6.0 is current and that your configuration options match the library's API documentation on npm or the official docs site.
|
|
||
| type Sidebar = SidebarSection[]; | ||
|
|
||
| const stripNumberPrefixes = (path: string): string => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we stripping the number prefixes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is just for the starlight-llms-txt package - we don't strip number prefixes for the sidebar config parameter. The starlight-llms-txt package uses the paths to serve the page contents as markdown on-demand. It cannot resolve the path to the docs file if the paths are prefixed with the numbers that are used by the sidebar config parameter for sorting. It has no impact on any of the existing site code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think I understand. Are you saying the mismatch between the name of the file and the file slug is what's causing problems here? Should we actually be determining the appropriate slug for the page instead of stripping the leading number prefix? I'm thinking of situations like the logging overview page where the slug is docs/reference/logging, not docs/reference/logging/overview, even though that's what you'd get if you just stripped numbers off the front of the file names.
Description
This PR adds the
starlight-llms-txtpackage todocs-starlightto improve how LLMs can navigate the documentation. Specifically, it:/llm.txtpath that is auto-generated from the existingdocs-starlightdocumentation.astro.config.mjsto include the newstarlightLlmsintegration.llms.tsto handle generation and serving of the LLM-readable content.package.jsonto include the new dependency.TODOs
Read the Gruntwork contribution guidelines.
Release Notes (draft)
Added
starlight-llms-txtto auto-generate a/llm.txtpath, giving LLMs access to all documentation content in Markdown format.Migration Guide
No backward-incompatible changes.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.