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.
- package/CHANGELOG.md +225 -0
- package/CONTRIBUTING.md +37 -5
- package/README.md +61 -6
- package/SUPPORT.md +3 -3
- package/agent/native/linux-aarch64/dsh-wsl-agent +0 -0
- package/agent/native/linux-x86_64/dsh-wsl-agent +0 -0
- package/agent/wsl-agent.sh +331 -11
- package/cordis.patch.yml +10 -5
- package/docs/AGENT-PROTOCOL-V7.md +175 -0
- package/docs/API.md +24 -0
- package/docs/ARCHITECTURE.md +20 -6
- package/docs/COMPATIBILITY.md +1 -1
- package/docs/CONFIGURATION.md +33 -5
- package/docs/CONFIGURATION.zh.md +25 -4
- package/docs/LIMITATIONS.md +39 -7
- package/docs/LIMITATIONS.zh.md +31 -6
- package/docs/MIGRATION.md +4 -4
- package/docs/PEER-PARITY.md +94 -35
- package/docs/QUICKSTART.md +19 -2
- package/docs/QUICKSTART.zh.md +16 -1
- package/docs/README.zh.md +47 -7
- package/docs/RELEASING.md +3 -2
- package/docs/REQUIREMENTS.zh.md +11 -6
- package/docs/ROADMAP-1.0.md +40 -29
- package/docs/ROADMAP.md +10 -6
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +6 -1
- package/docs/UPSTREAM-FSIO-EXPORT.md +2 -2
- package/docs/UPSTREAM-SERVICE-SWAP.md +124 -0
- package/docs/UPSTREAM-SESSION-NOTICE.md +3 -1
- package/docs/UPSTREAM-TERMINAL-TITLE.md +3 -0
- package/docs/root-fs-routing.md +3 -3
- package/lib/agent-confined.js +4 -4
- package/lib/agent-errors.d.ts +1 -1
- package/lib/agent-errors.js +1 -1
- package/lib/agent-exec.d.ts +1 -1
- package/lib/agent-exec.js +1 -1
- package/lib/agent-protocol.d.ts +58 -8
- package/lib/agent-protocol.js +40 -7
- package/lib/agent-shared.d.ts +1 -1
- package/lib/agent-shared.js +1 -1
- package/lib/agent.d.ts +171 -1
- package/lib/agent.js +448 -288
- package/lib/auto-preset.d.ts +1 -1
- package/lib/auto-preset.js +1 -1
- package/lib/bwrap.d.ts +1 -1
- package/lib/bwrap.js +1 -1
- package/lib/distro-route.d.ts +1 -1
- package/lib/distro-route.js +1 -1
- package/lib/doctor-live.d.ts +53 -0
- package/lib/doctor-live.js +37 -0
- package/lib/file-reference-wsl.d.ts +1 -1
- package/lib/file-reference-wsl.js +1 -1
- package/lib/fs-decisions.d.ts +1 -1
- package/lib/fs-decisions.js +1 -1
- package/lib/fs-routing.d.ts +52 -2
- package/lib/fs-routing.js +56 -1
- package/lib/fs-substrate.d.ts +90 -11
- package/lib/fs-substrate.js +202 -1
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +1 -1
- package/lib/fsio-agent.d.ts +128 -4
- package/lib/fsio-agent.js +224 -15
- package/lib/fsio-text.d.ts +1 -1
- package/lib/fsio-text.js +1 -1
- package/lib/git-exec.d.ts +1 -1
- package/lib/git-exec.js +1 -1
- package/lib/git-route.d.ts +1 -1
- package/lib/git-route.js +1 -1
- package/lib/index.d.ts +127 -3
- package/lib/index.js +301 -99
- package/lib/listing.d.ts +1 -1
- package/lib/listing.js +1 -1
- package/lib/native-agent.d.ts +1 -1
- package/lib/native-agent.js +2 -2
- package/lib/paths.d.ts +6 -3
- package/lib/paths.js +4 -4
- package/lib/picker.d.ts +1 -1
- package/lib/picker.js +7 -7
- package/lib/ports.d.ts +1 -1
- package/lib/ports.js +1 -1
- package/lib/preflight.d.ts +1 -1
- package/lib/preflight.js +1 -1
- package/lib/sandbox-core.d.ts +1 -1
- package/lib/sandbox-core.js +2 -2
- package/lib/sandbox.d.ts +1 -1
- package/lib/sandbox.js +1 -1
- package/lib/search-exec.d.ts +1 -1
- package/lib/search-exec.js +1 -1
- package/lib/search-route.d.ts +1 -1
- package/lib/search-route.js +1 -1
- package/lib/session-runtime.d.ts +1 -1
- package/lib/session-runtime.js +2 -2
- package/lib/session-scope.d.ts +1 -1
- package/lib/session-scope.js +1 -1
- package/lib/shell-env.d.ts +1 -1
- package/lib/shell-env.js +1 -1
- package/lib/shell.d.ts +1 -1
- package/lib/shell.js +1 -1
- package/lib/subprocess.d.ts +1 -1
- package/lib/subprocess.js +2 -2
- package/lib/terminal-activity.d.ts +1 -1
- package/lib/terminal-activity.js +1 -1
- package/lib/terminal-route.d.ts +1 -1
- package/lib/terminal-route.js +1 -1
- package/lib/watcher.d.ts +1 -1
- package/lib/watcher.js +1 -1
- package/lib/wsl.d.ts +1 -31
- package/lib/wsl.js +1 -21
- package/package.json +41 -28
- package/scripts/doctor.mjs +34 -11
package/scripts/doctor.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* a fresh-agent handshake, stale session scopes, and the known profile-patch trap.
|
|
10
10
|
*
|
|
11
11
|
* node scripts/doctor.mjs [distro] [--json] [--fix] [--install] [--yes] [--read-only]
|
|
12
|
+
* [--wsl <path to wsl.exe>]
|
|
12
13
|
*
|
|
13
14
|
* Exit status is 0 when nothing failed and 1 when a `fail` check did; warnings
|
|
14
15
|
* (optional tools, a missing cache) do not fail the run. `--fix` performs only
|
|
@@ -23,6 +24,12 @@
|
|
|
23
24
|
* `--json` prints one machine-readable report instead of the human sections.
|
|
24
25
|
* The report shape is versioned (`schemaVersion`).
|
|
25
26
|
*
|
|
27
|
+
* This CLI always probes a **fresh** resident — the app process's live
|
|
28
|
+
* resident's `deaths`/`lastError` are host-private (no IPC), and the report
|
|
29
|
+
* says so at the handshake check. Consumers holding the plugin's context
|
|
30
|
+
* merge them through `doctorReport()` in `lib/index.js` / the
|
|
31
|
+
* `mergeLiveResidentStatus` helper in `lib/doctor-live.js` (WSL-313).
|
|
32
|
+
*
|
|
26
33
|
* @module dsh-plugin-wsl/scripts/doctor
|
|
27
34
|
*/
|
|
28
35
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -39,7 +46,7 @@ import { sessionScopeSweepScript } from "../lib/session-scope.js";
|
|
|
39
46
|
import { parseListeningPorts, procNetScript } from "../lib/ports.js";
|
|
40
47
|
|
|
41
48
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
42
|
-
|
|
49
|
+
let WSL = "wsl.exe";
|
|
43
50
|
const CMD = "cmd.exe";
|
|
44
51
|
const TIMEOUT_MS = 60_000;
|
|
45
52
|
|
|
@@ -125,10 +132,19 @@ function inDistro(distro, script) {
|
|
|
125
132
|
/**
|
|
126
133
|
* Parse the doctor's own arguments.
|
|
127
134
|
* @param {string[]} argv - `process.argv.slice(2)`.
|
|
128
|
-
* @returns {{ distro: string, json: boolean, fix: boolean, install: boolean, yes: boolean, readOnly: boolean, help: boolean }} the options.
|
|
135
|
+
* @returns {{ distro: string, wsl: string, json: boolean, fix: boolean, install: boolean, yes: boolean, readOnly: boolean, help: boolean }} the options.
|
|
129
136
|
*/
|
|
130
137
|
function parseArgs(argv) {
|
|
131
|
-
const options = {
|
|
138
|
+
const options = {
|
|
139
|
+
distro: "",
|
|
140
|
+
wsl: "",
|
|
141
|
+
json: false,
|
|
142
|
+
fix: false,
|
|
143
|
+
install: false,
|
|
144
|
+
yes: false,
|
|
145
|
+
readOnly: false,
|
|
146
|
+
help: false,
|
|
147
|
+
};
|
|
132
148
|
for (let i = 0; i < argv.length; i += 1) {
|
|
133
149
|
const arg = argv[i] ?? "";
|
|
134
150
|
if (arg === "--json") options.json = true;
|
|
@@ -139,6 +155,8 @@ function parseArgs(argv) {
|
|
|
139
155
|
else if (arg === "--help" || arg === "-h") options.help = true;
|
|
140
156
|
else if (arg === "--distro") options.distro = argv[++i] ?? "";
|
|
141
157
|
else if (arg.startsWith("--distro=")) options.distro = arg.slice("--distro=".length);
|
|
158
|
+
else if (arg === "--wsl") options.wsl = argv[++i] ?? "";
|
|
159
|
+
else if (arg.startsWith("--wsl=")) options.wsl = arg.slice("--wsl=".length);
|
|
142
160
|
else if (arg.startsWith("-")) throw new Error(`doctor: unknown option "${arg}"`);
|
|
143
161
|
else options.distro = arg;
|
|
144
162
|
}
|
|
@@ -261,11 +279,16 @@ function rejectReadOnly() {
|
|
|
261
279
|
|
|
262
280
|
/**
|
|
263
281
|
* Run the doctor.
|
|
264
|
-
|
|
282
|
+
* @param {{ distro: string, wsl: string, json: boolean, fix: boolean, install: boolean, yes: boolean, readOnly: boolean, help: boolean }} options - the parsed options.
|
|
265
283
|
* @returns {Promise<number>} the exit status.
|
|
266
284
|
*/
|
|
267
285
|
async function main(options) {
|
|
268
286
|
if (options.readOnly && (options.fix || options.install)) return rejectReadOnly();
|
|
287
|
+
// One rebinding covers every probe below (`-l -q`, `inDistro`, the
|
|
288
|
+
// resident handshake, the sessions survey): an explicit `--wsl` replaces
|
|
289
|
+
// the module-level default for this whole run.
|
|
290
|
+
const wslExe = options.wsl.length > 0 ? options.wsl : WSL;
|
|
291
|
+
WSL = wslExe;
|
|
269
292
|
/** @type {Check[]} */
|
|
270
293
|
const checks = [];
|
|
271
294
|
/**
|
|
@@ -285,12 +308,12 @@ async function main(options) {
|
|
|
285
308
|
if (build !== null) check("host.windows", "ok", "Windows build", build[0]);
|
|
286
309
|
else check("host.windows", "info", "Windows build", "unreadable through cmd.exe; run this from Windows or a WSL with interop enabled");
|
|
287
310
|
|
|
288
|
-
const version = await run([
|
|
311
|
+
const version = await run([wslExe, "--version"]);
|
|
289
312
|
const wslVersion = version.stdout.replace(/\0/g, "").split(/\r?\n/).filter((line) => line.trim().length > 0).slice(0, 2).join(" ");
|
|
290
313
|
if (version.ok && wslVersion.length > 0) check("host.wsl", "ok", "WSL version", wslVersion);
|
|
291
314
|
else check("host.wsl", "warn", "WSL version", "wsl.exe --version failed; WSL 1 or a very old build", "wsl.exe --update, then confirm the distro runs as WSL 2 (wsl.exe -l -v shows VERSION 2)");
|
|
292
315
|
|
|
293
|
-
const listed = await run([
|
|
316
|
+
const listed = await run([wslExe, "-l", "-q"]);
|
|
294
317
|
const distros = listed.ok ? parseDistroList(listed.stdout.replace(/\0/g, "")) : [];
|
|
295
318
|
if (distros.length === 0) {
|
|
296
319
|
check("host.distros", "fail", "Installed distros", "none", "wsl.exe --list --online lists names; wsl.exe --install -d <name> installs one, then reopen the session");
|
|
@@ -421,13 +444,13 @@ async function main(options) {
|
|
|
421
444
|
} else if (!existsSync(agentScript)) {
|
|
422
445
|
check("agent.handshake", "fail", "Agent handshake", "agent/wsl-agent.sh is missing from this install", "reinstall the plugin; the shell agent ships with the package");
|
|
423
446
|
} else {
|
|
424
|
-
const handshake = await probeResident(distro, agentScript);
|
|
447
|
+
const handshake = await probeResident(distro, agentScript, wslExe);
|
|
425
448
|
if (handshake.ok) {
|
|
426
449
|
const live = livePids.length > 0
|
|
427
|
-
? `; a live resident (pid${livePids.length > 1 ? "s" : ""} ${livePids.join(", ")}) is already running in this distro — this check starts a fresh one, which cannot read its last error`
|
|
450
|
+
? `; a live resident (pid${livePids.length > 1 ? "s" : ""} ${livePids.join(", ")}) is already running in this distro — this check starts a fresh one, which cannot read its last error; the app-side doctorReport() merge surfaces it`
|
|
428
451
|
: "";
|
|
429
452
|
check("agent.handshake", handshake.digestMatches ? "ok" : "fail", "Agent handshake",
|
|
430
|
-
`pid ${handshake.pid}, protocol ${PROTOCOL_VERSION}, digest ${handshake.digestMatches ? "matches" : "MISMATCH — the distro reads a different script than this package"}${live}`,
|
|
453
|
+
`probed: a fresh resident, pid ${handshake.pid}, protocol ${PROTOCOL_VERSION}, digest ${handshake.digestMatches ? "matches" : "MISMATCH — the distro reads a different script than this package"}${live}`,
|
|
431
454
|
handshake.digestMatches ? undefined : "resync the runtime copy (pnpm run sync:windows), then restart the app");
|
|
432
455
|
} else {
|
|
433
456
|
check("agent.handshake", "fail", "Agent handshake", handshake.detail, "restart the DSH app; if it persists, delete ~/.cache/dsh-wsl/agent inside the distro and rerun the doctor");
|
|
@@ -573,7 +596,7 @@ async function main(options) {
|
|
|
573
596
|
* @param {string} scriptPath - the agent script as a Linux path inside the distro.
|
|
574
597
|
* @returns {Promise<{ ok: true, pid: number, digestMatches: boolean } | { ok: false, detail: string }>} the verdict, with the pid on success.
|
|
575
598
|
*/
|
|
576
|
-
function probeResident(distro, scriptPath) {
|
|
599
|
+
function probeResident(distro, scriptPath, wslExe = WSL) {
|
|
577
600
|
return new Promise((settle) => {
|
|
578
601
|
let settled = false;
|
|
579
602
|
/** @param {{ ok: true, pid: number, digestMatches: boolean } | { ok: false, detail: string }} value - the verdict. */
|
|
@@ -584,7 +607,7 @@ function probeResident(distro, scriptPath) {
|
|
|
584
607
|
child.kill();
|
|
585
608
|
settle(value);
|
|
586
609
|
};
|
|
587
|
-
const child = spawn(
|
|
610
|
+
const child = spawn(wslExe, ["-d", distro, "--exec", "sh", scriptPath], {
|
|
588
611
|
stdio: ["pipe", "pipe", "pipe"],
|
|
589
612
|
windowsHide: true,
|
|
590
613
|
env: { ...process.env, WSL_UTF8: "1" },
|