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.
- package/CHANGELOG.md +212 -0
- package/README.md +9 -5
- package/SECURITY.md +10 -0
- package/client.js +974 -165
- package/cordis.patch.yml +28 -3
- package/docs/API.md +2 -1
- package/docs/ARCHITECTURE.md +36 -13
- package/docs/COMPATIBILITY.md +5 -0
- package/docs/CONFIGURATION.md +80 -9
- package/docs/CONFIGURATION.zh.md +64 -8
- package/docs/DIAGNOSTICS.md +48 -20
- package/docs/DIAGNOSTICS.zh.md +36 -14
- package/docs/LIMITATIONS.md +36 -9
- package/docs/LIMITATIONS.zh.md +26 -7
- package/docs/MIGRATION.md +1 -1
- package/docs/PEER-PARITY.md +4 -4
- package/docs/QUICKSTART.md +42 -12
- package/docs/QUICKSTART.zh.md +29 -8
- package/docs/README.zh.md +9 -5
- package/docs/RELEASING.md +17 -13
- package/docs/REQUIREMENTS.zh.md +5 -4
- package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
- package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
- package/docs/root-fs-routing.md +1 -1
- package/lib/agent-confined.d.ts +7 -1
- package/lib/agent-confined.js +3 -3
- package/lib/auto-preset.d.ts +27 -0
- package/lib/auto-preset.js +40 -3
- package/lib/bwrap.d.ts +14 -0
- package/lib/bwrap.js +11 -0
- package/lib/client-host.d.ts +2 -2
- package/lib/client-host.js +2 -2
- package/lib/cwd-prompt.d.ts +41 -3
- package/lib/cwd-prompt.js +125 -8
- package/lib/doctor-report.d.ts +50 -0
- package/lib/doctor-report.js +172 -0
- package/lib/fs-routing.d.ts +1 -1
- package/lib/fs-routing.js +1 -1
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/index.d.ts +6 -1464
- package/lib/index.js +5 -2120
- package/lib/listing.d.ts +21 -9
- package/lib/listing.js +25 -21
- package/lib/messages.d.ts +1 -1
- package/lib/messages.js +3 -3
- package/lib/picker.d.ts +50 -16
- package/lib/picker.js +103 -23
- package/lib/preflight.d.ts +7 -4
- package/lib/preflight.js +27 -13
- package/lib/preset-choice.d.ts +22 -3
- package/lib/preset-choice.js +36 -3
- package/lib/provider-common.d.ts +58 -0
- package/lib/provider-common.js +123 -0
- package/lib/sandbox-core.d.ts +1 -0
- package/lib/sandbox-core.js +4 -2
- package/lib/session-runtime.d.ts +7 -1
- package/lib/session-runtime.js +9 -2
- package/lib/shell.d.ts +1 -1
- package/lib/shell.js +1 -1
- package/lib/status.d.ts +261 -0
- package/lib/status.js +425 -0
- package/lib/writable-roots.d.ts +109 -0
- package/lib/writable-roots.js +257 -0
- package/lib/wsl-doctor-tool.d.ts +8 -0
- package/lib/wsl-doctor-tool.js +18 -20
- package/lib/wsl-filesystem.d.ts +692 -0
- package/lib/wsl-filesystem.js +897 -0
- package/lib/wsl-shell.d.ts +742 -0
- package/lib/wsl-shell.js +965 -0
- package/lib/wsl.d.ts +13 -1
- package/lib/wsl.js +16 -1
- package/locale/doctor/en.json +3 -2
- package/locale/doctor/zh.json +3 -2
- package/package.json +12 -4
- package/scripts/doctor.mjs +436 -226
- package/scripts/profile-preset.mjs +17 -5
package/cordis.patch.yml
CHANGED
|
@@ -163,6 +163,22 @@
|
|
|
163
163
|
- id: wsl-env-client-host
|
|
164
164
|
name: 'dsh-plugin-wsl-env'
|
|
165
165
|
|
|
166
|
+
# Status route for the sidebar panel: `GET /api/wsl-env/status` lists the
|
|
167
|
+
# installed distros and, for one named distro, runs the quick doctor CLI
|
|
168
|
+
# and returns its digested verdict; `POST` on the same route runs the full
|
|
169
|
+
# doctor with `--fix-owned` (stale scopes and a broken agent cache only,
|
|
170
|
+
# both re-verified) and answers with the fix rows. The route rides the
|
|
171
|
+
# authenticated /api channel (`ctx.connection.fetch`), so only the owner
|
|
172
|
+
# browser reads it; a composition without the Web connection leaves this
|
|
173
|
+
# row inert. Probing a stopped distro boots it, so a check or repair only
|
|
174
|
+
# ever starts from an explicit click — never from listing.
|
|
175
|
+
- id: wsl-status
|
|
176
|
+
name: 'dsh-plugin-wsl-env/status'
|
|
177
|
+
config:
|
|
178
|
+
cacheMs: 15000
|
|
179
|
+
timeoutMs: 90000
|
|
180
|
+
wslPath: wsl.exe
|
|
181
|
+
|
|
166
182
|
# The human-facing `/wsl-doctor` command (the composer button's target):
|
|
167
183
|
# registered globally so any session can run the diagnosis, not only WSL
|
|
168
184
|
# preset agents. The handler spawns the standalone doctor CLI — no model
|
|
@@ -264,7 +280,7 @@
|
|
|
264
280
|
# 2. `tool-bash` is enabled and `tool-pwsh` disabled outright, where the
|
|
265
281
|
# shipped copy derives the choice from `process.platform`;
|
|
266
282
|
# 3. the identity and display metadata: row `preset-wsl`, preset `wsl`,
|
|
267
|
-
# `name`/`description` for the mode selector, `order:
|
|
283
|
+
# `name`/`description` for the mode selector, `order: 1`.
|
|
268
284
|
# Regenerate it when an app update changes the preset: take
|
|
269
285
|
# `packages/bundle/web-app/presets/standard.patch.yml` from the harness tree
|
|
270
286
|
# the peer pins track, replace this row to the end of the file with its
|
|
@@ -278,9 +294,14 @@
|
|
|
278
294
|
# selector falls back to the raw id and "no description" unless the
|
|
279
295
|
# declaration carries its own copy (registry policy: user-authored
|
|
280
296
|
# metadata is never localized — write it in the deployment language).
|
|
281
|
-
|
|
297
|
+
#
|
|
298
|
+
# The name says what it is: 标准模式's capabilities in the distro's
|
|
299
|
+
# world, not a fifth task mode. The order ties with 标准模式 (order 1);
|
|
300
|
+
# the registry sorts equal orders by id, and "standard" sorts before
|
|
301
|
+
# "wsl", so the variant sits directly under the mode it extends.
|
|
302
|
+
name: 标准模式(WSL)
|
|
282
303
|
description: 在 WSL 的 Linux 实例中打开项目工作区:命令执行、shell 脚本和文件访问均在 Linux 空间内完成,以获得全套 Linux shell 工具链,受限命令经 bubblewrap 沙箱隔离。
|
|
283
|
-
order:
|
|
304
|
+
order: 1
|
|
284
305
|
plugins:
|
|
285
306
|
- id: wsl-env
|
|
286
307
|
name: cordis:group
|
|
@@ -320,6 +341,8 @@
|
|
|
320
341
|
# shipped shell agent. native fails the first command instead
|
|
321
342
|
# of falling back; shell forces the shell agent.
|
|
322
343
|
agentBackend: auto
|
|
344
|
+
# 工具链缓存等额外可写目录;默认空。示例(与 wsl-fs 配同一列表):
|
|
345
|
+
# writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
|
|
323
346
|
- id: wsl-fs
|
|
324
347
|
name: 'dsh-plugin-wsl-env/fs'
|
|
325
348
|
config:
|
|
@@ -336,6 +359,8 @@
|
|
|
336
359
|
# Confined writes ride the session runtime (ADR 0001), so they
|
|
337
360
|
# share the command's real /tmp and workspace mounts.
|
|
338
361
|
sessionSandbox: true
|
|
362
|
+
# 与 wsl-shell 的 writableRoots 保持同一列表;见 CONFIGURATION。
|
|
363
|
+
# writableRoots: ['~/.npm', '~/.cache', '~/.local/share/pnpm']
|
|
339
364
|
- id: persona
|
|
340
365
|
name: '@deepseek-ai/dsh-persona'
|
|
341
366
|
config:
|
package/docs/API.md
CHANGED
|
@@ -9,7 +9,7 @@ this page is the quick tour.
|
|
|
9
9
|
|---|---|---|
|
|
10
10
|
| `.` | — | the no-op root host half: a deliberate no-op plugin mounted at the bare package name, anchoring the browser client below (before 0.21.0 this resolved to the executor itself — see `./shell`) |
|
|
11
11
|
| `./shell` | `WslShellExecutor` | the model-facing shell executor (`ctx.shell`), mounted inside the WSL preset's isolate realm |
|
|
12
|
-
| `./client` | — (no importable surface) | the browser half the harness's web client loader serves for the bare-name row: the
|
|
12
|
+
| `./client` | — (no importable surface) | the browser half the harness's web client loader serves for the bare-name row: the sidebar status panel and the access-mode prompt |
|
|
13
13
|
| `./fs` | `WslFileSystem` | the filesystem provider over the distro (`ctx.fs`) |
|
|
14
14
|
| `./index` | `WslShellExecutor`, `WslFileSystem`, `doctorReport`, `effectiveMaskWindowsDrive`, … | the composition root's full named surface — the integration API (`doctorReport` for tooling that wants the doctor's versioned report) |
|
|
15
15
|
| `./fs-routing` | `WslRoutingFileSystem` | the root-plane coordinate router |
|
|
@@ -22,6 +22,7 @@ this page is the quick tour.
|
|
|
22
22
|
| `./file-reference-wsl` | `traversalArgv`, `parseTraversalListing`, `FileReferenceTraversal`, … | the distro-side traversal strategy for `@` completion (pure library — built and tested, not yet wired to a row; see ARCHITECTURE) |
|
|
23
23
|
| `./wsl-doctor-tool` | the `wsl-doctor-tool` row | the `wsl_doctor` model tool: in-process diagnosis with scoping (`depth`, `section`) |
|
|
24
24
|
| `./wsl-doctor-command` | the `wsl-doctor-command` row | the `/wsl-doctor` UI command: spawns the standalone doctor CLI, renders detached from model history |
|
|
25
|
+
| `./status` | the `wsl-status` row | the sidebar panel's route over `/api`: installed distros, one distro's quick doctor, and the `--fix-owned` full run (repair when repairable, full check otherwise); the last result persists across reloads and running distros' stored results refresh in the background |
|
|
25
26
|
| `./paths` | `uncToPosix`, `toLinuxPath`, `toWorldPath`, … | the coordinate mappers |
|
|
26
27
|
| `./picker` | `WslDirectoryPicker` | the distro-aware directory picker |
|
|
27
28
|
| `./auto-preset` | the `auto-preset` row | first-run profile bootstrap |
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -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/
|
|
23
|
-
| `ctx.fs` | `WslFileSystem` | [`lib/
|
|
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`
|
|
@@ -65,22 +65,28 @@ functions.
|
|
|
65
65
|
|
|
66
66
|
| Subpath | Class or name | File | What it does |
|
|
67
67
|
|---|---|---|---|
|
|
68
|
-
| `dsh-plugin-wsl-env/picker` | `WslDirectoryPicker` | [`lib/picker.js`](../lib/picker.js) |
|
|
68
|
+
| `dsh-plugin-wsl-env/picker` | `WslDirectoryPicker` | [`lib/picker.js`](../lib/picker.js) | The folder picker's two worlds: a category root with a Windows branch (starting at the drives) and a WSL branch (one row per installed distro); distro levels list from inside the distro (the resident's `find`, one-shot `wsl.exe` when it is out). |
|
|
69
69
|
| `dsh-plugin-wsl-env/auto-preset` | `auto-preset` | [`lib/auto-preset.js`](../lib/auto-preset.js) | Binds the `wsl` agent preset when a new session's workspace is inside a distro. |
|
|
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
|
-
| `dsh-plugin-wsl-env`
|
|
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
|
+
| `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. |
|
|
78
79
|
|
|
79
|
-
Three
|
|
80
|
+
Three path and interop helpers import no DSH package.
|
|
80
81
|
[`lib/paths.js`](../lib/paths.js) translates paths.
|
|
81
82
|
[`lib/listing.js`](../lib/listing.js) builds directory listings and breadcrumbs.
|
|
82
83
|
[`lib/wsl.js`](../lib/wsl.js) holds the `wsl.exe` interop primitives.
|
|
83
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
|
+
|
|
84
90
|
## How the pieces are mounted
|
|
85
91
|
|
|
86
92
|
[`cordis.patch.yml`](../cordis.patch.yml) is the bundle layer. It is a top-level
|
|
@@ -97,7 +103,7 @@ The environment is per session, not per process:
|
|
|
97
103
|
| `subprocess-wsl` | at the app level, called the composition; the shipped `subprocess` row is disabled | because no session identity reaches the terminal controller, see below |
|
|
98
104
|
| `workspace-files` | shipped, not replaced | its client half is the browser `file` resource provider the Sidebar previews need; it reads WSL paths through the routed root filesystem |
|
|
99
105
|
| `fs-routing` | at the app level; the shipped `fs-sandbox` row is disabled | the root `ctx.fs` is session-less, and its write fence has no root-plane consumers |
|
|
100
|
-
| `directory-picker-wsl`, `wsl-shell-env`, `auto-preset`, `wsl-preflight`, `wsl-update-check`, `wsl-cwd-prompt`, `wsl-cwd-prompt-tool`, `wsl-doctor-command`, `wsl-env-client-host` | at the app level | they answer questions that are not scoped to a single preset; `shell-env` resolves its facts per session workspace, and the advisory/diagnosis rows must answer even when a session never opens |
|
|
106
|
+
| `directory-picker-wsl`, `wsl-shell-env`, `auto-preset`, `wsl-preflight`, `wsl-update-check`, `wsl-cwd-prompt`, `wsl-cwd-prompt-tool`, `wsl-doctor-command`, `wsl-status`, `wsl-env-client-host` | at the app level | they answer questions that are not scoped to a single preset; `shell-env` resolves its facts per session workspace, and the advisory/diagnosis rows must answer even when a session never opens |
|
|
101
107
|
| `wsl-doctor-tool` | inside `preset-wsl` (model-facing) | the tool surface follows the preset: a session on a Windows folder keeps the shipped tools |
|
|
102
108
|
|
|
103
109
|
The preset mount requires the isolate realms. Without them the registry rejects the
|
|
@@ -222,7 +228,7 @@ distro, and the argv is the same either way:
|
|
|
222
228
|
```text
|
|
223
229
|
wsl.exe -d <distro> --cd <linux dir> --exec bwrap \
|
|
224
230
|
--ro-bind / / --dev /dev --unshare-pid --proc /proc --die-with-parent \
|
|
225
|
-
[--tmpfs /tmp --bind <workspace> <workspace>] [--tmpfs /mnt] -- <shell> -lc <cmd>
|
|
231
|
+
[--tmpfs /tmp --bind <workspace> <workspace> [--bind <root> <root> ...]] [--tmpfs /mnt] -- <shell> -lc <cmd>
|
|
226
232
|
```
|
|
227
233
|
|
|
228
234
|
By default the profile wraps the session's resident agent ONCE, under
|
|
@@ -243,10 +249,19 @@ cannot be read or exfiltrated and its executables cannot be launched through
|
|
|
243
249
|
interop. The option is off by default; [CONFIGURATION.md](CONFIGURATION.md) lists
|
|
244
250
|
the row keys, and `lib/sandbox-core.js` states its honest ceiling.
|
|
245
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
|
+
|
|
246
261
|
| Mode | What a command inside the distro can do |
|
|
247
262
|
|---|---|
|
|
248
263
|
| `read-only` | read the whole distro; a fresh `/dev` is mounted writable, so `/dev/null` and `/dev/shm` work, and nothing else does |
|
|
249
|
-
| `workspace-write` | the above, plus the session workspace
|
|
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`) |
|
|
250
265
|
| `danger-full-access` | no sandbox; used for an approved wider-permission request |
|
|
251
266
|
|
|
252
267
|
`WslFileSystem` checks writes against the same policy and the same writable list,
|
|
@@ -319,11 +334,12 @@ own dialect, described after the table.
|
|
|
319
334
|
| Code | Raised by | Meaning | What clears it |
|
|
320
335
|
|---|---|---|---|
|
|
321
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 |
|
|
322
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 |
|
|
323
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 |
|
|
324
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 |
|
|
325
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 |
|
|
326
|
-
| `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/
|
|
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`) |
|
|
327
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 | — |
|
|
328
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 |
|
|
329
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 |
|
|
@@ -447,7 +463,7 @@ src/bwrap.ts the bwrap command line every confinement site
|
|
|
447
463
|
assert it)
|
|
448
464
|
src/client-host.ts the bare-name host half — a deliberate no-op that
|
|
449
465
|
anchors the browser client
|
|
450
|
-
src/cwd-prompt.ts rewrites the
|
|
466
|
+
src/cwd-prompt.ts rewrites the working directory; applies the temporary prompt adapters
|
|
451
467
|
to the distro's POSIX form
|
|
452
468
|
src/cwd-prompt-tool.ts serves the model's read/cd tool with distro-POSIX
|
|
453
469
|
cwd output
|
|
@@ -468,7 +484,11 @@ src/fsio-text.ts the peer's pure text mechanics, replicated pending
|
|
|
468
484
|
src/git-exec.ts the agent-backed execution handle for the
|
|
469
485
|
git-snapshot spawn
|
|
470
486
|
src/git-route.ts which git spawns belong inside the distro (pure)
|
|
471
|
-
src/index.ts
|
|
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
|
|
472
492
|
src/listing.ts pure directory listing and breadcrumb helpers
|
|
473
493
|
src/messages.ts the en/zh message catalogs and the host-locale wiring
|
|
474
494
|
src/native-agent.ts native binary selection and preparation
|
|
@@ -495,6 +515,8 @@ src/terminal-route.ts which execution world a terminal launch belongs to
|
|
|
495
515
|
src/update-check.ts the once-a-day update notice (fact store +
|
|
496
516
|
host-delegated check)
|
|
497
517
|
src/watcher.ts in-distro file watching for WslFileSystem.watch
|
|
518
|
+
src/status.ts the panel's route (distro list, one distro's
|
|
519
|
+
quick doctor, and the --fix-owned repair over /api)
|
|
498
520
|
src/wsl-doctor-command.ts the `/wsl-doctor` UI command row (spawns the
|
|
499
521
|
standalone doctor CLI)
|
|
500
522
|
src/wsl-doctor-tool.ts the `wsl_doctor` model tool row (in-process diagnosis)
|
|
@@ -535,7 +557,8 @@ standalone CLI (peer-free by design, so it starts when the plugin's own
|
|
|
535
557
|
runtime is broken), the `/wsl-doctor` UI command (spawns the CLI host-side,
|
|
536
558
|
renders detached from model history), and the `wsl_doctor` model tool
|
|
537
559
|
(in-process, merging the live resident's state through `lib/doctor-live.js`).
|
|
538
|
-
|
|
560
|
+
The sidebar panel renders the quick digest and posts the repair action the
|
|
561
|
+
same way (`--fix-owned`: plugin-owned state only). A run can be scoped (`--quick`, `--sections <csv>` on the CLI; `depth` /
|
|
539
562
|
`section` on the tool), and the report itemizes every check grouped by
|
|
540
563
|
distro. See [DIAGNOSTICS.md](DIAGNOSTICS.md) for the surfaces and the
|
|
541
564
|
verdict contract.
|
package/docs/COMPATIBILITY.md
CHANGED
|
@@ -76,6 +76,11 @@ Alpine (musl).
|
|
|
76
76
|
| Alpine | Import the **minirootfs** tarball (`wsl --import`), not the standard/cloud images. Create a normal user and set `[user] default=…` in `/etc/wsl.conf` — the imported default is root, and a root agent writes 0600 files the probe user cannot read. Install `coreutils util-linux` (busybox `mktemp`/`ps` lack the used options) and `shadow` for `useradd`. |
|
|
77
77
|
| Fedora / openSUSE / Arch | systemd PID 1 out of the box. openSUSE: `zypper --non-interactive` (the plain `-y` still prompts); Arch: `pacman -Sy --needed`. |
|
|
78
78
|
|
|
79
|
+
On a minimal Alpine image the **shell** agent's FSB enumeration needs GNU
|
|
80
|
+
`findutils` (BusyBox `find` lacks `-printf`); the packaged native agent does
|
|
81
|
+
not, and `auto` prefers it. Install `findutils` only when pinning
|
|
82
|
+
`agentBackend: shell` — the doctor decodes the failure and names that package.
|
|
83
|
+
|
|
79
84
|
Dependencies used everywhere: `bash bubblewrap git nodejs` (node 20–26 all
|
|
80
85
|
pass; the plugin's `engines` floor applies to the harness host, not to probe
|
|
81
86
|
nodes). The probe runner per distro, from inside the distro:
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -12,11 +12,17 @@ rows and values shipped by this plugin.
|
|
|
12
12
|
A profile layer can target a top-level row by `id`. Plugin rows at that level
|
|
13
13
|
include `fs-routing`, `directory-picker-wsl`, `subprocess-wsl`, `wsl-shell-env`,
|
|
14
14
|
`wsl-preflight`, `auto-preset`, `wsl-cwd-prompt`, `wsl-cwd-prompt-tool`,
|
|
15
|
-
`wsl-update-check`, `wsl-doctor-command`, `wsl-env-client-host`, and
|
|
15
|
+
`wsl-update-check`, `wsl-doctor-command`, `wsl-status`, `wsl-env-client-host`, and
|
|
16
16
|
`preset-wsl`. The `wsl-shell`, `wsl-fs` and `wsl-doctor-tool` rows are nested
|
|
17
17
|
inside `preset-wsl.config.plugins`; a profile entry targeting those ids directly
|
|
18
18
|
is ignored with a `patch: entry <id> not found` warning.
|
|
19
19
|
|
|
20
|
+
A root-level `- id: wsl-shell` / `wsl-fs` entry patches a top-level row that
|
|
21
|
+
does not exist in the shipped composition, so it is ignored with a warning.
|
|
22
|
+
An entry indented under `- insert:` is a different thing: it adds a real
|
|
23
|
+
top-level row, which is how a probe profile can mount these providers without
|
|
24
|
+
the preset. The doctor's `config.preset-trap` check only reports the former.
|
|
25
|
+
|
|
20
26
|
A row's `config` is replaced as a whole. Include any non-default values from
|
|
21
27
|
the bundled row that you want to retain. This matters most for `preset-wsl`,
|
|
22
28
|
whose config contains the complete preset and its nested plugins.
|
|
@@ -62,6 +68,7 @@ after a plugin upgrade that changes the preset.
|
|
|
62
68
|
| `sandbox` | `true` | Confine commands with `bwrap`. A missing or unusable `bwrap` fails closed. `false` runs commands without confinement. |
|
|
63
69
|
| `interopVisibility` | Unset; effective default is `visible` | `visible`, `masked`, or `disabled`. When set, this takes precedence over `maskWindowsDrive`. See [Windows interop](#windows-interop). |
|
|
64
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). |
|
|
65
72
|
| `cwd` | `''` | Default workdir. Empty uses the distro user's home. |
|
|
66
73
|
| `timeoutMs` / `maxTimeoutMs` | `120000` / `600000` (shipped) | Default per-call timeout and the maximum timeout a call may request. |
|
|
67
74
|
| `wslPath` | `wsl.exe` | Path to `wsl.exe`. |
|
|
@@ -77,12 +84,54 @@ after a plugin upgrade that changes the preset.
|
|
|
77
84
|
| `sandbox` | `true` | Check writes against the sandbox policy. Confined writes fail closed if `bwrap` is unavailable. |
|
|
78
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. |
|
|
79
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). |
|
|
80
88
|
| `substrate` | `agent` (shipped) | File operations use the in-distro agent. The legacy `share` value is refused at startup. |
|
|
81
89
|
| `cwd` | `''` | Base directory for relative paths. Empty uses the distro user's home. |
|
|
82
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. |
|
|
83
91
|
| `wslPath` | `wsl.exe` | Path to `wsl.exe`. |
|
|
84
92
|
| `diffBasisMaxBytes` | `10485760` | UTF-8 byte limit per side of an overwrite diff. Larger files are written without a diff. |
|
|
85
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
|
+
|
|
86
135
|
### `fs-routing`
|
|
87
136
|
|
|
88
137
|
This top-level row serves root-level `ctx.fs` calls. It routes distro UNC paths
|
|
@@ -112,7 +161,7 @@ The root router is app-level, not session-owned, so it does not use
|
|
|
112
161
|
| Row | Key | Default / shipped value | Description |
|
|
113
162
|
|---|---|---|---|
|
|
114
163
|
| `directory-picker-wsl` | `preferredDistro` | `''` (shipped) | Distro shown first and used for the Home location. |
|
|
115
|
-
| | `includeHostHome` | `true` (shipped) |
|
|
164
|
+
| | `includeHostHome` | `true` (shipped) | Offer the Windows path branch; its walk starts at the drive roots. |
|
|
116
165
|
| | `maxEntries` | `1000` (shipped) | Maximum entries returned for one directory. |
|
|
117
166
|
| | `wslPath` | `wsl.exe` | Path to `wsl.exe`. |
|
|
118
167
|
| | `distroCacheMs` | `5000` | Cache lifetime for the distro list. |
|
|
@@ -133,6 +182,10 @@ The root router is app-level, not session-owned, so it does not use
|
|
|
133
182
|
| `auto-preset` | `preset` | `wsl` | Preset to bind when a session workspace is inside a distro. An explicit operator selection is preserved. |
|
|
134
183
|
| | `attempts` | `6` | Number of attempts to bind the preset. |
|
|
135
184
|
| | `retryMs` | `150` | Delay between attempts, in milliseconds. |
|
|
185
|
+
| | `windowsWorkspaces` | `[]` | Distro directories opened for Windows access (UNC paths). Sessions under them keep the host preset; the add-workspace prompt writes here, and Settings can change it back. |
|
|
186
|
+
| `wsl-status` | `cacheMs` | `15000` | How long one distro's verdict stays fresh in memory, in milliseconds (the last result is persisted separately). |
|
|
187
|
+
| | `timeoutMs` | `90000` | Deadline for one check or repair run, in milliseconds. |
|
|
188
|
+
| | `wslPath` | `wsl.exe` | `wsl.exe` used to list the distros. |
|
|
136
189
|
| `wsl-preflight` | `distro` | `''` | Distro to check. Empty or `auto` follows the session workspace. |
|
|
137
190
|
| | `wslPath` | `wsl.exe` | Path to `wsl.exe`. |
|
|
138
191
|
| | `sandbox` | `true` | Run the session-start `bwrap` check. |
|
|
@@ -300,13 +353,17 @@ It also checks
|
|
|
300
353
|
the session-runtime prerequisites when `sessionSandbox: true`. The warning is
|
|
301
354
|
advisory: it does not install packages or change the providers' fail-closed
|
|
302
355
|
behavior. Set `sandbox: false` on this row or remove it to silence the
|
|
303
|
-
|
|
356
|
+
preflight warning. Set `sessionSandbox: false` when the profile does not use a
|
|
304
357
|
session runtime.
|
|
305
358
|
|
|
306
359
|
Setting `sandbox: false` on `wsl-shell` or `wsl-fs` runs commands or writes
|
|
307
360
|
without confinement; their `sandboxMode` becomes `undefined`. The tool layer
|
|
308
361
|
reports that no sandbox is active. On `fs-routing`, the setting disables the
|
|
309
|
-
mutation fence; that row reports `sandboxMode: undefined` either way.
|
|
362
|
+
mutation fence; that row reports `sandboxMode: undefined` either way. When
|
|
363
|
+
every surface opts out — `sandbox: false` on all three rows *and*
|
|
364
|
+
`sessionSandbox: false` — the doctor still reports it, as a **warning** that
|
|
365
|
+
names the unconfined posture and skips the fence smoke; the opt-out never
|
|
366
|
+
blocks the verdict.
|
|
310
367
|
|
|
311
368
|
### Message language
|
|
312
369
|
|
|
@@ -359,20 +416,34 @@ the peer floor, a fresh agent handshake, stale session scopes, the known
|
|
|
359
416
|
profile-patch and deprecated-key traps — each failure with a copyable remedy.
|
|
360
417
|
The run ends in a verdict (`ready` or `blocked`) computed under the effective
|
|
361
418
|
configuration: `--json` is the machine contract (schemaVersion 2), `--fix`
|
|
362
|
-
re-verifies what it fixed (
|
|
363
|
-
|
|
419
|
+
re-verifies what it fixed (the plugin-owned stale-scope sweep and agent-cache
|
|
420
|
+
purge are automatic; packages need `--fix --install` and an explicit
|
|
421
|
+
confirmation; `--fix-owned` restricts a run to the plugin-owned two), `--all`
|
|
422
|
+
checks every installed distro, `--bundle
|
|
364
423
|
<path>` writes the attachable diagnostic file (`--redact` strips the paths),
|
|
365
424
|
and `--locale <tag>` (or `DSH_WSL_DOCTOR_LOCALE`) selects the skeleton
|
|
366
425
|
language without re-probing. `--yes` skips the confirmation prompt (not the
|
|
367
426
|
confirmation gate itself), and `--read-only` refuses to run together with
|
|
368
|
-
`--fix` or `--install`.
|
|
369
|
-
registries the on-demand update check asks (comma-separated; empty skips
|
|
370
|
-
it — for air-gapped machines).
|
|
427
|
+
`--fix` or `--install`.
|
|
371
428
|
See [DIAGNOSTICS.md](DIAGNOSTICS.md) for the verdict contract and the
|
|
372
429
|
error-code map. With the CLI distribution, `dsh --profile <name> --dump-config` inspects
|
|
373
430
|
the composed profile without booting it and shows whether a row override
|
|
374
431
|
applied; the desktop app has no `dsh` command, so read `cordis.patch.yml` and
|
|
375
432
|
the Plugins page there.
|
|
433
|
+
The sidebar's **WSL environment** panel renders the same quick digest over
|
|
434
|
+
`GET /api/wsl-env/status` and posts the full-run action to the same route: a
|
|
435
|
+
doctor run with `--fix-owned`, which sweeps stale session scopes and purges a
|
|
436
|
+
broken agent cache, then re-verifies both. Each row states when the check ran, its source (manual or background) and its
|
|
437
|
+
result structure (per-status totals and per-section tallies). The last result
|
|
438
|
+
per distro is stored at `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`
|
|
439
|
+
(`~/.dsh/...` when the host names no home), so a page reload or app restart
|
|
440
|
+
still shows it. On load, a stored result for a distro that is currently
|
|
441
|
+
running is re-checked in the background; a failed background run overwrites
|
|
442
|
+
the stored result. Nothing is labeled expired — delete the file to reset the
|
|
443
|
+
panel's history. The label follows the report: **修复** when
|
|
444
|
+
such a repairable finding is present, **完整检查** otherwise; every other
|
|
445
|
+
warning keeps its manual remedy. It never installs packages or rewrites
|
|
446
|
+
Windows-owned or user configuration.
|
|
376
447
|
Use `scripts/bootstrap.sh <distro>` to inspect distro prerequisites.
|
|
377
448
|
|
|
378
449
|
| Symptom | Result | Action |
|
package/docs/CONFIGURATION.zh.md
CHANGED
|
@@ -12,11 +12,16 @@ profile 设置存放在 `$DSH_HOME/profiles/<name>/cordis.patch.yml`。可以用
|
|
|
12
12
|
profile 层可以按 `id` 指向顶层行。这一层的插件行包括 `fs-routing`、
|
|
13
13
|
`directory-picker-wsl`、`subprocess-wsl`、`wsl-shell-env`、`wsl-preflight`、
|
|
14
14
|
`auto-preset`、`wsl-cwd-prompt`、`wsl-cwd-prompt-tool`、`wsl-update-check`、
|
|
15
|
-
`wsl-doctor-command`、`wsl-env-client-host` 和 `preset-wsl`。
|
|
15
|
+
`wsl-doctor-command`、`wsl-status`、`wsl-env-client-host` 和 `preset-wsl`。
|
|
16
16
|
`wsl-shell`、`wsl-fs` 与 `wsl-doctor-tool` 嵌套在
|
|
17
17
|
`preset-wsl.config.plugins` 内;直接按这些 id 配置的 profile 条目会被忽略,
|
|
18
18
|
并产生 `patch: entry <id> not found` 警告。
|
|
19
19
|
|
|
20
|
+
根级的 `- id: wsl-shell` / `wsl-fs` 条目会去 patch 一个在随包组合里并不存在的
|
|
21
|
+
顶层行,因此被忽略并给出告警;缩进在 `- insert:` 下的条目是另一回事——它会新增
|
|
22
|
+
一个真实的顶层行,探针 profile 正是用这种方式在不启用 preset 的情况下挂载这两个
|
|
23
|
+
provider。doctor 的 `config.preset-trap` 只报告前者。
|
|
24
|
+
|
|
20
25
|
一行的 `config` 是整体替换。如果你想保留随包行中的非默认值,
|
|
21
26
|
必须把它们一并写入。这对 `preset-wsl` 尤其重要:
|
|
22
27
|
它的 config 包含完整的 preset 及其嵌套插件。
|
|
@@ -60,6 +65,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
|
|
|
60
65
|
| `sandbox` | `true` | 用 `bwrap` 约束命令。`bwrap` 缺失或不可用时关闭(fail closed)。`false` 则不加约束地运行命令。 |
|
|
61
66
|
| `interopVisibility` | 未设置;有效默认值为 `visible` | `visible`、`masked` 或 `disabled`。设置后优先于 `maskWindowsDrive`。见 [Windows interop](#windows-interop)。 |
|
|
62
67
|
| `maskWindowsDrive` | `false` | 对受限命令,在 `/mnt` 上挂载空的 tmpfs。见 [Windows interop](#windows-interop)。 |
|
|
68
|
+
| `writableRoots` | `[]` | `workspace-write` 下额外可写的发行版目录(`~` 可用),用于工具链缓存或 linked worktree 的共享 Git 目录。条目必须是已存在的物理目录;已在工作区、`/tmp`、`/dev/shm` 内或嵌套在另一条授权内的条目会被忽略。`wsl-fs` 上应配置同一列表。见[工具链缓存](#工具链缓存与额外可写目录)。 |
|
|
63
69
|
| `cwd` | `''` | 默认工作目录。空则使用发行版用户家目录。 |
|
|
64
70
|
| `timeoutMs` / `maxTimeoutMs` | `120000` / `600000`(shipped) | 默认的单次调用超时,以及一次调用可请求的最大超时。 |
|
|
65
71
|
| `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
|
|
@@ -75,12 +81,47 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
|
|
|
75
81
|
| `sandbox` | `true` | 按沙箱策略检查写入。`bwrap` 不可用时,受限写入关闭(fail closed)。 |
|
|
76
82
|
| `sessionSandbox` | `false`;shipped 为 `true` | 使用与 `wsl-shell` 相同的会话 runtime。`auto` 在会话 runtime 不可用时回退到按策略约束的常驻 agent。 |
|
|
77
83
|
| `maskWindowsDrive` | `false` | 对受限变更隐藏 `/mnt`。读取不受影响。 |
|
|
84
|
+
| `writableRoots` | `[]` | 与 `wsl-shell` 的键同义、同规则。受限写入与命令必须看到同一挂载表,因此两行应配置同一个列表。见[工具链缓存](#工具链缓存与额外可写目录)。 |
|
|
78
85
|
| `substrate` | `agent`(shipped) | 文件操作使用发行版内 agent。旧值 `share` 在启动时被拒绝。 |
|
|
79
86
|
| `cwd` | `''` | 相对路径的基准目录。空则使用发行版用户家目录。 |
|
|
80
87
|
| `watchMaxDepth` | `0` | 监视整棵树。正值深度使用有界轮询,可能遗漏边界以下的变更,直到边界之上发生变更触发回调。 |
|
|
81
88
|
| `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
|
|
82
89
|
| `diffBasisMaxBytes` | `10485760` | 覆盖写入 diff 每一侧的 UTF-8 字节上限。更大的文件不带 diff 直接写入。 |
|
|
83
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
|
+
|
|
84
125
|
### `fs-routing`
|
|
85
126
|
|
|
86
127
|
这个顶层行为根级 `ctx.fs` 调用提供服务。它把发行版 UNC 路径
|
|
@@ -110,7 +151,7 @@ Loader 在挂载该行之前会校验宿主和发行版设置;
|
|
|
110
151
|
| 行 | 键 | 默认 / shipped 值 | 说明 |
|
|
111
152
|
|---|---|---|---|
|
|
112
153
|
| `directory-picker-wsl` | `preferredDistro` | `''`(shipped) | 首位展示的发行版,也是 Home 位置使用的发行版。 |
|
|
113
|
-
| | `includeHostHome` | `true`(shipped) |
|
|
154
|
+
| | `includeHostHome` | `true`(shipped) | 提供 Windows 路径分支;该分支从驱动器根开始。 |
|
|
114
155
|
| | `maxEntries` | `1000`(shipped) | 单个目录返回的最大条目数。 |
|
|
115
156
|
| | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
|
|
116
157
|
| | `distroCacheMs` | `5000` | 发行版列表的缓存时长。 |
|
|
@@ -131,6 +172,10 @@ Loader 在挂载该行之前会校验宿主和发行版设置;
|
|
|
131
172
|
| `auto-preset` | `preset` | `wsl` | 会话工作区位于发行版内时绑定的 preset。操作者的显式选择会被保留。 |
|
|
132
173
|
| | `attempts` | `6` | 绑定 preset 的尝试次数。 |
|
|
133
174
|
| | `retryMs` | `150` | 两次尝试之间的延迟,单位毫秒。 |
|
|
175
|
+
| | `windowsWorkspaces` | `[]` | 以 Windows 访问方式打开的发行版目录(UNC 路径)。这些路径下的会话保留宿主 preset;添加工作区时的访问方式选择会写入这里,设置页可改回。 |
|
|
176
|
+
| `wsl-status` | `cacheMs` | `15000` | 单个发行版判定在内存中的新鲜时间,单位毫秒(最后一次结果另行持久化)。 |
|
|
177
|
+
| | `timeoutMs` | `90000` | 单次检查或修复运行的死线,单位毫秒。 |
|
|
178
|
+
| | `wslPath` | `wsl.exe` | 列出发行版用的 `wsl.exe`。 |
|
|
134
179
|
| `wsl-preflight` | `distro` | `''` | 要检查的发行版。空或 `auto` 跟随会话工作区。 |
|
|
135
180
|
| | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
|
|
136
181
|
| | `sandbox` | `true` | 运行会话启动时的 `bwrap` 检查。 |
|
|
@@ -287,13 +332,15 @@ wsl.exe -d <distro> -u root -- apt-get install -y bubblewrap
|
|
|
287
332
|
重启之后判定就已经出现在日志里,该发行版上的会话只会重复注入运行时上下文条目。
|
|
288
333
|
`sessionSandbox: true` 时,它还会检查会话 runtime 的前置条件。
|
|
289
334
|
该警告仅供参考:它不会安装软件包,也不会改变提供者关闭(fail-closed)
|
|
290
|
-
的行为。在该行设置 `sandbox: false`
|
|
335
|
+
的行为。在该行设置 `sandbox: false` 或移除该行可让预检警告静音。
|
|
291
336
|
profile 不使用会话 runtime 时,设置 `sessionSandbox: false`。
|
|
292
337
|
|
|
293
338
|
在 `wsl-shell` 或 `wsl-fs` 上设置 `sandbox: false` 后,命令或写入
|
|
294
339
|
将无约束地运行;其 `sandboxMode` 变为 `undefined`。工具层
|
|
295
340
|
会报告没有沙箱生效。在 `fs-routing` 上,该设置会禁用变更围栏;
|
|
296
|
-
无论开关如何,该行都报告 `sandboxMode: undefined
|
|
341
|
+
无论开关如何,该行都报告 `sandboxMode: undefined`。当所有表面都选择
|
|
342
|
+
退出——三行均为 `sandbox: false` 且 `sessionSandbox: false`——doctor
|
|
343
|
+
仍会以**警告**点名无约束状态并跳过围栏冒烟;该选择退出永不阻断裁决。
|
|
297
344
|
|
|
298
345
|
### 消息语言
|
|
299
346
|
|
|
@@ -332,16 +379,25 @@ profile 不使用会话 runtime 时,设置 `sessionSandbox: false`。
|
|
|
332
379
|
bubblewrap、systemd/Linger、peer 下限、新 agent 握手、残留会话 scope、已知的
|
|
333
380
|
profile 补丁与废弃键陷阱——每个失败附可复制的修复。运行以生效配置下计算的
|
|
334
381
|
裁决(`ready` 或 `blocked`)收尾:`--json` 是机器契约(schemaVersion 2),
|
|
335
|
-
`--fix`
|
|
336
|
-
`--
|
|
382
|
+
`--fix` 复核它修过的项(插件自有的残留 scope 清扫与 agent 缓存清理是
|
|
383
|
+
自动的;安装软件包需要 `--fix --install` 并显式确认;`--fix-owned` 把运行
|
|
384
|
+
限定在插件自有的这两类),`--all` 检查每个已装发行版,`--bundle <路径>` 写出可附加的诊断文件
|
|
337
385
|
(`--redact` 脱敏路径),`--locale <标签>`(或 `DSH_WSL_DOCTOR_LOCALE`)
|
|
338
386
|
无需重新探测即可选择骨架语言。`--yes` 跳过确认提示(不跳过确认门本身),
|
|
339
|
-
`--read-only` 拒绝与 `--fix` 或 `--install`
|
|
340
|
-
查询可用 `DSH_UPDATE_REGISTRIES` 覆盖(逗号分隔;置空即跳过,气隙机器适用)。
|
|
387
|
+
`--read-only` 拒绝与 `--fix` 或 `--install` 同用。
|
|
341
388
|
判定契约与错误码地图见 [DIAGNOSTICS.zh.md](DIAGNOSTICS.zh.md)。
|
|
342
389
|
CLI 发行版可用 `dsh --profile <name> --dump-config` 检查合成后的 profile,
|
|
343
390
|
无需真正启动;输出会显示某行的覆盖是否生效。桌面应用没有 `dsh` 命令,
|
|
344
391
|
请直接查看 `cordis.patch.yml` 与 Plugins 页面。
|
|
392
|
+
侧边栏的 **WSL 环境** 面板经 `GET /api/wsl-env/status` 渲染同一份快速摘要,
|
|
393
|
+
并把完整运行动作提交到同一路由:以 `--fix-owned` 运行 doctor,清扫残留
|
|
394
|
+
session scope、清理损坏的 agent 缓存并逐一复检。行内显示上次检查时间、来源(手动或后台)与结果结构(各状态计数与分区分布)。
|
|
395
|
+
每个发行版的最后一次结果存放在 `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`
|
|
396
|
+
(宿主未指定 home 时为 `~/.dsh/...`),页面刷新或应用重启后仍可见。加载时会对
|
|
397
|
+
正在运行的发行版在后台复核;后台失败会覆盖已存结果。不标记“已过期”——删除该
|
|
398
|
+
文件即可重置面板历史。按钮标签随报告切换:
|
|
399
|
+
存在这类可自动修复项时显示“修复”,否则显示“完整检查”;其余告警保留各自的
|
|
400
|
+
手动处理办法。它不会安装软件包,也不会改写 Windows 或用户所有的配置。
|
|
345
401
|
使用 `scripts/bootstrap.sh <distro>` 检查发行版前置依赖。
|
|
346
402
|
|
|
347
403
|
| 现象 | 结果 | 处理 |
|