最近推送 2026-10-27 00:41(2 天前),属于活跃维护
rtk-ai/rtk
GITHUB中文整理主语言 Rust · 84,858 星 · Apache-2.0 · 创建于 2026-01-23
一个用 Rust 编写的命令行代理工具,在 AI 编程 agent 读取 shell 命令输出前进行拦截与压缩,从而减少传给大模型的 token 数量。
仓库健康度
5 个维度开放 Issue 1,599 个 · Fork 5,397 个
star 记录还不够天数,增量算不出来
许可证 Apache-2.0 · 8 个 topics · 开了 Wiki
这一项暂无数据,不代表项目没有发布
「证据不足」表示这项数据暂时没有取到,不能读成「项目有问题」;「部分数据」表示只拿到一部分信号。版本发布要额外调 Releases 接口,下一版补。
Star 趋势
6 天记录横轴 2026-10-23 → 2026-10-28,纵轴按这段时间的最小/最大值拉伸。趋势来自站内每天记录一次的星数,页面打开时不会实时请求 GitHub。
它解决什么问题
据 README 归纳AI 编程 agent 执行 ls、git、grep 等命令时,原始输出往往冗长且充满噪声,直接进入模型上下文会浪费大量 token,增加成本并挤占有效上下文。没有它,agent 需要处理未经过滤的完整输出,既慢又贵。
核心能力
6 条- 1拦截 shell 命令输出,在送入 agent 前完成压缩
- 2过滤注释、空白与样板文本等噪声内容
- 3按目录或错误类型聚合相似条目
- 4截断冗余长行,保留关键上下文
- 5对重复日志行计数并合并
- 6提供初始化命令适配多种 AI 编程工具
项目画像
6 个角度项目定位
一个用 Rust 编写的命令行代理工具,在 AI 编程 agent 读取 shell 命令输出前进行拦截与压缩,从而减少传给大模型的 token 数量。
适合谁
使用 Claude Code、Copilot、Gemini CLI、Codex、Cursor 等 AI 编程工具的开发者,尤其是关注 token 消耗与上下文效率的团队。
典型场景
让 AI agent 执行文件列表、代码搜索和 git 操作时,自动获得压缩后的紧凑输出,节省上下文空间。;运行测试或代码检查命令时,只把失败项和汇总数量交给 agent,避免成功用例刷屏。;在 Cursor、Windsurf 等工具中初始化后,日常编码会话中的 shell 输出自动被精简。
部署难度
需通过 Homebrew、winget 或安装脚本获取对应版本,再用 rtk init 按所用 AI 工具初始化;无额外依赖,步骤较少。
风险限制
hook 仅对 Bash 工具调用生效,内置 Read、Grep、Glob 等工具不经过它;完整版与开源版安装同名的 rtk 二进制,不能同时安装;crates.io 上存在同名项目需注意区分。
最近维护
最近一次推送是 2026-10-27 00:41。 实现方式:通过 hook 机制在 agent 调用 Bash 工具时介入,对命令输出执行过滤、分组、截断和去重,再以紧凑格式交给模型;内置的 Read、Grep 等工具不经过该流程。
README 原文细节
3 个板块怎么安装从零跑起来的步骤
Installation
Then check you have the right package — another project named "rtk" exists on crates.io:
brew install rtk # macOS / Linux
winget install rtk-ai.rtk # Windows
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
What You Install
RTK ships as three downloads. The two rtk editions install a binary with the same name — hooks, scripts and agent config work unchanged across both — so they cannot be installed together. Uninstall one before installing the other.
Production use is free, engine and daemon included. What the BUSL grant does not cover is offering RTK or a derivative to third parties as a commercial product or service — for that, contact [email protected].
- rtk- — Apache-2.0 + BUSL-1.1 — Hook core, every command filter, and the compression engine
- rtk-oss- — Apache-2.0 only — Hook core and every command filter. No engine.
- rtk-proxy- — BUSL-1.1 — The RTK Proxy daemon. Never bundled with either rtk.
flowchart TD
agent["Your coding agent"]
subgraph editions["Pick one · both install a binary named rtk"]
direction LR
full["<b>rtk</b><br/>Apache-2.0 + BUSL-1.1<br/>hooks · filters · engine"]
oss["<b>rtk-oss</b><br/>Apache-2.0 only<br/>hooks · filters"]
end
proxy["<b>rtk-proxy</b><br/>BUSL-1.1<br/>compresses API traffic"]
agent -->|"command output"| full
agent -->|"command output"| oss
agent -.->|"API traffic"| proxy
classDef apache stro
Quick Start
The agent receives compact output without ever calling rtk explicitly.
The hook only fires on Bash tool calls. Built-in tools like Read, Grep and Glob do not pass through it. Use shell commands (cat, rg, find) or call rtk read, rtk grep, rtk find directly.
# 1. Install for your AI tool
rtk init -g # Claude Code / Copilot (default)
rtk init -g --gemini # Gemini CLI
rtk init -g --codex # Codex (OpenAI)
rtk init -g --agent cursor # Cursor
rtk init -g --agent windsurf # Windsurf
rtk init --agent cline # Cline / Roo Code
rtk init --agent kilocode # Kilo Code
rtk init --agent antigravity # Google Antigravity
rtk init --agent kimi # Kimi AI
rtk init -g --agent pi # Pi
实现原理它内部是怎么做的
How It Works
- Smart Filtering - Removes noise (comments, whitespace, boilerplate)
- Grouping - Aggregates similar items (files by directory, errors by type)
- Truncation - Keeps relevant context, cuts redundancy
- Deduplication - Collapses repeated log lines with counts
其它说明README 里剩下的内容
What RTK Does
RTK intercepts shell commands and compresses their output before your agent reads it.
- ls / tree — Tree format with file counts instead of one line per entry
- cat / read — Smart file reading: signatures and structure over full bodies
- grep / rg — Truncates long lines, groups matches by file
- ast-grep — Groups structural matches by file, caps overflow
- git status — Compact stat format, grouped by state
- git diff — Reduced context, headers stripped
- git log — Hash, author and subject only
- git add/commit/push — Confirmation line instead of full progress output
- cargo test / npm test — Failures only, passing tests collapsed to a count
- ruff check — Grouped by rule and file
- sqlfluff lint — Grouped by rule and file
- pytest — Failures only, traceback trimmed
- go test — NDJSON parsed, failures only
- docker ps — Essential fields only
Supported AI Tools
RTK supports 18 AI coding tools. Each integration rewrites shell commands to rtk equivalents, reducing the bash output the agent reads where the agent supports command interception.
For per-agent setup details, override controls, and graceful degradation, see the Supported Agents guide. The Hermes plugin source and tests live in hooks/hermes/; installed Hermes runtime files still live under ~/.hermes/plugins/rtk-rewrite/.
- Claude Code — rtk init -g — PreToolUse hook (native binary)
- GitHub Copilot (VS Code) — rtk init -g --copilot — PreToolUse hook — transparent rewrite
- GitHub Copilot CLI — rtk init -g --copilot — PreToolUse deny-with-suggestion (CLI limitation)
- Cursor — rtk init -g --agent cursor — preToolUse hook (hooks.json)
- Gemini CLI — rtk init -g --gemini — BeforeTool hook
- Codex — rtk init -g --codex — PreToolUse hook (updatedInput) + AGENTS.md
- Windsurf — rtk init -g --agent windsurf — .windsurfrules (project-scoped)
- Cline / Roo Code — rtk init --agent cline — .clinerules (project-scoped)
- OpenCode — rtk init -g --opencode — Plugin TS (execute.before / tool.execute.before), needs 1.18.29 or newer
- OpenClaw — openclaw plugins install ./openclaw — Plugin TS (beforetoolcall)
- Pi — rtk init -g --agent pi (global) — TypeScript extension (toolcall)
- Oh My Pi (OMP) — rtk init -g --agent omp (global) / rtk init --agent omp (project) — TypeScript extension (toolcall, shared with Pi)
- Hermes — rtk init --agent hermes — Python plugin adapter (terminal command mutation via rtk rewrite)
- Mistral Vibe — rtk init -g --agent vibe — pretool hook (hooks.toml)
概述
Agent-agnostic token optimization: compress, route, filter, and more. One composable pipeline across everything your AI agent reads and sends — built on RTK's battle-tested bash-output compression (up to 90% smaller).
Website • Install • Troubleshooting • Architecture • Discord
English • Francais • 中文 • 日本語 • 한국어 • Espanol • Português
rtk filters and compresses command outputs before they reach your LLM context. Single Rust binary, 100+ supported commands, <10ms overhead.
关于 rtk 的常见问题
7 个问题rtk 是做什么的?
一个用 Rust 编写的命令行代理工具,在 AI 编程 agent 读取 shell 命令输出前进行拦截与压缩,从而减少传给大模型的 token 数量。 AI 编程 agent 执行 ls、git、grep 等命令时,原始输出往往冗长且充满噪声,直接进入模型上下文会浪费大量 token,增加成本并挤占有效上下文。没有它,agent 需要处理未经过滤的完整输出,既慢又贵。
rtk 有哪些功能?
核心能力:拦截 shell 命令输出,在送入 agent 前完成压缩;过滤注释、空白与样板文本等噪声内容;按目录或错误类型聚合相似条目;截断冗余长行,保留关键上下文;对重复日志行计数并合并;提供初始化命令适配多种 AI 编程工具。
rtk 适合谁用?
使用 Claude Code、Copilot、Gemini CLI、Codex、Cursor 等 AI 编程工具的开发者,尤其是关注 token 消耗与上下文效率的团队。
rtk 是怎么工作的?
通过 hook 机制在 agent 调用 Bash 工具时介入,对命令输出执行过滤、分组、截断和去重,再以紧凑格式交给模型;内置的 Read、Grep 等工具不经过该流程。
怎么安装 rtk?
按项目 README 的说明:Then check you have the right package — another project named "rtk" exists on crates.io:;rtk- — Apache-2.0 + BUSL-1.1 — Hook core, every command filter, and the compression engine;rtk-oss- — Apache-2.0 only — Hook core and every command filter. No engine.;rtk-proxy- — BUSL-1.1 — The RTK Proxy daemon. Never bundled with either rtk.。完整命令见下方「怎么安装」一节或 GitHub 仓库的 README。
用 rtk 有什么门槛或限制?
hook 仅对 Bash 工具调用生效,内置 Read、Grep、Glob 等工具不经过它;完整版与开源版安装同名的 rtk 二进制,不能同时安装;crates.io 上存在同名项目需注意区分。
rtk 现在还在维护吗?数据怎么样?
目前 84,858 星,5,397 个 Fork,主语言 Rust,创建于 2026-01-23,最近一次推送 2026-10-27 00:41,许可证 Apache-2.0。星数、Fork、推送时间都是 GitHub 返回的实时数据,「最近推送」离现在越近说明越活跃;长期不动要留意是否已停止维护。
这些内容来自哪
读法说明项目数据取自 GitHub 官方接口与项目 README;星数、Fork、语言与时间以 GitHub 页面为准,档案更新于 2026-10-23 17:51。
