lean-ctx 3.9.17

Context Runtime for AI Agents with CCP. 71 MCP tools, 10 read modes, 95+ 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
//! CLI tab-completions: `lean-ctx completions <shell>` generates a script,
//! `lean-ctx __complete <shell> -- <words…>` serves dynamic completions.

mod engine;
mod shells;
pub mod spec;

/// `lean-ctx completions zsh|bash|fish` — print a static completion script.
pub fn run_completions(args: &[String]) {
    let shell = args.first().map_or("zsh", String::as_str);
    let script = match shell {
        "zsh" => shells::zsh_script(),
        "bash" => shells::bash_script(),
        "fish" => shells::fish_script(),
        other => {
            eprintln!("Unknown shell: {other}  (supported: zsh, bash, fish)");
            std::process::exit(1);
        }
    };
    print!("{script}");
}

/// `lean-ctx __complete zsh -- <words…>` — emit completions for the current input.
#[allow(non_snake_case)]
pub fn run___complete(args: &[String]) {
    let (shell, words) = match args.iter().position(|a| a == "--") {
        Some(pos) => {
            let shell = args.first().map_or("zsh", String::as_str);
            (shell, &args[pos + 1..])
        }
        None => ("zsh", args),
    };

    let completions = engine::complete(words);

    let output = match shell {
        "zsh" => shells::format_zsh(&completions),
        "fish" => shells::format_fish(&completions),
        _ => shells::format_bash(&completions),
    };
    print!("{output}");
}