跳到主要内容

dsh-rtk-plugin

已验证

dsh-rtk-plugin · v0.2.0 · MIT

RTK (Reusable Token Kompressor) tool for DeepSeek Harness — token-optimized CLI proxy exposing read/ls/git/grep/err/test/json and more through the standard shell sandbox.

安装

dsh plugin add dsh-rtk-plugin

用 dsh --profile default --dump-config 确认 layer 已生效 —— 参见安装指南。

源码

标签

作者

说明文档

dsh-rtk-plugin

RTK (Reusable Token Kompressor) tool for DeepSeek Harness — a high-performance CLI proxy that filters and compresses command output before it reaches the model context, saving substantial tokens.

This bundle exposes RTK as a model-facing rtk tool through the standard ctx.shell capability seam, so every call inherits the harness's sandbox policy, timeout handling, and cancellation exactly like the native bash tool.

What the tool does

The model (and you, via @) gets one tool, rtk, that runs any RTK subcommand with token-optimized output:

Subcommand Use
read <file> Read a file with intelligent filtering (-n line numbers, -m N max lines, --tail-lines N, -l minimal|aggressive)
ls / find Compact directory listing / file finding
git <args> Compact git output (status, log, diff, branch…)
grep / rg Compact search, grouped by file
err -- <cmd> Run any command, show only errors/warnings
test -- <cmd> Run tests, show only failures
json <file> Compact JSON (-d depth, --keys-only for structure only)
deps Summarize project dependencies
diff / log / wc Condensed diff / deduplicated logs / compact counts
smart <file> 2-line technical summary of a file
summary -- <cmd> Heuristic summary of command output

Plus wrappers for tree, gh, glab, aws, psql, pnpm, docker, kubectl, jest, vitest, prisma, tsc, next, lint, prettier, cargo, npm, npx, ruff, playwright, dotnet, wget, env, curl, format.

The tool's command parameter takes the subcommand without the leading rtk (e.g. read -n -m 50 package.json, git status, err -- npm run build).

Prerequisites

  • RTK installed and on the PATH the shell executor uses (brew install rtk / rtk --version to check). If it lives elsewhere, see Configuration.

Install

Into a profile (recommended — survives restarts):

dsh plugin --profile web add dsh-rtk-plugin        # from npm (once published)
dsh plugin --profile web add /path/to/dsh-rtk-plugin  # from a local checkout

Then restart dsh web (or the profile's host) for the composition to pick up the new bundle row.

Uninstall / disable

dsh plugin --profile web remove dsh-rtk-plugin

Or disable just the row in the profile's cordis.patch.yml:

- id: rtk
  disabled: true

Default routing (enforced)

By default (guardBash: true) every single bash command whose first word maps 1:1 to an RTK wrapper (grep, rg, ls, cat→read, git, wc, find) is denied at the tools/guard layer. The denial message tells the model to retry through the rtk tool:

Route 'grep' through the rtk tool ... Retry as rtk command 'grep …'

Compound or piped commands (|, &&, ;, `, $(, >, <, () and multi-line scripts are exempt — RTK cannot wrap them, so they run raw.

Explicit opt-out: when the model really needs raw output, it appends a shell comment that the guard checks for:

grep pattern file.txt # no-rtk   # or: # raw

Either marker lets the call through.

Configuration

The bundle row accepts options via the profile's cordis.patch.yml:

- id: rtk
  name: 'dsh-rtk-plugin'
  config:
    rtkPath: /opt/homebrew/bin/rtk   # default: 'rtk' (PATH resolution)
    guardBash: true                   # default: true — set false to keep rtk opt-in

Notes and limitations

  • rtk gain (savings history) may fail under a file sandbox because its tracking DB lives outside the session workspace — expected, not a tool bug.
  • RTK output is already token-optimized; avoid piping it through additional filters.
  • Non-zero exits are reported as [exit code: N] markers; sandbox denials as [sandbox: file access denied under <mode> mode] — the same vocabulary as the native bash tool.

Development

npm test    # smoke tests (no harness needed)

Pure JavaScript, no build step — index.js is the published source.

License

MIT