rtk:基于 Rust 的命令输出过滤压缩工具

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

分支180Tags173
文件最后提交记录最后更新时间
chore(ci): deny warnings and make clippy pass mandatory in ci 25 天前
Update pr-target-check.yml22 天前
chore(claude): migrate skills to dir structure, add command hints - Convert repo-recap, security-guardian, ship skills from flat .md to SKILL.md inside dedicated directories - Remove performance.md (no replacement needed) - Add cross-platform clip() helper in issue-triage and pr-triage skills (supports pbcopy, xclip, wl-copy) - Add argument-hint metadata to worktree command files - Update rust-rtk agent model from pinned ID to "sonnet" alias - Remove hardcoded absolute paths from diagnose.md - Add .rtk/filters.toml project-local filter config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com> 1 个月前
fix: add website URL (rtk-ai.app) across project metadata (#81) - Cargo.toml: add homepage field - README.md: add website/github/install links - Formula/rtk.rb: update homepage to website - release.yml: update homepage and docs link in formula template Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>3 个月前
feat(hermes): add rtk integration Signed-off-by: Kayphoon <109347466+Kayphoon@users.noreply.github.com> 24 天前
feat(hermes): add rtk integration Signed-off-by: Kayphoon <109347466+Kayphoon@users.noreply.github.com> 24 天前
feat: OpenClaw plugin for transparent exec rewriting (#358) * feat: add OpenClaw plugin for transparent exec rewriting Adds an OpenClaw plugin that intercepts exec tool calls via the before_tool_call hook and rewrites commands to their RTK equivalents. This is the OpenClaw equivalent of hooks/rtk-rewrite.sh for Claude Code. The plugin: - Registers a before_tool_call hook on the exec tool - Rewrites git, grep, find, ls, gh, docker, kubectl, and test commands - Guards against rewriting piped/compound commands and heredocs - Returns properly typed PluginHookBeforeToolCallResult - Supports enabled/verbose config options Measured savings: 48-87% token reduction on common commands. Files: - openclaw/index.ts — plugin source - openclaw/openclaw.plugin.json — plugin manifest - openclaw/README.md — installation and usage docs * refactor: delegate OpenClaw plugin to rtk rewrite Replace 60+ hardcoded regex rules with a single call to rtk rewrite, matching the OpenCode plugin pattern (hooks/opencode-rtk.ts). Benefits: - Zero maintenance: new RTK filters work automatically - Single source of truth: rewrite logic in Rust (src/discover/registry.rs) - 122 → 73 lines, no rule duplication Also: rebase on develop, fix homepage URL, bump version to 1.0.0. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> * feat: add package.json for npm publishing Enables openclaw plugins install @rtk-ai/rtk-rewrite for OpenClaw users. Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> --------- Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> Co-authored-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>2 个月前
Merge pull request #1368 from ousamabenyounes/fix/issue-1250 fix(install): reject archive with path traversal before extraction (#1250)22 天前
fix(truncate): global caps reduce (avoid underflow and 0 results) - Avoid underflow + 0 results caused by overwrite of global constant CAPS - Soon user will be able to apply global configuration, this will change global CAPS and should not cause any underflow or 0 results, if overwrite sub >= CAPS -> use CAPS. 14 天前
feat(gradlew): add Gradle/gradlew support with streaming filters Adds rtk gradlew command for build, test, lint, and dependency operations on Gradle projects. Filters task progress noise, preserves build scan URLs, test failures, lint violations, and compiler warnings. Recognises ./gradlew, gradlew, gradlew.bat, and gradle invocations. Surfaces unit-test report paths and shows a progress indicator for long-running tasks. Targets 75% savings (90% on test, 80% on build). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> 30 天前
feat(benchmark): add multipass VM integration test suite Bun/TypeScript orchestrator that creates an Ubuntu 24.04 VM via multipass, installs all dev tools (Rust, Go, Node, Python, .NET, Terraform, etc.), builds RTK, and runs 103 tests across 11 phases: - Cargo quality (fmt, clippy, test) - 47 Rust built-in commands (git, ls, grep, cargo, pytest, go, tsc...) - 21 TOML filter commands (df, ps, shellcheck, hadolint, helm...) - Hook rewrite engine (17 rewrite assertions) - Exit code preservation - Token savings verification (avg 81%) - Pipe compatibility - Edge cases (unicode, ANSI, empty output) - Performance (memory < 20MB) - Concurrency (10 parallel executions) Usage: bun run scripts/benchmark/run.ts # Full suite (~3 min) bun run scripts/benchmark/run.ts --quick # Skip perf/concurrency bun run scripts/benchmark/run.ts --phase 3 # Single phase bun run scripts/benchmark/cleanup.ts # Delete VM bun run scripts/benchmark/rebuild.ts # Fast rebuild Prerequisites: brew install multipass, bun Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> 1 个月前
chore(master): release 0.36.01 个月前
feat(cicd): enforce cicd sast & package check - semgrep for sast check by yml rules - dependabot for package detection - update CICD doc - clippy -D unsafe_code hard fail 1 个月前
fix(init-uninstall): uninstall removes --claude-md artifacts on Windows 30 天前
Merge branch 'develop' into feat/pr-review-skill1 个月前
refacto(truncations): Set global CAPS for truncation Following tee and hint refacto Add global CAP constant to be inherited , to enable easier global configuration later 15 天前
build(deps): bump rustls-webpki from 0.103.9 to 0.103.13 Bumps [rustls-webpki](https://github.com/rustls/webpki) from 0.103.9 to 0.103.13. - [Release notes](https://github.com/rustls/webpki/releases) - [Commits](https://github.com/rustls/webpki/compare/v/0.103.9...v/0.103.13) --- updated-dependencies: - dependency-name: rustls-webpki dependency-version: 0.103.13 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>1 个月前
chore(ci): deny warnings and make clippy pass mandatory in ci 25 天前
fix(docs): clean some docs + disclaimer 2 个月前
Merge pull request #1009 from KuSh/broken-pnpm-i fix(pnpm): install don't take a list of packages1 个月前
Add files via upload2 个月前
docs(readme): fix license references to match LICENSE (Apache-2.0) The README badge and footer claimed MIT, but the LICENSE file is Apache License 2.0. Updates both references so the README matches the authoritative LICENSE file. Closes #1996 Co-Authored-By: Claude <noreply@anthropic.com> 15 天前
feat(js): distinguish between jest and vitest and don't rewrite npm test commands as we don't know which test framework is used under the hood Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com> 1 个月前
feat(js): distinguish between jest and vitest and don't rewrite npm test commands as we don't know which test framework is used under the hood Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com> 1 个月前
feat(js): distinguish between jest and vitest and don't rewrite npm test commands as we don't know which test framework is used under the hood Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com> 1 个月前
feat(js): distinguish between jest and vitest and don't rewrite npm test commands as we don't know which test framework is used under the hood Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com> 1 个月前
feat(js): distinguish between jest and vitest and don't rewrite npm test commands as we don't know which test framework is used under the hood Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com> 1 个月前
fix(security): correct email domain from .dev to .app Fixes #608 — security@rtk-ai.dev was bouncing, preventing vulnerability reports from reaching maintainers. Signed-off-by: Patrick Szymkowiak <patrick@rtk-ai.app> Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu> 1 个月前
fix(build): increase Windows startup stack Signed-off-by: Ахмедов Нурбек Медетбаевич <n.akhmedov@uzdc.uz> 2 个月前
Merge pull request #1368 from ousamabenyounes/fix/issue-1250 fix(install): reject archive with path traversal before extraction (#1250)22 天前
fix: patrick's 3 issues (latest tag, ccusage fallback, versioning) 1. CRITICAL: Fix 'latest' tag creation after releases - Move update-latest-tag job from release.yml to release-please.yml - release-please creates tags via API (no push event) → must run in same workflow - Job now conditional on release_created output 2. IMPORTANT: Add npx fallback for ccusage + improve message - Check binary in PATH first, fallback to 'npx ccusage' - Updated message: "npm i -g ccusage (or use npx ccusage)" - Consistent with other JS tooling (next_cmd, tsc_cmd, prettier_cmd) 3. PROCESS: Slow down version bumps with release-please config - Add release-please-config.json with bump-patch-for-minor-pre-major - In 0.x versions: feat: → patch bump instead of minor - Prevents rapid version inflation (0.3.1 → 0.5.0 in 21h) Fixes issues raised by Patrick after PR #21 merge. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> 4 个月前

RTK - Rust Token Killer

高性能 CLI 代理,将 LLM token 消耗降低 60-90%

CI Release License: MIT Discord Homebrew

官网安装故障排除架构Discord

EnglishFrancais中文日本語한국어Espanol


rtk 在命令输出到达 LLM 上下文之前进行过滤和压缩。单一 Rust 二进制文件,零依赖,<10ms 开销。

Token 节省(30 分钟 Claude Code 会话)

操作 频率 标准 rtk 节省
ls / tree 10x 2,000 400 -80%
cat / read 20x 40,000 12,000 -70%
grep / rg 8x 16,000 3,200 -80%
git status 10x 3,000 600 -80%
git diff 5x 10,000 2,500 -75%
cargo test / npm test 5x 25,000 2,500 -90%
总计 ~118,000 ~23,900 -80%

安装

Homebrew(推荐)

brew install rtk

快速安装(Linux/macOS)

curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh

Cargo

cargo install --git https://github.com/rtk-ai/rtk

验证

rtk --version   # 应显示 "rtk 0.27.x"
rtk gain        # 应显示 token 节省统计

快速开始

# 1. 为 Claude Code 安装 hook(推荐)
rtk init --global

# 2. 重启 Claude Code,然后测试
git status  # 自动重写为 rtk git status

工作原理

  没有 rtk:                                      使用 rtk:

  Claude  --git status-->  shell  -->  git         Claude  --git status-->  RTK  -->  git
    ^                                   |            ^                      |          |
    |        ~2,000 tokens(原始)       |            |   ~200 tokens        | 过滤     |
    +-----------------------------------+            +------- (已过滤)-----+----------+

四种策略:

  1. 智能过滤 - 去除噪音(注释、空白、样板代码)
  2. 分组 - 聚合相似项(按目录分文件,按类型分错误)
  3. 截断 - 保留相关上下文,删除冗余
  4. 去重 - 合并重复日志行并计数

命令

文件

rtk ls .                        # 优化的目录树
rtk read file.rs                # 智能文件读取
rtk find "*.rs" .               # 紧凑的查找结果
rtk grep "pattern" .            # 按文件分组的搜索结果

Git

rtk git status                  # 紧凑状态
rtk git log -n 10               # 单行提交
rtk git diff                    # 精简 diff
rtk git push                    # -> "ok main"

测试

rtk jest                        # Jest 紧凑输出
rtk vitest                      # Vitest 紧凑输出
rtk pytest                      # Python 测试(-90%)
rtk go test                     # Go 测试(-90%)
rtk test <cmd>                  # 仅显示失败(-90%)

构建 & 检查

rtk lint                        # ESLint 按规则分组
rtk tsc                         # TypeScript 错误分组
rtk cargo build                 # Cargo 构建(-80%)
rtk ruff check                  # Python lint(-80%)

容器

rtk docker ps                   # 紧凑容器列表
rtk docker logs <container>     # 去重日志
rtk kubectl pods                # 紧凑 Pod 列表

分析

rtk gain                        # 节省统计
rtk gain --graph                # ASCII 图表(30 天)
rtk discover                    # 发现遗漏的节省机会

文档

贡献

欢迎贡献!请在 GitHub 上提交 issue 或 PR。

加入 Discord 社区。

许可证

MIT 许可证 - 详见 LICENSE

免责声明

详见 DISCLAIMER.md

项目介绍

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

定制我的领域

下载使用量

0

项目总下载次数(含Clone、Pull、 zip 包及 release 下载),每日凌晨更新

语言类型

Rust92.3%
Shell5.25%
TypeScript1.53%
Python0.87%
Ruby0.05%