← 返回
未分类 中文

Leanctx Integration

Automatically compresses OpenClaw tool outputs to reduce token usage by 60-99%
自动压缩 OpenClaw 工具输出,减少 60‑99% 的 token 使用
jackkeller jackkeller 来源
未分类 clawhub v0.1.4 1 版本 100000 Key: 无需
★ 2
Stars
📥 439
下载
💾 0
安装
1
版本
#latest

概述

LeanContext Integration

LeanContext integration for OpenClaw that automatically compresses tool outputs to reduce token usage by 60-99%.

External Endpoints

EndpointData SentPurpose
------------------------------
NoneN/AThis skill operates entirely locally

No external API calls are made. All processing happens on your local machine.

Security & Privacy

  • Local-only operation: All compression and caching happens locally
  • No data leaves your machine: No files, commands, or content is sent to external services
  • Cache location: Stored in memory (optional filesystem cache can be configured)
  • No telemetry: No usage data, metrics, or analytics are transmitted

Model Invocation

This skill operates autonomously during OpenClaw's normal operation. It intercepts read and exec tool calls transparently without requiring explicit user approval for each invocation. This is standard behavior for OpenClaw skills.

To disable automatic invocation, set enabled: false in your OpenClaw config.

Trust Statement

By using this skill, your file contents and command outputs are processed locally for compression purposes. No data is sent to external services. Only install if you are comfortable with this local processing.

What it does

Intercepts OpenClaw's read and exec tool calls and applies intelligent compression:

  • File reads: AST-aware compression removes comments, whitespace, collapses function bodies
  • Shell exec: Pattern-matching compresses common commands (git, npm, docker, etc.)
  • Session caching: Re-reads cost ~13 tokens instead of thousands

Installation

openclaw skills install leanctx-integration

Or manually:

cd ~/.openclaw/workspace/skills
git clone https://github.com/your-repo/leanctx-integration.git
cd leanctx-integration
npm install
npm run build

Configuration

Add to your openclaw.json:

{
  "skills": {
    "leanctx-integration": {
      "enabled": true,
      "config": {
        "threshold": 100,
        "cacheEnabled": true,
        "excludedPaths": ["node_modules", ".git", "dist"],
        "excludedCommands": ["cat", "echo"]
      }
    }
  }
}

Usage

Once installed, LeanContext works automatically - no code changes required!

Check Metrics

Note: Metrics tracking has been temporarily disabled. The skill automatically compresses tool outputs, but session-level metrics reporting is not currently available. This feature may be revisited in a future update.

Clear Cache

Via your agent:

Ask: "Clear the LeanCTX cache"

Direct CLI:

npx leanctx clear-cache

Compression Examples

TypeScript File (800 lines)

Before: ~2000 tokens

After: ~50 tokens

Savings: 97.5%

Git Log

Before: ~500 tokens (full commit info)

After: ~30 tokens (hashes + messages)

Savings: 94%

NPM Install

Before: ~200 tokens (all download messages)

After: ~10 tokens (summary only)

Savings: 95%

Supported Languages

  • TypeScript / JavaScript
  • Python
  • Svelte
  • Go
  • Rust
  • Java / Kotlin
  • Generic (fallback)

Supported Commands

  • git log → Commit hashes + first line
  • git status → Changed files only
  • git diff → Diff markers + changes
  • npm install → Package count
  • npm test → Test results + summary
  • cargo build → Errors only
  • docker ps → Header + first 10 rows
  • kubectl → Header + first 15 rows

Performance

  • Cache hit: <5ms overhead
  • First read: ~10ms (AST parse)
  • Compression: 60-99% token reduction

Troubleshooting

Not working?

  1. Check if skill is enabled in config
  2. Verify threshold isn't too high
  3. Check excluded paths aren't matching

Want to disable for specific files?

Add to excludedPaths in config:

{
  "excludedPaths": ["node_modules", ".git", "**/*.spec.ts"]
}

Cache too large?

Ask your agent: "Clear the LeanCTX cache"

Or via CLI:

npx leanctx clear-cache

How it works

  1. OpenClaw makes a tool call (read or exec)
  2. LeanContext intercepts the call
  3. Checks cache (instant return if hit)
  4. Compresses based on file type or command pattern
  5. Caches result
  6. Returns compressed output to OpenClaw
  7. Metrics updated

License

MIT

版本历史

共 1 个版本

  • v0.1.4 当前
    2026-05-03 08:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 875 📥 351,320
ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,451 📥 329,714
ai-agent

Find Skills

root
帮助用户发现和安装智能体技能,当用户询问如「如何做X」、「找X的技能」、「有能做...的吗」等问题时
★ 1,530 📥 583,536