Skip to main content

smart_context

Function smart_context 

Source
pub fn smart_context(
    db: &Database,
    analytics: &Analytics,
    provider: &dyn EmbeddingProvider,
    task: &str,
    config: SmartConfig,
) -> Result<SmartContext>
Expand description

Select files relevant to a task using semantic search and call graph analysis.

ยงAlgorithm

  1. Embed the task description
  2. Find top-N symbols matching the embedding
  3. For each matched symbol:
    • Add the file containing the symbol
    • Expand call graph (callers + callees) to specified depth
    • Add files from expanded symbols
  4. Deduplicate files, keeping highest relevance
  5. Count tokens for each file
  6. Sort by relevance score descending
  7. Include files until token limit is reached