[package]
name = "lean-ctx"
version = "3.8.0"
edition = "2021"
autobins = false
description = "Context Runtime for AI Agents with CCP. 71 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24+ AI tools. Reduces LLM token consumption by up to 99%."
license = "Apache-2.0"
repository = "https://github.com/yvgude/lean-ctx"
homepage = "https://leanctx.com"
readme = "README.md"
keywords = ["mcp", "llm", "tokens", "compression", "ai"]
categories = ["command-line-utilities", "development-tools"]
exclude = ["examples/", "tests/"]

[package.metadata.binstall]
bin-dir = "{ bin }{ binary-ext }"
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }.tar.gz"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"
pkg-url = "{ repo }/releases/download/v{ version }/{ name }-{ target }.zip"

[lib]
name = "lean_ctx"
path = "src/lib.rs"

[[bin]]
name = "lean-ctx"
path = "src/main.rs"

[[example]]
name = "lean-ctx-cloud-api"
path = "src/cloud_server_main.rs"
required-features = ["cloud-server"]

[[example]]
name = "gen_mcp_manifest"
path = "src/bin/gen_mcp_manifest.rs"
required-features = ["dev-tools"]

[[example]]
name = "gen_tdd_schema"
path = "src/bin/gen_tdd_schema.rs"
required-features = ["dev-tools"]

[[example]]
name = "gen_docs"
path = "src/bin/gen_docs.rs"
required-features = ["dev-tools"]

[[example]]
name = "locomo_bench"
path = "src/bin/locomo_bench.rs"
required-features = ["dev-tools"]

[[example]]
name = "seed_observatory"
path = "src/bin/seed_observatory.rs"
required-features = ["dev-tools"]

[features]
default = ["tree-sitter", "embeddings", "http-server", "team-server", "secure-update", "jemalloc"]
jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"]
dev-tools = []
no-jail = []
neural = ["dep:rten", "dep:rten-tensor"]
embeddings = ["dep:rten", "dep:rten-tensor"]
http-server = ["dep:axum", "dep:tower-http", "dep:reqwest"]
qdrant = ["embeddings"]
team-server = ["http-server"]
secure-update = []
cloud-server = [
  "http-server",
  "dep:deadpool-postgres",
  "dep:tokio-postgres",
  "dep:lettre",
  "dep:jsonwebtoken",
  "dep:base64",
  "dep:uuid",
  "dep:hex",
  "dep:rand",
  "dep:argon2",
  "dep:resvg",
]
tree-sitter = [
  "dep:tree-sitter",
  "dep:tree-sitter-rust",
  "dep:tree-sitter-typescript",
  "dep:tree-sitter-javascript",
  "dep:tree-sitter-python",
  "dep:tree-sitter-go",
  "dep:tree-sitter-java",
  "dep:tree-sitter-c",
  "dep:tree-sitter-cpp",
  "dep:tree-sitter-ruby",
  "dep:tree-sitter-c-sharp",
  "dep:tree-sitter-kotlin-ng",
  "dep:tree-sitter-swift",
  "dep:tree-sitter-php",
  "dep:tree-sitter-bash",
  "dep:tree-sitter-dart",
  "dep:tree-sitter-scala",
  "dep:tree-sitter-elixir",
  "dep:tree-sitter-zig",
  "dep:tree-sitter-gdscript",
]
wasm = ["dep:wasmi"]

[dependencies]
rmcp = { version = "1", features = ["server", "client", "transport-io", "transport-streamable-http-server", "transport-child-process", "transport-streamable-http-client-reqwest"] }
# Header types for the gateway's downstream HTTP MCP client (already in the tree via rmcp/reqwest).
http = "1"
tiktoken-rs = "0.6"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros", "io-std", "io-util", "net", "sync", "time", "signal", "process"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
subtle = "2"
md-5 = "0.10"
anyhow = "1"
regex = "1"
walkdir = "2"
ignore = "0.4"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
thiserror = "2"
futures = "0.3"
tokio-util = { version = "0.7", features = ["codec"] }
dirs = "5"
chrono = { version = "0.4", features = ["serde"] }
toml = "0.8"
toml_edit = "0.22"
similar = "2"
flate2 = "1"
rusqlite = { version = "0.39.0", features = ["bundled"] }
tree-sitter = { version = "0.26", optional = true }
tree-sitter-rust = { version = "0.24", optional = true }
tree-sitter-typescript = { version = "0.23", optional = true }
tree-sitter-javascript = { version = "0.25", optional = true }
tree-sitter-python = { version = "0.25", optional = true }
tree-sitter-go = { version = "0.25", optional = true }
tree-sitter-java = { version = "0.23", optional = true }
tree-sitter-c = { version = "0.24", optional = true }
tree-sitter-cpp = { version = "0.23", optional = true }
tree-sitter-ruby = { version = "0.23", optional = true }
tree-sitter-c-sharp = { version = "0.23", optional = true }
# tree-sitter-kotlin (fwcd) caps tree-sitter at <0.23; kotlin-ng matches tree-sitter 0.26.
tree-sitter-kotlin-ng = { version = "1.1", optional = true }
tree-sitter-swift = { version = "0.7", optional = true }
tree-sitter-php = { version = "0.24", optional = true }
ureq = "3.3.0"
# PDF → text extraction for ctx_url_read (research context layer).
pdf-extract = "0.10"
tar = "0.4.46"
zip = "8.4.0"
tree-sitter-bash = { version = "0.25", optional = true }
tree-sitter-scala = { version = "0.25", optional = true }
tree-sitter-elixir = { version = "0.3", optional = true }
tree-sitter-zig = { version = "1.1", optional = true }
tree-sitter-dart = { version = "0.1", optional = true }
tree-sitter-gdscript = { version = "6.1", optional = true }
rten = { version = "0.24", optional = true }
rten-tensor = { version = "0.24", optional = true }
axum = { version = "0.8", optional = true }
tower-http = { version = "0.6", features = ["cors", "auth"], optional = true }
deadpool-postgres = { version = "0.14", optional = true }
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4", "with-uuid-1"], optional = true }
lettre = { version = "0.11", default-features = false, features = ["tokio1-rustls-tls", "smtp-transport", "builder"], optional = true }
jsonwebtoken = { version = "10.3", optional = true }
base64 = { version = "0.22", optional = true }
uuid = { version = "1", features = ["v4", "serde"], optional = true }
hex = { version = "0.4", optional = true }
hmac = "0.12"
sha2 = "0.10"
hkdf = "0.12"
chacha20poly1305 = "0.10"
rand = { version = "0.9.3", optional = true }
argon2 = { version = "0.5", optional = true }
glob = "0.3.3"
urlencoding = "2"
ratatui = "0.30"
crossterm = "0.29"
rpassword = "7.4.0"
ed25519-dalek = { version = "2", features = ["rand_core"] }
getrandom = "0.3"
tempfile = "3"
reqwest = { version = "0.13.2", default-features = false, features = ["rustls", "stream", "json"], optional = true }
bytecount = "0.6.9"
libc = "0.2"
blake3 = "1"
rayon = "1.10"
moka = { version = "0.12.15", features = ["sync"] }
bincode = { version = "2", features = ["serde"] }
zstd = "0.13"
memmap2 = "0.9"
lsp-types = "0.97"
fs2 = "0.4.3"
unicode-width = "0.2"
resvg = { version = "0.47.0", optional = true }
wasmi = { version = "1.0.9", optional = true }
gethostname = "1.1.0"

[lints.rust]
unreachable_pub = "warn"
# CI coverage (cargo-tarpaulin) injects `--cfg tarpaulin`; declare it to avoid
# `-D unexpected_cfgs` failures when using `cfg_attr(tarpaulin, ...)`.
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(tarpaulin)"] }

[lints.clippy]
pedantic = { level = "warn", priority = -1 }

# --- Style preferences (not quality issues) ---
too_many_lines = "allow"
module_name_repetitions = "allow"
must_use_candidate = "allow"
return_self_not_must_use = "allow"
similar_names = "allow"
unreadable_literal = "allow"

# --- Documentation: covered by separate doc-coverage tooling ---
missing_errors_doc = "allow"
missing_panics_doc = "allow"
doc_markdown = "allow"

# --- Casts: intentional numeric conversions for token counting, stats, sizing ---
cast_possible_truncation = "allow"
cast_precision_loss = "allow"
cast_sign_loss = "allow"
cast_possible_wrap = "allow"
cast_lossless = "allow"

# --- Performance: format_push_string would require 276 refactors for minimal gain ---
format_push_string = "allow"

# --- Struct design: Config/StatsStore legitimately use many bools ---
struct_excessive_bools = "allow"

# --- Float: intentional comparisons in stats/benchmarks ---
float_cmp = "allow"

# --- Style: constants placed near usage for readability ---
items_after_statements = "allow"

# --- Underscore bindings: intentionally named for clarity then used ---
used_underscore_binding = "allow"
no_effect_underscore_binding = "allow"

# --- Micro-optimization: &bool vs bool, readability preferred ---
trivially_copy_pass_by_ref = "allow"

# --- HashMap: we always use default hasher ---
implicit_hasher = "allow"

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
strip = true
panic = "unwind"

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = [
    "Win32_Foundation",
    "Win32_System_Threading",
    "Win32_Security",
    "Win32_System_Pipes",
] }

[target.'cfg(not(windows))'.dependencies]
tikv-jemallocator = { version = "0.6", optional = true }
tikv-jemalloc-ctl = { version = "0.6", optional = true }

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
filetime = "0.2.29"
insta = "1"
jsonschema = { version = "0.46.5", default-features = false }
proptest = "1"
serial_test = "3.4.0"
tempfile = "3.27.0"
tower = "0.5"
wat = "1.251.0"

[[bench]]
name = "compression"
harness = false

[[bench]]
name = "graph_export"
harness = false

[[bench]]
name = "efficiency"
harness = false
