opencode-rtk-optimizerOpenCode plugin for RTK, reduces LLM token consumption by 60-90% on dev commands
0
39
近 7 天 7
28.3
生态多维模型
1 个月前
2026-07-16
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-rtk-optimizer@0.1.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-rtk-optimizer@0.1.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-rtk-optimizeropencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
[!NOTE] This fork exists because openrtk appears inactive, with no updates for roughly four months. The npm package will be removed if changes are accepted upstream.
OpenCode plugin for RTK (Rust Token Killer). Reduces LLM token consumption by 60-90% on common dev commands by transparently routing them through RTK's output compression.
A lightweight OpenCode plugin that intercepts shell commands and routes them through RTK for automatic output compression. The model retains the original command in its history while receiving RTK's optimized output.
Prerequisites
Install RTK:
cargo install rtk
Installation
Install via npm:
npm install opencode-rtk-optimizer
Then add to your OpenCode config (opencode.json or .opencode/config.json):
{
"plugin": ["opencode-rtk-optimizer"]
}
Or copy src/index.ts directly into .opencode/plugins/ for local use.
How it works
The plugin hooks into OpenCode's tool execution events and delegates shell command rewrites to rtk rewrite. The rewritten command executes while the original command remains visible to the model.
git status -> rtk git status (72% savings)
cargo test -> rtk cargo test (80% savings)
docker ps -> rtk docker ps (65% savings)
Supported commands are determined by the installed RTK version. Common rewrites include:
Supported commands
| Category | Commands |
|---|---|
| Git | status, diff, log, add, commit, push, pull, branch, fetch, stash, show |
| GitHub CLI | pr, issue, run, api, release |
| Rust | cargo test/build/clippy/check/install/fmt |
| File ops | cat, grep, rg, ls, tree, find, diff |
| JS/TS | vitest, npm test/run, tsc, eslint, prettier, playwright, prisma |
| Containers | docker (compose/ps/images/logs/run/build/exec), kubectl (get/logs/describe/apply) |
| Network | curl, wget |
| Python | pytest, ruff, pip, uv pip |
| Go | go test/build/vet, golangci-lint |
| Packages | pnpm list/ls/outdated |
Development
npm run build # build the plugin
npm test # run tests
License
MIT