lean-ctx 3.3.7

Context Runtime for AI Agents with CCP. 46 MCP tools, 10 read modes, 90+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing + diaries, 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
pub const DEFAULT_MAX_READ_BYTES: usize = 4 * 1024 * 1024;
pub const DEFAULT_MAX_SHELL_BYTES: usize = 2 * 1024 * 1024;

fn env_usize(key: &str) -> Option<usize> {
    std::env::var(key)
        .ok()
        .and_then(|v| v.trim().parse::<usize>().ok())
}

pub fn max_read_bytes() -> usize {
    env_usize("LCTX_MAX_READ_BYTES")
        .or_else(|| env_usize("LEAN_CTX_MAX_READ_BYTES"))
        .unwrap_or(DEFAULT_MAX_READ_BYTES)
        .max(1024)
}

pub fn max_shell_bytes() -> usize {
    env_usize("LCTX_MAX_SHELL_BYTES")
        .or_else(|| env_usize("LEAN_CTX_MAX_SHELL_BYTES"))
        .unwrap_or(DEFAULT_MAX_SHELL_BYTES)
        .max(1024)
}