Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds Content-Type: text/markdown headers to several LLM Markdown routes, appends .mdx links and a tokens section to the LLM text route, and introduces a new tokens.mdx/[category] route that reads, parses, and renders CSS design tokens as Markdown. Changes
Sequence DiagramsequenceDiagram
actor Client
participant Router as Token Route Handler
participant FS as File System
participant Parser as parseCSSFile
participant Formatter as toMarkdown
Client->>Router: GET /tokens.mdx/{category}
Router->>Router: Validate category in CATEGORIES
alt invalid category
Router->>Client: notFound()
else valid category
Router->>FS: Read CSS file for category
alt file missing
Router->>Client: notFound()
else file found
FS-->>Router: CSS content
Router->>Parser: parseCSSFile(content)
Parser-->>Router: sections & tokens
Router->>Formatter: toMarkdown(parsed)
Formatter-->>Router: Markdown string
Router->>Client: 200 Response (Content-Type: text/markdown)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/www/package.json (1)
10-10: Consider wiring token generation into the build pipeline.Line 10 adds the generator, but it isn’t invoked by
build, sotokens.mdcan become stale.♻️ Suggested change
- "build": "next build", + "build": "npm run generate:tokens && next build",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/www/package.json` at line 10, The build pipeline currently doesn't invoke the "generate:tokens" script, so tokens.md can go stale; update the package.json "build" script to run "generate:tokens" as part of the build (e.g., run "npm run generate:tokens" before or as part of the existing "build" script) so that the "generate:tokens" script is executed automatically during builds and keeps tokens.md up to date; reference the "generate:tokens" script name and the "build" script when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/www/scripts/generate-tokens.mjs`:
- Around line 51-65: The parser currently assigns currentComment =
commentMatch[1] and then clears it when the comment startsWith('Example
usage:'), which overwrites and drops existing section headings; instead, only
set currentComment when the extracted comment is not an "Example usage:" line —
i.e., replace the assignment in the comment-handling block so you check
commentMatch[1] first (e.g., let extracted = commentMatch[1]; if
(!extracted.startsWith('Example usage:')) currentComment = extracted;) and leave
currentComment untouched when skipping example comments so sections, selector,
and tokens logic (sections, currentSelector, tokens) retain the prior heading.
In `@apps/www/src/app/`(llms)/llms.txt/route.ts:
- Around line 17-19: The generated links use page.url + ".mdx" which produces
non-resolvable /docs/*.mdx paths; change the link target to the catch-all LLMS
route by using the slug segments from page.slugs (e.g., join with '/'), so build
the link as "/llms.mdx/" + page.slugs.join('/') instead of `${page.url}.mdx`,
keeping the same display text (page.data.title) and description
(page.data.description) in the list.push call in route.ts.
---
Nitpick comments:
In `@apps/www/package.json`:
- Line 10: The build pipeline currently doesn't invoke the "generate:tokens"
script, so tokens.md can go stale; update the package.json "build" script to run
"generate:tokens" as part of the build (e.g., run "npm run generate:tokens"
before or as part of the existing "build" script) so that the "generate:tokens"
script is executed automatically during builds and keeps tokens.md up to date;
reference the "generate:tokens" script name and the "build" script when making
this change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 45cbd980-b3f8-4a1d-afe7-5497d7224a47
📒 Files selected for processing (7)
apps/www/package.jsonapps/www/scripts/generate-tokens.mjsapps/www/src/app/(llms)/llms-full.txt/route.tsapps/www/src/app/(llms)/llms.mdx/[[...slug]]/route.tsapps/www/src/app/(llms)/llms.txt/route.tsapps/www/src/app/(llms)/tokens.mdx/route.tsapps/www/src/app/(llms)/tokens.mdx/tokens.md
There was a problem hiding this comment.
♻️ Duplicate comments (1)
apps/www/scripts/generate-tokens.mjs (1)
53-65:⚠️ Potential issue | 🟡 MinorDon’t clobber section comments when skipping “Example usage” lines.
At Line 63 and Line 64, assigning then nulling
currentCommentdrops the previous heading context, which can mislabel sections in output.Proposed fix
- const commentMatch = trimmed.match(/^\/\*\s*(.+?)\s*\*\/$/); + const commentMatch = trimmed.match(/^\/\*\s*(.+?)\s*\*\/$/); if (commentMatch && currentSelector) { + const nextComment = commentMatch[1]; + if (nextComment.startsWith('Example usage:')) continue; + if (tokens.length) { sections.push({ selector: currentSelector, comment: currentComment, tokens: [...tokens] }); tokens = []; } - currentComment = commentMatch[1]; - if (currentComment.startsWith('Example usage:')) currentComment = null; + currentComment = nextComment; continue; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/www/scripts/generate-tokens.mjs` around lines 53 - 65, The code assigns currentComment = commentMatch[1] then immediately nulls it for "Example usage:" comments which clobbers the previous section heading; change the logic in the comment-handling block (the commentMatch/currentSelector flow that pushes into sections and resets tokens) so you do not overwrite currentComment when the matched comment starts with "Example usage:" — either only assign currentComment when commentMatch[1] does not startWith('Example usage:') or move the startsWith check before assigning; keep existing pushes to sections (sections, tokens, currentSelector) unchanged.
🧹 Nitpick comments (1)
apps/www/scripts/generate-tokens.mjs (1)
99-121: Automate token generation in the build lifecycle to prevent drift.
main()is only executed when this script is run manually, but the runtime route servestokens.mddirectly. Please wire generation into build/prebuild so docs stay in sync with CSS tokens.Suggested wiring (outside this file)
--- a/apps/www/package.json +++ b/apps/www/package.json @@ - "prebuild": "cd ../.. && npm run build:apsara", + "prebuild": "cd ../.. && npm run build:apsara && npm run generate:tokens",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/www/scripts/generate-tokens.mjs` around lines 99 - 121, The generate-tokens script currently only runs when main() is executed manually; wire it into the project build by invoking this script as a build/prebuild step (e.g., add a package.json script entry that runs node apps/www/scripts/generate-tokens.mjs before the docs/build step), ensuring the same FILES/OUTPUT constants and main() entry are used so tokens.md is regenerated automatically; update CI/build pipelines to run that package script (or add a "prebuild" lifecycle script) so build/route serving tokens.md always reflects the CSS token source.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@apps/www/scripts/generate-tokens.mjs`:
- Around line 53-65: The code assigns currentComment = commentMatch[1] then
immediately nulls it for "Example usage:" comments which clobbers the previous
section heading; change the logic in the comment-handling block (the
commentMatch/currentSelector flow that pushes into sections and resets tokens)
so you do not overwrite currentComment when the matched comment starts with
"Example usage:" — either only assign currentComment when commentMatch[1] does
not startWith('Example usage:') or move the startsWith check before assigning;
keep existing pushes to sections (sections, tokens, currentSelector) unchanged.
---
Nitpick comments:
In `@apps/www/scripts/generate-tokens.mjs`:
- Around line 99-121: The generate-tokens script currently only runs when main()
is executed manually; wire it into the project build by invoking this script as
a build/prebuild step (e.g., add a package.json script entry that runs node
apps/www/scripts/generate-tokens.mjs before the docs/build step), ensuring the
same FILES/OUTPUT constants and main() entry are used so tokens.md is
regenerated automatically; update CI/build pipelines to run that package script
(or add a "prebuild" lifecycle script) so build/route serving tokens.md always
reflects the CSS token source.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a88f997a-c7b4-4ab5-8082-3a9e1c077a09
📒 Files selected for processing (2)
apps/www/scripts/generate-tokens.mjsapps/www/src/app/(llms)/tokens.mdx/tokens.md
Remove generate-tokens script and pre-generated .md files. The tokens route now parses CSS files on demand with early 404 if file is missing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
apps/www/src/app/(llms)/tokens.mdx/[category]/route.ts (2)
107-113: Avoidfs.stat+fs.readFilesplit; read once and map ENOENT to 404.Line 107 does a separate existence check before Line 113 reads the file. This adds duplicate I/O and a race window (file can disappear between calls).
🛠️ Single-read pattern
- const exists = await fs.stat(filePath).then( - () => true, - () => false - ); - if (!exists) notFound(); - - const content = await fs.readFile(filePath, 'utf-8'); + let content: string; + try { + content = await fs.readFile(filePath, 'utf-8'); + } catch (error) { + if ((error as NodeJS.ErrnoException).code === 'ENOENT') notFound(); + throw error; + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/www/src/app/`(llms)/tokens.mdx/[category]/route.ts around lines 107 - 113, Replace the two-step existence check (fs.stat -> exists -> notFound()) plus fs.readFile with a single fs.readFile call wrapped in try/catch: attempt to read filePath with fs.readFile('utf-8') and on error check if err.code === 'ENOENT' then call notFound(), otherwise rethrow or propagate the error; remove the prior fs.stat usage to avoid duplicate I/O and the race condition between stat and read.
10-10: Add explicitdynamic = 'force-static'for clarity (optional).
generateStaticParamsis sufficient to pre-render the route for all specified categories at build time. However, addingexport const dynamic = 'force-static'makes the static behavior explicit and prevents confusion about caching intent.♻️ Suggested alignment
+export const dynamic = 'force-static'; export const revalidate = false;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/www/src/app/`(llms)/tokens.mdx/[category]/route.ts at line 10, The route currently exports "revalidate = false" but should also explicitly export "dynamic = 'force-static'"; update the file to add an export const dynamic = 'force-static' alongside the existing export const revalidate = false so the route's static pre-rendering intent is explicit (refer to the exports named revalidate and add the new dynamic export).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/www/src/app/`(llms)/tokens.mdx/[category]/route.ts:
- Around line 5-8: STYLES_DIR currently uses path.resolve(process.cwd(),
'../../packages/raystack/styles') which is brittle in Vercel; replace it with a
defensive candidate-resolution: build an ordered list of plausible bases (e.g.,
process.cwd(), path.join(process.cwd(), 'apps/www'), possibly __dirname), map
each to a candidate via path.resolve(base, '../../packages/raystack/styles'),
use fs.existsSync to pick the first existing candidate and assign that to
STYLES_DIR (and if none exist, throw a clear error). Update the const STYLES_DIR
declaration in route.ts and keep references to path.resolve, process.cwd(), and
add fs.existsSync checks so the route works regardless of working directory.
---
Nitpick comments:
In `@apps/www/src/app/`(llms)/tokens.mdx/[category]/route.ts:
- Around line 107-113: Replace the two-step existence check (fs.stat -> exists
-> notFound()) plus fs.readFile with a single fs.readFile call wrapped in
try/catch: attempt to read filePath with fs.readFile('utf-8') and on error check
if err.code === 'ENOENT' then call notFound(), otherwise rethrow or propagate
the error; remove the prior fs.stat usage to avoid duplicate I/O and the race
condition between stat and read.
- Line 10: The route currently exports "revalidate = false" but should also
explicitly export "dynamic = 'force-static'"; update the file to add an export
const dynamic = 'force-static' alongside the existing export const revalidate =
false so the route's static pre-rendering intent is explicit (refer to the
exports named revalidate and add the new dynamic export).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 394c5712-124d-4cc4-9c5a-697964d72aa0
📒 Files selected for processing (2)
apps/www/src/app/(llms)/llms.txt/route.tsapps/www/src/app/(llms)/tokens.mdx/[category]/route.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/www/src/app/(llms)/llms.txt/route.ts
rohanchkrabrty
left a comment
There was a problem hiding this comment.
Let's add a rewrite for tokens/*.mdx -> tokens.mdx/*. So that the public route exposed is in the format tokens/*.mdx
async rewrites() {
return [
{
source: '/tokens/*.mdx',
destination: '/tokens.mdx/*'
},Rewrite /tokens/:path*.mdx to /tokens.mdx/:path* and update llms.txt links to use the public URL format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Content-Type: text/markdownheader to all LLM routes (llms.txt,llms-full.txt,llms.mdx).mdxsuffix to URLs inllms.txtso agents follow links to markdown, not HTML/tokens.mdx/colors,/tokens.mdx/spacing,/tokens.mdx/typography,/tokens.mdx/effects,/tokens.mdx/radius)generate:tokens) to generate flat, dense token markdown from CSS source filesTest plan
curl http://localhost:3001/llms.txt— URLs should have.mdxsuffix, tokens section listedcurl http://localhost:3001/tokens.mdx/colors— flat token list, no tables/prosecurl http://localhost:3001/docs/components/button.mdx— returns markdown via rewritenpm run generate:tokens— regenerates token files from CSSSummary by CodeRabbit
New Features
Improvements