ralph-coder 0.2.1

An agentic code generation CLI powered by multiple LLM backends
Documentation
use crate::symbol_index::SymbolIndex;

/// Search the index for symbols matching `query` (case-insensitive, substring).
pub fn find_symbol(index: &SymbolIndex, query: &str) -> String {
    let results = index.find(query, 20);
    if results.is_empty() {
        return format!(
            "No symbols found matching '{}'. Try a shorter or different term.",
            query
        );
    }
    let mut out = format!(
        "Found {} symbol(s) matching '{}':\n\n",
        results.len(),
        query
    );
    for sym in &results {
        out.push_str(&format!(
            "  {} {}{}:{}\n",
            sym.kind,
            sym.name,
            sym.file.display(),
            sym.line_start,
        ));
    }
    out
}

/// Return the source body of the first symbol named `name` (exact, case-insensitive).
pub fn read_symbol(index: &SymbolIndex, name: &str) -> String {
    match index.read_body(name) {
        Some(body) => body,
        None => format!(
            "Symbol '{}' not found. Use find_symbol to search by partial name.",
            name
        ),
    }
}