单次文件读取消耗4,200 Token
AI Agent只需要180 Token的函数签名,却读取了4,200 Token的整个文件。它解析了本可压缩到42 Token的1,800 Token原始Shell输出。每次文件访问都浪费Token并拖慢工作流程。
观看ctx_read的map模式如何从TypeScript文件中仅提取依赖图和关键签名,将4,200 Token减少到仅180。
6 工具
10种读取模式
从完整缓存读取到熵过滤签名--为每个上下文选择正确的压缩方式。
Shell压缩
95+种模式,支持git、npm、cargo、docker等。输出减少60-90%,零配置。
确定性搜索
正则和语义搜索,稳定排序、有界结果和安全边界。
编辑安全
原子写入,带预像保护、TOCTOU防护和差异证据。
图感知读取
每次文件读取都包含来自Property Graph的评分相关文件——Agent始终知道下一步该读取什么。
增量图更新
基于Git差异的图更新仅修补变更的节点和边,而非重建完整图。
Token密集方言(TDD)
一种压缩协议,最大化每个Token的信息密度--按模型族校准。
13 MCP 工具
LeanCTX读取、压缩和缓存每次文件访问。从10种智能读取模式(从完整缓存读取到熵过滤签名)中选择,利用95+种Shell压缩模式支持git、npm、docker等工具,以及具有稳定结果的确定性搜索。每次读取都感知图:Property Graph对相关文件评分,使Agent始终知道下一步该读取什么。智能缓存使重复读取仅需13个Token。
ctx_read Read file (cached, compressed). Cached re-reads can be ~13 tok when unchanged. Auto-selects optimal mode. Modes: full|map|signatures|diff|aggressive|entropy|task|reference|lines:N-M. fresh=true forces a disk re-read.
ctx_shell Run shell command (compressed output, 95+ patterns). Use raw=true to skip compression. cwd sets working directory (persists across calls via cd tracking). Output redaction is on by default for non-admin roles (admin can disable).
ctx_search Regex code search (.gitignore aware, compact results). Deterministic ordering. Secret-like files (e.g. .env, *.pem) are skipped unless role allows. ignore_gitignore requires explicit policy.
ctx_semantic_search Semantic code search (BM25 + optional embeddings/hybrid). action=reindex to rebuild.
ctx_tree Directory listing with file counts.
ctx_edit Edit a file via search-and-replace. Works without native Read/Edit tools. Use this when the IDE's Edit tool requires Read but Read is unavailable.
ctx_multi_read Batch read files in one call. Same modes as ctx_read.
ctx_smart_read Auto-select optimal read mode for a file.
ctx_delta Incremental diff — sends only changed lines since last read.
ctx_expand Retrieve archived tool output (zero-loss). Large outputs are auto-archived; use this to retrieve full details. Actions: retrieve (default), list.
ctx_outline List all symbols in a file (functions, structs, classes, methods) with signatures. Much fewer tokens than reading the full file.
ctx_symbol Read a specific symbol (function, struct, class) by name. Returns only the symbol code block instead of the entire file. 90-97% fewer tokens than full file read.
ctx_fill Budget-aware context fill — auto-selects compression per file within token limit.
每个输出都附带证明
LeanCTX为每个会话生成证明构件:读取了哪些文件、压缩了什么、哪些检查通过了、Token如何使用。这使AI工作可审计、可重放、值得信赖。