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