Skip to main content

Module scope

Module scope 

Source
Expand description

Scope-label heuristics for chunks.

Given the index’s tree-sitter symbol table and a chunk, produce a short human-readable label answering “what does this chunk show?”.

Used by formatters (CLI, MCP) to enrich result headers — an agent or human reading the line crates/foo/bar.rs:46-95 [score=0.025] gets a much faster answer to “is this relevant?” when the line ends with defines `Manifest``` or in `fn handle_search```.

Two entry points:

  • chunk_scope_label — one-shot label lookup. Iterates the full symbol slice; fine for one or two labels per call (CLI format, MCP refs handler).
  • ScopeIndex — pre-builds a file_path → symbol indices map so each subsequent label call is O(symbols_in_file) instead of O(total_symbols). The right choice for the TUI render loop, which resolves ~30 labels per redraw.

Structs§

ScopeIndex
Pre-indexed file_path → symbol indices map for fast repeated scope-label lookups (the TUI render loop).

Functions§

chunk_scope_label
Pick a short scope label for a chunk so a reader can route on the result header without reading the body.