MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / findRelevantContext

Method findRelevantContext

src/index.ts:3285–3306  ·  view source on GitHub ↗

* Find relevant subgraph for a query * * Combines semantic search with graph traversal to find the most * relevant nodes and their relationships for a given query. * * @param query - Natural language query describing the task * @param options - Search and traversal options * @re

(
    query: string,
    options?: FindRelevantContextOptions
  )

Source from the content-addressed store, hash-verified

3283 * @returns Subgraph of relevant nodes and edges
3284 */
3285 async findRelevantContext(
3286 query: string,
3287 options?: FindRelevantContextOptions
3288 ): Promise<Subgraph> {
3289 // Segment-vocab supplement: FTS keeps camelCase names as single tokens,
3290 // so a word-level query ("auto-scroll to bottom") can never reach
3291 // `pinFeedIfNearBottom` through search alone. Resolve the query's words
3292 // against name_segment_vocab (same precision rules as the prompt hook:
3293 // co-occurrence, else rare singles, verified against live nodes) and hand
3294 // the names down as dampened exact-name seeds. Callers that pass their
3295 // own seedNames keep them; failures degrade to no supplement.
3296 let seedNames = options?.seedNames;
3297 if (seedNames === undefined) {
3298 try {
3299 seedNames = this.getSegmentMatches(extractSegmentSearchWords(query), 8)
3300 .map((m) => m.name);
3301 } catch {
3302 seedNames = [];
3303 }
3304 }
3305 return this.contextBuilder.findRelevantContext(query, { ...options, seedNames });
3306 }
3307
3308 /**
3309 * Build context for a task

Calls 3

getSegmentMatchesMethod · 0.95
mapMethod · 0.80

Tested by 1

runFunction · 0.36