dsh-plugin-wsl-env 0.23.0 → 0.24.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.
@@ -23,11 +23,13 @@ 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
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
31
33
  session-start preflight announces the same verdict on every session start.
32
34
  `DSH_WSL_DOCTOR` additionally carries a ready-to-run command for the doctor
33
35
  script itself (`sh -c "$DSH_WSL_DOCTOR --json"`).
@@ -37,8 +39,10 @@ the environment and ends in a verdict: `ready` means the first command should
37
39
  succeed; `blocked` names the exact checks to fix, each with a copy-paste
38
40
  remedy. It reads the distro's WSL mode from `wsl.exe -l -v` itself, so no
39
41
  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
42
+ (the stale-scope sweep and a broken agent cache, both re-verified; the Windows
43
+ git trust after a confirmation) or `--fix --install` (packages, after a
44
+ confirmation); `--fix-owned` restricts a fix run to the plugin-owned state
45
+ (the panel's repair action); `--bundle <path>` writes
42
46
  the diagnostic file a setup report attaches (`--redact` strips the paths
43
47
  from it). A run can be scoped — `--quick` probes the first-command
44
48
  prerequisites only (~10 s), `--sections <list>` (comma-separated) runs the
@@ -76,6 +80,25 @@ profile of that name.)
76
80
  In the GUI, open a folder through the picker (`\\wsl.localhost\<distro>\home\<you>\proj`)
77
81
  or an UNC path directly. The session's commands, file tools, terminal and previews
78
82
  all run in that distro; a Windows folder keeps the normal Windows environment.
83
+
84
+ The sidebar's **WSL environment** panel is the diagnostic page: it lists the
85
+ installed distros, runs one distro's quick doctor check on demand (showing
86
+ whether bwrap, systemd and Linger are in place), and offers **修复** on a checked
87
+ row as a full doctor with `--fix-owned` — labeled **修复** when a finding is
88
+ repairable (a stale session scope or a broken agent cache) and **完整检查**
89
+ otherwise; the row also shows when the check ran, its source (manual, or the
90
+ page-load background refresh), and its result structure (pass/warn/fail/info/
91
+ skip, plus the per-section tallies). The last result survives a page reload
92
+ from the local store, and a stored result for a running distro is re-checked
93
+ in the background on load. The run sweeps the scopes and purges the cache when they need it,
94
+ then re-verifies; every other warning keeps its manual remedy, and the action
95
+ never installs packages or rewrites Windows-owned configuration (a check boots
96
+ a stopped distro, so either action only runs on a click). Workspaces still open through **Add workspace**; selecting a folder inside a
97
+ distro through the picker makes the app ask once how to open it: **Remote
98
+ WSL** (the default — commands, files and the terminal all run in the distro) or
99
+ **Windows access** (the folder as an ordinary Windows share over 9p, without the
100
+ Linux toolchain). The choice is recorded in the `auto-preset` row's
101
+ `windowsWorkspaces` and applies to later sessions in that workspace too.
79
102
  Two distros can be open at once, each with its own environment.
80
103
 
81
104
  ### Open the workspace in VS Code (Remote-WSL)
@@ -22,18 +22,21 @@ _本页是权威版本;英文译本见 [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
+ 判定落在对话里;会话启动预检在每次会话打开时通报同样的判定。`DSH_WSL_DOCTOR` 还携带一条现成命令,可在发行版内执行 doctor 脚本本身
30
31
  (`sh -c "$DSH_WSL_DOCTOR --json"`)。
31
32
 
32
33
  doctor(`scripts/doctor.mjs`,或在检出目录中运行 `pnpm run doctor`)会检查
33
34
  环境并以裁决收尾:`ready` 表示首条命令应能成功;`blocked` 会列明待修项,
34
35
  每项附可复制的处理办法。发行版的 WSL 模式由 doctor 自己从 `wsl.exe -l -v`
35
- 读取,无需单独确认。doctor 默认只读,除非传入 `--fix`(清理过期 scope,以及
36
- 确认后的 Windows git 信任)或 `--fix --install`(安装软件包,需确认);
36
+ 读取,无需单独确认。doctor 默认只读,除非传入 `--fix`(清理过期 scope、清理损坏的
37
+ agent 缓存,两者都会复检;以及确认后的 Windows git 信任)或
38
+ `--fix --install`(安装软件包,需确认);`--fix-owned` 把修复限定在
39
+ 插件自有状态(面板的“修复”动作);
37
40
  `--bundle <路径>` 写出可附加到问题报告的诊断文件(`--redact`
38
41
  将其中的路径脱敏)。运行可以收窄范围——`--quick` 只探首条命令的前置项
39
42
  (约 10 秒),`--sections <分区清单>`(逗号分隔)只运行指定分区——
@@ -71,6 +74,18 @@ dsh --profile <profile> --dump-config # 输出中必须包含插件的行
71
74
  都在该发行版中运行;打开 Windows 文件夹则保留正常的 Windows 环境。
72
75
  两个发行版可以同时打开,各自拥有自己的环境。
73
76
 
77
+ 侧边栏的 **WSL 环境** 面板是诊断页:它列出已安装的发行版,可对单个发行版运行
78
+ 一次 doctor 快速检查,显示 bwrap、systemd、Linger 等前置项是否正常;已检查的行提供一次完整 doctor(`--fix-owned`):存在可自动修复项(残留 session
79
+ scope 或损坏的 agent 缓存)时标为 **修复**,否则标为 **完整检查**;行内还显示上次
80
+ 检查时间、来源(手动,或页面加载时的后台复核)与结果结构(通过/告警/失败/
81
+ 信息/跳过,以及分区分布);最后一次结果会从本地存档恢复,正在运行的发行版会在
82
+ 页面加载时后台复核;运行时按需清扫
83
+ 残留 scope、清理缓存并逐一复检,其余告警保留各自的手动处理办法,不安装软件包、
84
+ 不改写 Windows 配置(检查会让停止的发行版启动,所以两种动作都只在点击时执行)。工作区仍在 **添加工作区** 里打开;选中发行版内的文件夹时,应用会问一次打开方式:**Remote WSL**(默认,命令、
85
+ 文件与终端都在发行版内)或 **Windows 访问**(把该文件夹当作普通 Windows 共享,经 9p
86
+ 读写,没有 Linux 工具链)。选择记录在 `auto-preset` 行的 `windowsWorkspaces` 里,
87
+ 对该工作区之后新建的会话同样生效。
88
+
74
89
  ### 在 VS Code 中打开工作区(Remote-WSL)
75
90
 
76
91
  把 WSL 文件夹当作 Windows UNC 共享打开也可行,但属于降级模式:
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 快速检查——宿主侧执行,不进模型对话;会话启动预检在每次会话打开时通报环境判定。
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
 
@@ -143,7 +144,7 @@ wsl.exe -d <发行版> -u root -- apt-get install -y bubblewrap
143
144
  | | `sandbox` | `true` | 按策略检查受限写入 |
144
145
  | | `sessionSandbox` | `false`;随包 `true` | 受限写入跑在会话 runtime 中 |
145
146
  | | `substrate` | `agent` | 发行版内 agent;`share` 在启动时被拒绝 |
146
- | `directory-picker-wsl` | `includeHostHome` | `true` | 同时列出 Windows 家目录 |
147
+ | `directory-picker-wsl` | `includeHostHome` | `true` | 同时提供 Windows 路径分支(从驱动器开始) |
147
148
  | `subprocess-wsl` | `distro` | `''` | 发行版模式;空/`auto` 跟随启动目录 |
148
149
  | `wsl-preflight` | `distro` | `''` | 环境检查探测的发行版;空/`auto` 跟随会话工作区 |
149
150
  | | `startup` | `true` | 插件加载时预先运行同一组检查,让判定在任何会话打开之前就出现在日志里 |
@@ -38,7 +38,7 @@ docs/ 各篇里的行为承诺登记成带编号的需求条目,并给每条
38
38
  | R2 | 文件工具读写真实发行版文件:单一 agent 基座(ext4),share 基座不复存在 | ARCHITECTURE「The filesystem substrate」;LIMITATIONS 首节 | ①②③⑤:读/写/身份在 ext4、原生符号链接与 mode 位;`createIfAbsent` no-replace 关闭 TOCTOU、版本随写 op 下发并在 rename 前复核(`FS_STALE_VERSION`);新文件 0600、agent 失联 fail-closed 均为明文;0600 与反斜杠文件名为已声明极限 | `fs-substrate.test.mjs`、`fsio-agent.test.mjs`、`agent-fs-script.test.mjs`、`provider.test.mjs`(守卫链)、`fs.boot.test.mjs`;probe:substrate 8/8 | rename 后无目录 fsync(OI-5,已入 LIMITATIONS) |
39
39
  | R3 | 会话级环境绑定:distro 目录自动绑 `wsl` preset,Windows 目录保持原生 | ARCHITECTURE「How the pieces are mounted」;README「Architecture」 | ①②④:触发条件与 isolate realms 机制成文;registry/agent-loop 两棵树不相交的设计约束可复核 | `preset-choice.test.mjs` | 猴补上游 `ensureSession` 的接缝风险已转 promotion-map 跟踪(非本仓可独立修) |
40
40
  | R4 | GUI 终端按会话路由:WSL 目录会话得发行版 shell,Windows 目录会话得 PowerShell(`hostSessions`) | ARCHITECTURE「Why the terminal provider is app-level」;LIMITATIONS 终端诸条 | ①②③⑤:路由判定、无目录启动落发行版、idle/busy/unknown 三态回收(`unknown` 必须暂停回收)逐项规定;tab 标题极限给出根因、上游提案与用户缓解 | `terminal.test.mjs`(terminalRoute 判定)、`terminal-activity.test.mjs`;probe:terminal | tab 标题读 `WSL`(UPSTREAM-TERMINAL-TITLE);host 终端 unknown 不回收——均为已声明边界 |
41
- | R5 | 目录选择器列出已装发行版及其层级 | README「Install」;CONFIGURATION `directory-picker-wsl` 行 | ①②③⑤:根级列表、`includeHostHome`/`maxEntries`/`preferredDistro`、常驻 out 时 one-shot 回退;换行符文件名极限的边界论证闭合(`/` 不可能出现在名字里) | `listing.test.mjs`(`maxEntries` 封顶、行解析);probe:picker | `preferredDistro` 决定的根级 `path`/`home` 领位、`includeHostHome` 的排序姿态:单测与探针都没有断言(探针只查成员构成与截断旗标) |
41
+ | R5 | 目录选择器分层为 Windows 路径与 WSL 发行版两支,并列出已装发行版及其层级 | README「Install」;CONFIGURATION `directory-picker-wsl` 行 | ①②③⑤:根级列表、`includeHostHome`/`maxEntries`/`preferredDistro`、常驻 out 时 one-shot 回退;换行符文件名极限的边界论证闭合(`/` 不可能出现在名字里) | `listing.test.mjs`(`maxEntries` 封顶、行解析);probe:picker | `preferredDistro` 决定的根级 `path`/`home` 领位、`includeHostHome` 的排序姿态:单测与探针都没有断言(探针只查成员构成与截断旗标) |
42
42
  | R6 | 端口可见性:`DSH_WSL_PORTS` 按节奏经常驻 agent 刷新 | README「Using it」;CONFIGURATION「`wsl-shell-env`」表 | ①⑤:机制(`/proc/net/tcp{,6}` 扫描)、`portsRefreshMs` 默认 10s、与 WSL2 localhost 转发的关系(平台行为)成文 | `ports.test.mjs`(解析层) | 轮询使常驻 agent 永不闲置回收(OI-4,已入 LIMITATIONS) |
43
43
  | R7 | 模型可见的发行版事实与 WSLENV 政策:受管 `DSH_*` 前缀准入,`PATH` 刻意不转发 | README「Using it」「Recipes」 | ①②③:两个 Windows 路径变量带 `/p` 翻译、`PATH` 不转发的理由成文;传输环境钉死 essentials+`DSH_*`+过滤后 WSLENV;shell 解析失败则省略事实而非报假值(宁可缺报不误报) | `terminal.test.mjs`(`/p` 翻译)、`agent.test.mjs`(传输环境 WSLENV 钉死为受管项)、`provider.test.mjs`(探针失败重试、不钉占位符)、`shell-env.test.mjs`(假 `wsl.exe` 下挂载/清扫/resolve 双路径与 doctorFact/windowsToPosix) | 已闭合(原残差:`lib/shell-env.js` 无单测、覆盖率报告不含该模块):`test:coverage` 实测该模块 行 97.7%/分支 83.6%/函数 92.9%,逐模块地板(85/70/60)达标,`coverage-allowlist` 豁免已撤;未覆盖项仅为需在驻 agent 的端口扫描成功臂(探针层) |
44
44
  | R8 | 权限三档(read-only / workspace-write / danger-full-access)与提权提议流 | README「Sandbox」表;ARCHITECTURE「Error codes」 | ①②:三档行为逐档成表;模型可见两行前缀逐字给出;`FS_SANDBOX_DENIED` 可提权而 `FS_OUTSIDE_DISTRO` 不可,且区分理由明文(宽权限开不出另一个发行版) | `fs-decisions.test.mjs`、`provider.test.mjs`、`fsio-agent.test.mjs`(分类) | — |
@@ -61,7 +61,7 @@ docs/ 各篇里的行为承诺登记成带编号的需求条目,并给每条
61
61
  | R25 | 安装/卸载/升级流:四步安装、幂等陷阱及补救、ES 模块重启须知 | README「Install」「Troubleshooting」 | ①③:每步预期输出、`add` 幂等性陷阱的补救(先 remove 再 add)、pnpm UNC 链接极限成文 | 人工步骤,无自动化(依赖真实 dsh CLI + Windows) | 无自动化守护 |
62
62
  | R26 | 诊断三入口同一份逐项报告:独立 CLI、`/wsl-doctor` UI 命令(宿主侧、不进模型历史)、`wsl_doctor` 模型工具(进程内合并常驻状态);报告按 distro 分组逐项带显式状态标记与失败修复;`--quick`/`--sections`(工具侧 `depth`/`section`)收窄范围且未运行项显式列为跳过 | DIAGNOSTICS「The surfaces」;README「Install」;CONFIGURATION「Diagnose configuration and refusals」 | ①②④:三入口的分工与边界成文;范围化报告携带 `scope`、`--fix` 要求完整运行成文;逐项化与跳过行的形态由 parity 测试钉住 | `wsl-doctor-tool.test.mjs`(digest/渲染/CHECK_CATALOG parity)、`wsl-doctor-command.test.mjs`(语法/handler/子进程面)、`doctor.test.mjs`(CLI 采集) | 真机多 distro 报告依赖实机;报告形态的宿主渲染(命令面 UI)无单测 |
63
63
  | R27 | doctor CLI 独立性:不加载 peer 依赖与宿主服务,插件运行时本身损坏时仍可诊断;固定骨架本地化(Windows 区域设置检测,`--locale`/`DSH_WSL_DOCTOR_LOCALE` 覆盖),逐项事实保持英文,`--json` 语言无关 | DIAGNOSTICS「The surfaces」;CONFIGURATION「Message language」;LIMITATIONS「消息本地化」条 | ①②④:peer-free 内联与防漂移对拍成文;catalog 键 parity 与占位符行为有测试 | `doctor.test.mjs`(inlining parity、locale catalog、检测与覆盖) | 语言检测需 Windows registry(非 Windows 上回退英文,`run` 不抛错) |
64
- | R28 | 每日更新检查经宿主插件管理器委托,不自取;事实进 `DSH_WSL_PLUGIN_UPDATE`;`wsl-update-check.enabled: false` 可关闭 | README「Install」;CONFIGURATION `wsl-update-check` 行 | ①②⑤:委托路径、TTL、关闭开关成文 | `update-check.test.mjs` | doctor 的按需 registry 查询独立于此行(`DSH_UPDATE_REGISTRIES` 控制,气隙可跳过) |
64
+ | R28 | 每日更新检查经宿主插件管理器委托,不自取;事实进 `DSH_WSL_PLUGIN_UPDATE`;`wsl-update-check.enabled: false` 可关闭 | README「Install」;CONFIGURATION `wsl-update-check` 行 | ①②⑤:委托路径、TTL、关闭开关成文 | `update-check.test.mjs` | doctor 不再自行查询 registry:更新提示只走这条委托路径 |
65
65
 
66
66
  登记覆盖面:上表登记 README 与 docs/ 中对外成文的行为承诺(含随发的服务面)。
67
67
  **有意未接线**的模块不设条目——`lib/file-reference-wsl.js`(`@` 补全的发行版侧
@@ -89,8 +89,9 @@ home 缓存,所以同一个根平面可以同时服务多个发行版;`distr
89
89
  `ui-deliverables` 的交付物打开路由(`present-open.ts`)用同一等式,一并失败。
90
90
  workspace-files 的 change feed 与 `stat.absolutePath` 因此同为 UNC 形态,两者
91
91
  一致;Linux 形态保留在目标的 `displayPath`(模型看到的那一面)。共享根
92
- (distro 根)的尾分隔符会归一化:substrate 渲染 `\\wsl.localhost\<distro>\`,
93
- 而宿主 `resolve` 去掉尾部分隔符,`processPath` 以宿主形态为准。
92
+ (distro 根)保留 substrate 的尾分隔符:宿主 `resolve` 会去掉它,因此根目标
93
+ 通不过宿主路径校验;根目录本身不可 open/reveal(Windows 的 opener 也不接受
94
+ 共享根 URL),根下面的路径不受影响。
94
95
  **代价**:客户端 `fileMediaUrl` 拒绝 `\\` 开头的路径,WSL 工作区里 Markdown
95
96
  预览的相对图片因此不渲染;聊天侧此前就已如此(其 `cwd` 本就是 UNC)。
96
97
  - **watch 的事件粒度**:无限深目录且有 `inotifywait` 时,distro 侧优先使用
@@ -44,6 +44,15 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
44
44
  attempts: z<number, number, "defined">;
45
45
  /** Gap between attempts, in milliseconds. */
46
46
  retryMs: z<number, number, "defined">;
47
+ /**
48
+ * Workspace directories the operator opened for Windows access (9p) instead
49
+ * of the distro environment. A session inside one of them keeps the host
50
+ * preset, so the choice made in the sidebar survives later sessions.
51
+ *
52
+ * Volatile: the sidebar's access-mode dialog records the choice through the
53
+ * Settings service, and this row must observe it without a remount.
54
+ */
55
+ windowsWorkspaces: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
47
56
  }>>, Schemastery.ObjectT<NoInfer<{
48
57
  /** Preset to bind for a WSL workspace. */
49
58
  preset: z<string, string, "defined">;
@@ -51,6 +60,15 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
51
60
  attempts: z<number, number, "defined">;
52
61
  /** Gap between attempts, in milliseconds. */
53
62
  retryMs: z<number, number, "defined">;
63
+ /**
64
+ * Workspace directories the operator opened for Windows access (9p) instead
65
+ * of the distro environment. A session inside one of them keeps the host
66
+ * preset, so the choice made in the sidebar survives later sessions.
67
+ *
68
+ * Volatile: the sidebar's access-mode dialog records the choice through the
69
+ * Settings service, and this row must observe it without a remount.
70
+ */
71
+ windowsWorkspaces: z<NoInfer<string[]>, NoInfer<string[]>, "volatile-defined">;
54
72
  }>>, "plain">;
55
73
  /** The config schema's validated output. */
56
74
  interface AutoPresetConfig {
@@ -60,6 +78,15 @@ interface AutoPresetConfig {
60
78
  attempts?: number;
61
79
  /** Gap between attempts, in milliseconds. */
62
80
  retryMs?: number;
81
+ /**
82
+ * Paths reserved for Windows access. The Loader hands a volatile field to
83
+ * `apply` as a live reference, so both spellings are accepted: a reference
84
+ * when the row was composed by the Loader, a plain array in hand-built test
85
+ * contexts.
86
+ */
87
+ windowsWorkspaces?: readonly string[] | {
88
+ get: () => readonly string[];
89
+ };
63
90
  }
64
91
  /**
65
92
  * The slice of a created agent this plugin inspects; the harness's agent
@@ -36,7 +36,7 @@
36
36
  import { appendFileSync } from "node:fs";
37
37
  import z from "@deepseek-ai/schemastery";
38
38
  import { isWslUnc } from "./paths.js";
39
- import { shouldAdoptWslPreset } from "./preset-choice.js";
39
+ import { isWindowsAccessWorkspace, shouldAdoptWslPreset } from "./preset-choice.js";
40
40
  /**
41
41
  * Set `DSH_WSL_TRACE` to a file path to record every decision this plugin makes.
42
42
  *
@@ -69,7 +69,35 @@ export const Config = z.object({
69
69
  attempts: z.natural().min(1).default(6),
70
70
  /** Gap between attempts, in milliseconds. */
71
71
  retryMs: z.natural().default(150),
72
+ /**
73
+ * Workspace directories the operator opened for Windows access (9p) instead
74
+ * of the distro environment. A session inside one of them keeps the host
75
+ * preset, so the choice made in the sidebar survives later sessions.
76
+ *
77
+ * Volatile: the sidebar's access-mode dialog records the choice through the
78
+ * Settings service, and this row must observe it without a remount.
79
+ */
80
+ windowsWorkspaces: z.array(z.string()).default([]).volatile(),
72
81
  });
82
+ /**
83
+ * Read the Windows-access list at consideration time.
84
+ *
85
+ * A volatile field arrives as a reference whose `get()` returns the value the
86
+ * current configuration resolves to; reading it per decision is what makes an
87
+ * edit in the sidebar apply to the next session instead of the next boot.
88
+ *
89
+ * @param value - the configured field, plain or volatile.
90
+ * @returns the current list, or an empty list when the field is unset.
91
+ */
92
+ function windowsAccessList(value) {
93
+ if (value === undefined)
94
+ return [];
95
+ if (typeof value.get === "function") {
96
+ const current = value.get();
97
+ return Array.isArray(current) ? current : [];
98
+ }
99
+ return Array.isArray(value) ? value : [];
100
+ }
73
101
  /**
74
102
  * Mount the auto-preset plugin.
75
103
  *
@@ -126,8 +154,13 @@ export async function apply(ctx, config = {}) {
126
154
  catch {
127
155
  fallback = void 0;
128
156
  }
129
- if (!shouldAdoptWslPreset({ cwd, current, fallback }))
157
+ const windowsAccess = windowsAccessList(config.windowsWorkspaces);
158
+ if (!shouldAdoptWslPreset({ cwd, current, fallback, windowsAccess })) {
159
+ if (cwd !== undefined && windowsAccess.length > 0) {
160
+ trace(` -> skipped: Windows-access workspace ${JSON.stringify(cwd)}`);
161
+ }
130
162
  return;
163
+ }
131
164
  trace(` -> acting: fallback=${String(fallback)} isWsl=${isWslUnc(cwd)}`);
132
165
  // Deferred on purpose — see the module comment.
133
166
  void (async () => {
@@ -180,7 +213,11 @@ export async function apply(ctx, config = {}) {
180
213
  const original = facade.ensureSession;
181
214
  facade.ensureSession = async function (sessionId, cwd, checkPersistedIdentity, presetId) {
182
215
  // An explicit choice always wins, and only a distro workspace is affected.
183
- if (presetId !== void 0 || cwd === undefined || !isWslUnc(cwd)) {
216
+ // A workspace the operator opened for Windows access keeps the host
217
+ // preset even here: this is the frame that makes the first mount correct,
218
+ // so skipping it is what the choice means.
219
+ if (presetId !== void 0 || cwd === undefined || !isWslUnc(cwd)
220
+ || isWindowsAccessWorkspace(cwd, windowsAccessList(config.windowsWorkspaces))) {
184
221
  return original.call(this, sessionId, cwd, checkPersistedIdentity, presetId);
185
222
  }
186
223
  try {
@@ -14,8 +14,8 @@
14
14
  * - `./shell` (`lib/shell.js`): the session shell executor, mounted inside
15
15
  * the WSL agent preset's isolate realm.
16
16
  *
17
- * Compositions that still mount the bare name get the client half (the doctor
18
- * composer button) and nothing else; the executor keeps its behavior through
17
+ * Compositions that still mount the bare name get the client half (the sidebar
18
+ * status panel and the access-mode prompt) and nothing else; the executor keeps its behavior through
19
19
  * the explicit subpath. Before 0.21.0 `.` resolved to the executor itself —
20
20
  * a profile that relied on that shape must switch to `dsh-plugin-wsl-env/shell`.
21
21
  *
@@ -14,8 +14,8 @@
14
14
  * - `./shell` (`lib/shell.js`): the session shell executor, mounted inside
15
15
  * the WSL agent preset's isolate realm.
16
16
  *
17
- * Compositions that still mount the bare name get the client half (the doctor
18
- * composer button) and nothing else; the executor keeps its behavior through
17
+ * Compositions that still mount the bare name get the client half (the sidebar
18
+ * status panel and the access-mode prompt) and nothing else; the executor keeps its behavior through
19
19
  * the explicit subpath. Before 0.21.0 `.` resolved to the executor itself —
20
20
  * a profile that relied on that shape must switch to `dsh-plugin-wsl-env/shell`.
21
21
  *
@@ -286,11 +286,12 @@ export declare class WslRoutingFileSystem extends LocalFileSystem {
286
286
  * and `contains` still compares POSIX coordinates; only this accessor — the
287
287
  * one the Host's path-taking consumers read — speaks host spelling.
288
288
  *
289
- * The share root is the one spelling the substrate and the Host disagree on:
290
- * `posixToUnc(distro, "/")` renders `\\wsl.localhost\<distro>\` (a trailing
291
- * separator), while the Host's `path.resolve` normalizes the same directory
292
- * to `\\wsl.localhost\<distro>`. Stripping it keeps the round trip closed for
293
- * a distro root chosen as the workspace.
289
+ * The share root is deliberately left alone: `posixToUnc(distro, "/")`
290
+ * renders `\\wsl.localhost\<distro>\` with a trailing separator, and the
291
+ * Host's `path.resolve` drops it, so the Host-path check refuses the root
292
+ * instead of passing a share-root spelling to an opener that cannot open it
293
+ * (0.23.0 stripped the separator; Explorer then showed a network error for
294
+ * `file://wsl.localhost/<distro>`). Paths inside the distro are unaffected.
294
295
  *
295
296
  * @param target - the resolved target.
296
297
  * @returns the canonical UNC for a distro target, the host path otherwise.
package/lib/fs-routing.js CHANGED
@@ -377,18 +377,19 @@ export class WslRoutingFileSystem extends LocalFileSystem {
377
377
  * and `contains` still compares POSIX coordinates; only this accessor — the
378
378
  * one the Host's path-taking consumers read — speaks host spelling.
379
379
  *
380
- * The share root is the one spelling the substrate and the Host disagree on:
381
- * `posixToUnc(distro, "/")` renders `\\wsl.localhost\<distro>\` (a trailing
382
- * separator), while the Host's `path.resolve` normalizes the same directory
383
- * to `\\wsl.localhost\<distro>`. Stripping it keeps the round trip closed for
384
- * a distro root chosen as the workspace.
380
+ * The share root is deliberately left alone: `posixToUnc(distro, "/")`
381
+ * renders `\\wsl.localhost\<distro>\` with a trailing separator, and the
382
+ * Host's `path.resolve` drops it, so the Host-path check refuses the root
383
+ * instead of passing a share-root spelling to an opener that cannot open it
384
+ * (0.23.0 stripped the separator; Explorer then showed a network error for
385
+ * `file://wsl.localhost/<distro>`). Paths inside the distro are unaffected.
385
386
  *
386
387
  * @param target - the resolved target.
387
388
  * @returns the canonical UNC for a distro target, the host path otherwise.
388
389
  */
389
390
  processPath(target) {
390
391
  if (targetIsDistro(target.targetKey))
391
- return String(target.targetKey).replace(/\\+$/, "");
392
+ return String(target.targetKey);
392
393
  return super.processPath(target);
393
394
  }
394
395
  }
package/lib/listing.d.ts CHANGED
@@ -49,22 +49,34 @@ export declare function fullyQualified(path: string): boolean;
49
49
  * @returns the ancestry, outermost first.
50
50
  */
51
51
  export declare function ancestryCrumbs(target: string): ListingRow[];
52
+ /** The three virtual roots the picker's breadcrumb trail is built from. */
53
+ export interface PickerRoots {
54
+ /** The two-category level ("工作区"): Windows paths and WSL distros. */
55
+ picker: string;
56
+ /** The Windows branch's drive list. */
57
+ windows: string;
58
+ /** The WSL branch's distro list (the share root). */
59
+ wsl: string;
60
+ }
52
61
  /**
53
- * Breadcrumb rows for a level, with the WSL share head prepended for anything
54
- * inside a distro.
62
+ * Breadcrumb rows for a level: the category root, then the world the path
63
+ * belongs to, then the path itself.
64
+ *
65
+ * The trail is what makes the two top-level categories reachable from anywhere:
66
+ * every level keeps "工作区" as its first crumb, so a browse into a distro or a
67
+ * drive never strands the user without a way back to the other world.
55
68
  *
56
- * Two Windows path quirks make this more than a relabel. `win32.dirname` treats
69
+ * Two Windows path quirks need explicit handling. `win32.dirname` treats
57
70
  * `\\server\share` as a volume root and never yields the share itself, so the
58
- * WSL row has to be synthesized; and `win32.basename` of that same share root is
59
- * the empty string, so the distro row is named from the parsed distro instead.
60
- * Without both fixes, browsing into a distro would render a blank breadcrumb and
61
- * offer no way back to the distro list.
71
+ * WSL rows are synthesized from the parsed distro instead of the ancestry walk;
72
+ * and `win32.basename` of a volume root is empty, so {@link ancestryCrumbs}
73
+ * already falls back to the drive's own path.
62
74
  *
63
75
  * @param target - the directory being listed.
64
- * @param providerRoot - the share root acting as the WSL row's jump target.
76
+ * @param roots - the picker, Windows and WSL jump targets.
65
77
  * @returns breadcrumb rows, outermost first.
66
78
  */
67
- export declare function breadcrumbs(target: string, providerRoot: string): ListingRow[];
79
+ export declare function breadcrumbs(target: string, roots: PickerRoots): ListingRow[];
68
80
  /**
69
81
  * Insert a streamed candidate into the name-sorted bounded window, evicting the
70
82
  * name-largest candidate when the window exceeds `keep`. Keeps memory O(keep)
package/lib/listing.js CHANGED
@@ -57,34 +57,38 @@ export function ancestryCrumbs(target) {
57
57
  }
58
58
  }
59
59
  /**
60
- * Breadcrumb rows for a level, with the WSL share head prepended for anything
61
- * inside a distro.
60
+ * Breadcrumb rows for a level: the category root, then the world the path
61
+ * belongs to, then the path itself.
62
62
  *
63
- * Two Windows path quirks make this more than a relabel. `win32.dirname` treats
63
+ * The trail is what makes the two top-level categories reachable from anywhere:
64
+ * every level keeps "工作区" as its first crumb, so a browse into a distro or a
65
+ * drive never strands the user without a way back to the other world.
66
+ *
67
+ * Two Windows path quirks need explicit handling. `win32.dirname` treats
64
68
  * `\\server\share` as a volume root and never yields the share itself, so the
65
- * WSL row has to be synthesized; and `win32.basename` of that same share root is
66
- * the empty string, so the distro row is named from the parsed distro instead.
67
- * Without both fixes, browsing into a distro would render a blank breadcrumb and
68
- * offer no way back to the distro list.
69
+ * WSL rows are synthesized from the parsed distro instead of the ancestry walk;
70
+ * and `win32.basename` of a volume root is empty, so {@link ancestryCrumbs}
71
+ * already falls back to the drive's own path.
69
72
  *
70
73
  * @param target - the directory being listed.
71
- * @param providerRoot - the share root acting as the WSL row's jump target.
74
+ * @param roots - the picker, Windows and WSL jump targets.
72
75
  * @returns breadcrumb rows, outermost first.
73
76
  */
74
- export function breadcrumbs(target, providerRoot) {
75
- const crumbs = ancestryCrumbs(target);
76
- const head = crumbs[0];
77
- if (head === undefined)
78
- return [{ name: "WSL", path: providerRoot, hidden: false }];
79
- const parsed = isWslUnc(head.path) ? uncToPosix(head.path) : undefined;
80
- if (parsed !== undefined && parsed.linuxPath === "/") {
81
- // `win32.dirname` reports the share root with a trailing separator
82
- // (`\\wsl.localhost\ubuntu\`); rewrite the row to the canonical distro root
83
- // so crumb paths match what distroRoot() and the picker produce elsewhere.
84
- crumbs[0] = { name: parsed.distro, path: `${providerRoot}\\${parsed.distro}`, hidden: false };
85
- crumbs.unshift({ name: "WSL", path: providerRoot, hidden: false });
77
+ export function breadcrumbs(target, roots) {
78
+ const head = [{ name: "工作区", path: roots.picker, hidden: false }];
79
+ const parsed = isWslUnc(target) ? uncToPosix(target) : undefined;
80
+ if (parsed === undefined) {
81
+ return [...head, { name: "Windows 路径", path: roots.windows, hidden: false }, ...ancestryCrumbs(target)];
82
+ }
83
+ const distroRootPath = `${roots.wsl}\\${parsed.distro}`;
84
+ head.push({ name: "WSL 发行版", path: roots.wsl, hidden: false });
85
+ head.push({ name: parsed.distro, path: distroRootPath, hidden: false });
86
+ let current = distroRootPath;
87
+ for (const segment of parsed.linuxPath.split("/").filter((part) => part.length > 0)) {
88
+ current = `${current}\\${segment}`;
89
+ head.push({ name: segment, path: current, hidden: false });
86
90
  }
87
- return crumbs;
91
+ return head;
88
92
  }
89
93
  /**
90
94
  * Insert a streamed candidate into the name-sorted bounded window, evicting the