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
@@ -19,12 +19,19 @@ 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
- A leg whose prerequisite failed reports `skipped` with the blocker named;
27
- `skipped` never blocks. A read the transport could not vouch for — `wsl.exe`
27
+ `functional.exec` / `functional.fs` run the shell agent; when `auto` or
28
+ `native` selects the native binary, `functional.native` runs the same EXEC and
29
+ FSB chain over it. The shell agent is then the fallback, so its failures are
30
+ warnings and name their cause (a BusyBox distro without GNU `find` reports
31
+ `find: unrecognized: -printf` and the `findutils` remedy) — unless the shell
32
+ agent is the configured backend, or neither backend answers, where the leg
33
+ blocks. A leg whose prerequisite failed reports `skipped` with the blocker
34
+ named; `skipped` never blocks. A read the transport could not vouch for — `wsl.exe`
28
35
  timed out or wedged mid-probe, common when several distros are probed
29
36
  concurrently and one of them is cold-booting — reports `unknown` after one
30
37
  automatic retry, names the flake in its detail, and never blocks or feeds a
@@ -33,10 +40,14 @@ that the file is broken. Rerun the doctor for a clean answer.
33
40
 
34
41
  `--fix` ends in a re-verified report: every fix is followed by a fresh probe
35
42
  of what it claims to have fixed, the affected checks carry the after state,
36
- and the verdict is recomputed — `ready`, or the remaining blockers. Remedies
37
- that rewrite user- or distro-owned files (`.wslconfig`, `/etc/wsl.conf`, a
38
- WSL1 conversion, installing a distro) are never automated; the remedy text
39
- says so.
43
+ and the verdict is recomputed — `ready`, or the remaining blockers. The
44
+ plugin-owned state is repaired automatically: the stale-scope sweep and a
45
+ purge of the agent cache when an entry is not executable (the handshake is
46
+ re-probed after the purge). `--fix-owned` narrows a run to exactly those two —
47
+ the sidebar panel's repair action uses it — and cannot be combined with
48
+ `--install`. Remedies that rewrite user- or distro-owned files (`.wslconfig`,
49
+ `/etc/wsl.conf`, a WSL1 conversion, installing a distro) are never automated;
50
+ the remedy text says so.
40
51
 
41
52
  `--bundle <path>` writes a local JSON file (report + versions + effective
42
53
  configuration) for a setup report; `--redact` replaces home and DSH paths
@@ -45,22 +56,38 @@ environment variables, and no telemetry.
45
56
 
46
57
  ## The surfaces
47
58
 
48
- The doctor answers through three surfaces with one report:
59
+ The doctor answers through three surfaces with one report; the sidebar's
60
+ **WSL environment** panel renders the same quick digest over its own route and
61
+ posts the full-run action (`--fix-owned`, labeled 修复 or 完整检查):
49
62
 
50
- - **The standalone CLI** — `node scripts/doctor.mjs [distro] [--all] [--json] [--quick] [--sections host,sandbox,session,conf,net,agent] [--fix] [--install] [--yes] [--read-only] [--bundle <path>] [--redact] [--locale <tag>]`
63
+ - **The standalone CLI** — `node scripts/doctor.mjs [distro] [--all] [--json] [--quick] [--sections host,sandbox,session,conf,net,agent] [--fix] [--fix-owned] [--install] [--yes] [--read-only] [--bundle <path>] [--redact] [--locale <tag>]`
51
64
  (the same line `--help` prints).
52
65
  The authoritative surface: it loads **no peer dependency and no host
53
66
  service**, so it still starts when the plugin's own runtime is the thing
54
- that is broken. Only pure, peer-free `lib/` modules are imported; the two
55
- helpers that used to live behind peer-tainted modules (`lib/index.js`,
56
- `lib/update-check.js`) are inlined and drift-pinned against the lib exports
57
- by `test/doctor.test.mjs`. Exit 0 = `ready`, 1 = `blocked`, 2 = refused
58
- (`--read-only` with `--fix`/`--install`, or `--fix` on a scoped run).
59
- - **The `/wsl-doctor` UI command** — the composer button drops a
60
- `/wsl-doctor [quick|full|<section>] [--distro <name>]` line; the commands
67
+ that is broken. Only pure, peer-free `lib/` modules are imported; the one
68
+ helper that used to live behind a peer-tainted module (`lib/index.js`) is
69
+ inlined and drift-pinned against the lib export by `test/doctor.test.mjs`. Exit 0 = `ready`, 1 = `blocked`, 2 = refused
70
+ (`--read-only` with `--fix`/`--install`, `--fix-owned` with `--install`, or
71
+ `--fix` on a scoped run).
72
+ - **The `/wsl-doctor` UI command** — typing
73
+ `/wsl-doctor [quick|full|<section>] [--distro <name>]` in the composer — the commands
61
74
  registry executes it host-side, the handler spawns the standalone CLI, and
62
75
  the itemized report renders detached from model history (no model turn, no
63
- tokens). Without a command adapter (headless, ACP) the row is a no-op and
76
+ tokens). The sidebar's **WSL environment** panel runs the same quick
77
+ check per distro through the authenticated status route, showing a badge with
78
+ numbered failing items and warnings, and a second action on a checked row: the full doctor with `--fix-owned`,
79
+ labeled **修复** when the report carries a repairable finding (stale scopes
80
+ or a broken agent cache) and **完整检查** otherwise, answered with its
81
+ before → after fix rows. The row also states when the check ran, its source
82
+ (manual or the page-load background refresh), and how its results landed —
83
+ per-status totals and per-section tallies. Each checked row expands to the
84
+ full list of checks that run executed, grouped by section with each status
85
+ and its evidence; the catalog rows a quick run never touched are counted
86
+ (`N more in the full run`), not listed as results. The last result is stored locally
87
+ (`$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`, falling back to `~/.dsh`)
88
+ so a reload still shows it; a background refresh runs only for distros that
89
+ are already up, and a failed one replaces the stored result as observed.
90
+ Manual warnings keep their remedies; full diagnosis still uses the entry above and `/wsl-doctor`. Without a command adapter (headless, ACP) the row is a no-op and
64
91
  the CLI is the surface. Without `--distro` the handler names the distro from
65
92
  the session's live working directory (the agent-scoped `workingDirectory`
66
93
  service first, then the Session header's `cwd`); when neither yields a WSL
@@ -93,8 +120,9 @@ Class legend:
93
120
  |---|---|---|---|
94
121
  | `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`, `sandbox.bwrap-usable`, `functional.sandbox` | the requested confinement cannot be enforced (no usable bubblewrap) |
95
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 |
96
124
  | `FS_OUTSIDE_DISTRO` | policy | `config.effective` (the effective `distro`) | the path names another distro's share while the fence is pinned |
97
- | `FS_IO_ERROR` | environment | `distro.reachable`, `distro.disk`, `agent.handshake`, `functional.exec`, `functional.fs` | the catch-all: an agent outage, a wedged distro, a full disk, an unmappable path |
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 |
98
126
  | `FS_NOT_FOUND` | data | — | the path does not exist — the ordinary answer |
99
127
  | `FS_NOT_REGULAR_FILE` | data | — | a directory, symlink or device where a regular file is required |
100
128
  | `FS_NOT_DIRECTORY` | data | — | a list was asked of a non-directory |
@@ -107,7 +135,7 @@ Class legend:
107
135
  | `FS_AMBIGUOUS_EDIT` | data | — | the literal edit matched more than once |
108
136
  | `FS_PATCH_MISMATCH` | data | — | the hunks no longer match the file; rebuild them |
109
137
  | `FS_SAME_TARGET` | data | — | a move whose source and destination are the same file |
110
- | `AgentUnavailableError` | environment | `agent.handshake`, `agent.native`, `agent.cache`, `functional.exec` | the execution layer's revival budget is spent; the named state says so |
138
+ | `AgentUnavailableError` | environment | `agent.handshake`, `agent.native`, `agent.cache`, `agent.home-writable`, `functional.exec`, `functional.native` | the execution layer's revival budget is spent; the named state says so |
111
139
 
112
140
  The agent's structured FS reasons (`notfound`, `notdir`, `perm`, `loop`,
113
141
  `stale`, `io`) map onto the codes above at `lib/fsio-agent.js`; the wire
@@ -14,11 +14,19 @@
14
14
  `sessionSandbox: true` 时 fail;`auto` 点名其 per-command 回退,`false`
15
15
  点名选择退出,两者均为 warn),因此裁决回答的是**生效配置**——应用实际
16
16
  加载的 profile 层叠加在出厂 preset 之上——而不是出厂默认。`config.effective`
17
- 检查报告读到了什么、从哪里读的。
17
+ 检查报告读到了什么、从哪里读的。有意的选择退出从不构成失败:当所有表面都
18
+ 关闭隔离(`sandbox: false` 且 `sessionSandbox: false`),沙箱检查发出
19
+ **警告**点名 UNCONFINED 状态,并跳过围栏冒烟——醒目,但不阻断。
18
20
 
19
- `verdict: ready` 表示首条命令应在目标 distro、预期 scope 下成功;smoke 腿
21
+ `verdict: ready` 表示本次运行覆盖的检查在目标 distro、预期 scope 下全部通过,
22
+ 不保证之后每条命令都成功;smoke 腿
20
23
  (`functional.exec`、`functional.sandbox`、`functional.fs`)证明链路本身——
21
- 帧 I/O、受限围栏、批量 substrate——而不只是前置条件。前置失败的腿以
24
+ 帧 I/O、受限围栏、批量 substrate——而不只是前置条件。`functional.exec` /
25
+ `functional.fs` 运行 shell agent;当 `auto` 或 `native` 选中 native 二进制时,
26
+ `functional.native` 在它之上跑同一条 EXEC 与 FSB 链路。此时 shell agent 是
27
+ 回退,其失败降为警告并点名原因(未装 GNU `find` 的 BusyBox 会报
28
+ `find: unrecognized: -printf`,并给出 `findutils` 的处理办法)——除非配置
29
+ 钉死 shell agent,或两个后端都答不出,则仍为阻断。前置失败的腿以
22
30
  `skipped` 报告并点名阻断者;`skipped` 永不阻断。传输层无法担保的读数——
23
31
  `wsl.exe` 超时或探测中途卡死(多个 distro 并发探测、其中一个正在冷启动时
24
32
  最常见)——在自动重试一次后报告 `unknown`,detail 点名该次抖动;`unknown`
@@ -27,8 +35,11 @@
27
35
 
28
36
  `--fix` 以复验报告收尾:每个修复后都跟着一次对它声称修好的东西的全新探查,
29
37
  受影响的检查项携带 after 状态,verdict 重算——`ready`,或剩余阻断者。
30
- 会改写用户或 distro 所有文件的修复(`.wslconfig`、`/etc/wsl.conf`、WSL1
31
- 转换、安装 distro)永不开启自动化;补救文本会写明。
38
+ 插件自有状态会被自动修复:残留 scope 清扫,以及缓存条目不可执行时清理
39
+ agent 缓存(清理后重新握手)。`--fix-owned` 把运行收窄到这两类——侧边栏
40
+ 面板的“修复”动作即用它——且不能与 `--install` 同用。会改写用户或 distro
41
+ 所有文件的修复(`.wslconfig`、`/etc/wsl.conf`、WSL1 转换、安装 distro)
42
+ 永不开启自动化;补救文本会写明。
32
43
 
33
44
  `--bundle <path>` 写出本地 JSON 文件(报告 + 版本 + 生效配置)供 setup
34
45
  report 附带;`--redact` 把 home 与 DSH 路径替换为 `<redacted-*>` 占位符。
@@ -36,20 +47,30 @@ bundle 不含文件内容、环境变量,也没有遥测。
36
47
 
37
48
  ## 三个入口
38
49
 
39
- doctor 通过三个入口给出同一份报告:
50
+ doctor 通过三个入口给出同一份报告;侧边栏的 **WSL 环境** 面板经自己的
51
+ 路由渲染同一份快速摘要,并提交完整运行动作(`--fix-owned`,按报告标为修复或完整检查):
40
52
 
41
- - **独立 CLI**——`node scripts/doctor.mjs [distro] [--all] [--json] [--quick] [--sections host,sandbox,session,conf,net,agent] [--fix] [--install] [--yes] [--read-only] [--bundle <路径>] [--redact] [--locale <标签>]`
53
+ - **独立 CLI**——`node scripts/doctor.mjs [distro] [--all] [--json] [--quick] [--sections host,sandbox,session,conf,net,agent] [--fix] [--fix-owned] [--install] [--yes] [--read-only] [--bundle <路径>] [--redact] [--locale <标签>]`
42
54
  (与 `--help` 输出同一行)。
43
55
  这是权威入口:它**不加载任何 peer 依赖、任何宿主服务**,即使插件的运行时
44
56
  本身就是故障源,它也能启动。只 import 纯净、无 peer 的 `lib/` 模块;原先
45
- 挂在 peer 污染模块(`lib/index.js`、`lib/update-check.js`)后面的两个
46
- helper 已内联,并由 `test/doctor.test.mjs` 与 lib 导出对拍防漂移。
57
+ 挂在 peer 污染模块(`lib/index.js`)后面的唯一 helper 已内联,并由
58
+ `test/doctor.test.mjs` 与 lib 导出对拍防漂移。
47
59
  退出码 0 = `ready`,1 = `blocked`,2 = 拒绝(`--read-only` 与
48
- `--fix`/`--install` 同用,或对范围化运行使用 `--fix`)。
49
- - **`/wsl-doctor` UI 命令**——composer 按钮投下
60
+ `--fix`/`--install` 同用、`--fix-owned` 与 `--install` 同用,或对范围化
61
+ 运行使用 `--fix`)。
62
+ - **`/wsl-doctor` UI 命令**——在输入框输入
50
63
  `/wsl-doctor [quick|full|<分区>] [--distro <名称>]`;命令面在宿主侧执行,
51
64
  handler 子进程运行独立 CLI,逐项报告直接渲染在 UI 上、不进模型历史
52
- (无模型回合、零 token)。没有命令适配器的部署(headless、ACP)中该行是
65
+ (无模型回合、零 token)。侧边栏的 **WSL 环境** 面板按发行版运行同源的快速检查,
66
+ 结果以状态徽标、编号的待修项与告警列出;已检查的行还提供一个完整 doctor 动作(`--fix-owned`):报告中存在可自动修复项
67
+ (残留 scope 或损坏的 agent 缓存)时标为 **修复**,否则标为 **完整检查**;
68
+ 返回 before → after 的修复行。行内同时给出上次检查时间、来源(手动或页面加载时的后台复核)与结果结构(各状态
69
+ 计数与分区分布)。每个已检查的行可展开查看本次运行执行的全部检查项,按分区分组、逐项带状态与依据;
70
+ 快速检查未触及的目录项只以“完整检查还会运行 N 项”计数,不伪装成结果。最后一次结果存放在本地(`$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`,
71
+ 缺省回退到 `~/.dsh`),刷新后仍可见;后台复核只针对正在运行的发行版,失败时按
72
+ 实际观测覆盖已存结果。手动告警保留各自处理办法;
73
+ 完整诊断仍走上面的入口与 `/wsl-doctor`。没有命令适配器的部署(headless、ACP)中该行是
53
74
  no-op,CLI 就是入口。未给 `--distro` 时,handler 从会话当前工作目录解析
54
75
  发行版(先读 agent 作用域的 `workingDirectory` 服务,再退回 Session 头部
55
76
  记录的 `cwd`);两者都给不出 WSL UNC 路径时,由 CLI 的生效配置决定,而
@@ -76,8 +97,9 @@ doctor 通过三个入口给出同一份报告:
76
97
  |---|---|---|---|
77
98
  | `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`、`sandbox.bwrap-usable`、`functional.sandbox` | 所请求的隔离无法强制(无可用 bubblewrap) |
78
99
  | `FS_SANDBOX_DENIED` | policy | `functional.sandbox`(围栏形状) | 文件效果策略拒绝了写入,或内核在驻留 agent 的 profile 处拒绝 |
100
+ | `SANDBOX_INVALID_ROOT` | configuration | —(`writableRoots` 的逐项检查在首次使用时进行,doctor 不预跑) | 额外可写目录格式错误、指向另一个世界,或未通过物理目录检查 |
79
101
  | `FS_OUTSIDE_DISTRO` | policy | `config.effective`(生效的 `distro`) | 围栏钉死时路径指向另一 distro 的共享 |
80
- | `FS_IO_ERROR` | environment | `distro.reachable`、`distro.disk`、`agent.handshake`、`functional.exec`、`functional.fs` | 兜底:agent 失联、distro 僵死、磁盘满、无法映射的路径 |
102
+ | `FS_IO_ERROR` | environment | `distro.reachable`、`distro.disk`、`host.disk`、`agent.handshake`、`agent.home-writable`、`functional.exec`、`functional.fs` | 兜底:agent 失联、distro 僵死、磁盘满、无法映射的路径 |
81
103
  | `FS_NOT_FOUND` | data | — | 路径不存在——普通答案 |
82
104
  | `FS_NOT_REGULAR_FILE` | data | — | 需要常规文件处出现了目录、符号链接或设备 |
83
105
  | `FS_NOT_DIRECTORY` | data | — | 对非目录发起列表 |
@@ -90,7 +112,7 @@ doctor 通过三个入口给出同一份报告:
90
112
  | `FS_AMBIGUOUS_EDIT` | data | — | 字面编辑命中多处 |
91
113
  | `FS_PATCH_MISMATCH` | data | — | hunk 与文件不再吻合;按新文本重建 |
92
114
  | `FS_SAME_TARGET` | data | — | move 的源与目的地解析为同一文件 |
93
- | `AgentUnavailableError` | environment | `agent.handshake`、`agent.native`、`agent.cache`、`functional.exec` | 执行层的复活预算耗尽;具名状态会说明 |
115
+ | `AgentUnavailableError` | environment | `agent.handshake`、`agent.native`、`agent.cache`、`agent.home-writable`、`functional.exec`、`functional.native` | 执行层的复活预算耗尽;具名状态会说明 |
94
116
 
95
117
  agent 的结构化 FS 原因(`notfound`、`notdir`、`perm`、`loop`、`stale`、
96
118
  `io`)在 `lib/fsio-agent.js` 映射到上表各码;线上方言本身见
@@ -29,6 +29,12 @@ operations never use the 9p share.
29
29
  after the rename (shell agent). The native agent keeps its file-level
30
30
  `sync_all` only — see the peer-parity divergence note. A filesystem that
31
31
  refuses a directory fsync keeps the peer's own promise.
32
+ - **The shell agent's tool floor is GNU.** It needs coreutils, GNU `find`
33
+ (`-printf`), `realpath` and `od`; a minimal BusyBox image (Alpine without
34
+ `findutils`) fails its FSB stat/list with `find: unrecognized: -printf`. The
35
+ packaged native agent, which `auto` prefers, does not need those tools —
36
+ install `findutils` only when pinning `agentBackend: shell`.
37
+
32
38
  - **A Linux filename containing a backslash cannot be addressed** — the backslash is
33
39
  the UNC separator, so `a\b.ts` round-trips to `a/b.ts`. Rename away from backslash
34
40
  names; this is the coordinate system's own limit.
@@ -95,6 +101,16 @@ operations never use the 9p share.
95
101
  [ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement).
96
102
  - **`bubblewrap` must be installed**, or both providers fail with the install
97
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.
98
114
  - **Message localization is partial by design** — the preflight verdicts, `bwrap`
99
115
  remedies and distro/workdir errors follow the app's Language setting
100
116
  ([CONFIGURATION.md](CONFIGURATION.md#message-language)); the `FS_*` refusal texts
@@ -160,22 +176,33 @@ CLI's `--all` says the same thing explicitly). The handler bounds an unresolved
160
176
  run at 60 s (a resolved one at 120 s) so it settles with the narrowing hint
161
177
  instead of leaving the card "executing" for the dispatcher's whole budget.
162
178
 
163
- The doctor reads and reports; it never rewrites user- or distro-owned files.
179
+ The sidebar's stored result is a record of the last run, not a live verdict:
180
+ its timestamp and source say which run it is, and a probe is never started for
181
+ a stopped distro in the background. The doctor reads and reports; it never
182
+ rewrites user- or distro-owned files.
164
183
  `.wslconfig`, `/etc/wsl.conf`, a WSL1 conversion and distro installation are
165
184
  remedy-only — the remedy text carries the exact command — and the fixable set
166
- is limited to what is safe and reversible (stale scopes, the optional
167
- packages behind `--install` plus a confirmation, and the Windows git
168
- safe.directory whitelist behind the same gate). The verdict never upgrades
169
- the sandbox's security statement: `enforcement: partial` is untouched.
185
+ is limited to what is safe and reversible (stale scopes, the plugin-owned
186
+ agent cache, the optional packages behind `--install` plus a confirmation, and
187
+ the Windows git safe.directory whitelist behind the same gate). `--fix-owned`
188
+ narrows a run to the plugin-owned two (stale scopes and the cache); the
189
+ sidebar panel's full-run action is exactly that run, labeled **修复** only when
190
+ one of those findings is present and **完整检查** otherwise, so it can never
191
+ install a package or write Windows-owned configuration, and it never implies
192
+ that a remedy-only warning is auto-fixable. The verdict never upgrades the
193
+ sandbox's security statement: `enforcement: partial` is untouched.
170
194
 
171
195
  ## Session-start advisories
172
196
 
173
- - **There is no session-UI notice seam in DSH 0.2.1.** `wsl-preflight` failures go
174
- to the host log and the session's runtime context (model-visible next assembly) —
175
- advisory only, never installing or cancelling. The upstream ask:
176
- [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).
177
202
  - **The runtime-context entry is a repeated snapshot, not a dismissible
178
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.
179
206
 
180
207
  ## Ports
181
208
 
@@ -26,6 +26,12 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
26
26
  rename 之后所在目录也会尽力 fsync(shell agent)。native agent 目前只有
27
27
  文件级 `sync_all` —— 见 peer 对齐文档的分歧注记。拒绝目录 fsync 的
28
28
  文件系统保持与对端相同的承诺。
29
+ - **shell agent 的工具下限是 GNU 套件。** 它需要 coreutils、GNU `find`
30
+ (`-printf`)、`realpath` 与 `od`;最小化 BusyBox 镜像(未装 `findutils`
31
+ 的 Alpine)会在 FSB stat/list 上失败并报 `find: unrecognized: -printf`。
32
+ `auto` 优先使用的打包 native agent 不需要这些工具——只有在钉死
33
+ `agentBackend: shell` 时才需要安装 `findutils`。
34
+
29
35
  - **含反斜杠的 Linux 文件名无法被寻址** —— 反斜杠是 UNC 分隔符,
30
36
  `a\b.ts` 会往返成 `a/b.ts`。请把文件名改掉,不要用反斜杠;
31
37
  这是坐标系自身的限制。
@@ -90,6 +96,13 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
90
96
  [ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement)。
91
97
  - **必须安装 `bubblewrap`**,否则两个提供者都会带着安装命令失败;
92
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` 覆盖或嵌套在另一条授权内的条目不绑定。
93
106
  - **消息本地化按设计只覆盖一部分** —— 预检判定、`bwrap` 修复提示与
94
107
  发行版/工作目录错误跟随应用的语言设置
95
108
  ([CONFIGURATION.zh.md](CONFIGURATION.zh.md#消息语言));`fs-decisions`
@@ -146,21 +159,27 @@ doctor 的 `verdict` 在生效配置(应用加载的 profile 层叠加在随
146
159
  的运行设 60 秒时限(已解析出发行版时 120 秒),让它带着收窄提示收尾,而不是
147
160
  一直显示「执行中」直到命令面的整个预算耗尽。
148
161
 
149
- doctor 只读取和报告,从不改写用户或发行版所有的文件。`.wslconfig`、
162
+ 侧边栏保存的是上一次运行的结果,不是实时裁决:时间戳与来源标明它是哪次运行,
163
+ 后台也不会为已停止的发行版启动探测。doctor 只读取和报告,从不改写用户或发行版
164
+ 所有的文件。`.wslconfig`、
150
165
  `/etc/wsl.conf`、WSL1 转换和发行版安装只以补救命令的形式出现——补救文本
151
- 携带确切的命令;可自动修复的集合仅限安全且可逆的部分(过期 scope、
152
- `--install` 加确认后的可选软件包、以及同一道确认门后的 Windows git
153
- `safe.directory` 白名单)。裁决从不升级沙箱的安全声明:
166
+ 携带确切的命令;可自动修复的集合仅限安全且可逆的部分(过期 scope、插件自有的
167
+ agent 缓存、`--install` 加确认后的可选软件包、以及同一道确认门后的
168
+ Windows git `safe.directory` 白名单)。`--fix-owned` 把运行收窄到插件自有
169
+ 的两类(过期 scope 与缓存);侧边栏面板的“修复”动作正是这次运行,存在这两类
170
+ 可修复项时标为“修复”,否则标为“完整检查”,因此它永远不会安装软件包或
171
+ 改写 Windows 所有的配置,也不会暗示仅能手动处理的告警可被自动修复。裁决从不升级沙箱的安全声明:
154
172
  `enforcement: partial` 不受影响。
155
173
 
156
174
  ## 会话启动建议
157
175
 
158
- - **DSH 0.2.1 没有会话 UI 通知接缝。** `wsl-preflight` 的失败进入宿主日志
176
+ - **DSH 0.2.1 没有会话 UI 通知接缝。** `wsl-preflight` 的阻塞裁决进入宿主日志
159
177
  和会话的 runtime context(下次组装时对模型可见)——仅供参考,从不安装、
160
- 从不取消。对上游的请求见:
178
+ 从不取消。ready 裁决只写日志:“前置项可用”不是模型的动作。对上游的请求见:
161
179
  [UPSTREAM-SESSION-NOTICE.md](UPSTREAM-SESSION-NOTICE.md)。
162
180
  - **runtime context 条目是重复的快照,不是可关闭的通知。**
163
- 移除 `wsl-preflight` 行即可让该探针完全静音。
181
+ 移除 `wsl-preflight` 行即可让该探针完全静音。阻塞消息把修复标记为用户操作;
182
+ ready 裁决不再发送。
164
183
 
165
184
  ## 端口
166
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.
@@ -23,22 +23,28 @@ supplies the WSL environment.
23
23
  | systemd + Linger (for the session runtime) | `node <plugin>/scripts/doctor.mjs` (installed) or `pnpm run doctor` (checkout) | `[boot] systemd=true` in `/etc/wsl.conf`, `wsl --shutdown`, then `loginctl enable-linger "$USER"`; or set `sessionSandbox: auto`/`false` |
24
24
  | Node `^22.19.0` or `>=24.0.0` | only needed for source/development work | not needed inside the distro to use the published plugin |
25
25
 
26
- No terminal at hand? Three ways without one: the **WSL 诊断** button in the
27
- composer opens a menu (quick, full, or one section) and drops a `/wsl-doctor`
28
- command that runs host-side and renders in the UI — no model turn, no tokens;
29
- in a session, ask for a diagnosis and the model runs the `wsl_doctor` tool
30
- (mounted by this plugin), the verdict landing in the transcript; and the
31
- session-start preflight announces the same verdict on every session start.
26
+ No terminal at hand? Several ways without one: the sidebar's **WSL
27
+ environment** panel runs a quick doctor check per distro, listing the badge,
28
+ numbered failing items and warnings, and offers the full run labeled **修复** for the plugin-owned state when such a
29
+ finding exists (stale scopes and a broken agent cache), **完整检查** otherwise; typing `/wsl-doctor [quick|full|<section>]`
30
+ in the composer also runs host-side and renders in the UI — no model turn, no
31
+ tokens; in a session, ask for a diagnosis and the model runs the `wsl_doctor`
32
+ tool (mounted by this plugin), the verdict landing in the transcript; and the
33
+ session-start preflight logs the same verdict on every session start, and adds
34
+ it to the session's context only when blocked.
32
35
  `DSH_WSL_DOCTOR` additionally carries a ready-to-run command for the doctor
33
36
  script itself (`sh -c "$DSH_WSL_DOCTOR --json"`).
34
37
 
35
38
  The doctor (`scripts/doctor.mjs`, or `pnpm run doctor` from a checkout) checks
36
- the environment and ends in a verdict: `ready` means the first command should
37
- succeed; `blocked` names the exact checks to fix, each with a copy-paste
38
- remedy. It reads the distro's WSL mode from `wsl.exe -l -v` itself, so no
39
- separate version check is needed. Doctor is read-only unless you pass `--fix`
40
- (stale scopes, and the Windows git trust after a confirmation) or
41
- `--fix --install` (packages, after a confirmation); `--bundle <path>` writes
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`
44
+ (the stale-scope sweep and a broken agent cache, both re-verified; the Windows
45
+ git trust after a confirmation) or `--fix --install` (packages, after a
46
+ confirmation); `--fix-owned` restricts a fix run to the plugin-owned state
47
+ (the panel's repair action); `--bundle <path>` writes
42
48
  the diagnostic file a setup report attaches (`--redact` strips the paths
43
49
  from it). A run can be scoped — `--quick` probes the first-command
44
50
  prerequisites only (~10 s), `--sections <list>` (comma-separated) runs the
@@ -76,6 +82,25 @@ profile of that name.)
76
82
  In the GUI, open a folder through the picker (`\\wsl.localhost\<distro>\home\<you>\proj`)
77
83
  or an UNC path directly. The session's commands, file tools, terminal and previews
78
84
  all run in that distro; a Windows folder keeps the normal Windows environment.
85
+
86
+ The sidebar's **WSL environment** panel is the diagnostic page: it lists the
87
+ installed distros, runs one distro's quick doctor check on demand (showing
88
+ whether bwrap, systemd and Linger are in place), and offers **修复** on a checked
89
+ row as a full doctor with `--fix-owned` — labeled **修复** when a finding is
90
+ repairable (a stale session scope or a broken agent cache) and **完整检查**
91
+ otherwise; the row also shows when the check ran, its source (manual, or the
92
+ page-load background refresh), and its result structure (pass/warn/fail/info/
93
+ skip, plus the per-section tallies). The last result survives a page reload
94
+ from the local store, and a stored result for a running distro is re-checked
95
+ in the background on load. The run sweeps the scopes and purges the cache when they need it,
96
+ then re-verifies; every other warning keeps its manual remedy, and the action
97
+ never installs packages or rewrites Windows-owned configuration (a check boots
98
+ a stopped distro, so either action only runs on a click). Workspaces still open through **Add workspace**; selecting a folder inside a
99
+ distro through the picker makes the app ask once how to open it: **Remote
100
+ WSL** (the default — commands, files and the terminal all run in the distro) or
101
+ **Windows access** (the folder as an ordinary Windows share over 9p, without the
102
+ Linux toolchain). The choice is recorded in the `auto-preset` row's
103
+ `windowsWorkspaces` and applies to later sessions in that workspace too.
79
104
  Two distros can be open at once, each with its own environment.
80
105
 
81
106
  ### Open the workspace in VS Code (Remote-WSL)
@@ -141,6 +166,11 @@ pnpm test
141
166
  pnpm dev # a dev server survives the command that started it with sessionSandbox: true
142
167
  ```
143
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
+
144
174
  The server's port can appear in `DSH_WSL_PORTS` after a successful snapshot
145
175
  (refreshed every 10 s by default); open a forwarded port from Windows at
146
176
  `http://localhost:<port>`.
@@ -22,18 +22,22 @@ _本页是权威版本;英文译本见 [QUICKSTART](QUICKSTART.md)。_
22
22
  | systemd + Linger(会话 runtime 需要) | `node <plugin>/scripts/doctor.mjs`(已安装)或 `pnpm run doctor`(检出目录) | 在 `/etc/wsl.conf` 设置 `[boot] systemd=true`,`wsl --shutdown`,然后 `loginctl enable-linger "$USER"`;或设置 `sessionSandbox: auto`/`false` |
23
23
  | Node `^22.19.0` 或 `>=24.0.0` | 仅源码/开发工作需要 | 使用已发布的插件时,发行版内不需要 Node |
24
24
 
25
- 手边没有终端?有三条不依赖终端的路:composer 里的 **WSL 诊断** 按钮打开菜单
26
- (quick、full 或单个分区),投下一条 `/wsl-doctor` 命令——宿主侧执行、直接在
27
- UI 渲染,不进模型对话、零 token;在会话里请求诊断,模型会运行本插件挂载的
28
- `wsl_doctor` 工具,判定落在对话里;会话启动预检在每次会话打开时通报同样的
29
- 判定。`DSH_WSL_DOCTOR` 还携带一条现成命令,可在发行版内执行 doctor 脚本本身
25
+ 手边没有终端?有几条不依赖终端的路:侧边栏的 **WSL 环境** 面板按发行版运行
26
+ doctor 快速检查,结果以状态徽标、编号的待修项与告警列出,并在存在相应可修复项时把对插件自有状态
27
+ (残留 scope、损坏的 agent 缓存)的完整运行标为 **修复**,否则标为 **完整检查**;在输入框里输入
28
+ `/wsl-doctor [quick|full|<分区>]` 同样在宿主侧执行、直接渲染在 UI,不进模型
29
+ 对话、零 token;在会话里请求诊断,模型会运行本插件挂载的 `wsl_doctor` 工具,
30
+ 判定落在对话里;会话启动预检在每次会话打开时把同样的判定写进日志,只有 blocked
31
+ 判定同时进入会话上下文。`DSH_WSL_DOCTOR` 还携带一条现成命令,可在发行版内执行 doctor 脚本本身
30
32
  (`sh -c "$DSH_WSL_DOCTOR --json"`)。
31
33
 
32
34
  doctor(`scripts/doctor.mjs`,或在检出目录中运行 `pnpm run doctor`)会检查
33
- 环境并以裁决收尾:`ready` 表示首条命令应能成功;`blocked` 会列明待修项,
35
+ 环境并以裁决收尾:`ready` 表示本次运行覆盖的检查全部通过,不保证每条命令都成功;`blocked` 会列明待修项,
34
36
  每项附可复制的处理办法。发行版的 WSL 模式由 doctor 自己从 `wsl.exe -l -v`
35
- 读取,无需单独确认。doctor 默认只读,除非传入 `--fix`(清理过期 scope,以及
36
- 确认后的 Windows git 信任)或 `--fix --install`(安装软件包,需确认);
37
+ 读取,无需单独确认。doctor 默认只读,除非传入 `--fix`(清理过期 scope、清理损坏的
38
+ agent 缓存,两者都会复检;以及确认后的 Windows git 信任)或
39
+ `--fix --install`(安装软件包,需确认);`--fix-owned` 把修复限定在
40
+ 插件自有状态(面板的“修复”动作);
37
41
  `--bundle <路径>` 写出可附加到问题报告的诊断文件(`--redact`
38
42
  将其中的路径脱敏)。运行可以收窄范围——`--quick` 只探首条命令的前置项
39
43
  (约 10 秒),`--sections <分区清单>`(逗号分隔)只运行指定分区——
@@ -71,6 +75,18 @@ dsh --profile <profile> --dump-config # 输出中必须包含插件的行
71
75
  都在该发行版中运行;打开 Windows 文件夹则保留正常的 Windows 环境。
72
76
  两个发行版可以同时打开,各自拥有自己的环境。
73
77
 
78
+ 侧边栏的 **WSL 环境** 面板是诊断页:它列出已安装的发行版,可对单个发行版运行
79
+ 一次 doctor 快速检查,显示 bwrap、systemd、Linger 等前置项是否正常;已检查的行提供一次完整 doctor(`--fix-owned`):存在可自动修复项(残留 session
80
+ scope 或损坏的 agent 缓存)时标为 **修复**,否则标为 **完整检查**;行内还显示上次
81
+ 检查时间、来源(手动,或页面加载时的后台复核)与结果结构(通过/告警/失败/
82
+ 信息/跳过,以及分区分布);最后一次结果会从本地存档恢复,正在运行的发行版会在
83
+ 页面加载时后台复核;运行时按需清扫
84
+ 残留 scope、清理缓存并逐一复检,其余告警保留各自的手动处理办法,不安装软件包、
85
+ 不改写 Windows 配置(检查会让停止的发行版启动,所以两种动作都只在点击时执行)。工作区仍在 **添加工作区** 里打开;选中发行版内的文件夹时,应用会问一次打开方式:**Remote WSL**(默认,命令、
86
+ 文件与终端都在发行版内)或 **Windows 访问**(把该文件夹当作普通 Windows 共享,经 9p
87
+ 读写,没有 Linux 工具链)。选择记录在 `auto-preset` 行的 `windowsWorkspaces` 里,
88
+ 对该工作区之后新建的会话同样生效。
89
+
74
90
  ### 在 VS Code 中打开工作区(Remote-WSL)
75
91
 
76
92
  把 WSL 文件夹当作 Windows UNC 共享打开也可行,但属于降级模式:
@@ -133,6 +149,11 @@ pnpm test
133
149
  pnpm dev # a dev server survives the command that started it with sessionSandbox: true
134
150
  ```
135
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
+
136
157
  快照成功后(默认每 10 s 刷新一次),server 的端口可能出现在 `DSH_WSL_PORTS`
137
158
  中;从 Windows 通过 `http://localhost:<port>` 访问转发的端口。
138
159
 
package/docs/README.zh.md CHANGED
@@ -47,7 +47,7 @@ Windows 上的编程工具要在 WSL 项目中工作,有三条路:把整个
47
47
  - **发行版内没有服务。** 没有辅助服务、没有守护进程、没有监听端口。唯一持久化的内容是 `~/.cache/dsh-wsl/agent/` 下按内容寻址的原生 agent 副本。
48
48
  - **默认有沙箱。** 受限命令在发行版内的 `bubblewrap` 中运行。缺少 `bubblewrap` 时命令直接失败,不会脱箱运行。
49
49
  - **按会话生效。** 打开发行版文件夹的会话获得发行版环境;打开 Windows 文件夹的会话保留 Windows 工具。两者可同时运行在一个 harness 进程中。
50
- - **与 GUI 集成。** 文件夹选择器列出已安装的发行版,终端在发行版内打开 shell,模型能看到监听端口。composer 里的诊断按钮以 `/wsl-doctor` 命令运行环境诊断——宿主侧执行,不进模型对话;会话启动预检在每次会话打开时通报环境判定。
50
+ - **与 GUI 集成。** 文件夹选择器列出已安装的发行版,终端在发行版内打开 shell,模型能看到监听端口。侧边栏的 **WSL 环境** 面板按发行版运行 doctor 快速检查——宿主侧执行,不进模型对话;会话启动预检在每次会话打开时把环境判定写进日志,只有 blocked 判定同时进入会话上下文。
51
51
 
52
52
  ### 为什么是 Linux,而不是 PowerShell
53
53
 
@@ -111,9 +111,9 @@ dsh --profile wsl # 启动
111
111
  wsl.exe -d <发行版> -u root -- apt-get install -y bubblewrap
112
112
  ```
113
113
 
114
- 在插件检出目录中,`pnpm run doctor` 是一键环境体检:Windows/WSL 版本、每个发行版的 WSL 模式、`.wslconfig` 与 `/etc/wsl.conf` 交叉核对、磁盘、时钟与 DNS、bubblewrap 可用性、systemd / user manager / Linger、可选工具、peer 版本、agent 缓存、新 agent 握手、三条证明链路完好的冒烟腿(帧 I/O、受限围栏、批量 substrate)、残留会话 scope、已知的 profile 补丁与废弃键陷阱,以及 registry 上是否存在更新的稳定版。报告逐项列出每个检查——按 distro 分组,每项带显式状态标记,失败项下附可复制的处理办法——并以裁决收尾:`ready`(首条命令应能成功)或 `blocked`(列明待修项),按生效配置计算。运行可以收窄范围:`--quick` 只探首条命令的前置项(约 10 秒),`--sections <分区清单>`(逗号分隔)只运行指定分区,且范围化报告会把未运行的检查显式列为跳过项。`--json` 供脚本使用,`--fix` 会复核它修过的项(安装包需要 `--fix --install` 并显式确认),`--all` 检查每个已装发行版,`--bundle <路径>` 写出可附加到问题报告的诊断文件(`--redact` 将路径脱敏)。固定骨架按宿主语言渲染——从 Windows 区域设置检测,可用 `--locale <标签>` 或 `DSH_WSL_DOCTOR_LOCALE` 覆盖;`--json` 保持语言无关。同一份报告经三个入口给出:本 CLI、`/wsl-doctor` 命令(composer 按钮——宿主侧执行,不进模型对话)、以及 `wsl_doctor` 模型工具(进程内采集,合并常驻 agent 的实时状态)。`DSH_WSL_DOCTOR` 还携带一条现成命令(`sh -c "$DSH_WSL_DOCTOR --json"`),可在发行版内直接重放 doctor。`pnpm run diagnose` 是 CLI 的只读别名。`pnpm run bootstrap <发行版>` 仍是较窄的工具安装助手。
114
+ 在插件检出目录中,`pnpm run doctor` 是一键环境体检:Windows/WSL 平台、每个发行版的 WSL 模式与身份、`.wslconfig` 与 `/etc/wsl.conf` 交叉核对、发行版与宿主卷、时钟与 DNS、bubblewrap 可用性、systemd / user manager / Linger、可选工具、peer 版本、native agent 与其缓存、新 agent 握手、证明链路完好的 shell 冒烟腿(帧 I/O、受限围栏、批量 substrate)与一条 native HELLO 腿、残留会话 scope、已知的 profile 补丁与废弃键陷阱。报告逐项列出每个检查——按 distro 分组,每项带显式状态标记,失败项下附可复制的处理办法——并以裁决收尾:`ready`(本次运行覆盖的检查全部通过,不保证每条命令都成功)或 `blocked`(列明待修项),按生效配置计算。运行可以收窄范围:`--quick` 只探首条命令的前置项(约 10 秒),`--sections <分区清单>`(逗号分隔)只运行指定分区,且范围化报告会把未运行的检查显式列为跳过项。`--json` 供脚本使用;`--fix` 会复核它修过的项——插件自有的残留 scope 清扫与 agent 缓存清理是安全自动的,安装包需要 `--fix --install` 并显式确认,`--fix-owned` 只运行插件自有的这两类(即侧边栏面板的“修复”动作)——`--all` 检查每个已装发行版,`--bundle <路径>` 写出可附加到问题报告的诊断文件(`--redact` 将路径脱敏)。固定骨架按宿主语言渲染——从 Windows 区域设置检测,可用 `--locale <标签>` 或 `DSH_WSL_DOCTOR_LOCALE` 覆盖;`--json` 保持语言无关。同一份报告经三个入口给出:本 CLI、`/wsl-doctor` 命令(在输入框输入——宿主侧执行,不进模型对话)、以及 `wsl_doctor` 模型工具(进程内采集,合并常驻 agent 的实时状态)。`DSH_WSL_DOCTOR` 还携带一条现成命令(`sh -c "$DSH_WSL_DOCTOR --json"`),可在发行版内直接重放 doctor。`pnpm run diagnose` 是 CLI 的只读别名。`pnpm run bootstrap <发行版>` 仍是较窄的工具安装助手。
115
115
 
116
- 插件大约每天自行检查一次更新(启动后 2–10 分钟内首查),方式是询问应用的插件管理器——它从不自行联网。当存在更新的稳定版时,每个发行版会话中受管的 `DSH_WSL_PLUGIN_UPDATE` 变量会携带该事实;补丁配置里的 `wsl-update-check.enabled: false` 可关闭该检查,`DSH_UPDATE_REGISTRIES` 覆盖 doctor 的按需检查询问哪些 registry(逗号分隔,留空可让气隙机器跳过)。升级保持手动,因为 harness 没有热重载:重新安装(Plugins 页面或 `add` 命令),然后重启。
116
+ 插件大约每天自行检查一次更新(启动后 2–10 分钟内首查),方式是询问应用的插件管理器——它从不自行联网。当存在更新的稳定版时,每个发行版会话中受管的 `DSH_WSL_PLUGIN_UPDATE` 变量会携带该事实;补丁配置里的 `wsl-update-check.enabled: false` 可关闭该检查。升级保持手动,因为 harness 没有热重载:重新安装(Plugins 页面或 `add` 命令),然后重启。
117
117
 
118
118
  卸载:在 Plugins 页面移除,或在 CLI 发行版执行 `dsh plugin --profile wsl remove dsh-plugin-wsl-env`;之后可删除 `~/.cache/dsh-wsl`。如果你为了恢复预览在 profile 里加过 `workspace-files-wsl` 的临时覆盖,升级后请删掉:插件不再挂载该行。
119
119
 
@@ -126,6 +126,7 @@ wsl.exe -d <发行版> -u root -- apt-get install -y bubblewrap
126
126
  - **New terminal** 在同一发行版、同一目录打开 shell。
127
127
  - 模型能看到监听端口,并返回 dev server 的 URL。WSL 2 会把 localhost 转发到 Windows。
128
128
  - 权限选择器:`read-only`、`workspace-write`(默认)、`danger-full-access`。只有 `danger-full-access` 不经过沙箱。
129
+ - 侧边栏的 **WSL 环境** 面板是诊断页:列出已安装的发行版,可对单个发行版运行 doctor 快速检查(bwrap / systemd / Linger 等前置项),并提供一次完整运行(`--fix-owned`,存在插件可修复项时标为 **修复**,否则标为 **完整检查**)——清扫残留 session scope、清理损坏的 agent 缓存并逐一复检,不安装软件包、不改写 Windows 配置;其余告警保留各自的手动处理办法。每个已检查的行还显示上次检查时间、来源(**手动** 或页面加载时的 **后台** 复核)与结果结构——各状态计数与分区分布。每个已检查的行还可展开查看本次运行执行的全部检查项,按分区分组、逐项带状态与依据(快速检查未触及的目录项只计数、不伪装成结果),绿色或异常的行都能被审计而不只是被相信。不必再打开 doctor 就能决定下一步。每个发行版的最后一次结果保存在 `$DSH_HOME/cache/dsh-plugin-wsl-env/status.json`(缺省回退到 `~/.dsh`),页面刷新或应用重启后仍可见;加载时只对正在运行的发行版在后台复核(不会启动已停止的发行版),后台运行失败会按实际观测覆盖已存结果。不标记“已过期”:时间戳就是时间戳。经 **添加工作区** 选中发行版目录时,会问一次 **Remote WSL**(默认,发行版内执行)还是 **Windows 访问**(按 9p 共享打开,没有 Linux 工具链),后者记录在 `auto-preset` 行的 `windowsWorkspaces` 中。
129
130
 
130
131
  ## 配置
131
132
 
@@ -138,12 +139,14 @@ wsl.exe -d <发行版> -u root -- apt-get install -y bubblewrap
138
139
  | | `sessionSandbox` | `false`;随包 `true` | 会话命令跑在同一个 systemd user scope 中 |
139
140
  | | `agentBackend` | `auto` | 发行版内 agent:`auto`、`native` 或 `shell` |
140
141
  | | `maskWindowsDrive` | `false` | 让受限命令看不到 `/mnt` |
142
+ | | `writableRoots` | `[]` | 额外可写的发行版目录(工具链缓存等;`wsl-fs` 上配同一列表) |
141
143
  | `wsl-fs` | `distro` | `''` | 发行版模式;空/`auto` 跟随每个目标路径 |
142
144
  | | `restrictToDistro` | `true` | 固定发行版(`default` 或名字)时拒绝属于其他发行版的路径 |
143
145
  | | `sandbox` | `true` | 按策略检查受限写入 |
144
146
  | | `sessionSandbox` | `false`;随包 `true` | 受限写入跑在会话 runtime 中 |
145
147
  | | `substrate` | `agent` | 发行版内 agent;`share` 在启动时被拒绝 |
146
- | `directory-picker-wsl` | `includeHostHome` | `true` | 同时列出 Windows 家目录 |
148
+ | | `writableRoots` | `[]` | 与 `wsl-shell` 相同的额外可写目录列表 |
149
+ | `directory-picker-wsl` | `includeHostHome` | `true` | 同时提供 Windows 路径分支(从驱动器开始) |
147
150
  | `subprocess-wsl` | `distro` | `''` | 发行版模式;空/`auto` 跟随启动目录 |
148
151
  | `wsl-preflight` | `distro` | `''` | 环境检查探测的发行版;空/`auto` 跟随会话工作区 |
149
152
  | | `startup` | `true` | 插件加载时预先运行同一组检查,让判定在任何会话打开之前就出现在日志里 |
@@ -175,7 +178,7 @@ wsl preset(每个会话)
175
178
  | 模式 | 命令可以做什么 |
176
179
  |---|---|
177
180
  | `read-only` | 读整个发行版;挂载新的 `/dev`,其余不可写 |
178
- | `workspace-write` | 上面的权限,加上会话工作区;会话 runtime 下 `/tmp` 是发行版真实 `/tmp` |
181
+ | `workspace-write` | 上面的权限,加上会话工作区与配置的 `writableRoots`;会话 runtime 下 `/tmp` 是发行版真实 `/tmp` |
179
182
  | `danger-full-access` | 不经过沙箱 |
180
183
 
181
184
  设置 `sessionSandbox: false` 时,`workspace-write` 命令使用私有的 `/tmp`,而不是发行版的真实 `/tmp`;`read-only` 不挂载可写的 `/tmp`。
@@ -191,6 +194,7 @@ wsl preset(每个会话)
191
194
  | 每条命令都报 `SANDBOX_UNAVAILABLE` | 在发行版内安装 `bubblewrap`,或设置 `sandbox: false` |
192
195
  | 会话在第一条命令前就被拒绝 | 运行 `pnpm run doctor`;启用 systemd 和 linger,或把 `wsl-shell`、`wsl-fs` 上的 `sessionSandbox` 设为 `auto` 或 `false` |
193
196
  | 发行版内 `glob`、`grep` 很慢 | 运行 `pnpm run bootstrap <发行版>`,使用打印的安装命令安装 `ripgrep` |
197
+ | `npm install` / `pnpm add` 报 `EROFS` | 沙箱默认只授予工作区;在 `wsl-shell` 和 `wsl-fs` 上配置 `writableRoots`(如 `~/.npm`、`~/.cache`、`~/.local/share/pnpm`),见 [CONFIGURATION](CONFIGURATION.zh.md#工具链缓存与额外可写目录) |
194
198
  | `dsh plugin add` 没有输出,或 Plugins 页面装完没有日志 | 以 profile 的 `package.json` 与 `dsh.profile.bundles` 为准:列出插件即安装成功 |
195
199
  | 对 `wsl-shell`/`wsl-fs` 的 profile 补丁不生效 | 这些行嵌套在 `preset-wsl` 里。运行 `pnpm run preset --check <补丁>`;它会失败并输出需要粘贴的完整块 |
196
200
  | 改了 `lib/` 但不生效 | 运行 `pnpm run sync:windows`,然后重启应用 |