返回目录
模型与 MCP 插件

dsh-wsl-suite

stallenlu/dsh-wsl-suite

WSL workspaces for DeepSeek Harness: one persistent in-distro agent instead of 9P polling. Sidebar W entry, in-distro terminal, WSL-native grep/glob, wsl-<mode> preset variants.

Stars
3
Forks
1
Issues
0
更新
8 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:stallenlu/dsh-wsl-suite

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-wsl-suite

WSL workspaces for DeepSeek Harness. A rebuild of dsh-wsl-workspace on a different substrate: one persistent agent process inside the distribution, reached over a JSON-lines pipe, instead of a 9P file share plus a spawn per command. 中文版:README.zh-CN.md(内容对应,以本文为准).

English · 中文

Version 0.1.12
Harness DeepSeek Harness 0.2.1-rc.5 (desktop & web)
Node >= 22
Distro any WSL2 distro (tested on Ubuntu 26.04)
Peer deps @deepseek-ai/cordis ^4.0.5 · @deepseek-ai/dsh-fs / dsh-shell / dsh-sandbox / dsh-subprocess / dsh-tools ^0.2.1-rc.5 · @deepseek-ai/schemastery ^3.18.5
Client inject @deepseek-ai/dsh-client-ui-slots · @deepseek-ai/dsh-client-ui-sidebar

Acknowledgments

This plugin stands on the shoulders of dsh-wsl-workspace by Yuntao Liu (@6Mikao9) and its maintainers. That plugin proved the workflow this one serves — adding a WSL workspace from the sidebar and running a whole session inside the distribution — and its client design (the header-entry mount, the add-workspace dialog, the footer-seat fallback) is the blueprint src/client/ follows. The rebuild changes the substrate, not the ideas: thank you.

Please file dsh-wsl issues here, and direct dsh-wsl-workspace questions to its own repository.

browser ──POST /dsh-wsl/api──▶ host plugin ──pipe──▶ node agent.mjs (in distro)
                                     │                        │
                                     └── ctx.fs / ctx.shell ◀─┘

Why the substrate changed

Measured on this machine against a live Ubuntu distro:

operation 9P share (//wsl.localhost/…) one wsl.exe spawn per call this agent
stat 4.3 ms 212–282 ms 0.20 ms
readdir 2.8 ms 212–282 ms 0.25 ms
run a command — 212–282 ms 13–20 ms
glob a 5.2 GB repo (64,625 files) 44 s (and misses ~half the tree) — 0.59 s

Three consequences follow, and all three are the point of the rebuild:

  • No polling. The old plugin swept the share every 3 s and walked it every 30 s so it could notice changes. Against a share, each sweep is a batch of multi-millisecond metadata calls that reaches into the distro and, when WSLg is on, pulls focus to the Windows desktop every half minute. The agent is asked on demand, so those timers are gone rather than tuned — nothing touches the distro while it is idle.
  • /mnt/<drive> works inside the distro, but not as a workspace root. A 9P share serves ext4 only; the drvfs mounts are invisible to it, which forced the old plugin to reroute those paths to Windows drive letters and to synthesize /mnt entries by probing every drive. Inside the distribution /mnt/c is just a directory, so the rerouting and the probe are deleted along with the class of bug where a workspace key and its path disagreed — tools, the terminal and the file dialog all reach /mnt normally. Registering one as a workspace is the exception: the host canonicalises every workspace path with fs.realpath, and Windows cannot resolve anything below /mnt (EPERM, drvfs is mounted inside the distro only). The dialog says so and disables the button instead of surfacing that error; keep projects on the distribution filesystem (/home/you/…).
  • Search runs in the distribution. grep and glob are the shipped tools backed by a packaged Windows ripgrep, which against a share is not merely slow: a whole-home walk took 44 s over 9P versus 0.29 s in-distro, a content search 150 s versus 0.79 s, and the 9P run returned 22,436 lines where the native one returned 41,838 — it silently missed about half the tree. So the WSL variant swaps in search-wsl, which runs the distro's own rg through the agent. The same glob '*.toml' query answers 891 files in 2.3 s.

What it does for you

  • Add a WSL workspace from the sidebar. In the Workspaces section header, press the W button beside the shipped “添加工作区” control (it falls back to a bottom-list entry when the header is absent). The dialog lists your installed distributions and browses the Linux filesystem; “添加此文件夹” registers the folder through the host's own workspace registry — a WSL workspace is just a host workspace whose path is a UNC path (\\wsl.localhost\Ubuntu\home\you\…), so there is exactly one record and no private store to drift. The path field takes a typed path as well as a click: type /home/you/projects and press Enter, or a bare name relative to the directory on screen. Holding depth in a folder tree is not a navigation problem to click through.
  • The sidebar terminal follows the session in. A session whose workspace is a WSL path opens its terminal inside the distribution — a real bash with a real pty (input, output and resize all round-trip). Windows-cwd sessions are untouched.
  • The model gets WSL-native tools. A wsl-<mode> twin of every healthy preset replaces the shell/fs tools with the WSL ones and adds grep/glob that run the distro's own ripgrep — including /mnt/<drive> and unreadable-directory tolerance (exit 2 keeps the partial results instead of failing the call).
  • Failures say what happened. A distribution with no reachable node reports which non-login shell was searched and what to do about it (nvm/fnm/volta users: a login shell hides this, the agent does not get one); a machine with no distribution at all says so instead of showing an empty picker; a preset twin that failed to publish is called out in the dialog, because the symptom would otherwise be new WSL sessions quietly running the host default.
  • Localized. The dialog follows navigator.language: Simplified Chinese for zh-*, English otherwise.

Configuration

Two fields, both optional:

field default meaning
nodePath node The executable that starts the in-distro agent. Resolved against the non-login path, which is what wsl.exe --exec gets — an nvm/fnm/volta install is not on it, so pin an absolute path there.
defaultPreset wsl-standard The twin a new WSL session starts in. An empty string keeps the host default.

The browser route is deliberately not configurable: the client bundle is prebuilt and cannot read the host's config, so a configurable endpoint would only produce a dialog that called a route nobody registered.

The route accepts loopback requests only, and it requires content-type: application/json. The second check is what keeps the route private: the loopback test passes for anything a page in your browser sends, because the browser is the client, and a text/plain body is a CORS simple request — no preflight, so any site you visit could otherwise list a distribution or register a workspace. application/json cannot be sent cross-origin without a preflight this route never answers.

What is in here

file role
agent/agent.mjs zerodep Node script run inside the distro: stat, lstat, readdir, read, readRange, write, mkdir, remove, realpath, exec, kill, ping over JSON lines. Reconstructs the login environment once at startup so --exec still sees ~/.local/bin.
src/channel.ts host side of that pipe: spawns the agent, pairs replies by id, idles closed after 10 minutes (idle = no request outstanding, so a 30-minute test run is never killed), one channel per distro, reopen-on-death.
src/shell.ts WslShellExecutor extends ShellExecutor — exit codes, stream split, live streaming, timeout that kills the process group, tail-preserving output cap, background handles whose unobserved rejection can never kill the host.
src/fs.ts WslFileSystem extends FileSystem — 12 primitives, version-guarded writes, FS_STALE_VERSION/FS_AMBIGUOUS_EDIT/FS_NOT_TEXT handling, sandbox fencing, atomic write by rename, and byte-faithful CRLF: the seam's LF normalization applies to the reported before/after only, never to the bytes on disk.
src/search.ts the grep and glob tools, running ripgrep inside the distribution, with a 4 MB ceiling on the output one run may buffer.
src/terminal.ts makes the sidebar terminal follow a WSL session in: wraps the host's single subprocess.spawnTerminal so a UNC cwd launches wsl.exe -d <distro> --cd <linux> -- <shell>.
src/client/index.tsx browser half: the W header entry (via src/client/hostEntry.ts) with the bottom-list entry as fallback + discovery anchor; the add-workspace dialog (src/client/styles.ts styles it, src/client/locale.ts carries the zh/en strings).
src/client/baseline.ts the house design baseline (dsh-design-baseline v1.1.0), vendored: six accent colours, neutral surfaces mapped from the host's --dsw-alias-*. A client bundle cannot require a file path, so it is inlined rather than imported.
src/host/variants.ts preset transform that rewrites an agent preset into its WSL variant. Works on parsed rows, never on indentation.
src/rows.ts the wsl-world group: shell-wsl + fs-wsl + search-wsl under isolate: {shell: true, fs: true}.
src/index.ts host entry: distro discovery, wsl-<mode> materialization, DSH_WSL_DISTRO, and one loopback-only POST route.

The sidebar seat

The W control mounts beside the shipped add-workspace button in the Workspaces section header — the treatment the old dsh-wsl-workspace plugin shipped. The header is host-private (no slot declares it), so src/client/hostEntry.ts mirrors the reference's technique: walk up from the footer action's own DOM element to [class*="_sectionHeader"] / [class*="_headerActions"], inject a <span class="dww-header-slot"> and React-render HostEntryButton into it with the add button's own class list, and observe the strip because React re-renders drop unknown children. The strip's 60 px cap is widened to 92 px while the entry is seated (max-width: 92px in src/client/styles.ts) or the third button is clipped; the shipped-hidden variant keeps it collapsed.

The footer entry stays registered on sidebar.footer.action (a list slot, replaceRisk: "none", fresh id dsh-wsl-suite) — hidden while the header seat is present, and the fallback when the header is absent (rail sidebar, a release that renames the classes). It is also the anchor the header discovery walks up from.

The dialog itself is portalled to document.body, not rendered where the seat lives. The sidebar clips its own subtree (overflow: hidden on the region) and puts a stacking context on the rail, so a position: fixed overlay opened from inside it is painted inside that clipping ancestor: the dialog mounts, the button responds, and nothing appears. Portalling to the paint root is what the shell's own dialogs do, and it also means the keybinding still opens a dialog when the footer seat is hidden, collapsed or unmounted.

The keybinding

The entry is also reachable from the keyboard. apply() registers one command with the shell's own shortcuts service (workspace.wsl-add, Ctrl+Shift+W / ⌘⇧W) — that is a plain registration, not a custom listener, so the shell stores the binding, lists it under Settings → General → Shortcuts, and lets the user rebind it like any built-in command. The web:linux profile is deliberately omitted: the browser allowlist rejects a two-modifier binding there, and a profile left out is simply unbound instead of a registration failure. The tooltip reads the shell's resolved keycap (ctx.shortcuts.catalog) and repaints when the user rebinds, and the button carries the same value in aria-keyshortcuts.

Colours

The dialog follows the house design baseline (dsh-design-baseline, vendored as src/client/baseline.ts): every neutral surface comes from the host's own --dsw-alias-* tokens, and colour comes from exactly six accents — green for a completed add, rose for a failure, blue for focus, nothing else. Primary buttons are inverted rather than coloured, because colour is reserved for state. The baseline maps its neutrals on .dsb-root, not :root, so the dark theme's overrides actually reach them; the overlay carries that class. The shell chrome (the footer button and the header entry) stays on --dsw-* directly so it keeps looking like the host's own icon buttons.

src/client/baseline.ts opens with a /*! >>> dsh-design-baseline v1.1.0 sha256 … */ stamp line. It is not decoration: the baseline's check-all.mjs uses that stamp to tell a plugin that carries a compiled copy of the sheet (drift is then tracked against dist/theme.js) from one that hand-copied a few tokens. Regenerate the file whenever the baseline is rebuilt — the stamp's hash has to move with it.

The terminal

The sidebar terminal is not driven by the terminals registry, so adding a terminal backend does not reach it. terminalController gets its environment from agent.ctx.get('subprocess') and calls subprocess.spawnTerminal(...) directly. That service is single-slot and agent.ctx sits outside any preset group, so a preset cannot provide a WSL one — isolation only propagates to descendants, and the preset registry rejects a service that leaks into the host realm.

What it can do instead is wrap the host provider's spawnTerminal in place, which src/terminal.ts does. The discriminator is already in the request: a session inside a distribution has a UNC cwd, and the wrapper rewrites that one call into

wsl.exe -d <distro> --cd <linux cwd> -- <shell>

so the host's own ConPTY carries a real Linux pty — input, output and resize all round-trip. Sessions with a Windows cwd pass through untouched, byte for byte.

resolveExecutable and terminalEnvironment are deliberately left alone: they answer host-wide questions (which bash.exe exists on Windows) and only feed shell discovery and argument building. The shell that actually starts is chosen here — the requested POSIX shell name is passed into the distribution (/bin/zsh, /bin/fish, …, falling back to /bin/bash), so the distro's own shells are honored.

Preset variants, not a mode

The shell dialect has to change with the world: outside a distribution the agent runs pwsh, inside it runs bash. So instead of a global routing provider, every healthy preset in the profile gets a wsl-<mode> twin (standard → wsl-standard) whose shell and file tools are the WSL ones. The rest of the preset — persona, skills, jobs, delegation — is carried through untouched.

Creating a session from a WSL workspace now starts it in the wsl-standard twin instead of the host's Windows standard: the plugin wraps the session-create service and, when the caller left the preset unset and the target path is a WSL UNC path, fills in wsl-standard. A preset chosen explicitly on the new-session screen always wins, and a Windows workspace is left untouched. The config field defaultPreset (default wsl-standard) names that twin; set it to an empty string to keep the host default. If the twin has not been published yet, the request is passed through unchanged.

The transform matches rows by id in the parsed document, which makes it immune to the indentation fragility that made a nested subagent row invisible to the original (tool "subagent" is already registered in this scope). It also clears a disabled: !!js process.platform === 'win32' gate off a row it lifts into the world: that expression is evaluated by the loader on the host, so carrying it along would disable the very tool the variant exists to provide.

Variants are built once, when the plugin applies. A preset that another plugin registers after that (install a plugin that declares a new mode without restarting) gets no twin until the next start — the roster exposes no change event to hook, and polling it to mount full preset trees on a guess is not worth the cost. The dialog surfaces the count of variants that failed to publish, so a silent miss shows up as a warning rather than as sessions that inexplicably run the host preset.

!!js expressions survive the round trip as {__jsExpr: …} nodes, which is the shape the host loader itself tests for, so a re-registered preset still evaluates its own gates.

Installing, updating, verifying

From npm (the normal way). The published name is dsh-wsl-suite; the bundle and its rows are named the same. In the profile directory:

# in C:\Users\<you>\.dsh\profiles\desktop\
pnpm add dsh-wsl-suite          # or: npm install dsh-wsl-suite

then add "dsh-wsl-suite" to dsh.profile.bundles in that profile's package.json and restart the harness.

From GitHub. Same result, useful before a version reaches the registry:

pnpm add "dsh-wsl-suite@github:stallenlu/dsh-wsl-suite"

github: specs are fetched as a tarball, so the copy is replaced wholesale on every push — no file:-style remove/reinstall dance.

Prebuilt release tarball. Each release also attaches a ready-to-install dsh-wsl-suite.tgz (no build step, so it skips the allowBuilds approval):

pnpm add https://github.com/stallenlu/dsh-wsl-suite/releases/download/v0.1.12/dsh-wsl-suite.tgz

The asset name carries no version number and the URL is pinned to a tag, so the link never rots when a later release is published. The awesome-dsh-plugin catalog entry points at this URL as its tarball: fallback.

One naming rule worth knowing, because violating it breaks the boot silently: the client bundle's registration id must equal the package name. The host keys its client boot graph by package name (dsh-client-modules/lib/index.js this.table.set(packageName, …)), and its arrive() only accepts a bundle whose factory registered under that same id — otherwise the entry never activates and the renderer logs client-modules: duplicate factory registration. tsdown.config.ts writes that id into the bundle banner, and tests/client.test.ts asserts it matches package.json.

Local checkout (development):

# source of truth — edit here
E:\DshConfig\dsh-wsl-suite\
# the copy the harness actually loads (a FILE COPY, not a symlink)
C:\Users\GT14\.dsh\profiles\desktop\node_modules\dsh-wsl-suite\

Because the installed copy is a copy, every source change needs a reinstall; from a DeepSeek Harness session:

  1. npm run verify in the source tree (typecheck + build + 84 checks).
  2. plugin_manager remove_bundle target=dsh-wsl-suite, then plugin_manager install_bundle target=file:E:\DshConfig\dsh-wsl-suite.
  3. Restart DSH (the reinstall answers application: "restart-required").
  4. If the entry ever disappears again: check dsh.profile.bundles in C:\Users\GT14\.dsh\profiles\desktop\package.json still contains dsh-wsl-suite (a concurrent profile rewrite has dropped it before), and plugin_manager set_bundle target=dsh-wsl-suite enabled=true re-mounts it hot — no restart needed — when the boot is stable and no other HMR transaction is open.

Quick host-side check without the UI:

curl -X POST http://127.0.0.1:<gui-port>/dsh-wsl/api \
  -H "content-type: application/json" -d '{"method":"listDistros"}'
# → {"ok":true,"value":{"distros":[{"name":"Ubuntu","default":true}]}}

check and listDir go through the persistent in-distro agent, so a 200 with real entries proves the whole pipe.

Developing

npm install          # devDependencies pin the 0.2.1-rc.5 host surface
npm run typecheck    # also needs @deepseek-ai/dsh-llm (pinned in devDependencies)
npm run build        # lib/{index,fs,shell,search,client}.js + paths-*.js
npm test             # 84 checks; live ones skip when no distro is present
npm run verify       # typecheck, then build + test

tests/live.test.ts runs against a real distro and skips — rather than fails — when wsl.exe -l -q returns nothing, so the suite is honest on a machine without WSL. tests/client.test.ts loads the built bundle the way the host's loader does, so npm test builds first (pretest); that is the only place the browser half is checked, because tsconfig.json excludes it.

Deliberate non-goals

  • No fs.watch. The distro's filesystem cannot be watched from the host; the sidebar file browser swallows the resulting workspace-file/watch-unsupported code and does a one-shot refresh instead. The reference plugin had no watch either.
  • sandboxMode is undefined. The WSL VM is the boundary; there is nothing inside it for the host's sandbox policy to fence.
  • No wsl_terminal model tool / persistent-shell terminal door / workspace context-menu items. The old plugin's model-side terminal and menu hack are superseded: the model uses the persistent channel (structured exit codes and streams, faster than driving a pty), and people use the sidebar terminal, which now enters the distribution on its own.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度高

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek。