Skip to main content

Crate lean_ctx

Crate lean_ctx 

Source
Expand description

§LeanCTX | OSS

LeanCTX is the Context Gateway for AI agents. Control what your AI can see.

The open-source Engine brings context selection, supported access and content controls, local knowledge and observable evidence to existing AI tools through CLI, MCP, hooks and supported proxy paths. Your host owns the task, agent loop and model.

§Install and connect an agent

cargo install lean-ctx --locked
lean-ctx wrap codex     # or: wrap claude / wrap cursor
lean-ctx doctor

§Select · Control · Learn · Prove

  • Select: search and read the detail a task needs, with compact views and source references for recovering more.
  • Control: apply configured path permissions, content filters and budgets on supported integration paths.
  • Learn: retain local task, finding and decision records and connect code and knowledge across sessions. This does not train the model.
  • Prove: inspect the source, operation, policy and usage evidence the integration can observe with lean-ctx inspect.

A context-only integration records its prepared result; the host owns the subsequent model call. Filters have configured coverage limits. Recovery depends on current permissions, retention and source or archive availability. Usage estimates and calculated costs are separate from answer quality.

§Build from source

From the repository’s rust/ directory:

cargo check --locked
cargo fast

Development builds use the configured jobs and shared target directory. Use cargo build --release --locked for explicit release validation. Keep the installed runtime running while building or testing; lean-ctx dev-install performs the supported atomic replacement after a successful build.

§Validate a change

cargo test --lib
cargo clippy --all-features -- -D warnings
cargo fmt --check

§Integration boundaries

  • Attach: use the installed CLI, MCP server, hooks or supported local proxy.
  • Embed: use the standalone LeanCTX | SDK’s released lifecycle and Agent Tools contracts. Preview operations and older in-tree experiments keep their own limits.
  • Commercial deployments: Enterprise and SDK/OEM have separate scope and licensing; consult the applicable release and agreement.

See the repository overview, installation guide, security policy, canonical positioning and SDK boundaries.

Modules§

compound_lexer
config_io
core
daemon
daemon_autostart
daemon_client
dropin
Drop-in style installation.
gitlab_bootstrap
Protected GitLab source bootstrap for agent launches. The protected MCP server’s outside wrapper.
heatmap
instructions
ipc
kits
Context Kits are versioned, task-specific context plans.
lsp
marked_block
mcp_stdio
proxy_autostart
report
lean-ctx report-issue — collects diagnostics and creates a GitHub issue.
rewrite_registry
rules_inject
Rules + SKILL.md injection for every supported agent, split by concern (GL#440): content (payloads), targets (agent catalog), detect (installation checks), write (atomic file surgery), skills (SKILL.md). This hub owns the shared types and the orchestration entry points.
shell
shell_hook
telemetry_transport
HTTP transport for telemetry and product feedback: the API base URL (with the test-process loopback guard), the telemetry-v2 batch send, remote telemetry deletion and anonymous product feedback.
terminal_ui
tool_defs

Constants§

JEMALLOC_CONF
jemalloc runtime options, exported by the binary as _rjem_malloc_conf (see crates/lean-ctx/src/main.rs). NUL-terminated: jemalloc reads it as a C string.