Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/benchmark.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# What our local code-context experiments show

## Front-end repo matrix (plan)

### Now

- Ship `.vue` / `.svelte` indexing, Nuxt/SvelteKit framework claims, and tighter Next.js route detection (SvelteKit `+` routes, Nuxt `app/pages/*.vue`).
- Re-run the five-repo smoke matrix after each fix; keep this section honest.

### Next

- Dedicated Vue/Nuxt and Svelte analyzers (patterns, route conventions) instead of generic-only SPA handling.
- Path-alias coverage for Vite/Nuxt `~/` and monorepo package exports beyond TypeScript `paths`.
- Markdown-heavy repos (docs sites) as a separate benchmark series.

### Done

- 2026-10-30: Cloned and exercised five OSS front-end repos (see table below); fixed SPA file gaps and Next.js false positives; added fixture tests in `tests/frontend-spa-indexing.test.ts`.

### Five-repo smoke (2026-10-30, `reindex --no-embeddings`, Node 22, this branch)

Clones: [shadcn-ui/taxonomy](https://github.com/shadcn-ui/taxonomy) (Next.js), [nuxt/ui](https://github.com/nuxt/ui), [angular/components](https://github.com/angular/components), [sveltejs/kit](https://github.com/sveltejs/kit), [vercel/turbo](https://github.com/vercel/turbo) (pnpm/turbo monorepo with UI apps).

| Repo | Init / reindex / status | Framework metadata | SPA sources in index | Symbol refs | Edit preflight (realistic query) |
| --- | --- | --- | --- | --- | --- |
| taxonomy (Next.js) | pass / pass / ready | Next.js detected | 94 `.tsx` indexed | `cn` useful (241 hits) | not ready — low confidence; top hit was relevant layout |
| nuxt/ui | pass / pass / ready | Nuxt detected (was missing) | **816** `.vue` indexed (was **0**) | `UButton` finds `Button.vue` imports | not ready — low confidence; stale-source hint on some queries |
| angular/components | pass / pass / ready | Angular patterns | TS/Angular only | `MatDialog` static refs OK | not ready — low confidence; dialog hits sensible |
| sveltejs/kit | pass / pass / ready | SvelteKit detected (monorepo deps) | **1011** `.svelte` indexed (was **0**) | `load` very noisy (587 lexical) | not ready — no longer mislabels SvelteKit tests as Next.js pages |
| vercel/turbo | pass / pass / ready; chunk cap warning | monorepo packages listed | UI via Next apps in `examples/` | `Button` finds UI components | not ready — low confidence; 5k chunk cap drops most of repo |

Known limits surfaced here (not fixed in this pass): default 5k chunk cap on very large repos, lexical `load`/`Button` ambiguity, edit preflight still conservative on broad natural-language queries, one Rust-generated TS parse warning in turbo.

---

This report describes local evidence from five ways of giving an AI coding agent context: Raw-native, Codebase Context, jCodeMunch, Repowise, and context-mode. The evidence is split into separate families because retrieval, repeated runs, full-agent observations, and a metered replay do not answer the same question. The families are not pooled into one score.

The clearest current finding is narrow: in this fixed retrieval setup, Codebase Context recovered 25.7% of expected gold files at 11.5% file precision, while fresh indexing had material local cost. These measurements do not show better completed coding tasks.
Expand Down
84 changes: 59 additions & 25 deletions src/analyzers/generic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import {
categorizeDependency
} from '../../utils/dependency-detection.js';
import type { WorkspacePackageJson } from '../../utils/workspace-detection.js';
import {
detectFrontendFrameworkFromDeps,
extractSingleFileComponentScripts
} from '../../utils/frontend-framework-metadata.js';

export class GenericAnalyzer implements FrameworkAnalyzer {
readonly name = 'generic';
Expand Down Expand Up @@ -91,7 +95,9 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
'.css',
'.scss',
'.sass',
'.less'
'.less',
'.vue',
'.svelte'
];
readonly priority = 10; // Low priority - fallback analyzer

Expand All @@ -107,6 +113,7 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
): Promise<AnalysisResult> {
const language = detectLanguage(filePath);
const relativePath = path.relative(process.cwd(), filePath);
const isSingleFileComponent = language === 'vue' || language === 'svelte';

// Parse based on language
let components: CodeComponent[] = [];
Expand All @@ -126,8 +133,20 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
usesTreeSitterSymbols = true;
}

if (language === 'typescript' || language === 'javascript') {
const parsed = await this.parseJSTSFile(filePath, content, language);
const scripts = isSingleFileComponent ? extractSingleFileComponentScripts(content) : [];
if (scripts.length > 0) {
// Module and instance/setup scripts have separate scopes and may use different syntax.
components = [];
usesTreeSitterSymbols = false;
treeSitterGrammar = undefined;
for (const { body, jsx, lineOffset } of scripts) {
const parsed = await this.parseJSTSFile(filePath, body, jsx, lineOffset);
components.push(...parsed.components);
imports.push(...parsed.imports);
exports.push(...parsed.exports);
}
} else if (language === 'typescript' || language === 'javascript') {
const parsed = await this.parseJSTSFile(filePath, content);
imports = parsed.imports;
exports = parsed.exports;

Expand Down Expand Up @@ -217,7 +236,7 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
metadata
);

if (exceedsASTChunkingLimits && chunkComponents.length > 0) {
if ((exceedsASTChunkingLimits || isSingleFileComponent) && chunkComponents.length > 0) {
const componentChunks = chunks.sort((a, b) => a.startLine - b.startLine);
chunks = [];
let coveredThrough = 0;
Expand Down Expand Up @@ -280,6 +299,7 @@ export class GenericAnalyzer implements FrameworkAnalyzer {

let workspaceType: string = 'single';
let workspacePackages: WorkspacePackageJson[] = [];
let frameworkClaim: CodebaseMetadata['framework'];

try {
workspaceType = await detectWorkspaceType(rootPath);
Expand Down Expand Up @@ -309,6 +329,11 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
version: version as string,
category: categorizeDependency(name)
}));

const framework = detectFrontendFrameworkFromDeps(rawDeps);
if (framework) {
frameworkClaim = framework;
}
} catch (_error) {
// skip
}
Expand All @@ -318,6 +343,7 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
rootPath,
languages: [],
dependencies,
framework: frameworkClaim,
architecture: {
type: 'mixed',
layers: {
Expand Down Expand Up @@ -372,7 +398,8 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
private async parseJSTSFile(
filePath: string,
content: string,
_language: 'typescript' | 'javascript'
jsx = filePath.endsWith('x'),
lineOffset = 0
): Promise<{
components: CodeComponent[];
imports: ImportStatement[];
Expand All @@ -389,11 +416,17 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
loc: true,
range: true,
comment: true,
jsx: filePath.endsWith('x')
jsx
});

// Extract imports
for (const node of ast.body) {
for (const statement of ast.body) {
const node =
statement.type === 'ExportNamedDeclaration' ||
statement.type === 'ExportDefaultDeclaration'
? (statement.declaration ?? statement)
: statement;

// Extract imports
if (node.type === 'ImportDeclaration' && node.source.value) {
imports.push({
source: node.source.value as string,
Expand All @@ -409,7 +442,7 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
(s: TSESTree.ImportClause) => s.type === 'ImportDefaultSpecifier'
),
isDynamic: false,
line: node.loc?.start.line
line: node.loc.start.line + lineOffset
});
}

Expand All @@ -418,8 +451,8 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
components.push({
name: node.id.name,
type: 'class',
startLine: node.loc!.start.line,
endLine: node.loc!.end.line,
startLine: node.loc.start.line + lineOffset,
endLine: node.loc.end.line + lineOffset,
metadata: {}
});
}
Expand All @@ -428,8 +461,8 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
components.push({
name: node.id.name,
type: 'function',
startLine: node.loc!.start.line,
endLine: node.loc!.end.line,
startLine: node.loc.start.line + lineOffset,
endLine: node.loc.end.line + lineOffset,
metadata: {}
});
}
Expand All @@ -446,19 +479,19 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
components.push({
name: decl.id.name,
type: isFunction ? 'function' : 'variable',
startLine: decl.loc!.start.line,
endLine: decl.loc!.end.line,
startLine: decl.loc.start.line + lineOffset,
endLine: decl.loc.end.line + lineOffset,
metadata: {}
});
}
}
}

// Extract exports
if (node.type === 'ExportNamedDeclaration') {
if (node.declaration) {
if (node.declaration.type === 'VariableDeclaration') {
for (const decl of node.declaration.declarations) {
if (statement.type === 'ExportNamedDeclaration') {
if (statement.declaration) {
if (statement.declaration.type === 'VariableDeclaration') {
for (const decl of statement.declaration.declarations) {
if (decl.id.type === 'Identifier') {
exports.push({
name: decl.id.name,
Expand All @@ -467,8 +500,8 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
});
}
}
} else if ('id' in node.declaration && node.declaration.id) {
const declId = node.declaration.id as { name: string };
} else if ('id' in statement.declaration && statement.declaration.id) {
const declId = statement.declaration.id as { name: string };
exports.push({
name: declId.name,
isDefault: false,
Expand All @@ -477,8 +510,8 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
}
}

if (node.specifiers) {
for (const spec of node.specifiers) {
if (statement.specifiers) {
for (const spec of statement.specifiers) {
if (spec.type === 'ExportSpecifier') {
exports.push({
name:
Expand All @@ -491,8 +524,9 @@ export class GenericAnalyzer implements FrameworkAnalyzer {
}
}

if (node.type === 'ExportDefaultDeclaration') {
const name = node.declaration.type === 'Identifier' ? node.declaration.name : 'default';
if (statement.type === 'ExportDefaultDeclaration') {
const name =
statement.declaration.type === 'Identifier' ? statement.declaration.name : 'default';
exports.push({
name,
isDefault: true,
Expand Down
Loading
Loading