dsh-plugin-wsl-env 0.19.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -1
- package/README.md +2 -2
- package/client.d.ts +5 -0
- package/client.js +218 -0
- package/cordis.patch.yml +75 -1
- package/docs/API.md +1 -0
- package/docs/CONFIGURATION.md +48 -5
- package/docs/CONFIGURATION.zh.md +15 -1
- package/docs/DIAGNOSTICS.md +110 -0
- package/docs/DIAGNOSTICS.zh.md +96 -0
- package/docs/LIMITATIONS.md +25 -0
- package/docs/LIMITATIONS.zh.md +7 -0
- package/docs/MIGRATION.md +1 -1
- package/docs/QUICKSTART.md +19 -3
- package/docs/RELEASING.md +3 -0
- package/docs/ROADMAP-1.0.md +49 -4
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +5 -0
- package/docs/UPSTREAM-OPEN-IN-APP.md +33 -0
- package/lib/client-host.d.ts +29 -0
- package/lib/client-host.js +29 -0
- package/lib/cwd-prompt-tool.d.ts +88 -0
- package/lib/cwd-prompt-tool.js +94 -0
- package/lib/cwd-prompt.d.ts +166 -0
- package/lib/cwd-prompt.js +203 -0
- package/lib/doctor-live.d.ts +5 -1
- package/lib/doctor-live.js +3 -2
- package/lib/index.d.ts +11 -0
- package/lib/index.js +10 -8
- package/lib/messages.d.ts +238 -0
- package/lib/messages.js +292 -0
- package/lib/preflight.d.ts +24 -0
- package/lib/preflight.js +111 -11
- package/lib/sandbox-core.js +7 -14
- package/lib/session-scope.js +10 -5
- package/lib/shell-env.d.ts +25 -0
- package/lib/shell-env.js +56 -0
- package/lib/shell.d.ts +3 -1
- package/lib/shell.js +3 -1
- package/lib/update-check.d.ts +197 -0
- package/lib/update-check.js +211 -0
- package/lib/wsl-doctor-command.d.ts +105 -0
- package/lib/wsl-doctor-command.js +240 -0
- package/lib/wsl-doctor-tool.d.ts +214 -0
- package/lib/wsl-doctor-tool.js +423 -0
- package/locale/doctor/en.json +30 -0
- package/locale/doctor/zh.json +30 -0
- package/package.json +47 -5
- package/scripts/doctor.mjs +1606 -171
package/docs/CONFIGURATION.zh.md
CHANGED
|
@@ -133,6 +133,7 @@ Loader 在挂载该行之前会校验宿主和发行版设置;
|
|
|
133
133
|
| | `wslPath` | `wsl.exe` | `wsl.exe` 的路径。 |
|
|
134
134
|
| | `sandbox` | `true` | 运行会话启动时的 `bwrap` 检查。 |
|
|
135
135
|
| | `sessionSandbox` | `true` | 同时检查 systemd、user manager、`systemd-run` 和 Linger。profile 不使用会话 runtime 时设为 false。 |
|
|
136
|
+
| | `startup` | `true` | 插件加载时(即安装 + 重启后)对 pin 的或 WSL 默认发行版预先运行同一组检查,让判定在任何会话打开之前就出现在日志里。 |
|
|
136
137
|
| `wsl-shell-env` | `distro` | `''` | 用于填充 `DSH_WSL_*` 环境事实的发行版。 |
|
|
137
138
|
| | `portsRefreshMs` | `10000` | 监听端口快照的刷新间隔,单位毫秒。 |
|
|
138
139
|
|
|
@@ -276,7 +277,9 @@ scripts/bootstrap.sh <distro> --install
|
|
|
276
277
|
wsl.exe -d <distro> -u root -- apt-get install -y bubblewrap
|
|
277
278
|
```
|
|
278
279
|
|
|
279
|
-
会话打开时,`wsl-preflight`
|
|
280
|
+
会话打开时,`wsl-preflight` 行会运行这些检查;`startup: true`(默认)时,
|
|
281
|
+
插件加载阶段还会对 pin 的或 WSL 默认发行版预先运行同一组检查,因此安装加
|
|
282
|
+
重启之后判定就已经出现在日志里,该发行版上的会话只会重复注入运行时上下文条目。
|
|
280
283
|
`sessionSandbox: true` 时,它还会检查会话 runtime 的前置条件。
|
|
281
284
|
该警告仅供参考:它不会安装软件包,也不会改变提供者关闭(fail-closed)
|
|
282
285
|
的行为。在该行设置 `sandbox: false` 或移除该行可让沙箱警告静音。
|
|
@@ -287,6 +290,17 @@ profile 不使用会话 runtime 时,设置 `sessionSandbox: false`。
|
|
|
287
290
|
会报告没有沙箱生效。在 `fs-routing` 上,该设置会禁用变更围栏;
|
|
288
291
|
无论开关如何,该行都报告 `sandboxMode: undefined`。
|
|
289
292
|
|
|
293
|
+
### 消息语言
|
|
294
|
+
|
|
295
|
+
插件的拒绝与修复消息(`sessionSandbox` 预检判定、`bwrap` 的安装与修复提示、
|
|
296
|
+
发行版/工作目录命令错误)跟随 harness 应用的语言设置:偏好经宿主 settings
|
|
297
|
+
服务从 `locale` 条目的 `preference` 字段读取,切换语言无需重启应用。
|
|
298
|
+
内置中文(`zh`,含 `zh-CN`、`zh-Hans` 标签)与英文;其他语言——以及
|
|
299
|
+
没有 settings 服务的 profile 或未设置偏好的情况——渲染英文。消息内的
|
|
300
|
+
命令、配置键与文件路径一律不翻译。三组消息按设计保持英文:
|
|
301
|
+
`fs-decisions` 中的 `FS_*` 拒绝文本与 fsio 复刻(工具层按字节匹配这些
|
|
302
|
+
字符串),以及独立运行的 `scripts/doctor.mjs`(它在应用之外执行)。
|
|
303
|
+
|
|
290
304
|
## 诊断配置问题与拒绝
|
|
291
305
|
|
|
292
306
|
CLI 发行版可用 `dsh --profile <name> --dump-config` 检查合成后的 profile,
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Diagnostics: the doctor and the error-code map
|
|
2
|
+
|
|
3
|
+
Every refusal this plugin produces is named. This page is the map between
|
|
4
|
+
those names and the doctor: for each error code, whether the `doctor`
|
|
5
|
+
(`pnpm run doctor`, or `node scripts/doctor.mjs --json`) covers its
|
|
6
|
+
precondition, and which check id answers for it. The authoritative meaning
|
|
7
|
+
and remedy of each code live in [ARCHITECTURE.md](ARCHITECTURE.md#error-codes);
|
|
8
|
+
this page adds the diagnostics dimension and the verdict contract.
|
|
9
|
+
|
|
10
|
+
## The doctor's verdict
|
|
11
|
+
|
|
12
|
+
`doctor --json` (schemaVersion 2) ends in `verdict: "ready" | "blocked"`
|
|
13
|
+
with the blocking ids in `blockers`, and a per-distro breakdown in
|
|
14
|
+
`distroVerdicts`. The blocking rule has one invariant: **a `fail` blocks** —
|
|
15
|
+
config-awareness lives in the statuses (a missing systemd only fails under
|
|
16
|
+
`sessionSandbox: true`; `auto` names its per-command fallback and `false`
|
|
17
|
+
names the opt-out, both as warnings), so the verdict answers under the
|
|
18
|
+
**effective configuration** — the profile layers the app loads, overlaid on
|
|
19
|
+
the shipped preset — not the shipped defaults. The `config.effective` check
|
|
20
|
+
reports what was read and from where.
|
|
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`,
|
|
24
|
+
`functional.sandbox`, `functional.fs`) prove the chain itself — frame I/O,
|
|
25
|
+
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`
|
|
28
|
+
timed out or wedged mid-probe, common when several distros are probed
|
|
29
|
+
concurrently and one of them is cold-booting — reports `unknown` after one
|
|
30
|
+
automatic retry, names the flake in its detail, and never blocks or feeds a
|
|
31
|
+
config verdict: a flaked read of `/etc/wsl.conf` says the read failed, never
|
|
32
|
+
that the file is broken. Rerun the doctor for a clean answer.
|
|
33
|
+
|
|
34
|
+
`--fix` ends in a re-verified report: every fix is followed by a fresh probe
|
|
35
|
+
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.
|
|
40
|
+
|
|
41
|
+
`--bundle <path>` writes a local JSON file (report + versions + effective
|
|
42
|
+
configuration) for a setup report; `--redact` replaces home and DSH paths
|
|
43
|
+
with `<redacted-*>` placeholders. The bundle contains no file contents, no
|
|
44
|
+
environment variables, and no telemetry.
|
|
45
|
+
|
|
46
|
+
## The surfaces
|
|
47
|
+
|
|
48
|
+
The doctor answers through three surfaces with one report:
|
|
49
|
+
|
|
50
|
+
- **The standalone CLI** — `node scripts/doctor.mjs [distro] [--json] [--quick] [--sections …] [--locale <tag>]`.
|
|
51
|
+
The authoritative surface: it loads **no peer dependency and no host
|
|
52
|
+
service**, so it still starts when the plugin's own runtime is the thing
|
|
53
|
+
that is broken. Only pure, peer-free `lib/` modules are imported; the two
|
|
54
|
+
helpers that used to live behind peer-tainted modules (`lib/index.js`,
|
|
55
|
+
`lib/update-check.js`) are inlined and drift-pinned against the lib exports
|
|
56
|
+
by `test/doctor.test.mjs`. Exit 0 = `ready`, 1 = `blocked`.
|
|
57
|
+
- **The `/wsl-doctor` UI command** — the composer button drops a
|
|
58
|
+
`/wsl-doctor [quick|full|<section>] [--distro <name>]` line; the commands
|
|
59
|
+
registry executes it host-side, the handler spawns the standalone CLI, and
|
|
60
|
+
the itemized report renders detached from model history (no model turn, no
|
|
61
|
+
tokens). Without a command adapter (headless, ACP) the row is a no-op and
|
|
62
|
+
the CLI is the surface.
|
|
63
|
+
- **The `wsl_doctor` model tool** — in-process via `doctorReport()`, so the
|
|
64
|
+
live resident's state merges in. This is the only surface that depends on
|
|
65
|
+
the model path; use the command or the CLI when the plugin's runtime itself
|
|
66
|
+
is under suspicion.
|
|
67
|
+
|
|
68
|
+
## The map
|
|
69
|
+
|
|
70
|
+
Class legend:
|
|
71
|
+
|
|
72
|
+
- **environment** — a machine state the doctor probes; `doctor` green covers
|
|
73
|
+
it.
|
|
74
|
+
- **policy** — a per-call decision (the sandbox fence, the distro fence);
|
|
75
|
+
the doctor proves the fence's shape, the call decides the case.
|
|
76
|
+
- **data** — caller- or data-transient; no machine precondition exists, so
|
|
77
|
+
no doctor check claims it.
|
|
78
|
+
|
|
79
|
+
| Code | Class | Doctor checks | In one line |
|
|
80
|
+
|---|---|---|---|
|
|
81
|
+
| `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`, `sandbox.bwrap-usable`, `functional.sandbox` | the requested confinement cannot be enforced (no usable bubblewrap) |
|
|
82
|
+
| `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 |
|
|
83
|
+
| `FS_OUTSIDE_DISTRO` | policy | `config.effective` (the effective `distro`) | the path names another distro's share while the fence is pinned |
|
|
84
|
+
| `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 |
|
|
85
|
+
| `FS_NOT_FOUND` | data | — | the path does not exist — the ordinary answer |
|
|
86
|
+
| `FS_NOT_REGULAR_FILE` | data | — | a directory, symlink or device where a regular file is required |
|
|
87
|
+
| `FS_NOT_DIRECTORY` | data | — | a list was asked of a non-directory |
|
|
88
|
+
| `FS_NOT_TEXT` | data | — | the content is not UTF-8 text |
|
|
89
|
+
| `FS_TOO_LARGE` | data | — | the content exceeds the caller's byte cap |
|
|
90
|
+
| `FS_ABORTED` | data | — | the caller's own signal cancelled the call |
|
|
91
|
+
| `FS_NOT_OBSERVED` | data | — | a guarded create targeted a file that existed unread |
|
|
92
|
+
| `FS_STALE_VERSION` | data | — | the caller's version is stale; re-read and retry |
|
|
93
|
+
| `FS_EDIT_NOT_FOUND` | data | — | the literal edit matched nothing |
|
|
94
|
+
| `FS_AMBIGUOUS_EDIT` | data | — | the literal edit matched more than once |
|
|
95
|
+
| `FS_PATCH_MISMATCH` | data | — | the hunks no longer match the file; rebuild them |
|
|
96
|
+
| `FS_SAME_TARGET` | data | — | a move whose source and destination are the same file |
|
|
97
|
+
| `AgentUnavailableError` | environment | `agent.handshake`, `agent.native`, `agent.cache`, `functional.exec` | the execution layer's revival budget is spent; the named state says so |
|
|
98
|
+
|
|
99
|
+
The agent's structured FS reasons (`notfound`, `notdir`, `perm`, `loop`,
|
|
100
|
+
`stale`, `io`) map onto the codes above at `lib/fsio-agent.js`; the wire
|
|
101
|
+
dialect itself is [AGENT-PROTOCOL-V7.md](AGENT-PROTOCOL-V7.md).
|
|
102
|
+
|
|
103
|
+
## When the doctor is green but a call still fails
|
|
104
|
+
|
|
105
|
+
That is the **policy** and **data** classes doing their jobs: a refusal the
|
|
106
|
+
doctor cannot predict because it depends on the call, not the machine. If a
|
|
107
|
+
call fails repeatedly with an **environment**-class code while the doctor
|
|
108
|
+
says `ready`, that is a bug — file it with the `doctor --bundle` output (a
|
|
109
|
+
[setup report](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/.github/ISSUE_TEMPLATE/setup_report.yml)
|
|
110
|
+
carries it).
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# 诊断:doctor 与错误码地图
|
|
2
|
+
|
|
3
|
+
本插件产生的每一个拒绝都有名字。本页是这些名字与 doctor 的对照表:
|
|
4
|
+
对每个错误码,说明 `doctor`(`pnpm run doctor`,或
|
|
5
|
+
`node scripts/doctor.mjs --json`)是否覆盖其前置条件、由哪个检查 id 应答。
|
|
6
|
+
每个码的权威含义与修复在 [ARCHITECTURE.md](ARCHITECTURE.md)(错误码一节);
|
|
7
|
+
本页补充诊断维度与 verdict 契约。
|
|
8
|
+
|
|
9
|
+
## doctor 的裁决
|
|
10
|
+
|
|
11
|
+
`doctor --json`(schemaVersion 2)以 `verdict: "ready" | "blocked"` 收尾,
|
|
12
|
+
阻断 id 列在 `blockers`,按 distro 的细分在 `distroVerdicts`。阻断规则只有
|
|
13
|
+
一条不变式:**`fail` 即阻断**——配置感知体现在状态上(缺 systemd 只在
|
|
14
|
+
`sessionSandbox: true` 时 fail;`auto` 点名其 per-command 回退,`false`
|
|
15
|
+
点名选择退出,两者均为 warn),因此裁决回答的是**生效配置**——应用实际
|
|
16
|
+
加载的 profile 层叠加在出厂 preset 之上——而不是出厂默认。`config.effective`
|
|
17
|
+
检查报告读到了什么、从哪里读的。
|
|
18
|
+
|
|
19
|
+
`verdict: ready` 表示首条命令应在目标 distro、预期 scope 下成功;smoke 腿
|
|
20
|
+
(`functional.exec`、`functional.sandbox`、`functional.fs`)证明链路本身——
|
|
21
|
+
帧 I/O、受限围栏、批量 substrate——而不只是前置条件。前置失败的腿以
|
|
22
|
+
`skipped` 报告并点名阻断者;`skipped` 永不阻断。传输层无法担保的读数——
|
|
23
|
+
`wsl.exe` 超时或探测中途卡死(多个 distro 并发探测、其中一个正在冷启动时
|
|
24
|
+
最常见)——在自动重试一次后报告 `unknown`,detail 点名该次抖动;`unknown`
|
|
25
|
+
永不阻断,也不构成配置裁决:`/etc/wsl.conf` 读数抖动说明的是读取失败,
|
|
26
|
+
而不是文件损坏。重跑 doctor 即可得到干净答案。
|
|
27
|
+
|
|
28
|
+
`--fix` 以复验报告收尾:每个修复后都跟着一次对它声称修好的东西的全新探查,
|
|
29
|
+
受影响的检查项携带 after 状态,verdict 重算——`ready`,或剩余阻断者。
|
|
30
|
+
会改写用户或 distro 所有文件的修复(`.wslconfig`、`/etc/wsl.conf`、WSL1
|
|
31
|
+
转换、安装 distro)永不开户自动化;remedy 文本会写明。
|
|
32
|
+
|
|
33
|
+
`--bundle <path>` 写出本地 JSON 文件(报告 + 版本 + 生效配置)供 setup
|
|
34
|
+
report 附带;`--redact` 把 home 与 DSH 路径替换为 `<redacted-*>` 占位符。
|
|
35
|
+
bundle 不含文件内容、环境变量,也没有遥测。
|
|
36
|
+
|
|
37
|
+
## 三个入口
|
|
38
|
+
|
|
39
|
+
doctor 通过三个入口给出同一份报告:
|
|
40
|
+
|
|
41
|
+
- **独立 CLI**——`node scripts/doctor.mjs [distro] [--json] [--quick] [--sections …] [--locale <tag>]`。
|
|
42
|
+
这是权威入口:它**不加载任何 peer 依赖、任何宿主服务**,即使插件的运行时
|
|
43
|
+
本身就是故障源,它也能启动。只 import 纯净、无 peer 的 `lib/` 模块;原先
|
|
44
|
+
挂在 peer 污染模块(`lib/index.js`、`lib/update-check.js`)后面的两个
|
|
45
|
+
helper 已内联,并由 `test/doctor.test.mjs` 与 lib 导出对拍防漂移。
|
|
46
|
+
退出码 0 = `ready`,1 = `blocked`。
|
|
47
|
+
- **`/wsl-doctor` UI 命令**——composer 按钮投下
|
|
48
|
+
`/wsl-doctor [quick|full|<分区>] [--distro <名称>]`;命令面在宿主侧执行,
|
|
49
|
+
handler 子进程运行独立 CLI,逐项报告直接渲染在 UI 上、不进模型历史
|
|
50
|
+
(无模型回合、零 token)。没有命令适配器的部署(headless、ACP)中该行是
|
|
51
|
+
no-op,CLI 就是入口。
|
|
52
|
+
- **`wsl_doctor` 模型工具**——经 `doctorReport()` 进程内采集,会合并常驻
|
|
53
|
+
agent 的实时状态。这是唯一依赖模型链路的入口;怀疑插件运行时本身时,
|
|
54
|
+
用命令或 CLI。
|
|
55
|
+
|
|
56
|
+
## 地图
|
|
57
|
+
|
|
58
|
+
类别图例:
|
|
59
|
+
|
|
60
|
+
- **environment**——doctor 探查的机器状态;doctor 绿即覆盖。
|
|
61
|
+
- **policy**——按调用决定(沙箱围栏、distro 围栏);doctor 证明围栏形状,
|
|
62
|
+
调用决定具体情形。
|
|
63
|
+
- **data**——调用方或数据瞬态;不存在机器前置条件,因此没有 doctor 检查
|
|
64
|
+
认领它。
|
|
65
|
+
|
|
66
|
+
| 码 | 类别 | doctor 检查 | 一句话 |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| `SANDBOX_UNAVAILABLE` | environment | `sandbox.bwrap`、`sandbox.bwrap-usable`、`functional.sandbox` | 所请求的隔离无法强制(无可用 bubblewrap) |
|
|
69
|
+
| `FS_SANDBOX_DENIED` | policy | `functional.sandbox`(围栏形状) | 文件效果策略拒绝了写入,或内核在驻留 agent 的 profile 处拒绝 |
|
|
70
|
+
| `FS_OUTSIDE_DISTRO` | policy | `config.effective`(生效的 `distro`) | 围栏钉死时路径指向另一 distro 的共享 |
|
|
71
|
+
| `FS_IO_ERROR` | environment | `distro.reachable`、`distro.disk`、`agent.handshake`、`functional.exec`、`functional.fs` | 兜底:agent 失联、distro 僵死、磁盘满、无法映射的路径 |
|
|
72
|
+
| `FS_NOT_FOUND` | data | — | 路径不存在——普通答案 |
|
|
73
|
+
| `FS_NOT_REGULAR_FILE` | data | — | 需要常规文件处出现了目录、符号链接或设备 |
|
|
74
|
+
| `FS_NOT_DIRECTORY` | data | — | 对非目录发起列表 |
|
|
75
|
+
| `FS_NOT_TEXT` | data | — | 内容不是 UTF-8 文本 |
|
|
76
|
+
| `FS_TOO_LARGE` | data | — | 内容超出调用方携带的字节上限 |
|
|
77
|
+
| `FS_ABORTED` | data | — | 调用方自己的信号取消了调用 |
|
|
78
|
+
| `FS_NOT_OBSERVED` | data | — | 受守卫的创建命中了存在但未读过的文件 |
|
|
79
|
+
| `FS_STALE_VERSION` | data | — | 调用方版本过期;重读后重试 |
|
|
80
|
+
| `FS_EDIT_NOT_FOUND` | data | — | 字面编辑没有命中 |
|
|
81
|
+
| `FS_AMBIGUOUS_EDIT` | data | — | 字面编辑命中多处 |
|
|
82
|
+
| `FS_PATCH_MISMATCH` | data | — | hunk 与文件不再吻合;按新文本重建 |
|
|
83
|
+
| `FS_SAME_TARGET` | data | — | move 的源与目的地解析为同一文件 |
|
|
84
|
+
| `AgentUnavailableError` | environment | `agent.handshake`、`agent.native`、`agent.cache`、`functional.exec` | 执行层的复活预算耗尽;具名状态会说明 |
|
|
85
|
+
|
|
86
|
+
agent 的结构化 FS 原因(`notfound`、`notdir`、`perm`、`loop`、`stale`、
|
|
87
|
+
`io`)在 `lib/fsio-agent.js` 映射到上表各码;线上方言本身见
|
|
88
|
+
[AGENT-PROTOCOL-V7.md](AGENT-PROTOCOL-V7.md)。
|
|
89
|
+
|
|
90
|
+
## doctor 绿但调用仍失败
|
|
91
|
+
|
|
92
|
+
那是 **policy** 与 **data** 类别在正常工作:doctor 无法预测取决于调用而非
|
|
93
|
+
机器的拒绝。若某个 **environment** 类错误码反复出现而 doctor 显示 `ready`,
|
|
94
|
+
那是缺陷——附上 `doctor --bundle` 输出提报
|
|
95
|
+
([setup report](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/.github/ISSUE_TEMPLATE/setup_report.yml)
|
|
96
|
+
会携带它)。
|
package/docs/LIMITATIONS.md
CHANGED
|
@@ -94,6 +94,14 @@ operations never use the 9p share.
|
|
|
94
94
|
[ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement).
|
|
95
95
|
- **`bubblewrap` must be installed**, or both providers fail with the install
|
|
96
96
|
command; a session-start preflight surfaces the same text as an advisory warning.
|
|
97
|
+
- **Message localization is partial by design** — the preflight verdicts, `bwrap`
|
|
98
|
+
remedies and distro/workdir errors follow the app's Language setting
|
|
99
|
+
([CONFIGURATION.md](CONFIGURATION.md#message-language)); the `FS_*` refusal texts
|
|
100
|
+
in `fs-decisions` and the fsio replica stay byte-identical English because the
|
|
101
|
+
tool layer matches on those strings, and the standalone `scripts/doctor.mjs`
|
|
102
|
+
always prints English because it runs outside the app and cannot read the
|
|
103
|
+
host's locale preference. A remedy composed at probe time keeps the language
|
|
104
|
+
the probe ran in until that probe runs again.
|
|
97
105
|
- A workspace directory deleted mid-session fails with a runner error; the plugin
|
|
98
106
|
does not recreate it. A configured `cwd` that does not exist is reported as an
|
|
99
107
|
error naming the directory.
|
|
@@ -130,6 +138,23 @@ absolute path to pin one.
|
|
|
130
138
|
`git.exe`** — the `safe.directory` whitelist that WSL change review needs when
|
|
131
139
|
Windows git is installed (see Terminals below).
|
|
132
140
|
|
|
141
|
+
## The doctor's verdict and remedy boundary
|
|
142
|
+
|
|
143
|
+
The doctor's `verdict` answers under the effective configuration (the profile
|
|
144
|
+
layers the app loads, overlaid on the shipped preset) — but it is a verdict
|
|
145
|
+
about the machine and the configuration, not about a session: the
|
|
146
|
+
**policy**- and **data**-class error codes (see
|
|
147
|
+
[DIAGNOSTICS.md](DIAGNOSTICS.md#the-map)) are per-call decisions the doctor
|
|
148
|
+
cannot predict, and `ready` does not promise them away.
|
|
149
|
+
|
|
150
|
+
The doctor reads and reports; it never rewrites user- or distro-owned files.
|
|
151
|
+
`.wslconfig`, `/etc/wsl.conf`, a WSL1 conversion and distro installation are
|
|
152
|
+
remedy-only — the remedy text carries the exact command — and the fixable set
|
|
153
|
+
is limited to what is safe and reversible (stale scopes, the optional
|
|
154
|
+
packages behind `--install` plus a confirmation, and the Windows git
|
|
155
|
+
safe.directory whitelist behind the same gate). The verdict never upgrades
|
|
156
|
+
the sandbox's security statement: `enforcement: partial` is untouched.
|
|
157
|
+
|
|
133
158
|
## Session-start advisories
|
|
134
159
|
|
|
135
160
|
- **There is no session-UI notice seam in DSH 0.2.1.** `wsl-preflight` failures go
|
package/docs/LIMITATIONS.zh.md
CHANGED
|
@@ -88,6 +88,13 @@ Windows 侧 share 后端(`substrate: "share"`)在启动时被拒绝;WSL
|
|
|
88
88
|
[ARCHITECTURE.md](ARCHITECTURE.md#reported-enforcement)。
|
|
89
89
|
- **必须安装 `bubblewrap`**,否则两个提供者都会带着安装命令失败;
|
|
90
90
|
会话启动预检会以建议性警告的形式给出同样的文本。
|
|
91
|
+
- **消息本地化按设计只覆盖一部分** —— 预检判定、`bwrap` 修复提示与
|
|
92
|
+
发行版/工作目录错误跟随应用的语言设置
|
|
93
|
+
([CONFIGURATION.zh.md](CONFIGURATION.zh.md#消息语言));`fs-decisions`
|
|
94
|
+
中的 `FS_*` 拒绝文本与 fsio 复刻保持逐字节英文,因为工具层按这些字符串
|
|
95
|
+
匹配;独立的 `scripts/doctor.mjs` 永远输出英文,因为它在应用之外运行,
|
|
96
|
+
读不到宿主的语言偏好。探测时合成的修复文本保持探测发生时的语言,
|
|
97
|
+
直到该探测再次运行。
|
|
91
98
|
- 会话中途被删除的工作区目录会以 runner 错误失败;插件不会重建它。
|
|
92
99
|
配置的 `cwd` 不存在时,报错会指明该目录。
|
|
93
100
|
|
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, syntax, build freshness, tsc,
|
|
77
|
+
| `pnpm test` | style, links, syntax, build freshness, tsc, 42 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) |
|
package/docs/QUICKSTART.md
CHANGED
|
@@ -23,10 +23,21 @@ 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? In a session, ask for a diagnosis: the model runs the
|
|
27
|
+
`wsl_doctor` tool (mounted by this plugin) and the verdict — `ready`, or
|
|
28
|
+
`blocked` with per-failure copy-paste remedies — lands in the transcript.
|
|
29
|
+
The session-start preflight announces the same verdict on every session
|
|
30
|
+
start. `DSH_WSL_DOCTOR` additionally carries a ready-to-run command for the
|
|
31
|
+
doctor script itself (`sh -c "$DSH_WSL_DOCTOR --json"`).
|
|
32
|
+
|
|
26
33
|
The doctor (`scripts/doctor.mjs`, or `pnpm run doctor` from a checkout) checks
|
|
27
|
-
the environment and
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
the environment and ends in a verdict: `ready` means the first command should
|
|
35
|
+
succeed; `blocked` names the exact checks to fix, each with a copy-paste
|
|
36
|
+
remedy. It reads the distro's WSL mode from `wsl.exe -l -v` itself, so no
|
|
37
|
+
separate version check is needed. Doctor is read-only unless you pass `--fix`
|
|
38
|
+
(stale scopes, and the Windows git trust after a confirmation) or
|
|
39
|
+
`--fix --install` (packages, after a confirmation); `--bundle <path>` writes
|
|
40
|
+
the diagnostic file a setup report attaches.
|
|
30
41
|
|
|
31
42
|
## 2. Install
|
|
32
43
|
|
|
@@ -94,6 +105,11 @@ distro kernel. If the first command fails, the error names the remedy; the
|
|
|
94
105
|
[doctor](CONFIGURATION.md) and the [Troubleshooting table](../README.md#troubleshooting)
|
|
95
106
|
cover the common cases.
|
|
96
107
|
|
|
108
|
+
First-write note: the sandbox asks for permission before a write the session
|
|
109
|
+
policy has not granted — the prompt names the command and the target, and
|
|
110
|
+
allowing it once is safe. Enabling `loginctl enable-linger <user>` inside the
|
|
111
|
+
distro prevents the repeat prompts a non-lingering user manager causes.
|
|
112
|
+
|
|
97
113
|
The probe below runs the shipped kernel-enforced bwrap profiles live — writes
|
|
98
114
|
inside the workspace land, tested writes outside are refused with `EROFS`, and
|
|
99
115
|
the strict profile hides `/mnt` entirely
|
package/docs/RELEASING.md
CHANGED
|
@@ -256,3 +256,6 @@ npm does not let a published version be replaced, so the fix goes forward:
|
|
|
256
256
|
| The npm readme is chosen from the candidate files at the package root, and the rule is not fully explained. With `README.md` and `README.zh.md` side by side, version 0.1.1 published as `readmeFilename: README.zh.md`, so its npm page rendered Chinese — even though the tarball listed `README.md` first. Both names match the npm CLI's own selection code (`@npmcli/package-json/lib/normalize.js` globs `{README,README.*}` and accepts `/\.m?a?r?k?d?o?w?n?$/i`, which does match `.md`), so neither name is screened out. | Do not rely on the rule. Keep exactly one readme candidate at the package root, which `pnpm run lint:style` checks. The Chinese README lives in `docs/` for this reason. |
|
|
257
257
|
| A local `~/.npmrc` may point at a mirror | Pass `--registry=https://registry.npmjs.org/` on every publish and every verification. |
|
|
258
258
|
| The npm token is a credential | Keep it out of command arguments and the repository; revoke a temporary token after the release. |
|
|
259
|
+
| `gh api -f body="$var"` posts the variable as literal text, so a JSON-encoded string lands as visible `\uXXXX` escapes | The 0.19.0 announcement (2026-11-06) rendered as `\u5d2f\u53d1...` on discussion #8644 because the body was `json.dumps`-encoded and then passed through `-f`, which treats the value as raw. For non-ASCII content use `-F body=@file` (`-F` reads the file's bytes verbatim), and delete the bad comment via `deleteDiscussionComment` before reposting. |
|
|
260
|
+
| A successful write to an external system says nothing about the rendered content | Every release step that posts content (discussion comments, GitHub Release notes) must read the result back and compare it to the local source before declaring the step done. The API returns success for a double-encoded body; only the read-back — grep for `\u` escape sequences, diff the first lines against the source file — catches it. The workflow's release-verify step had to be re-created by hand on 0.19.0 for the sibling reason: its one-shot registry check ran inside the propagation window (now fixed to poll, cea5d4a). |
|
|
261
|
+
| WSL mounts drvfs per terminal session | After a `C:` 9p mount flips to read-only, `sudo mount -t drvfs 'C:' /mnt/c -o remount,rw` only fixes the session that ran it; another shell (a probe runner, an agent session) keeps the stale read-only mount and `sync-to-windows` fails with tar exit 2 ("Read-only file system"). Recover in the terminal that will run the sync: `sudo umount -l /mnt/c && sudo mount -t drvfs 'C:' /mnt/c -o rw,uid=1000,gid=1000`, then verify with `touch` before rerunning. |
|
package/docs/ROADMAP-1.0.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Roadmap 1.0: the WSL plugin the DSH ecosystem should have
|
|
2
2
|
|
|
3
|
-
Status: working plan, last refreshed 2026-11-
|
|
3
|
+
Status: working plan, last refreshed 2026-11-07 against `0.19.0` (WSL-316 doctor closed-loop planning; the §2 area tables were last refreshed at 0.15.0).
|
|
4
4
|
The 0.12.0 baseline that motivated the plan is kept below as history.
|
|
5
5
|
Audience: maintainers and contributors. This is a plan, not a release promise.
|
|
6
6
|
The short version: **from "the only WSL plugin" to "the default WSL plugin"** —
|
|
@@ -197,6 +197,13 @@ editor/LSP rewrite without an upstream seam, and default telemetry.
|
|
|
197
197
|
|
|
198
198
|
**Decision rules:**
|
|
199
199
|
|
|
200
|
+
- A new feature candidate originates from a logged pain in the
|
|
201
|
+
repository-local pain journal (`docs/superpowers/pains.md`), not from a
|
|
202
|
+
document-inferred gap; it
|
|
203
|
+
passes the three triage questions (who hurts, magnitude on the human time
|
|
204
|
+
scale, cost of not doing it) before entering this roadmap. The 2026-11-06
|
|
205
|
+
batch is the calibration: per-file watch events, the `@` seam push and the
|
|
206
|
+
clean-machine timing all died on these questions.
|
|
200
207
|
- A P1 item moves only with a measured need or a concrete consumer.
|
|
201
208
|
- A compatibility claim enters the matrix only with a test or a probe.
|
|
202
209
|
- A security statement never exceeds what the sandbox actually enforces.
|
|
@@ -379,9 +386,13 @@ command.
|
|
|
379
386
|
- [x] The preflight checks bwrap, systemd PID 1, `systemd-run` and Linger.
|
|
380
387
|
- [x] The warning is visibly attached to the session through the
|
|
381
388
|
runtime-context entry (not only logs).
|
|
382
|
-
- [
|
|
383
|
-
|
|
384
|
-
|
|
389
|
+
- [x] The transcript renders it: the runtime-context entry now carries the
|
|
390
|
+
verdict on healthy sessions too (the ready line). A dedicated GUI
|
|
391
|
+
notice/banner remains the session-notice ask
|
|
392
|
+
([#10263](https://github.com/deepseek-ai/deepseek-harness/discussions/10263)),
|
|
393
|
+
now self-sufficient: the `wsl_doctor` tool runs the doctor in-session
|
|
394
|
+
(the per-plugin diagnostics proposal #12499 was filed and withdrawn the
|
|
395
|
+
same day — the cohesive shape needs no upstream surface).
|
|
385
396
|
- [x] The warning never installs anything and never changes fail-closed
|
|
386
397
|
behavior.
|
|
387
398
|
- [x] A session with a usable environment produces no warning.
|
|
@@ -813,6 +824,40 @@ release gate; full probe suite.
|
|
|
813
824
|
|
|
814
825
|
**Depends on:** WSL-101, WSL-102, WSL-202, WSL-203.
|
|
815
826
|
|
|
827
|
+
### WSL-316 — Doctor closed loop: WSL mode, `.wslconfig`/`wsl.conf` diagnostics, verdict and smoke legs
|
|
828
|
+
|
|
829
|
+
**Priority:** P2 · **Size:** L · **Labels:** `area:onboarding`,
|
|
830
|
+
`type:feature`, `priority:P2`
|
|
831
|
+
|
|
832
|
+
**Status:** implemented on the plugin side (2026-11-07); the app-closed probe suite legs and the GUI-session closed-loop leg are on the maintainer checklist — the real-machine record is [2026-11-07 doctor real-machine](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/docs/superpowers/probe-runs/2026-11-07-doctor-real-machine.md). Designed and implemented the same day. The initial three
|
|
833
|
+
check groups (`distro.wsl-mode`, `config.wslconfig`, `distro.wsl-conf-*`) were
|
|
834
|
+
filed in [issue #35](https://github.com/Big-Dao/dsh-plugin-wsl-env/issues/35)
|
|
835
|
+
from the competitive triage (gaps #2/#3/#4). A commercial-doctor review added
|
|
836
|
+
A-level gaps (multi-distro `--all` with per-distro verdicts, the disk-full
|
|
837
|
+
class, `.wslconfig` semantics, the error-code matrix document, per-section
|
|
838
|
+
timing) and accepted B-level items (`--bundle`, DNS/clock legs, the
|
|
839
|
+
`git.win-safe` fix, `skipped` hygiene, deprecated-key detection) — the design
|
|
840
|
+
addendum and the acceptance list in the issue are the contract. Execution plan:
|
|
841
|
+
[2026-11-07 doctor closed-loop plan](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/docs/superpowers/plans/2026-11-07-doctor-closed-loop.md).
|
|
842
|
+
|
|
843
|
+
**Why:** the doctor is the onboarding promise's enforcement point; the bar is
|
|
844
|
+
the closed loop — after `doctor` and its named remedies, the first command
|
|
845
|
+
works, and `verdict: ready | blocked` says so machine-readably under the
|
|
846
|
+
**effective configuration** (a `session.systemd` failure blocks only under
|
|
847
|
+
`sessionSandbox: true`; with `auto` the fallback runs).
|
|
848
|
+
|
|
849
|
+
**Acceptance:** the issue's revised checklist (fake-`wsl.exe` matrix per new
|
|
850
|
+
check, smoke-leg fault injection, the fix-loop before→after re-verify, the
|
|
851
|
+
Tier 1 closed loop run with the GUI-session leg executed by the maintainer,
|
|
852
|
+
bilingual DIAGNOSTICS coverage of every shipped error code).
|
|
853
|
+
|
|
854
|
+
**Tests/probes:** `test/doctor.test.mjs` fake-`wsl.exe`/`cmd.exe` matrix;
|
|
855
|
+
`pnpm run doctor` against the real `wsl.exe` (read-only); the app-closed probe
|
|
856
|
+
suite for the maintainer-run legs.
|
|
857
|
+
|
|
858
|
+
**Depends on:** none upstream; the GUI verdict surface stays behind the
|
|
859
|
+
session-notice seam (#10263, deferred).
|
|
860
|
+
|
|
816
861
|
## 10. Release gates
|
|
817
862
|
|
|
818
863
|
A release is ready when:
|
|
@@ -73,6 +73,11 @@ or re-implementing the ranking engine — the regression path the RFC rules out.
|
|
|
73
73
|
**Fallback: keep the 9p walk.** `@` completion works today; it pays the
|
|
74
74
|
per-directory share cost above. There is no plugin-side optimization that is
|
|
75
75
|
safe without the seam, and the plugin does not replace the upstream module.
|
|
76
|
+
Maintainer observation (2026-11-06, real use): completion latency is
|
|
77
|
+
acceptable in practice — the human scanning the candidate list dominates the
|
|
78
|
+
walk, so the measured 56× is not the pain point. The seam stays a passive
|
|
79
|
+
wire-up when it lands (the canary watches the peer line); no active upstream
|
|
80
|
+
push is planned.
|
|
76
81
|
|
|
77
82
|
Wire `file-reference-wsl` when either happens:
|
|
78
83
|
|
|
@@ -7,6 +7,39 @@ start as Node, exit 1, and the UI reports launch-failed. File Explorer and
|
|
|
7
7
|
other non-Electron launchers work. The failure is the same on a Windows
|
|
8
8
|
folder and on a WSL UNC workspace.
|
|
9
9
|
|
|
10
|
+
Update 2026-11-06: the `0.2.1-rc.5` line cleared the flag in
|
|
11
|
+
`launchDetachedApp` (`clearedElectronFlag`, extracted in
|
|
12
|
+
[app.asar.0.2.1-rc.5.open-in-app.index.js](upstream/app.asar.0.2.1-rc.5.open-in-app.index.js)),
|
|
13
|
+
and **`0.2.2-rc.1` lost that clearing** — the regression is back on the
|
|
14
|
+
current runtime. The local machine carries a re-applied patch to the
|
|
15
|
+
installed `app.asar` (same helper, both `lib/index.js` and
|
|
16
|
+
`lib/types/resolver.js` of `@deepseek-ai/dsh-host-open-in-app`);
|
|
17
|
+
`test/probe/open-in-app-patch.sh` detects which state an install is in
|
|
18
|
+
(upstream-fixed / locally-patched / broken) and must be run after every app
|
|
19
|
+
upgrade, because an upgrade replaces the archive and silently drops the
|
|
20
|
+
local patch.
|
|
21
|
+
|
|
22
|
+
### Local patch 2 — WSL workspaces open through `--folder-uri` (verified 2026-11-06)
|
|
23
|
+
|
|
24
|
+
Riding on the same re-patch: a WSL UNC workspace
|
|
25
|
+
(`\\wsl.localhost\<distro>\...`) passed as a plain path opens a plain-folder
|
|
26
|
+
window where every command runs on the Windows side, and VS Code only
|
|
27
|
+
*suggests* "Reopen Folder in WSL". The patched `launchArgs` converts a WSL
|
|
28
|
+
UNC path (both `wsl.localhost` and `wsl$` spellings) to
|
|
29
|
+
`vscode-remote://wsl%2B<distro>/<posix path>` and passes it as
|
|
30
|
+
`--folder-uri=<uri>` — but only when the launch command is an Electron
|
|
31
|
+
editor (`Code.exe`, `Code - Insiders.exe`, `Cursor.exe`, `Windsurf.exe`);
|
|
32
|
+
every other launcher (terminals, Explorer) keeps the literal path, and
|
|
33
|
+
drive-letter paths are never rewritten. Two shapes were tried before this
|
|
34
|
+
one settled: the URI as a positional argument opens an untitled *file* whose
|
|
35
|
+
content is the URI text, so the explicit `--folder-uri=` form is required.
|
|
36
|
+
The patched module is archived in
|
|
37
|
+
[app.asar.0.2.2-rc.1.open-in-app.index.js](upstream/app.asar.0.2.2-rc.1.open-in-app.index.js).
|
|
38
|
+
|
|
39
|
+
Upstream ask, extended: besides clearing `ELECTRON_RUN_AS_NODE`, resolve a
|
|
40
|
+
WSL UNC workspace to its `vscode-remote` URI for Electron editors, so the
|
|
41
|
+
launched window is already in Remote-WSL.
|
|
42
|
+
|
|
10
43
|
User-facing note: [LIMITATIONS.md](LIMITATIONS.md#host-open-in-app).
|
|
11
44
|
|
|
12
45
|
## Environment
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root host half of `dsh-plugin-wsl-env`: a deliberate no-op plugin.
|
|
3
|
+
*
|
|
4
|
+
* The web client-modules roster only scans Loader rows whose name is an exact
|
|
5
|
+
* package name (`exactPackageSpecifier` rejects subpaths), so the browser half
|
|
6
|
+
* declared under `dsh.client` loads only when this package is mounted at its
|
|
7
|
+
* bare name. The shell executor that used to own `.` cannot serve that role:
|
|
8
|
+
* mounted at the composition root it would shadow the shipped host shell for
|
|
9
|
+
* every session. The two roles therefore split —
|
|
10
|
+
*
|
|
11
|
+
* - `.` (this module): a no-op host half, safe at the composition root; its
|
|
12
|
+
* only job is anchoring the bare-name row whose manifest the roster reads
|
|
13
|
+
* to serve `./client`;
|
|
14
|
+
* - `./shell` (`lib/shell.js`): the session shell executor, mounted inside
|
|
15
|
+
* the WSL agent preset's isolate realm.
|
|
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
|
|
19
|
+
* the explicit subpath. Before 0.20.0 `.` resolved to the executor itself —
|
|
20
|
+
* a profile that relied on that shape must switch to `dsh-plugin-wsl-env/shell`.
|
|
21
|
+
*
|
|
22
|
+
* This is a TypeScript source built to `lib/client-host.js`; edit THIS file and
|
|
23
|
+
* run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
24
|
+
* `pnpm test` fails when it drifts.
|
|
25
|
+
*
|
|
26
|
+
* @module dsh-plugin-wsl-env
|
|
27
|
+
*/
|
|
28
|
+
/** A no-op Cordis plugin: no config, no services, no effects. */
|
|
29
|
+
export declare function apply(): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root host half of `dsh-plugin-wsl-env`: a deliberate no-op plugin.
|
|
3
|
+
*
|
|
4
|
+
* The web client-modules roster only scans Loader rows whose name is an exact
|
|
5
|
+
* package name (`exactPackageSpecifier` rejects subpaths), so the browser half
|
|
6
|
+
* declared under `dsh.client` loads only when this package is mounted at its
|
|
7
|
+
* bare name. The shell executor that used to own `.` cannot serve that role:
|
|
8
|
+
* mounted at the composition root it would shadow the shipped host shell for
|
|
9
|
+
* every session. The two roles therefore split —
|
|
10
|
+
*
|
|
11
|
+
* - `.` (this module): a no-op host half, safe at the composition root; its
|
|
12
|
+
* only job is anchoring the bare-name row whose manifest the roster reads
|
|
13
|
+
* to serve `./client`;
|
|
14
|
+
* - `./shell` (`lib/shell.js`): the session shell executor, mounted inside
|
|
15
|
+
* the WSL agent preset's isolate realm.
|
|
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
|
|
19
|
+
* the explicit subpath. Before 0.20.0 `.` resolved to the executor itself —
|
|
20
|
+
* a profile that relied on that shape must switch to `dsh-plugin-wsl-env/shell`.
|
|
21
|
+
*
|
|
22
|
+
* This is a TypeScript source built to `lib/client-host.js`; edit THIS file and
|
|
23
|
+
* run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
24
|
+
* `pnpm test` fails when it drifts.
|
|
25
|
+
*
|
|
26
|
+
* @module dsh-plugin-wsl-env
|
|
27
|
+
*/
|
|
28
|
+
/** A no-op Cordis plugin: no config, no services, no effects. */
|
|
29
|
+
export function apply() { }
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distro-native `working_directory` tool output: serve the model's own
|
|
3
|
+
* read/cd tool with the SAME read/`cd` semantics the harness ships, but with
|
|
4
|
+
* the returned `cwd` rewritten to the distro's POSIX form on a WSL session.
|
|
5
|
+
*
|
|
6
|
+
* The runtime-context rewrite (`lib/cwd-prompt.js`) covers the system-prompt
|
|
7
|
+
* entry and the per-turn snapshot. The `working_directory` tool is the THIRD
|
|
8
|
+
* surface the cwd reaches the model through: `dsh-tool-working-directory`
|
|
9
|
+
* prints `fs.processPath()` verbatim, which on this deployment is the UNC
|
|
10
|
+
* spelling — the one coordinate the distro shell cannot resolve. A model that
|
|
11
|
+
* quotes that path into `bash` fails exactly the failure mode the
|
|
12
|
+
* runtime-context rewrite exists to remove, so the surfaces must agree.
|
|
13
|
+
*
|
|
14
|
+
* This row DISABLES the shipped tool row and mounts a replacement with the
|
|
15
|
+
* same tool name, the same parameters, the same `cd` semantics (the harness's
|
|
16
|
+
* `workingDirectory` service still owns directory validation, resolution, and
|
|
17
|
+
* the durable change), and one difference: the returned `cwd` string has every
|
|
18
|
+
* WSL UNC spelling rewritten to its POSIX form. A non-WSL path passes through
|
|
19
|
+
* byte for byte, so host sessions see the shipped behavior.
|
|
20
|
+
*
|
|
21
|
+
* Advisory by construction. The service reads the harness's
|
|
22
|
+
* `workingDirectory` structurally; a harness without it fails this row's
|
|
23
|
+
* activation loudly (a missing service is a composition error, not a runtime
|
|
24
|
+
* degradation), while every per-call failure is the shipped tool's own — this
|
|
25
|
+
* wrapper adds no I/O and no new failure modes.
|
|
26
|
+
*
|
|
27
|
+
* This is a TypeScript source built to `lib/cwd-prompt-tool.js`; edit THIS
|
|
28
|
+
* file and run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
29
|
+
* `pnpm test` fails when it drifts.
|
|
30
|
+
*
|
|
31
|
+
* @module dsh-plugin-wsl-env/cwd-prompt-tool
|
|
32
|
+
*/
|
|
33
|
+
export declare const name = "wsl-cwd-prompt-tool";
|
|
34
|
+
/**
|
|
35
|
+
* The context properties `apply` reads. Cordis 4 refuses an undeclared read —
|
|
36
|
+
* `cannot get property "tools" without inject` — so both the tool registry and
|
|
37
|
+
* the harness's `workingDirectory` service must be named here. Both are
|
|
38
|
+
* required: a host without one fails this row's activation loudly, which is
|
|
39
|
+
* the design (a missing service is a composition error, not a degradation).
|
|
40
|
+
*/
|
|
41
|
+
export declare const inject: string[];
|
|
42
|
+
/** The config schema's validated output: the row takes no options. */
|
|
43
|
+
export interface CwdPromptToolConfig {
|
|
44
|
+
/** Reserved; the wrapper has no options today. */
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** The tool registry slice this service consumes. */
|
|
48
|
+
export interface ToolRegistrySlice {
|
|
49
|
+
register: (tool: unknown) => unknown;
|
|
50
|
+
}
|
|
51
|
+
/** The harness's `workingDirectory` service slice the shipped tool uses. */
|
|
52
|
+
export interface WorkingDirectoryToolSlice {
|
|
53
|
+
ensure: (agent: unknown, signal?: unknown) => Promise<string>;
|
|
54
|
+
set: (agent: unknown, path: string, signal?: unknown) => Promise<string>;
|
|
55
|
+
}
|
|
56
|
+
/** The cordis context slice this service consumes. */
|
|
57
|
+
export type CwdPromptToolContext = {
|
|
58
|
+
tools: ToolRegistrySlice;
|
|
59
|
+
workingDirectory: WorkingDirectoryToolSlice;
|
|
60
|
+
};
|
|
61
|
+
/** A resolved tool call: what the shipped tool's `execute` receives. */
|
|
62
|
+
export interface ToolExec {
|
|
63
|
+
/** The live agent, required by the shipped tool too. */
|
|
64
|
+
agent: unknown;
|
|
65
|
+
/** Cancellation for the underlying directory operations. */
|
|
66
|
+
signal?: unknown;
|
|
67
|
+
}
|
|
68
|
+
/** The tool's result: one rewritten absolute path. */
|
|
69
|
+
export interface WorkingDirectoryResult {
|
|
70
|
+
/** The current absolute working directory, distro-native on WSL sessions. */
|
|
71
|
+
cwd: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A raw absolute path as the model should see it: the POSIX path a WSL UNC
|
|
75
|
+
* names, and every other path unchanged. This is the single-path sibling of
|
|
76
|
+
* `cwd-prompt.js`'s `rewriteQuotedUnc`, which handles the JSON-quoted texts.
|
|
77
|
+
*
|
|
78
|
+
* @param path - the absolute path the harness produced.
|
|
79
|
+
* @returns the distro-native path, or the input unchanged.
|
|
80
|
+
*/
|
|
81
|
+
export declare function rewriteUncPath(path: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Mount the replacement tool.
|
|
84
|
+
*
|
|
85
|
+
* @param ctx - the cordis context (the composition root, where the shipped
|
|
86
|
+
* tool row is disabled by the patch layer).
|
|
87
|
+
*/
|
|
88
|
+
export declare function apply(ctx: CwdPromptToolContext): Promise<void>;
|