lean-ctx 3.6.15

Context Runtime for AI Agents with CCP. 62 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 crate::dashboard::routes::helpers::{detect_project_root_for_dashboard, extract_query_param};

pub(super) fn get_route(
    path: &str,
    query_str: &str,
) -> Option<(&'static str, &'static str, String)> {
    match path {
        "/api/health" => Some(health()),
        "/api/hotspots" => Some(hotspots()),
        "/api/communities" => Some(communities()),
        "/api/smells" => Some(smells(query_str)),
        "/api/smells/summary" => Some(smells_summary()),
        _ => None,
    }
}

fn health() -> (&'static str, &'static str, String) {
    let root = detect_project_root_for_dashboard();
    let result = crate::tools::ctx_architecture::handle("health", None, &root, Some("json"));
    ("200 OK", "application/json", result)
}

fn hotspots() -> (&'static str, &'static str, String) {
    let root = detect_project_root_for_dashboard();
    let result = crate::tools::ctx_architecture::handle("hotspots", None, &root, Some("json"));
    ("200 OK", "application/json", result)
}

fn communities() -> (&'static str, &'static str, String) {
    let root = detect_project_root_for_dashboard();
    let result = crate::tools::ctx_architecture::handle("communities", None, &root, Some("json"));
    ("200 OK", "application/json", result)
}

fn smells(query_str: &str) -> (&'static str, &'static str, String) {
    let root = detect_project_root_for_dashboard();
    let rule = extract_query_param(query_str, "rule");
    let path_filter = extract_query_param(query_str, "path");
    let result = crate::tools::ctx_smells::handle(
        "scan",
        rule.as_deref(),
        path_filter.as_deref(),
        &root,
        Some("json"),
    );
    ("200 OK", "application/json", result)
}

fn smells_summary() -> (&'static str, &'static str, String) {
    let root = detect_project_root_for_dashboard();
    let result = crate::tools::ctx_smells::handle("summary", None, None, &root, Some("json"));
    ("200 OK", "application/json", result)
}