← 返回
开发者工具 中文

Oktk

LLM Token Optimizer - Reduce AI API costs by 60-90%. Compresses CLI outputs (git, docker, kubectl) before sending to GPT-4/Claude. AI auto-learning included. By Buba Draugelis 🇱🇹
LLM Token 优化器 - 降低 60-90% AI API 成本。在发送给 GPT-4/Claude 前压缩 CLI 输出(git、docker、kubectl)。含 AI 自动学习功能。作者:Buba Draugelis 🇱🇹
satnamra satnamra 来源
开发者工具 clawhub v2.4.0 1 版本 99879.5 Key: 无需
★ 0
Stars
📥 1,658
下载
💾 24
安装
1
版本
#latest

概述

oktk - CLI Output Compressor for LLMs

The Problem

When you run commands through an AI assistant, the full output goes into the LLM context:

$ git status
# Returns 60+ lines, ~800 tokens
# Your AI reads ALL of it, you pay for ALL of it

Every token costs money. Verbose outputs waste your context window.

The Solution

oktk sits between your commands and the LLM, compressing outputs intelligently:

┌──────────┐     ┌──────────┐     ┌──────────┐
│ Command  │ ──► │   oktk   │ ──► │   LLM    │
│ (800 tk) │     │ compress │     │ (80 tk)  │
└──────────┘     └──────────┘     └──────────┘
                      │
                 90% SAVED

When Does It Work?

Automatically when you run supported commands through OpenClaw:

CommandWhat oktk doesSavings
-------------------------:-------:
git statusShows only: branch, ahead/behind, file counts90%
git logOne line per commit: hash + message + author85%
git diffSummary: X files, +Y/-Z lines, file list80%
npm testJust: ✅ passed or ❌ failed + count98%
ls -laGroups by type, shows sizes, skips details83%
curlStatus code + key headers + truncated body97%
grepMatch count + first N matches80%
docker psContainer list: name, image, status85%
docker logsLast N lines + error count90%
kubectl get podsPod status summary with counts85%
kubectl logsLast N lines + error/warning counts90%
Any commandAI learns patterns automatically (optional)~70%

Concrete Example

Before oktk (800 tokens sent to LLM):

On branch main
Your branch is ahead of 'origin/main' by 3 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   src/components/Button.jsx
        modified:   src/components/Header.jsx
        modified:   src/utils/format.js
        modified:   src/utils/validate.js
        modified:   package.json
        modified:   package-lock.json

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        src/components/Footer.jsx
        src/components/Sidebar.jsx
        tests/Button.test.js

no changes added to commit (use "git add" and/or "git commit -a")

After oktk (80 tokens sent to LLM):

📍 main
↑ Ahead 3 commits
✏️  Modified: 6
❓ Untracked: 3

Same information. 90% fewer tokens. Same cost savings.

How It Works Technically

  1. Intercepts command output after execution
  2. Detects command type (git? npm? ls?)
  3. Applies specialized filter for that command
  4. Extracts only essential information
  5. Caches results (same command = instant, no reprocessing)

Safety First

oktk never breaks your workflow:

Try specialized filter
    ↓ fails?
Try basic filter  
    ↓ fails?
Return raw output (same as without oktk)

Worst case: You get normal output

Best case: 90% token savings

Usage

Global Command (Recommended)

After installation, oktk is available globally:

# Pipe any command through oktk
git status | oktk git status
docker ps | oktk docker ps
kubectl get pods | oktk kubectl get pods

# See your total savings
oktk --stats

# Bypass filter (get raw)
oktk --raw git status

Shell Aliases (Auto-Filter)

Source the aliases file for automatic filtering:

# Add to ~/.zshrc or ~/.bashrc
source ~/.openclaw/workspace/skills/oktk/scripts/oktk-aliases.sh

Then use short aliases:

gst        # git status (filtered)
glog       # git log (filtered)
dps        # docker ps (filtered)
kpods      # kubectl get pods (filtered)

# Universal wrapper - filter ANY command
ok git status
ok docker ps -a
ok kubectl describe pod my-pod

OpenClaw Integration

When using OpenClaw's exec tool, pipe outputs through oktk:

# In your prompts, ask OpenClaw to:
git status | oktk git status
docker logs container | oktk docker logs

# Or use the 'ok' wrapper (if aliases sourced):
ok git diff HEAD~5

Note: OpenClaw doesn't have a built-in exec output transformer yet.

The recommended approach is:

  1. Source the aliases file in your shell
  2. Use ok wrapper for any command
  3. Or manually pipe: | oktk

Real Savings Example

After 1 week of normal usage:

📊 Token Savings
━━━━━━━━━━━━━━━━
Commands filtered: 1,247
Tokens saved:      456,789 (78%)

💰 At $0.01/1K tokens = $4.57 saved

Installation

Already included in OpenClaw workspace, or:

clawhub install oktk

Made with ❤️ in Lithuania 🇱🇹

版本历史

共 1 个版本

  • v2.4.0 当前
    2026-03-29 00:36 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Self-Improving + Proactive Agent

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

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,082 📥 812,430
ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,228 📥 268,040