fix(explore): accurately resolve query file paths and find camelCase symbols
Previously, `codegraph_explore` queries explicitly naming files by path (e.g., `src/routes/m/projects/[id]/runs/[runId]/+page.svelte`) were shredded. Bracketed path segments exploded into "named symbol" seeds, and FTS on fragments like `page` or `runs` admitted every sibling file, starving the user's intended target. This change introduces: - **Query path pinning:** File paths named in a query are now resolved against the index, "pinned," and stripped from the query. Pinned files are guaranteed inclusion, top ranking, and fair allocation. Unresolvable path-like spans are reported. - **Segment vocabulary supplement:** Natural language query terms (e.g., "auto-scroll to bottom") can now reach camelCase identifiers (e.g., `pinFeedIfNearBottom`, `feedAtBottom`) by matching against their constituent segments. - **Variable seeding:** `variable` and `constant` node kinds are now included in identifier seeding, improving recall for `$state`-style variables common in frameworks like Svelte.
This commit is contained in:
+18
-2
@@ -54,7 +54,7 @@ import { EXTRACTION_VERSION } from './extraction/extraction-version';
|
||||
import { getCodeGraphDir } from './directory';
|
||||
import { deriveProjectNameTokens } from './search/query-utils';
|
||||
import { CodeGraphPackageVersion } from './mcp/version';
|
||||
import { segmentLookupVariants, splitIdentifierSegments } from './search/identifier-segments';
|
||||
import { extractSegmentSearchWords, segmentLookupVariants, splitIdentifierSegments } from './search/identifier-segments';
|
||||
import { createYielder } from './resolution/cooperative-yield';
|
||||
import { minRefsForPool } from './resolution/resolver-pool';
|
||||
|
||||
@@ -1823,7 +1823,23 @@ export class CodeGraph {
|
||||
query: string,
|
||||
options?: FindRelevantContextOptions
|
||||
): Promise<Subgraph> {
|
||||
return this.contextBuilder.findRelevantContext(query, options);
|
||||
// Segment-vocab supplement: FTS keeps camelCase names as single tokens,
|
||||
// so a word-level query ("auto-scroll to bottom") can never reach
|
||||
// `pinFeedIfNearBottom` through search alone. Resolve the query's words
|
||||
// against name_segment_vocab (same precision rules as the prompt hook:
|
||||
// co-occurrence, else rare singles, verified against live nodes) and hand
|
||||
// the names down as dampened exact-name seeds. Callers that pass their
|
||||
// own seedNames keep them; failures degrade to no supplement.
|
||||
let seedNames = options?.seedNames;
|
||||
if (seedNames === undefined) {
|
||||
try {
|
||||
seedNames = this.getSegmentMatches(extractSegmentSearchWords(query), 8)
|
||||
.map((m) => m.name);
|
||||
} catch {
|
||||
seedNames = [];
|
||||
}
|
||||
}
|
||||
return this.contextBuilder.findRelevantContext(query, { ...options, seedNames });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user