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