dsh-pwsh-rtk-rewrite

devtested: passnpmMIT

Replaces the web profile's pwsh shell executor with a subclass that rewrites every command through `rtk rewrite` before execution for token savings, running the original command unchanged on any rewrite failure (no equivalent, missing rtk, timeout) and keeping sandbox semantics intact.

下载量 / Downloads
1,797
依赖体积 / node_modules
0.03 MB
测试时间 / Tested
2026-11-06
DSH 版本 / Version
0.2.2-rc.1

Install

dsh plugin --profile web add dsh-pwsh-rtk-rewrite

Sandbox test results

StageResult
1 install✓
2 list✓
3 mount✓
4 boot—

Four stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).

README

dsh-pwsh-rtk-rewrite

English | [中文](./README_zh.md)

A native rtk bridge plugin for DeepSeek Harness (DSH):

it replaces the desktop profile's shell executor with an rtk-rewriting subclass, so

**every pwsh shell command is transparently rewritten through rtk rewrite "<cmd>"

before execution**, letting rtk's compact output format save tokens on every tool call.

Verified on a real machine (2026-09-25, dsh 0.1.7-rc.2 + rtk 0.50.0 + Node v24.19.0):

[rtk-rewrite] "git status" -> "rtk git status"
[rtk-rewrite] "cat E:\\CLI\\dsh-web.log" -> "rtk read E:\\CLI\\dsh-web.log"
# Even compound commands are rewritten segment by segment:
"cat a.log; git status; grep -c x b.log"
  -> "rtk read a.log; rtk git status; rtk grep -c x b.log"

rtk gain climbs in real time as commands run (experiment: Total commands 10274 → 10277,

matching the 3 rewrite log lines in dsh-web.log one to one).

Compatibility

0.2.0 (verified 2026-09-29): @deepseek-ai/dsh-pwsh-sandbox@0.2.0-rc.1's

lib/index.js is byte-identical to 0.1.7-rc.2 (252 lines, 0 diff). The

SandboxPwshExecutor named export, the execute(spec) signature, and the resolve()

policy-stamp layer are all unchanged — this plugin needs no code change;

peerDependencies was widened to >=0.2.0-rc.1 <0.3.0-0 (since v1.1.0).

0.2.0-rc.2 (verified 2026-09-30): @deepseek-ai/dsh-pwsh-sandbox@0.2.0-rc.2's

lib/index.js is byte-identical to 0.2.0-rc.1 (same SHA256 BED19D2C…, 252

lines, 0 diff). The only in-package changes are version numbers in package.json

(rc.1 → rc.2) — the persistent-PowerShell fix in rc.2 ("command-end detection fails

when the completion status is followed by a space, losing exit codes or leaking

internal markers") lives in the dsh kernel, not in this sandbox package. The

dsh-pwsh-sandbox copy bundled inside the desktop 0.2.0-rc.2 app.asar was also

extracted and compared: byte-identical to the npm rc.2 (same SHA256).

0.2.1 (verified 2026-10-17): @deepseek-ai/dsh-pwsh-sandbox@0.2.1-rc.2's

lib/index.js is byte-identical to 0.2.0-rc.2 (same SHA256 BED19D2C…,

0 diff) — the whole 0.2.1 line so far touched only README/locale/package.json

metadata. The desktop 0.2.1-rc.1 app.asar was extracted and bundles the same

byte-identical copy; the pwsh-sandbox cordis line is still present in the

kernel, and the upstream changelog (v0.2.1-rc.1/rc.2) contains no

shell-executor or patch-mechanism breaking changes. This plugin needs **no

code change**; the existing peer range >=0.2.0-rc.1 <0.3.0-0 already covers

0.2.1-rc.1/rc.2, and test.js loaded the devDependency copy of 0.2.1-rc.2 under

bare node to keep exercising the subclassing contract (that pin has since moved to

0.2.1-rc.3, see the next entry).

0.2.1-rc.3 (verified 2026-10-24): @deepseek-ai/dsh-pwsh-sandbox@0.2.1-rc.3's

lib/index.js is byte-identical to 0.2.1-rc.2 (same SHA256 BED19D2C…, 252

lines, 0 diff); the only in-package diff is package.json — the package version and

its internal dependency pins (rc.2 → rc.3). The upstream

dsh-v0.2.1-rc.3

changelog carries no shell-executor or patch-mechanism breaking changes: a full tree

diff against dsh-v0.2.1-rc.2 shows packages/shell/, packages/sandbox/ and

packages/subprocess/** touching only their package.json versions (no source

files), and the patch-grammar file packages/bundle/base/cordis.patch.yml is

identical across the two tags (the only cordis.patch.yml change is one added UI

entry-customization line in the web bundle). This plugin needs no code change;

the existing peer range >=0.2.0-rc.1 <0.3.0-0 already covers 0.2.1-rc.3 under

DSH's semver.satisfies(..., { includePrerelease: true }) check, and test.js now

loads the devDependency copy of 0.2.1-rc.3. This entry was verified by comparing

the npm packages and the upstream repository trees — no desktop re-installation test

was run for it.

Desktop adaptation (verified and fixed on a real machine 2026-09-30, v1.1.3):

the desktop 0.2.0-rc.2 dsh kernel is packaged inside resources\app.asar; neither

the desktop profile's dependency chain nor the node-directory layouts can resolve the

kernel package, so the plugin's original four probe chains all missed → the

rtk-pwsh-shell service failed to load and the patch silently fell back to the

native shell (the assembly-layer patch declaration itself was correct — confirmed by

actually probing loadProfileDirectory). v1.1.3 adds a fifth **Electron desktop

layout probe chain** <exe dir>\resources\app.asar\dsh\node_modules\@deepseek-ai\dsh,

which hits in the desktop main process (thanks to Electron's asar fs support);

node test.js passes all 6 checks in that same shape. After installing v1.1.3,

restart the desktop app and it works — no DSH_INSTALL_PACKAGE_JSON needed.

Requirements

  • **DeepSeek Harness ≥ 0.1.7 (including 0.2.0-rc.1 / 0.2.0-rc.2 / 0.2.1-rc.1 /

0.2.1-rc.2 / 0.2.1-rc.3)** desktop app

(dsh CLI with the dsh plugin mechanism)

  • rtk ≥ 0.50.0 on PATH (rtk rewrite subcommand available; use the RTK_BIN

environment variable to point at an alias). Contract re-verified against rtk

0.51.0 on 2026-10-03: exit-code semantics unchanged.

  • Windows + PowerShell (the plugin replaces the pwsh executor; bash/other shell

tools are unaffected)

How It Works

DSH's plugin system (cordis) lets a bundle replace service lines via a patch

declaration. Each context allows exactly one ctx.shell implementation, so the

patch does two things:

1. Disable the original executor: - id: pwsh-sandbox / disabled: true

2. Insert this plugin: insert: - id: rtk-pwsh-shell / name: 'dsh-pwsh-rtk-rewrite'

Once loaded, shell capability is provided by RtkPwshExecutor:

execute(spec)
  ├─ RTK_DISABLED=1 ? ────────────────► run as-is
  ├─ command starts with "rtk "/"rtk.exe " ? ──► run as-

…(truncated)

Rendered from the README published on npm. Formatted only, not edited.

Versions

Published on npm::7,最后更新 2026-10-24

Links

GitHub · Homepage · npm

Same category