वह सिस्टम जो तय करता है
कि आपका AI क्या देखता है।
AI एजेंट्स के लिए context engineering layerमॉडल के दोनों ओर एक स्थानीय बाइनरी। LeanCTX, फ़ाइल रीड्स से लेकर सत्यापित आउटपुट तक, AI context के संपूर्ण जीवनचक्र को महसूस करता है, कंप्रेस करता है, याद रखता है, रूट करता है और नियंत्रित करता है।
Cognitive Context Layer क्या है?
एक Cognitive Context Layer आपके AI टूल्स और आपकी कोडबेस के बीच का इंफ्रास्ट्रक्चर है। यह नियंत्रित करता है कि कौन सी फ़ाइलें पढ़ी जाती हैं, आउटपुट को कैसे कंप्रेस किया जाता है, किस ज्ञान का सत्रों में बने रहना चाहिए, और डिलीवरी से पहले क्या परिणाम गुणवत्ता मानकों को पूरा करते हैं।
निर्माण का चित्र
शिप किए गए बाइनरी की प्रक्रिया टोपोलॉजी: सात एंट्री पॉइंट, एक रनटाइम, स्थानीय स्टोरों का एक सेट। नीचे हर बॉक्स एक वास्तविक मॉड्यूल, पोर्ट या डिस्क पर फ़ाइल से मैप होता है।
lean-ctx lean-ctx serve lean-ctx serve --daemon lean-ctx -c "<cmd>" lean-ctx proxy start lean-ctx dashboard lean-ctx watch · gain --live एक सिंगल रीड का क्या होता है
शीट 2 रनटाइम के माध्यम से एक अनुरोध को चरण दर चरण ट्रैक करती है, जिसमें कैश शॉर्ट-सर्किट शामिल है जो बार-बार रीड्स को लगभग मुफ्त बना देता है। शेल पाथ उसी अकाउंटिंग के साथ समानांतर में चलता है।
ctx_read(path, mode) · lean-ctx read - PathJail
core/pathjail.rsCanonicalises the path and rejects escapes outside the workspace root before any I/O happens.
- Session cache
hit → ~13 tokensContent-addressed lookup keyed by path + mtime/hash. Unchanged files collapse to a stub instead of re-sending content.
- AST extraction
26 languagestree-sitter parses the file into a syntax tree: signatures, imports, call edges — Lua, Luau, Kotlin and GDScript are graph-indexed too. Regex fallback for unsupported languages.
- Mode selection
10 modesauto picks the optimal of 10 read modes (full, map, signatures, diff, task, reference, aggressive, entropy, lines:N-M) from task intent and file size; structure_first biases cold medium-file code reads toward map, and a file flagged suspect on a fix task is forced to full.
- Compression
adaptive thresholdsShannon-entropy line filtering, U-curve attention placement (LITM), TF-IDF codebook and query-conditioned Information-Bottleneck fusion — an anti-inflation guard ships the file verbatim whenever framing would cost more tokens than the raw bytes.
- Token accounting
core/tokens.rsExact tiktoken counts (o200k_base; cl100k_base approximation for Claude-family models) on input and output.
- Ledger + stats
savings sign / verify-batchSavings are appended to the local ledger (Ed25519-signable), stats and the gain score update, the result streams back.
lean-ctx -c "cargo test" · IDE bash hook दोनों पथ एक ही लेजर पर समाप्त होते हैं: हर संपीड़न घटना की गिनती सटीक टोकनाइज़र गणित के साथ होती है और gain, डैशबोर्ड और हस्ताक्षरित बचत लेजर को फीड करती है।
इंजीनियरिंग डेटा शीट
ड्रॉइंग के पीछे संदर्भ तालिकाएँ: हर सतह अपने परिवहन और जीवनचक्र के साथ, ऑन-डिस्क लेआउट, अनुकूली-सीखने वाली परतें, और सुरक्षा सीमाएँ जो रनटाइम लागू करता है।
Aप्रोसेस मॉडल
सभी सतहें विभिन्न भूमिकाओं में एक ही बाइनरी हैं। किसी को क्लाउड कनेक्शन की आवश्यकता नहीं है; सब कुछ स्थानीय-प्रथम (local-first) से बंधा हुआ है।
| REF | SURFACE | TRANSPORT | ENDPOINT | LIFECYCLE | कमांड |
|---|---|---|---|---|---|
| 01 | MCP server (stdio) | JSON-RPC over stdin/stdout | spawned per editor session | child process of the editor | lean-ctx |
| 02 | MCP server (HTTP) | MCP Streamable HTTP | localhost, configurable --host/--port | foreground or service | lean-ctx serve |
| 03 | IPC daemon | Unix Domain Socket | OS data dir, e.g. ~/Library/Application Support/lean-ctx/daemon.sock | launchd / systemd autostart | lean-ctx serve --daemon |
| 04 | Shell hook | process exec, compressed stdout | wraps IDE bash calls + interactive shells | per command | lean-ctx -c "<cmd>" |
| 05 | API proxy | HTTP (LLM API pass-through) | localhost:4444 (default) | on demand | lean-ctx proxy start |
| 06 | Web dashboard | HTTP + bearer token | localhost:3333 (default, --port) | on demand | lean-ctx dashboard |
| 07 | Terminal UI | TTY (in-place redraw) | live event stream / 1 s refresh | interactive | lean-ctx watch · gain --live |
Bस्टोरेज लेआउट — लोकल XDG डायरेक्टरीज़
स्थायी स्थिति (persistent state) XDG बेस डायरेक्टरीज़ के तहत सादे फ़ाइलें हैं: निरीक्षण योग्य, निर्यात करने योग्य, हटाने योग्य। इन स्थानीय फ़ोल्डरों से परे कोई छिपे हुए डेटाबेस नहीं।
| आर्टिफैक्ट | FORM | उद्देश्य |
|---|---|---|
config.toml | TOML | Single config file — integration mode, compression, providers, opt-outs (config dir) |
cache/ | content-addressed | Session file cache; unchanged re-reads collapse to ~13-token stubs (cache dir) |
bm25 index | inverted index | Lexical search over code chunks + provider documents (data dir) |
context_graph/ | property graph | Imports, calls, types across files and repos — powers map mode + deep queries (data dir) |
knowledge | SQLite | Persistent facts, decisions, rooms — recalled across sessions, CCP (data dir) |
savings ledger | append-only JSONL | Every compression event; Ed25519-signable for audit (data dir) |
litm_calibration.json | JSON | Learned context-position hit rates (lost-in-the-middle calibration) (cache dir) |
events.jsonl | event stream | Live feed consumed by watch, dashboard and efficacy reports (state dir) |
Cएडैप्टिव-लर्निंग लेयर्स
सात ऑनलाइन-लर्निंग मैकेनिज्म बౌन्सेस और एडिट फेलियर्स जैसे गुणवत्ता संकेतों के आधार पर आपके वास्तविक उपयोग के लिए संपीड़न (compression) को स्थानीय रूप से ट्यून करते हैं। गहन अध्ययन: एडैप्टिव लर्निंग →
- L1 Adaptive thresholds Online-learned compression aggressiveness from quality signals (bounces, edit failures, clean runs)
- L2 LITM calibration Empirical placement of critical context at positions the model actually attends to
- L3 Stigmergic scent field Multi-agent coordination via decaying markers: claimed, done, stuck, hot, avoid
- L4 Delta playbook Incremental checkpoint snapshots that survive context compaction
- L5 Query-conditioned IB Information-Bottleneck compression fused with query relevance
- L6 Theta-gamma chunking Wakeup facts grouped in attention-friendly bursts
- L7 Semantic dedup Likelihood-scored redundancy filtering across the session
Dसुरक्षा सीमाएँ
रनटाइम में लागू कठोर गारंटी। सिक्योरिटी मॉडल →
- PathJail Every file access is canonicalised and confined to the workspace root
- IDE config-dir jail Home-level IDE/agent config dirs (~/.claude, ~/.codex, ~/.codebuddy, …) are writable only when allow_ide_config_dirs is opted in; otherwise PathJail blocks them
- Shell allowlist Deny-by-default command policy for agent-issued shell executions
- Local-first All processing on-device; dashboard binds to localhost and requires a bearer token
- Signed evidence Savings ledger entries are Ed25519-signable and batch-verifiable
एक बाइनरी। तीन तरीकों से प्रवेश।
LeanCTX स्वचालित रूप से प्रत्येक एजेंट के लिए इष्टतम इंटीग्रेशन मोड का चयन करता है: CLI-Redirect शून्य MCP ओवरहेड के साथ संपादक नियमों के माध्यम से LeanCTX CLI चलाता है, Hybrid में MCP कैश रीड्स को शेल कंप्रेसन हुक्स के साथ जोड़ा जाता है, और Full MCP प्रोटोकॉल-केवल एडिटर्स के लिए अधिकतम टूल एक्सेस प्रदान करता है।
lean-ctx -c / read / grep MCP cache + CLI shell/search 81 tools via MCP + lazy tool set किसी भी तरह से, LeanCTX आपके एडिटर के लिए सही मोड चुनता है, स्वचालित रूप से। 30+ समर्थित टूल्स देखें
हमेशा ऑन। हमेशा आपका।
एक छोटा बैकग्राउंड सर्विस आपके सेशन को गर्म रखता है, ताकि कैश हिट तुरंत हो और मेमोरी हमेशा उपलब्ध रहे। यह सेटअप के दौरान स्वचालित रूप से शुरू होता है, अपडेट करने पर खुद को रीस्टार्ट करता है, और अपने आप साफ हो जाता है, प्रबंधित करने के लिए कुछ नहीं।
हर क्षमता, एक बाइनरी।
आपके कोड और AI के बीच सब कुछ, संभाला गया।
Smart I/O
निर्धारित रीड्स, शेल संपीड़न, खोज, पूर्ण कॉन्टेक्स्ट विजिबिलिटी + 99% कम टोकन
अनुरोध संपीड़न (Request Compression)
एक वैकल्पिक स्थानीय प्रॉक्सी मॉडल को हर अनुरोध - सिस्टम प्रॉम्प्ट, इतिहास और टूल परिणाम - संपीड़ित करता है — प्रॉम्प्ट-कैश सुरक्षित।
Intelligence
इरादा रूटिंग, मोड चयन, अनुकूली पाइपलाइन
Memory
सेशन, प्रोजेक्ट ज्ञान, ग्राफ, हैंडऑफ़्स
Governance
भूमिकाएँ, बजट, SLOs, वर्कफ़्लो गेट्स, नीतियाँ
Verification
Lean4 औपचारिक प्रमाण, दावा-आधारित सत्यापन, गुणवत्ता स्तर 0-4
Integrations
MCP, HTTP, SDK, 29+ IDEs, Cloud, Team Server
Shared Sessions
एजेंट्स के बीच वर्कस्पेस और चैनल-आधारित सेशन शेयरिंग
Context Bus
SSE के माध्यम से context परिवर्तनों के लिए रियल-टाइम इवेंट स्ट्रीम
SDK & API
बाहरी इंटीग्रेशन के लिए TypeScript SDK और REST API
हर आउटपुट प्रमाण लेकर आता है
LeanCTX हर सत्र के लिए प्रमाण कलाकृतियाँ उत्पन्न करता है: कौन सी फ़ाइलें पढ़ी गईं, क्या संपीड़ित किया गया, कौन सी जाँच पास हुईं, और टोकन कैसे खर्च हुए। यह AI कार्य को ऑडिट करने योग्य, पुनरावृत्ति योग्य और भरोसेमंद बनाता है।
LeanCTX (Lean Context का संक्षिप्त रूप) AI agents के लिए ओपन-सोर्स context engineering layer है। एक स्थानीय Rust बाइनरी यह तय करती है कि एजेंट्स क्या पढ़ते हैं (10 रीड मोड, 60–90% कम टोकन, ~13-टोकन कैश किए गए री-रीड्स), वे क्या सीखते हैं उसे याद रखती है (स्थायी सत्र, नॉलेज ग्राफ), वे क्या छूते हैं उसकी रक्षा करती है (PathJail, सीक्रेट रेडैक्शन, बजट, इंजेक्शन डिटेक्शन), वे क्या बचाते हैं उसका प्रमाण देती है (Ed25519-signed ledger, reproducible benchmark) और जो उन्होंने देखा उसे फिर से चलाती है (git-anchored, signed context snapshots जिन्हें आप पुनर्स्थापित या साझा कर सकते हैं); एक वैकल्पिक स्थानीय प्रॉक्सी उनके द्वारा भेजे गए डेटा को संपीड़ित करता है — हर अनुरोध का सिस्टम प्रॉम्प्ट, इतिहास और टूल आउटपुट, वायर पर prompt-cache-safe। कम्प्रेशन — रीड-साइड और वायर-साइड — पाँच उपप्रणालियों में से एक है, और हर मूल डेटा स्थानीय रूप से पुनर्प्राप्त करने योग्य रहता है। MCP और शेल हुक्स के माध्यम से 30+ AI कोडिंग टूल्स के साथ काम करता है; Python, TypeScript और Rust SDKs के साथ एक वर्ज़न किए गए /v1 API के माध्यम से किसी भी एजेंट में एम्बेड होता है। स्थानीय उपयोग हमेशा के लिए मुफ्त है, जो CI द्वारा लागू किया जाता है।
पूरी कहानी पढ़ें