sleepinginsummer/dsh-rtk-optimizer
Project Overview项目介绍
This is a native DSH plugin built exclusively for DeepSeek Harness, ported from the pi-rtk-optimizer project from the Pi Coding Agent ecosystem. It works as a host interceptor that adds two key features: RTK command rewrite suggestions and tool output compaction for existing tool calls. To install the plugin, run the command dsh plugin --profile <name> add dsh-rtk-optimizer in your terminal, then restart DSH to activate it across all your sessions. It does not register new model tools, instead it hooks into existing tool events to work globally for all bash, grep, and read calls.
When an LLM calls a bash command, the plugin checks if you have the RTK binary installed locally on your machine. By default, it runs in suggest mode, which does not interrupt the original command and only appends the RTK rewrite suggestion to the end of the output. You can switch to rewrite mode via the /rtk command, which will deny the original call, return the rewritten command in the error feedback, and let the model retry with the improved command. The output compaction feature processes successful outputs from bash, grep, and read calls with a configurable pipeline to reduce redundant text.
The output compaction pipeline includes multiple steps: stripping ANSI color codes, compressing Git output, aggregating test results, filtering build logs, grouping grep search results, and truncating overly long output. The plugin tracks the number of characters saved by compaction across all calls, which you can view with the /rtk stats command. If RTK is not installed on your local machine, the plugin leaves all original commands unchanged and caches the detection result for 60 seconds to avoid repeated checks. Development of the plugin includes 20 test cases covering all core compaction and functionality features.
本项目是专为DeepSeek Harness(DSH)开发的原生插件,作为宿主拦截器工作,移植自Pi Coding Agent生态的pi-rtk-optimizer,核心提供RTK命令改写建议与工具输出压缩两大功能。插件不注册新模型工具,而是挂载到两个工具事件上,对所有会话的bash、grep、read调用全局生效,同时提供/rtk命令供用户查看运行状态与配置。
当模型调用bash命令时,如果用户本地已经安装RTK二进制工具,插件可在两种模式下工作:默认是suggest模式,不打断原命令执行,仅在输出结果末尾附上RTK给出的改写建议;手动开启rewrite模式后会拦截原调用,返回改写后的命令让模型重试。输出压缩功能可对bash、grep、read调用的成功输出按规则压缩,减少不必要的冗余内容。
本插件可通过dsh plugin命令一键安装,安装后重启DSH即可全局生效。它支持ANSI码剥离、Git输出压缩、测试结果聚合、构建日志过滤、搜索结果分组、超长输出智能截断等多个压缩步骤,还能统计每次压缩节省的字符总数。插件依赖本地安装RTK二进制工具,若未安装则原命令正常执行,不会中断现有工作流。
请帮我安装这个 DSH 插件。安装前先完成【兼容性检查 + 安全性检查】,检查通过再动手。
插件:dsh-rtk-optimizer(sleepinginsummer/dsh-rtk-optimizer)
仓库:https://github.com/sleepinginsummer/dsh-rtk-optimizer
本站详情页:https://www.yhbd.top/plugins/sleepinginsummer-dsh-rtk-optimizer/
本站登记:类型 plugin · 归类 原生 DSH 插件 · 许可证未声明 · ⭐ 2 · 最近提交 2026-08-14 · 主语言 JavaScript
按下面顺序执行,每步先把结论告诉我,再进入下一步:
【1 兼容性检查】
① 我这边:DSH 版本、Node 版本、操作系统、当前 profile(web / desktop)。
② 读它的 README、package.json、插件 manifest,列出它要求的 DSH 版本 / Node 版本 / 操作系统 / 外部依赖 / 需要另外先装的运行时。
③ 逐条比对,结论只写「满足 / 不满足 / 未知」三种;不满足的给出可行替代方案。
④ 检查是否和我已装的插件冲突:命令名重复、skill / tool 重名、端口占用、重复注册的 MCP server。
【2 安全性检查】
① 仓库可信度:和上面「本站登记」是否一致;star / fork 数、创建时间、最近提交,是否归档或长期停更。
② 安装脚本:逐行看 package.json 的 preinstall / install / postinstall,以及 install.sh、setup.ps1 之类脚本。出现 curl|bash、下载后直接执行、混淆代码、访问与插件功能无关的域名,立刻停下来告诉我,不要继续装。
③ 依赖:列出新增依赖,标出无人维护、或与知名包拼写近似的可疑包(typosquatting)。
④ 权限与副作用:它会读写哪些目录、访问哪些域名、需要哪些 DSH 权限(filesystem / network / shell / clipboard 等),以及怎么卸载和回滚。
⑤ 如果它要求 sudo / 管理员权限,或权限明显超出功能所需,先停下来问我。
【3 安装】
上面两步没有「不满足」和「高危项」时才执行;用官方推荐方式安装,不要自行提权。
【4 汇报】
用表格输出:检查项 / 结论 / 依据 / 是否需要我决策。拿不准的一律写「未知」并说明要我怎么确认——不要猜,也不要替我决定。
Send this message to DSH in your current session: it verifies compatibility and security first (answering met / not met / unknown item by item) and only installs once everything checks out — it will stop and ask you if it finds a high-risk item. The box scrolls; the copy is the full prompt. CLI install commands may not be accurate across systems, so DSH is the safer route.把上面这条消息直接发给当前会话里的 DSH:它会先核对兼容性与安全性(逐条给「满足 / 不满足 / 未知」),确认没问题再安装,有高危项会停下来问你。框内可滚动,复制到的是完整提示词;安装命令不一定准确,发给 DSH 更稳。
- No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
- Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项
Compatibility兼容性
- DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
- External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
- Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册
Security安全性
- Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
- Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
- curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
- Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
- Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
- Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式
Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add dsh-rtk-optimizer
把 sleepinginsummer/dsh-rtk-optimizer 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-rtk-optimizer
RTK 命令改写建议 + 工具输出压缩——DSH 插件(Host 拦截器),移植自 Pi Coding Agent 生态的 pi-rtk-optimizer。
不注册模型工具:它挂在两个工具事件上,全局生效(对所有会话的 bash/grep/read 调用),并提供 /rtk 命令查看状态。
功能
1. RTK 命令改写(tools/pre-execute)
模型调用 bash 时,若本机装有 rtk 二进制(rtk rewrite <command>),插件:
mode: rewrite(默认关闭,需 /rtk 切换)——deny 一次该调用,并在错误反馈中给出改写后的命令;模型重试时用新命令(rtk 幂等,不会循环;同一命令 30s 内只 deny 一次)。mode: suggest(默认)——不打断调用,在结果末尾附注[rtk-optimizer] rtk suggests: ...。
DSH 工具参数在分发管道中不可变(
tools/execute只能改exec.signal),所以"自动改写"以 deny+反馈的形式实现——这是架构允许下最接近自动改写的语义。rtk未安装时:原命令原样执行(guardWhenRtkMissing: true),探测结果缓存 60s,不重复 probe。
2. 输出压缩(tools/post-execute)
对成功返回的 bash/grep/read 文本输出按配置走压缩管线(可单独开关):
| 阶段 | 说明 |
|---|---|
| ANSI 剥离 | 移除 CSI/OSC 颜色控制序列 |
| Git 压缩 | git status --short 行汇总为一行统计;40 位 commit hash 缩短为 7 位 |
| 测试聚合 | 保留 Tests: N passed, M failed 总结与失败行,折叠其余(jest/mocha/vitest/go test/pytest 命令触发) |
| 构建过滤 | 只保留 error/warning 行 + 汇总统计(build/tsc/make/npm 等命令触发) |
| 搜索分组 | path:line:content 行按文件分组(grep 工具输出) |
| 智能截断 | 超 maxOutputChars(默认 30000)时保留头 + 尾,中间打截断标记 |
统计每个调用的节省字符数,/rtk stats 可查。
3. /rtk 命令
/rtk [show|verify|stats|clear-stats|reset|set|help]——配置与运行状态、rtk 二进制探测、压缩节省量统计。
| 子命令 | 说明 |
|---|---|
show |
当前配置 + rtk 二进制状态 + 统计 |
verify |
检查 rtk 二进制是否可用(探测结果缓存 60s) |
stats / clear-stats |
查看 / 重置压缩节省量统计 |
set <key> <value> |
运行时切换:mode(suggest|rewrite)、enabled、guardWhenRtkMissing、readCompaction |
reset |
恢复默认配置 |
实现适配:rtk 0.43 对成功改写返回退出码 3(非文档所述 0),插件同时接受 0 与 3;不支持的命令退出 1 且无输出,命令原样放行。
安装
dsh plugin --profile <name> add dsh-rtk-optimizer
安装后重启 DSH,压缩与改写对全部会话的 bash/grep/read 调用生效(/rtk 命令可查状态与统计)。
开发
npm test # 20 用例:ANSI、git 压缩、搜索分组、测试聚合、构建过滤、截断、总管线、静态求值
titanwings/distilly
YuJunZhiXue/dsh-purge
Clearailhc/clearai-dsh
yejiming/MuseAI
superdesigndev/superdesign-skill
Miaotofu01/Study-Mate