Skip to content

feat(analyzers): recognize NestJS projects#127

Open
aolin480 wants to merge 7 commits into
PatrickSys:masterfrom
aolin480:feature/nestjs-analyzer
Open

feat(analyzers): recognize NestJS projects#127
aolin480 wants to merge 7 commits into
PatrickSys:masterfrom
aolin480:feature/nestjs-analyzer

Conversation

@aolin480

@aolin480 aolin480 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a NestJS analyzer for controllers, providers, modules, guards, pipes, interceptors, filters, repositories, and common Nest testing patterns.
  • Update the analyzer registry and framework metadata so NestJS can be selected alongside the existing framework analyzers.
  • Refresh React and Next.js analyzer detection with current project patterns and add regression coverage for the updated indicators.
  • Make the searchable chunk limit configurable per project while keeping 5,000 as the default.

Large repository indexing

While indexing a large Nx monorepo project, Codebase Context created more than 22,000 chunks but only kept the first 5,000 in both the semantic and keyword indexes. The limit was hardcoded in CodebaseIndexer, so increasing chunk size would not fix the missing search coverage.

This adds projects[].parsing.maxChunks to ~/.codebase-context/config.json:

{
  "projects": [
    {
      "root": "/path/to/large-project",
      "parsing": {
        "maxChunks": 25000
      }
    }
  ]
}

The default stays at 5,000 for smaller projects. A project can raise the limit when it has enough files to exceed that safety cap. The value is validated as a positive integer and is used by both indexing paths:

  • MCP server indexing loads the project setting through its runtime overrides.
  • codebase-context reindex resolves the current root against the same server config.
  • Semantic embeddings and the keyword index use the same resolved limit, so they keep matching coverage.

Verification

  • pnpm build
  • pnpm format:check
  • pnpm test — 624 tests passed across 87 files
  • Focused server-config and indexer tests — 20 tests passed
  • Verified the installed CLI resolves the configured large-project root to maxChunks: 25000
  • Smoke-tested React, Next.js, and NestJS analyzer behavior against local projects before splitting this branch

Notes

  • The analyzer examples are framework usage signals only; they do not encode project-specific behavior.
  • Raising maxChunks increases embedding time, memory use, and local index size. The override is intentionally per project rather than a larger global default.

aolin480 added 5 commits July 25, 2026 23:46
React 19 and Next 16 added framework signals that the analyzers were not classifying yet. Keep the analyzer surface current without touching core search or indexing behavior.
We work in NestJS code often enough that treating it as generic TypeScript loses useful context. Add a dedicated analyzer for controllers, modules, providers, routes, DI, and common Nest packages so backend code gets the same first-class treatment as React and Next.js.
Large repositories were silently limited to the first 5,000 searchable chunks. Let each configured project raise that safety limit while keeping 5,000 as the default for smaller codebases.

Use the same setting in MCP server and CLI reindex paths so both keyword and semantic indexes cover the same files.
Keep the auto-extracted Git history in project memory so future searches can surface the fixes and test constraints already handled in this repository.
@aolin480
aolin480 marked this pull request as ready for review July 26, 2026 05:12
@greptile-apps

greptile-apps Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds NestJS framework analysis and extends project indexing configuration.

  • Registers and exports a NestJS analyzer that extracts components, routes, dependencies, module metadata, and framework signals.
  • Refreshes React and Next.js pattern and routing detection.
  • Adds a validated per-project parsing.maxChunks override used by CLI and server indexing.
  • Updates framework metadata, documentation, package exports, and regression tests.

Confidence Score: 3/5

The PR should not merge until analyzer selection stops routing common NestJS providers through Angular and React pattern detection distinguishes React's use API from unrelated functions.

The current priority ordering makes standard NestJS @Injectable() files lose Nest-specific analysis, while unqualified name matching introduces incorrect Suspense metadata in valid React files.

Files Needing Attention: src/analyzers/nestjs/index.ts, src/analyzers/react/index.ts

Important Files Changed

Filename Overview
src/analyzers/nestjs/index.ts Adds comprehensive NestJS extraction, but its priority allows Angular's overlapping decorator detection to capture common NestJS provider files first.
src/analyzers/react/index.ts Adds current React hooks and patterns, but textual detection of calls named use creates false Suspense signals.
src/analyzers/nextjs/index.ts Expands App Router special-file recognition, proxy detection, and async metadata detection without an identified defect.
src/core/indexer.ts Makes the existing semantic and keyword chunk cap configurable while retaining the 5,000-chunk default.
src/server/config.ts Parses and validates positive integer per-project chunk limits and resolves configuration by project root.
src/index.ts Registers NestJS and propagates configured chunk limits through server indexing runtime overrides.
src/cli.ts Registers NestJS and loads the selected project's parsing override for direct CLI indexing.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  F[Source file] --> R[Analyzer registry]
  R --> A{Highest-priority analyzer<br/>whose canAnalyze matches}
  A -->|Angular priority 100| NG[Angular analysis]
  A -->|Next.js priority 90| NX[Next.js analysis]
  A -->|NestJS priority 85| NS[NestJS analysis]
  A -->|React priority 80| RE[React analysis]
  A -->|Fallback| GE[Generic analysis]
  NS --> C[NestJS components and route metadata]
  C --> I[Semantic and keyword indexes]
Loading

Reviews (1): Last reviewed commit: "style(indexing): Format project index ov..." | Re-trigger Greptile

readonly version = '1.0.0';
readonly supportedExtensions = ['.ts', '.js', '.mjs', '.cjs', '.mts', '.cts'];
readonly priority = 85;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Angular captures NestJS providers

When a NestJS file contains @Injectable(), the higher-priority Angular analyzer accepts it before this analyzer is considered, causing the file to be indexed as Angular and lose its NestJS-specific component classification and metadata.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment thread src/analyzers/react/index.ts Outdated
Comment on lines +347 to +349
if (calleeName === 'use') {
usesSuspense = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Unbound use calls imply Suspense

When an analyzable React file calls any local or imported function named use, this name-only check marks the file as using Suspense, causing unrelated calls to pollute framework pattern statistics and search metadata.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

aolin480 added 2 commits July 26, 2026 00:59
NestJS imports are a stronger framework signal than Angular's shared decorator names. Give the NestJS analyzer precedence so providers keep their Nest-specific classification and metadata.
A function named use is not necessarily React's API. Track the actual React import binding so local and unrelated use calls do not add hook or Suspense metadata.
@aolin480

Copy link
Copy Markdown
Contributor Author

Greptile identified two issues in this PR, and both have been fixed:

  • Angular could capture NestJS providers before the NestJS analyzer. Fixed in 6093099.
  • Unrelated functions named use could add React hook and Suspense metadata. Fixed in 0154f45.

Both fixes include regression coverage. The build, formatting, typecheck, and full test suite pass with 627 tests across 87 files.

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