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

Method findRelevantContext

src/index.ts:3388–3409  ·  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

3386 * @returns Subgraph of relevant nodes and edges
3387 */
3388 async findRelevantContext(
3389 query: string,
3390 options?: FindRelevantContextOptions
3391 ): Promise<Subgraph> {
3392 // Segment-vocab supplement: FTS keeps camelCase names as single tokens,
3393 // so a word-level query ("auto-scroll to bottom") can never reach
3394 // `pinFeedIfNearBottom` through search alone. Resolve the query's words
3395 // against name_segment_vocab (same precision rules as the prompt hook:
3396 // co-occurrence, else rare singles, verified against live nodes) and hand
3397 // the names down as dampened exact-name seeds. Callers that pass their
3398 // own seedNames keep them; failures degrade to no supplement.
3399 let seedNames = options?.seedNames;
3400 if (seedNames === undefined) {
3401 try {
3402 seedNames = this.getSegmentMatches(extractSegmentSearchWords(query), 8)
3403 .map((m) => m.name);
3404 } catch {
3405 seedNames = [];
3406 }
3407 }
3408 return this.contextBuilder.findRelevantContext(query, { ...options, seedNames });
3409 }
3410
3411 /**
3412 * Build context for a task

Calls 3

getSegmentMatchesMethod · 0.95
mapMethod · 0.80

Tested by 1

runFunction · 0.36