dsh-plugin-wsl-env 0.24.0 → 0.25.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +6 -3
  3. package/SECURITY.md +10 -0
  4. package/cordis.patch.yml +4 -0
  5. package/docs/ARCHITECTURE.md +28 -9
  6. package/docs/CONFIGURATION.md +43 -0
  7. package/docs/CONFIGURATION.zh.md +36 -0
  8. package/docs/DIAGNOSTICS.md +4 -2
  9. package/docs/DIAGNOSTICS.zh.md +3 -1
  10. package/docs/LIMITATIONS.md +17 -4
  11. package/docs/LIMITATIONS.zh.md +11 -3
  12. package/docs/MIGRATION.md +1 -1
  13. package/docs/PEER-PARITY.md +4 -4
  14. package/docs/QUICKSTART.md +12 -5
  15. package/docs/QUICKSTART.zh.md +8 -2
  16. package/docs/README.zh.md +6 -3
  17. package/docs/RELEASING.md +17 -13
  18. package/docs/REQUIREMENTS.zh.md +3 -2
  19. package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
  20. package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
  21. package/docs/root-fs-routing.md +1 -1
  22. package/lib/agent-confined.d.ts +7 -1
  23. package/lib/agent-confined.js +3 -3
  24. package/lib/bwrap.d.ts +14 -0
  25. package/lib/bwrap.js +11 -0
  26. package/lib/cwd-prompt.d.ts +41 -3
  27. package/lib/cwd-prompt.js +125 -8
  28. package/lib/doctor-report.d.ts +50 -0
  29. package/lib/doctor-report.js +172 -0
  30. package/lib/fs-routing.d.ts +1 -1
  31. package/lib/fs-routing.js +1 -1
  32. package/lib/fs.d.ts +1 -1
  33. package/lib/fs.js +1 -1
  34. package/lib/index.d.ts +6 -1464
  35. package/lib/index.js +5 -2120
  36. package/lib/messages.d.ts +1 -1
  37. package/lib/messages.js +3 -3
  38. package/lib/preflight.d.ts +7 -4
  39. package/lib/preflight.js +27 -13
  40. package/lib/provider-common.d.ts +58 -0
  41. package/lib/provider-common.js +123 -0
  42. package/lib/sandbox-core.d.ts +1 -0
  43. package/lib/sandbox-core.js +4 -2
  44. package/lib/session-runtime.d.ts +7 -1
  45. package/lib/session-runtime.js +9 -2
  46. package/lib/shell.d.ts +1 -1
  47. package/lib/shell.js +1 -1
  48. package/lib/writable-roots.d.ts +109 -0
  49. package/lib/writable-roots.js +257 -0
  50. package/lib/wsl-doctor-tool.js +2 -2
  51. package/lib/wsl-filesystem.d.ts +692 -0
  52. package/lib/wsl-filesystem.js +897 -0
  53. package/lib/wsl-shell.d.ts +742 -0
  54. package/lib/wsl-shell.js +965 -0
  55. package/lib/wsl.d.ts +1 -1
  56. package/lib/wsl.js +1 -1
  57. package/package.json +4 -3
  58. package/scripts/doctor.mjs +1 -1
  59. package/scripts/profile-preset.mjs +17 -5
package/CHANGELOG.md CHANGED
@@ -16,6 +16,58 @@ were part of the record.
16
16
 
17
17
  ## [Unreleased]
18
18
 
19
+ ## [0.25.0] - 2026-11-11
20
+
21
+ One theme: the model reads its prompt facts in the distro's own terms, and
22
+ `workspace-write` can grant the toolchain caches the policy had always
23
+ advertised.
24
+
25
+ ### Added
26
+
27
+ - **`writableRoots` on `wsl-shell` and `wsl-fs`.** `workspace-write` still grants
28
+ only the session workspace and the temp areas by default, but a row can now
29
+ name extra distro directories to bind read-write — the package-manager caches
30
+ npm, pnpm and cargo write under `$HOME`, and a linked worktree's shared Git
31
+ directory. Entries accept `~`/`~/...` and absolute Linux paths, must be
32
+ existing physical directories, and are ignored when already writable inside
33
+ the workspace, `/tmp` or `/dev/shm`, or nested inside another grant. The two
34
+ rows should carry the same list. `pnpm run preset --writable-roots
35
+ '~/.npm,~/.cache'` writes it into both nested rows of the printed block.
36
+ CONFIGURATION documents the cache recipes and the security trade-off.
37
+
38
+ - **Prompt adapters for the Windows-shaped prompt facts.** A WSL session now
39
+ carries a one-sentence `wsl:shell` note (the shell tool is named `bash` but
40
+ runs the distro's login shell with `-lc`), a POSIX-only `sandbox:policy` line
41
+ built from `ctx.sandboxPolicy` (mode, workspace and `additionalWritableRoots`,
42
+ no UNC path, plus the conditional `partial` enforcement note), and no
43
+ `harness:source` value — the host's `app.asar` Windows path is not a readable
44
+ checkout from the distro. The adapters are temporary and each names the
45
+ upstream change that retires it in
46
+ [docs/UPSTREAM-PROMPT-ADAPTERS.md](docs/UPSTREAM-PROMPT-ADAPTERS.md).
47
+
48
+ ### Changed
49
+
50
+ - **A ready preflight verdict is log-only.** Only a blocked `wsl-preflight`
51
+ verdict reaches the session's runtime context, and its remedy is marked as
52
+ operator action (ask the user before running anything). "The prerequisite is
53
+ usable" is not a model action; it stays in the host log, which still carries
54
+ the verdict on every session.
55
+ - **`ready` no longer promises the next command.** The `wsl_doctor` tool
56
+ description and its ready note say ready covers the checks in that run; the
57
+ older "the first command should succeed" was a step past what the probes
58
+ prove. The doctor and quickstart docs, and both READMEs, state the same.
59
+
60
+ ### Fixed
61
+
62
+ - **Confined WSL operations now honor the policy's `additionalWritableRoots`.**
63
+ The fence accepted a same-distro UNC extra root while the bwrap profile (and
64
+ the confined-write resident's cache key) dropped it, so an approved write
65
+ failed with `EROFS` or `FS_IO_ERROR`; a Linux-spelled entry was refused by the
66
+ fence even though it is the execution-world spelling. Both sources now resolve
67
+ through `lib/writable-roots.js` into one effective Linux list used by the
68
+ command profile, the confined-write resident and the session runtime, and the
69
+ session-runtime keys include the grants.
70
+
19
71
  ## [0.24.0] - 2026-11-10
20
72
 
21
73
  One theme: the diagnosis becomes something to act on — a sidebar panel
package/README.md CHANGED
@@ -48,7 +48,7 @@ A Windows coding tool that works on WSL projects has three options: run the whol
48
48
  - **No service in the distro.** There is no helper server, no daemon and no listening port. The only persisted artifact is a content-addressed copy of the native agent in `~/.cache/dsh-wsl/agent/`.
49
49
  - **Sandboxed by default.** Confined commands run under `bubblewrap` inside the distro. If `bubblewrap` is missing, the command fails; it does not run unconfined.
50
50
  - **Per-session.** A session opened on a distro folder gets the distro environment. A session opened on a Windows folder keeps the normal Windows tools. Both can run in one harness process.
51
- - **Integrated with the GUI.** The folder picker lists installed distros, the terminal opens a shell in the distro, and the model can see listening ports. The sidebar's **WSL environment** panel runs a quick doctor check per distro — host-side, no model turn — and the session-start preflight announces the environment verdict on every session.
51
+ - **Integrated with the GUI.** The folder picker lists installed distros, the terminal opens a shell in the distro, and the model can see listening ports. The sidebar's **WSL environment** panel runs a quick doctor check per distro — host-side, no model turn — and the session-start preflight logs the environment verdict on every session, adding a blocked verdict to the session's context.
52
52
 
53
53
  ### Why Linux, not PowerShell
54
54
 
@@ -115,7 +115,7 @@ Install `bubblewrap` before the first command:
115
115
  wsl.exe -d <distro> -u root -- apt-get install -y bubblewrap
116
116
  ```
117
117
 
118
- From a checkout, `pnpm run doctor` is the one-command environment check: the Windows/WSL platform, the per-distro WSL mode and identity, `.wslconfig` and `/etc/wsl.conf` cross-checks, the distro and host volumes, clock and DNS, bubblewrap usability, systemd / the user manager / Linger, the optional tools, peer versions, the native agent and its cache, a fresh-agent handshake, the shell smoke legs that prove the chain (frame I/O, the confined fence, the batched substrate) and a native HELLO leg, stale session scopes, and the known profile-patch and deprecated-key traps. The report itemizes every check — grouped by distro, each with an explicit status marker and a copy-paste remedy under every failure — and ends in a verdict, `ready` (the first command should succeed) or `blocked` (the named checks to fix), computed under the effective configuration. A run can be scoped: `--quick` probes the first-command prerequisites only (~10 s), `--sections <list>` (comma-separated) runs the named sections, and a scoped report lists the checks it did not run as explicit skips. `--json` is the machine contract; `--fix` re-verifies what it fixed — the plugin-owned stale-scope sweep and agent-cache purge are safe and automatic, packages need `--fix --install` and an explicit confirmation, and `--fix-owned` narrows a run to the plugin-owned two — `--all` checks every installed distro, and `--bundle <path>` writes the diagnostic file a setup report attaches (`--redact` strips the paths). The fixed skeleton renders in the host's language — detected from the Windows locale, overridable with `--locale <tag>` or `DSH_WSL_DOCTOR_LOCALE`; `--json` stays language-independent. The same report answers through three surfaces: this CLI, the `/wsl-doctor` command (typed in the composer — host-side, no model turn), and the `wsl_doctor` model tool (in-process, merging the live resident's state). `DSH_WSL_DOCTOR` additionally carries a ready-to-run command (`sh -c "$DSH_WSL_DOCTOR --json"`) that replays the doctor inside the distro. `pnpm run diagnose` is the CLI's read-only alias. `pnpm run bootstrap <distro>` remains the narrower tool-install helper.
118
+ From a checkout, `pnpm run doctor` is the one-command environment check: the Windows/WSL platform, the per-distro WSL mode and identity, `.wslconfig` and `/etc/wsl.conf` cross-checks, the distro and host volumes, clock and DNS, bubblewrap usability, systemd / the user manager / Linger, the optional tools, peer versions, the native agent and its cache, a fresh-agent handshake, the shell smoke legs that prove the chain (frame I/O, the confined fence, the batched substrate) and a native HELLO leg, stale session scopes, and the known profile-patch and deprecated-key traps. The report itemizes every check — grouped by distro, each with an explicit status marker and a copy-paste remedy under every failure — and ends in a verdict, `ready` (every check that run covered passed — not a promise about a later command) or `blocked` (the named checks to fix), computed under the effective configuration. A run can be scoped: `--quick` probes the first-command prerequisites only (~10 s), `--sections <list>` (comma-separated) runs the named sections, and a scoped report lists the checks it did not run as explicit skips. `--json` is the machine contract; `--fix` re-verifies what it fixed — the plugin-owned stale-scope sweep and agent-cache purge are safe and automatic, packages need `--fix --install` and an explicit confirmation, and `--fix-owned` narrows a run to the plugin-owned two — `--all` checks every installed distro, and `--bundle <path>` writes the diagnostic file a setup report attaches (`--redact` strips the paths). The fixed skeleton renders in the host's language — detected from the Windows locale, overridable with `--locale <tag>` or `DSH_WSL_DOCTOR_LOCALE`; `--json` stays language-independent. The same report answers through three surfaces: this CLI, the `/wsl-doctor` command (typed in the composer — host-side, no model turn), and the `wsl_doctor` model tool (in-process, merging the live resident's state). `DSH_WSL_DOCTOR` additionally carries a ready-to-run command (`sh -c "$DSH_WSL_DOCTOR --json"`) that replays the doctor inside the distro. `pnpm run diagnose` is the CLI's read-only alias. `pnpm run bootstrap <distro>` remains the narrower tool-install helper.
119
119
 
120
120
  The plugin notices its own updates about once a day (first check 2–10 minutes after startup) by asking the app's plugin manager — it never fetches on its own. When a newer stable release exists, the managed `DSH_WSL_PLUGIN_UPDATE` variable in every distro session carries the fact; `wsl-update-check.enabled: false` in the patch config turns the check off. Upgrading stays manual, because the harness has no hot reload: install again (Plugins page, or the `add` command), then restart. Uninstall on
121
121
  the Plugins page, or with `dsh plugin --profile wsl remove dsh-plugin-wsl-env`
@@ -146,11 +146,13 @@ Settings live on named rows in `$DSH_HOME/profiles/<name>/cordis.patch.yml`. The
146
146
  | | `sessionSandbox` | `false`; shipped `true` | run the session's commands in one systemd user scope |
147
147
  | | `agentBackend` | `auto` | `auto`, `native` or `shell` for the in-distro agent |
148
148
  | | `maskWindowsDrive` | `false` | hide `/mnt` from confined commands |
149
+ | | `writableRoots` | `[]` | extra distro directories to grant (toolchain caches; put the same list on `wsl-fs`) |
149
150
  | `wsl-fs` | `distro` | `''` | distro mode; empty/`auto` follows each target path |
150
151
  | | `restrictToDistro` | `true` | under a fixed distro, refuse paths that belong to another distro |
151
152
  | | `sandbox` | `true` | check confined writes against the policy |
152
153
  | | `sessionSandbox` | `false`; shipped `true` | run confined writes in the session runtime |
153
154
  | | `substrate` | `agent` | in-distro agent; `share` is rejected at startup |
155
+ | | `writableRoots` | `[]` | the same extra-writable list as `wsl-shell` |
154
156
  | `directory-picker-wsl` | `includeHostHome` | `true` | also offer the Windows path branch (starting at the drives) |
155
157
  | `subprocess-wsl` | `distro` | `''` | distro mode; empty/`auto` follows the launch directory |
156
158
  | `wsl-preflight` | `distro` | `''` | distro the environment checks probe; empty/`auto` follows the session workspace |
@@ -189,7 +191,7 @@ wsl preset (per session)
189
191
  | Mode | What a command can do |
190
192
  |---|---|
191
193
  | `read-only` | read the whole distro; a fresh `/dev` is mounted, nothing else is writable |
192
- | `workspace-write` | the above, plus the session workspace; `/tmp` is the distro's real `/tmp` with the session runtime |
194
+ | `workspace-write` | the above, plus the session workspace and any configured `writableRoots`; `/tmp` is the distro's real `/tmp` with the session runtime |
193
195
  | `danger-full-access` | no sandbox |
194
196
 
195
197
  With `sessionSandbox: false`, a `workspace-write` command gets a private `/tmp` instead of the distro's real one. `read-only` does not mount a writable `/tmp`.
@@ -205,6 +207,7 @@ Enforcement is reported as `partial`. A command inside the distro can still star
205
207
  | every command reports `SANDBOX_UNAVAILABLE` | install `bubblewrap` in the distro, or set `sandbox: false` |
206
208
  | the session refuses before the first command | run `pnpm run doctor`; enable systemd and linger, or set `sessionSandbox` to `auto` or `false` on `wsl-shell` and `wsl-fs` |
207
209
  | `glob` and `grep` are slow in the distro | run `pnpm run bootstrap <distro>` and use its printed install command to install `ripgrep` |
210
+ | `npm install` / `pnpm add` fail with `EROFS` | the sandbox grants only the workspace by default; configure `writableRoots` on `wsl-shell` and `wsl-fs` (e.g. `~/.npm`, `~/.cache`, `~/.local/share/pnpm`); see [CONFIGURATION](docs/CONFIGURATION.md#toolchain-caches-and-extra-writable-roots) |
208
211
  | `dsh plugin add` prints nothing, or the Plugins page finishes without feedback | trust the profile's `package.json` and its `dsh.profile.bundles` entry: the plugin listed there is installed |
209
212
  | a profile patch for `wsl-shell`/`wsl-fs` changes nothing | those rows are nested inside `preset-wsl`. Run `pnpm run preset --check <patch>`; it fails with the complete block to paste |
210
213
  | changes under `lib/` have no effect | run `pnpm run sync:windows`, then restart the app |
package/SECURITY.md CHANGED
@@ -103,6 +103,16 @@ A report is still welcome if you find an escape that does not depend on interop,
103
103
  if the masked profile is bypassable from `/mnt`, or if the plugin ever reports
104
104
  `full` while interop is reachable.
105
105
 
106
+ One escape of that kind is known and unfixed: a confined command can ask the
107
+ distro user's own service manager to start a unit, and that unit runs outside the
108
+ mount profile — a write to the distro user's home succeeds where the same write
109
+ from inside the fence is refused. Masking `/mnt` does not narrow this path
110
+ because it never involves interop. The socket paths and the reproduction steps are
111
+ withheld until a fix ships; the finding, its verification and the deferred
112
+ decision are recorded in
113
+ [docs/superpowers/value-discovery-2026-11-10.md](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/docs/superpowers/value-discovery-2026-11-10.md)
114
+ (E4). Report new instances through the private channel above, as with any escape.
115
+
106
116
  ## Credentials
107
117
 
108
118
  No credential, token, or private key belongs in this repository. That includes npm
package/cordis.patch.yml CHANGED
@@ -341,6 +341,8 @@
341
341
  # shipped shell agent. native fails the first command instead
342
342
  # of falling back; shell forces the shell agent.
343
343
  agentBackend: auto
344
+ # 工具链缓存等额外可写目录;默认空。示例(与 wsl-fs 配同一列表):
345
+ # writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
344
346
  - id: wsl-fs
345
347
  name: 'dsh-plugin-wsl-env/fs'
346
348
  config:
@@ -357,6 +359,8 @@
357
359
  # Confined writes ride the session runtime (ADR 0001), so they
358
360
  # share the command's real /tmp and workspace mounts.
359
361
  sessionSandbox: true
362
+ # 与 wsl-shell 的 writableRoots 保持同一列表;见 CONFIGURATION。
363
+ # writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
360
364
  - id: persona
361
365
  name: '@deepseek-ai/dsh-persona'
362
366
  config:
@@ -19,8 +19,8 @@ smaller integrations listed below.
19
19
 
20
20
  | Service | Class | File | What it does |
21
21
  |---|---|---|---|
22
- | `ctx.shell` | `WslShellExecutor` | [`lib/index.js`](../lib/index.js) | Runs each command in the distro's login shell over the resident in-distro agent (the default), wrapped in a distro-side `bwrap` sandbox; while the agent is out, or with `agent: false`, the same command falls back to one `wsl.exe -d <distro> --cd <linux dir> --exec <login shell> -lc <cmd>` process. |
23
- | `ctx.fs` | `WslFileSystem` | [`lib/index.js`](../lib/index.js) | Serves WSL-routed file operations through the resident in-distro agent; the former Windows-side share substrate is retired (see below). |
22
+ | `ctx.shell` | `WslShellExecutor` | [`lib/wsl-shell.js`](../lib/wsl-shell.js) | Runs each command in the distro's login shell over the resident in-distro agent (the default), wrapped in a distro-side `bwrap` sandbox; while the agent is out, or with `agent: false`, the same command falls back to one `wsl.exe -d <distro> --cd <linux dir> --exec <login shell> -lc <cmd>` process. |
23
+ | `ctx.fs` | `WslFileSystem` | [`lib/wsl-filesystem.js`](../lib/wsl-filesystem.js) | Serves WSL-routed file operations through the resident in-distro agent; the former Windows-side share substrate is retired (see below). |
24
24
  | `ctx.subprocess` | `WslSubprocessRuntime` | [`lib/subprocess.js`](../lib/subprocess.js) | Opens the GUI terminal inside the distro, in the session workspace, and rewrites the file-search and git-snapshot spawns into the distro (see below). |
25
25
 
26
26
  `WslShellExecutor` extends the shipped `LocalBashExecutor`, and `WslFileSystem`
@@ -70,18 +70,23 @@ functions.
70
70
  | `dsh-plugin-wsl-env/shell-env` | `wsl-shell-env` | [`lib/shell-env.js`](../lib/shell-env.js) | Contributes `DSH_WSL_DISTRO`, `DSH_WSL_SHELL`, `DSH_WSL_HOME` and `DSH_WSL_PORTS` to the managed `DSH_*` namespace, choosing the session workspace's distro (default/pinned facts are probed at mount; other distros are warmed when their session appears). The port list is a snapshot per active distro, refreshed every `portsRefreshMs` (10000 by default), so a server started moments ago may not be listed yet. |
71
71
  | `dsh-plugin-wsl-env/preflight` | `wsl-preflight` | [`lib/preflight.js`](../lib/preflight.js) | Runs the environment advisory at session start — and, with `startup: true` (the default), once at plugin load — surfacing the doctor-style verdict as a non-gating warning. |
72
72
  | `dsh-plugin-wsl-env/update-check` | `wsl-update-check` | [`lib/update-check.js`](../lib/update-check.js) | Asks the app's plugin manager about a newer stable release about once a day and carries the fact in `DSH_WSL_PLUGIN_UPDATE`; never fetches on its own. |
73
- | `dsh-plugin-wsl-env/cwd-prompt` | `wsl-cwd-prompt` | [`lib/cwd-prompt.js`](../lib/cwd-prompt.js) | Rewrites the runtime context's working-directory entry to the distro's POSIX form. |
73
+ | `dsh-plugin-wsl-env/cwd-prompt` | `wsl-cwd-prompt` | [`lib/cwd-prompt.js`](../lib/cwd-prompt.js) | Rewrites the runtime context's working-directory entry to the distro's POSIX form; adds the one-sentence `wsl:shell` note; replaces `sandbox:policy` with a POSIX-only rendering; and suppresses the host `harness:source` value in WSL sessions. The last three are temporary adapters tracked in [UPSTREAM-PROMPT-ADAPTERS.md](UPSTREAM-PROMPT-ADAPTERS.md). |
74
74
  | `dsh-plugin-wsl-env/cwd-prompt-tool` | `wsl-cwd-prompt-tool` | [`lib/cwd-prompt-tool.js`](../lib/cwd-prompt-tool.js) | Serves the model's read/`cd` tool with the same semantics the harness ships, rewriting the returned `cwd` to the distro's POSIX form. |
75
75
  | `dsh-plugin-wsl-env/wsl-doctor-tool` | `wsl-doctor-tool` | [`lib/wsl-doctor-tool.js`](../lib/wsl-doctor-tool.js) | The `wsl_doctor` model tool: the doctor in-process (merging the live resident's state), scoped by `depth`/`section`, rendered as the itemized digest. |
76
76
  | `dsh-plugin-wsl-env/wsl-doctor-command` | `wsl-doctor-command` | [`lib/wsl-doctor-command.js`](../lib/wsl-doctor-command.js) | The `/wsl-doctor` UI command: spawns the standalone doctor CLI as a host subprocess and renders the same digest detached from model history. |
77
77
  | `dsh-plugin-wsl-env/status` | `wsl-status` | [`lib/status.js`](../lib/status.js) | The sidebar panel's route (`GET /api/wsl-env/status`): lists the installed distros and runs one distro's quick doctor; `POST` on the same route runs the full doctor with `--fix-owned` (labeled repair when stale scopes or a broken agent cache are repairable, a full check otherwise; both re-verified). Answered over the Host connection's authenticated exact-Fetch channel; the last result per distro is persisted under `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json` and stored results for running distros are refreshed in the background. |
78
78
  | `dsh-plugin-wsl-env` (bare name) | `wsl-env-client-host` | [`lib/client-host.js`](../lib/client-host.js) | The deliberate no-op host half whose bare-name mount lets the web client roster serve `./client`: the sidebar's WSL environment panel and the post-add access-mode prompt. |
79
79
 
80
- Three modules support them and import no DSH package.
80
+ Three path and interop helpers import no DSH package.
81
81
  [`lib/paths.js`](../lib/paths.js) translates paths.
82
82
  [`lib/listing.js`](../lib/listing.js) builds directory listings and breadcrumbs.
83
83
  [`lib/wsl.js`](../lib/wsl.js) holds the `wsl.exe` interop primitives.
84
84
 
85
+ [`lib/provider-common.js`](../lib/provider-common.js) is provider glue rather
86
+ than a peer-free helper: it imports `@deepseek-ai/dsh-sandbox` and shares distro
87
+ resolution, home caching, runtime selection and writable-root translation
88
+ between the shell and filesystem providers.
89
+
85
90
  ## How the pieces are mounted
86
91
 
87
92
  [`cordis.patch.yml`](../cordis.patch.yml) is the bundle layer. It is a top-level
@@ -223,7 +228,7 @@ distro, and the argv is the same either way:
223
228
  ```text
224
229
  wsl.exe -d <distro> --cd <linux dir> --exec bwrap \
225
230
  --ro-bind / / --dev /dev --unshare-pid --proc /proc --die-with-parent \
226
- [--tmpfs /tmp --bind <workspace> <workspace>] [--tmpfs /mnt] -- <shell> -lc <cmd>
231
+ [--tmpfs /tmp --bind <workspace> <workspace> [--bind <root> <root> ...]] [--tmpfs /mnt] -- <shell> -lc <cmd>
227
232
  ```
228
233
 
229
234
  By default the profile wraps the session's resident agent ONCE, under
@@ -244,10 +249,19 @@ cannot be read or exfiltrated and its executables cannot be launched through
244
249
  interop. The option is off by default; [CONFIGURATION.md](CONFIGURATION.md) lists
245
250
  the row keys, and `lib/sandbox-core.js` states its honest ceiling.
246
251
 
252
+ The optional `--bind <root> <root>` pairs come from the row's `writableRoots`
253
+ and the shared policy's `additionalWritableRoots`. `lib/writable-roots.js`
254
+ resolves them (`~` expansion, UNC/Linux spelling), drops entries already
255
+ writable under the workspace, `/tmp` or `/dev/shm` and entries nested inside
256
+ another grant, then checks once per process that each remaining root is an
257
+ existing physical directory. The same effective list goes into the command
258
+ profile, the confined-write resident and the session runtime — and into their
259
+ cache keys, because the mount table is fixed for an agent's lifetime.
260
+
247
261
  | Mode | What a command inside the distro can do |
248
262
  |---|---|
249
263
  | `read-only` | read the whole distro; a fresh `/dev` is mounted writable, so `/dev/null` and `/dev/shm` work, and nothing else does |
250
- | `workspace-write` | the above, plus the session workspace is writable; `/tmp` is the distro's real `/tmp` in the session runtime, and a fresh tmpfs in the per-command profile (`sessionSandbox: false`) |
264
+ | `workspace-write` | the above, plus the session workspace and any explicitly granted roots are writable; `/tmp` is the distro's real `/tmp` in the session runtime, and a fresh tmpfs in the per-command profile (`sessionSandbox: false`) |
251
265
  | `danger-full-access` | no sandbox; used for an approved wider-permission request |
252
266
 
253
267
  `WslFileSystem` checks writes against the same policy and the same writable list,
@@ -320,11 +334,12 @@ own dialect, described after the table.
320
334
  | Code | Raised by | Meaning | What clears it |
321
335
  |---|---|---|---|
322
336
  | `SANDBOX_UNAVAILABLE` | `WslSandbox.confine` | the requested mode cannot be enforced: no usable `bwrap` in the distro | install `bubblewrap` there (a failed probe is re-run, so no restart is needed), or set `sandbox: false` |
337
+ | `SANDBOX_INVALID_ROOT` | `effectiveWritableRoots` (both providers) | an entry in `writableRoots` or `additionalWritableRoots` is malformed, names another world, or fails the one-time physical-directory check | fix the entry; create the directory inside the distro first, use an absolute Linux path or `~/...`, and use the physical directory rather than a symlink |
323
338
  | `FS_SANDBOX_DENIED` | `WslFileSystem.checkedTarget`, and `lib/fsio-agent.js` (a write the confined resident's mount table refused, classified from the kernel's `read-only file system`) | the file-effect policy refused the write: `read-only`, or a target outside the writable roots — or the kernel refused it at the resident's profile | a wider permission for that one call, or a session workspace that contains the target |
324
339
  | `FS_OUTSIDE_DISTRO` | `WslFileSystem.worldPath` | `distro` is fixed (`default` or a name), `restrictToDistro` is on, and the path names **another distro**'s share — a configuration fence, not a sandbox decision. With `distro: ''`/`auto` a UNC target is served by its own distro, so the fence has nothing foreign to refuse | set `distro` to `''`/`auto` (the default), or open a session in that distro. A wider permission does **not** lift it |
325
340
  | `FS_NOT_OBSERVED` | `lib/fs-substrate.js` (`writeText`; the agent's `exists` conclusion, mapped in `lib/fsio-agent.js`) | a guarded create (`createIfAbsent`) targeted a file that exists and had not been read first | read the file, then overwrite with the version guard or edit it |
326
341
  | `FS_STALE_VERSION` | `lib/fs-substrate.js` (`writeText`, `editText`; the agent's `stale` conclusion, mapped in `lib/fsio-agent.js`) | the version the caller holds no longer matches: the file changed, or is gone | read it again and retry with the fresh version |
327
- | `FS_IO_ERROR` | the filesystem stack: `lib/fs-decisions.js` (the substrate is unavailable), `lib/fsio-agent.js` (a `perm`/`loop`/`io` reason or a malformed record), `lib/index.js` (a path that cannot be mapped, or a `SandboxUnavailableError`), and `WslFileSystem.watch` | the catch-all I/O failure — most often the resident agent is out or the distro returned an I/O error, the "agent outage fails closed" case above. A watch target outside the selected distro is the narrow one | get the resident back (check `wsl.exe -l -v`, then restart the session); for a watch, aim it at a distro path — the watch itself runs where the files live (`lib/watcher.js`) |
342
+ | `FS_IO_ERROR` | the filesystem stack: `lib/fs-decisions.js` (the substrate is unavailable), `lib/fsio-agent.js` (a `perm`/`loop`/`io` reason or a malformed record), `lib/wsl-filesystem.js` (a path that cannot be mapped, or a `SandboxUnavailableError`), and `WslFileSystem.watch` | the catch-all I/O failure — most often the resident agent is out or the distro returned an I/O error, the "agent outage fails closed" case above. A watch target outside the selected distro is the narrow one | get the resident back (check `wsl.exe -l -v`, then restart the session); for a watch, aim it at a distro path — the watch itself runs where the files live (`lib/watcher.js`) |
328
343
  | `FS_NOT_FOUND` | `lib/fsio-agent.js` and `lib/fs-substrate.js` (the agent's `notfound`/`notdir` conclusion, an empty path, or a missing edit target), and the host filesystem stack behind a drive path | the path does not exist — the ordinary answer | — |
329
344
  | `FS_NOT_REGULAR_FILE` | `lib/fsio-agent.js`, `lib/fs-substrate.js` | the target is not a regular file where one is required: a directory, symlink or device on a read, or a non-file target on a write | point the call at a regular file |
330
345
  | `FS_NOT_DIRECTORY` | `lib/fsio-agent.js` (`listChildren`) | the target is not a directory, so there are no children to list | list a directory |
@@ -448,7 +463,7 @@ src/bwrap.ts the bwrap command line every confinement site
448
463
  assert it)
449
464
  src/client-host.ts the bare-name host half — a deliberate no-op that
450
465
  anchors the browser client
451
- src/cwd-prompt.ts rewrites the runtime context's working directory
466
+ src/cwd-prompt.ts rewrites the working directory; applies the temporary prompt adapters
452
467
  to the distro's POSIX form
453
468
  src/cwd-prompt-tool.ts serves the model's read/cd tool with distro-POSIX
454
469
  cwd output
@@ -469,7 +484,11 @@ src/fsio-text.ts the peer's pure text mechanics, replicated pending
469
484
  src/git-exec.ts the agent-backed execution handle for the
470
485
  git-snapshot spawn
471
486
  src/git-route.ts which git spawns belong inside the distro (pure)
472
- src/index.ts WslShellExecutor (ctx.shell) and WslFileSystem (ctx.fs)
487
+ src/index.ts public provider exports
488
+ src/wsl-shell.ts WslShellExecutor (ctx.shell)
489
+ src/wsl-filesystem.ts WslFileSystem (ctx.fs)
490
+ src/doctor-report.ts in-process doctor collector used by the tool
491
+ src/provider-common.ts distro, home, runtime and writable-root helpers
473
492
  src/listing.ts pure directory listing and breadcrumb helpers
474
493
  src/messages.ts the en/zh message catalogs and the host-locale wiring
475
494
  src/native-agent.ts native binary selection and preparation
@@ -68,6 +68,7 @@ after a plugin upgrade that changes the preset.
68
68
  | `sandbox` | `true` | Confine commands with `bwrap`. A missing or unusable `bwrap` fails closed. `false` runs commands without confinement. |
69
69
  | `interopVisibility` | Unset; effective default is `visible` | `visible`, `masked`, or `disabled`. When set, this takes precedence over `maskWindowsDrive`. See [Windows interop](#windows-interop). |
70
70
  | `maskWindowsDrive` | `false` | For confined commands, mount an empty tmpfs over `/mnt`. See [Windows interop](#windows-interop). |
71
+ | `writableRoots` | `[]` | Extra distro directories granted read-write under `workspace-write` (`~` allowed), for toolchain caches or a linked worktree's shared Git directory. Each entry must be an existing physical directory; entries already inside the workspace, `/tmp` or `/dev/shm`, or nested inside another grant, are ignored. Put the same list on `wsl-fs`. See [Toolchain caches](#toolchain-caches-and-extra-writable-roots). |
71
72
  | `cwd` | `''` | Default workdir. Empty uses the distro user's home. |
72
73
  | `timeoutMs` / `maxTimeoutMs` | `120000` / `600000` (shipped) | Default per-call timeout and the maximum timeout a call may request. |
73
74
  | `wslPath` | `wsl.exe` | Path to `wsl.exe`. |
@@ -83,12 +84,54 @@ after a plugin upgrade that changes the preset.
83
84
  | `sandbox` | `true` | Check writes against the sandbox policy. Confined writes fail closed if `bwrap` is unavailable. |
84
85
  | `sessionSandbox` | `false`; shipped `true` | Use the same session runtime as `wsl-shell`. `auto` falls back to a per-policy confined resident when the session runtime is unavailable. |
85
86
  | `maskWindowsDrive` | `false` | Hide `/mnt` from confined mutations. Reads are unaffected. |
87
+ | `writableRoots` | `[]` | Same key and rules as on `wsl-shell`. Confined writes and commands must see one mount table, so configure the same list on both rows. See [Toolchain caches](#toolchain-caches-and-extra-writable-roots). |
86
88
  | `substrate` | `agent` (shipped) | File operations use the in-distro agent. The legacy `share` value is refused at startup. |
87
89
  | `cwd` | `''` | Base directory for relative paths. Empty uses the distro user's home. |
88
90
  | `watchMaxDepth` | `0` | Watch the full tree. A positive depth uses bounded polling and can miss changes below the bound until a change above it triggers the callback. |
89
91
  | `wslPath` | `wsl.exe` | Path to `wsl.exe`. |
90
92
  | `diffBasisMaxBytes` | `10485760` | UTF-8 byte limit per side of an overwrite diff. Larger files are written without a diff. |
91
93
 
94
+ ### Toolchain caches and extra writable roots
95
+
96
+ The default `workspace-write` grants only the session workspace and the temp
97
+ areas (`/tmp`, the distro's real `/tmp` under the session runtime). npm, pnpm,
98
+ cargo and friends keep their package caches under `$HOME`, so installing a
99
+ dependency that is not already cached fails with `EROFS`. Configure the same
100
+ list on the **nested** `wsl-shell` and `wsl-fs` rows; `pnpm run preset
101
+ --writable-roots '~/.npm,~/.cache'` writes both into the printed `preset-wsl`
102
+ block, or edit the block by hand:
103
+
104
+ ```yaml
105
+ - id: wsl-shell
106
+ config:
107
+ writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
108
+ - id: wsl-fs
109
+ config:
110
+ writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
111
+ ```
112
+
113
+ Rules:
114
+
115
+ - `~` and `~/...` expand against the distro user's home; every other entry must
116
+ be an absolute Linux path.
117
+ - The directory must already exist and must be a physical directory (symlinks
118
+ are refused). Create it with `mkdir -p` first, or let one unconfined command
119
+ create it.
120
+ - Entries already inside the workspace, `/tmp` or `/dev/shm`, or nested inside
121
+ another grant, are ignored: they are already writable, and binding them would
122
+ only add a symlink-redirection risk.
123
+ - Keep both rows equal; otherwise commands and confined writes can see
124
+ different mount tables, and the session runtime keys diverge.
125
+ - It applies only to `workspace-write`. `read-only` ignores it, and
126
+ `danger-full-access` does not go through the sandbox at all.
127
+ - Security boundary: executable content in a granted directory (for example a
128
+ package cache's binaries) can be used by a later build or command. This is an
129
+ explicit narrowing of the sandbox, not a way to turn it off; `enforcement`
130
+ stays `partial`.
131
+ - The shared `sandboxPolicy.additionalWritableRoots` is honored too (same-distro
132
+ UNC or Linux spelling), but it applies to the whole profile. When the same
133
+ profile also serves Windows sessions, prefer the plugin key above.
134
+
92
135
  ### `fs-routing`
93
136
 
94
137
  This top-level row serves root-level `ctx.fs` calls. It routes distro UNC paths
@@ -65,6 +65,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
65
65
  | `sandbox` | `true` | 用 `bwrap` 约束命令。`bwrap` 缺失或不可用时关闭(fail closed)。`false` 则不加约束地运行命令。 |
66
66
  | `interopVisibility` | 未设置;有效默认值为 `visible` | `visible`、`masked` 或 `disabled`。设置后优先于 `maskWindowsDrive`。见 [Windows interop](#windows-interop)。 |
67
67
  | `maskWindowsDrive` | `false` | 对受限命令,在 `/mnt` 上挂载空的 tmpfs。见 [Windows interop](#windows-interop)。 |
68
+ | `writableRoots` | `[]` | `workspace-write` 下额外可写的发行版目录(`~` 可用),用于工具链缓存或 linked worktree 的共享 Git 目录。条目必须是已存在的物理目录;已在工作区、`/tmp`、`/dev/shm` 内或嵌套在另一条授权内的条目会被忽略。`wsl-fs` 上应配置同一列表。见[工具链缓存](#工具链缓存与额外可写目录)。 |
68
69
  | `cwd` | `''` | 默认工作目录。空则使用发行版用户家目录。 |
69
70
  | `timeoutMs` / `maxTimeoutMs` | `120000` / `600000`(shipped) | 默认的单次调用超时,以及一次调用可请求的最大超时。 |
70
71
  | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
@@ -80,12 +81,47 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
80
81
  | `sandbox` | `true` | 按沙箱策略检查写入。`bwrap` 不可用时,受限写入关闭(fail closed)。 |
81
82
  | `sessionSandbox` | `false`;shipped 为 `true` | 使用与 `wsl-shell` 相同的会话 runtime。`auto` 在会话 runtime 不可用时回退到按策略约束的常驻 agent。 |
82
83
  | `maskWindowsDrive` | `false` | 对受限变更隐藏 `/mnt`。读取不受影响。 |
84
+ | `writableRoots` | `[]` | 与 `wsl-shell` 的键同义、同规则。受限写入与命令必须看到同一挂载表,因此两行应配置同一个列表。见[工具链缓存](#工具链缓存与额外可写目录)。 |
83
85
  | `substrate` | `agent`(shipped) | 文件操作使用发行版内 agent。旧值 `share` 在启动时被拒绝。 |
84
86
  | `cwd` | `''` | 相对路径的基准目录。空则使用发行版用户家目录。 |
85
87
  | `watchMaxDepth` | `0` | 监视整棵树。正值深度使用有界轮询,可能遗漏边界以下的变更,直到边界之上发生变更触发回调。 |
86
88
  | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
87
89
  | `diffBasisMaxBytes` | `10485760` | 覆盖写入 diff 每一侧的 UTF-8 字节上限。更大的文件不带 diff 直接写入。 |
88
90
 
91
+ ### 工具链缓存与额外可写目录
92
+
93
+ 默认的 `workspace-write` 只授予会话工作区和临时区(`/tmp`,会话 runtime 下是
94
+ 发行版的真实 `/tmp`)。npm、pnpm、cargo 等把包缓存写在 `$HOME` 下,所以安装一个
95
+ 尚未缓存的依赖会以 `EROFS` 失败。给**嵌套的** `wsl-shell` 和 `wsl-fs` 两行配置
96
+ 同一组目录即可;用 `pnpm run preset --writable-roots '~/.npm,~/.cache'` 可以把
97
+ 它们写进打印出的 `preset-wsl` 块,或手工在块内添加:
98
+
99
+ ```yaml
100
+ - id: wsl-shell
101
+ config:
102
+ writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
103
+ - id: wsl-fs
104
+ config:
105
+ writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
106
+ ```
107
+
108
+ 规则:
109
+
110
+ - `~` 和 `~/...` 按发行版用户家目录展开;其他条目必须是绝对 Linux 路径。
111
+ - 目录必须已经存在,且必须是物理目录(symlink 会被拒绝)。先 `mkdir -p`,
112
+ 或让一次不受限命令创建它。
113
+ - 已经位于工作区、`/tmp`、`/dev/shm` 内,或嵌套在另一条授权内的条目会被忽略:
114
+ 它们本来就已可写,绑定它们只会增加 symlink 重定向的风险。
115
+ - 两行必须一致;否则命令和受限写入可能看到不同的挂载表,会话 runtime 也会按
116
+ 不同的 key 各建一份。
117
+ - 只影响 `workspace-write`。`read-only` 忽略它;`danger-full-access` 本来就不
118
+ 经过沙箱。
119
+ - 安全边界:授权目录里的可执行内容(例如包缓存里的二进制)可以被后续构建或
120
+ 命令使用。这是**显式收窄**沙箱,不是关闭沙箱;`enforcement` 仍是 `partial`。
121
+ - 共享的 `sandboxPolicy.additionalWritableRoots` 也会被插件采用(同发行版 UNC
122
+ 或 Linux 拼写),但它作用于整个 profile;同一 profile 里还有 Windows 会话时,
123
+ 用上面的插件键更安全。
124
+
89
125
  ### `fs-routing`
90
126
 
91
127
  这个顶层行为根级 `ctx.fs` 调用提供服务。它把发行版 UNC 路径
@@ -19,8 +19,9 @@ names the opt-out, both as warnings), so the verdict answers under the
19
19
  the shipped preset — not the shipped defaults. The `config.effective` check
20
20
  reports what was read and from where.
21
21
 
22
- `verdict: ready` means the first command should succeed in the target
23
- distro(s) under the expected scope; the smoke legs (`functional.exec`,
22
+ `verdict: ready` means every check this run covered passed in the target
23
+ distro(s) under the expected scope; it is not a promise about a later
24
+ command. The smoke legs (`functional.exec`,
24
25
  `functional.sandbox`, `functional.fs`) prove the chain itself — frame I/O,
25
26
  the confined fence, the batched substrate — not just the prerequisites.
26
27
  `functional.exec` / `functional.fs` run the shell agent; when `auto` or
@@ -119,6 +120,7 @@ Class legend:
119
120
  |---|---|---|---|
120
121
  | `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`, `sandbox.bwrap-usable`, `functional.sandbox` | the requested confinement cannot be enforced (no usable bubblewrap) |
121
122
  | `FS_SANDBOX_DENIED` | policy | `functional.sandbox` (the fence shape) | the file-effect policy refused the write, or the kernel refused it at the resident's profile |
123
+ | `SANDBOX_INVALID_ROOT` | configuration | — (the per-entry `writableRoots` check runs on first use; the doctor does not pre-run it) | an extra writable root is malformed, names another world, or fails the physical-directory check |
122
124
  | `FS_OUTSIDE_DISTRO` | policy | `config.effective` (the effective `distro`) | the path names another distro's share while the fence is pinned |
123
125
  | `FS_IO_ERROR` | environment | `distro.reachable`, `distro.disk`, `host.disk`, `agent.handshake`, `agent.home-writable`, `functional.exec`, `functional.fs` | the catch-all: an agent outage, a wedged distro, a full disk, an unmappable path |
124
126
  | `FS_NOT_FOUND` | data | — | the path does not exist — the ordinary answer |
@@ -18,7 +18,8 @@
18
18
  关闭隔离(`sandbox: false` 且 `sessionSandbox: false`),沙箱检查发出
19
19
  **警告**点名 UNCONFINED 状态,并跳过围栏冒烟——醒目,但不阻断。
20
20
 
21
- `verdict: ready` 表示首条命令应在目标 distro、预期 scope 下成功;smoke 腿
21
+ `verdict: ready` 表示本次运行覆盖的检查在目标 distro、预期 scope 下全部通过,
22
+ 不保证之后每条命令都成功;smoke 腿
22
23
  (`functional.exec`、`functional.sandbox`、`functional.fs`)证明链路本身——
23
24
  帧 I/O、受限围栏、批量 substrate——而不只是前置条件。`functional.exec` /
24
25
  `functional.fs` 运行 shell agent;当 `auto` 或 `native` 选中 native 二进制时,
@@ -96,6 +97,7 @@ doctor 通过三个入口给出同一份报告;侧边栏的 **WSL 环境** 面
96
97
  |---|---|---|---|
97
98
  | `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`、`sandbox.bwrap-usable`、`functional.sandbox` | 所请求的隔离无法强制(无可用 bubblewrap) |
98
99
  | `FS_SANDBOX_DENIED` | policy | `functional.sandbox`(围栏形状) | 文件效果策略拒绝了写入,或内核在驻留 agent 的 profile 处拒绝 |
100
+ | `SANDBOX_INVALID_ROOT` | configuration | —(`writableRoots` 的逐项检查在首次使用时进行,doctor 不预跑) | 额外可写目录格式错误、指向另一个世界,或未通过物理目录检查 |
99
101
  | `FS_OUTSIDE_DISTRO` | policy | `config.effective`(生效的 `distro`) | 围栏钉死时路径指向另一 distro 的共享 |
100
102
  | `FS_IO_ERROR` | environment | `distro.reachable`、`distro.disk`、`host.disk`、`agent.handshake`、`agent.home-writable`、`functional.exec`、`functional.fs` | 兜底:agent 失联、distro 僵死、磁盘满、无法映射的路径 |
101
103
  | `FS_NOT_FOUND` | data | — | 路径不存在——普通答案 |
@@ -101,6 +101,16 @@ operations never use the 9p share.
101
101
  [ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement).
102
102
  - **`bubblewrap` must be installed**, or both providers fail with the install
103
103
  command; a session-start preflight surfaces the same text as an advisory warning.
104
+ - **`workspace-write` does not grant the package-manager caches under `$HOME`
105
+ by default** — npm's `~/.npm`, pnpm's store and cargo's `~/.cargo/registry`
106
+ live outside the workspace, so installing a dependency that is not already
107
+ cached fails with `EROFS`. Grant them explicitly with `writableRoots` (see
108
+ [CONFIGURATION](CONFIGURATION.md#toolchain-caches-and-extra-writable-roots));
109
+ executable content in a granted directory can be used by a later build, so
110
+ this narrows the sandbox rather than turning it off, and `enforcement` stays
111
+ `partial`. Entries must be existing physical directories; entries already
112
+ covered by the workspace, `/tmp` or `/dev/shm`, or nested inside another
113
+ grant, are not bound.
104
114
  - **Message localization is partial by design** — the preflight verdicts, `bwrap`
105
115
  remedies and distro/workdir errors follow the app's Language setting
106
116
  ([CONFIGURATION.md](CONFIGURATION.md#message-language)); the `FS_*` refusal texts
@@ -184,12 +194,15 @@ sandbox's security statement: `enforcement: partial` is untouched.
184
194
 
185
195
  ## Session-start advisories
186
196
 
187
- - **There is no session-UI notice seam in DSH 0.2.1.** `wsl-preflight` failures go
188
- to the host log and the session's runtime context (model-visible next assembly) —
189
- advisory only, never installing or cancelling. The upstream ask:
190
- [UPSTREAM-SESSION-NOTICE.md](UPSTREAM-SESSION-NOTICE.md).
197
+ - **There is no session-UI notice seam in DSH 0.2.1.** A blocked `wsl-preflight`
198
+ verdict goes to the host log and the session's runtime context (model-visible
199
+ next assembly) — advisory only, never installing or cancelling. A ready
200
+ verdict is log-only: "the prerequisite is usable" is not a model action. The
201
+ upstream ask: [UPSTREAM-SESSION-NOTICE.md](UPSTREAM-SESSION-NOTICE.md).
191
202
  - **The runtime-context entry is a repeated snapshot, not a dismissible
192
203
  notification.** Removing the `wsl-preflight` row silences the probe entirely.
204
+ A blocked message marks its remedy as operator action to ask the user about;
205
+ ready verdicts are not sent.
193
206
 
194
207
  ## Ports
195
208
 
@@ -96,6 +96,13 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
96
96
  [ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement)。
97
97
  - **必须安装 `bubblewrap`**,否则两个提供者都会带着安装命令失败;
98
98
  会话启动预检会以建议性警告的形式给出同样的文本。
99
+ - **`workspace-write` 默认不授予 `$HOME` 下的包管理器缓存** —— npm 的
100
+ `~/.npm`、pnpm 的 store、cargo 的 `~/.cargo/registry` 都在工作区之外,
101
+ 安装一个尚未缓存的依赖会以 `EROFS` 失败。用 `writableRoots` 显式授权
102
+ (见 [CONFIGURATION](CONFIGURATION.zh.md#工具链缓存与额外可写目录));
103
+ 授权目录里的可执行内容可被后续构建使用,这是收窄沙箱,不是关闭它,
104
+ `enforcement` 仍是 `partial`。条目必须是已存在的物理目录;已被工作区、
105
+ `/tmp`、`/dev/shm` 覆盖或嵌套在另一条授权内的条目不绑定。
99
106
  - **消息本地化按设计只覆盖一部分** —— 预检判定、`bwrap` 修复提示与
100
107
  发行版/工作目录错误跟随应用的语言设置
101
108
  ([CONFIGURATION.zh.md](CONFIGURATION.zh.md#消息语言));`fs-decisions`
@@ -166,12 +173,13 @@ Windows git `safe.directory` 白名单)。`--fix-owned` 把运行收窄到插
166
173
 
167
174
  ## 会话启动建议
168
175
 
169
- - **DSH 0.2.1 没有会话 UI 通知接缝。** `wsl-preflight` 的失败进入宿主日志
176
+ - **DSH 0.2.1 没有会话 UI 通知接缝。** `wsl-preflight` 的阻塞裁决进入宿主日志
170
177
  和会话的 runtime context(下次组装时对模型可见)——仅供参考,从不安装、
171
- 从不取消。对上游的请求见:
178
+ 从不取消。ready 裁决只写日志:“前置项可用”不是模型的动作。对上游的请求见:
172
179
  [UPSTREAM-SESSION-NOTICE.md](UPSTREAM-SESSION-NOTICE.md)。
173
180
  - **runtime context 条目是重复的快照,不是可关闭的通知。**
174
- 移除 `wsl-preflight` 行即可让该探针完全静音。
181
+ 移除 `wsl-preflight` 行即可让该探针完全静音。阻塞消息把修复标记为用户操作;
182
+ ready 裁决不再发送。
175
183
 
176
184
  ## 端口
177
185
 
package/docs/MIGRATION.md CHANGED
@@ -74,7 +74,7 @@ shows the composed value.
74
74
  | Gate | How | Runs where |
75
75
  |---|---|---|
76
76
  | Config docs and CHANGELOG current | review the diff; `lint:links` covers cross-references | CI |
77
- | `pnpm test` | style, links, requirement citations, doc consistency, syntax, build freshness, tsc, 48 unit files | CI (Node 22/24, Ubuntu + Windows) |
77
+ | `pnpm test` | style, links, requirement citations, doc consistency, syntax, build freshness, tsc, 50 unit files | CI (Node 22/24, Ubuntu + Windows) |
78
78
  | `pnpm run test:coverage` | lines 85 / branches 84 / functions 70 | CI (Node 24, Ubuntu) |
79
79
  | Peer line tested | `peer-canary` workflow resolves `next` and runs the scratch upgrade | CI schedule/manual |
80
80
  | Packed install/upgrade/uninstall | `pnpm run e2e:install` (temp `DSH_HOME`, 0.17.1 → current over the peer raise, marker) | manual, this machine (10/10 on 2026-11-06; the origin moved 0.11.0 → 0.17.1 because dsh 0.2.2-rc.1 rightly rejects the exact-pin era) |
@@ -31,10 +31,10 @@ file records the verification against the real peers.
31
31
  the package's exports, so `lib/fsio-text.js` reimplements it and imports
32
32
  nothing from it (the export is proposed in `docs/UPSTREAM-FSIO-EXPORT.md`).
33
33
  The peer **packages** are ordinary build-time imports that stay in the
34
- shipped artifact — `lib/fs-routing.js` and `lib/index.js` both import
35
- `LocalFileSystem` from `@deepseek-ai/dsh-fs-local`, and `lib/index.js` also
36
- imports `FsError` from `@deepseek-ai/dsh-fs`. Neither dependency is
37
- removable.
34
+ shipped artifact — `lib/fs-routing.js` and `lib/wsl-filesystem.js` both
35
+ import `LocalFileSystem` from `@deepseek-ai/dsh-fs-local`, and
36
+ `lib/wsl-filesystem.js` also imports `FsError` from `@deepseek-ai/dsh-fs`.
37
+ Neither dependency is removable.
38
38
  - Method: `npm pack` both pins, confirm the bytes, extract, and compare the
39
39
  shipped `lib/index.js` (unminified ESM) function-by-function and
40
40
  string-by-string against this repository.
@@ -30,15 +30,17 @@ finding exists (stale scopes and a broken agent cache), **完整检查** otherwi
30
30
  in the composer also runs host-side and renders in the UI — no model turn, no
31
31
  tokens; in a session, ask for a diagnosis and the model runs the `wsl_doctor`
32
32
  tool (mounted by this plugin), the verdict landing in the transcript; and the
33
- session-start preflight announces the same verdict on every session start.
33
+ session-start preflight logs the same verdict on every session start, and adds
34
+ it to the session's context only when blocked.
34
35
  `DSH_WSL_DOCTOR` additionally carries a ready-to-run command for the doctor
35
36
  script itself (`sh -c "$DSH_WSL_DOCTOR --json"`).
36
37
 
37
38
  The doctor (`scripts/doctor.mjs`, or `pnpm run doctor` from a checkout) checks
38
- the environment and ends in a verdict: `ready` means the first command should
39
- succeed; `blocked` names the exact checks to fix, each with a copy-paste
40
- remedy. It reads the distro's WSL mode from `wsl.exe -l -v` itself, so no
41
- separate version check is needed. Doctor is read-only unless you pass `--fix`
39
+ the environment and ends in a verdict: `ready` means every check that run
40
+ covered passed — not a promise about a later command; `blocked` names the exact
41
+ checks to fix, each with a copy-paste remedy. It reads the distro's WSL mode
42
+ from `wsl.exe -l -v` itself, so no separate version check is needed. Doctor is
43
+ read-only unless you pass `--fix`
42
44
  (the stale-scope sweep and a broken agent cache, both re-verified; the Windows
43
45
  git trust after a confirmation) or `--fix --install` (packages, after a
44
46
  confirmation); `--fix-owned` restricts a fix run to the plugin-owned state
@@ -164,6 +166,11 @@ pnpm test
164
166
  pnpm dev # a dev server survives the command that started it with sessionSandbox: true
165
167
  ```
166
168
 
169
+ On a cold cache or a new dependency, `workspace-write` blocks the
170
+ `~/.npm`/pnpm-store writes (`EROFS`). Configure the same `writableRoots` list on
171
+ `wsl-shell` and `wsl-fs` (e.g. `~/.npm`, `~/.cache`, `~/.local/share/pnpm`);
172
+ see [CONFIGURATION](CONFIGURATION.md#toolchain-caches-and-extra-writable-roots).
173
+
167
174
  The server's port can appear in `DSH_WSL_PORTS` after a successful snapshot
168
175
  (refreshed every 10 s by default); open a forwarded port from Windows at
169
176
  `http://localhost:<port>`.
@@ -27,11 +27,12 @@ doctor 快速检查,结果以状态徽标、编号的待修项与告警列出
27
27
  (残留 scope、损坏的 agent 缓存)的完整运行标为 **修复**,否则标为 **完整检查**;在输入框里输入
28
28
  `/wsl-doctor [quick|full|<分区>]` 同样在宿主侧执行、直接渲染在 UI,不进模型
29
29
  对话、零 token;在会话里请求诊断,模型会运行本插件挂载的 `wsl_doctor` 工具,
30
- 判定落在对话里;会话启动预检在每次会话打开时通报同样的判定。`DSH_WSL_DOCTOR` 还携带一条现成命令,可在发行版内执行 doctor 脚本本身
30
+ 判定落在对话里;会话启动预检在每次会话打开时把同样的判定写进日志,只有 blocked
31
+ 判定同时进入会话上下文。`DSH_WSL_DOCTOR` 还携带一条现成命令,可在发行版内执行 doctor 脚本本身
31
32
  (`sh -c "$DSH_WSL_DOCTOR --json"`)。
32
33
 
33
34
  doctor(`scripts/doctor.mjs`,或在检出目录中运行 `pnpm run doctor`)会检查
34
- 环境并以裁决收尾:`ready` 表示首条命令应能成功;`blocked` 会列明待修项,
35
+ 环境并以裁决收尾:`ready` 表示本次运行覆盖的检查全部通过,不保证每条命令都成功;`blocked` 会列明待修项,
35
36
  每项附可复制的处理办法。发行版的 WSL 模式由 doctor 自己从 `wsl.exe -l -v`
36
37
  读取,无需单独确认。doctor 默认只读,除非传入 `--fix`(清理过期 scope、清理损坏的
37
38
  agent 缓存,两者都会复检;以及确认后的 Windows git 信任)或
@@ -148,6 +149,11 @@ pnpm test
148
149
  pnpm dev # a dev server survives the command that started it with sessionSandbox: true
149
150
  ```
150
151
 
152
+ 冷缓存或新增依赖时,`workspace-write` 会拦住 `~/.npm`、pnpm store 等缓存写入
153
+ (`EROFS`)。在 `wsl-shell` 和 `wsl-fs` 上配置同一组 `writableRoots`(例如
154
+ `~/.npm`、`~/.cache`、`~/.local/share/pnpm`),见
155
+ [CONFIGURATION](CONFIGURATION.zh.md#工具链缓存与额外可写目录)。
156
+
151
157
  快照成功后(默认每 10 s 刷新一次),server 的端口可能出现在 `DSH_WSL_PORTS`
152
158
  中;从 Windows 通过 `http://localhost:<port>` 访问转发的端口。
153
159