lean-ctx 3.6.2

Context Runtime for AI Agents with CCP. 51 MCP tools, 10 read modes, 60+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%.
Documentation
use std::collections::HashMap;
use std::sync::OnceLock;

use tree_sitter::Query;

use super::queries::{get_language, get_query};

pub(crate) fn get_cached_sig_query(file_ext: &str) -> Option<&'static Query> {
    static SIG_QUERY_CACHE: OnceLock<HashMap<&'static str, Query>> = OnceLock::new();

    let cache = SIG_QUERY_CACHE.get_or_init(|| {
        let mut map = HashMap::new();
        let exts: &[&str] = &[
            "rs", "ts", "tsx", "js", "jsx", "py", "go", "java", "c", "h", "cpp", "cc", "cxx",
            "hpp", "rb", "cs", "kt", "kts", "swift", "php", "sh", "bash", "dart", "scala", "sc",
            "ex", "exs", "zig",
        ];
        for &ext in exts {
            if let (Some(lang), Some(src)) = (get_language(ext), get_query(ext)) {
                if let Ok(q) = Query::new(&lang, src) {
                    map.insert(ext, q);
                }
            }
        }
        map
    });

    cache.get(file_ext)
}