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 `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 compound_lexer;
24pub mod core;
25pub mod daemon;
26pub mod daemon_autostart;
27pub mod daemon_client;
28pub mod dropin;
29/// Protected GitLab source bootstrap for agent launches.
30pub mod gitlab_bootstrap;
31pub mod heatmap;
32pub mod instructions;
33pub mod lsp;
34pub mod marked_block;
35pub mod mcp_stdio;
36pub mod rewrite_registry;
37pub mod rules_inject;
38pub mod shell;
39pub mod shell_hook;
40pub mod terminal_ui;
41pub mod tool_defs;
42
43// The proxy lives in crates/lean-ctx-proxy (lib `lean_ctx_proxy`), above the
44// Engine; the Engine reaches it only through registrations (output shapers).
45pub mod proxy_autostart;
46
47// ---------------------------------------------------------------------------
48// Pillar: Cloud — hosted API, accounts, sync, billing edge
49// ---------------------------------------------------------------------------
50pub mod telemetry_transport;
51
52// ---------------------------------------------------------------------------
53// Shared — CLI, IPC, config, diagnostics, setup
54// ---------------------------------------------------------------------------
55pub mod config_io;
56pub mod ipc;
57pub mod kits;
58pub mod report;
59#[cfg(any(test, feature = "test-support"))]
60pub mod test_env;