Skip to main content

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 `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 compound_lexer;
24pub mod core;
25pub mod daemon;
26pub mod daemon_autostart;
27pub mod daemon_client;
28pub mod dashboard;
29pub mod dropin;
30/// Low-level Apache in-process tool-execution façade for Engine embedders.
31pub mod engine;
32pub mod heatmap;
33pub mod hook_handlers;
34pub mod hooks;
35pub mod instructions;
36pub mod lsp;
37pub mod marked_block;
38pub mod mcp_stdio;
39pub mod rewrite_registry;
40pub mod rules_inject;
41pub mod server;
42pub mod shell;
43pub mod shell_hook;
44pub mod terminal_ui;
45pub mod token_report;
46pub mod tool_defs;
47pub mod tools;
48
49// Always compiled: the shared accounting the rest of the engine reads (CCR
50// archive, usage meters, savings, introspection). The HTTP proxy server and its
51// provider adapters inside are gated on `http-server` (#586).
52pub mod proxy;
53pub mod proxy_autostart;
54pub mod proxy_setup;
55
56// ---------------------------------------------------------------------------
57// Pillar: Cloud — hosted API, accounts, sync, billing edge
58// ---------------------------------------------------------------------------
59#[cfg(feature = "http-server")]
60pub mod http_server;
61pub mod telemetry_transport;
62
63// ---------------------------------------------------------------------------
64// Shared — CLI, IPC, config, diagnostics, setup
65// ---------------------------------------------------------------------------
66pub mod cli;
67pub mod config_io;
68pub mod doctor;
69pub mod ipc;
70pub mod kits;
71pub mod report;
72pub mod setup;
73pub mod status;
74#[cfg(test)]
75pub(crate) mod test_env;
76pub mod uninstall;