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

Method findRelevantContext

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

1863 * @returns Subgraph of relevant nodes and edges
1864 */
1865 async findRelevantContext(
1866 query: string,
1867 options?: FindRelevantContextOptions
1868 ): Promise<Subgraph> {
1869 // Segment-vocab supplement: FTS keeps camelCase names as single tokens,
1870 // so a word-level query ("auto-scroll to bottom") can never reach
1871 // `pinFeedIfNearBottom` through search alone. Resolve the query's words
1872 // against name_segment_vocab (same precision rules as the prompt hook:
1873 // co-occurrence, else rare singles, verified against live nodes) and hand
1874 // the names down as dampened exact-name seeds. Callers that pass their
1875 // own seedNames keep them; failures degrade to no supplement.
1876 let seedNames = options?.seedNames;
1877 if (seedNames === undefined) {
1878 try {
1879 seedNames = this.getSegmentMatches(extractSegmentSearchWords(query), 8)
1880 .map((m) => m.name);
1881 } catch {
1882 seedNames = [];
1883 }
1884 }
1885 return this.contextBuilder.findRelevantContext(query, { ...options, seedNames });
1886 }
1887
1888 /**
1889 * Build context for a task

Callers 3

context.test.tsFile · 0.45
runFunction · 0.45

Calls 2

getSegmentMatchesMethod · 0.95

Tested by 1

runFunction · 0.36