Introducing the dsh-router-ext-rtk Plugin: Compressing Bash Output with RTK

Introduction

The DeepSeek Harness (DSH) ecosystem emphasizes modularity. dsh-router-ext-rtk is an extension designed for dsh-router. When agents execute bash commands, the output often contains a large amount of redundant information, leading to substantial token consumption. This plugin rewrites bash commands into rtk <cmd> and uses Rust Token Killer to compress the output, reducing bash output sent to the LLM by 60-90%.

What Is It

This plugin is maintained by CARVIN94 and is licensed under MIT. It registers a command rewriting extension that causes dsh-router to run each command through rtk rewrite whenever the bash tool is invoked, thereby compressing the output. Installing it standalone has no effect; it depends on the dsh-router core to provide the panel and switch storage.

Installation and Enablement

Before use, ensure the DSH version is 0.2.0 or later.

  1. Install the plugin:
dsh plugin --profile web add dsh-router-ext-rtk
  1. Install the prerequisite tool RTK (note that it is not Rust Type Kit):
brew install rtk
# 或
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/master/install.sh | sh
  1. Verify the RTK installation:
rtk --version   # 应返回版本号
rtk gain        # 应显示 token 节省统计
  1. Enable it in the Web interface:
    Go to the “Settings → Routing → Extensions” page and turn on the RTK switch. If RTK is not installed or unavailable, the core will refuse to enable it and return API 409.

Core Features

  • Real proxying: Each bash command is rewritten via rtk rewrite before execution, and the LLM reads the compressed output.
  • Safe fallback: If rtk is missing, no equivalent rewrite exists, or execution fails, the command is executed as-is and never errors.
  • Bash-only interception: Only the bash tool is intercepted; other tools (such as run_code) are unaffected.
  • Switch self-check: At startup, the system probes for rtk; if it is unavailable, the core refuses to enable it and provides a description.
  • Switch persistence: The state is stored in the core’s configuration file (<profile>/data/ext.json) and is disabled by default.

Configuration

If rtk is not in the default path, you can explicitly specify the executable file path using the environment variable DSH_RTK_BIN.

How It Works

The core is responsible for managing the panel, rendering the interface, persisting the switch state, and deciding whether the switch can be enabled. The plugin is responsible for performing the rewrite, intercepting bash calls, and handling exit codes. The plugin is stateless; it interacts with the core through router.extStore and does not perform file I/O by itself.

Key point: When calling tools.get('bash', exec.agent) in code, the agent scope cannot be omitted. Without the scope, it only checks the global view; if the target cannot be found, it silently falls back to the original behavior without reporting an error or performing a rewrite.

RTK Exit Code Handling

RTK permissions default to the lowest level, and very few commands return Allow(0). Common commands (such as git status) all return Ask(3). After the user enables the switch and grants authorization, exit code 3 also adopts stdout:

  • 0 (Allow): An equivalent rewrite exists; stdout is adopted.
  • 1 (No equivalent): The command is allowed; it is executed as-is.
  • 2 (Deny): The command is allowed; it is not blocked.
  • 3 (Ask): An equivalent rewrite exists but requires confirmation by default; stdout is adopted (the user has already authorized it).
  • Spawn failure/timeout: The command is allowed.

Intended Use

This project is for learning and technical research purposes only; do not use it for commercial purposes.

Summary

This plugin improves efficiency by reducing LLM bash output by 60-90%. The core provides management, while the plugin handles execution. For more details, please check the project pages:
- Plugin directory
- GitHub repository

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye