Skip to content

features search and context

Bryan edited this page Jun 13, 2026 · 1 revision

Search and context

Active contributors: Bryan

Search and context are the read path agents use most often. Search finds indexed nodes with SQLite FTS, and context turns those hits into a bounded reading list with graph neighbors.

Purpose

search_nodes() in src/lode/storage.py answers raw search queries. build_context_pack() in src/lode/context.py turns search hits into an agent-ready response with summary, must_read, top_hits, related, confidence, and notes.

Directory layout

src/lode/storage.py # search_nodes, find_symbol, get_neighbors
src/lode/context.py # context pack assembly
src/lode/cli.py     # search, symbol, context commands
src/lode/daemon.py  # /search and /context endpoints

How it works

graph LR
    Query --> FTS[node_fts]
    FTS --> Hits[search_nodes]
    Hits --> Rank[context_rank]
    Rank --> MustRead[must_read list]
    Hits --> Neighbors[get_neighbors]
    MustRead --> Pack[context pack]
    Neighbors --> Pack
Loading

The context pack favors local code over ExternalSymbol placeholders through context_rank() in src/lode/context.py. It estimates item cost in estimate_item_cost() and avoids duplicate path/line ranges.

Key source files

File Purpose
src/lode/storage.py FTS, symbol, and neighbor queries.
src/lode/context.py Context response assembly.
src/lode/cli.py CLI commands.
src/lode/daemon.py HTTP endpoints.
tests/test_lode.py Search and context tests.

Entry points for modification

Tune match quality in search_nodes() in src/lode/storage.py or response packing in src/lode/context.py. Keep output bounded and include path/line citations for agent use.

Related pages

Clone this wiki locally