Skip to content

Add NestJS and Next.js framework support - #24

Merged
mohanagy merged 5 commits into
mainfrom
feature/nestjs-framework-support
Apr 30, 2026
Merged

mohanagy merged 5 commits into
mainfrom
feature/nestjs-framework-support

Conversation

@mohanagy

@mohanagy mohanagy commented Apr 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add full NestJS and Next.js extraction, retrieval, and impact semantics to complete the five-framework JS/TS support plan
  • add benchmark and retrieval/impact guardrails plus public docs for the shipped framework coverage and compact MCP behavior
  • bump the package and lockfile version to 0.9.1 for the release PR

Test Plan

  • npm run typecheck
  • npm run test:run
  • npm run build

Summary by CodeRabbit

  • New Features

    • Framework-aware JS/TS extraction now covers NestJS and Next.js; retrieval and impact scoring respect framework-specific roles.
  • Documentation

    • README, capability matrix, and docs updated to document five-framework coverage and boundary behavior.
  • Tests

    • Added extensive unit/integration/benchmark tests validating NestJS/Next.js extraction, retrieval quality, and impact semantics.
  • Chores

    • Bumped package version and added 0.9.1 changelog entry.

- 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>
@coderabbitai

coderabbitai Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@mohanagy has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 39 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ba4acff5-92a7-4712-a743-76463d9e5ac1

📥 Commits

Reviewing files that changed from the base of the PR and between 04afdd2 and de4429a.

📒 Files selected for processing (2)
  • src/pipeline/extract/frameworks/next.ts
  • tests/unit/extract-frameworks.test.ts
📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Docs & Manifest
CHANGELOG.md, README.md, docs/language-capability-matrix.md, examples/why-graphify.md, package.json
Bumped package to 0.9.1 and updated docs/capability matrix/readme/examples to document NestJS and Next.js framework-aware extraction and clarify dynamic-boundary fallback behavior.
Extraction Core
src/pipeline/extract/frameworks/core.ts
Added Nest/Next adapters to the default adapter set and expanded allowed external-target edge relation types retained during extraction/merge/filtering.
NestJS Adapter
src/pipeline/extract/frameworks/nest.ts
New exported nestAdapter: detects @nestjs/common and Nest decorators, resolves imports with caching, emits class/module/controller/provider/route nodes, records constructor injects, expands @Module metadata, and attaches uses_guard/uses_interceptor/uses_pipe edges.
Next.js Adapter
src/pipeline/extract/frameworks/next.ts
New exported nextAdapter: matches app/pages/middleware files and directives, infers client/server boundaries, caches module exports, emits semantic route/layout/middleware/action/component nodes, links owners→components/actions (renders/defines_action/depends_on), and applies middleware matcher logic.
Runtime Impact
src/runtime/impact.ts
Extended frameworkSummaryRank to include Nest and Next framework_role values for impact ordering and path selection.
Runtime Retrieve & Scoring
src/runtime/retrieve.ts
Added framework and framework_role to matched nodes, extended intent detection for nest/next and many role signals, threaded framework metadata through scoring/hop expansion, and added framework-role-specific boost rules.
Fixtures: NestJS
tests/fixtures/nest-*.ts, tests/fixtures/nestjs-common.d.ts
Added Nest fixtures (module, controller, service, guard/pipe/interceptor) and an ambient @nestjs/common declaration for tests.
Fixtures: Next App Router
tests/fixtures/next-app/...
Added App Router fixtures: nested segments, parallel slot, layouts/templates/loading/error/not-found/defaults, client components, server actions, API route handlers, and middleware with matcher config.
Fixtures: Next Pages Router
tests/fixtures/next-pages/pages/*
Added Pages Router fixtures: _app, _document, _error, sample page, and an API route.
Tests
tests/unit/benchmark-quality.test.ts, tests/unit/extract-frameworks.test.ts, tests/unit/impact.test.ts, tests/unit/retrieve.test.ts, tests/unit/generate.test.ts
Added/expanded tests: benchmark enforcing retrieval quality across five frameworks, extensive Nest/Next extraction contract tests, impact analysis tests for framework blast-radius, retrieval integration tests validating framework metadata and boosts, and adjusted generateGraph test timeout.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through modules, routes, and stacks,

Nest controllers and Next pages in my sack,
Guards and middleware stitched to each route,
Edges and nodes in a tidy semantic suit,
Five frameworks dancing in one little track.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding framework support for NestJS and Next.js, which is the primary focus of the substantial code additions and feature expansion.
Description check ✅ Passed The PR description follows the template structure with Summary and Test Plan sections completed with specific details, and includes checked checkboxes confirming the testing steps were performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/nestjs-framework-support

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
Review rate limit: 0/1 reviews remaining, refill in 28 minutes and 39 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between eb94d3f and 357e10c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (34)
  • CHANGELOG.md
  • README.md
  • docs/language-capability-matrix.md
  • examples/why-graphify.md
  • package.json
  • src/pipeline/extract/frameworks/core.ts
  • src/pipeline/extract/frameworks/nest.ts
  • src/pipeline/extract/frameworks/next.ts
  • src/runtime/impact.ts
  • src/runtime/retrieve.ts
  • tests/fixtures/nest-auth.controller.ts
  • tests/fixtures/nest-auth.module.ts
  • tests/fixtures/nest-auth.service.ts
  • tests/fixtures/nestjs-common.d.ts
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/@modal/default.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/ClientTeamPanel.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/actions.ts
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/error.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/layout.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/loading.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/not-found.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/page.tsx
  • tests/fixtures/next-app/app/(marketing)/dashboard/[team]/template.tsx
  • tests/fixtures/next-app/app/api/teams/[team]/route.ts
  • tests/fixtures/next-app/middleware.ts
  • tests/fixtures/next-pages/pages/_app.tsx
  • tests/fixtures/next-pages/pages/_document.tsx
  • tests/fixtures/next-pages/pages/_error.tsx
  • tests/fixtures/next-pages/pages/account.tsx
  • tests/fixtures/next-pages/pages/api/auth/[...nextauth].ts
  • tests/unit/benchmark-quality.test.ts
  • tests/unit/extract-frameworks.test.ts
  • tests/unit/impact.test.ts
  • tests/unit/retrieve.test.ts

Comment thread src/pipeline/extract/frameworks/nest.ts Resolved
Comment thread src/pipeline/extract/frameworks/nest.ts Resolved
Comment thread src/pipeline/extract/frameworks/next.ts Resolved
Comment thread src/pipeline/extract/frameworks/next.ts Resolved
- 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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
tests/unit/benchmark-quality.test.ts (1)

26-33: ⚡ Quick win

Extract 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

📥 Commits

Reviewing files that changed from the base of the PR and between 357e10c and f5ae9ca.

📒 Files selected for processing (5)
  • src/pipeline/extract/frameworks/nest.ts
  • src/pipeline/extract/frameworks/next.ts
  • tests/unit/benchmark-quality.test.ts
  • tests/unit/extract-frameworks.test.ts
  • tests/unit/generate.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pipeline/extract/frameworks/nest.ts

Comment thread src/pipeline/extract/frameworks/next.ts Resolved
Comment thread src/pipeline/extract/frameworks/next.ts Resolved
Comment thread src/pipeline/extract/frameworks/next.ts Resolved
- 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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between f5ae9ca and 04afdd2.

📒 Files selected for processing (2)
  • src/pipeline/extract/frameworks/next.ts
  • tests/unit/extract-frameworks.test.ts

Comment thread src/pipeline/extract/frameworks/next.ts Resolved
Comment thread src/pipeline/extract/frameworks/next.ts Resolved
- 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>
@mohanagy
mohanagy merged commit 05e09cb into main Apr 30, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant