yvgude/lean-ctx
Control what your AI can see. LeanCTX (Lean Context) is the context intelligence layer for AI agents — one local Rust binary that decides what they read, remembers what they learn, guards what they touch, and proves what they save. 60–90% fewer tokens as the receipt. 76 MCP tools, 30+ agents, local-first.
它解決的問題
AI 代理常常受到上下文膨脹的困擾,重複的檔案讀取、冗長的 shell 輸出以及長時間的聊天歷史會消耗大量 token,導致成本上升且推理空間減少。LeanCTX 透過管理傳遞給模型的資訊,將 token 使用量減少 60–90%。
工作原理
LeanCTX 作為 AI 代理與其環境(程式碼、shell、資料)之間的本地二進位層。它在兩個層面上運作:
- Read Path: 它使用各種模式(如 AST 簽名或熵過濾視圖)來精確決定從檔案和 shell 指令中提取哪些資訊。
- Wire Path: 它作為本地代理,壓縮系統提示、歷史記錄與工具結果,且保持與模型提供者的提示快取相容。
- Memory & Graph: 它使用屬性圖與會話記憶,在本地跨不同聊天會話持續保存知識。
目標對象
使用 AI 程式碼代理(如 Cursor、Claude Code、Copilot 或 Windsurf)的開發者,想要降低 API 成本、透過節省上下文空間延長有用的編程會話,並保持本地、可攜帶的代理記憶所有權。
重點特色
- Token Reduction: 讀取與 shell 輸出可節省 60–90% 的 token。
- Local-First Memory: 透過本地知識圖在聊天間持續保存任務事實與決策。
- Reversible Compression: 使用內容位址儲存,使被裁剪的資料可按需檢索。
- Model-Agnostic: 可與 OpenAI、Anthropic、Gemini 等合作,且不會將上下文鎖定於特定供應商。
- Observability: 包含儀表板,可即時追蹤 token 使用與預算控制。