Crate reflex

Crate reflex 

Source
Expand description

Reflex: Local-first, structure-aware code search engine

Reflex is a fast, deterministic code search tool designed specifically for AI coding agents. It provides structured results (symbols, spans, scopes) with sub-100ms latency by maintaining a lightweight, incremental cache in .reflex/.

§Architecture

  • Indexer: Scans code and builds trigram index; writes to cache
  • Query Engine: Loads cache on demand; executes deterministic searches; parses symbols at runtime
  • Cache: Memory-mapped storage for trigrams, content, and metadata

§Example Usage

use reflex::{cache::CacheManager, indexer::Indexer, models::IndexConfig};

// Create and initialize index
let cache = CacheManager::new(".");
let config = IndexConfig::default();
let indexer = Indexer::new(cache, config);
let stats = indexer.index(".", false).unwrap();

println!("Indexed {} files", stats.total_files);

Re-exports§

pub use cache::CacheManager;
pub use indexer::Indexer;
pub use models::Dependency;
pub use models::DependencyInfo;
pub use models::FileGroupedResult;
pub use models::ImportType;
pub use models::IndexConfig;
pub use models::IndexStats;
pub use models::IndexStatus;
pub use models::IndexWarning;
pub use models::IndexWarningDetails;
pub use models::IndexedFile;
pub use models::Language;
pub use models::MatchResult;
pub use models::QueryResponse;
pub use models::SearchResult;
pub use models::Span;
pub use models::SymbolKind;
pub use query::QueryEngine;
pub use query::QueryFilter;
pub use watcher::watch;
pub use watcher::WatchConfig;

Modules§

ast_query
AST pattern matching using Tree-sitter queries
background_indexer
Background symbol indexer for transparent caching
cache
Cache management and memory-mapped I/O
cli
CLI argument parsing and command handlers
content_store
Content store for memory-mapped file access
context
Codebase context generation for AI prompts
dependency
Dependency tracking and graph analysis
formatter
Terminal output formatting for query results
git
Git repository utilities for branch tracking
indexer
Indexing engine for parsing source code
interactive
line_filter
Line-based pre-filtering to detect comments and string literals
mcp
MCP (Model Context Protocol) server implementation
models
Core data models for Reflex
output
User-facing output utilities for clean, colored terminal messages
parsers
Tree-sitter parsers for extracting symbols from source code
query
Query engine for searching indexed code
regex_trigrams
Extract literal sequences from regex patterns for trigram optimization
semantic
Semantic query generation using LLMs
symbol_cache
Symbol cache for storing parsed symbols
trigram
Trigram-based inverted index for fast full-text code search
watcher
File system watcher for automatic reindexing