dsh-plugin-wsl-env 0.17.1 → 0.19.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 (110) hide show
  1. package/CHANGELOG.md +225 -0
  2. package/CONTRIBUTING.md +37 -5
  3. package/README.md +61 -6
  4. package/SUPPORT.md +3 -3
  5. package/agent/native/linux-aarch64/dsh-wsl-agent +0 -0
  6. package/agent/native/linux-x86_64/dsh-wsl-agent +0 -0
  7. package/agent/wsl-agent.sh +331 -11
  8. package/cordis.patch.yml +10 -5
  9. package/docs/AGENT-PROTOCOL-V7.md +175 -0
  10. package/docs/API.md +24 -0
  11. package/docs/ARCHITECTURE.md +20 -6
  12. package/docs/COMPATIBILITY.md +1 -1
  13. package/docs/CONFIGURATION.md +33 -5
  14. package/docs/CONFIGURATION.zh.md +25 -4
  15. package/docs/LIMITATIONS.md +39 -7
  16. package/docs/LIMITATIONS.zh.md +31 -6
  17. package/docs/MIGRATION.md +4 -4
  18. package/docs/PEER-PARITY.md +94 -35
  19. package/docs/QUICKSTART.md +19 -2
  20. package/docs/QUICKSTART.zh.md +16 -1
  21. package/docs/README.zh.md +47 -7
  22. package/docs/RELEASING.md +3 -2
  23. package/docs/REQUIREMENTS.zh.md +11 -6
  24. package/docs/ROADMAP-1.0.md +40 -29
  25. package/docs/ROADMAP.md +10 -6
  26. package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +6 -1
  27. package/docs/UPSTREAM-FSIO-EXPORT.md +2 -2
  28. package/docs/UPSTREAM-SERVICE-SWAP.md +124 -0
  29. package/docs/UPSTREAM-SESSION-NOTICE.md +3 -1
  30. package/docs/UPSTREAM-TERMINAL-TITLE.md +3 -0
  31. package/docs/root-fs-routing.md +3 -3
  32. package/lib/agent-confined.js +4 -4
  33. package/lib/agent-errors.d.ts +1 -1
  34. package/lib/agent-errors.js +1 -1
  35. package/lib/agent-exec.d.ts +1 -1
  36. package/lib/agent-exec.js +1 -1
  37. package/lib/agent-protocol.d.ts +58 -8
  38. package/lib/agent-protocol.js +40 -7
  39. package/lib/agent-shared.d.ts +1 -1
  40. package/lib/agent-shared.js +1 -1
  41. package/lib/agent.d.ts +171 -1
  42. package/lib/agent.js +448 -288
  43. package/lib/auto-preset.d.ts +1 -1
  44. package/lib/auto-preset.js +1 -1
  45. package/lib/bwrap.d.ts +1 -1
  46. package/lib/bwrap.js +1 -1
  47. package/lib/distro-route.d.ts +1 -1
  48. package/lib/distro-route.js +1 -1
  49. package/lib/doctor-live.d.ts +53 -0
  50. package/lib/doctor-live.js +37 -0
  51. package/lib/file-reference-wsl.d.ts +1 -1
  52. package/lib/file-reference-wsl.js +1 -1
  53. package/lib/fs-decisions.d.ts +1 -1
  54. package/lib/fs-decisions.js +1 -1
  55. package/lib/fs-routing.d.ts +52 -2
  56. package/lib/fs-routing.js +56 -1
  57. package/lib/fs-substrate.d.ts +90 -11
  58. package/lib/fs-substrate.js +202 -1
  59. package/lib/fs.d.ts +1 -1
  60. package/lib/fs.js +1 -1
  61. package/lib/fsio-agent.d.ts +128 -4
  62. package/lib/fsio-agent.js +224 -15
  63. package/lib/fsio-text.d.ts +1 -1
  64. package/lib/fsio-text.js +1 -1
  65. package/lib/git-exec.d.ts +1 -1
  66. package/lib/git-exec.js +1 -1
  67. package/lib/git-route.d.ts +1 -1
  68. package/lib/git-route.js +1 -1
  69. package/lib/index.d.ts +127 -3
  70. package/lib/index.js +301 -99
  71. package/lib/listing.d.ts +1 -1
  72. package/lib/listing.js +1 -1
  73. package/lib/native-agent.d.ts +1 -1
  74. package/lib/native-agent.js +2 -2
  75. package/lib/paths.d.ts +6 -3
  76. package/lib/paths.js +4 -4
  77. package/lib/picker.d.ts +1 -1
  78. package/lib/picker.js +7 -7
  79. package/lib/ports.d.ts +1 -1
  80. package/lib/ports.js +1 -1
  81. package/lib/preflight.d.ts +1 -1
  82. package/lib/preflight.js +1 -1
  83. package/lib/sandbox-core.d.ts +1 -1
  84. package/lib/sandbox-core.js +2 -2
  85. package/lib/sandbox.d.ts +1 -1
  86. package/lib/sandbox.js +1 -1
  87. package/lib/search-exec.d.ts +1 -1
  88. package/lib/search-exec.js +1 -1
  89. package/lib/search-route.d.ts +1 -1
  90. package/lib/search-route.js +1 -1
  91. package/lib/session-runtime.d.ts +1 -1
  92. package/lib/session-runtime.js +2 -2
  93. package/lib/session-scope.d.ts +1 -1
  94. package/lib/session-scope.js +1 -1
  95. package/lib/shell-env.d.ts +1 -1
  96. package/lib/shell-env.js +1 -1
  97. package/lib/shell.d.ts +1 -1
  98. package/lib/shell.js +1 -1
  99. package/lib/subprocess.d.ts +1 -1
  100. package/lib/subprocess.js +2 -2
  101. package/lib/terminal-activity.d.ts +1 -1
  102. package/lib/terminal-activity.js +1 -1
  103. package/lib/terminal-route.d.ts +1 -1
  104. package/lib/terminal-route.js +1 -1
  105. package/lib/watcher.d.ts +1 -1
  106. package/lib/watcher.js +1 -1
  107. package/lib/wsl.d.ts +1 -31
  108. package/lib/wsl.js +1 -21
  109. package/package.json +41 -28
  110. package/scripts/doctor.mjs +34 -11
package/docs/API.md ADDED
@@ -0,0 +1,24 @@
1
+ # API surface
2
+
3
+ The published API is the generated `lib/*.d.ts` next to each compiled module
4
+ (`pnpm run build` keeps them byte-fresh; `lint:build` fails on drift). The
5
+ `exports` map in `package.json` is the authority on what a consumer can import;
6
+ this page is the quick tour.
7
+
8
+ | Subpath | Exports | Role |
9
+ |---|---|---|
10
+ | `.` | `WslShellExecutor` | the model-facing shell executor (`ctx.shell`) |
11
+ | `./fs` | `WslFileSystem` | the filesystem provider over the distro (`ctx.fs`) |
12
+ | `./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) |
13
+ | `./fs-routing` | `WslRoutingFileSystem` | the root-plane coordinate router |
14
+ | `./wsl` | `defaultShell`, `listDistros`, `shellArgs`, `wslTerminalArgv`, … | the `wsl.exe` interop primitives |
15
+ | `./agent` | `WslAgent` | the resident-agent transport |
16
+ | `./subprocess` | `WslSubprocessRuntime` | the terminal/subprocess runtime |
17
+ | `./preflight` | the `wsl-preflight` row | session-start advisories |
18
+ | `./paths` | `uncToPosix`, `toLinuxPath`, `toWorldPath`, … | the coordinate mappers |
19
+ | `./picker` | `WslDirectoryPicker` | the distro-aware directory picker |
20
+ | `./auto-preset` | the `auto-preset` row | first-run profile bootstrap |
21
+ | `./shell-env` | the `wsl-shell-env` row | the `DSH_WSL_*` facts registry |
22
+
23
+ Stability: tool names and error codes are API (docs/MIGRATION.md); the
24
+ runtime rows' config keys are documented in docs/CONFIGURATION.md.
@@ -77,7 +77,9 @@ Three modules support them and import no DSH package.
77
77
 
78
78
  [`cordis.patch.yml`](../cordis.patch.yml) is the bundle layer. It is a top-level
79
79
  YAML array of patch entries, and `dsh plugin --profile <name> add
80
- dsh-plugin-wsl-env` applies it as one layer.
80
+ dsh-plugin-wsl-env` applies it as one layer on the CLI distribution; the
81
+ desktop app applies the same bundle through its sidebar **Plugins** page
82
+ (**Add plugin**) and records it in the profile's `dsh.profile.bundles`.
81
83
 
82
84
  The environment is per session, not per process:
83
85
 
@@ -318,6 +320,8 @@ own dialect, described after the table.
318
320
  | `FS_ABORTED` | `lib/fsio-agent.js`, `lib/fsio-text.js` | the caller's signal was aborted before or during the operation | not a refusal — the caller cancelled; a fresh call clears it |
319
321
  | `FS_EDIT_NOT_FOUND` | `lib/fsio-text.js` (`applyLiteralEdit`) | `old_string` was empty, or matched nothing in the file | give an `old_string` the file actually contains |
320
322
  | `FS_AMBIGUOUS_EDIT` | `lib/fsio-text.js` (`applyLiteralEdit`) | `old_string` matched more than once and `replace_all` was not set | make `old_string` unique, or set `replace_all` |
323
+ | `FS_PATCH_MISMATCH` | `lib/fs-substrate.js` (`patchText`; the agent's record dialect, `docs/AGENT-PROTOCOL-V7.md`) | a hunk's `oldLines` no longer match the file at the lines the hunks name — the text drifted between the caller's read and the patch | re-read the file and rebuild the hunks against the fresh text |
324
+ | `FS_SAME_TARGET` | `lib/fs-substrate.js` (`moveFile`) | `moveFile`'s source and destination resolve to the same file | give two distinct paths, or drop the call |
321
325
 
322
326
  The GUI file service keeps the shipped `workspace-files` row, so its wire
323
327
  refusals are the peer's `workspace-file/*` dialect (plus `gateway/bad-request`
@@ -361,14 +365,15 @@ step with the checkout, and `pnpm run sync:windows` runs that script.
361
365
  | Build consistency | [`test/build-freshness.mjs`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/build-freshness.mjs) | no; it re-runs the real build and byte-compares the committed `lib/`, so it also catches an orphan there |
362
366
  | Type check | `tsc --noEmit` over `test/**` and `types/*.d.ts` (`src/` is checked by the build itself) | no |
363
367
  | Unit tests | `test/*.test.mjs` | no |
368
+ | Requirements matrix | [`scripts/check-requirements.mjs`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/scripts/check-requirements.mjs) | no; every cited test must exist and stay wired |
364
369
  | Sandbox probe | [`test/probe/sandbox.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/sandbox.sh) | no; it applies the profile arguments directly |
365
- | Harness probes | [`test/probe/run.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/run.sh), `terminal.sh`, `sandbox-shell.sh`, `interop-shell.sh`, `picker.sh`, `fs-routing.sh`, `missing-wsl.sh`, `sandbox-off.sh` | yes: Windows, WSL2, a mounted profile, and a linked checkout |
366
- | Distro probes | [`test/probe/substrate.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/substrate.sh), `watch.sh`, `agent.sh`, `exec.sh` | Windows and WSL2, but no harness boot and no profile: they run from a distro terminal with Node available, reaching `wsl.exe` through interop |
370
+ | Harness probes | [`test/probe/run.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/run.sh), `terminal.sh`, `sandbox-shell.sh`, `interop-shell.sh`, `picker.sh`, `fs-routing.sh`, `missing-wsl.sh`, `sandbox-off.sh`, `native-session.sh` | yes: Windows, WSL2, a mounted profile, and a linked checkout |
371
+ | Distro probes | [`test/probe/substrate.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/substrate.sh), `watch.sh`, `agent.sh`, `exec.sh`, `session-sandbox.sh`, `gui-preview.sh`, `file-reference-9p.sh` | Windows and WSL2, but no harness boot and no profile: they run from a distro terminal with Node available, reaching `wsl.exe` through interop |
367
372
  | Host probe | [`test/probe/mode.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/mode.sh) | Windows Node, no harness |
368
- | Probe plugins | the `*-probe.mjs` and `*-probe.yml` files in `test/probe/` | loaded by the scripts above |
373
+ | Probe plugins | the `*-probe.mjs` and `*-probe.yml` files in `test/probe/` (plus standalone measurers such as `gui-preview.mjs`, `native-session.mjs`, `fs-probe.mjs`, `fs-queue.mjs`) | loaded or invoked by the scripts above |
369
374
 
370
- `pnpm test` runs `lint:style`, `lint:links`, `test:syntax`, `lint:build`,
371
- `lint:types` and `test:unit`, in that order.
375
+ `pnpm test` runs `lint:style`, `lint:links`, `lint:requirements`,
376
+ `test:syntax`, `lint:build`, `lint:types` and `test:unit`, in that order.
372
377
  [`test/probe/run-all-when-closed.sh`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/test/probe/run-all-when-closed.sh)
373
378
  waits for the app to exit and then runs the whole real-machine suite once —
374
379
  `--include-fs` prepends `run.sh`.
@@ -485,3 +490,12 @@ src/wsl.ts wsl.exe interop primitives (no DSH imports)
485
490
  same three archived files, the second so a reader who does not read Chinese can
486
491
  still tell what is there; the records themselves are Chinese.
487
492
  - [`README.md`](../README.md) is the only statement of current state.
493
+
494
+ ## Diagnostics
495
+
496
+ `pnpm run doctor` (and `pnpm run diagnose`) is the operator-facing entry
497
+ point over everything above: it probes the Windows/WSL versions, the distro
498
+ and its shell, bubblewrap, systemd/Linger, the peer floor, a fresh agent
499
+ handshake and the stale session scopes, and reports the versioned
500
+ `doctorReport` structure (`scripts/doctor.mjs`, `lib/doctor-live.js`) with a
501
+ remedy per failure.
@@ -5,7 +5,7 @@ Measured evidence for the support tiers in [`ROADMAP-1.0.md`](ROADMAP-1.0.md)
5
5
  (x86_64, Windows 11, WSL 2, kernel 6.18) on **2026-10-26**, with the probe
6
6
  suite in [`test/probe/`](https://github.com/Big-Dao/dsh-plugin-wsl-env/tree/main/test/probe/) run from inside each distro against a
7
7
  fresh `--depth 1` clone. The aarch64 native agent is additionally executed per
8
- push under qemu in CI — see the `native packages` job in
8
+ push under qemu in CI — see the `native-package` job in
9
9
  [`.github/workflows/ci.yml`](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/.github/workflows/ci.yml); VM-only by
10
10
  decision — see "Scope decisions" below.
11
11
 
@@ -43,7 +43,8 @@ that row unless you pass `--force`. Prefer manual merging for existing profiles.
43
43
  To edit the preset manually, replace the entire `preset-wsl` row. Its config is
44
44
  not deep-merged: preserve `id`, `order`, and every item in `plugins`. Copy the
45
45
  current block from `cordis.patch.yml` or from
46
- `dsh --profile <name> --dump-config`, then change the nested values. Re-copy it
46
+ `dsh --profile <name> --dump-config` (CLI distribution — the desktop app has no
47
+ `dsh` command), then change the nested values. Re-copy it
47
48
  after a plugin upgrade that changes the preset.
48
49
 
49
50
  ### `wsl-shell`
@@ -51,7 +52,7 @@ after a plugin upgrade that changes the preset.
51
52
  | Key | Default / shipped value | Description |
52
53
  |---|---|---|
53
54
  | `distro` | `''` (shipped) | Empty or `auto` follows the request workdir's distro. `default` selects WSL's default distro; a name pins commands to that distro. |
54
- | `shell` | `''` | Empty resolves the distro user's login shell. Set an absolute Linux path to pin a shell. |
55
+ | `shell` | `''` | Empty resolves the distro user's login shell (`getent passwd`, then `$SHELL`). When both probes fail the command errors out instead of running under another shell — set an absolute Linux path here to pin one. |
55
56
  | `loginShell` | `true` (shipped) | Use login semantics for POSIX shells. Non-POSIX shells use their own command form. |
56
57
  | `agent` | `true` | Use the resident agent. If it is unavailable, commands use the one-shot `wsl.exe` path. Set `false` to always use that path. Cwd and sandbox refusals are returned directly. |
57
58
  | `agentBackend` | `auto` (shipped) | `auto` selects the packaged static-musl binary at `agent/native/linux-<arch>/dsh-wsl-agent` or the `DSH_WSL_AGENT_NATIVE` override; otherwise it uses the shell agent. `native` fails if it cannot prepare; `shell` forces the shell agent. Applies to commands, confined writes, and shared reads. |
@@ -217,6 +218,27 @@ gives the `visible` behavior.
217
218
  When `interopVisibility` is set, it takes precedence over
218
219
  `maskWindowsDrive`.
219
220
 
221
+ ### Three scenarios across four surfaces
222
+
223
+ What a setting changes depends on which surface acts. Confined commands run
224
+ in the `wsl-shell` sandbox; confined writes are checked by the `wsl-fs`
225
+ write sandbox; unrestricted file reads go through the shared read agent and
226
+ are not sandbox-governed; a Windows-side host operation is anything that
227
+ ends up executing on Windows.
228
+
229
+ | Surface | `visible` (default) | `masked` | distro-level `enabled=false` |
230
+ |---|---|---|---|
231
+ | Confined command (`wsl-shell`) | reads Windows files and launches Windows executables under `/mnt` | `/mnt` is an empty tmpfs in the profile: path operations under it fail | interop is refused by the distro itself; `/mnt` visibility still follows the mask above |
232
+ | Confined write (`wsl-fs`) | the write policy checks the target; `/mnt` visibility plays no role | the same mask applies to the write profile | unchanged — the write boundary was never interop-dependent |
233
+ | Unrestricted read (shared read agent) | reads `/mnt` freely | **not covered**: the mask lives in confined profiles only, the read agent still sees `/mnt` | **not governed by the plugin** |
234
+ | Windows-side host operation | reachable through `/mnt` | **still reachable**: `binfmt_misc` dispatches by file content, so a Windows executable copied into the workspace runs anyway (`enforcement: partial`) | the only real closure — and it is a manual `wsl.conf` step |
235
+
236
+ Masking affects real workflows on purpose: a script living under a Windows
237
+ path (a checkout under `/mnt/c`, tools on the Windows `PATH`) can no longer
238
+ be read or run by confined commands — move it into the distro or grant the
239
+ visible stance. Masking never deletes anything: the tmpfs shadows the view
240
+ inside one confined profile; the files on `/mnt/c` are untouched.
241
+
220
242
  Masking narrows access; it does not close interop. WSL can still run a Windows
221
243
  executable written into the workspace because `binfmt_misc` dispatches by file
222
244
  content. Enforcement therefore remains `partial`, and results report
@@ -278,9 +300,15 @@ mutation fence; that row reports `sandboxMode: undefined` either way.
278
300
 
279
301
  ## Diagnose configuration and refusals
280
302
 
281
- Use `dsh --profile <name> --dump-config` to inspect the composed profile
282
- without booting it. The output shows whether a row override applied. Use
283
- `scripts/bootstrap.sh <distro>` to inspect distro prerequisites.
303
+ `pnpm run doctor` is the one-command environment check: Windows/WSL versions,
304
+ the distro and its shell, bubblewrap, systemd/Linger, the peer floor, a fresh
305
+ agent handshake, stale session scopes and the known profile-patch traps — each
306
+ failure with a copyable remedy (`--json` for scripts, `--fix` for the stale
307
+ scopes). With the CLI distribution, `dsh --profile <name> --dump-config` inspects
308
+ the composed profile without booting it and shows whether a row override
309
+ applied; the desktop app has no `dsh` command, so read `cordis.patch.yml` and
310
+ the Plugins page there.
311
+ Use `scripts/bootstrap.sh <distro>` to inspect distro prerequisites.
284
312
 
285
313
  | Symptom | Result | Action |
286
314
  |---|---|---|
@@ -42,6 +42,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
42
42
  要手动编辑 preset,需替换整个 `preset-wsl` 行。它的 config
43
43
  不做深度合并:保留 `id`、`order` 以及 `plugins` 中的每一项。
44
44
  从 `cordis.patch.yml` 或 `dsh --profile <name> --dump-config`
45
+ (CLI 发行版;桌面应用没有 `dsh` 命令)
45
46
  复制当前块,再修改嵌套的值。插件升级改变了 preset 后要重新复制。
46
47
 
47
48
  ### `wsl-shell`
@@ -49,7 +50,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
49
50
  | 键 | 默认 / shipped 值 | 说明 |
50
51
  |---|---|---|
51
52
  | `distro` | `''`(shipped) | 空或 `auto` 跟随请求工作目录所属的发行版。`default` 选择 WSL 默认发行版;给出名字则把命令固定到该发行版。 |
52
- | `shell` | `''` | 空则解析发行版用户的登录 shell。设置绝对 Linux 路径可固定一个 shell。 |
53
+ | `shell` | `''` | 空则解析发行版用户的登录 shell(先 `getent passwd`,再 `$SHELL`)。两条探测都失败时命令直接报错,而不是落到另一个 shell——在此设置绝对 Linux 路径可固定一个。 |
53
54
  | `loginShell` | `true`(shipped) | 对 POSIX shell 使用登录语义。非 POSIX shell 使用各自的命令形式。 |
54
55
  | `agent` | `true` | 使用常驻 agent。不可用时,命令走一次性的 `wsl.exe` 路径。设为 `false` 则总是走该路径。Cwd 与沙箱拒绝会被直接返回。 |
55
56
  | `agentBackend` | `auto`(shipped) | `auto` 选择包内 `agent/native/linux-<arch>/dsh-wsl-agent` 的静态 musl 二进制或 `DSH_WSL_AGENT_NATIVE` 覆盖;否则使用 shell agent。`native` 在准备失败时报错;`shell` 强制使用 shell agent。适用于命令、受限写入和共享读取。 |
@@ -61,7 +62,7 @@ profile 层;检测到时会打印应使用的块。`--out` 会整体替换目
61
62
  | `timeoutMs` / `maxTimeoutMs` | `120000` / `600000`(shipped) | 默认的单次调用超时,以及一次调用可请求的最大超时。 |
62
63
  | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
63
64
  | `hostCwd` | 未设置 | `wsl.exe` 进程的 Windows 工作目录。可用时默认为 `%SystemRoot%`。 |
64
- | `forwardEnv` | `[]` | 额外通过 `WSLENV` 转发的宿主环境变量名。见 [环境变量转发](#environment-forwarding)。 |
65
+ | `forwardEnv` | `[]` | 额外通过 `WSLENV` 转发的宿主环境变量名。见 [环境变量转发](#环境变量转发)。 |
65
66
 
66
67
  ### `wsl-fs`
67
68
 
@@ -213,6 +214,25 @@ unset _fnm_env
213
214
  设置了 `interopVisibility` 时,它优先于
214
215
  `maskWindowsDrive`。
215
216
 
217
+ ### 三个场景 × 四个作用面
218
+
219
+ 设置改变什么,取决于哪个面在起作用。受限命令运行在 `wsl-shell`
220
+ 沙箱中;受限写入由 `wsl-fs` 的写入沙箱检查;非受限文件读取走共享读
221
+ agent,不受沙箱管辖;Windows 侧宿主操作指最终在 Windows 上执行的任何
222
+ 东西。
223
+
224
+ | 作用面 | `visible`(默认) | `masked` | 发行版级 `enabled=false` |
225
+ |---|---|---|---|
226
+ | 受限命令(`wsl-shell`) | 可读 Windows 文件、经 `/mnt` 启动 Windows 可执行文件 | profile 中 `/mnt` 是空 tmpfs:其下的路径操作失败 | interop 由发行版自身拒绝;`/mnt` 可见性仍遵循上方的遮蔽设置 |
227
+ | 受限写入(`wsl-fs`) | 写入策略检查目标;`/mnt` 可见性不起作用 | 同样的遮蔽作用于写入 profile | 不变——写入边界从来不依赖 interop |
228
+ | 非受限读取(共享读 agent) | 自由读 `/mnt` | **不在覆盖范围**:遮蔽只存在于受限 profile 中,读 agent 仍能看到 `/mnt` | **不归插件管辖** |
229
+ | Windows 侧宿主操作 | 可经 `/mnt` 到达 | **仍然可达**:`binfmt_misc` 按文件内容分发,被拷进工作区的 Windows 可执行文件照样运行(`enforcement: partial`) | 唯一真正的关闭手段——且是手工的 `wsl.conf` 步骤 |
230
+
231
+ 遮蔽刻意影响真实工作流:放在 Windows 路径下的脚本(`/mnt/c` 下的
232
+ 检出、Windows `PATH` 上的工具)不再能被受限命令读取或执行——把它移进
233
+ 发行版,或改用 `visible` 姿态。遮蔽不会删除任何东西:tmpfs 只遮蔽单个
234
+ 受限 profile 内的视图,`/mnt/c` 上的文件原样保留。
235
+
216
236
  遮蔽只是收窄访问,并不关闭 interop。WSL 仍能运行被写入工作区的
217
237
  Windows 可执行文件,因为 `binfmt_misc` 按文件内容分发。
218
238
  因此强制级别仍是 `partial`,结果会报告 `windowsDrive: 'masked'`。
@@ -269,8 +289,9 @@ profile 不使用会话 runtime 时,设置 `sessionSandbox: false`。
269
289
 
270
290
  ## 诊断配置问题与拒绝
271
291
 
272
- 使用 `dsh --profile <name> --dump-config` 检查合成后的 profile,
273
- 无需真正启动。输出会显示某行的覆盖是否生效。
292
+ CLI 发行版可用 `dsh --profile <name> --dump-config` 检查合成后的 profile,
293
+ 无需真正启动;输出会显示某行的覆盖是否生效。桌面应用没有 `dsh` 命令,
294
+ 请直接查看 `cordis.patch.yml` 与 Plugins 页面。
274
295
  使用 `scripts/bootstrap.sh <distro>` 检查发行版前置依赖。
275
296
 
276
297
  | 现象 | 结果 | 处理 |
@@ -24,8 +24,11 @@ operations never use the 9p share.
24
24
  `FS_STALE_VERSION`, but a change between check and rename can still be overwritten.
25
25
  - **A cancelled write can have an unknown outcome** — inspect the file before
26
26
  retrying.
27
- - **A successful write is not crash-durable.** The staged file is synced, the
28
- containing directory is not: a power loss can lose the entry.
27
+ - **A successful write is as crash-durable as the platform's `sync -d`.** The
28
+ staged file is synced, and the containing directory is fsynced best effort
29
+ after the rename (shell agent). The native agent keeps its file-level
30
+ `sync_all` only — see the peer-parity divergence note. A filesystem that
31
+ refuses a directory fsync keeps the peer's own promise.
29
32
  - **A Linux filename containing a backslash cannot be addressed** — the backslash is
30
33
  the UNC separator, so `a\b.ts` round-trips to `a/b.ts`. Rename away from backslash
31
34
  names; this is the coordinate system's own limit.
@@ -84,8 +87,10 @@ operations never use the 9p share.
84
87
  preflight sweeps stale scopes on the next WSL session (never another live
85
88
  session's).
86
89
  - **The sandbox does not govern WSL interop** — reported as `enforcement: partial`.
87
- `maskWindowsDrive` narrows `/mnt` but is not a closure; distro-level
88
- `[interop] enabled=false` in `wsl.conf` must be configured separately.
90
+ `maskWindowsDrive` and `interopVisibility` narrow `/mnt` but are not a closure;
91
+ even `interopVisibility: "disabled"` only produces the `wsl.conf`
92
+ `[interop] enabled=false` remedy (printed by `doctor`) — the distro-level
93
+ setting must still be applied manually.
89
94
  [ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement).
90
95
  - **`bubblewrap` must be installed**, or both providers fail with the install
91
96
  command; a session-start preflight surfaces the same text as an advisory warning.
@@ -97,7 +102,13 @@ operations never use the 9p share.
97
102
 
98
103
  Commands run as `<shell> -lc <command>` — login (profile scripts sourced, so version
99
104
  managers work) and **non-interactive** (no prompt/plugin output in the model's
100
- streams).
105
+ streams). With `loginShell: false` the login flag is dropped (`<shell> -c <command>`).
106
+
107
+ `<shell>` is the distro user's login shell (`getent passwd`, then `$SHELL`). When
108
+ both probes fail — a cold distro, a flaky first `wsl.exe` call, a musl distro
109
+ without `getent` — the command **errors out** instead of silently running under
110
+ bash; the failure is not cached, so a retry re-probes. Set `shell:` to an
111
+ absolute path to pin one.
101
112
 
102
113
  - **`~/.zshrc` / `~/.bashrc` are never read.** Move machine-level PATH setup
103
114
  (`fnm`, nvm, cargo) into `~/.zprofile` or `~/.zshenv`; keep prompts and completion
@@ -109,8 +120,11 @@ streams).
109
120
  ## Agent diagnostics
110
121
 
111
122
  - **The doctor's `agent.handshake` probes a fresh resident**, not the live one —
112
- a running resident's `lastError` stays in the app log (`WslAgent.status()` exposes
113
- it in-process).
123
+ a running resident's own view is folded in where a shared agent exists
124
+ (`doctorReport` merges `WslAgent.status()` via `mergeLiveResidentStatus`,
125
+ 0.18.0), but the CLI's handshake check still names its probe source
126
+ (`probed: a fresh resident`); without an app-side call the `lastError`
127
+ stays in the app log.
114
128
  - **`dsh-wsl-*.scope` counts are point-in-time**; `--fix` runs the preflight's sweep.
115
129
  - **The doctor's `git.win-safe` probe reports the Windows git trust through interop
116
130
  `git.exe`** — the `safe.directory` whitelist that WSL change review needs when
@@ -150,6 +164,9 @@ streams).
150
164
  app. Two alternatives: the doctor's `git.win-safe` probe reports the state, and a
151
165
  machine **without** Windows git needs nothing — the provider routes discovery into
152
166
  the distro and translates the output into UNC form.
167
+ - **Colon-separated multi-directory `GIT_*` values pass through untranslated.**
168
+ The git environment translation rewrites single Windows directory values; a
169
+ colon-separated list (no current caller sets one) is forwarded as-is.
153
170
  - **A NEW tab's title reads `WSL`** whatever it runs — the controller titles from the
154
171
  composition's profile before the provider rewrites the launch, and a plugin cannot
155
172
  correct the default ([UPSTREAM-TERMINAL-TITLE.md](UPSTREAM-TERMINAL-TITLE.md)).
@@ -162,6 +179,21 @@ streams).
162
179
  close-by-hand. Windows-folder host terminals keep the shipped no-reclamation
163
180
  behaviour.
164
181
 
182
+ ## Enabling the plugin on a running profile
183
+
184
+ - **A GUI enable of this bundle can fail on a busy profile, and a restart
185
+ applies it.** The three root-plane takeovers (`subprocess`, `fs`,
186
+ `directoryPicker`) replace shipped services under the same names. On
187
+ app `0.2.2-rc.1` (cordis 4.1.0), a disposing provider keeps its service
188
+ registration until every dependent releases, so the replacements
189
+ collide with the shipped providers while sessions are live and the
190
+ enable reports them as failed. The selection is persisted either way;
191
+ **restarting the app loads the plugin** (the cold composition is
192
+ correct). Closing sessions before enabling usually lets the hot path
193
+ succeed — with no dependents the shipped providers release inside the
194
+ recomposition. Mechanism and repro:
195
+ [UPSTREAM-SERVICE-SWAP.md](UPSTREAM-SERVICE-SWAP.md).
196
+
165
197
  ## Host "Open in app"
166
198
 
167
199
  - **Opening VS Code from "Open in app" can fail independently of this plugin** — the
@@ -21,8 +21,10 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
21
21
  会重新校验版本。不匹配时返回 `FS_STALE_VERSION`,但检查与 rename 之间发生的
22
22
  变更仍可能被覆盖。
23
23
  - **被取消的写入结果可能是未知的** —— 重试前先检查文件。
24
- - **写入成功不等于崩溃持久。** 被暂存的文件会 sync,但所在目录不会:
25
- 断电可能丢失该目录项。
24
+ - **写入的崩溃持久性取决于平台的 `sync -d`。** 被暂存的文件会 sync,
25
+ rename 之后所在目录也会尽力 fsync(shell agent)。native agent 目前只有
26
+ 文件级 `sync_all` —— 见 peer 对齐文档的分歧注记。拒绝目录 fsync 的
27
+ 文件系统保持与对端相同的承诺。
26
28
  - **含反斜杠的 Linux 文件名无法被寻址** —— 反斜杠是 UNC 分隔符,
27
29
  `a\b.ts` 会往返成 `a/b.ts`。请把文件名改掉,不要用反斜杠;
28
30
  这是坐标系自身的限制。
@@ -79,8 +81,10 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
79
81
  按命令形态。应用硬崩溃可能留下过期的 `dsh-wsl-*.scope`;预检会在下一个
80
82
  WSL 会话时清扫过期 scope(从不清扫其他活跃会话的)。
81
83
  - **沙箱不管辖 WSL interop** —— 上报为 `enforcement: partial`。
82
- `maskWindowsDrive` 收窄 `/mnt` 但不是关闭;发行版级 `wsl.conf` 中的
83
- `[interop] enabled=false` 需要另行配置。
84
+ `maskWindowsDrive` 和 `interopVisibility` 收窄 `/mnt` 但不是关闭;即使是
85
+ `interopVisibility: "disabled"` 也只是给出 `wsl.conf` 中
86
+ `[interop] enabled=false` 的补救命令(由 `doctor` 打印)——发行版级设置
87
+ 仍需手工执行。
84
88
  [ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement)。
85
89
  - **必须安装 `bubblewrap`**,否则两个提供者都会带着安装命令失败;
86
90
  会话启动预检会以建议性警告的形式给出同样的文本。
@@ -91,6 +95,12 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
91
95
 
92
96
  命令以 `<shell> -lc <command>` 运行——登录 shell(会 source profile 脚本,
93
97
  因此版本管理器可用)且**非交互**(模型的输出流中没有提示符/插件输出)。
98
+ 设置 `loginShell: false` 后去掉登录旗标(`<shell> -c <command>`)。
99
+
100
+ `<shell>` 是 distro 用户的登录 shell(先 `getent passwd`,再 `$SHELL`)。
101
+ 两条探测都失败时——冷启动的 distro、首个 `wsl.exe` 调用抖动、没有 `getent`
102
+ 的 musl 系——命令**直接报错**,而不是静默落到 bash;失败不缓存,重试即重探测。
103
+ 需要钉死就用 `shell:` 指定绝对路径。
94
104
 
95
105
  - **`~/.zshrc` / `~/.bashrc` 永远不会被读取。** 把机器级的 PATH 设置
96
106
  (`fnm`、nvm、cargo)移进 `~/.zprofile` 或 `~/.zshenv`;提示符和补全
@@ -102,8 +112,10 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
102
112
  ## Agent 诊断
103
113
 
104
114
  - **doctor 的 `agent.handshake` 探测的是一个新起的常驻 agent**,而不是
105
- 在跑的那个——运行中常驻 agent 的 `lastError` 留在应用日志里
106
- (进程内可通过 `WslAgent.status()` 查看)。
115
+ 在跑的那个——存在共享 agent 时,doctorReport 会经
116
+ `mergeLiveResidentStatus` 合入 `WslAgent.status()` 的在驻视角(0.18.0),
117
+ 但 CLI 的握手检查仍会标注其探测来源(`probed: a fresh resident`);
118
+ 没有应用侧调用时,`lastError` 仍留在应用日志里。
107
119
  - **`dsh-wsl-*.scope` 计数是某一时刻的快照**;`--fix` 会执行预检的清扫。
108
120
  - **doctor 的 `git.win-safe` 探针通过 interop 的 `git.exe` 报告 Windows git
109
121
  的信任状态** —— 装了 Windows git 时,WSL 变更审查需要那份
@@ -142,6 +154,8 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
142
154
  应用。两个替代方案:doctor 的 `git.win-safe` 探针可报告该状态;而
143
155
  **没有** Windows git 的机器什么都不用做——提供者把发现请求路由进
144
156
  发行版,并把输出转写成 UNC 形式。
157
+ - **冒号分隔的多目录 `GIT_*` 值不做转写直接透传。** git 环境转写只改写单个
158
+ Windows 目录值;冒号分隔的列表(当前没有调用方设置这种形态)原样转发。
145
159
  - **NEW 标签页的标题显示 `WSL`**,无论它实际运行什么——控制器在提供者
146
160
  改写启动命令之前就按 composition 的 profile 命名了,而插件无法纠正
147
161
  这个默认值([UPSTREAM-TERMINAL-TITLE.md](UPSTREAM-TERMINAL-TITLE.md))。
@@ -153,6 +167,17 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
153
167
  `unattendedTimeoutMs`(2 h)。`terminalIdleReclaim: false` 恢复手动关闭。
154
168
  Windows 文件夹的宿主终端保持随包的不回收行为。
155
169
 
170
+ ## 在运行中的 profile 上启用本插件
171
+
172
+ - **在繁忙的 profile 上通过 GUI 启用本 bundle 可能失败,重启应用即可生效。**
173
+ 三个根面接管行(`subprocess`、`fs`、`directoryPicker`)以同名替换随包服务。
174
+ 在应用 `0.2.2-rc.1`(cordis 4.1.0)上,正在销毁的提供者在全部依赖方释放之前
175
+ 一直持有服务注册,因此会话存活期间替换行会与随包提供者相撞,启用操作将它们
176
+ 报告为失败。无论如何选择都会持久化;**重启应用即可加载插件**(冷启动组合是
177
+ 正确的)。启用前先关闭会话通常能让热路径成功——没有依赖方时,随包提供者会在
178
+ 重组期间释放。机制与复现:
179
+ [UPSTREAM-SERVICE-SWAP.md](UPSTREAM-SERVICE-SWAP.md)。
180
+
156
181
  ## 宿主的"在应用中打开"
157
182
 
158
183
  - **从"在应用中打开"启动 VS Code 可能独立于本插件而失败** ——
package/docs/MIGRATION.md CHANGED
@@ -74,11 +74,11 @@ 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, syntax, build freshness, tsc, 40 unit files | CI (Node 22/24, Ubuntu + Windows) |
77
+ | `pnpm test` | style, links, syntax, build freshness, tsc, 41 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
- | Packed install/upgrade/uninstall | `pnpm run e2e:install` (temp `DSH_HOME`, 0.11.0 → current, marker) | manual, this machine (10/10 on 2026-10-19) |
81
- | Real-machine probe suite | `test/probe/run-all-when-closed.sh --include-fs` (needs the app closed) | manual; 15 probes passed on this Windows/WSL machine on 2026-10-31 |
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) |
81
+ | Real-machine probe suite | `test/probe/run-all-when-closed.sh --include-fs` (needs the app closed) | manual; 15/15 on 2026-10-31 and again 2026-11-05 (docs/superpowers/probe-runs/); the suite grew to 17 on 2026-11-06 — the first 17-probe run on the same day passed 16 and failed the new `two-distro.sh` on a wrong assertion vehicle (session-scoped `DSH_WSL_DISTRO` is absent on a direct `ctx.shell` seam); after the probe was reworked to per-distro `/tmp` markers it passed alone, giving all 17 probes a pass on this machine (2026-11-06-probe-suite.md) |
82
82
  | Clean Win11 + Ubuntu first run ≤ 5 min | a clean machine, a stopwatch | **not run** (the project's machine is already configured) |
83
83
  | aarch64 executed | the native 18-check suite under qemu in CI | **run in CI** (physical aarch64 WSL is out of scope; see COMPATIBILITY.md) |
84
84
  | No open P0 bug for 30 days | issue tracker | time-based; cannot be asserted from a checkout |
@@ -94,7 +94,7 @@ ships through the tag workflow, but its notes say which gates were executed.
94
94
  ```bash
95
95
  pnpm run preset --distro default --check <profile>/cordis.patch.yml # no nested-row trap
96
96
  pnpm run doctor --json # effective environment facts
97
- dsh --profile <name> --dump-config # composed rows
97
+ dsh --profile <name> --dump-config # composed rows (CLI distribution)
98
98
  ```
99
99
 
100
100
  A profile that fails to boot after a migration should name the remedy in the
@@ -7,20 +7,25 @@ same refusal dialect on both substrates. The **read path** holds end to end;
7
7
  the **edit path** carries two declared divergences, listed at the end. This
8
8
  file records the verification against the real peers.
9
9
 
10
- - Peers: `@deepseek-ai/dsh-fs-local@0.2.1-rc.3` (the exact version the
11
- devDependencies pin, and the floor the peer range `>=0.2.1-rc.3` was
12
- verified against), plus `@deepseek-ai/dsh-fs@0.2.1-rc.3` for the
10
+ - Peers: `@deepseek-ai/dsh-fs-local@0.2.2-rc.1` (the exact version the
11
+ devDependencies pin, and the floor the peer range `>=0.2.2-rc.1` was
12
+ verified against), plus `@deepseek-ai/dsh-fs@0.2.2-rc.1` for the
13
13
  `FsVersion` brand the local package imports. Divergence 2 is measured
14
- against a third peer, `@deepseek-ai/dsh-bash-local@0.2.1-rc.3` — the shell
14
+ against a third peer, `@deepseek-ai/dsh-bash-local@0.2.2-rc.1` — the shell
15
15
  executor carries the collect-budget/spill machinery; `spill` and
16
16
  `maxSpillBytes` do not appear in `dsh-fs-local` at all.
17
- - The `0.2.1-rc.3` move leaves every line reference below intact: all three
18
- peers' shipped `lib/index.js` are **byte-identical** to the `0.2.1-rc.2`
19
- ones (`cmp` clean; `dsh-fs-local`'s is still 909 lines), so only the
20
- tarballs' digests changed — upstream shipped the manifests' version fields
21
- and nothing else in these packages. `dsh-fs@0.2.1-rc.3` still has no
22
- `./invariant` export subpath (dropped back at `0.2.1-rc.2`); this plugin
23
- imports neither it nor `dsh-invariants`.
17
+ - The `0.2.2-rc.1` move grows `dsh-fs-local`'s shipped `lib/index.js` from 909
18
+ to 1048 lines (patch/move/delete operations, `expandHomePrefix`, `writeIoError`,
19
+ multi-key locks), so every line reference below was re-walked on 2026-11-05.
20
+ Every replicated string survived verbatim; the fsio **read path** holds end
21
+ to end and the **edit path** carries the same two declared divergences, listed
22
+ at the end. The release also added a `FS_ERROR_CODES` const export with two
23
+ new codes (`FS_PATCH_MISMATCH`, `FS_SAME_TARGET`) for operations this plugin
24
+ does not serve — see the new-peer-operations section at the end.
25
+ `dsh-bash-local@0.2.2-rc.1`'s `lib/index.js` is byte-identical to
26
+ `0.2.1-rc.3`'s (only manifests and locale files changed), so its references
27
+ stand. `dsh-fs@0.2.2-rc.1` still has no `./invariant` export subpath; this
28
+ plugin imports neither it nor `dsh-invariants`.
24
29
  - What "not imported" means: the peer's **fsio module** is not reachable from
25
30
  the package's exports, so `lib/fsio-text.js` reimplements it and imports
26
31
  nothing from it (the export is proposed in `docs/UPSTREAM-FSIO-EXPORT.md`).
@@ -42,17 +47,19 @@ wc -l package/lib/index.js # expect 909
42
47
  ```
43
48
 
44
49
  The tarballs this audit compared, by content — the same values
45
- `npm view <pkg>@0.2.1-rc.3 dist.integrity` reports:
50
+ `npm view <pkg>@0.2.2-rc.1 dist.integrity` reports (re-recorded 2026-11-05;
51
+ the `0.2.1-rc.3` values they supersede are in git history):
46
52
 
47
53
  ```
48
- @deepseek-ai/dsh-fs-local@0.2.1-rc.3 sha512-bB2CwCqvYAdAKl28+5XXMRRq1NBtRmYX3wNOpJ2JlGBm7uj2Aix9Vl9rFig4AQcXXd5Bk738b5KNsOIkbXy+XQ==
49
- @deepseek-ai/dsh-fs@0.2.1-rc.3 sha512-tENLWe471WlAXMc13J4cns8xU6lFyu1smwpkSKR85vhGr6FyWZhTlpVohZYm66LbwKTmSWiDhd9Urk7VxN9B9w==
54
+ @deepseek-ai/dsh-fs-local@0.2.2-rc.1 sha512-tibC9z4YJx7C6DhiWmTc9AYeF+GSh22XVaaDdumwTgBgvFuiNITNGn3E0DTL3skugB3MKnvAvrjybdveNQ7MmQ==
55
+ @deepseek-ai/dsh-fs@0.2.2-rc.1 sha512-sbr+u+3dG4KAUdY7FoMLJg/gSE39gvgBMwmvVeR/6acNrlHaIducvnuxRUYAq2V0+NOVnG8fA9sdfBq2uGAfUw==
50
56
  ```
51
57
 
52
58
  Each row of the table below names the peer's `lib/index.js` line and the
53
59
  literal both sides must produce. Verified 2026-10-03; the read/edit split
54
60
  re-verified 2026-10-06; the whole table re-checked against `0.2.1-rc.2`,
55
- 2026-10-17 and against `0.2.1-rc.3`, 2026-10-26.
61
+ 2026-10-17, against `0.2.1-rc.3`, 2026-10-26, and against `0.2.2-rc.1`,
62
+ 2026-11-05 (line numbers shifted; strings identical).
56
63
 
57
64
  ## Verdict
58
65
 
@@ -69,22 +76,22 @@ declared extensions, listed at the end.
69
76
 
70
77
  | Item | Evidence (peer `lib/index.js`) | Ours |
71
78
  |---|---|---|
72
- | `normalizeLineEndings` | `:584` `content.replaceAll("\r\n", "\n")` | identical |
73
- | `detectLineEndings` | `:587` 4096-char sample; `crlf > lf - crlf` | identical |
74
- | `restoreLineEndings` | `:600` LF unchanged; CRLF re-normalizes then `\n` → `\r\n` | identical (`replaceAll` vs `split/join` — equivalent) |
75
- | occurrence counting | `:603` non-overlapping left-to-right | `split(needle).length - 1` — equivalent |
76
- | `applyLiteralEdit` | `:698` empty needle, not-found, and ambiguous refusals; single-pass `split/join` without rescanning | identical |
77
- | edit refusal strings | `:700`, `:703`, `:704` — `old_string must be a non-empty string` (`FS_EDIT_NOT_FOUND`); ``old_string was not found in "${displayPath}"``; ``old_string matched ${n} times in "${displayPath}"; provide a more specific old_string or set replace_all to true`` (`FS_AMBIGUOUS_EDIT`) | identical |
78
- | invalid UTF-8, read path | `:328`, `:331` — ``cannot ${verb} "${displayPath}": invalid UTF-8 text`` (`FS_NOT_TEXT`), verb `read` | identical (the edit path's verb differs; see 4) |
79
- | binary detection, read path | `:369` (guard at `:373`), stream at `:457` — 8192-byte sample, NUL check; ``cannot read "${displayPath}": binary file`` (`FS_NOT_TEXT`) | identical — both accept a NUL at offset 8500, past the sample; the edit path's bound differs, see 4 |
80
- | size caps | `:389`, `:400` — ``cannot read "${displayPath}": ${size} bytes exceeds the ${maxBytes}-byte limit`` and ``content exceeds the ${maxBytes}-byte limit`` (`FS_TOO_LARGE`) | identical |
81
- | `writeText` guards | `:867`, `:869-870`, `:871` — not-regular (`FS_NOT_REGULAR_FILE`), `file no longer exists` / `file changed since it was read` (`FS_STALE_VERSION`), ``cannot overwrite existing "${displayPath}" without reading it first`` (`FS_NOT_OBSERVED`) | identical |
82
- | `editText` guards — not-regular and stale version | `:887`, `:888` — ``cannot edit "${displayPath}": not a regular file`` (`FS_NOT_REGULAR_FILE`); `file changed since it was read` (`FS_STALE_VERSION`) when the expected version differs | identical |
83
- | `editText` guards — missing file | `:886` — one refusal for every caller: `file changed since it was read` (`FS_STALE_VERSION`), with or without an expected version | **diverges by design** — we split on the caller's evidence: with an expected version `file no longer exists` (`FS_STALE_VERSION`), without one `file does not exist` (`FS_NOT_FOUND`). See 5 |
84
- | `listDir` refusal | `:296` — ``cannot list "${displayPath}": not a directory`` (`FS_NOT_DIRECTORY`) | identical |
85
- | diff-basis gate | `:872` — `existing !== null && Buffer.byteLength(content) < diffBasisMaxBytes` — keyed on the NEW content's size, `null` above the cap | identical — the gate's new-size keying is inherited by design, not a divergence |
86
- | outcome shapes | `:876`, `:905` — `operation: "update" \| "create"`, the `missing:${targetKey}` sentinel version, `before`/`after` | identical |
87
- | version join | `:145` — `` `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}` `` (branded by `dsh-fs`'s `FsVersion`) | `versionOf` — identical shape |
79
+ | `normalizeLineEndings` | `:628` `content.replaceAll("\r\n", "\n")` | identical |
80
+ | `detectLineEndings` | `:630` 4096-char sample; `crlf > lf - crlf` | identical |
81
+ | `restoreLineEndings` | `:643` LF unchanged; CRLF re-normalizes then `\n` → `\r\n` | identical (`replaceAll` vs `split/join` — equivalent) |
82
+ | occurrence counting | `:650` non-overlapping left-to-right | `split(needle).length - 1` — equivalent |
83
+ | `applyLiteralEdit` | `:741` empty needle, not-found, and ambiguous refusals; single-pass `split/join` without rescanning | identical |
84
+ | edit refusal strings | `:743`, `:746`, `:747` — `old_string must be a non-empty string` (`FS_EDIT_NOT_FOUND`); ``old_string was not found in "${displayPath}"``; ``old_string matched ${n} times in "${displayPath}"; provide a more specific old_string or set replace_all to true`` (`FS_AMBIGUOUS_EDIT`) | identical |
85
+ | invalid UTF-8, read path | `:343` — ``cannot ${verb} "${displayPath}": invalid UTF-8 text`` (`FS_NOT_TEXT`), verb `read` | identical (the edit path's verb differs; see 4) |
86
+ | binary detection, read path | `:99`/`:387` (sample const, guard), stream at `:471-473` — 8192-byte sample, NUL check; ``cannot read "${displayPath}": binary file`` (`FS_NOT_TEXT`) | identical — both accept a NUL at offset 8500, past the sample; the edit path's bound differs, see 4 |
87
+ | size caps | `:403`, `:414` — ``cannot read "${displayPath}": ${size} bytes exceeds the ${maxBytes}-byte limit`` and ``content exceeds the ${maxBytes}-byte limit`` (`FS_TOO_LARGE`) | identical |
88
+ | `writeText` guards | `:505`, `:506-508` — not-regular (`FS_NOT_REGULAR_FILE`), `file no longer exists` / `file changed since it was read` (`FS_STALE_VERSION`) via `writeTarget` at `:1021-1025`, ``cannot overwrite existing "${displayPath}" without reading it first`` (`FS_NOT_OBSERVED`) | identical |
89
+ | `editText` guards — not-regular and stale version | `:938`, `:939` — ``cannot edit "${displayPath}": not a regular file`` (`FS_NOT_REGULAR_FILE`); `file changed since it was read` (`FS_STALE_VERSION`) when the expected version differs (`requireFile` at `:1030-1032`) | identical |
90
+ | `editText` guards — missing file | `:937` — one refusal for every caller: `file changed since it was read` (`FS_STALE_VERSION`), with or without an expected version | **diverges by design** — we split on the caller's evidence: with an expected version `file no longer exists` (`FS_STALE_VERSION`), without one `file does not exist` (`FS_NOT_FOUND`). See 5 |
91
+ | `listDir` refusal | `:310` — ``cannot list "${displayPath}": not a directory`` (`FS_NOT_DIRECTORY`) | identical |
92
+ | diff-basis gate | `:920` — `existing !== null && Buffer.byteLength(content) < diffBasisMaxBytes` — keyed on the NEW content's size, `null` above the cap (the move path inherits the same keying at `:983`/`:997`) | identical — the gate's new-size keying is inherited by design, not a divergence |
93
+ | outcome shapes | `:927`, `:992` — `operation: "update" \| "create"`, the `missing:${targetKey}` sentinel version (`:1044`), `before`/`after` | identical |
94
+ | version join | `:148` — `` `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}` `` (branded by `dsh-fs`'s `FsVersion`) | `versionOf` — identical shape |
88
95
 
89
96
  ## Deliberate divergences (declared, not drift)
90
97
 
@@ -104,10 +111,10 @@ declared extensions, listed at the end.
104
111
  dialect, but a divergence all the same, so it is declared: an edit refused
105
112
  for its bytes reads ``cannot read "…": binary file`` or
106
113
  ``cannot read "…": invalid UTF-8 text`` — verb `read`, where the peer's
107
- `readForEdit` (`lib/index.js:621`) says ``cannot edit "…": …``. The NUL
114
+ `readForEdit` (`lib/index.js:664`) says ``cannot edit "…": …``. The NUL
108
115
  check is likewise the read path's 8192-byte sample
109
116
  (`src/fsio-agent.ts:377-384`, guard at `:380`), where the peer scans the
110
- whole buffer (`lib/index.js:625`): a file whose first 8192 bytes are clean
117
+ whole buffer (`lib/index.js:668`): a file whose first 8192 bytes are clean
111
118
  but that carries a NUL later is edited by us and refused by the peer.
112
119
  Measured on a 9000-byte fixture with a NUL at offset 8500 — ours `EDITED`,
113
120
  the peer `FS_NOT_TEXT: cannot edit "…"`.
@@ -117,8 +124,60 @@ declared extensions, listed at the end.
117
124
  behind it names a file that never answered the stat, so it takes the read
118
125
  path's missing-file dialect (`cannot edit "…": file does not exist`,
119
126
  `FS_NOT_FOUND`). The peer throws `file changed since it was read`
120
- (`FS_STALE_VERSION`, `lib/index.js:886`) for both. Pinned by
121
- `test/fs-substrate.test.mjs`.
127
+ (`FS_STALE_VERSION`, `lib/index.js:937` via `requireFile` at `:1030`) for
128
+ both. Pinned by `test/fs-substrate.test.mjs`.
129
+ 6. **Publication durability (shell agent, 2026-11-06).** After the publish
130
+ rename, the shell agent fsyncs the destination's containing directory
131
+ (`sync -d`, best effort), so a power loss cannot lose an entry whose file
132
+ contents already survived. The peer's publication makes no directory-fsync
133
+ promise, and the native agent keeps its file-level `sync_all` only
134
+ (`agent/native/spike/src/main.rs` stat write path) — the divergence holds
135
+ until the native binary's next build. Filesystems that refuse a directory
136
+ fsync (and `sync` builds without `-d`) degrade to the peer's promise
137
+ silently.
138
+
139
+ 7. **Frame-validation hardening (shell agent, 2026-11-06).** The shell agent
140
+ validates every numeric frame field it acts on — EXEC/FS `timeout_s` and
141
+ `nargs` (mirroring the FSB checks), and fs_read's `offset`/`max`, where a
142
+ malformed or non-positive window is a protocol-class refusal rather than a
143
+ silent empty answer. The native binary trusts the host's numerics the same
144
+ way it always has; the divergence holds until its next build. The host
145
+ always sends numerics, so this is drift-hardening at the trust boundary,
146
+ not a behavioral change for any caller.
147
+
148
+ ## The peer's 0.2.2-rc.1 operations: implemented over protocol v7
149
+
150
+ `0.2.2-rc.1` added three operations to the peer's `FileSystem` base —
151
+ `patchText` (hunks via `@deepseek-ai/dsh-fs-patch`, refusal
152
+ `FS_PATCH_MISMATCH`), `deleteFile`, and `moveFile` (same-target refusal
153
+ `FS_SAME_TARGET`). 0.18.0 shipped them as an honest refusal (an inherited
154
+ host call would touch the wrong filesystem); protocol v7
155
+ ([AGENT-PROTOCOL-V7.md](AGENT-PROTOCOL-V7.md)) now serves them for real:
156
+
157
+ - **`delete` / `move`** ride two new FS ops in both agent implementations,
158
+ with the peer's guard dialects (source `requireFile`, destination
159
+ `writeTarget`, version re-verification distro-side before the destructive
160
+ step, staging + atomic/no-replace publication, the two-effect
161
+ `sourceDeleted: false` outcome).
162
+ - **`patchText`** has no frame on purpose: hunks are applied in-process by
163
+ the peer's own `applyHunks` (`@deepseek-ai/dsh-fs-patch` is now a peer
164
+ dependency), so the mismatch dialect is the peer's byte-for-byte, then the
165
+ result publishes through the same guarded atomic write an edit takes.
166
+ - **Structured FS errors**: failed FS ops answer with `FSERR|id|reason|b64`
167
+ instead of the stderr sniffing notation (which stays parsed for older
168
+ agents).
169
+ - **Batched FS frames** (`FSB`): one round trip for the GUI preview's
170
+ stat+list+read shape; `readWholeText` and `listChildren` use it when the
171
+ resident advertises `batch`. Benchmark: `test/probe/gui-preview-batch.sh`.
172
+ - **Negotiation**: the host accepts agents 6–7 and gates every v7 frame on
173
+ the HELLO version, so a half-updated mirror degrades to v6 behaviour.
174
+
175
+ Pinned by `test/fs-substrate.test.mjs` (patch/delete/move over the live v7
176
+ script), `test/composition.test.mjs` (routing forwards the three ops),
177
+ `agent/native/spike/test.mjs` (both agents: batch, delete, move, capabilities)
178
+ and `test/agent-protocol.test.mjs` (HELLO caps, FSERR, FSB encoding).
179
+ Divergence 4's binary/UTF-8 dialect note now also covers the patch path, which
180
+ re-reads through `readForEdit`.
122
181
 
123
182
  ## Maintenance
124
183