diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..2dd6ff5 --- /dev/null +++ b/README.en.md @@ -0,0 +1,694 @@ +
+██╗ ███████╗ █████╗ ███╗ ██╗ ██████╗████████╗██╗ ██╗ +██║ ██╔════╝██╔══██╗████╗ ██║ ██╔════╝╚══██╔══╝╚██╗██╔╝ +██║ █████╗ ███████║██╔██╗ ██║ ██║ ██║ ╚███╔╝ +██║ ██╔══╝ ██╔══██║██║╚██╗██║ ██║ ██║ ██╔██╗ +███████╗███████╗██║ ██║██║ ╚████║ ╚██████╗ ██║ ██╔╝ ██╗ +╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ++ +### **Control what your AI can see.** + +**LeanCTX — Lean Context Engineering for AI agents** + +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: 60–90% fewer +tokens. +Zero config required. +Local-first. + +| Problem | With 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 | + +--- + + + +
+ Website · Docs · Install · SDKs · Scenarios · Demo · Benchmarks · Cookbook · Security · Changelog +
+ +See it in action:
+ +
+
+ + Read + Shell + + Map-mode reads + compressed CLI output + |
+
+
+ + Gain (live) + + Tokens + USD savings in real time + |
+
+
+ + Benchmark proof + + Measure compression by language + mode + |
+
All GIFs are generated from reproducible VHS tapes in demo/.
+ Saves you tokens? Give it a star — it helps others discover LeanCTX. +
+ +--- + +## 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. + +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.** + +--- + +## 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: + +### 1. Compression — input efficiency + +Your AI agent reads files and runs commands. LeanCTX compresses both automatically. + +- **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) + +### 2. Routing — the right fidelity per read + +Not every file needs the same depth. LeanCTX sends the signal, not the noise. + +- **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 + +### 3. Memory — context that persists + +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 + +### 4. Verification — control what reaches the model + +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 + +| + +### 🟢 Your first 30 seconds +*"I just installed it — now what?"* + +```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)** + + | ++ +### 📖 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)** + + | +
| + +### 🧠 Resume where you left off +*"My new chat forgot everything."* + +```bash +lean-ctx overview # task-aware project recap +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)** + + | ++ +### 🗺️ 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)** + + | +
| + +### 🔌 Providers & multi-repo +*"Pull in GitHub issues and our 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)** + + | ++ +### 🛠️ 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)** + + | +
| + +### 🎛️ 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)** + + | ++ +### 🤝 Run a team of agents +*"Planner + coder + reviewer on one repo."* + +```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)** + + | +
| + +### 🏢 Share across a team / CI +*"One shared index, headless in pipelines."* + +```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)** + + | ++ +### 🎚️ 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)** + + | +
| + +### 📊 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)** + + | ++ +### 📚 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)** + + | +