dsh-plugin-wsl-env 0.23.1 → 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 (77) hide show
  1. package/CHANGELOG.md +212 -0
  2. package/README.md +9 -5
  3. package/SECURITY.md +10 -0
  4. package/client.js +974 -165
  5. package/cordis.patch.yml +28 -3
  6. package/docs/API.md +2 -1
  7. package/docs/ARCHITECTURE.md +36 -13
  8. package/docs/COMPATIBILITY.md +5 -0
  9. package/docs/CONFIGURATION.md +80 -9
  10. package/docs/CONFIGURATION.zh.md +64 -8
  11. package/docs/DIAGNOSTICS.md +48 -20
  12. package/docs/DIAGNOSTICS.zh.md +36 -14
  13. package/docs/LIMITATIONS.md +36 -9
  14. package/docs/LIMITATIONS.zh.md +26 -7
  15. package/docs/MIGRATION.md +1 -1
  16. package/docs/PEER-PARITY.md +4 -4
  17. package/docs/QUICKSTART.md +42 -12
  18. package/docs/QUICKSTART.zh.md +29 -8
  19. package/docs/README.zh.md +9 -5
  20. package/docs/RELEASING.md +17 -13
  21. package/docs/REQUIREMENTS.zh.md +5 -4
  22. package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
  23. package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
  24. package/docs/root-fs-routing.md +1 -1
  25. package/lib/agent-confined.d.ts +7 -1
  26. package/lib/agent-confined.js +3 -3
  27. package/lib/auto-preset.d.ts +27 -0
  28. package/lib/auto-preset.js +40 -3
  29. package/lib/bwrap.d.ts +14 -0
  30. package/lib/bwrap.js +11 -0
  31. package/lib/client-host.d.ts +2 -2
  32. package/lib/client-host.js +2 -2
  33. package/lib/cwd-prompt.d.ts +41 -3
  34. package/lib/cwd-prompt.js +125 -8
  35. package/lib/doctor-report.d.ts +50 -0
  36. package/lib/doctor-report.js +172 -0
  37. package/lib/fs-routing.d.ts +1 -1
  38. package/lib/fs-routing.js +1 -1
  39. package/lib/fs.d.ts +1 -1
  40. package/lib/fs.js +1 -1
  41. package/lib/index.d.ts +6 -1464
  42. package/lib/index.js +5 -2120
  43. package/lib/listing.d.ts +21 -9
  44. package/lib/listing.js +25 -21
  45. package/lib/messages.d.ts +1 -1
  46. package/lib/messages.js +3 -3
  47. package/lib/picker.d.ts +50 -16
  48. package/lib/picker.js +103 -23
  49. package/lib/preflight.d.ts +7 -4
  50. package/lib/preflight.js +27 -13
  51. package/lib/preset-choice.d.ts +22 -3
  52. package/lib/preset-choice.js +36 -3
  53. package/lib/provider-common.d.ts +58 -0
  54. package/lib/provider-common.js +123 -0
  55. package/lib/sandbox-core.d.ts +1 -0
  56. package/lib/sandbox-core.js +4 -2
  57. package/lib/session-runtime.d.ts +7 -1
  58. package/lib/session-runtime.js +9 -2
  59. package/lib/shell.d.ts +1 -1
  60. package/lib/shell.js +1 -1
  61. package/lib/status.d.ts +261 -0
  62. package/lib/status.js +425 -0
  63. package/lib/writable-roots.d.ts +109 -0
  64. package/lib/writable-roots.js +257 -0
  65. package/lib/wsl-doctor-tool.d.ts +8 -0
  66. package/lib/wsl-doctor-tool.js +18 -20
  67. package/lib/wsl-filesystem.d.ts +692 -0
  68. package/lib/wsl-filesystem.js +897 -0
  69. package/lib/wsl-shell.d.ts +742 -0
  70. package/lib/wsl-shell.js +965 -0
  71. package/lib/wsl.d.ts +13 -1
  72. package/lib/wsl.js +16 -1
  73. package/locale/doctor/en.json +3 -2
  74. package/locale/doctor/zh.json +3 -2
  75. package/package.json +12 -4
  76. package/scripts/doctor.mjs +436 -226
  77. package/scripts/profile-preset.mjs +17 -5
package/CHANGELOG.md CHANGED
@@ -16,6 +16,218 @@ 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
+
71
+ ## [0.24.0] - 2026-11-10
72
+
73
+ One theme: the diagnosis becomes something to act on — a sidebar panel
74
+ that checks a distro and repairs the plugin-owned state — while the
75
+ doctor's catalog is triaged and answers the effective configuration.
76
+
77
+ ### Added
78
+
79
+ - **A diagnostic status panel with a safe repair action, and a real choice when
80
+ a WSL workspace is added.** The navigation column now carries **WSL
81
+ environment**: the installed distros with an on-demand quick doctor check per
82
+ distro (bwrap, systemd, Linger and the other prerequisites, through the same
83
+ standalone CLI as `/wsl-doctor`). A checked row also offers a full run, labeled
84
+ **修复** when a finding is repairable and **完整检查** otherwise: a `POST` to
85
+ the same authenticated route runs the doctor with `--fix-owned`, sweeps stale
86
+ session scopes and purges a broken agent cache, then re-verifies both and
87
+ answers with the before → after `fix.*` rows. The result names what was
88
+ fixed, what failed re-verification, and what remains manual, so the button
89
+ never promises a fix it cannot apply. Each checked row carries its last check
90
+ time (date and time, with a relative hint), its source (manual or the page-load
91
+ background refresh), and a result structure — per-status totals and
92
+ per-section tallies — so the next action is visible at a glance. The last
93
+ result per distro is persisted under
94
+ `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json` (falling back to `~/.dsh`),
95
+ so a page reload or an app restart still shows it; on load, stored results
96
+ for running distros are re-checked in the background, and a failed
97
+ background run overwrites the stored result exactly as observed. Results are
98
+ never labeled expired. The panel opens no workspace, runs no session, and never installs packages or
99
+ rewrites Windows-owned configuration; a click is the only thing that boots a
100
+ stopped distro. Adding a workspace through the picker now asks once how a
101
+ distro folder is opened — **Remote WSL** (the default) or **Windows access**
102
+ (the folder as a 9p share under the host environment). The choice is
103
+ persisted in the `auto-preset` row's `windowsWorkspaces` volatile field, which
104
+ the auto-preset hook reads so later sessions in that workspace keep the host
105
+ preset; the prompt switches the workspace's blank session before its first
106
+ turn.
107
+
108
+ - **A checked distro row expands to every check the run executed.** The row
109
+ already showed the failures, the warnings and the per-section tallies; a green
110
+ verdict was still an assertion the user had to trust. **查看检查详情(N 项)**
111
+ now opens the full list, grouped by the doctor's sections (host / sandbox /
112
+ session / conf / net / agent), each row with its status mark, id, evidence and
113
+ (for a non-ok row) its remedy. The catalog rows a quick run never touches are
114
+ counted in one line — "the full run covers N more" — instead of being listed
115
+ as fake results, and the list is part of the persisted view, so a reload keeps
116
+ it. The detail is also carried for `error` rows (empty) and for older stored
117
+ views (defaulted), so a stale cache cannot break the panel.
118
+
119
+ - **`--fix` repairs the agent cache too, and `--fix-owned` scopes a run to
120
+ plugin-owned state.** A non-executable (or non-runnable) entry under
121
+ `~/.cache/dsh-wsl/agent` is purged and re-inventoried, and a failed handshake
122
+ is re-probed after the purge. `--fix-owned` narrows the fix loop to the stale-scope sweep and the
123
+ cache purge (it implies `--fix`, skips the package install and the Windows
124
+ git whitelist, and refuses `--install`); the sidebar's repair action uses it.
125
+
126
+ - **Four checks for failure modes the catalog missed.**
127
+ `functional.native` execs the cached native binary and verifies its HELLO
128
+ self-digest against the content-addressed cache directory (`skipped` on a
129
+ fresh machine, `fail` under `agentBackend: native`, `warn` under `auto`);
130
+ `agent.home-writable` creates and executes a temp file under `$HOME` to catch
131
+ a read-only home or a `noexec` mount before the native cache is extracted;
132
+ `host.disk` reads the Windows volume that holds the VHDX (fail < 2 GiB,
133
+ warn < 5 GiB), which `distro.disk` cannot see; `distro.unc` proves Windows can
134
+ read `\\wsl.localhost\<distro>`, the path the GUI file service, picker and
135
+ open-in-app use. `distro.wsl-conf-interop` also probes the WSLInterop binfmt
136
+ handler when interop is **enabled**, so a stale boot that breaks `git.exe` /
137
+ `explorer.exe` is named instead of surfacing as command-not-found.
138
+
139
+ - **The folder picker starts at a category level, not inside one home directory.**
140
+ It now opens on
141
+ a category level with **Windows 路径** and **WSL 发行版**; the Windows branch
142
+ starts at the drive roots (`C:\`, `D:\`, …) instead of at one account's home
143
+ directory, and the WSL branch lists the installed distros. Every level keeps
144
+ a **工作区** crumb, so either world is one click away. `includeHostHome` now
145
+ gates the Windows branch as a whole.
146
+
147
+ ### Changed
148
+
149
+ - **The doctor's check catalog was triaged row by row.** The merged rows carry
150
+ their facts together instead of in info-only satellites:
151
+ `host.platform` replaces `host.windows` + `host.wsl` and now fails below the
152
+ WSL 2 build floor (19041); `distro.identity` replaces `distro.shell` +
153
+ `distro.home`; the package family folded into the install remedy (no row) and
154
+ the architecture into `agent.native`; `config.profiles` folded into
155
+ `config.deprecated`. `distro.kernel` is gone. A `substrate: share` profile now
156
+ **fails** the verdict instead of warning: the fs provider throws at
157
+ construction, so the plugin does not boot that profile.
158
+
159
+ - **The sandbox checks answer the effective configuration.** With
160
+ `sandbox: false` on every row *and* `sessionSandbox: false`, nothing is
161
+ confined, so the doctor no longer blocks on a missing bwrap: `sandbox.bwrap`
162
+ reports a warning that names the UNCONFINED posture, and the usability and
163
+ fence-smoke rows skip with that reason. An explicit opt-out is conspicuous,
164
+ never silent.
165
+
166
+ - **The agent checks are config-aware too.** `agent.native`, `agent.cache` and
167
+ the new `agent.home-writable` fail only when `agentBackend: native` makes the
168
+ backend mandatory; under `auto` they warn (the shell agent still serves the
169
+ command), and a missing native binary under `shell` is context. A cache entry
170
+ is now probed for **execution**, not just the mode bit: a `noexec` mount and a
171
+ binary that cannot start both count as broken.
172
+
173
+ - **The Windows entry can run the agent chain.** The doctor translates the
174
+ package root through the distro's automount root (`C:\...` ->
175
+ `/mnt/c/...`, or the configured root), so `agent.handshake`, `functional.exec`
176
+ and `functional.fs` run on the real Windows surface instead of being skipped
177
+ as "the script path is a Windows path"; automount-disabled distros report the
178
+ honest skip. The digest check still reads the script through the host path.
179
+
180
+ - **The quick profile no longer probes the optional tools** (`rg`, `git`,
181
+ `inotifywait`): they are feature-degradation warnings, not first-command
182
+ prerequisites, and each is a process spawn per distro.
183
+
184
+ - **The WSL preset reads as a variant of 标准模式 and sits beside it.** The mode
185
+ picker listed `WSL 模式` as a fifth peer; it is now `标准模式(WSL)` with
186
+ `order: 1`, so it appears directly under 标准模式 (equal orders sort by id, and
187
+ `standard` precedes `wsl`). The composition is unchanged.
188
+
189
+ ### Removed
190
+
191
+ - **The doctor's registry update check is gone.** `update.latest` and its two
192
+ registry GETs were not a diagnosis: the plugin's delegated update service and
193
+ the app's Versions page already answer the question, and the doctor's promise
194
+ is a read-only pass over the machine. `DSH_UPDATE_REGISTRIES` is no longer
195
+ read anywhere (the env-var escape hatch left with the check).
196
+
197
+ - **The composer's WSL 诊断 pill is gone.** Its menu duplicated the sidebar
198
+ panel's per-distro quick check, which now also lists the numbered failing
199
+ items and the warnings. `/wsl-doctor` itself is unchanged and still runs when
200
+ typed in the composer.
201
+
202
+ ### Fixed
203
+
204
+ - **The doctor no longer misreads a top-level `insert:` of the WSL providers as
205
+ a nested-row id patch.** `config.preset-trap` matched an indented
206
+ `- id: wsl-shell` / `wsl-fs` line, so probe profiles that deliberately
207
+ `insert:` those rows at the top level were warned about a patch they do not
208
+ have. Only a root-level id entry — the one that truly targets a top-level row
209
+ and matches nothing — is reported now, and the remedy names the `insert:`
210
+ alternative. Verified against the host's profiles: the probe profiles that
211
+ insert these rows at the top level now scan clean.
212
+
213
+ - **A full doctor run on a BusyBox distro no longer blocks on the shell
214
+ fallback.** The FSB batch failure now decodes its `BAD <op>|<reason>|<base64>`
215
+ payload instead of printing base64, and names the cause: the shell agent's
216
+ GNU `find -printf` floor, which BusyBox lacks (`find: unrecognized: -printf`).
217
+ When `auto`/`native` selects the packaged native agent, the smoke legs over
218
+ the shell agent warn (it is the fallback) while `functional.native` runs the
219
+ same HELLO + EXEC + FSB chain over the cached native binary; the verdict
220
+ stays `ready`. Under `agentBackend: shell`, or when neither backend answers,
221
+ the leg still blocks — with `findutils` as the remedy, not a restart. The
222
+ family probe now knows `apk`, so Alpine's install remedies are `apk add`
223
+ rather than an apt command.
224
+
225
+ - **A full run with nothing to repair is narrated as a check.** The action is
226
+ the same `--fix-owned` run either way, but the row used to say **修复中…**
227
+ even when the button read **完整检查**: the pill, the busy label and the
228
+ running hint now follow the button's intent (检查中… / 完整检查中… / "正在运行
229
+ 完整检查"), so a plain full diagnosis never claims to be repairing anything.
230
+
19
231
  ## [0.23.1] - 2026-11-10
20
232
 
21
233
  ### Fixed
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. A doctor button in the composer runs the environment diagnosis as a `/wsl-doctor` command — 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,9 +115,9 @@ 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: Windows/WSL versions, the per-distro WSL mode, `.wslconfig` and `/etc/wsl.conf` cross-checks, the disk, clock and DNS, bubblewrap usability, systemd / the user manager / Linger, the optional tools, peer versions, the agent cache, a fresh-agent handshake, three smoke legs that prove the chain (frame I/O, the confined fence, the batched substrate), stale session scopes, the known profile-patch and deprecated-key traps, and whether a newer stable release exists on the registry. 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 (packages need `--fix --install` and an explicit confirmation), `--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 (the composer button — 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
- 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, and `DSH_UPDATE_REGISTRIES` overrides which registries the doctor's on-demand check asks (comma-separated, or empty to skip it on an air-gapped machine). Upgrading stays manual, because the harness has no hot reload: install again (Plugins page, or the `add` command), then restart. Uninstall on
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`
122
122
  where the CLI is installed; the agent cache under `~/.cache/dsh-wsl` can then be
123
123
  deleted. If you added a local `workspace-files-wsl` workaround to your profile to
@@ -133,6 +133,7 @@ Open a distro folder as the workspace, for example `\\wsl.localhost\ubuntu\home\
133
133
  - **New terminal** opens a shell in the same distro and directory.
134
134
  - The model sees listening ports and can return the URL of a dev server. WSL 2 forwards localhost to Windows.
135
135
  - The Permissions selector offers `read-only`, `workspace-write` (default) and `danger-full-access`. Only `danger-full-access` runs without the sandbox.
136
+ - The sidebar's **WSL environment** panel is the diagnostic page: the installed distros, an on-demand quick doctor check per distro (bwrap / systemd / Linger and the other prerequisites), and a full-run action (`--fix-owned`, labeled **修复** when a finding is one the plugin can repair and **完整检查** otherwise) that sweeps stale session scopes and purges a broken agent cache, then re-verifies both — without touching packages or Windows-owned configuration; every other warning keeps its manual remedy. Each checked row also states when the check ran, where it came from (**手动** or the page-load **后台** refresh), and how its results landed — the per-status totals and the per-section tallies. Each checked row also expands to the full list of checks that run executed, grouped by section with each status and its evidence (the catalog rows a quick run never touched are counted, not listed), so a green or blocked row can be audited instead of trusted. The next action is visible without opening the doctor. The last result per distro is stored under `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json` (falling back to `~/.dsh`), so a page reload or an app restart still shows it; on load, stored results for distros that are currently running are re-checked in the background (never a stopped one), and a failed background run replaces the stored result exactly as observed. No result is labeled expired: the timestamp is the timestamp. **Add workspace** on a distro folder asks once between **Remote WSL** (the default, everything runs in the distro) and **Windows access** (the folder as a 9p share, without the Linux toolchain), recorded in the `auto-preset` row's `windowsWorkspaces`.
136
137
 
137
138
  ## Configure
138
139
 
@@ -145,12 +146,14 @@ Settings live on named rows in `$DSH_HOME/profiles/<name>/cordis.patch.yml`. The
145
146
  | | `sessionSandbox` | `false`; shipped `true` | run the session's commands in one systemd user scope |
146
147
  | | `agentBackend` | `auto` | `auto`, `native` or `shell` for the in-distro agent |
147
148
  | | `maskWindowsDrive` | `false` | hide `/mnt` from confined commands |
149
+ | | `writableRoots` | `[]` | extra distro directories to grant (toolchain caches; put the same list on `wsl-fs`) |
148
150
  | `wsl-fs` | `distro` | `''` | distro mode; empty/`auto` follows each target path |
149
151
  | | `restrictToDistro` | `true` | under a fixed distro, refuse paths that belong to another distro |
150
152
  | | `sandbox` | `true` | check confined writes against the policy |
151
153
  | | `sessionSandbox` | `false`; shipped `true` | run confined writes in the session runtime |
152
154
  | | `substrate` | `agent` | in-distro agent; `share` is rejected at startup |
153
- | `directory-picker-wsl` | `includeHostHome` | `true` | also list the Windows home directory |
155
+ | | `writableRoots` | `[]` | the same extra-writable list as `wsl-shell` |
156
+ | `directory-picker-wsl` | `includeHostHome` | `true` | also offer the Windows path branch (starting at the drives) |
154
157
  | `subprocess-wsl` | `distro` | `''` | distro mode; empty/`auto` follows the launch directory |
155
158
  | `wsl-preflight` | `distro` | `''` | distro the environment checks probe; empty/`auto` follows the session workspace |
156
159
  | | `startup` | `true` | run the same checks once at plugin load, so the verdict is in the log before any session opens |
@@ -188,7 +191,7 @@ wsl preset (per session)
188
191
  | Mode | What a command can do |
189
192
  |---|---|
190
193
  | `read-only` | read the whole distro; a fresh `/dev` is mounted, nothing else is writable |
191
- | `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 |
192
195
  | `danger-full-access` | no sandbox |
193
196
 
194
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`.
@@ -204,6 +207,7 @@ Enforcement is reported as `partial`. A command inside the distro can still star
204
207
  | every command reports `SANDBOX_UNAVAILABLE` | install `bubblewrap` in the distro, or set `sandbox: false` |
205
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` |
206
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) |
207
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 |
208
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 |
209
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