dsh-plugin-wsl-env 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -12,13 +12,97 @@ reference below points at that record's numbering.
12
12
 
13
13
  ## [Unreleased]
14
14
 
15
+ ## [0.1.3] - 2026-10-02
16
+
17
+ Repository and release engineering. No runtime behaviour changed.
18
+
19
+ ### Added
20
+
21
+ - `npm run lint:style` ([`test/style.mjs`](test/style.mjs)): a dependency-free gate
22
+ over the rules `.editorconfig` states, plus three packaging checks — every `files`
23
+ entry still matches tracked content, every `exports` target exists, and exactly one
24
+ readme candidate sits at the package root. That last one is the regression guard
25
+ for the 0.1.1 readme, and it is why the gate exists at all.
26
+ - `npm run test:coverage`, with thresholds of 85% lines, 85% branches and 70%
27
+ functions, using Node's built-in coverage. No coverage dependency was added. The
28
+ spawning half of `lib/wsl.js` and the four service modules are covered by the
29
+ probes instead, which is why the function threshold is lower than the others.
30
+ - `.github/workflows/release.yml`: a `v*` tag is checked against `package.json`
31
+ ([`scripts/check-release-tag.mjs`](scripts/check-release-tag.mjs)), gated, then
32
+ published with `--provenance` through npm trusted publishing, and the GitHub
33
+ Release is created from the changelog section
34
+ ([`scripts/changelog-section.mjs`](scripts/changelog-section.mjs)). No npm token is
35
+ stored in the repository.
36
+ - The governance files a public repository is expected to carry:
37
+ [`SECURITY.md`](SECURITY.md), [`CONTRIBUTING.md`](CONTRIBUTING.md),
38
+ [`SUPPORT.md`](SUPPORT.md), [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md),
39
+ `CODEOWNERS`, a pull-request template, bug-report and contact-link issue templates,
40
+ and a Dependabot configuration for the pinned workflow actions.
41
+ - [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) describes the plugin as it is
42
+ today — the providers, how they are mounted, the three path coordinate systems, the
43
+ sandbox, the runtime mirror and the test layers — so the current design no longer
44
+ has to be reconstructed from a changelog and a historical record.
45
+ - [`docs/RELEASING.md`](docs/RELEASING.md): the release checklist, including the
46
+ operational facts that cost time to learn.
47
+ - [`docs/archive/README.en.md`](docs/archive/README.en.md): an English index of the
48
+ Chinese archive.
49
+ - `.nvmrc` names the Node version the coverage job uses.
50
+
51
+ ### Changed
52
+
53
+ - The probes no longer carry a user name, a home directory or a distro name.
54
+ [`test/probe/env.sh`](test/probe/env.sh) derives them from the machine
55
+ (`%USERPROFILE%`, `%LOCALAPPDATA%`, `WSL_DISTRO_NAME`) and
56
+ [`test/probe/env.mjs`](test/probe/env.mjs) does the same for the Node-side probes,
57
+ which learn their own location from `import.meta.url`. The YAML overlays are now
58
+ templates with `@NAME@` placeholders, and the scripts substitute real values into
59
+ generated copies that `.gitignore` keeps out of the tree. The two profile layers
60
+ use `distro: ''` (WSL's default distro) instead of naming one.
61
+ - CI runs the unit suite on Windows as well as Linux. The plugin targets Windows, and
62
+ the Windows legs also prove that the LF guarantee in `.gitattributes` holds on the
63
+ platform whose default is CRLF. The workflow gained least-privilege `permissions`,
64
+ a `concurrency` group, timeouts, and actions pinned by commit SHA.
65
+ - `package.json`: `packageManager` is gone, because the package has no dependencies
66
+ and npm is the reference toolchain everywhere else; `author` and `publishConfig`
67
+ are set; `prepublishOnly` runs the gates; and `files` ships `CONTRIBUTING.md`,
68
+ `SECURITY.md` and `SUPPORT.md` so a tarball without the repository still says how
69
+ to contribute, report and get help.
70
+ - Both READMEs gained a *Contributing and support* section, and list the new gates.
71
+
72
+ ### Fixed
73
+
74
+ - Corrected the 0.1.2 entry. It had named the npm CLI's readme rule as the cause of
75
+ the 0.1.1 readme mix-up; that rule does not match `.md` names and is not the code
76
+ path that decides a published package's readme, so the entry now records what was
77
+ observed instead of a mechanism that does not hold. The GitHub Release notes for
78
+ v0.1.2 were corrected the same way.
79
+ - Six lines in [`lib/index.js`](lib/index.js) were indented with tabs while the rest
80
+ of the file uses spaces, which the new style gate caught.
81
+
82
+ ## [0.1.2] - 2026-10-02
83
+
84
+ ### Fixed
85
+
86
+ - The npm package page rendered the Chinese README instead of the English one. 0.1.1
87
+ published `README.md` and `README.zh.md` side by side, and the registry answered
88
+ with `readmeFilename: README.zh.md`. Two candidates are enough to make the outcome
89
+ unreliable, and neither obvious rule explains which one won: it is not the tarball's
90
+ entry order (0.1.1's tarball listed `package/README.md` first), and it is not the
91
+ npm CLI's own selection rule (`@npmcli/package-json/lib/normalize.js` globs
92
+ `{README,README.*}` and accepts `/\.m?a?r?k?d?o?w?n$/i`, which does not match a
93
+ `.md` name at all). The registry is picking by a rule this repository should not
94
+ depend on. The translation now lives at `docs/README.zh.md`, which leaves exactly
95
+ one candidate at the package root and removes the question by construction. The
96
+ English header still links to it and `files` still ships it. 0.1.1 remains on the
97
+ registry with the wrong readme; 0.1.2 supersedes it.
98
+
15
99
  ## [0.1.1] - 2026-10-02
16
100
 
17
101
  Documentation only: the README was reorganised for readers and translated into Chinese. No code changed.
18
102
 
19
103
  ### Added
20
104
 
21
- - A Chinese translation of the README, [README.zh.md](README.zh.md), linked from
105
+ - A Chinese translation of the README, [docs/README.zh.md](docs/README.zh.md), linked from
22
106
  the English header (and back). It is a translation, not the second README that
23
107
  was removed earlier: that file's problem was genre — it called itself the current
24
108
  description while contradicting the English one — whereas these two say the same
@@ -234,7 +318,7 @@ performance caveat, unsupported `watch()`, and the missing executable bit on
234
318
  freshly created files.
235
319
  ### Removed
236
320
 
237
- - `README.zh.md` stopped being a README: the file moved to
321
+ - `docs/README.zh.md` stopped being a README: the file moved to
238
322
  `docs/archive/engineering-record.zh.md` and left the package's `files` list, so
239
323
  npm and GitHub now render exactly one README. The reasoning is under Fixed
240
324
  below; nothing was deleted, only renamed out of the slot that made it look
@@ -264,7 +348,7 @@ freshly created files.
264
348
 
265
349
  Documentation that a reader would have acted on, and that was no longer true:
266
350
 
267
- - The repository briefly carried two READMEs. `README.zh.md` called itself the
351
+ - The repository briefly carried two READMEs. `docs/README.zh.md` called itself the
268
352
  current description of the plugin while its conclusions had been superseded
269
353
  three times over — most sharply by the sandbox work below — which is exactly
270
354
  the ambiguity a second README creates. It is now
@@ -0,0 +1,127 @@
1
+ # Contributing
2
+
3
+ This document covers the development loop, the gates a pull request must pass, and
4
+ the conventions this repository uses.
5
+
6
+ ## Prerequisites
7
+
8
+ | Requirement | Notes |
9
+ |---|---|
10
+ | Windows 10 or 11 | the plugin targets Windows only |
11
+ | WSL2 with at least one distro | `wsl.exe -l -v` lists the installed distros |
12
+ | `bubblewrap` in the distro | `sudo apt install bubblewrap`. The sandbox fails closed without it. |
13
+ | Node 20, 22, or 24 | the versions CI runs. `engines` requires `>=20`. |
14
+
15
+ ## Toolchain
16
+
17
+ The package has no dependencies, so there is no install step. Run the scripts
18
+ straight from a checkout.
19
+
20
+ `npm` runs the scripts in this repository, and CI uses npm. Treat
21
+ `npm run <script>` as the reference toolchain.
22
+
23
+ Do not add a runtime dependency. The package ships an empty `dependencies` object
24
+ on purpose, because it is loaded into the DSH process and everything it needs
25
+ arrives as a peer package.
26
+
27
+ Style tooling is kept out for the same reason. There is no ESLint, no Prettier, and
28
+ no `devDependencies` at all. The checks that would normally need them are built
29
+ from Node builtins instead. `test/style.mjs` verifies the rules `.editorconfig`
30
+ states, and it checks that every `files` entry still matches tracked content and
31
+ every `exports` target still exists. The syntax pass inside `npm test` uses Node's
32
+ own parser.
33
+
34
+ ## The development loop
35
+
36
+ 1. Clone the repository inside the distro. Most contributors develop there.
37
+ 2. Make the change.
38
+ 3. Run the gates below.
39
+ 4. Restart the DSH app before testing by hand, if you changed anything under
40
+ `lib/`. A running process caches ES modules, so it keeps the old code
41
+ otherwise.
42
+
43
+ ### The runtime mirror
44
+
45
+ A DSH profile can only link a Windows path. pnpm rewrites
46
+ `link:\\wsl.localhost\...` into a broken `/wsl.localhost/...` symlink, so the
47
+ harness cannot load the plugin from a distro checkout.
48
+
49
+ The Windows copy under `default-workspace/dsh-plugin-wsl` is a runtime mirror. Sync
50
+ it before launching the app:
51
+
52
+ ```bash
53
+ npm run sync:windows
54
+ ```
55
+
56
+ The mirror destination sits outside a session workspace. An agent that runs the
57
+ sync from a confined shell is refused by the `workspace-write` policy and has to
58
+ approve a wider permission for that one command. Run the sync from a plain distro
59
+ terminal if you would rather not see the prompt.
60
+
61
+ ## Gates before a pull request
62
+
63
+ | Command | Covers | Needs a harness |
64
+ |---|---|---|
65
+ | `npm test` | style checks, syntax pass, and unit tests | no |
66
+ | `npm run test:coverage` | unit tests with coverage | no |
67
+ | `npm run lint:style` | style and lint rules | no |
68
+ | `npm run probe` | filesystem behaviour against a real distro | yes |
69
+ | `npm run probe:sandbox` | what bubblewrap confines and what it does not | no |
70
+ | `npm run probe:sandbox-shell` | the confined executor through a real boot | yes |
71
+ | `npm run probe:terminal` | the terminal provider | yes |
72
+
73
+ Every script above is wired in `package.json`. `npm test` runs `lint:style`,
74
+ `test:syntax` and `test:unit` in that order. `prepublishOnly` runs `npm test` again
75
+ at publish time, so a broken gate stops a release before the upload.
76
+
77
+ CI runs `npm test` on Node 20, 22 and 24, on both `ubuntu-latest` and
78
+ `windows-latest`, and `npm run test:coverage` on Node 24. The Windows runners are
79
+ there because the plugin targets Windows; the coverage thresholds need Node 22.8 or
80
+ newer, which is why that job runs on one version.
81
+
82
+ The probes marked "yes" need Windows, WSL2, a mounted harness profile and a linked
83
+ checkout, which a hosted runner does not have. Run them on your own machine and
84
+ paste the output into the pull request.
85
+
86
+ ## Adding a test
87
+
88
+ Choose the layer by what the test needs.
89
+
90
+ | Layer | Location | Use it for |
91
+ |---|---|---|
92
+ | Unit test | `test/*.test.mjs` | pure logic: path translation, listing, shell argument building, terminal helpers |
93
+ | Probe | `test/probe/` | behaviour that needs a real distro, a real profile, or bubblewrap |
94
+
95
+ Unit tests run under `node --test` and import only Node builtins. Add a file named
96
+ `<area>.test.mjs`, then add it to both the `test:unit` and the `test:coverage`
97
+ scripts in `package.json`. Both scripts list their files explicitly.
98
+
99
+ Probes are shell scripts that mount a throwaway profile, plus the small plugin
100
+ files they load. Those plugin files are the `*-probe.mjs` and `*-probe.yml` files
101
+ in the same directory. The setup steps for the throwaway profile are in the header
102
+ of `test/probe/run.sh`. `terminal.sh` and `sandbox-shell.sh` reuse it.
103
+
104
+ Keep probe output idempotent. Several probes delete their scratch files at the
105
+ start, because a leftover file from an earlier run changes the result.
106
+
107
+ ## Commit and pull request conventions
108
+
109
+ - Write an imperative subject line: `Fix the npm readme`, not `Fixed` or `Fixes`.
110
+ - Do not use conventional-commit prefixes. No `feat:`, `fix:`, or `chore:`.
111
+ - Explain why in the body. What changed is already visible in the diff.
112
+ - Add a `CHANGELOG.md` entry under `## [Unreleased]` for a behaviour change. A
113
+ change to documentation or to comments does not need one.
114
+ - Keep one topic per commit.
115
+ - In the pull request, say how you tested it. Paste probe output where a probe is
116
+ relevant.
117
+ - Update `README.md` and `docs/README.zh.md` together when a change affects usage.
118
+ The two files match section for section.
119
+
120
+ ## Reporting bugs and security issues
121
+
122
+ Open a GitHub issue for a bug:
123
+
124
+ https://github.com/Big-Dao/dsh-plugin-wsl-env/issues
125
+
126
+ Report a security issue privately. Follow [SECURITY.md](SECURITY.md) instead of
127
+ opening a public issue.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-plugin-wsl-env
2
2
 
3
- **English** · [中文](README.zh.md)
3
+ **English** · [中文](docs/README.zh.md)
4
4
 
5
5
  [![CI](https://github.com/Big-Dao/dsh-plugin-wsl-env/actions/workflows/ci.yml/badge.svg)](https://github.com/Big-Dao/dsh-plugin-wsl-env/actions/workflows/ci.yml)
6
6
  [![npm](https://img.shields.io/npm/v/dsh-plugin-wsl-env)](https://www.npmjs.com/package/dsh-plugin-wsl-env)
@@ -12,7 +12,8 @@ This plugin lets [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harn
12
12
 
13
13
  [What you get](#what-you-get) · [Install](#install) · [Using it](#using-it) ·
14
14
  [Configure](#configure) · [Sandbox](#sandbox) · [Troubleshooting](#troubleshooting) ·
15
- [Limitations](#limitations) · [Development](#development) · [Design notes](#design-notes)
15
+ [Limitations](#limitations) · [Development](#development) · [Design notes](#design-notes) ·
16
+ [Contributing and support](#contributing-and-support)
16
17
 
17
18
  ## What you get
18
19
 
@@ -147,13 +148,16 @@ These are the same arguments DSH uses on a Linux host (`dsh-sandbox-local`), so
147
148
  ## Development
148
149
 
149
150
  ```bash
150
- npm test # syntax check and unit tests; no dependencies, runs anywhere
151
+ npm test # style and packaging checks, syntax check, unit tests
152
+ npm run test:coverage # the unit tests with coverage thresholds (Node 22.8+)
151
153
  npm run probe:sandbox # measure inside the distro what bubblewrap does and does not confine
152
154
  npm run probe # filesystem probe against a real distro (Windows + WSL only)
153
155
  npm run probe:sandbox-shell # boot a real harness and drive the confined executor
154
156
  npm run probe:terminal # open a PTY through the terminal provider
155
157
  ```
156
158
 
159
+ The package has no dependencies, so there is nothing to install first.
160
+
157
161
  Layout:
158
162
 
159
163
  ```text
@@ -197,7 +201,8 @@ Counts: 42 unit assertions, 18 filesystem-probe assertions, 10 shell-probe check
197
201
 
198
202
  **The runtime mirror.** The checkout is developed inside the distro, but the harness is a Windows process, and a profile can only link a Windows path: pnpm rewrites `link:\\wsl.localhost\...` into a broken `/wsl.localhost/...` symlink. The Windows copy at `default-workspace/dsh-plugin-wsl` is therefore a runtime mirror. Sync it with `test/probe/sync-to-windows.sh` before launching the app. That destination is outside every session workspace, so an agent running the sync in a confined shell is refused by `workspace-write` and must approve `danger-full-access` for that one command. That is the sandbox behaving as designed, not a broken script; run the sync from a normal distro terminal if you prefer not to see the prompt.
199
203
 
200
- **CI** runs `npm test` on Linux with Node 20, 22 and 24.
204
+ **CI** runs `npm test` on Node 20, 22 and 24, on Linux and on Windows, and runs
205
+ `npm run test:coverage` on Node 24 to enforce the coverage thresholds.
201
206
 
202
207
  ## Design notes
203
208
 
@@ -211,6 +216,17 @@ For that reason, [`cordis.patch.yml`](cordis.patch.yml) replaces the **app-wide*
211
216
 
212
217
  **Why the sandbox is on the Linux side.** The Windows ACL runner's restricted token cannot reach WSL at all, so the confinement has to be built on the Windows side and run inside the distro. `lib/sandbox.js` copies the Linux `bwrap` approach from `dsh-sandbox-local` instead of using `ctx.sandbox`. `dsh-tool-bash` never asks for `ctx.sandbox` anyway: it reads the executor's `sandboxMode` and `ctx.sandboxPolicy`, and this plugin supplies both.
213
218
 
219
+ ## Contributing and support
220
+
221
+ | Document | What it covers |
222
+ |---|---|
223
+ | [CONTRIBUTING.md](CONTRIBUTING.md) | the development loop, the gates a pull request must pass, and the conventions used here |
224
+ | [SECURITY.md](SECURITY.md) | reporting a vulnerability privately, response targets, and what counts as in scope |
225
+ | [SUPPORT.md](SUPPORT.md) | what is supported, where to ask, and what a useful bug report contains |
226
+ | [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | how the providers are mounted, the sandbox design, and the test layers |
227
+ | [docs/RELEASING.md](docs/RELEASING.md) | the release checklist, including the trusted-publisher setup |
228
+ | [docs/archive/README.en.md](docs/archive/README.en.md) | an English index of the archived engineering record |
229
+
214
230
  ## License
215
231
 
216
232
  MIT. See [LICENSE](LICENSE).
package/SECURITY.md ADDED
@@ -0,0 +1,82 @@
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ Only the latest published version receives security fixes.
6
+
7
+ | Version | Supported |
8
+ |---|---|
9
+ | the version npm's `latest` tag points at | yes |
10
+ | every earlier version | no |
11
+
12
+ ## Reporting a vulnerability
13
+
14
+ Report a suspected vulnerability privately. Use GitHub's private vulnerability
15
+ reporting on this repository:
16
+
17
+ https://github.com/Big-Dao/dsh-plugin-wsl-env/security/advisories/new
18
+
19
+ If that form is not available to you, open an ordinary issue that asks for a
20
+ private channel. Do not put exploit details in that issue. A maintainer will reply
21
+ with a private place to send them.
22
+
23
+ Do not post exploit details in a public issue, a discussion, or a pull request
24
+ before a fix is released.
25
+
26
+ ## What to include in a report
27
+
28
+ - The plugin version you tested. `npm ls dsh-plugin-wsl-env` prints it, or name the
29
+ tag you built from.
30
+ - Your Windows build and the distro you used. `wsl.exe -l -v` lists the distros.
31
+ - The DSH version and the profile name.
32
+ - What you expected to happen, and what happened instead.
33
+ - The smallest reproduction you can produce, with the exact command.
34
+ - Whether the sandbox was enabled at the time. `sandbox: true` is the default.
35
+
36
+ ## Response times
37
+
38
+ These are targets, not a contract.
39
+
40
+ | Stage | Target |
41
+ |---|---|
42
+ | Acknowledge the report | within 3 business days |
43
+ | Initial assessment and severity | within 10 business days |
44
+ | A fix, or a documented mitigation | within 30 business days |
45
+
46
+ If a report is out of scope, we will say so and explain why.
47
+
48
+ ## Scope
49
+
50
+ In scope:
51
+
52
+ - the plugin's own code under `lib/`;
53
+ - the published package `dsh-plugin-wsl-env`.
54
+
55
+ Out of scope:
56
+
57
+ - the upstream DSH packages under `@deepseek-ai/`. Report those to their own
58
+ projects.
59
+ - WSL itself, the Windows kernel, and `bubblewrap`.
60
+ - The configuration of a user's own distro. That includes its `sudoers` rules, its
61
+ mounted filesystems, and the interpreters installed in it.
62
+ - Anything that requires an attacker to already control the user's Windows account
63
+ or their distro account.
64
+
65
+ ## Sandbox enforcement is `partial` by design
66
+
67
+ The plugin reports the sandbox enforcement level as `partial`, not `full`. A
68
+ process inside the distro can still start a Windows program through WSL interop,
69
+ for example `/mnt/c/.../*.exe`. That program runs outside the Linux sandbox.
70
+
71
+ This is a documented design boundary, not a vulnerability by itself. The command
72
+ `npm run probe:sandbox` demonstrates it on your machine, and the README states it
73
+ in its Sandbox section.
74
+
75
+ A report is still welcome if you find an escape that does not depend on interop,
76
+ or if the plugin ever reports `full` while interop is reachable.
77
+
78
+ ## Credentials
79
+
80
+ No credential, token, or private key belongs in this repository. That includes npm
81
+ tokens, GitHub tokens, and distro passwords. If you find one committed here, report
82
+ it through the private channel above. Do not open a public issue for it.
package/SUPPORT.md ADDED
@@ -0,0 +1,69 @@
1
+ # Support
2
+
3
+ ## What is supported
4
+
5
+ | Area | Supported |
6
+ |---|---|
7
+ | Operating system | Windows 10 and Windows 11 |
8
+ | Linux side | WSL2 with at least one distro |
9
+ | DSH packages | the `0.2.0-rc.2`-era packages listed in `peerDependencies` |
10
+ | Plugin version | the latest published version only |
11
+ | Node | 20, 22, or 24 |
12
+
13
+ Outside Windows there is nothing for the plugin to attach to. It runs `ctx.shell`
14
+ inside the distro through `wsl.exe`. A Linux host, a macOS host, or WSL1 is not a
15
+ supported configuration.
16
+
17
+ ## Where to get help
18
+
19
+ Open an issue in the repository:
20
+
21
+ https://github.com/Big-Dao/dsh-plugin-wsl-env/issues
22
+
23
+ Use it for bug reports and for questions about configuration. Search the open and
24
+ the closed issues first.
25
+
26
+ For a security issue, follow [SECURITY.md](SECURITY.md). Do not open a public
27
+ issue for one.
28
+
29
+ ## What is not supported
30
+
31
+ - macOS, and Linux hosts that are not WSL2.
32
+ - Windows without WSL2.
33
+ - A modified DSH build, or a fork of the harness packages.
34
+ - A distro the plugin cannot recognize. Examples are a replaced `/bin/sh`, a
35
+ container-style root filesystem, and a missing `bwrap`.
36
+ - The upstream `@deepseek-ai/*` packages. Report those to their own projects.
37
+ - Third-party npm mirrors. Install from the registry the package was published to.
38
+
39
+ ## Compatibility expectations
40
+
41
+ The upstream packages are a release candidate, so the peer versions are pinned
42
+ exactly. One example is `@deepseek-ai/dsh-fs: 0.2.0-rc.2`. An upstream change can
43
+ require a new release of this plugin. The exact pins are what make that break
44
+ loudly instead of quietly.
45
+
46
+ There is no long-term support branch. Fixes go to the latest version.
47
+
48
+ ## What a good bug report contains
49
+
50
+ | Item | How to get it |
51
+ |---|---|
52
+ | Plugin version | `npm ls dsh-plugin-wsl-env`, or the git tag you built from |
53
+ | DSH version | the version of the harness you run |
54
+ | Distro and kernel | `wsl.exe -l -v`, and `uname -r` inside the distro |
55
+ | Windows build | `winver` |
56
+ | The composed configuration | `dsh --profile <name> --dump-config`, in particular the `dsh-plugin-wsl-env` layer and the rows it patches |
57
+ | Sandbox behaviour | the output of `npm run probe:sandbox`, when the sandbox is involved |
58
+ | What you expected and what happened | one paragraph each |
59
+ | A reproduction | the exact command, or the exact sequence of clicks |
60
+
61
+ Redact your user name and any path you would rather not publish. The useful part
62
+ of `--dump-config` is usually the layer heading and the patched rows, not the whole
63
+ file.
64
+
65
+ ## Response times
66
+
67
+ This is a small project maintained in spare time. There is no service-level
68
+ agreement and no guaranteed response time. Security reports have their own targets,
69
+ which are listed in [SECURITY.md](SECURITY.md).
@@ -1,16 +1,16 @@
1
1
  # dsh-plugin-wsl-env
2
2
 
3
- [English](README.md) · **中文**
3
+ [English](../README.md) · **中文**
4
4
 
5
5
  [![CI](https://github.com/Big-Dao/dsh-plugin-wsl-env/actions/workflows/ci.yml/badge.svg)](https://github.com/Big-Dao/dsh-plugin-wsl-env/actions/workflows/ci.yml)
6
6
  [![npm](https://img.shields.io/npm/v/dsh-plugin-wsl-env)](https://www.npmjs.com/package/dsh-plugin-wsl-env)
7
- [![license](https://img.shields.io/npm/l/dsh-plugin-wsl-env)](LICENSE)
7
+ [![license](https://img.shields.io/npm/l/dsh-plugin-wsl-env)](../LICENSE)
8
8
 
9
9
  这个插件让 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 直接把 WSL 发行版当作工作环境使用。命令在发行版里执行,模型的文件工具读写发行版里的真实文件,打开文件夹时可以直接选择发行版目录,GUI 终端也开在发行版里,而不是开在 UNC 路径下的 `cmd.exe`。
10
10
 
11
11
  **只支持 Windows + WSL2。** 安装只有一条命令,插件自身没有依赖。WSL 环境按会话生效:会话如果打开的是 Windows 文件夹,它继续使用原来的 Windows 环境,不受影响。
12
12
 
13
- 目录:[能做什么](#能做什么) · [安装](#安装) · [使用](#使用) · [配置](#配置) · [沙箱](#沙箱) · [常见问题](#常见问题) · [已知限制](#已知限制) · [开发](#开发) · [设计说明](#设计说明)
13
+ 目录:[能做什么](#能做什么) · [安装](#安装) · [使用](#使用) · [配置](#配置) · [沙箱](#沙箱) · [常见问题](#常见问题) · [已知限制](#已知限制) · [开发](#开发) · [设计说明](#设计说明) · [参与与支持](#参与与支持)
14
14
 
15
15
  ## 能做什么
16
16
 
@@ -41,7 +41,7 @@ dsh --profile wsl # 4. 启动
41
41
 
42
42
  然后在 GUI 里打开 `\\wsl.localhost\<发行版名>\...` 下的文件夹(选择器会在根一级列出每个发行版),或者直接点 **New terminal**。
43
43
 
44
- 这个包是一个 DSH bundle:`package.json` 里声明了 `dsh.bundle.patch`,所以第 2 步会把 [`cordis.patch.yml`](cordis.patch.yml) 作为配置层加入,不需要手工合并补丁。第 1 步用 Web 模板创建 profile,原因是这一层要覆盖几个只有 Web 界面才有的行:组合层的 `subprocess` provider、终端控制器和文件夹选择器。
44
+ 这个包是一个 DSH bundle:`package.json` 里声明了 `dsh.bundle.patch`,所以第 2 步会把 [`cordis.patch.yml`](../cordis.patch.yml) 作为配置层加入,不需要手工合并补丁。第 1 步用 Web 模板创建 profile,原因是这一层要覆盖几个只有 Web 界面才有的行:组合层的 `subprocess` provider、终端控制器和文件夹选择器。
45
45
 
46
46
  还需要在发行版里安装 **bubblewrap**(`sudo apt install bubblewrap`)。没有它时每条命令都会直接失败,原因见[沙箱](#沙箱)。
47
47
 
@@ -64,7 +64,7 @@ dsh --profile wsl # 4. 启动
64
64
 
65
65
  ## 配置
66
66
 
67
- 修改配置的方式是在自己的 profile 层里按 id 覆盖某一行。文件是 `$DSH_HOME/profiles/<名字>/cordis.patch.yml`,示例见 [`examples/profile.cordis.patch.yml`](examples/profile.cordis.patch.yml)。下表中标了 *(shipped)* 的值是 [`cordis.patch.yml`](cordis.patch.yml) 里实际设置的值,其余是 schema 的默认值,列出来是因为它们比较常用。
67
+ 修改配置的方式是在自己的 profile 层里按 id 覆盖某一行。文件是 `$DSH_HOME/profiles/<名字>/cordis.patch.yml`,示例见 [`examples/profile.cordis.patch.yml`](../examples/profile.cordis.patch.yml)。下表中标了 *(shipped)* 的值是 [`cordis.patch.yml`](../cordis.patch.yml) 里实际设置的值,其余是 schema 的默认值,列出来是因为它们比较常用。
68
68
 
69
69
  | 行 | 键 | 默认值 | 说明 |
70
70
  |---|---|---|---|
@@ -145,13 +145,16 @@ wsl.exe -d <发行版> --cd <Linux 目录> --exec bwrap \
145
145
  ## 开发
146
146
 
147
147
  ```bash
148
- npm test # 语法检查 + 单元测试,无依赖,任何平台都能跑
148
+ npm test # 风格与打包检查、语法检查、单元测试
149
+ npm run test:coverage # 带覆盖率阈值的单元测试(需 Node 22.8+)
149
150
  npm run probe:sandbox # 在发行版里实测 bubblewrap 能约束什么、不能约束什么
150
151
  npm run probe # 文件系统探针,需要真实发行版(仅 Windows + WSL)
151
152
  npm run probe:sandbox-shell # 启动真实 harness,驱动受限执行器
152
153
  npm run probe:terminal # 通过终端 provider 打开一个 PTY
153
154
  ```
154
155
 
156
+ 这个包没有依赖,所以不需要先安装任何东西。
157
+
155
158
  目录结构:
156
159
 
157
160
  ```text
@@ -195,20 +198,32 @@ docs/archive/ 被本设计替换掉的方案,以及原因
195
198
 
196
199
  **运行时镜像。** checkout 在发行版内开发,但 harness 是 Windows 进程,而 profile 只能链接 Windows 路径:pnpm 会把 `link:\\wsl.localhost\...` 改写成坏掉的 `/wsl.localhost/...` 符号链接。所以 `default-workspace/dsh-plugin-wsl` 这份 Windows 副本是运行时镜像,启动应用前用 `test/probe/sync-to-windows.sh` 同步。该目标目录不在任何会话工作区内,所以 agent 在受限 shell 里执行同步时会被 `workspace-write` 拒绝,需要为这一条命令批准 `danger-full-access`。这是沙箱的预期行为,不是脚本坏了;不想看到提示就在普通 distro 终端里执行。
197
200
 
198
- **CI** 在 Linux 上用 Node 20、22、24 运行 `npm test`。
201
+ **CI** 在 Linux 和 Windows 上用 Node 20、22、24 运行 `npm test`,并在 Node 24 上运行
202
+ `npm run test:coverage` 以执行覆盖率阈值。
199
203
 
200
204
  ## 设计说明
201
205
 
202
- 有两处设计从 profile YAML 里看不出来。完整推理、实测数据和所有被放弃的方案都在归档工程记录里:[docs/archive/engineering-record.zh.md](docs/archive/engineering-record.zh.md)。它是历史文档,不是第二份 README;如果它与本文冲突,以本文为准。
206
+ 有两处设计从 profile YAML 里看不出来。完整推理、实测数据和所有被放弃的方案都在归档工程记录里:[docs/archive/engineering-record.zh.md](archive/engineering-record.zh.md)。它是历史文档,不是第二份 README;如果它与本文冲突,以本文为准。
203
207
 
204
208
  **为什么终端 provider 放在组合层。** `ctx.shell` 和 `ctx.fs` 是按会话提供的,位于 `wsl` agent preset 的 isolate realm 中。因此宿主工作区继续使用官方受限的 PowerShell 环境,WSL 工作区使用发行版,两者可以在同一个进程里同时存在。
205
209
 
206
210
  终端无法这样提供。`dsh-api-terminal-controller` 通过 `agent.ctx.get("subprocess")` 查找执行环境。Agent 的 context 由 agent loop 创建在**根** realm 之下;preset 的 isolate realm 则由 `dsh-agent-preset-registry` 创建在**注册表自身的** context 之下。这两条作用域链不会相交,所以挂在 `preset-wsl` 里的 `subprocess` provider 对终端窗口不可见。
207
211
 
208
- 因此 [`cordis.patch.yml`](cordis.patch.yml) 替换的是**组合层**的 `subprocess` 行,换成一个只覆写 `spawnTerminal` 的子类。普通的 `spawn()`、Windows 侧的 ripgrep 搜索、pwsh 执行器和 LSP 宿主都仍然走官方实现。代价是终端跟着组合走,而不是跟着会话走,见[已知限制](#已知限制)。
212
+ 因此 [`cordis.patch.yml`](../cordis.patch.yml) 替换的是**组合层**的 `subprocess` 行,换成一个只覆写 `spawnTerminal` 的子类。普通的 `spawn()`、Windows 侧的 ripgrep 搜索、pwsh 执行器和 LSP 宿主都仍然走官方实现。代价是终端跟着组合走,而不是跟着会话走,见[已知限制](#已知限制)。
209
213
 
210
214
  **为什么沙箱放在 Linux 侧。** Windows ACL runner 的受限令牌完全到不了 WSL,所以约束只能在 Windows 侧构造、在发行版内执行。`lib/sandbox.js` 因此照搬 `dsh-sandbox-local` 的 Linux `bwrap` 方案,而不是去用 `ctx.sandbox`;后者 `dsh-tool-bash` 从来不用,它读的是执行器的 `sandboxMode` 和 `ctx.sandboxPolicy`,这两样都由本插件提供。
211
215
 
216
+ ## 参与与支持
217
+
218
+ | 文档 | 内容 |
219
+ |---|---|
220
+ | [CONTRIBUTING.md](../CONTRIBUTING.md) | 开发循环、提交前必须通过的质量门、本仓库的约定 |
221
+ | [SECURITY.md](../SECURITY.md) | 如何私下上报漏洞、响应时限、以及哪些问题在范围内 |
222
+ | [SUPPORT.md](../SUPPORT.md) | 支持范围、去哪里提问、以及一份有用的缺陷报告应包含什么 |
223
+ | [docs/ARCHITECTURE.md](ARCHITECTURE.md) | provider 如何挂载、沙箱设计、测试分层 |
224
+ | [docs/RELEASING.md](RELEASING.md) | 发布检查单,含信任发布(trusted publishing)的配置 |
225
+ | [docs/archive/README.en.md](archive/README.en.md) | 归档工程记录的英文索引 |
226
+
212
227
  ## 许可
213
228
 
214
- MIT,见 [LICENSE](LICENSE)。
229
+ MIT,见 [LICENSE](../LICENSE)。
package/lib/index.js CHANGED
@@ -228,12 +228,12 @@ export class WslShellExecutor extends LocalBashExecutor {
228
228
  * @returns an absolute path to the shell inside the distro.
229
229
  */
230
230
  async shellName() {
231
- // Consumed by the shell tool after upstream change A: it names and describes
232
- // itself from the executor, so a zsh distro is never presented as bash.
233
- const shell = await this.shell();
234
- const base = String(shell ?? "").split("/").pop() ?? "";
235
- const name = base.replace(/\.exe$/i, "").replace(/^[-.]+/, "");
236
- return /^[a-z0-9_+-]+$/i.test(name) ? name : "bash";
231
+ // Consumed by the shell tool after upstream change A: it names and describes
232
+ // itself from the executor, so a zsh distro is never presented as bash.
233
+ const shell = await this.shell();
234
+ const base = String(shell ?? "").split("/").pop() ?? "";
235
+ const name = base.replace(/\.exe$/i, "").replace(/^[-.]+/, "");
236
+ return /^[a-z0-9_+-]+$/i.test(name) ? name : "bash";
237
237
  }
238
238
 
239
239
  async shell() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-wsl-env",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Run a DeepSeek Harness session against a WSL distro: a ctx.shell executor that runs commands inside the distro and a ctx.fs backend over its UNC share",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -34,14 +34,20 @@
34
34
  "cordis.patch.yml",
35
35
  "examples/**/*.yml",
36
36
  "README.md",
37
- "README.zh.md",
37
+ "docs/README.zh.md",
38
38
  "CHANGELOG.md",
39
+ "CONTRIBUTING.md",
40
+ "SECURITY.md",
41
+ "SUPPORT.md",
39
42
  "LICENSE"
40
43
  ],
41
44
  "scripts": {
42
- "test": "npm run test:syntax && npm run test:unit",
45
+ "test": "npm run lint:style && npm run test:syntax && npm run test:unit",
46
+ "test:coverage": "node --test --experimental-test-coverage --test-coverage-lines=85 --test-coverage-branches=85 --test-coverage-functions=70 test/paths.test.mjs test/listing.test.mjs test/shell.test.mjs test/terminal.test.mjs",
43
47
  "test:syntax": "node test/syntax.mjs",
44
48
  "test:unit": "node --test test/paths.test.mjs test/listing.test.mjs test/shell.test.mjs test/terminal.test.mjs",
49
+ "lint:style": "node test/style.mjs",
50
+ "prepublishOnly": "npm test",
45
51
  "probe": "bash test/probe/run.sh",
46
52
  "probe:terminal": "bash test/probe/terminal.sh",
47
53
  "probe:sandbox": "bash test/probe/sandbox.sh",
@@ -51,7 +57,14 @@
51
57
  "engines": {
52
58
  "node": ">=20"
53
59
  },
54
- "packageManager": "pnpm@11.7.0",
60
+ "author": {
61
+ "name": "Andy Zhao",
62
+ "url": "https://github.com/Big-Dao"
63
+ },
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "registry": "https://registry.npmjs.org/"
67
+ },
55
68
  "license": "MIT",
56
69
  "repository": {
57
70
  "type": "git",