在 DeepSeek Harness (DSH) 的开发流程中,Agent 执行 Shell 命令产生的输出往往包含大量冗余信息,这会增加 Token 消耗并占用上下文。dsh-rtk 是一个社区维护的 DSH 插件,它利用本地的 RTK 工具在命令输出进入模型上下文之前进行压缩重写。
Plugin Purpose and Core Functionality¶
dsh-rtk is a community project maintained by robbin810130 (not an official DeepSeek AI project). Its core role is to route shell commands through the locally installed RTK at startup, allowing RTK to rewrite and compress the output content.
The plugin has the following core capabilities:
* Command Rewriting and Compression: Hand shell commands to RTK for processing and compress the output before it enters the context.
* Multi-Platform Support: Supports macOS (arm64/x64), Linux (x64/arm64), and Windows (x64).
* Multi-Shell Support: Supports POSIX (bash) and PowerShell (pwsh).
* In-Session Self-Check: Provides commands such as /rtk, /rtk recheck, /rtk doctor, and /rtk gain, allowing status checks or token savings statistics without exiting.
* Configuration and Control: Supports configuration items such as autoDiscover, bin, timeoutMs, verbose, and statusFile, as well as environment variable controls such as RTK_BIN and DSH_RTK_DISABLE.
Installation and Activation¶
Before installing this plugin, you must first ensure that the RTK binary is locally installed; the plugin does not include the RTK binary itself.
1. Install the RTK Binary¶
Choose the installation method according to your system. For example, on macOS or Linux:
brew install rtk
rtk --version
2. Install the DSH Plugin¶
Use the official DSH command to add the plugin to the currently used profile (for example, the desktop version typically uses desktop):
dsh plugin --profile desktop add github:robbin810130/dsh-rtk#v1.5.0
3. Restart DSH¶
After installation, you must completely quit and reopen DSH for the plugin configuration to be loaded.
4. Verify Activation¶
Enter the following command in any session to check the status:
/rtk
If you see “Status: Active”, you can confirm that the plugin is working properly.
Configuration and Usage¶
In-Session Commands¶
The plugin provides a set of in-session commands for self-checking and viewing statistics:
* Check Current Status: /rtk or /rtk status
* Discard Cache and Probe Again: /rtk recheck (use when RTK has just been installed and you do not want to restart DSH)
* Run a Full Self-Check: /rtk doctor
* View Token Savings Statistics: /rtk gain
Environment Variable Configuration¶
- Explicitly Specify the RTK Path:
- macOS/Linux:
export RTK_BIN=/absolute/path/to/rtk
- macOS/Linux:
- Skip Rewriting:
- POSIX Shell:
DSH_RTK_DISABLE=1 <command> - PowerShell:
$env:DSH_RTK_DISABLE='1'; <command>
- POSIX Shell:
Configuration File¶
You can override the default configuration in the profile’s cordis.patch.yml:
- id: dsh-rtk
config:
autoDiscover: true
bin: /opt/homebrew/bin/rtk
timeoutMs: 3000
verbose: false
statusFile: true
Notes and Troubleshooting¶
- RTK Binary Dependency: The plugin does not include the RTK binary; it must be installed separately.
- Windows Behavior: Windows only accepts
.exefiles and rejects.cmd/.batfiles (for security reasons, it refuses to forward command text through the shell). - Configuration Activation: Changes to configuration items and environment variables require completely quitting and reopening DSH to take effect.
- Environment Variable Differences:
- macOS/Linux reads the login shell environment (such as
~/.zshrc). - Windows reads user environment variables from the registry and does not read shell configuration (such as
$PROFILE).
- macOS/Linux reads the login shell environment (such as
- Older Version Compatibility: Versions 1.0.x modify the host source code; upgrading to 1.1.0+ no longer modifies the host source code. Please make sure to back up before upgrading.
Summary¶
dsh-rtk introduces the local RTK tool to provide compression capabilities at the Shell command output layer of DSH, helping reduce token consumption. It uses the /rtk command family to provide comprehensive in-session diagnostics and statistics, making it suitable for developers who need to optimize command output length in a DSH environment.