dsh-plugin-wsl-env 0.26.1 → 0.26.3-rc.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 +143 -0
- package/CONTRIBUTING.md +2 -1
- package/CONTRIBUTING.zh.md +2 -1
- package/README.md +1 -1
- package/docs/ARCHITECTURE.md +13 -2
- package/docs/ARCHITECTURE.zh.md +11 -2
- package/docs/CONFIGURATION.md +2 -1
- package/docs/CONFIGURATION.zh.md +2 -1
- package/docs/DIAGNOSTICS.md +20 -0
- package/docs/DIAGNOSTICS.zh.md +17 -0
- package/docs/LIMITATIONS.md +37 -12
- package/docs/LIMITATIONS.zh.md +30 -9
- package/docs/MIGRATION.md +4 -2
- package/docs/MIGRATION.zh.md +4 -2
- package/docs/QUICKSTART.md +2 -1
- package/docs/QUICKSTART.zh.md +2 -1
- package/docs/README.zh.md +1 -1
- package/docs/REQUIREMENTS.zh.md +1 -1
- package/docs/UPSTREAM-SERVICE-SWAP.md +35 -9
- package/docs/root-fs-routing.md +1 -1
- package/lib/fs-routing.d.ts +16 -1
- package/lib/fs-routing.js +18 -1
- package/lib/git-exec.d.ts +39 -7
- package/lib/git-exec.js +151 -18
- package/lib/listing.d.ts +17 -0
- package/lib/listing.js +20 -0
- package/lib/messages.d.ts +27 -0
- package/lib/messages.js +26 -2
- package/lib/picker.d.ts +52 -1
- package/lib/picker.js +63 -22
- package/lib/search-exec.d.ts +45 -9
- package/lib/search-exec.js +152 -20
- package/lib/service-takeover.d.ts +46 -0
- package/lib/service-takeover.js +65 -0
- package/lib/status.d.ts +7 -0
- package/lib/status.js +6 -3
- package/lib/subprocess.d.ts +112 -2
- package/lib/subprocess.js +36 -4
- package/lib/takeover-report.d.ts +80 -0
- package/lib/takeover-report.js +119 -0
- package/lib/wsl-doctor-command.d.ts +4 -1
- package/lib/wsl-doctor-command.js +7 -3
- package/lib/wsl-doctor-tool.js +6 -2
- package/lib/wsl.d.ts +35 -0
- package/lib/wsl.js +54 -1
- package/package.json +6 -4
- package/scripts/doctor.mjs +21 -13
|
@@ -7,10 +7,27 @@ seen on the desktop `0.2.2-rc.1` release (app-bundled
|
|
|
7
7
|
`@deepseek-ai/cordis-plugin-loader@1.1.0`; the npm line still ships
|
|
8
8
|
cordis `4.0.5` / loader `1.0.5`), reproduced in isolation against both
|
|
9
9
|
version pairs on 2026-11-05, and the mechanism is confirmed down to the
|
|
10
|
-
`_unload` diff. The
|
|
10
|
+
`_unload` diff. The installed desktop `0.2.2-rc.3` still bundles those same
|
|
11
|
+
cordis/loader versions, and the failure it reports on a plugin upgrade
|
|
12
|
+
(`0.24.0 → 0.26.2`, [#39](https://github.com/Big-Dao/dsh-plugin-wsl-env/issues/39))
|
|
13
|
+
carries the identical `service "subprocess" has been registered at
|
|
14
|
+
<LocalSubprocessRuntime>` diagnostic; the composed tree it rolled back from was
|
|
15
|
+
correct. The exact filing payload (title, body, command; drafted
|
|
11
16
|
2026-11-09) is
|
|
12
17
|
[proposal-service-swap.md](https://github.com/Big-Dao/dsh-plugin-wsl-env/blob/main/docs/upstream/proposal-service-swap.md).
|
|
13
18
|
|
|
19
|
+
The same class is already filed upstream for the update path:
|
|
20
|
+
[deepseek-ai/deepseek-harness#12510](https://github.com/deepseek-ai/deepseek-harness/discussions/12510)
|
|
21
|
+
(opened 2026-11-07, category Q&A, **open, no accepted answer** as of
|
|
22
|
+
2026-11-17) reports the `directoryPicker` collision from `updateBundle` with
|
|
23
|
+
HMR. Its thread identifies the remove-then-install window — during
|
|
24
|
+
`removeBundle` the bundle's `disabled: true` rows are gone, so the shipped
|
|
25
|
+
provider re-activates and collides with the incoming replacement — and records
|
|
26
|
+
a three-way result: an HMR update fails and rolls back; the same update with
|
|
27
|
+
the `hmr` row disabled succeeds and waits for a restart; a stopped-host
|
|
28
|
+
`dsh plugin add` succeeds. #12510 is the discussion to attach this plugin's
|
|
29
|
+
`subprocess`/`fs` cases to; the payload below remains unfiled.
|
|
30
|
+
|
|
14
31
|
## The gap
|
|
15
32
|
|
|
16
33
|
A plugin row that **replaces** a shipped row providing the same cordis
|
|
@@ -118,11 +135,20 @@ that would:
|
|
|
118
135
|
|
|
119
136
|
## The plugin's posture until then
|
|
120
137
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
The plugin no longer exposes the collision: its three takeover rows mount
|
|
139
|
+
through `src/service-takeover.ts`, which registers the provider immediately
|
|
140
|
+
when the name is free and otherwise stays ACTIVE, watches `internal/service`
|
|
141
|
+
for the slot, and registers when the outgoing provision releases. A live
|
|
142
|
+
enable or HMR upgrade therefore succeeds; the takeover lands as soon as the
|
|
143
|
+
shipped provider drains, or at the next restart when a dependent outlives the
|
|
144
|
+
recomposition. `test/hot-swap.test.mjs` pins the four states this relies on
|
|
145
|
+
(the rejected immediate registration, the takeover after release, the idle
|
|
146
|
+
swap, and the deferral), so a host change that alters the race fails in CI
|
|
147
|
+
rather than in a user's upgrade. The in-app doctor's `providers.takeover` row
|
|
148
|
+
names whichever provider still serves a name.
|
|
149
|
+
|
|
150
|
+
The upstream gap remains for every other bundle that performs a same-name
|
|
151
|
+
takeover, and for the ordering itself: a host that composed the disable to
|
|
152
|
+
completion before starting the replacement would remove the need for the
|
|
153
|
+
deferral entirely. [docs/LIMITATIONS.md](LIMITATIONS.md#enabling-the-plugin-on-a-running-profile)
|
|
154
|
+
keeps the operator-facing summary.
|
package/docs/root-fs-routing.md
CHANGED
|
@@ -165,7 +165,7 @@ export `./fs-routing`)。config 承载两侧旋钮:宿主侧 `cwd`/`diffBasi
|
|
|
165
165
|
服务代理覆盖。该文件自 2026-10-19 起已在 `test:unit` 与 `test:coverage`
|
|
166
166
|
清单里(`docs/REQUIREMENTS.zh.md` 的 OI-7,已解决)。
|
|
167
167
|
- 真机探针全套(`test/probe/run-all-when-closed.sh --include-fs`,16 项常规
|
|
168
|
-
+ `run.sh` 共
|
|
168
|
+
+ `run.sh` 共 18 项,2026-11-06 起;`auto-preset.sh` 2026-11-17 加入)覆盖 agent、watch、substrate 等底座,并包含本路由的
|
|
169
169
|
`test/probe/fs-routing.sh`:临时 profile 以本路由为根 `fs`,经 UNC 坐标读
|
|
170
170
|
distro 内 ext4 文件、经盘符路径读 Windows 文件,并拒绝另一 distro 的 UNC。
|
|
171
171
|
|
package/lib/fs-routing.d.ts
CHANGED
|
@@ -298,4 +298,19 @@ export declare class WslRoutingFileSystem extends LocalFileSystem {
|
|
|
298
298
|
*/
|
|
299
299
|
processPath(target: FsTarget): string;
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
/**
|
|
302
|
+
* The row the loader mounts: registers {@link WslRoutingFileSystem} under the
|
|
303
|
+
* `fs` name now, or after an outgoing provision releases (see
|
|
304
|
+
* {@link mountTakeover}). The `sandboxPolicy` inject rides on the row exactly
|
|
305
|
+
* as it did on the provider, so the fiber still waits for its sibling row.
|
|
306
|
+
*/
|
|
307
|
+
export default class WslRoutingRow {
|
|
308
|
+
static Config: z<RoutingConfig>;
|
|
309
|
+
static inject: string[];
|
|
310
|
+
/**
|
|
311
|
+
* @param ctx - the row's context; it owns the provider's provision.
|
|
312
|
+
* @param config - the schema-validated row config.
|
|
313
|
+
*/
|
|
314
|
+
constructor(ctx: Context, config: RoutingConfig);
|
|
315
|
+
}
|
|
316
|
+
export {};
|
package/lib/fs-routing.js
CHANGED
|
@@ -34,6 +34,7 @@ import { isWslUnc, uncToPosix } from "./paths.js";
|
|
|
34
34
|
import z from "@deepseek-ai/schemastery";
|
|
35
35
|
import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
|
|
36
36
|
import { WslFileSystem } from "./wsl-filesystem.js";
|
|
37
|
+
import { mountTakeover } from "./service-takeover.js";
|
|
37
38
|
/**
|
|
38
39
|
* Whether a resolved target identity belongs to the distro.
|
|
39
40
|
*
|
|
@@ -393,4 +394,20 @@ export class WslRoutingFileSystem extends LocalFileSystem {
|
|
|
393
394
|
return super.processPath(target);
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
|
-
|
|
397
|
+
/**
|
|
398
|
+
* The row the loader mounts: registers {@link WslRoutingFileSystem} under the
|
|
399
|
+
* `fs` name now, or after an outgoing provision releases (see
|
|
400
|
+
* {@link mountTakeover}). The `sandboxPolicy` inject rides on the row exactly
|
|
401
|
+
* as it did on the provider, so the fiber still waits for its sibling row.
|
|
402
|
+
*/
|
|
403
|
+
export default class WslRoutingRow {
|
|
404
|
+
static Config = WslRoutingFileSystem.Config;
|
|
405
|
+
static inject = WslRoutingFileSystem.inject;
|
|
406
|
+
/**
|
|
407
|
+
* @param ctx - the row's context; it owns the provider's provision.
|
|
408
|
+
* @param config - the schema-validated row config.
|
|
409
|
+
*/
|
|
410
|
+
constructor(ctx, config) {
|
|
411
|
+
mountTakeover(ctx, "fs", () => { new WslRoutingFileSystem(ctx, config); });
|
|
412
|
+
}
|
|
413
|
+
}
|
package/lib/git-exec.d.ts
CHANGED
|
@@ -25,14 +25,46 @@
|
|
|
25
25
|
* The agent being out is the fallback cue, exactly as `search-exec.ts`:
|
|
26
26
|
* `spawnFallback` (the caller's one-shot `wsl.exe` handle) is consulted
|
|
27
27
|
* lazily inside `done`, and from that point the facade proxies the delegate
|
|
28
|
-
* verbatim
|
|
29
|
-
* `kill()` abort the agent
|
|
28
|
+
* verbatim unless its relay named a broken program or directory. Cancellation
|
|
29
|
+
* shares one channel: the caller's `signal` and `kill()` abort the agent
|
|
30
|
+
* exec, settling `done` as killed.
|
|
31
|
+
*
|
|
32
|
+
* ## Failure surfacing: a broken distro must not look like "no changes"
|
|
33
|
+
*
|
|
34
|
+
* `GitRunner` reads git's own exit codes and stderr; a rejection from
|
|
35
|
+
* `handle.done` is an opaque snapshot failure the model cannot act on. The
|
|
36
|
+
* agent's two local failures therefore become git's own dialect instead:
|
|
37
|
+
*
|
|
38
|
+
* - A `SpawnError` means the agent could not start the program. The native
|
|
39
|
+
* agent reports both a missing executable and a missing working directory
|
|
40
|
+
* that way, without naming either — so the synthesized message names both
|
|
41
|
+
* and the install remedy, at exit 127 (a shell's command-not-found; never
|
|
42
|
+
* `1`, which several git subcommands use for a normal negative answer, nor
|
|
43
|
+
* `128`, which `GitRunner` reads as "not a repository").
|
|
44
|
+
* - A `CwdError` names the directory that could not be entered. It becomes
|
|
45
|
+
* git's fatal class — `fatal: cannot change to '<path>': No such file or
|
|
46
|
+
* directory` at exit 128 — which is exactly what `git -C <missing>` itself
|
|
47
|
+
* prints.
|
|
48
|
+
*
|
|
49
|
+
* Neither failure falls back to the one-shot path. A missing program would
|
|
50
|
+
* only produce the relay's `execvpe(git) failed` at exit `1`, and a missing
|
|
51
|
+
* directory is worse: `wsl.exe --cd` does not fail on it — it warns, runs in
|
|
52
|
+
* `/`, and exits 0 — where `git` then answers "not a git repository", which
|
|
53
|
+
* the snapshot reads as a clean, empty result. The one-shot delegate is
|
|
54
|
+
* post-processed for both relay markers, so the agent being out cannot turn a
|
|
55
|
+
* broken environment into a silent "no changes" either. Other failures still
|
|
56
|
+
* propagate through `done` as rejections.
|
|
57
|
+
*
|
|
58
|
+
* A discovery call's absolute-path answer is translated on BOTH transports:
|
|
59
|
+
* the one-shot delegate's stdout is taken over and passed through
|
|
60
|
+
* `translateDiscoveryOutput` exactly as the agent's result is, so change
|
|
61
|
+
* review sees the same UNC paths whether or not the resident is up.
|
|
30
62
|
*
|
|
31
63
|
* Pure shaping over injected collaborators, unit-testable without a distro.
|
|
32
64
|
*
|
|
33
65
|
* This is a TypeScript source built to `lib/git-exec.js`; edit THIS file and
|
|
34
|
-
* run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
35
|
-
*
|
|
66
|
+
* run `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
67
|
+
* fails when it drifts.
|
|
36
68
|
*
|
|
37
69
|
* @module dsh-plugin-wsl-env/git-exec
|
|
38
70
|
*/
|
|
@@ -86,10 +118,10 @@ export declare function gitExecutionHandle({ agent, cwd, argv, env, stdin, caps,
|
|
|
86
118
|
/** The distro-side argv (`git` and its arguments). */
|
|
87
119
|
argv: string[];
|
|
88
120
|
/**
|
|
89
|
-
* The distro name;
|
|
90
|
-
* become `\\wsl.localhost\<distro><path>`).
|
|
121
|
+
* The distro name; used by the discovery translation (absolute path lines
|
|
122
|
+
* become `\\wsl.localhost\<distro><path>`) and by every failure's remedy.
|
|
91
123
|
*/
|
|
92
|
-
distro
|
|
124
|
+
distro: string;
|
|
93
125
|
/**
|
|
94
126
|
* True for a SENTINEL discovery call (`--show-toplevel` /
|
|
95
127
|
* `--absolute-git-dir` / `--git-path` answered by the distro git): the
|
package/lib/git-exec.js
CHANGED
|
@@ -25,19 +25,71 @@
|
|
|
25
25
|
* The agent being out is the fallback cue, exactly as `search-exec.ts`:
|
|
26
26
|
* `spawnFallback` (the caller's one-shot `wsl.exe` handle) is consulted
|
|
27
27
|
* lazily inside `done`, and from that point the facade proxies the delegate
|
|
28
|
-
* verbatim
|
|
29
|
-
* `kill()` abort the agent
|
|
28
|
+
* verbatim unless its relay named a broken program or directory. Cancellation
|
|
29
|
+
* shares one channel: the caller's `signal` and `kill()` abort the agent
|
|
30
|
+
* exec, settling `done` as killed.
|
|
31
|
+
*
|
|
32
|
+
* ## Failure surfacing: a broken distro must not look like "no changes"
|
|
33
|
+
*
|
|
34
|
+
* `GitRunner` reads git's own exit codes and stderr; a rejection from
|
|
35
|
+
* `handle.done` is an opaque snapshot failure the model cannot act on. The
|
|
36
|
+
* agent's two local failures therefore become git's own dialect instead:
|
|
37
|
+
*
|
|
38
|
+
* - A `SpawnError` means the agent could not start the program. The native
|
|
39
|
+
* agent reports both a missing executable and a missing working directory
|
|
40
|
+
* that way, without naming either — so the synthesized message names both
|
|
41
|
+
* and the install remedy, at exit 127 (a shell's command-not-found; never
|
|
42
|
+
* `1`, which several git subcommands use for a normal negative answer, nor
|
|
43
|
+
* `128`, which `GitRunner` reads as "not a repository").
|
|
44
|
+
* - A `CwdError` names the directory that could not be entered. It becomes
|
|
45
|
+
* git's fatal class — `fatal: cannot change to '<path>': No such file or
|
|
46
|
+
* directory` at exit 128 — which is exactly what `git -C <missing>` itself
|
|
47
|
+
* prints.
|
|
48
|
+
*
|
|
49
|
+
* Neither failure falls back to the one-shot path. A missing program would
|
|
50
|
+
* only produce the relay's `execvpe(git) failed` at exit `1`, and a missing
|
|
51
|
+
* directory is worse: `wsl.exe --cd` does not fail on it — it warns, runs in
|
|
52
|
+
* `/`, and exits 0 — where `git` then answers "not a git repository", which
|
|
53
|
+
* the snapshot reads as a clean, empty result. The one-shot delegate is
|
|
54
|
+
* post-processed for both relay markers, so the agent being out cannot turn a
|
|
55
|
+
* broken environment into a silent "no changes" either. Other failures still
|
|
56
|
+
* propagate through `done` as rejections.
|
|
57
|
+
*
|
|
58
|
+
* A discovery call's absolute-path answer is translated on BOTH transports:
|
|
59
|
+
* the one-shot delegate's stdout is taken over and passed through
|
|
60
|
+
* `translateDiscoveryOutput` exactly as the agent's result is, so change
|
|
61
|
+
* review sees the same UNC paths whether or not the resident is up.
|
|
30
62
|
*
|
|
31
63
|
* Pure shaping over injected collaborators, unit-testable without a distro.
|
|
32
64
|
*
|
|
33
65
|
* This is a TypeScript source built to `lib/git-exec.js`; edit THIS file and
|
|
34
|
-
* run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
35
|
-
*
|
|
66
|
+
* run `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
67
|
+
* fails when it drifts.
|
|
36
68
|
*
|
|
37
69
|
* @module dsh-plugin-wsl-env/git-exec
|
|
38
70
|
*/
|
|
39
|
-
import { AgentUnavailableError } from "./agent-errors.js";
|
|
71
|
+
import { AgentUnavailableError, CwdError, SpawnError } from "./agent-errors.js";
|
|
72
|
+
import { t } from "./messages.js";
|
|
40
73
|
import { translateDiscoveryOutput } from "./git-route.js";
|
|
74
|
+
import { execProgramFailure, workdirFailure } from "./wsl.js";
|
|
75
|
+
/** The exit code a shell reports for a command it could not run. */
|
|
76
|
+
const COMMAND_NOT_FOUND_EXIT = 127;
|
|
77
|
+
/**
|
|
78
|
+
* git's fatal-error exit code. A directory that cannot be entered is what
|
|
79
|
+
* `git -C <missing>` itself reports this way, so the synthesized line speaks
|
|
80
|
+
* git's own dialect rather than inventing a code.
|
|
81
|
+
*/
|
|
82
|
+
const GIT_FATAL_EXIT = 128;
|
|
83
|
+
/**
|
|
84
|
+
* The stderr one snapshot settles with when its working directory is gone:
|
|
85
|
+
* git's own fatal line, then the directory's remedy.
|
|
86
|
+
*
|
|
87
|
+
* @param linuxPath - the directory the agent could not enter.
|
|
88
|
+
* @returns the stderr text.
|
|
89
|
+
*/
|
|
90
|
+
function workdirFailureText(linuxPath) {
|
|
91
|
+
return `fatal: cannot change to '${linuxPath}': No such file or directory\n${t("gitWorkdirMissing", { path: linuxPath })}`;
|
|
92
|
+
}
|
|
41
93
|
/**
|
|
42
94
|
* Run one git command through the agent and present it as a git-snapshot
|
|
43
95
|
* handle.
|
|
@@ -46,7 +98,7 @@ import { translateDiscoveryOutput } from "./git-route.js";
|
|
|
46
98
|
* @returns the snapshot handle (`done`, `collected`, `kill`).
|
|
47
99
|
*/
|
|
48
100
|
export function gitExecutionHandle({ agent, cwd, argv, env, stdin, caps, distro, discovery, signal, spawnFallback }) {
|
|
49
|
-
const state = { delegate: undefined, stdout: undefined, stderr: undefined };
|
|
101
|
+
const state = { delegate: undefined, stdout: undefined, stderr: undefined, lossy: { stdout: false, stderr: false } };
|
|
50
102
|
const controller = new AbortController();
|
|
51
103
|
if (signal?.aborted)
|
|
52
104
|
controller.abort(signal.reason);
|
|
@@ -61,13 +113,86 @@ export function gitExecutionHandle({ agent, cwd, argv, env, stdin, caps, distro,
|
|
|
61
113
|
return {
|
|
62
114
|
readFrom(from) {
|
|
63
115
|
const buffer = state[slot] ?? Buffer.alloc(0);
|
|
64
|
-
const lossy = buffer.length > cap;
|
|
116
|
+
const lossy = state.lossy[slot] || buffer.length > cap;
|
|
65
117
|
const visible = lossy ? buffer.subarray(0, cap) : buffer;
|
|
66
118
|
const start = Math.min(from, visible.length);
|
|
67
119
|
return { text: visible.subarray(start).toString("utf8"), lossy, nextOffset: visible.length };
|
|
68
120
|
},
|
|
69
121
|
};
|
|
70
122
|
};
|
|
123
|
+
/**
|
|
124
|
+
* Settle on a synthesized failure: drop any delegate so `collected` serves
|
|
125
|
+
* the buffers this facade owns.
|
|
126
|
+
*
|
|
127
|
+
* @param exitCode - git's dialect exit code for the failure.
|
|
128
|
+
* @param stderr - the model-facing diagnostic, remedy included.
|
|
129
|
+
* @returns the settled outcome.
|
|
130
|
+
*/
|
|
131
|
+
const settleFailure = (exitCode, stderr) => {
|
|
132
|
+
state.delegate = undefined;
|
|
133
|
+
state.stdout = Buffer.alloc(0);
|
|
134
|
+
state.stderr = Buffer.from(stderr, "utf8");
|
|
135
|
+
state.lossy = { stdout: false, stderr: false };
|
|
136
|
+
return { exitCode, signal: null };
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* The 127 result for a program the distro could not start.
|
|
140
|
+
*
|
|
141
|
+
* @param detail - the agent's or the relay's own spawn diagnostic.
|
|
142
|
+
* @returns the settled outcome.
|
|
143
|
+
*/
|
|
144
|
+
const settleProgramMissing = (detail) => settleFailure(COMMAND_NOT_FOUND_EXIT, t("gitProgramMissing", { distro, detail }));
|
|
145
|
+
/**
|
|
146
|
+
* The fatal result for a directory the distro could not enter.
|
|
147
|
+
*
|
|
148
|
+
* @param linuxPath - the directory that could not be entered.
|
|
149
|
+
* @returns the settled outcome.
|
|
150
|
+
*/
|
|
151
|
+
const settleWorkdirMissing = (linuxPath) => settleFailure(GIT_FATAL_EXIT, workdirFailureText(linuxPath));
|
|
152
|
+
/**
|
|
153
|
+
* Take the delegated discovery call's streams over so their stdout gets the
|
|
154
|
+
* SAME UNC translation the agent path applies. The one-shot transport runs
|
|
155
|
+
* the same distro git, so an untranslated answer would hand the caller
|
|
156
|
+
* Linux absolute paths that only resolve correctly on the agent transport —
|
|
157
|
+
* a transport-dependent change review. The delegate's per-stream cut flags
|
|
158
|
+
* are carried into this facade's readers rather than flattened.
|
|
159
|
+
*
|
|
160
|
+
* @param delegate - the settled one-shot handle.
|
|
161
|
+
*/
|
|
162
|
+
const takeOverDiscoveryOutput = (delegate) => {
|
|
163
|
+
const stdout = delegate.collected.stdout?.readFrom(0);
|
|
164
|
+
const stderr = delegate.collected.stderr?.readFrom(0);
|
|
165
|
+
state.delegate = undefined;
|
|
166
|
+
state.stdout = translateDiscoveryOutput(distro, Buffer.from(stdout?.text ?? "", "utf8"));
|
|
167
|
+
state.stderr = Buffer.from(stderr?.text ?? "", "utf8");
|
|
168
|
+
state.lossy = { stdout: stdout?.lossy === true, stderr: stderr?.lossy === true };
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Delegate one agent-unavailable request to the one-shot handle, translating
|
|
172
|
+
* the relay's missing-directory warning and missing-program line into the
|
|
173
|
+
* same explicit failures the agent path produces. Any other delegated
|
|
174
|
+
* outcome passes through verbatim (its collected streams stay the
|
|
175
|
+
* delegate's).
|
|
176
|
+
*
|
|
177
|
+
* @returns the settled outcome.
|
|
178
|
+
*/
|
|
179
|
+
const settleDelegate = async () => {
|
|
180
|
+
const delegate = spawnFallback();
|
|
181
|
+
state.delegate = delegate;
|
|
182
|
+
const outcome = await delegate.done;
|
|
183
|
+
if (outcome.exitCode === null)
|
|
184
|
+
return outcome;
|
|
185
|
+
const text = delegate.collected.stderr?.readFrom(0).text ?? "";
|
|
186
|
+
const missingDir = workdirFailure("", text);
|
|
187
|
+
if (missingDir !== undefined)
|
|
188
|
+
return settleWorkdirMissing(missingDir);
|
|
189
|
+
const relayFailure = execProgramFailure("", text);
|
|
190
|
+
if (relayFailure !== undefined)
|
|
191
|
+
return settleProgramMissing(relayFailure);
|
|
192
|
+
if (discovery)
|
|
193
|
+
takeOverDiscoveryOutput(delegate);
|
|
194
|
+
return outcome;
|
|
195
|
+
};
|
|
71
196
|
const handle = {
|
|
72
197
|
get collected() {
|
|
73
198
|
if (state.delegate !== undefined)
|
|
@@ -78,21 +203,29 @@ export function gitExecutionHandle({ agent, cwd, argv, env, stdin, caps, distro,
|
|
|
78
203
|
let result;
|
|
79
204
|
try {
|
|
80
205
|
result = await agent.exec({ cwd, argv, env, stdin, maxOutputBytes: wireCap, signal: controller.signal });
|
|
81
|
-
state.stdout = discovery ? translateDiscoveryOutput(distro
|
|
206
|
+
state.stdout = discovery ? translateDiscoveryOutput(distro, result.stdout) : result.stdout;
|
|
82
207
|
state.stderr = result.stderr;
|
|
83
208
|
}
|
|
84
209
|
catch (error) {
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
210
|
+
if (controller.signal.aborted) {
|
|
211
|
+
// Our kill() or the caller's cancellation: the killed outcome the
|
|
212
|
+
// one-shot path reports, not a failure.
|
|
213
|
+
return { exitCode: null, signal: "SIGTERM" };
|
|
214
|
+
}
|
|
215
|
+
if (error instanceof CwdError) {
|
|
216
|
+
// The directory is gone: git's own fatal dialect, so the snapshot
|
|
217
|
+
// reports the path instead of rejecting as a provider failure.
|
|
218
|
+
return settleWorkdirMissing(error.linuxPath);
|
|
92
219
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
220
|
+
if (error instanceof SpawnError) {
|
|
221
|
+
// The agent could not start the program. The native agent reports
|
|
222
|
+
// both a missing executable and a missing workdir this way, so the
|
|
223
|
+
// message names both and the remedy makes it actionable.
|
|
224
|
+
return settleProgramMissing(error.message);
|
|
225
|
+
}
|
|
226
|
+
if (!(error instanceof AgentUnavailableError))
|
|
227
|
+
throw error;
|
|
228
|
+
return await settleDelegate();
|
|
96
229
|
}
|
|
97
230
|
return { exitCode: result.exitCode, signal: null };
|
|
98
231
|
})(),
|
package/lib/listing.d.ts
CHANGED
|
@@ -111,6 +111,23 @@ export declare function boundedInsert<T extends {
|
|
|
111
111
|
* @returns the argv for the agent or a `wsl.exe --exec` launch.
|
|
112
112
|
*/
|
|
113
113
|
export declare function dirListingArgv(linuxDir: string): string[];
|
|
114
|
+
/**
|
|
115
|
+
* The distro-side argv one picker directory is created with.
|
|
116
|
+
*
|
|
117
|
+
* The target is named in ABSOLUTE form even though the agent path also sets a
|
|
118
|
+
* working directory: `wsl.exe --cd <missing>` does not fail — it warns, runs
|
|
119
|
+
* the command in `/` and exits 0 — so a relative `mkdir -- <name>` on the
|
|
120
|
+
* one-shot fallback would create `/name` while the picker reports the UNC
|
|
121
|
+
* target as created (when the distro user can write `/`, e.g. a root-default
|
|
122
|
+
* image). The absolute path makes the target independent of the directory the
|
|
123
|
+
* transport actually entered; the agent path keeps the same argv, and its
|
|
124
|
+
* `cwd` still supplies the existence check.
|
|
125
|
+
*
|
|
126
|
+
* @param linuxParent - the absolute Linux parent directory.
|
|
127
|
+
* @param name - the validated single path segment to create.
|
|
128
|
+
* @returns the argv for the agent or a `wsl.exe --exec` launch.
|
|
129
|
+
*/
|
|
130
|
+
export declare function distroMkdirArgv(linuxParent: string, name: string): string[];
|
|
114
131
|
/**
|
|
115
132
|
* Parse one `find -print0` listing into the picker's rows.
|
|
116
133
|
*
|
package/lib/listing.js
CHANGED
|
@@ -148,6 +148,26 @@ export function boundedInsert(window, candidate, keep) {
|
|
|
148
148
|
export function dirListingArgv(linuxDir) {
|
|
149
149
|
return ["find", "-L", linuxDir, "-maxdepth", "1", "-mindepth", "1", "-type", "d", "-print0"];
|
|
150
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* The distro-side argv one picker directory is created with.
|
|
153
|
+
*
|
|
154
|
+
* The target is named in ABSOLUTE form even though the agent path also sets a
|
|
155
|
+
* working directory: `wsl.exe --cd <missing>` does not fail — it warns, runs
|
|
156
|
+
* the command in `/` and exits 0 — so a relative `mkdir -- <name>` on the
|
|
157
|
+
* one-shot fallback would create `/name` while the picker reports the UNC
|
|
158
|
+
* target as created (when the distro user can write `/`, e.g. a root-default
|
|
159
|
+
* image). The absolute path makes the target independent of the directory the
|
|
160
|
+
* transport actually entered; the agent path keeps the same argv, and its
|
|
161
|
+
* `cwd` still supplies the existence check.
|
|
162
|
+
*
|
|
163
|
+
* @param linuxParent - the absolute Linux parent directory.
|
|
164
|
+
* @param name - the validated single path segment to create.
|
|
165
|
+
* @returns the argv for the agent or a `wsl.exe --exec` launch.
|
|
166
|
+
*/
|
|
167
|
+
export function distroMkdirArgv(linuxParent, name) {
|
|
168
|
+
const base = linuxParent.endsWith("/") ? linuxParent : `${linuxParent}/`;
|
|
169
|
+
return ["mkdir", "--", `${base}${name}`];
|
|
170
|
+
}
|
|
151
171
|
/**
|
|
152
172
|
* Parse one `find -print0` listing into the picker's rows.
|
|
153
173
|
*
|
package/lib/messages.d.ts
CHANGED
|
@@ -92,6 +92,33 @@ declare const en: {
|
|
|
92
92
|
workdir: string;
|
|
93
93
|
distro: string;
|
|
94
94
|
}) => string;
|
|
95
|
+
/**
|
|
96
|
+
* `search-exec`: the agent could not start the search program. The native
|
|
97
|
+
* agent cannot tell a missing executable from a missing directory, so both
|
|
98
|
+
* causes and the install remedy are named.
|
|
99
|
+
*/
|
|
100
|
+
searchProgramMissing: ({ program, distro, detail }: {
|
|
101
|
+
program: string;
|
|
102
|
+
distro: string;
|
|
103
|
+
detail: string;
|
|
104
|
+
}) => string;
|
|
105
|
+
/** `search-exec`: the working directory a search asked for does not exist. */
|
|
106
|
+
searchWorkdirMissing: ({ path }: {
|
|
107
|
+
path: string;
|
|
108
|
+
}) => string;
|
|
109
|
+
/**
|
|
110
|
+
* `git-exec`: the agent could not start git. The native agent cannot tell a
|
|
111
|
+
* missing executable from a missing directory, so both causes and the
|
|
112
|
+
* install remedy are named.
|
|
113
|
+
*/
|
|
114
|
+
gitProgramMissing: ({ distro, detail }: {
|
|
115
|
+
distro: string;
|
|
116
|
+
detail: string;
|
|
117
|
+
}) => string;
|
|
118
|
+
/** `git-exec`: the working directory a git snapshot asked for does not exist. */
|
|
119
|
+
gitWorkdirMissing: ({ path }: {
|
|
120
|
+
path: string;
|
|
121
|
+
}) => string;
|
|
95
122
|
/**
|
|
96
123
|
* `auto-preset`: a distro workspace is recorded as Windows access (9p), so
|
|
97
124
|
* the session runs the host preset. The model-facing half of the reminder;
|
package/lib/messages.js
CHANGED
|
@@ -69,6 +69,24 @@ const en = {
|
|
|
69
69
|
workdirAnotherDistro: ({ workdir, distro }) => `"${workdir}" names a workspace in another WSL distro, and this profile pins its commands to "${distro}" — ` +
|
|
70
70
|
`running them here would act on a different machine's tree. Open a session in that distro, ` +
|
|
71
71
|
`or point cwd/workdir at this distro.`,
|
|
72
|
+
/**
|
|
73
|
+
* `search-exec`: the agent could not start the search program. The native
|
|
74
|
+
* agent cannot tell a missing executable from a missing directory, so both
|
|
75
|
+
* causes and the install remedy are named.
|
|
76
|
+
*/
|
|
77
|
+
searchProgramMissing: ({ program, distro, detail }) => `${program} could not be started inside distro "${distro}" (${detail}). Commands run with wsl.exe's default PATH, so a user-local install under ~/.local/bin is invisible, and the search directory may also be gone. ` +
|
|
78
|
+
`Install ripgrep with "scripts/bootstrap.sh ${distro} --install" (from the package), or with the distro's own package manager.`,
|
|
79
|
+
/** `search-exec`: the working directory a search asked for does not exist. */
|
|
80
|
+
searchWorkdirMissing: ({ path }) => `The search directory "${path}" does not exist inside the distro. Create it, or point the session's working directory at a directory that exists.`,
|
|
81
|
+
/**
|
|
82
|
+
* `git-exec`: the agent could not start git. The native agent cannot tell a
|
|
83
|
+
* missing executable from a missing directory, so both causes and the
|
|
84
|
+
* install remedy are named.
|
|
85
|
+
*/
|
|
86
|
+
gitProgramMissing: ({ distro, detail }) => `git could not be started inside distro "${distro}" (${detail}). Commands run with wsl.exe's default PATH, so a user-local install under ~/.local/bin is invisible, and the snapshot directory may also be gone. ` +
|
|
87
|
+
`Install git with "scripts/bootstrap.sh ${distro} --install" (from the package), or with the distro's own package manager.`,
|
|
88
|
+
/** `git-exec`: the working directory a git snapshot asked for does not exist. */
|
|
89
|
+
gitWorkdirMissing: ({ path }) => `The git snapshot directory "${path}" does not exist inside the distro. Create it, or point the session's working directory at a directory that exists.`,
|
|
72
90
|
/**
|
|
73
91
|
* `auto-preset`: a distro workspace is recorded as Windows access (9p), so
|
|
74
92
|
* the session runs the host preset. The model-facing half of the reminder;
|
|
@@ -99,7 +117,7 @@ const en = {
|
|
|
99
117
|
/** `wsl_doctor` digest: one summary line for the checks the run's scope never executed; `reason` says why (the run's scope profile). */
|
|
100
118
|
doctorDigestSkipRow: ({ n, reason, ids }) => `[SKIP] not run in this scope — ${reason} (${n}): ${ids}`,
|
|
101
119
|
/** `wsl_doctor` digest: the scope reason for a quick run's skip line. */
|
|
102
|
-
doctorSkipReasonQuick: () => "the quick profile covers
|
|
120
|
+
doctorSkipReasonQuick: () => "the quick profile covers the prerequisites and the optional tools only",
|
|
103
121
|
/** `wsl_doctor` digest: the scope reason for a section-filtered run's skip line. */
|
|
104
122
|
doctorSkipReasonSections: ({ sections }) => `the run covered only: ${sections}`,
|
|
105
123
|
/** `wsl_doctor` digest: the scope reason when the report recorded none. */
|
|
@@ -146,6 +164,12 @@ const zh = {
|
|
|
146
164
|
`请创建该目录,或将 \`cwd\`(或请求的 \`workdir\`)指向一个已存在的目录。`,
|
|
147
165
|
workdirAnotherDistro: ({ workdir, distro }) => `"${workdir}" 指向另一个 WSL 发行版中的工作区,而本 profile 将命令固定在 "${distro}" —— ` +
|
|
148
166
|
`在这里运行会作用于另一台机器的目录树。请在该发行版中打开会话,或将 cwd/workdir 指向本发行版。`,
|
|
167
|
+
searchProgramMissing: ({ program, distro, detail }) => `无法在发行版 "${distro}" 内启动 ${program}(${detail})。命令使用 wsl.exe 给出的默认 PATH,因此安装在 ~/.local/bin 下的用户级版本不可见;搜索目录也可能已不存在。` +
|
|
168
|
+
`请用 "scripts/bootstrap.sh ${distro} --install"(随包提供)安装 ripgrep,或使用该发行版自己的包管理器。`,
|
|
169
|
+
searchWorkdirMissing: ({ path }) => `搜索目录 "${path}" 在发行版中不存在。请创建它,或将会话的工作目录指向一个已存在的目录。`,
|
|
170
|
+
gitProgramMissing: ({ distro, detail }) => `无法在发行版 "${distro}" 内启动 git(${detail})。命令使用 wsl.exe 给出的默认 PATH,因此安装在 ~/.local/bin 下的用户级版本不可见;快照目录也可能已不存在。` +
|
|
171
|
+
`请用 "scripts/bootstrap.sh ${distro} --install"(随包提供)安装 git,或使用该发行版自己的包管理器。`,
|
|
172
|
+
gitWorkdirMissing: ({ path }) => `git 快照目录 "${path}" 在发行版中不存在。请创建它,或将会话的工作目录指向一个已存在的目录。`,
|
|
149
173
|
hostModeWindowsAccess: ({ cwd, distro }) => `工作区 "${cwd}" 位于 WSL 发行版 "${distro}" 内,但被记录为 Windows 访问工作区,` +
|
|
150
174
|
`因此本会话运行在宿主(Windows)环境:命令经 PowerShell 执行,文件访问经过 9p 共享,发行版的 Linux 工具链不可用。` +
|
|
151
175
|
`不要在此假设 Linux 命令、路径或工具;如需在发行版内运行,须由操作者以 WSL preset 在本工作区新开会话。`,
|
|
@@ -160,7 +184,7 @@ const zh = {
|
|
|
160
184
|
doctorDigestNotRunLabel: () => "(不在本次范围)",
|
|
161
185
|
doctorDigestSessionLabel: ({ name }) => `${name}(当前会话的 distro)`,
|
|
162
186
|
doctorDigestSkipRow: ({ n, reason, ids }) => `[SKIP] 不在本次范围——${reason}(${n}):${ids}`,
|
|
163
|
-
doctorSkipReasonQuick: () => "quick
|
|
187
|
+
doctorSkipReasonQuick: () => "quick 档只探前置项与可选工具",
|
|
164
188
|
doctorSkipReasonSections: ({ sections }) => `本次只运行了这些分区:${sections}`,
|
|
165
189
|
doctorSkipReasonGeneric: () => "报告未记录运行范围",
|
|
166
190
|
doctorSkipGated: ({ id, reason }) => `[SKIP] ${id}——被前置阻断:${reason}`,
|
package/lib/picker.d.ts
CHANGED
|
@@ -284,4 +284,55 @@ export declare class WslDirectoryPicker extends DirectoryPicker {
|
|
|
284
284
|
*/
|
|
285
285
|
createDistroDirectory(parent: string, name: string, target: string): Promise<string>;
|
|
286
286
|
}
|
|
287
|
-
|
|
287
|
+
/**
|
|
288
|
+
* The row the loader mounts: registers {@link WslDirectoryPicker} under the
|
|
289
|
+
* `directoryPicker` name now, or after an outgoing provision releases (see
|
|
290
|
+
* {@link mountTakeover}).
|
|
291
|
+
*/
|
|
292
|
+
export default class WslDirectoryPickerRow {
|
|
293
|
+
static Config: z<Schemastery.ObjectS<NoInfer<{
|
|
294
|
+
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
295
|
+
wslPath: z<string, string, "defined">;
|
|
296
|
+
/**
|
|
297
|
+
* Distro listed first and used for the Home affordance. Empty means WSL's
|
|
298
|
+
* own default distro.
|
|
299
|
+
*/
|
|
300
|
+
preferredDistro: z<string, string, "defined">;
|
|
301
|
+
/**
|
|
302
|
+
* Offer the Windows path branch, starting at the drive roots, so every
|
|
303
|
+
* volume and account stays reachable without typing a path. Without it the
|
|
304
|
+
* category level carries the WSL branch alone; the dialog's editable path
|
|
305
|
+
* zone accepts any Windows path either way.
|
|
306
|
+
*/
|
|
307
|
+
includeHostHome: z<boolean, boolean, "defined">;
|
|
308
|
+
/** Bound on the directory rows one `list` call may return; the level is flagged truncated. */
|
|
309
|
+
maxEntries: z<number, number, "defined">;
|
|
310
|
+
/** How long a resolved distro list stays fresh. */
|
|
311
|
+
distroCacheMs: z<number, number, "defined">;
|
|
312
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
313
|
+
/** Path to `wsl.exe`; overridable for a non-standard install. */
|
|
314
|
+
wslPath: z<string, string, "defined">;
|
|
315
|
+
/**
|
|
316
|
+
* Distro listed first and used for the Home affordance. Empty means WSL's
|
|
317
|
+
* own default distro.
|
|
318
|
+
*/
|
|
319
|
+
preferredDistro: z<string, string, "defined">;
|
|
320
|
+
/**
|
|
321
|
+
* Offer the Windows path branch, starting at the drive roots, so every
|
|
322
|
+
* volume and account stays reachable without typing a path. Without it the
|
|
323
|
+
* category level carries the WSL branch alone; the dialog's editable path
|
|
324
|
+
* zone accepts any Windows path either way.
|
|
325
|
+
*/
|
|
326
|
+
includeHostHome: z<boolean, boolean, "defined">;
|
|
327
|
+
/** Bound on the directory rows one `list` call may return; the level is flagged truncated. */
|
|
328
|
+
maxEntries: z<number, number, "defined">;
|
|
329
|
+
/** How long a resolved distro list stays fresh. */
|
|
330
|
+
distroCacheMs: z<number, number, "defined">;
|
|
331
|
+
}>>, "plain">;
|
|
332
|
+
/**
|
|
333
|
+
* @param ctx - the row's context; it owns the provider's provision.
|
|
334
|
+
* @param config - the schema-validated row config.
|
|
335
|
+
*/
|
|
336
|
+
constructor(ctx: Context, config: PickerConfig);
|
|
337
|
+
}
|
|
338
|
+
export {};
|