Skip to main content

Crate llmgrep

Crate llmgrep 

Source
Expand description

llmgrep - Pattern-based code search powered by Magellan.

This library provides pattern-based code search capabilities using Magellan’s code graph database. It supports symbol search, reference search, call search, AST-based filtering, and algorithm-based analysis.

§Features

  • Symbol Search: Find symbols by name with fuzzy matching
  • Reference Search: Find incoming references to symbols
  • Call Search: Find outgoing function calls from symbols
  • AST Filtering: Filter by AST node kind (functions, loops, etc.)
  • Metrics Filtering: Filter by complexity, fan-in, fan-out
  • Algorithm Integration: Run Magellan algorithms (reachable, dead-code, cycles)

§Quick Start

use llmgrep::Backend;
use std::path::Path;

// Open a Magellan database
let db_path = Path::new(".magellan/llmgrep.db");
let backend = Backend::detect_and_open(db_path)?;

See the query module for search functions and options.

§Modules

  • algorithm - Magellan algorithm integration (reachable, dead-code, cycles)
  • ast - AST node queries and context
  • backend - Backend abstraction (SQLite, Geometric)
  • error - Error types
  • output - Response types and formatting
  • query - Search functions and options
  • safe_extraction - Safe UTF-8 extraction

Re-exports§

pub use query::infer_language;
pub use algorithm::parse_symbol_set_file;
pub use algorithm::resolve_fqn_to_symbol_id;
pub use algorithm::run_magellan_algorithm;
pub use algorithm::AlgorithmOptions;
pub use algorithm::SymbolSet;
pub use algorithm::SymbolSetStrategy;
pub use ast::calculate_decision_depth;
pub use ast::check_ast_table_exists;
pub use ast::expand_shorthand;
pub use ast::expand_shorthand_with_language;
pub use ast::expand_shorthands;
pub use ast::get_node_kinds_for_language;
pub use ast::get_supported_languages;
pub use ast::AstContext;
pub use backend::Backend;
pub use output::PerformanceMetrics;
pub use query::CoverageFilter;
pub use safe_extraction::*;

Modules§

algorithm
Algorithm integration module for Magellan 2.0 graph algorithms.
ast
AST query module for structural code search.
backend
Backend abstraction for SQLite and Geometric storage.
error
Error types for llmgrep.
output
Output formatting and response types for llmgrep.
output_common
Shared output formatting utilities for all response types.
platform
query
Query module for symbol, reference, and call search operations.
safe_extraction
Safe UTF-8 extraction functions for multi-byte character handling.

Enums§

SortMode
Sorting mode for search results