docs: make Chinese README the default
CodeQL / Analyze (rust) (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CI / CI Green (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 10:25:19 +00:00
parent cf51e38c70
commit 33aa4b4e54
+234 -275
View File
@@ -1,3 +1,9 @@
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/yvgude/lean-ctx) · [上游 README](https://github.com/yvgude/lean-ctx/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
<div align="center">
<pre>
@@ -9,28 +15,21 @@
╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
</pre>
### **Control what your AI can see.**
### **掌控你的 AI 能看到什么。**
**LeanCTX — Lean Context Engineering for AI agents**
**LeanCTX — 面向 AI 智能体的精简上下文工程(Lean Context Engineering**
LeanCTX — short for **Lean Context** — is the context engineering layer for
AI agents. It runs as a single local binary between your agents and everything
they touch — your code, shell, data, and the model itself: it **decides** what
they read, **compresses** what they send (an optional local proxy shrinks every
request — system prompt, history and tool results — prompt-cache-safe),
**remembers** what they learn, **guards** what they touch — and **proves** what
they save with a signed, verifiable savings ledger. The result: 6090% fewer
tokens.
Zero config required.
Local-first.
LeanCTX — **Lean Context** 的缩写 — 是面向 AI 智能体的上下文工程层。它以单一本地二进制程序的形式运行在你的智能体与其所接触的一切之间 — 你的代码、Shell、数据以及模型本身:它**决定**它们读取什么,**压缩**它们发送的内容(可选的本地代理会缩小每一次请求 — 系统提示、历史记录与工具结果 — 且对 prompt cache 安全),**记住**它们所学,**守护**它们所接触的内容 — 并通过带签名的可验证节省账本**证明**它们节省了什么。结果是:token 减少 60–90%。
零配置。
本地优先(Local-first)。
| Problem | With LeanCTX |
| 问题 | 使用 LeanCTX |
|---------|-------------|
| Repeated file reads: ~2000 tokens each | Cached re-reads: **~13 tokens** |
| Raw `git status`: ~800 tokens | Compressed: **~120 tokens** |
| Every turn re-sends the whole history | Proxy compresses each request, **prompt-cache-safe** |
| Context resets every chat | Session memory persists across chats |
| No visibility into context usage | Real-time dashboard + budget control |
| 重复读取文件:每次约 2000 tokens | 缓存后重读:**约 13 tokens** |
| 原始 `git status`:约 800 tokens | 压缩后:**约 120 tokens** |
| 每一轮都重新发送完整历史 | 代理压缩每次请求,**对 prompt cache 安全** |
| 每次聊天上下文都会重置 | 会话记忆跨聊天持久保存 |
| 无法洞察上下文使用情况 | 实时仪表盘 + 预算控制 |
---
@@ -57,11 +56,11 @@ Local-first.
---
> **Control what your AI can see.** LeanCTX — short for **Lean Context** — is the **context engineering layer** for AI agents: one local Rust binary that decides what your agents read, compresses what they send to the model, remembers what they learn, guards what they touch — and proves what they save.
> **掌控你的 AI 能看到什么。** LeanCTX — **Lean Context** 的缩写 — 是面向 AI 智能体的**上下文工程层**:一个本地 Rust 二进制程序,决定你的智能体读取什么、压缩它们发送给模型的内容、记住它们所学、守护它们所接触的内容 — 并证明它们节省了什么。
> Token savings are the receipt. Intelligence is the product. Works with **Cursor, Claude Code, Copilot, Windsurf, Codex, Gemini** and 30+ other agents — no config needed.
> Token 节省是收据,智能才是产品。可与 **CursorClaude CodeCopilotWindsurfCodexGemini** 及其他 30+ 智能体配合使用 — 无需配置。
<p align="center"><strong>See it in action:</strong></p>
<p align="center"><strong>眼见为实:</strong></p>
<table>
<tr>
@@ -70,116 +69,112 @@ Local-first.
<br/>
<strong>Read + Shell</strong>
<br/>
Map-mode reads + compressed CLI output
Map 模式读取 + 压缩后的 CLI 输出
</td>
<td align="center" width="33%">
<img src="assets/leanctx-gain.gif" width="320" alt="lean-ctx gain live dashboard demo">
<br/>
<strong>Gain (live)</strong>
<br/>
Tokens + USD savings in real time
实时 token 与美元节省
</td>
<td align="center" width="33%">
<img src="assets/leanctx-benchmark.gif" width="320" alt="lean-ctx benchmark report demo">
<br/>
<strong>Benchmark proof</strong>
<br/>
Measure compression by language + mode
按语言与模式测量压缩效果
</td>
</tr>
</table>
<p align="center"><sub>All GIFs are generated from reproducible VHS tapes in <code>demo/</code>.</sub></p>
<p align="center"><sub>所有 GIF 均由 <code>demo/</code> 中可复现的 VHS 录像带生成。</sub></p>
## Why developers use LeanCTX
## 开发者为何使用 LeanCTX
- **Longer useful coding sessions** — less context waste = more room for actual code reasoning
- **Lower API costs** — 6090% fewer tokens on reads and shell output, cached re-reads cost ~13 tokens
- **No more "I already showed you this file"** — session memory persists across chats
- **Works with your existing setup** — one `lean-ctx setup` command, no config changes needed
- **Full visibility** — see exactly where your context window budget goes
- **Model-agnostic & yours** — swap OpenAI/Anthropic/Gemini freely; your context and memory stay local and portable, never locked in a vendor's black box
- **更长的有效编码会话** — 减少上下文浪费 = 为实际代码推理留出更多空间
- **更低的 API 成本** — 读取与 Shell 输出 token 减少 6090%,缓存后重读仅需约 13 tokens
- **告别「我已经给你看过这个文件了」** — 会话记忆跨聊天持久保存
- **适配你现有环境** — 一条 `lean-ctx setup` 命令,无需更改配置
- **完全可见** — 精确了解上下文窗口预算花在哪里
- **模型无关且归你所有** — 可自由切换 OpenAI/Anthropic/Gemini;你的上下文与记忆保持本地、可移植,永不锁死在厂商黑盒中
---
<p align="center">
<strong>Saves you tokens?</strong> <a href="https://github.com/yvgude/lean-ctx">Give it a star</a> — it helps others discover LeanCTX.
<strong>帮你省了 token</strong> <a href="https://github.com/yvgude/lean-ctx">点个 Star</a> — 帮助更多人发现 LeanCTX
</p>
---
## Why now — own your context
## 为何是现在 — 拥有你的上下文
Models are converging on commodity. The durable edge isn't *which* model you call — it's your **context**: what your agents read, what they remember, and what you can prove. And the layer that optimizes and *owns* that context can't come from the vendor that bills per token or keeps your memory in a black box — it has to sit on your side.
模型正在趋同于商品化。持久的优势不在于你调用*哪一个*模型 — 而在于你的**上下文**:智能体读取什么、记住什么,以及你能证明什么。而优化并*拥有*该上下文的层,不可能来自按 token 计费或将你的记忆锁在黑盒中的厂商 — 它必须站在你这一侧。
That's the shift behind "agent entities" that live in your chat and remember your company (Claude in Slack, ClickUp Brain): a **context login, not a model login**you end up renting your own company knowledge back. LeanCTX is the opposite layer. It keeps the moat yours: local-first, portable (`.ctxpkg`), and model-agnostic — swap OpenAI, Anthropic or Gemini without losing context or cache. **Own your context; don't rent it back.**
这就是「agent entities」浪潮背后的转变:它们活在你的聊天中并记住你的公司(Claude in SlackClickUp Brain)— 这是一种**上下文登录,而非模型登录** — 你最终是在租回自己的公司知识。LeanCTX 是相反的一层。它让你的护城河归你所有:本地优先、可移植(`.ctxpkg`)、模型无关 — 切换 OpenAIAnthropic Gemini 而不丢失上下文或缓存。**拥有你的上下文;不要把它租回来。**
---
## What it does — the four dimensions of context
## 它能做什么 — 上下文的四个维度
LeanCTX treats context as a managed resource, not an afterthought. One binary
covers the four dimensions that decide how well an AI agent actually performs:
LeanCTX 将上下文视为受管资源,而非事后补救。一个二进制程序覆盖决定 AI 智能体实际表现优劣的四个维度:
### 1. Compression — input efficiency
### 1. 压缩 — 输入效率
Your AI agent reads files and runs commands. LeanCTX compresses both automatically.
你的 AI 智能体会读取文件并运行命令。LeanCTX 自动压缩两者。
- **File reads**: 10 read modes (`full`, `map`, `signatures`, `diff`, `lines:N-M`, `density:X`, …) — cached re-reads cost ~13 tokens
- **Target density** (`density:0.4`): SDE-style budget compression — keeps the highest-entropy lines until ~40% of the original tokens remain, deterministic
- **JIT disclosure**: `signatures` carries line spans and points at `lines:N-M` for targeted expansion — outline first, bodies on demand
- **Shell output**: 95+ shell-output patterns compress git, npm, cargo, docker, kubectl, terraform and more (270 passthrough rules)
- **Tree-sitter AST**: structural understanding for 27 languages — not just text compression
- **Reversible by design (CCR)**: compression never *discards* content — pruned or truncated payloads move to a content-addressed store with a deterministic handle, so the model can pull the original bytes back on demand via `ctx_expand`, `ctx_retrieve`, an in-band marker, or `GET /v1/references/{id}`. [Five recovery paths](docs/comparisons/vs-headroom.md#reversibility)
- **文件读取**10 种读取模式(`full``map``signatures``diff``lines:N-M``density:X`、…)— 缓存后重读仅需约 13 tokens
- **目标密度**`density:0.4`):SDE 风格预算压缩 — 保留最高熵行直至剩余约原 token 数的 40%,结果确定
- **JIT 披露**`signatures` 携带行跨度并指向 `lines:N-M` 以按需定向展开 — 先给大纲,正文按需获取
- **Shell 输出**95+ 种 Shell 输出模式压缩 gitnpmcargodockerkubectlterraform 等(270 条直通规则)
- **Tree-sitter AST**:对 27 种语言进行结构化理解 — 不只是文本压缩
- **可逆设计(CCR**:压缩从不*丢弃*内容 — 被剪枝或截断的载荷移至内容寻址存储并附带确定性句柄,模型可通过 `ctx_expand``ctx_retrieve`、带内标记或 `GET /v1/references/{id}` 按需取回原始字节。[五种恢复路径](docs/comparisons/vs-headroom.md#reversibility)
### 2. Routing — the right fidelity per read
### 2. 路由 — 按读取场景选择合适粒度
Not every file needs the same depth. LeanCTX sends the signal, not the noise.
并非每个文件都需要同等深度。LeanCTX 传递信号,过滤噪声。
- **10 read modes**: from full content down to AST signatures and entropy-filtered views
- **Adaptive `ModePredictor`**: learns the optimal read mode per file type from past sessions
- **`IntentEngine`**: classifies query complexity so simple lookups stay cheap
- **10 种读取模式**:从完整内容到 AST 签名(AST signatures)以及熵过滤视图
- **自适应 `ModePredictor`**:根据过往会话为各文件类型学习最优读取模式
- **`IntentEngine`**:对查询复杂度分类,让简单查找保持低成本
### 3. Memory — context that persists
### 3. 记忆 — 持久化上下文
Context doesn't disappear between chats anymore.
上下文不再在聊天之间消失。
- **Session memory (CCP)**: persist task/facts/decisions across chats — structured recovery queries survive compaction
- **Knowledge graph**: temporal facts with validity windows, episodic + procedural memory
- **Property Graph**: multi-edge code graph (imports, calls, exports, type_ref) powers impact analysis and search ranking
- **Yours, not the vendor's**: memory stays local and portable — export it as a `.ctxpkg` package and move it across machines or models, instead of locking it in a vendor's black box
- **会话记忆(CCP**:在聊天之间持久化任务/事实/决策 — 结构化恢复查询可经受压缩
- **知识图谱(Knowledge graph**:带有效期窗口的时序事实,情节记忆 + 程序性记忆
- **Property Graph**:多边代码图谱(importscallsexportstype_ref)支撑影响分析与搜索排序
- **属于你,而非厂商**:记忆保持本地且可移植 — 导出为 `.ctxpkg` 包,可在机器或模型间迁移,而非锁死在厂商黑箱中
### 4. Verification — control what reaches the model
### 4. 验证 — 控制进入模型的内容
Performance is accuracy, not just speed. You stay in control of the window.
性能关乎准确性,而非仅速度。你始终掌控上下文窗口。
- **Context Manager**: browser dashboard with real-time token tracking, compression stats, utilization gauge
- **Budgets & SLOs**: profiles, roles, per-agent budgets, and throttling policies
- **Context Proof** (`ctx_proof`, `ctx_verify`): 4-layer verification engine with CI drift gates
- **Context Manager**:浏览器仪表盘,实时 token 追踪、压缩统计、利用率仪表
- **预算与 SLO**:配置文件、角色、按智能体预算及限流策略
- **Context Proof**`ctx_proof``ctx_verify`):四层验证引擎,附带 CI 漂移门禁
<details>
<summary><strong>Full feature list (81 MCP tools)</strong></summary>
<summary><strong>完整功能列表(81 个 MCP 工具)</strong></summary>
- **Web & Research** (`ctx_url_read`): pull a public web page, PDF, or YouTube transcript into context as compressed, citation-backed text — `facts`/`quotes` return claims with a confidence score + source URL, relevance-ranked research-compression distils to a token budget, SSRF-guarded (http/https only)
- **Graph-Powered Intelligence**: hybrid search (BM25 + embeddings + graph proximity via RRF), incremental git-diff updates
- **LSP Refactoring** (`ctx_refactor`): language-server-powered rename, references, go-to-definition via rust-analyzer, typescript-language-server, pylsp, gopls
- **Multi-Agent** (`ctx_agent`, `ctx_handoff`): agent handoff with context transfer bundles, diary system, synchronized shared state
- **Archive Full-Text Search** (`ctx_expand search_all`): FTS5-powered cross-archive search over all previously archived tool outputs
- **PR Context Packs**: `lean-ctx pack --pr` builds a PR-ready context pack (changed files, related tests, impact, artifacts)
- **Context Packages**: `lean-ctx pack create` bundles Knowledge + Graph + Session into portable `.ctxpkg` files with SHA-256 integrity
- **Context Time Machine**: `lean-ctx snapshot create|list|show|verify|restore|publish|import` — git-anchored, ed25519-signed snapshots of the layer state (lineage, ledger Φ, ROI, session) on an append-only timeline; replay them in the dashboard, `restore` to resume a session (and `--git` to check out the commit), or `publish`/`import` a signed snapshot to share it ([concept](docs/concepts/context-time-machine.md))
- **Observability**: `lean-ctx gain --live` for real-time savings, `lean-ctx wrapped` for weekly/monthly summaries (`gain --svg`/`--share` for a shareable card or self-hostable page), `lean-ctx watch` for TUI monitoring
- **Verified savings**: `lean-ctx savings` is an auditable, per-event ledger (tokenizer transparency, bounce-netting, tamper-evident SHA-256 chain) — local-only, on by default
- **HTTP mode**: `lean-ctx serve` for Streamable HTTP MCP + `/v1/tools/call` (used by the Cookbook + SDK)
- **Web & Research**`ctx_url_read`):将公开网页、PDF 或 YouTube 转录稿拉入上下文,形成压缩且带引用的文本 — `facts`/`quotes` 返回带置信度评分 + 来源 URL 的断言,按相关性排序的研究压缩可精炼至 token 预算,SSRF 防护(仅 http/https
- **Graph-Powered Intelligence**:混合搜索(BM25 + 嵌入 + 经 RRF 的图邻近度),增量 git-diff 更新
- **LSP Refactoring**`ctx_refactor`):经语言服务器驱动的重命名、引用、跳转定义,支持 rust-analyzertypescript-language-serverpylspgopls
- **Multi-Agent**`ctx_agent``ctx_handoff`):智能体交接含上下文传输包、日记系统、同步共享状态
- **Archive Full-Text Search**`ctx_expand search_all`):FTS5 驱动的跨归档全文搜索,覆盖所有此前归档的工具输出
- **PR Context Packs**`lean-ctx pack --pr` 构建 PR 就绪上下文包(变更文件、相关测试、影响、产物)
- **Context Packages**`lean-ctx pack create` Knowledge + Graph + Session 打包为可移植的 `.ctxpkg` 文件,SHA-256 完整性校验
- **Context Time Machine**`lean-ctx snapshot create|list|show|verify|restore|publish|import` git 为锚、ed25519 签名的层状态快照(lineageledger ΦROIsession),存于仅追加时间线;在仪表盘中回放,`restore` 恢复会话(`--git` 检出提交),或 `publish`/`import` 签名快照以共享([概念](docs/concepts/context-time-machine.md)
- **Observability**`lean-ctx gain --live` 实时节省,`lean-ctx wrapped` 周/月摘要(`gain --svg`/`--share` 可分享卡片或自托管页面),`lean-ctx watch` TUI 监控
- **Verified savings**`lean-ctx savings` 是可审计的逐事件账本(分词器透明、bounce-netting、防篡改 SHA-256 链)— 仅本地,默认开启
- **HTTP mode**`lean-ctx serve` 用于 Streamable HTTP MCP + `/v1/tools/call`Cookbook + SDK 使用)
</details>
## Addons — run the ecosystem through one gateway
## Addons — 通过单一网关运行整个生态
You don't have to choose between LeanCTX and the other context tools you already
like. An **addon** wraps any MCP server in a tiny `lean-ctx-addon.toml` manifest;
LeanCTX runs it behind its gateway with one command, then treats what it returns
like your own reads instead of just proxying it.
你不必在 LeanCTX 与现有其他上下文工具之间二选一。**addon** 将任意 MCP 服务器封装在精简的 `lean-ctx-addon.toml` 清单中;LeanCTX 一条命令即在网关后运行它,并将其返回值当作自有读取处理,而非单纯代理。
```bash
lean-ctx addon search memory # browse the registry by category
@@ -187,46 +182,42 @@ lean-ctx addon add headroom # installs the upstream package + wires the MCP s
lean-ctx addon list # what's wired into your gateway
```
- **One command to add** — `addon add <name>` installs the upstream package via its native manager (uv, pip, cargo, npm, brew, dotnet) and wires the MCP server into your gateway. No fork, no recompile.
- **Folded in, not just proxied** — opt-in post-processing runs addon output through the same pipeline as your code: compress to a budget, spill oversized blobs to a `ctx_expand` handle, index into BM25 / graph / knowledge. Typed adapters route specific tools straight into `ctx_expand`, `ctx_callgraph` and `ctx_knowledge`.
- **Untrusted by default** — every addon's output is scrubbed for secrets and tagged untrusted before it reaches the model. Always on, not a flag.
- **You stay in control** — pin a machine or fleet to verified-only, an allowlist, or off entirely via one `[addons]` policy a single repo can't override.
- **一条命令添加** — `addon add <name>` 通过原生包管理器(uv、pipcargonpmbrewdotnet)安装上游包,并将 MCP 服务器接入网关。无需 fork,无需重新编译。
- **融入处理,而非仅代理** — 可选后处理将 addon 输出经与代码相同的流水线:压缩至预算、将超大块溢出至 `ctx_expand` 句柄、索引至 BM25 / graph / knowledge。类型化适配器将特定工具直接路由至 `ctx_expand``ctx_callgraph` `ctx_knowledge`
- **默认不可信** — 每个 addon 输出在抵达模型前均会清除机密并标记为不可信。始终开启,非可选开关。
- **你始终掌控** — 通过单一 `[addons]` 策略将单机或集群固定为仅 verified、白名单或完全关闭,单个仓库无法覆盖。
The registry spans compression (Headroom, Sophon), code intelligence (Repomix,
Serena), memory (Mem0, Cognee, Letta) and reasoning (Sequential Thinking). See the
**[addon guide](docs/guides/addons.md)** or [browse them all](https://leanctx.com/addons/).
注册表涵盖压缩(HeadroomSophon)、代码智能(Repomix、Serena)、记忆(Mem0、Cognee、Letta)与推理(Sequential Thinking)。参阅 **[addon 指南](docs/guides/addons.md)** 或 [浏览全部](https://leanctx.com/addons/).
## Where it's going
## 发展方向
LeanCTX is growing from a single context *layer* into a full **cognitive context
layer** for whole teams: version-controlled context strategy, one unified graph, and a
governance layer across many agents.
LeanCTX 正从单一上下文*层*成长为面向整支团队的完整**认知上下文层**:版本化的上下文策略、统一图谱,以及跨多智能体的治理层。
- **Context Time Machine → hosted history** — the snapshot engine, dashboard replay, restore, and signed file-based share/import have shipped (see above); next is a `ctxpkg.com` registry for hosted, versioned context history and a side-by-side model-view git-diff replay. The temporal axis through everything LeanCTX does — it *decides, remembers, guards, proves, and replays*. ([concept](docs/concepts/context-time-machine.md))
- **Context as Code** — declarative pipelines, profiles, and policies in TOML, versioned like infrastructure
- **Unified Context Graph** — code, tests, commits, CI runs, and knowledge entries in a single semantic graph
- **Agent Harness** — roles, budgets, and tool permissions for multi-agent governance
- **Context Observability** — SLOs on context consumption, anomaly detection, OpenTelemetry / Prometheus export
- **Context Time Machine → 托管历史** — 快照引擎、仪表盘回放、恢复及基于签名文件的共享/导入已交付(见上文);下一步是 `ctxpkg.com` 注册表,用于托管、版本化的上下文历史,以及并排模型视图 | git-diff 回放。时间轴贯穿 LeanCTX 所做一切 — 它*决策、记忆、守护、验证并回放*。([概念](docs/concepts/context-time-machine.md)
- **Context as Code** — TOML 中的声明式流水线、配置文件与策略,像基础设施一样版本化
- **Unified Context Graph** — 代码、测试、提交、CI 运行与知识条目汇入单一语义图谱
- **Agent Harness** — 多智能体治理的角色、预算与工具权限
- **Context Observability** — 上下文消耗的 SLO、异常检测、OpenTelemetry / Prometheus 导出
The full roadmap lives in **[VISION.md](VISION.md)**.
完整路线图见 **[VISION.md](VISION.md)**
## How it works (30 seconds)
## 工作原理(30 秒)
LeanCTX works on **two planes** — what your agents *read* and what they *send to the model*:
LeanCTX 在**两个平面**上运作 — 智能体*读取*什么,以及向模型*发送*什么:
```
read path: AI tool → (MCP tools + shell) → lean-ctx → your repo + CLI
wire path: AI tool → lean-ctx proxy → model provider (every request, compressed)
```
- **MCP server** *(read path)*: exposes `ctx_*` tools (read modes, caching, deltas, search, memory, multi-agent)
- **Shell hook** *(read path)*: transparently compresses common commands so the LLM sees less noise
- **Request proxy** *(wire path, opt-in)*: `lean-ctx proxy enable` puts a local proxy between your agent and the model that compresses **every request**system prompt, full history and tool results — prompt-cache-safe, with measured USD spend. It can also pin **one reasoning-effort level across OpenAI, Anthropic & Gemini** (`proxy.effort`) without breaking that cache, cut **output** tokens with a cache-safe verbosity steer plus a measured holdout, and **relocate volatile fields** (dates, UUIDs, commit SHAs) out of the cacheable prefix so a stable system prompt finally caches. Every rewrite is reversible (content-addressed recovery) and byte-stable by contract. Same layer as a standalone request-compression proxy (e.g. Headroom) — you don't need one on top.
- **Property Graph**: multi-edge code graph powers impact analysis, related file discovery, and search ranking
- **Session memory**: persists state with structured recovery so long-running work never "cold starts"
- **Context Manager**: browser dashboard for real-time visibility into what's in your context window
- **MCP server** *(读取路径)*:暴露 `ctx_*` 工具(读取模式、缓存、增量、搜索、记忆、多智能体)
- **Shell hook** *(读取路径)*:透明压缩常用命令,让 LLM 看到更少噪声
- **Request proxy** *(线路路径,可选)*`lean-ctx proxy enable` 在智能体与模型之间放置本地代理,压缩**每个请求** — 系统提示、完整历史与工具结果 — 提示缓存安全,并计量 USD 花费。还可跨 OpenAIAnthropic Gemini 固定**单一推理力度级别**`proxy.effort`)而不破坏该缓存,通过缓存安全的冗长度引导加计量 holdout 削减**输出** token,并将**易变字段**(日期、UUIDcommit SHA)移出可缓存前缀,使稳定的系统提示终于可缓存。每次重写可逆(按内容寻址恢复),按契约字节稳定。与独立请求压缩代理(如 Headroom)同一层 — 无需再叠一层。
- **Property Graph**:多边代码图谱支撑影响分析、相关文件发现与搜索排序
- **Session memory**:持久化状态并支持结构化恢复,长跑任务永不「冷启动」
- **Context Manager**:浏览器仪表盘,实时查看上下文窗口内容
## Get started (30 seconds)
## 快速开始(30 秒)
```bash
# 1) Install (pick one)
@@ -243,10 +234,10 @@ lean-ctx wrap cursor # or: wrap claude / wrap codex / wrap vscode
lean-ctx gain
```
`lean-ctx wrap` installs shell hooks, registers the MCP server, sets up agent hooks, starts the daemon, and verifies the connection — all in one command. Undo anytime with `lean-ctx unwrap cursor`.
`lean-ctx wrap` 一条命令即可完成:安装 shell hooks、注册 MCP 服务器、配置 agent hooks、启动守护进程并验证连接。随时可用 `lean-ctx unwrap cursor` 撤销。
<details>
<summary><strong>Alternative: full control</strong></summary>
<summary><strong>备选方案:完全控制</strong></summary>
```bash
lean-ctx onboard # connect all detected AI tools (zero prompts)
@@ -255,26 +246,26 @@ lean-ctx setup # interactive wizard with every option
</details>
**Building from source on Windows?** Clone the repo and run `./install.ps1` in PowerShell — it builds the release binary and installs it into Cargo's bin directory (pass `-BuildOnly` to build without installing).
**在 Windows 上从源码构建?** 克隆仓库并在 PowerShell 中运行 `./install.ps1` —— 它会构建 release 二进制文件并安装到 Cargo bin 目录(传入 `-BuildOnly` 可仅构建不安装)。
<details>
<summary><strong>Troubleshooting / Safety</strong></summary>
<summary><strong>故障排查 / 安全</strong></summary>
- Disable immediately (current shell): `lean-ctx-off`
- Run a single command uncompressed: `lean-ctx -c --raw "git status"`
- Only activate in AI agent sessions: set `shell_activation = "agents-only"` in `~/.config/lean-ctx/config.toml`
- Per-project config override: create `.lean-ctx.toml` in your project root (auto-merged with global config)
- Docker projects sharing `/workspace`: create `.lean-ctx-id` with a unique name to prevent context collisions
- Update: `lean-ctx update`
- Diagnose (shareable): `lean-ctx doctor --json`
- 立即禁用(当前 shell):`lean-ctx-off`
- 以未压缩方式运行单条命令:`lean-ctx -c --raw "git status"`
- 仅在 AI agent 会话中启用:在 `~/.config/lean-ctx/config.toml` 中设置 `shell_activation = "agents-only"`
- 按项目覆盖配置:在项目根目录创建 `.lean-ctx.toml`(自动与全局配置合并)
- 共享 `/workspace` 的 Docker 项目:创建 `.lean-ctx-id` 并使用唯一名称,以避免上下文冲突
- 更新:`lean-ctx update`
- 诊断(可分享):`lean-ctx doctor --json`
</details>
## Use it from your own code (SDKs)
## 在你的代码中使用(SDK
Beyond the CLI, lean-ctx ships published libraries so you can call it directly from your app.
CLI 外,lean-ctx 还提供已发布的库,可直接从应用中调用。
**Drop-in prompt compression — [`lean-ctx-sdk`](https://pypi.org/project/lean-ctx-sdk/) ([npm](https://www.npmjs.com/package/lean-ctx-sdk)).** Compress a chat-style `messages` array before it reaches any model — deterministic and prompt-cache friendly; images, tool-calls and ids pass through untouched.
**即插即用的 prompt 压缩 — [`lean-ctx-sdk`](https://pypi.org/project/lean-ctx-sdk/) ([npm](https://www.npmjs.com/package/lean-ctx-sdk)).** 在对话式 `messages` 数组到达任何模型之前进行压缩——确定性且对 prompt 缓存友好;图片、tool-calls 和 id 均原样透传。
```python
# pip install lean-ctx-sdk
@@ -288,9 +279,9 @@ import { compress } from "lean-ctx-sdk";
messages = await compress(messages, { model: "gpt-4o" });
```
Framework adapters included (LiteLLM, LangChain, Vercel AI SDK). **[compress() cookbook](docs/guides/compress-sdk.md)**
包含框架适配器(LiteLLMLangChainVercel AI SDK)。**[compress() cookbook](docs/guides/compress-sdk.md)**
**Thin `/v1` contract clients — [`lean-ctx-client`](https://pypi.org/project/lean-ctx-client/) ([npm](https://www.npmjs.com/package/lean-ctx-client) · [crates.io](https://crates.io/crates/lean-ctx-client)).** Wrap the full `/v1` tool, event and session API over the process boundary — never links the engine, so it stays stable as lean-ctx evolves.
**轻量 `/v1` 契约客户端 — [`lean-ctx-client`](https://pypi.org/project/lean-ctx-client/) ([npm](https://www.npmjs.com/package/lean-ctx-client) · [crates.io](https://crates.io/crates/lean-ctx-client)).** 在进程边界上封装完整的 `/v1` 工具、事件与会话 API——不链接引擎,因此在 lean-ctx 演进时保持稳定。
```bash
pip install lean-ctx-client # Python (imports as `leanctx`)
@@ -298,49 +289,46 @@ npm install lean-ctx-client # TypeScript / Node
cargo add lean-ctx-client # Rust
```
Start the server with `lean-ctx serve`, then point a client at it. **[API reference](https://leanctx.com/docs/api-reference/)**
使用 `lean-ctx serve` 启动服务器,然后将客户端指向它。**[API 参考](https://leanctx.com/docs/api-reference/)**
## Real-world scenarios
## 真实场景
LeanCTX grows with you. Below are the journeys most people actually take — each
links to a complete, function-by-function walkthrough in the
**[Reference](docs/reference/README.md)** (every CLI command and all 79 MCP
tools are documented there).
LeanCTX 会随你一起成长。以下是大多数人实际会经历的路径——每条都链接到 **[参考文档](docs/reference/README.md)** 中的完整、逐项功能讲解(所有 CLI 命令及全部 79 个 MCP 工具均记录于其中)。
<table>
<tr>
<td width="50%" valign="top">
### 🟢 Your first 30 seconds
*"I just installed it — now what?"*
### 🟢 最初 30 秒
*「刚装好——接下来做什么?」*
```bash
lean-ctx wrap cursor # one-command setup for your agent
lean-ctx doctor # confirm you're wired up
```
One command installs hooks, MCP registration, and verifies the connection.
**[Journey 1 — Setup & Onboarding](docs/reference/01-setup-and-onboarding.md)**
一条命令即可安装 hooks、完成 MCP 注册并验证连接。
**[旅程 1 — 安装与入门](docs/reference/01-setup-and-onboarding.md)**
</td>
<td width="50%" valign="top">
### 📖 Coding every day
*"Stop re-reading the same files."*
### 📖 日常编码
*「别再反复读同一批文件。」*
```bash
lean-ctx read src/server.rs -m map # API surface, ~13 tok on re-read
lean-ctx -c "git status" # compressed shell output
```
Your agent reads less and searches smarter — automatically.
**[Journey 2 — Daily Use](docs/reference/02-daily-use.md)**
你的 agent 自动读得更少、搜得更准。
**[旅程 2 — 日常使用](docs/reference/02-daily-use.md)**
</td>
</tr>
<tr>
<td width="50%" valign="top">
### 🧠 Resume where you left off
*"My new chat forgot everything."*
### 🧠 从上次中断处继续
*「新对话把之前全忘了。」*
```bash
lean-ctx overview # task-aware project recap
@@ -348,150 +336,149 @@ lean-ctx knowledge recall "auth" # facts that survive resets
lean-ctx knowledge consolidate # import session + compact lifecycle
lean-ctx knowledge consolidate --all # compact every project store
```
Session memory + a project knowledge graph persist across chats.
**[Journey 3 — Memory & Knowledge](docs/reference/03-memory-and-knowledge.md)**
会话记忆 + 项目知识图谱可在多次对话间持久保存。
**[旅程 3 — 记忆与知识](docs/reference/03-memory-and-knowledge.md)**
</td>
<td width="50%" valign="top">
### 🗺️ Understand a new codebase
*"Where does this function ripple to?"*
### 🗺️ 理解新代码库
*「这个函数会影响到哪里?」*
```bash
lean-ctx graph impact src/auth.rs # blast radius
lean-ctx smells scan # code-smell hotspots
```
A multi-edge property graph powers impact analysis + ranked search.
**[Journey 4 — Code Intelligence](docs/reference/04-code-intelligence.md)**
多边属性图(property graph)支撑影响分析 + 排序搜索。
**[旅程 4 — 代码智能](docs/reference/04-code-intelligence.md)**
</td>
</tr>
<tr>
<td width="50%" valign="top">
### 🔌 Providers & multi-repo
*"Pull in GitHub issues and our Postgres schema."*
### 🔌 提供方与多仓库
*「拉取 GitHub issues 和我们的 Postgres schema。」*
```bash
lean-ctx provider list
lean-ctx serve --root ./api --root ./web # multi-repo
```
External data flows through the same consolidation pipeline.
**[Journey 5 — Advanced & Integrations](docs/reference/05-advanced.md)**
外部数据经同一整合流水线流入。
**[旅程 5 — 高级功能与集成](docs/reference/05-advanced.md)**
</td>
<td width="50%" valign="top">
### 🛠️ Keep it healthy
*"Update, fix, or cleanly remove."*
### 🛠️ 保持健康运行
*「更新、修复或干净卸载。」*
```bash
lean-ctx doctor --fix
lean-ctx update
```
Self-healing diagnostics; surgical uninstall that only removes its own blocks.
**[Journey 6 — Lifecycle & Troubleshooting](docs/reference/06-lifecycle.md)**
自愈式诊断;精准卸载,仅移除自身相关块。
**[旅程 6 — 生命周期与故障排查](docs/reference/06-lifecycle.md)**
</td>
</tr>
<tr>
<td width="50%" valign="top">
### 🎛️ Take control of the window
*"Budget my context like a pro."*
### 🎛️ 掌控上下文窗口
*「像高手一样规划上下文预算。」*
```bash
lean-ctx plan "refactor billing" --budget 8000
lean-ctx compile --mode balanced
```
Phi-scored planning + knapsack compilation + a context ledger.
**[Journey 7 — Context Engineering](docs/reference/07-context-engineering.md)**
Phi 评分规划 + 背包(knapsack)编译 + 上下文账本。
**[旅程 7 — 上下文工程](docs/reference/07-context-engineering.md)**
</td>
<td width="50%" valign="top">
### 🤝 Run a team of agents
*"Planner + coder + reviewer on one repo."*
### 🤝 运行 agent 团队
*「同一仓库上的规划者 + 编码者 + 审查者。」*
```text
ctx_agent action=register role=dev
ctx_handoff action=create # baton-pass with full context
```
Shared message bus, diaries, knowledge, and deterministic handoffs.
**[Journey 8 — Multi-Agent Collaboration](docs/reference/08-multi-agent.md)**
共享消息总线、日记、知识库及确定性交接。
**[旅程 8 — 多 Agent 协作](docs/reference/08-multi-agent.md)**
</td>
</tr>
<tr>
<td width="50%" valign="top">
### 🏢 Share across a team / CI
*"One shared index, headless in pipelines."*
### 🏢 团队 / CI 共享
*「一套共享索引,在流水线中以无头模式运行。」*
```bash
lean-ctx team serve --config team.toml
lean-ctx bootstrap # zero-prompt CI setup
```
Scoped tokens, optional cloud sync, verifiable context gates.
**[Journey 9 — Team, Cloud & CI](docs/reference/09-team-cloud-ci.md)**
作用域 token、可选云同步、可验证的上下文门控。
**[旅程 9 — 团队、云与 CI](docs/reference/09-team-cloud-ci.md)**
</td>
<td width="50%" valign="top">
### 🎚️ Tune & govern
*"Make it behave exactly how we want."*
### 🎚️ 调优与治理
*「让它完全按我们的方式运行。」*
```bash
lean-ctx compression standard
lean-ctx harden # enforce token discipline
```
Compression levels, tool profiles, themes, and rules governance.
**[Journey 10 — Customization & Governance](docs/reference/10-customization-and-governance.md)**
压缩级别、工具配置、主题与规则治理。
**[旅程 10 — 自定义与治理](docs/reference/10-customization-and-governance.md)**
</td>
</tr>
<tr>
<td width="50%" valign="top">
### 📊 Prove the payoff
*"Show me the numbers."*
### 📊 证明收益
*「给我看数据。」*
```bash
lean-ctx gain --deep # savings, cost, per-agent, heatmap
lean-ctx wrapped # shareable recap (also: gain --svg / gain --share)
lean-ctx savings # verified per-event ledger (auditable; savings verify)
```
All analytics live in the CLI/dashboard — never burning agent tokens.
**[Journey 11 — Analytics & Insights](docs/reference/11-analytics-and-insights.md)**
所有分析均在 CLI/仪表板中——绝不消耗 agent token
**[旅程 11 — 分析与洞察](docs/reference/11-analytics-and-insights.md)**
</td>
<td width="50%" valign="top">
### 📚 The full reference
*"I want to read everything."*
### 📚 完整参考
*「我想通读全部内容。」*
Every command and all 81 MCP tools, organized as user journeys, plus
appendices for the [CLI map](docs/reference/appendix-cli-map.md),
[MCP tools](docs/reference/appendix-mcp-tools.md), and
[paths & config](docs/reference/appendix-paths-and-config.md).
**[Reference index](docs/reference/README.md)**
所有命令及全部 81 MCP 工具,按用户旅程组织,并附有 [CLI 映射](docs/reference/appendix-cli-map.md)、
[MCP 工具](docs/reference/appendix-mcp-tools.md)
[路径与配置](docs/reference/appendix-paths-and-config.md) 附录。
**[参考索引](docs/reference/README.md)**
</td>
</tr>
</table>
## Supported IDEs & AI tools
## 支持的 IDE AI 工具
LeanCTX is a standard **MCP server**, so it works with any MCP-compatible client. Two integration modes are auto-selected per agent:
LeanCTX 是标准 **MCP 服务器**,可与任何兼容 MCP 的客户端配合使用。系统会按 agent 自动选择两种集成模式之一:
| Mode | How it works | Best for |
| 模式 | 工作原理 | 最适合 |
|---|---|---|
| **Hybrid** | MCP for cached reads (~13 tokens) + shell hooks for command compression | Agents with shell access (Cursor, Claude Code, Codex, ...) |
| **MCP** | All 80 tools via MCP protocol, no shell hooks | Protocol-only agents (JetBrains, VS Code, Zed, ...) |
| **Hybrid(混合)** | MCP 用于缓存读取(约 13 tokens+ shell hooks 压缩命令 | 具备 shell 访问权限的 agentCursorClaude CodeCodex 等) |
| **MCP** | 通过 MCP 协议提供全部 80 个工具,无 shell hooks | 仅支持协议的 agentJetBrainsVS CodeZed 等) |
### Agent compatibility matrix
### 智能体兼容性矩阵
| Agent | Hybrid | MCP | Setup |
| 智能体 | 混合模式 | MCP | 设置 |
|---|:---:|:---:|---|
| Cursor | ● | | `lean-ctx init --agent cursor` |
| Claude Code | ● | | `lean-ctx init --agent claude` |
@@ -525,32 +512,26 @@ LeanCTX is a standard **MCP server**, so it works with any MCP-compatible client
| Emacs | | ● | `lean-ctx init --agent emacs` |
| Sublime Text | | ● | `lean-ctx init --agent sublime` |
> **Any MCP-compatible client** works out of the box — the table above shows agents with first-class auto-setup.
> **任何兼容 MCP 的客户端**均可开箱即用 — 上表列出的是支持一流自动配置的智能体。
### When to use (and when not to)
### 何时适用(何时不适用)
**Great fit if you...**
- use AI coding tools daily and your sessions are shell-heavy (git/tests/builds)
- work in medium/large repos (50+ files / monorepos)
- want a local-first layer with **no telemetry by default**
**非常适合,如果你……**
- 每天使用 AI 编程工具,且会话高度依赖 shell(git/测试/构建)
- 在中大型仓库中工作(50+ 文件 / 单体仓库)
- 需要默认**无遥测**的本地优先层
**Skip it if you...**
- mostly work in tiny repos and rarely call the shell from your AI tool
- always need raw/unfiltered logs (you can still use `--raw`, but ROI is lower)
**可以跳过,如果你……**
- 主要在小型仓库中工作,且很少从 AI 工具调用 shell
- 总是需要原始/未过滤的日志(你仍可使用 `--raw`,但投资回报率较低)
The honest fine print: the payoff depends on three levers — **reach** (own the
window via the proxy/engine, not just the `ctx_*` tool layer), **context
lifetime** (one long-lived session vs. a fresh process per phase), and
**provider pricing** (prompt-cache-priced vs. re-billed every turn). They stack
into a clear win where they line up and net to **break-even** where they don't.
See the [win vs. break-even matrix](docs/reference/14-performance-tuning.md#win-vs-break-even-at-a-glance)
for the full breakdown and how to tune for each case.
实话实说的细节:收益取决于三个杠杆 — **覆盖范围**(通过代理/引擎掌控窗口,而不仅是 `ctx_*` 工具层)、**上下文生命周期**(一个长生命周期会话 vs. 每个阶段一个新进程),以及**提供商定价**(按 prompt cache 计价 vs. 每轮重新计费)。三者对齐时叠加为明显收益,不对齐时净效果为**收支平衡**。完整分析与各场景的调优方法见[收益 vs. 收支平衡矩阵](docs/reference/14-performance-tuning.md#win-vs-break-even-at-a-glance)。
<a id="demo"></a>
## Demo
## 演示
Try these in any repo:
可在任意仓库中尝试:
```bash
lean-ctx read rust/src/server/mod.rs -m map
@@ -561,8 +542,8 @@ lean-ctx watch # TUI monitor
lean-ctx benchmark report .
```
- The repo ships the exact tapes used to render the GIFs in `demo/`
- Regenerate locally:
- 本仓库附带用于渲染 GIF 的完整录制脚本,见 `demo/`
- 本地重新生成:
```bash
vhs demo/leanctx.tape
@@ -572,82 +553,64 @@ vhs demo/benchmark.tape
<a id="benchmarks"></a>
## Benchmarks
## 基准测试
Real, reproduced numbers — never estimated. Measured on this repo with the GPT-4o
tokenizer (`o200k_base`); a tool that isn't installed is reported as such, never
guessed.
真实、可复现的数据 — 从不估算。在本仓库上使用 GPT-4o 分词器(`o200k_base`)测量;未安装的工具会如实报告,从不猜测。
| Read mode | Compression | Tokens (50 files) | Quality |
| 读取模式 | 压缩率 | Token 数(50 个文件) | 质量 |
|---|---:|---:|---:|
| Raw read | 0% | 533.2K | 100% |
| `map` | **98.1%** | 8.0K | 78% |
| `signatures` | **96.7%** | 14.0K | 96% |
| Cached re-read | ~99.99% | ~13 tok | 100% |
lean-ctx's **own cost is measured too**: the fixed per-session footprint it
injects (advertised tool schemas + MCP instructions) is ~2.1K tokens and
CI-gated via `lean-ctx doctor overhead --gate`, so it can only shrink. And the
long-lived proxy rail has a deterministic self-verify —
`lean-ctx benchmark dual-arm --json` replays a 15-turn session and prices it per
model (digest `f5ed145e61ce3689`, 99.4% input-side saving on cache-priced rails;
methodology: [bench/agent-task/r2](bench/agent-task/r2/README.md)).
lean-ctx **自身成本也有测量**:其注入的固定每会话占用(公布的工具 schema + MCP 指令)约为 2.1K token,并通过 `lean-ctx doctor overhead --gate` 进行 CI 门禁,因此只会缩减。长生命周期代理通道还有确定性自验证 — `lean-ctx benchmark dual-arm --json` 重放 15 轮会话并按模型计价(摘要 `f5ed145e61ce3689`,在按 cache 计价的通道上输入侧节省 99.4%;方法论:[bench/agent-task/r2](bench/agent-task/r2/README.md))。
Accuracy isn't a vibe: the lossy stages are **CI-gated**. A model-free A/B gate
proves the JSON crusher keeps *every* gold answer while cutting tokens, and proxy
rewrites are byte-stable by contract, so Anthropic (90%) / OpenAI (50%) prompt-cache
discounts survive compression. A deterministic **off-vs-on testbench**
(`lean-ctx eval testbench`) extends the proof to *answers*: it runs pinned real repos
through a raw-dump baseline and through lean-ctx at an identical token budget, grades
free-form QA with an LLM judge and code with each repo's own tests, and emits
`FINDINGS.md` (tokens / turns / walltime / quality) plus a regressions file — with a
committed recorded subset that blocks CI on any regression.
准确性不是凭感觉:有损阶段均受 **CI 门禁**约束。无模型的 A/B 门禁证明 JSON crusher 在削减 token 的同时保留*每一个*黄金答案,且代理重写按合约保持字节稳定,因此 Anthropic90%/ OpenAI50%)的 prompt-cache 折扣在压缩后依然有效。确定性 **关闭 vs. 开启测试台**`lean-ctx eval testbench`)将证明扩展到*答案*:它在相同 token 预算下,让固定的真实仓库分别经过 raw-dump 基线与 lean-ctx,用 LLM 评判器对自由形式问答评分、用各仓库自有测试对代码评分,并输出 `FINDINGS.md`token / 轮次 / 墙钟时间 / 质量)及回归文件 — 其中包含已提交的录制子集,任何回归都会阻断 CI。
- **Latest snapshot**: [BENCHMARKS.md](BENCHMARKS.md)
- **Reproduce**: `lean-ctx benchmark report .`
- **最新快照**[BENCHMARKS.md](BENCHMARKS.md)
- **复现**`lean-ctx benchmark report .`
## By the numbers
## 数据一览
- **3,000+ GitHub stars** — and counting
- **280+ forks** — active community contributions
- **200+ releases** — shipped near-daily since launch
- **30+ supported AI coding agents** — broadest MCP compatibility
- **81 MCP tools** — from simple file reads to multi-agent orchestration
- Used in production by teams running Claude Code, Cursor, and Codex daily
- **Live adoption metrics**: [leanctx.com/metrics](https://leanctx.com/metrics/) — installs, stars and savings, updated continuously
- **3,000+ GitHub stars** — 且仍在增长
- **280+ forks** — 活跃的社区贡献
- **200+ releases** — 自发布以来近乎每日发布
- **30+ 支持的 AI 编程智能体** — 最广的 MCP 兼容性
- **81 MCP 工具** — 从简单文件读取到多智能体编排
- 生产环境中被每天使用 Claude CodeCursor Codex 的团队采用
- **实时采用指标**[leanctx.com/metrics](https://leanctx.com/metrics/) — 安装量、star 数与节省量,持续更新
## Docs
## 文档
- **Reference (every function, by user journey)**: [docs/reference/](docs/reference/README.md) — 11 journeys + CLI/MCP/config appendices
- **For AI agents / LLMs**: [llms.txt](llms.txt) — a curated, machine-readable map of lean-ctx (per the [llms.txt](https://llmstxt.org) convention)
- Getting started: https://leanctx.com/docs/getting-started
- Tools reference: https://leanctx.com/docs/tools/
- CLI reference: https://leanctx.com/docs/cli-reference/
- What is LeanCTX: https://leanctx.com/what-is-leanctx/
- Comparison (vs RTK, Context+, MemGPT): https://leanctx.com/compare/
- Pricing & Cloud (local use is free forever): https://leanctx.com/pricing/
- FAQ: [discord-faq.md](discord-faq.md)
- Feature catalog (SSOT snapshot): [LEANCTX_FEATURE_CATALOG.md](LEANCTX_FEATURE_CATALOG.md)
- Monorepo guide: [docs/guides/monorepo.md](docs/guides/monorepo.md)
- Architecture: [ARCHITECTURE.md](ARCHITECTURE.md)
- Vision: [VISION.md](VISION.md)
- **参考文档(按用户旅程组织的每个功能)**:[docs/reference/](docs/reference/README.md) — 11 条旅程 + CLI/MCP/配置附录
- **面向 AI 智能体 / LLM**[llms.txt](llms.txt) — lean-ctx 的精选、机器可读地图(遵循 [llms.txt](https://llmstxt.org) 约定)
- 入门指南:https://leanctx.com/docs/getting-started
- 工具参考:https://leanctx.com/docs/tools/
- CLI 参考:https://leanctx.com/docs/cli-reference/
- 什么是 LeanCTXhttps://leanctx.com/what-is-leanctx/
- 对比(vs RTKContext+MemGPT):https://leanctx.com/compare/
- 定价与 Cloud(本地使用永久免费):https://leanctx.com/pricing/
- FAQ[discord-faq.md](discord-faq.md)
- 功能目录(SSOT 快照):[LEANCTX_FEATURE_CATALOG.md](LEANCTX_FEATURE_CATALOG.md)
- 单体仓库指南:[docs/guides/monorepo.md](docs/guides/monorepo.md)
- 架构:[ARCHITECTURE.md](ARCHITECTURE.md)
- 愿景:[VISION.md](VISION.md)
## Privacy & security
## 隐私与安全
- **No telemetry by default**
- **Optional anonymous stats sharing** (opt-in during setup)
- **Disableable update check** (config `update_check_disabled = true` or `LEAN_CTX_NO_UPDATE_CHECK=1`)
- **40+ security hardening fixes** in v3.5.16 (path traversal, injection, CSPRNG, CSP, resource limits — [details](CHANGELOG.md))
- **Context Governance Benchmark self-assessment**: graded **C2 — Managed** against the 32-control [CGB v1.0-draft](https://github.com/yvgude/context-governance-benchmark) spec, gaps declared — [docs/compliance/cgb-self-assessment.md](docs/compliance/cgb-self-assessment.md)
- Runs locally; your code never leaves your machine unless you explicitly enable cloud sync
- **默认无遥测**
- **可选的匿名统计共享**(安装时选择加入)
- **可禁用的更新检查**(配置 `update_check_disabled = true` `LEAN_CTX_NO_UPDATE_CHECK=1`
- v3.5.16 中 **40+ 项安全加固修复**(路径遍历、注入、CSPRNGCSP、资源限制 — [详情](CHANGELOG.md)
- **上下文治理基准(Context Governance Benchmark)自评**:对照 32 项控制的 [CGB v1.0-draft](https://github.com/yvgude/context-governance-benchmark) 规范评为 **C2 — Managed**,已声明差距 — [docs/compliance/cgb-self-assessment.md](docs/compliance/cgb-self-assessment.md)
- 本地运行;除非你显式启用云同步,否则代码不会离开你的机器
See [SECURITY.md](SECURITY.md).
详见 [SECURITY.md](SECURITY.md)
## Uninstall
## 卸载
One command removes **everything**it stops all processes, then deletes hooks,
editor configs, rules, autostart (LaunchAgent/systemd), the data dir, **and the
binary itself**:
一条命令即可移除**一切** — 停止所有进程,然后删除 hooks、编辑器配置、规则、自启动项(LaunchAgent/systemd)、数据目录,**以及二进制文件本身**:
```bash
lean-ctx uninstall # full clean removal
@@ -656,14 +619,13 @@ lean-ctx uninstall --keep-config # keep MCP configs + rules (for reinstall)
lean-ctx-off # or just disable for the current shell session
```
No binary on PATH (or you used the curl installer)? Run the same removal from the installer:
PATH 上没有二进制文件(或你使用了 curl 安装器)?从安装器运行相同的移除流程:
```bash
curl -fsSL https://leanctx.com/install.sh | sh -s -- --uninstall
```
If you installed via a package manager, `uninstall` removes everything it wrote and
tells you the one command to finish removing the binary:
若通过包管理器安装,`uninstall` 会移除其写入的一切,并告知你完成删除二进制文件所需的一条命令:
```bash
brew uninstall lean-ctx # Homebrew
@@ -672,23 +634,20 @@ npm uninstall -g lean-ctx-bin # npm
pi uninstall npm:pi-lean-ctx # Pi Coding Agent
```
## Star History
## Star 历史
<a href="https://star-history.com/#yvgude/lean-ctx&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=yvgude/lean-ctx&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=yvgude/lean-ctx&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=yvgude/lean-ctx&type=Date" />
<img alt="Star 历史图表" src="https://api.star-history.com/svg?repos=yvgude/lean-ctx&type=Date" />
</picture>
</a>
## Contributing
## 贡献
Start with [CONTRIBUTING.md](CONTRIBUTING.md). Easy first PR: propose a new CLI compression pattern via the [issue template](.github/ISSUE_TEMPLATE/compression_pattern.md).
请从 [CONTRIBUTING.md](CONTRIBUTING.md) 开始。适合新手的首个 PR:通过 [issue 模板](.github/ISSUE_TEMPLATE/compression_pattern.md) 提议新的 CLI 压缩模式(compression pattern)。
## License
## 许可证
Apache License 2.0 — see [LICENSE](LICENSE).
--- lean-ctx: ctx_compose bundles search+read+symbols in one call ---
Apache License 2.0 — 详见 [LICENSE](LICENSE)