How yvgude/lean-ctx works
LeanCTX is a local context gateway for AI tools and applications: supported tool calls are selected, governed, and delivered with usage or recovery evidence, while the host retains its agent loop and model call. The graph includes the documented MCP, CLI, hook, proxy, and SDK surfaces, plus continuity and knowledge capabilities. Relationship evidence is limited to the README and the sampled/indexed files; unsampled subsystem internals are represented only where their paths are supported.
Main entry points: pipeline.rs Call delivery · ctx_read_engine.rs Context reads · engine_cmd.rs CLI paths · agents Agent hooks
Components 19
Tool entry points
- MCP server
rust/crates/lean-ctx-server/src/server/call_tool/pipeline.rs - CLI paths
rust/crates/lean-ctx/src/cli/engine_cmd.rs - Agent hooks
rust/crates/lean-ctx-hooks/src/hooks/agents - Tool proxy
rust/crates/lean-ctx-proxy/src/forward/pipeline.rs
Context gateway
- Call delivery
rust/crates/lean-ctx-server/src/server/call_tool/pipeline.rs - Context reads
rust/crates/lean-ctx-server/src/tools/registered/ctx_read_engine.rs - Search and views
rust/crates/lean-ctx-server/src/tools/ctx_knowledge - Shell compression
rust/src/shell/compress/engine.rs - Access controls
rust/src/core/policy/runtime.rs - Engine interface
rust/src/core/engine_interface.rs - Source recovery
rust/src/core/ccr/storage.rs
Continuity and evidence
- Session records
rust/src/core/context_checkpoint/session_storage.rs - Knowledge and tasks
rust/crates/lean-ctx-hive/src/knowledge - Usage evidence
rust/crates/lean-ctx-hive/src/receipts.rs
Client integrations
- Rust client
clients/rust/lean-ctx-client/src/client.rs - TypeScript client
cookbook/sdk/src/client.ts - Hermes adapter
integrations/hermes-lean-ctx/engine.py - VS Code bridge
packages/vscode-lean-ctx/src/bridge/manager.ts
Other components
- AI tool or app
Connections 19
- AI tool or app → MCP server: calls tools
- AI tool or app → CLI paths: uses commands
- AI tool or app → Agent hooks: uses integration
- AI tool or app → Tool proxy: routes calls
- MCP server → Call delivery: dispatches calls
rust/crates/lean-ctx-server/src/server/call_tool/pipeline.rs - Call delivery → Context reads: serves reads
- Call delivery → Search and views: selects context
- Call delivery → Shell compression: compresses output
- Call delivery → Access controls: applies controls
- Call delivery → Engine interface: executes context
rust/src/core/engine_interface.rs - Context reads → Source recovery: retains references
- Call delivery → Session records: records continuity
- Call delivery → Knowledge and tasks: supports learning
- Call delivery → Usage evidence: records delivery
- Call delivery → AI tool or app: delivers context
- AI tool or app → Rust client: embeds engine
- AI tool or app → TypeScript client: embeds engine
- AI tool or app → Hermes adapter: uses engine
integrations/hermes-lean-ctx/engine.py - AI tool or app → VS Code bridge: uses bridge