هذا المرجع الشامل لكل أمر lean-ctx. لورقة غش سريعة، انظر المرجع السريع. لتفاصيل التحليلات ولوحات المعلومات، انظر دليل التحليلات.
ضغط الشل
هذه الأوامر تمرر أوامر الشل عبر أكثر من 95 نمط ضغط في lean-ctx.
lean-ctx -c "<command>"
نفّذ أي أمر شل واضغط إخراجه. الاسم المستعار: lean-ctx exec.
lean-ctx -c "git status"
lean-ctx -c "kubectl get pods -A"
lean-ctx -c "cargo build 2>&1"
lean-ctx exec "docker ps" Shell Hook (المثبت عبر lean-ctx init) يجعل هذا تلقائياً للأوامر الشائعة.
lean-ctx shell
ابدأ جلسة شل تفاعلية حيث يتم ضغط كل إخراج الأوامر.
lean-ctx shell
# Now every command output is compressed automatically
git log --oneline -20
docker compose logs
# Exit with Ctrl+D or 'exit' الوضع الخام
تخطي الضغط بالكامل عندما تحتاج إخراجاً كاملاً غير معدل. ثلاث طرق للتفعيل:
# CLI flag
lean-ctx -c --raw git log --stat
# Shell function (after lean-ctx init --global)
lean-ctx-raw kubectl get pods -o yaml
# MCP parameter
ctx_shell(command="cat package.json", raw=true)
# Environment variable
LEAN_CTX_RAW=1 lean-ctx -c npm list
# Bypass command - guaranteed zero compression
lean-ctx bypass "git diff HEAD~1"
# Kill-switch: disable ALL compression
LEAN_CTX_DISABLED=1 lean-ctx -c git status lean-ctx bypass "<command>"
تشغيل أي أمر مع ضمان عدم الضغط. يقوم داخلياً بتعيين LEAN_CTX_RAW=1 قبل تنفيذ الأمر. استخدمه عندما تحتاج إلى يقين مطلق بأن المخرجات غير معدّلة.
lean-ctx bypass "git diff HEAD~1" # guaranteed unmodified output
lean-ctx bypass "docker logs myapp" # no compression, no truncation
lean-ctx bypass "npm audit" # raw vulnerability report نصيحة: bypass يعادل LEAN_CTX_RAW=1 lean-ctx -c "command" لكنه أكثر ملاءمة. يتم تمرير سلسلة الأمر مباشرة إلى الصدفة.
عمليات الملفات
وصول مباشر من CLI إلى أدوات قراءة وبحث وتنقل lean-ctx.
lean-ctx read <file> [-m <mode>]
قراءة ملف مع وضع ضغط اختياري. الوضع الافتراضي هو full.
lean-ctx read src/main.rs # auto-selects best mode
lean-ctx read src/main.rs -m full # full content (cached)
lean-ctx read src/main.rs -m map # dependency graph + exports
lean-ctx read src/main.rs -m signatures # tree-sitter AST extraction
lean-ctx read src/main.rs -m aggressive # syntax-stripped
lean-ctx read src/main.rs -m entropy # Shannon entropy filtered
lean-ctx read src/main.rs -m diff # changed lines only
lean-ctx read src/main.rs -m task # IB-filtered for current task
lean-ctx read src/main.rs -m reference # cross-reference context
lean-ctx read src/main.rs -m lines:10-50 # specific line range
lean-ctx read src/main.rs -m lines:10-50,80 # multiple ranges lean-ctx diff <file1> <file2>
فرق مضغوط بين ملفين مع ملخصات تغييرات منظمة.
lean-ctx diff old.rs new.rs lean-ctx grep <pattern> [path]
بحث في محتويات الملفات مع نتائج مضغوطة ومجمعة.
lean-ctx grep "pub fn" src/
lean-ctx grep "TODO" .
lean-ctx grep "async fn.*Result" rust/src/ lean-ctx find <pattern> [path]
البحث عن ملفات بنمط الاسم. يحترم .gitignore.
lean-ctx find "*.rs" src/
lean-ctx find "test_*" . lean-ctx ls [path]
قائمة مجلدات مضغوطة كخريطة شجرية مع عدد الملفات.
lean-ctx ls
lean-ctx ls src/components/ lean-ctx deps [path]
عرض رسم تبعيات المشروع.
lean-ctx deps .
lean-ctx deps frontend/ أوضاع القراءة
أوضاع القراءة تتحكم في كيفية ضغط lean-ctx read وأداة MCP ctx_read لمحتوى الملفات.
| الوضع | الإخراج | حالة الاستخدام | Savings |
|---|---|---|---|
auto | أفضل وضع للسياق | الافتراضي عند عدم تحديد وضع - يختار lean-ctx الاستراتيجية المثلى | 60–95% |
full | محتوى الملف الكامل | ملفات ستحررها. إعادة القراءة تكلف ~13 رمز (مخزنة). | 0% (أول قراءة)، ~99% (مخزنة) |
map | رسم التبعيات + الصادرات + التوقيعات الرئيسية | ملفات للسياق فقط - فهم البنية بدون قراءة كل شيء. | 90–98% |
signatures | استخراج AST بـ tree-sitter (18 لغة) | واجهة API فقط - توقيعات الدوال/الطرق/الفئات. | 92–99% |
aggressive | محتوى منزوع الصياغة | أقصى ضغط مع الحفاظ على المنطق. | 85–95% |
entropy | إنتروبيا شانون + تصفية Jaccard | الاحتفاظ فقط بالسطور الغنية بالمعلومات. | 70–90% |
diff | السطور المتغيرة فقط (مقابل آخر قراءة) | بعد التحرير - رؤية ما تغير فقط. | 90–99% |
task | محتوى مُرشّح حسب المهمة | استخراج بتقييم IB حسب النية الحالية - يعيد فقط الكود المرتبط بالمهمة النشطة | 70–90% |
reference | سياق مرجعي متقاطع | أنواع مرتبطة، ومستدعون، واعتماديات للرمز أو الدالة المستهدفة | 60–85% |
lines:N-M | نطاقات سطور محددة | قراءة القسم الذي تحتاجه فقط. | varies |
اللغات المدعومة لوضع signatures: TypeScript وJavaScript وRust وPython وGo وJava وC وC++ وRuby وC# وKotlin وSwift وPHP (14 عبر tree-sitter).
الإعداد والتهيئة
lean-ctx setup
إعداد بأمر واحد. يكتشف تلقائياً الشل ويجد أدوات الذكاء الاصطناعي المثبتة ويهيئ خادم MCP + Shell Hooks.
lean-ctx setup يشغّل ثلاث خطوات داخلياً:
- يثبت اختصارات الشل (
init --global) - يهيئ MCP لكل أداة ذكاء اصطناعي مكتشفة
- يتحقق من كل شيء (
doctor)
Since v3.3.3, the setup wizard includes a Premium Features step where you can configure Terse Agent Mode, Tool Result Archive, and Output Density interactively.
lean-ctx init [--global | <shell>]
تثبيت اختصارات ضغط الشل في ملف الشل.
# File-based: writes aliases directly into your shell profile
lean-ctx init # install for current shell
lean-ctx init --global # same, explicit flag
# Eval-based: prints hook code to stdout (like starship, zoxide, atuin)
eval "$(lean-ctx init bash)" # bash: add to ~/.bashrc
eval "$(lean-ctx init zsh)" # zsh: add to ~/.zshrc
lean-ctx init fish | source # fish: add to config.fish
lean-ctx init powershell | Invoke-Expression # PowerShell: add to $PROFILE يكتب كتلة في ~/.zshrc أو ~/.bashrc أو ~/.config/fish/config.fish أو ملف PowerShell.
نمط eval: تقوم طريقة eval بطباعة كود الخطاف إلى stdout، مما يضمن تطابقه دائماً مع إصدار الملف الثنائي المثبت. هذا هو نفس النمط المستخدم بواسطة starship وzoxide وatuin. لا تصبح الخطافات قديمة أبداً بعد الترقيات.
lean-ctx init --agent <name>
تهيئة MCP لأداة ذكاء اصطناعي محددة بدون تشغيل الإعداد الكامل.
| Agent | Notes |
|---|---|
cursor | Cursor IDE (default MCP setup) |
claude | Claude Code / Claude Desktop |
codex | OpenAI Codex CLI |
gemini | Google Gemini CLI |
antigravity | Alias for gemini |
windsurf | Windsurf IDE |
copilot | GitHub Copilot |
cline | Cline (VS Code extension) |
roo | Roo Code |
aider | Aider CLI |
continue | Continue.dev |
zed | Zed Editor |
void | Void Editor |
amp | Amp (Sourcegraph) |
trae | Trae IDE |
kilo | Kilo Code |
opencode | OpenCode CLI |
pi | Installs pi-lean-ctx npm package |
custom | Generic MCP config - prompts for path |
lean-ctx init --agent cursor
lean-ctx init --agent claude
lean-ctx init --agent codex
lean-ctx init --agent gemini
lean-ctx init --agent antigravity # alias for gemini
lean-ctx init --agent windsurf
lean-ctx init --agent copilot
lean-ctx init --agent cline
lean-ctx init --agent roo
lean-ctx init --agent aider
lean-ctx init --agent continue
lean-ctx init --agent zed
lean-ctx init --agent void
lean-ctx init --agent amp
lean-ctx init --agent trae
lean-ctx init --agent kilo
lean-ctx init --agent opencode
lean-ctx init --agent pi # installs pi-lean-ctx npm package
lean-ctx init --agent custom # generic MCP config lean-ctx config [set <key> <value>]
عرض أو تعديل التهيئة المخزنة في ~/.lean-ctx/config.toml.
lean-ctx config # show current config
lean-ctx config set ultra_compact true # enable ultra-compact mode
lean-ctx config set tee_on_error true # log errors to ~/.lean-ctx/tee/
lean-ctx config set checkpoint_interval 20 Settable Configuration Keys
| Key | Type | Default | Description |
|---|---|---|---|
ultra_compact | bool | false | Enable ultra-compact output mode for maximum token savings |
tee_mode | string | "off" | Tee logging mode: off, on_error, always |
checkpoint_interval | int | 15 | Number of MCP calls between automatic checkpoints |
theme | string | "default" | Dashboard and TUI theme (default, dark, light, neon) |
slow_command_threshold_ms | int | 5000 | Threshold in milliseconds for slow-log entries |
passthrough_urls | string[] | [] | URL patterns that bypass compression (comma-separated) |
rules_scope | string | "project" | Scope for rules loading: project, global, or both |
lean-ctx config set theme neon
lean-ctx config set slow_command_threshold_ms 3000
lean-ctx config set passthrough_urls "localhost:3000,api.example.com"
lean-ctx config set rules_scope both lean-ctx doctor
تشغيل 8 فحوصات تشخيصية للتثبيت والبيئة:
- البرنامج مثبت وفي PATH
- Shell Hook نشط
- تهيئة MCP للمحررات المكتشفة
- استمرار ملف الإحصائيات
- مجلد الذاكرة المؤقتة
- شل مدعوم مكتشف
- اكتشاف أداة الذكاء الاصطناعي
- فحص الإصدار
- Rules injection status
- Claude Code instructions (rules + skill installed)
- Build integrity verification
lean-ctx doctor lean-ctx update [--check]
تحديث ذاتي لبرنامج lean-ctx من GitHub Releases.
lean-ctx update # download and install latest version
lean-ctx update --check # check if a newer version is available (no install) lean-ctx login <email> [--password <pw>] v3.3.3
Authenticate with LeanCTX Cloud. Only attempts login - does not create a new account. If password is omitted, prompts interactively.
lean-ctx login user@example.com
lean-ctx login user@example.com --password mypassword
On success, saves the API key to ~/.lean-ctx/cloud/credentials.json and syncs
your data. If your email is not yet verified, you'll receive a reminder to check your inbox.
lean-ctx register <email> [--password <pw>] v3.3.3
Create a new LeanCTX Cloud account. Separate from login - no auto-fallback.
A verification email is sent after registration.
lean-ctx register user@example.com
lean-ctx register user@example.com --password mypassword lean-ctx forgot-password <email>
Request a password reset email for an existing LeanCTX Cloud account.
lean-ctx forgot-password user@example.com lean-ctx uninstall
إزالة كل إعدادات lean-ctx.
lean-ctx uninstall التحليلات ولوحات المعلومات
لدليل مفصل انظر دليل التحليلات.
lean-ctx gain [flags]
لوحة طرفية بصرية تعرض توفير الرموز مدى الحياة.
مدعوم بـ GainEngine - واجهة رصد موحّدة تجمع مقاييس الضغط وتتبع التكلفة وتحليلات الجلسة ضمن GainScore (0–100). تستخدم ModelPricing مدمجًا (بدون شبكة) و TaskClassifier بـ 13 فئة.
| العلم | الإخراج |
|---|---|
(none) | لوحة كاملة: الموفر والمعدل وUSD والأوامر الأعلى وSparklines |
--score | GainScore (0–100) يجمع نسبة الضغط وكفاءة التكلفة والجودة والاتساق |
--cost | تفصيل التكلفة لكل نموذج مع تسعير مدمج (يدعم فلتر --model=<name>) |
--tasks | تفصيل تصنيف المهام عبر 13 فئة (file-ops و search و shell و memory وغيرها) |
--agents | إحصاءات لكل وكيل في جلسات متعددة الوكلاء (calls و tokens وإسناد التكلفة) |
--heatmap | خريطة حرارية لقراءة الملفات - ما الملفات الأكثر قراءة من قبل الذكاء الاصطناعي |
--wrapped | ملخص جلسة بأسلوب Spotify Wrapped (يدعم --period=week|month|all) |
--deep | تحليل عميق موحّد: report + tasks + cost + agents + heatmap في مخرج واحد |
--live | وضع التحديث التلقائي (يتحدث كل 2 ثانية). اضغط q للخروج. |
--graph | رسم توفير لـ 30 يوماً بأعمدة يومية |
--daily | جدول يومي مؤطر بأعداد الرموز وUSD |
--pipeline | Pipeline-view: shows compression stages and per-stage token savings |
--json | تصدير JSON خام لكل الإحصائيات (للسكريبتات/الأتمتة) |
المعدِّلات
| العلم | الإخراج |
|---|---|
--model=<name> | فلترة المخرجات إلى نموذج محدد (مثل --model=claude-4-sonnet) |
--period=<p> | نافذة الزمن: today و week و month و all (الافتراضي: all) |
--limit=<n> | الحد الأقصى لعدد الصفوف في الجداول المرتبة (الافتراضي: 10) |
--reset | مسح جميع الإحصاءات والبدء من جديد |
lean-ctx gain # overview with GainScore
lean-ctx gain --score # GainScore breakdown
lean-ctx gain --cost --model=claude-4-sonnet # cost for specific model
lean-ctx gain --tasks # task classification heatmap
lean-ctx gain --agents # multi-agent cost attribution
lean-ctx gain --deep # full deep-dive report
lean-ctx gain --wrapped --period=week # weekly summary
lean-ctx gain --live # real-time monitoring
lean-ctx gain --graph # ASCII savings graph
lean-ctx gain --daily # daily breakdown
lean-ctx gain --pipeline # per-stage compression breakdown
lean-ctx gain --json > stats.json # machine-readable export أداة MCP ctx_gain توفر نفس التحليلات برمجيًا - يمكن للوكلاء الاستعلام عن توفير التوكن وتفاصيل التكلفة و GainScore أثناء الجلسة. راجع مرجع أدوات MCP.
lean-ctx cep [--json]
تقرير تأثير CEP (Cognitive Efficiency Protocol) يعرض اتجاهات النقاط ومعدلات إصابة الذاكرة المؤقتة وتوزيع الأوضاع.
Internally uses ctx_gain --score to compute the Context Efficiency Protocol score.
The CEP score ranges from 0–100 and measures how efficiently context is being utilized across
read modes, shell compression, and deduplication.
| Flag | Description |
|---|---|
(none) | Pretty-print CEP score with breakdown |
--json | Machine-readable JSON output |
lean-ctx cep # show CEP score with breakdown
lean-ctx cep --json # JSON output for CI/CD integration lean-ctx dashboard [--port=N] [--project=<path>]
فتح لوحة الويب التفاعلية على http://localhost:3333.
| Flag | Description |
|---|---|
--port=<N> | Custom port (default: 3333) |
--project=<path> | Scope dashboard to a specific project directory instead of the global view |
lean-ctx dashboard # opens at localhost:3333
lean-ctx dashboard --port=8080 # custom port
lean-ctx dashboard --project=~/my-app # scoped to a single project lean-ctx wrapped [--week|--month|--all]
إنشاء بطاقة تقرير "Wrapped" قابلة للمشاركة لتوفير الرموز.
| العلم | الفترة |
|---|---|
(none) | الأسبوع الحالي |
--week | الأسبوع الحالي (صريح) |
--month | الشهر الحالي |
--all | إحصائيات مدى الحياة |
lean-ctx wrapped
lean-ctx wrapped --month
lean-ctx wrapped --all إدارة الجلسات
lean-ctx sessions [list|show|cleanup]
إدارة جلسات CCP (Context Continuity Protocol) المخزنة في ~/.lean-ctx/sessions/.
| الأمر الفرعي | الإجراء |
|---|---|
list | سرد كل الجلسات المحفوظة |
show | عرض أحدث حالة جلسة |
cleanup | إزالة الجلسات القديمة/المنتهية |
lean-ctx sessions list
lean-ctx sessions show
lean-ctx sessions cleanup lean-ctx session
عرض إحصائيات التبني - مدى استخدام سير عملك لضغط lean-ctx.
lean-ctx session إدارة المعرفة
وصول كامل عبر CLI إلى مخزن معرفة المشروع المستمر. تبقى الحقائق والأنماط والاتفاقيات عبر الجلسات وتتيح فهمًا تراكميًا للمشروع.
lean-ctx knowledge remember <value> --category <c> --key <k>
تخزين حقيقة في قاعدة معرفة المشروع مع درجة ثقة اختيارية.
lean-ctx knowledge remember "Uses JWT for auth" --category auth --key token-type
lean-ctx knowledge remember "PostgreSQL 16" --category arch --key database --confidence 0.95 lean-ctx knowledge recall [query] [--category <c>] [--mode auto|semantic|hybrid]
استرجاع الحقائق حسب نص الاستعلام أو الفئة. يدعم الاسترجاع الدلالي عند تفعيل التضمينات.
lean-ctx knowledge recall "authentication"
lean-ctx knowledge recall --category security
lean-ctx knowledge recall "auth" --mode semantic lean-ctx knowledge search <query>
البحث عبر جميع المشاريع والجلسات عن حقائق مطابقة.
lean-ctx knowledge search "database migration" lean-ctx knowledge export [--format json|jsonl|simple] [--output <path>]
تصدير قاعدة معرفة المشروع. الإخراج افتراضيًا إلى stdout (متوافق مع الأنابيب). ثلاثة تنسيقات: json (أصلي كامل، افتراضي)، jsonl (حقيقة واحدة لكل سطر)، simple (مصفوفة متوافقة مع المجتمع للترحيل من أدوات أخرى).
lean-ctx knowledge export # full JSON to stdout
lean-ctx knowledge export --format jsonl --output backup.jsonl # JSONL to file
lean-ctx knowledge export --format simple | jq '.[].key' # pipe-friendly lean-ctx knowledge import <path> [--merge replace|append|skip-existing] [--dry-run]
استيراد الحقائق من ملف JSON أو JSONL أو تصدير أصلي. يكتشف تنسيق الإدخال تلقائيًا. استراتيجية الدمج الافتراضية هي skip-existing (آمنة — لا تكتب فوق البيانات).
lean-ctx knowledge import backup.json --dry-run # preview changes
lean-ctx knowledge import facts.jsonl --merge replace # overwrite existing
lean-ctx knowledge import migration.json --merge skip-existing lean-ctx knowledge remove --category <c> --key <k>
إزالة حقيقة محددة من قاعدة المعرفة.
lean-ctx knowledge remove --category auth --key token-type lean-ctx knowledge status
عرض ملخص قاعدة المعرفة — عدد الحقائق والفئات ووقت آخر تحديث.
lean-ctx knowledge status lean-ctx knowledge health
تقرير صحي مع مقاييس الجودة واكتشاف الحقائق القديمة وتوازن المساحات.
lean-ctx knowledge health قياس الأداء
lean-ctx benchmark run [path] [--json]
تشغيل اختبارات رموز حقيقية على ملفات مشروعك باستخدام tiktoken (o200k_base).
lean-ctx benchmark run # benchmark current directory
lean-ctx benchmark run src/ # benchmark specific path
lean-ctx benchmark run . --json # output as JSON lean-ctx benchmark report [path]
إنشاء تقرير Markdown قابل للمشاركة من نتائج الاختبار.
lean-ctx benchmark report # generate report for current directory
lean-ctx benchmark report src/ > BENCHMARK.md Tee والفلاتر
lean-ctx tee [list|clear|show <file>|last]
إدارة ملفات tee للإخراج الكامل المحفوظة في ~/.lean-ctx/tee/.
lean-ctx filter [list|validate|init]
إدارة فلاتر الضغط المخصصة في ~/.lean-ctx/filters/*.toml.
# Create example filter
lean-ctx filter init
# List loaded filters
lean-ctx filter list
# Validate filter syntax
lean-ctx filter validate الأدوات المساعدة
lean-ctx discover
فحص سجل الشل بحثاً عن أوامر يمكن أن تستفيد من الضغط.
lean-ctx discover lean-ctx ghost [--json]
Reveals hidden token waste in your workflow - shows unoptimized shell commands, redundant reads,
and oversized contexts with a monthly USD savings estimate. Use --json for CI integration.
lean-ctx ghost
lean-ctx ghost --json lean-ctx cheatsheet
طباعة ورقة غش مضغوطة لكل الأوامر في الطرفية.
lean-ctx cheatsheet lean-ctx tee [list|clear|show <file>]
إدارة ملفات سجل الأخطاء المخزنة في ~/.lean-ctx/tee/.
| الأمر الفرعي | الإجراء |
|---|---|
list | سرد كل ملفات سجل الأخطاء |
clear | حذف كل سجلات الأخطاء |
show <file> | عرض سجل خطأ محدد |
lean-ctx tee list
lean-ctx tee show 2026-03-29_10-30.log
lean-ctx tee clear lean-ctx slow-log [list|clear]
عرض أو مسح سجل الأوامر البطيئة في ~/.lean-ctx/slow-commands.log.
lean-ctx slow-log list
lean-ctx slow-log clear Graph المشروع
بناء أو فحص dependency graph للمشروع. يقوم الـ graph بفهرسة علاقات الملفات (imports وexports والرموز) ويُستخدم في heat-ranking وتحليل النوايا والتحميل المسبق الذكي.
lean-ctx graph build
مسح دليل المشروع وبناء فهرس dependency graph. يتم بناء الـ graph أيضاً تلقائياً عند استخدام أدوات MCP.
lean-ctx graph build Heat Map السياق
تصور كثافة token الملفات واتصالات dependency graph كخريطة حرارية ملونة. الملفات ذات عدد token المرتفع والاتصالات الكثيرة تظهر أكثر سخونة.
lean-ctx heatmap
عرض heat map طرفية لجميع ملفات المشروع الحالي، مرتبة حسب درجة الحرارة (مزيج من عدد الـ token واتصالات الـ graph).
lean-ctx heatmap مستويات السلامة
يصنف LeanCTX كل أمر مدعوم إلى مستوى سلامة يحدد مدى قوة ضغط المخرجات. المستويات الأعلى لا تزيل أبداً المعلومات الحرجة للسلامة (الأخطاء، CVEs، حالة الصحة).
lean-ctx safety-levels
يعرض جدولاً مفصلاً يوضح بالضبط كيف يتم ضغط كل نوع أمر، وما هي البيانات المحفوظة، وما هي ميزات السلامة العامة النشطة.
lean-ctx safety-levels | المستوى | الأوامر | السلوك |
|---|---|---|
VERBATIM | df, git status, git stash, ls, find, wc, env | ضغط صفري. تمر المخرجات بالكامل دون تعديل. |
MINIMAL | git diff, git log, docker ps, grep, ruff, npm audit, pytest, pip, curl | تنسيق خفيف فقط. جميع البيانات الحرجة للسلامة (فروقات الكود، تفاصيل الأخطاء، معرّفات CVE، حالة الصحة) محفوظة بالكامل. |
STANDARD | cargo build, npm install, eslint, tsc, go build, maven, gradle, dotnet | ضغط مهيكل. يتم دائماً الحفاظ على الأخطاء والتحذيرات والعناصر القابلة للتنفيذ. |
AGGRESSIVE | kubectl describe, aws, terraform, docker images | ضغط كثيف للمخرجات المطوّلة. لا يزال يحافظ على رسائل الخطأ والكلمات المفتاحية الحرجة للسلامة. |
ميزات السلامة العامة تنطبق على جميع المستويات: فحص إبر السلامة (يحافظ على CRITICAL وFATAL وpanic وCVE-* وOOMKilled إلخ)، نسبة الحماية (تحظر الضغط >95%)، كشف المصادقة (يخفي الرموز/كلمات المرور)، والحد الأدنى للرموز (لا ضغط أقل من 50 رمزاً).
اختصارات الشل
بعد تشغيل lean-ctx init --global، هذه الاختصارات متاحة في الشل.
| الاختصار | الإجراء |
|---|---|
lean-ctx-on | تفعيل كل اختصارات الضغط |
lean-ctx-off | تعطيل الضغط (إخراج قابل للقراءة البشرية) |
lean-ctx-status | عرض ما إذا كان الضغط نشطاً حالياً |
lean-ctx-raw <cmd> | تشغيل أمر واحد بدون ضغط |
lean-ctx-status # check current state
lean-ctx-off # temporarily disable for human reading
git log # now shows full, uncompressed output
lean-ctx-on # re-enable for AI sessions متى تعطل: أوقف الضغط عندما تريد قراءة إخراج الأوامر بنفسك (التصحيح، مراجعة السجلات). أعد تشغيله قبل بدء جلسة برمجة بالذكاء الاصطناعي.
Server & Services
lean-ctx can run as a long-lived HTTP server, a TUI watcher, or a network proxy. These modes are useful for CI/CD pipelines, multi-agent orchestration, and headless environments.
lean-ctx serve [flags] feature: http-server
Start an HTTP/REST server that exposes all MCP tools as REST endpoints.
Requires the http-server feature gate.
Supports both stateful (session-persisted) and stateless modes.
| Flag | Default | Description |
|---|---|---|
--port=<N> | 9119 | Port to listen on |
--host=<addr> | 127.0.0.1 | Bind address (0.0.0.0 for all interfaces) |
--stateless | off | Disable session persistence - each request is independent |
--rate-limit=<N> | 100 | Max requests per minute per client |
--timeout=<ms> | 30000 | Request timeout in milliseconds |
--cors | off | Enable CORS headers for browser access |
# Start server with defaults
lean-ctx serve
# Public-facing with rate limits
lean-ctx serve --host=0.0.0.0 --port=8080 --rate-limit=50
# Stateless mode for CI/CD
lean-ctx serve --stateless --timeout=60000
# With CORS for web dashboard
lean-ctx serve --cors --port=9119
Once running, all MCP tools are available at POST /v1/tools/<tool_name>.
A health endpoint is at GET /health.
lean-ctx watch
Start lean-ctx in TUI (Terminal UI) mode with a live event bus.
Monitors all MCP activity in real time and writes events to
~/.lean-ctx/events.jsonl for post-hoc analysis.
| Flag | Description |
|---|---|
--filter=<pattern> | Only show events matching the pattern (e.g. ctx_read, error) |
--no-tui | Headless mode - stream events to stdout as JSONL |
lean-ctx watch # full TUI with live event stream
lean-ctx watch --filter=ctx_shell # only shell events
lean-ctx watch --no-tui # headless JSONL to stdout lean-ctx proxy <start|stop|status> feature-gated
Manage the lean-ctx network proxy. When active, the proxy intercepts MCP traffic
and applies compression transparently. Requires the proxy feature gate.
| Subcommand | Description |
|---|---|
start | Start the proxy daemon |
stop | Stop the running proxy |
status | Show proxy status (running/stopped, port, uptime) |
lean-ctx proxy start # start proxy daemon
lean-ctx proxy status # check if proxy is running
lean-ctx proxy stop # stop the proxy Terse Agent
The Terse Agent controls output density for AI agent communication. It persists across sessions and can be toggled at any time. See also the Configuration guide.
lean-ctx terse [lite|full|ultra|off]
Query or set the Terse Agent mode. Without arguments, shows the current mode. With an argument, sets the mode persistently.
| Mode | Description |
|---|---|
off | Terse Agent disabled - standard MCP output |
lite | Light compression: removes boilerplate, keeps structure |
full | Full terse mode: abbreviated keys, minimal whitespace, Fn refs |
ultra | Maximum density: single-line responses, aggressive abbreviation, diff-only |
lean-ctx terse # show current terse mode
lean-ctx terse lite # set to lite mode
lean-ctx terse full # set to full mode
lean-ctx terse ultra # maximum compression
lean-ctx terse off # disable terse agent Token Reports
Generate detailed token usage reports for analysis and cost tracking.
lean-ctx token-report [flags]
Display a comprehensive token usage report for the current or specified project.
Also available as lean-ctx report-tokens (alias).
| Flag | Description |
|---|---|
(none) | Summary report for the current session |
--project=<path> | Report for a specific project directory |
--period=<p> | Time period: today, week, month, all |
--by-tool | Break down usage by MCP tool |
--by-mode | Break down usage by read mode |
--json | Machine-readable JSON output |
lean-ctx token-report # current session summary
lean-ctx token-report --period=week # weekly report
lean-ctx token-report --by-tool --period=month # monthly per-tool breakdown
lean-ctx report-tokens --json > report.json # alias, JSON export Cache Management
Manage the lean-ctx content cache that accelerates repeated reads and avoids redundant compression.
lean-ctx cache <subcommand> [flags]
| Subcommand | Description |
|---|---|
status | Show cache size, hit rate, and entry count |
clear | Clear all cached entries |
invalidate <pattern> | Invalidate cache entries matching a glob pattern |
reset --project=<path> | Reset cache for a specific project only |
lean-ctx cache status # cache stats
lean-ctx cache clear # purge entire cache
lean-ctx cache invalidate "src/**/*.rs" # invalidate Rust files
lean-ctx cache reset --project=~/my-app # reset for one project Gotchas
Manage known gotchas - common pitfalls, edge cases, and warnings that lean-ctx
tracks across your projects. Also available as lean-ctx bugs (alias).
lean-ctx gotchas [list|add|remove|clear]
| Subcommand | Description |
|---|---|
list | Show all tracked gotchas for the current project |
add "<description>" | Add a new gotcha entry |
remove <id> | Remove a gotcha by its ID |
clear | Remove all gotchas for the current project |
lean-ctx gotchas list
lean-ctx gotchas add "ctx_shell timeout on M1 with Docker Rosetta"
lean-ctx gotchas remove 3
lean-ctx bugs list # alias for gotchas list
lean-ctx bugs clear Buddy
The Buddy (also called Pet) is an interactive companion feature that provides contextual tips, encouragement, and session insights. Purely cosmetic and opt-in.
lean-ctx buddy [status|on|off|name <name>]
| Subcommand | Description |
|---|---|
status | Show buddy status and current name |
on | Enable the buddy |
off | Disable the buddy |
name <name> | Give your buddy a custom name |
lean-ctx buddy status # check buddy state
lean-ctx buddy on # enable buddy
lean-ctx buddy name Ferris # name your buddy
lean-ctx pet off # alias - disable buddy حزم السياق
إنشاء وإدارة ومشاركة حزم سياق محمولة تجمع المعرفة وبيانات الرسم البياني ونتائج الجلسات والملاحظات في أرشيفات مُصدَّرة.
lean-ctx pack create --name <name> [--layers <layers>]
Create a context package from the current project. Layers default to all available
(knowledge,graph,session,patterns,gotchas).
lean-ctx pack create --name my-pkg
lean-ctx pack create --name api-knowledge --layers knowledge,gotchas
lean-ctx pack create --name full-snapshot --version 2.0.0 lean-ctx pack list
List all installed packages with version and auto-load status.
lean-ctx pack list lean-ctx pack info <name>
Show detailed metadata, layers, stats, and integrity hash for a package.
lean-ctx pack info my-pkg lean-ctx pack export <name> [-o <file>]
Export a package to a portable .lctxpkg file. Default output is <name>.lctxpkg.
lean-ctx pack export my-pkg
lean-ctx pack export my-pkg -o shared/my-pkg.lctxpkg lean-ctx pack import <file>
Import a package from a .lctxpkg file. Verifies SHA-256 integrity before installing.
lean-ctx pack import my-pkg.lctxpkg lean-ctx pack install <name>
Merge a package's context into the current project — knowledge facts, graph nodes, and gotchas.
lean-ctx pack install my-pkg lean-ctx pack remove <name>
Remove a package from the local registry.
lean-ctx pack remove my-pkg lean-ctx pack auto-load <name> <on|off>
Enable or disable auto-loading. When enabled, the package is merged into the project
context automatically when ctx_overview runs at session start.
lean-ctx pack auto-load my-pkg on
lean-ctx pack auto-load my-pkg off Instructions
Manually retrieve MCP server instructions. Useful in headless or non-interactive environments where the MCP handshake does not automatically deliver instructions.
lean-ctx instructions [flags] v3.3.x
| Flag | Description |
|---|---|
(none) | Print current MCP instructions to stdout |
--raw | Output raw instruction text without formatting |
--json | Output as JSON object with metadata |
--inject | Inject instructions into the active agent session |
lean-ctx instructions # print formatted instructions
lean-ctx instructions --raw # raw text for piping
lean-ctx instructions --json # JSON with metadata
lean-ctx instructions --inject # inject into running session This is particularly useful when integrating lean-ctx into CI/CD pipelines or custom agent frameworks that don't support the MCP instructions handshake natively.