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

Method findRelevantContext

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

3369 * @returns Subgraph of relevant nodes and edges
3370 */
3371 async findRelevantContext(
3372 query: string,
3373 options?: FindRelevantContextOptions
3374 ): Promise<Subgraph> {
3375 // Segment-vocab supplement: FTS keeps camelCase names as single tokens,
3376 // so a word-level query ("auto-scroll to bottom") can never reach
3377 // `pinFeedIfNearBottom` through search alone. Resolve the query's words
3378 // against name_segment_vocab (same precision rules as the prompt hook:
3379 // co-occurrence, else rare singles, verified against live nodes) and hand
3380 // the names down as dampened exact-name seeds. Callers that pass their
3381 // own seedNames keep them; failures degrade to no supplement.
3382 let seedNames = options?.seedNames;
3383 if (seedNames === undefined) {
3384 try {
3385 seedNames = this.getSegmentMatches(extractSegmentSearchWords(query), 8)
3386 .map((m) => m.name);
3387 } catch {
3388 seedNames = [];
3389 }
3390 }
3391 return this.contextBuilder.findRelevantContext(query, { ...options, seedNames });
3392 }
3393
3394 /**
3395 * Build context for a task

Calls 3

getSegmentMatchesMethod · 0.95
mapMethod · 0.80

Tested by 1

runFunction · 0.36