Repository navigation
Add NestJS and Next.js framework support - #24
Conversation
- add deep NestJS and Next.js extraction, retrieval, and impact semantics - add benchmark and documentation coverage for all five JS/TS frameworks - bump package version to 0.9.1 for the release PR Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds NestJS and Next.js framework-aware JS/TS extraction adapters, integrates them into the extraction pipeline, threads framework-role metadata through retrieval and impact scoring, updates docs and package version to 0.9.1, and adds extensive Nest/Next fixtures and tests. Changes
Sequence Diagram(s)sequenceDiagram
participant TS as TypeScript Compiler
participant Adapter as Framework Adapter (Nest/Next)
participant Resolver as Import Resolver & Cache
participant Builder as Node/Edge Builder
participant Store as Graph Store
participant Runtime as Impact/Retrieve
TS->>Adapter: provide parsed source + AST
Adapter->>Adapter: detect framework markers (decorators, file path, directives)
alt Framework matched
Adapter->>Resolver: resolve & read imports
Resolver-->>Adapter: parsed/imported module info (cached)
Adapter->>Builder: emit framework nodes (module/controller/route/page/middleware)
Builder->>Store: persist nodes/edges with framework_role
Adapter->>Builder: compute semantic relations (declares, provides, injects, handles_route, uses_*)
Builder->>Store: persist edges
else No framework detected
Adapter-->>Store: emit base AST extraction nodes/edges
end
Store->>Runtime: nodes/edges available for impact & retrieval scoring
Runtime->>Store: query nodes with framework-aware ranking/boosts
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Review rate limit: 0/1 reviews remaining, refill in 28 minutes and 39 seconds.Comment |
- allow small cross-platform slack in benchmark guardrails - raise the slow generate integration test timeout for Windows runners Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/pipeline/extract/frameworks/nest.ts`:
- Around line 276-281: The current collision check only compares the candidate
id against nodes in this fragment and misses collisions with the local base
extraction (baseNode), so imported Nest nodes can get the same id as a local
symbol; update the collision logic in the block that computes id (using
baseNode, id, collidingNode) to treat a match with baseNode as a collision too —
i.e., if collidingNode exists OR (baseNode && baseNode.id === id &&
baseNode.source_file !== reference.sourceFile) then regenerate id via
_makeId(resolve(reference.sourceFile), reference.label); reference the variables
baseNode, id, collidingNode, _makeId, resolve, reference, nodes and context to
locate and modify the code.
- Around line 531-578: The controller-level `@UsePipes` decorators are never
collected or propagated to routes; add a classPipeRefs by calling
collectUseTargets(classDecorators, bindings.usePipes, localBindings,
importedBindings) (like classGuardRefs/classInterceptorRefs), then merge it into
the method pipes when computing pipeRefs (e.g. const pipeRefs =
[...classPipeRefs, ...collectUseTargets(getDecorators(member),
bindings.usePipes, localBindings, importedBindings)]), so that
addUniqueEdge/createEdge emits uses_pipe edges for controller-wide pipes.
In `@src/pipeline/extract/frameworks/next.ts`:
- Around line 700-710: The code in handlePagesFile is creating a duplicate
next_route_handler node for Pages Router API files already emitted by
semanticSpecForPagesFile; modify handlePagesFile so that when info.kind ===
'api' and the file is a Pages "pages/api/**" file (i.e., the case handled by
semanticSpecForPagesFile) it does NOT emit a separate route node or add a
depends_on edge. Specifically, in handlePagesFile guard the block that returns
the route node (the branch using nextSemanticNodeId(...), label `API
${info.routePath}`, frameworkRole 'next_route_handler', runtimeBoundary
'server') with an additional check that this is not a Pages API file (or consult
the result from semanticSpecForPagesFile) and skip creating the node/edge to
avoid duplication; apply the same fix to the analogous block referenced in the
other location.
- Around line 421-434: The function findNextProjectDirs currently uses
parts.lastIndexOf('app'/'pages') which picks inner/nested segments like app/app
or src/app/pages; change the logic to pick the outermost Next root by finding
the first occurrence instead (use parts.findIndex(p => p === 'app' || p ===
'pages') or compute indexOf for both and take the smallest non-negative index).
Update the calculation of relevantIndex and keep the rest (rootDir,
preferredNextDir calls) the same so appDir/pagesDir derive from the correct
project root.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2760cba3-5b14-45d7-af15-482fdaf79c45
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (34)
CHANGELOG.mdREADME.mddocs/language-capability-matrix.mdexamples/why-graphify.mdpackage.jsonsrc/pipeline/extract/frameworks/core.tssrc/pipeline/extract/frameworks/nest.tssrc/pipeline/extract/frameworks/next.tssrc/runtime/impact.tssrc/runtime/retrieve.tstests/fixtures/nest-auth.controller.tstests/fixtures/nest-auth.module.tstests/fixtures/nest-auth.service.tstests/fixtures/nestjs-common.d.tstests/fixtures/next-app/app/(marketing)/dashboard/[team]/@modal/default.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/ClientTeamPanel.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/actions.tstests/fixtures/next-app/app/(marketing)/dashboard/[team]/error.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/layout.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/loading.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/not-found.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/page.tsxtests/fixtures/next-app/app/(marketing)/dashboard/[team]/template.tsxtests/fixtures/next-app/app/api/teams/[team]/route.tstests/fixtures/next-app/middleware.tstests/fixtures/next-pages/pages/_app.tsxtests/fixtures/next-pages/pages/_document.tsxtests/fixtures/next-pages/pages/_error.tsxtests/fixtures/next-pages/pages/account.tsxtests/fixtures/next-pages/pages/api/auth/[...nextauth].tstests/unit/benchmark-quality.test.tstests/unit/extract-frameworks.test.tstests/unit/impact.test.tstests/unit/retrieve.test.ts
- avoid duplicate Pages Router API route handler nodes - propagate controller-level Nest pipes to extracted routes - guard imported Nest refs against base extraction id collisions - prefer the outermost Next app root for nested literal app segments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
tests/unit/benchmark-quality.test.ts (1)
26-33: ⚡ Quick winExtract
stripFileNodes()into a shared test helper.This is the same filtering helper already used in
tests/unit/retrieve.test.ts, so keeping two copies makes the benchmark and retrieval suites drift independently the next time the file-node rules change.♻️ Suggested direction
- function stripFileNodes(extraction: ReturnType<typeof extractJs>): ReturnType<typeof extractJs> { - const semanticNodeIds = new Set(extraction.nodes.filter((node) => String(node.node_kind ?? '') !== '').map((node) => node.id)) - return { - ...extraction, - nodes: extraction.nodes.filter((node) => semanticNodeIds.has(node.id)), - edges: extraction.edges.filter((edge) => semanticNodeIds.has(edge.source) && semanticNodeIds.has(edge.target)), - } - } + // Move to a shared helper, e.g. `tests/unit/helpers/extraction.ts`, + // and import it from both benchmark and retrieval tests.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/benchmark-quality.test.ts` around lines 26 - 33, The stripFileNodes function duplicates logic already used elsewhere; move this function into a shared test helper module (exporting a function named stripFileNodes that accepts the ReturnType of extractJs) and update the benchmark test to import and use that exported helper instead of its local copy; ensure the helper preserves the same behavior (filters extraction.nodes by semantic node ids and filters edges by source/target presence) and update any imports to reference the new helper so both tests reuse the single implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/pipeline/extract/frameworks/next.ts`:
- Around line 909-927: The route handler node is created without linking to its
exported HTTP method implementation; after you call addSemanticNode(...) to
create routeNodeId, generate or lookup the semantic node id for the function
implementation (use the exported function name from statement.name!.text and the
same id strategy used elsewhere — e.g., nextSemanticNodeId with the
export/function node kind or the existing export-node id generator) and then
create a dependency edge from routeNodeId to that implementation node using the
same edge helper used for middleware/layout exports (the
addSemanticEdge/addDependencyEdge pattern), so the route semantic node points to
the actual GET/POST function implementation.
- Around line 1076-1092: The code currently only uses
defaultExportName(context.sourceFile) which returns null for "export function
middleware(...)" and causes an early return; update the logic in the middleware
handling block to first resolve a named "middleware" export (e.g., check for an
exported symbol named "middleware" on context.sourceFile) and use that as
exportName if present, otherwise fall back to
defaultExportName(context.sourceFile); then call findBaseNode(context,
exportName) and proceed to upsertFrameworkNode and addUniqueEdge as before (keep
middlewareSpec(...) and semanticNodeId creation unchanged).
- Around line 861-890: The annotateBoundaryExports logic is tagging every
top-level declaration regardless of export status; change it to only assign Next
boundary roles to exported callables by checking for export modifiers: for
ts.isFunctionDeclaration(statement) and ts.isClassDeclaration(statement) require
hasExportModifier(statement) before calling
roleForBoundary/addAugmentedBaseNode; for ts.isVariableStatement(statement)
iterate declarations but skip any without hasExportModifier(statement) and only
consider declarations whose initializer is a callable (ts.isArrowFunction,
ts.isFunctionExpression, ts.isClassExpression) — use unparenthesizeExpression to
detect callables and only then compute boundary via functionBoundary and call
addAugmentedBaseNode with the appropriate kind ('function' or 'class').
---
Nitpick comments:
In `@tests/unit/benchmark-quality.test.ts`:
- Around line 26-33: The stripFileNodes function duplicates logic already used
elsewhere; move this function into a shared test helper module (exporting a
function named stripFileNodes that accepts the ReturnType of extractJs) and
update the benchmark test to import and use that exported helper instead of its
local copy; ensure the helper preserves the same behavior (filters
extraction.nodes by semantic node ids and filters edges by source/target
presence) and update any imports to reference the new helper so both tests reuse
the single implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 35acbc55-7ecf-4b32-a8f6-b510f717fc34
📒 Files selected for processing (5)
src/pipeline/extract/frameworks/nest.tssrc/pipeline/extract/frameworks/next.tstests/unit/benchmark-quality.test.tstests/unit/extract-frameworks.test.tstests/unit/generate.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/pipeline/extract/frameworks/nest.ts
- link route-handler semantic nodes to exported HTTP method implementations - support named middleware exports when wiring middleware semantics - limit Next boundary annotations to exported callable declarations Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/pipeline/extract/frameworks/next.ts`:
- Around line 1006-1026: The code is defaulting unrelated imports to
'next_server_action' because createFrameworkNode is given frameworkRole:
binding.frameworkRole ?? 'next_server_action'; remove the fallback so
frameworkRole is only passed when binding.frameworkRole is defined—i.e., change
the createFrameworkNode call to include frameworkRole only if
binding.frameworkRole exists (similar to the runtimeBoundary spread) so plain
imports aren't synthesized as Next server actions; keep the existing conditional
edge additions (the checks on binding.frameworkRole === 'next_server_action' and
'next_client_component') as-is so edges are only created when the role is
actually present.
- Around line 315-337: The code is currently treating every exported variable as
a function/class reference; change the logic in the ts.isVariableStatement
branch to only create and record an export/reference when the declaration's
initializer is actually callable or a class (i.e., when initializer is an
ArrowFunction, FunctionExpression, or ClassExpression). Concretely, use the
existing initializer and functionLike checks (and ts.isClassExpression) to gate
creation of nodeKind, boundary, reference, localBindings.set and recordExport so
that non-callable exports (plain objects, primitives, etc.) are skipped and not
recorded as next_server_action/next_client_component.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9924e894-93c8-4f84-8c80-6e84fea49e9a
📒 Files selected for processing (2)
src/pipeline/extract/frameworks/next.tstests/unit/extract-frameworks.test.ts
- avoid defaulting plain imported bindings to next_server_action - skip non-callable exported variables in Next module analysis Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Test Plan
Summary by CodeRabbit
New Features
Documentation
Tests
Chores