DeepSeek Harness plugin

dsh-rtk-optimizer

RTK command rewriting suggestions + tool output compaction for DSH. Suggests rtk-rewritten bash commands (deny-mode under rewrite) and compacts noisy tool output (bash/grep/read) to reduce context

Jump to install

Source facts

Repository
sleepinginsummer/dsh-rtk-optimizer
Latest update
Aug 14, 2026
Category
Tools & Capabilities
GitHub stars
2
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/sleepinginsummer/dsh-rtk-optimizer
Plugin: dsh-rtk-optimizer
Author: sleepinginsummer

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer2 files
README.mdSource · read only

dsh-rtk-optimizer

![npm version](https://www.npmjs.com/package/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)、enabledguardWhenRtkMissingreadCompaction | | 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 压缩、搜索分组、测试聚合、构建过滤、截断、总管线、静态求值

参考