كيف يعمل

طبقة هندسة السياق
للبرمجة بالذكاء الاصطناعي.

lean-ctx هو نظام ضغط بثلاث طبقات مستقلة. خادم سياق يستبدل قراءات الملفات بنسخ مضغوطة واعية بـ AST. Shell Hook يعترض أكثر من 95 نمط أوامر CLI. وثلاثة بروتوكولات اتصال تعلم الذكاء الاصطناعي الاستجابة بكفاءة أكبر. تثبته مرة واحدة - وكل شيء آخر يحدث تلقائياً.

تدفق البيانات

أين يقع lean-ctx بالضبط؟

lean-ctx يعترض على مستويين: طبقة السياق (قراءات الملفات، البحث في الكود، أوامر الشل) وطبقة الشل (مخرجات CLI الخام). كلاهما يضغط البيانات قبل وصولها لنموذج اللغة. يرى الذكاء الاصطناعي نفس المعلومات بجزء بسيط من الرموز.

data flow - before vs. after
Without lean-ctx:

YouAI Tool  →  reads file  (full content)LLM processes everything

With lean-ctx:

YouAI Toollean-ctx compresses  →  signal onlyLLM: 60–99% less noise
                           ├─ PathJail sandbox + size caps
                           ├─ AST-aware compression
                           ├─ Memory Runtime (knowledge + forgetting)
                           ├─ Session cache (re-read ≈ 13 tok)
                           └─ 10 read modes per file type

أنت

برمج بشكل طبيعي. لا تغير شيئاً في سير عملك.

أداة الذكاء الاصطناعي

Cursor وClaude Code وCopilot وWindsurf و…

lean-ctx

يضغط كل شيء عبر خادم السياق و Shell Hook.

نموذج اللغة

يرى الإشارة فقط. 60–90% رموز أقل، نفس المعلومات.

أمران فقط. هذا كل شيء.

ماذا تفعل أنت فعلاً؟

تقريباً لا شيء. lean-ctx يعمل بشكل غير مرئي بعد إعداد لمرة واحدة. تستمر في البرمجة كما كنت بالضبط.

01

التثبيت

ملف Rust واحد. بدون اعتماديات، بدون سحابة، بدون حساب.

curl -fsSL leanctx.com/install.sh | sh
02

الإعداد

يكتشف تلقائياً الشل وأدوات الذكاء الاصطناعي. يعد كل شيء في ثوانٍ.

lean-ctx setup
03

لا يوجد خطوة 3

برمج بشكل طبيعي. ذكاؤك الاصطناعي يستخدم الأدوات المضغوطة تلقائياً.

الرموز الموفرة: تلقائياً

أنت مقابل الآلة

ما تفعله أنت (مرة واحدة) ما يحدث تلقائياً
lean-ctx setup الذكاء الاصطناعي يستخدم ctx_read بدلاً من Read - حتى 99% رموز أقل (إعادة القراءة المخزنة)
الذكاء الاصطناعي يستخدم ctx_shell بدلاً من Shell - 60–90% رموز أقل
الذكاء الاصطناعي يستخدم ctx_search بدلاً من Grep - 50–80% رموز أقل
Shell Hook يضغط مخرجات CLI بشفافية
ذاكرة التخزين المؤقت للجلسة تتذكر الملفات عبر القراءات (~13 رمزاً لإعادة القراءة)
lean-ctx gain (اختياري) شاهد لوحة التوفيرات مدى الحياة

دليل الإعداد الكامل ← البداية  ·  جميع أوامر CLI ← مرجع CLI

Reciprocal Rank Fusion (RRF) Cache Eviction

When the session cache is full, lean-ctx uses Reciprocal Rank Fusion to decide which entries to evict. Each signal (recency, frequency, size) is ranked independently, then fused into a single score - no arbitrary weight tuning required.

Formula: RRF(d) = Σ 1/(K + rank_i(d)) where K=60. This handles signal incomparability (seconds vs counts vs tokens) without needing tuned weights, unlike traditional weighted combinations.

Want to understand the architecture?

Explore the Context OS: the six-step pipeline, integration modes, agent matrix, Context Field Theory, and nine architectural pillars that make lean-ctx work.

Deep dive into Context OS

Security Layer

lean-ctx enforces a defense-in-depth security model to prevent LLM prompt injection from accessing files outside the project:

  • PathJail - All file operations are sandboxed to the project root. Symlink traversal, ../ escapes, and absolute paths outside the jail are blocked at the resolve_path chokepoint.
  • Bounded Shell Capture - Shell output is capped at 200KB with clear truncation markers. Prevents memory exhaustion from runaway commands.
  • TOCTOU Prevention - File edits use same file handle for read-verify-write, eliminating time-of-check-to-time-of-use race conditions.
  • Build Integrity - Compile-time integrity seed and hash verification detect tampered binaries. Checked automatically by lean-ctx doctor.
ابدأ الآن

مستعد لبدء التوفير؟

ملف واحد. بدون اعتماديات سحابية. رخصة Apache-2.0. ثبّت في 60 ثانية وابدأ بتوفير الرموز فوراً.