lean_ctx/lib.rs
1#![recursion_limit = "256"]
2#![doc = include_str!("../README.md")]
3// Every `unsafe` block must carry a `// SAFETY:` comment justifying soundness.
4// Enforced so the (mostly libc/Win32 syscall) unsafe surface stays documented.
5#![warn(clippy::undocumented_unsafe_blocks)]
6
7#[cfg(all(feature = "jemalloc", not(windows), not(target_env = "musl")))]
8#[global_allocator]
9static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
10
11/// jemalloc runtime options, exported by the binary as `_rjem_malloc_conf`
12/// (see `crates/lean-ctx/src/main.rs`). NUL-terminated: jemalloc reads it as a C string.
13#[cfg(all(feature = "jemalloc", not(windows), not(target_env = "musl")))]
14pub const JEMALLOC_CONF: &[u8] = if cfg!(target_os = "linux") {
15 b"background_thread:true,dirty_decay_ms:1000,muzzy_decay_ms:1000\0"
16} else {
17 b"dirty_decay_ms:1000,muzzy_decay_ms:1000\0"
18};
19
20// ---------------------------------------------------------------------------
21// Pillar: Engine — context compression, MCP tools, agent hooks, local UX
22// ---------------------------------------------------------------------------
23pub mod core;
24pub mod daemon;
25pub mod daemon_autostart;
26pub mod daemon_client;
27pub mod dropin;
28pub mod instructions;
29pub mod lsp;
30pub mod marked_block;
31pub mod rules_inject;
32pub mod shell;
33pub mod shell_hook;
34pub mod terminal_ui;
35pub mod tool_defs;
36
37// The proxy lives in crates/lean-ctx-proxy (lib `lean_ctx_proxy`), above the
38// Engine; the Engine reaches it only through registrations (output shapers).
39pub mod proxy_autostart;
40
41// ---------------------------------------------------------------------------
42// Pillar: Cloud — hosted API, accounts, sync, billing edge
43// ---------------------------------------------------------------------------
44pub mod telemetry_transport;
45
46// ---------------------------------------------------------------------------
47// Shared — CLI, IPC, config, diagnostics, setup
48// ---------------------------------------------------------------------------
49pub mod config_io;
50pub mod ipc;
51pub mod kits;
52#[cfg(any(test, feature = "test-support"))]
53pub mod test_env;