dsh-plugin-wsl-env 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/README.md +2 -2
  3. package/client.d.ts +5 -0
  4. package/client.js +98 -0
  5. package/cordis.patch.yml +66 -1
  6. package/docs/API.md +1 -0
  7. package/docs/CONFIGURATION.md +39 -5
  8. package/docs/CONFIGURATION.zh.md +15 -1
  9. package/docs/DIAGNOSTICS.md +83 -0
  10. package/docs/DIAGNOSTICS.zh.md +73 -0
  11. package/docs/LIMITATIONS.md +25 -0
  12. package/docs/LIMITATIONS.zh.md +7 -0
  13. package/docs/MIGRATION.md +1 -1
  14. package/docs/QUICKSTART.md +19 -3
  15. package/docs/RELEASING.md +3 -0
  16. package/docs/ROADMAP-1.0.md +49 -4
  17. package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +5 -0
  18. package/docs/UPSTREAM-OPEN-IN-APP.md +33 -0
  19. package/lib/client-host.d.ts +29 -0
  20. package/lib/client-host.js +29 -0
  21. package/lib/cwd-prompt-tool.d.ts +88 -0
  22. package/lib/cwd-prompt-tool.js +94 -0
  23. package/lib/cwd-prompt.d.ts +166 -0
  24. package/lib/cwd-prompt.js +203 -0
  25. package/lib/doctor-live.d.ts +5 -1
  26. package/lib/doctor-live.js +3 -2
  27. package/lib/index.js +6 -8
  28. package/lib/messages.d.ts +157 -0
  29. package/lib/messages.js +199 -0
  30. package/lib/preflight.d.ts +24 -0
  31. package/lib/preflight.js +111 -11
  32. package/lib/sandbox-core.js +7 -14
  33. package/lib/session-scope.js +10 -5
  34. package/lib/shell-env.d.ts +25 -0
  35. package/lib/shell-env.js +56 -0
  36. package/lib/shell.d.ts +3 -1
  37. package/lib/shell.js +3 -1
  38. package/lib/update-check.d.ts +197 -0
  39. package/lib/update-check.js +211 -0
  40. package/lib/wsl-doctor-tool.d.ts +122 -0
  41. package/lib/wsl-doctor-tool.js +161 -0
  42. package/package.json +43 -5
  43. package/scripts/doctor.mjs +1167 -160
@@ -0,0 +1,211 @@
1
+ /**
2
+ * The plugin's update check: notice when a newer release exists, stop there.
3
+ *
4
+ * Upgrading today means re-installing by hand (Plugins page, or
5
+ * `dsh plugin add`) and the harness's own plugin-manager already answers
6
+ * "which versions exist and do they fit this DSH" — `listVersions` resolves
7
+ * dist-tags, deprecation, and the `engines.dsh`/peer compatibility of every
8
+ * candidate against the running DSH. This service makes that answer arrive
9
+ * without the user opening the Versions page first: on a slow timer it asks
10
+ * the host's `pluginManager` for this package's version list and, when the
11
+ * stable channel has moved, publishes one fact. Applying the update stays a
12
+ * user action — a plugin that silently replaces its own code under a running
13
+ * harness is a posture this plugin rejects, and the harness has no HMR, so
14
+ * even a correct swap needs a restart to take effect.
15
+ *
16
+ * Delegation is the whole network story: the check spawns nothing and fetches
17
+ * nothing itself. `pluginManager` is read with `ctx.get`, the sanctioned read
18
+ * for a service this row does not inject — a host without it (or a bundle
19
+ * loaded from a linked checkout, which `listVersions` refuses as
20
+ * `not-updatable` because the mirror is managed by `pnpm run sync:windows`)
21
+ * simply means no check ran, at debug level, never a warning.
22
+ *
23
+ * This is a TypeScript source built to `lib/update-check.js`; edit THIS file
24
+ * and run `pnpm run build` — the artifact under `lib/` is generated, and
25
+ * `pnpm test` fails when it drifts.
26
+ *
27
+ * @module dsh-plugin-wsl-env/update-check
28
+ */
29
+ import z from "@deepseek-ai/schemastery";
30
+ export const name = "wsl-update-check";
31
+ /** The checked package: this plugin, by its npm name. */
32
+ const PACKAGE = "dsh-plugin-wsl-env";
33
+ /** The interval the row ships with. */
34
+ export const DEFAULT_INTERVAL_MS = 24 * 60 * 60 * 1000;
35
+ /** The smallest interval a config may ask for; one check spawns `pnpm view` in the profile. */
36
+ export const MIN_INTERVAL_MS = 60 * 1000;
37
+ export const Config = z.object({
38
+ /** Whether the update check runs at all. */
39
+ enabled: z.boolean().default(true),
40
+ /** How often the registry is asked, in milliseconds; floored at one minute. */
41
+ intervalMs: z.number().default(DEFAULT_INTERVAL_MS),
42
+ });
43
+ /**
44
+ * The module-level fact store. `shellEnv`'s resolver is synchronous by
45
+ * contract, so the timer-fed fact must live somewhere a plain import can read
46
+ * without await — the same posture as the ports snapshot, and the same
47
+ * module-singleton pattern as the shared agent (`lib/agent-shared.js`).
48
+ */
49
+ let fact;
50
+ /**
51
+ * The newest update fact this process has published, or undefined when no
52
+ * check ran, the registry said "up to date", or the last check learned
53
+ * nothing actionable.
54
+ *
55
+ * @returns the fact, for `shellEnv`'s synchronous resolver.
56
+ */
57
+ export function currentUpdateFact() {
58
+ return fact;
59
+ }
60
+ /**
61
+ * Publish (or clear) the update fact. Exported for the tests, which must be
62
+ * able to stage a fact without a host plugin-manager — the same "tests-only"
63
+ * carve-out as `clearNativeBackendCache`.
64
+ *
65
+ * @param next - the fact to publish, or undefined to clear.
66
+ */
67
+ export function setUpdateFact(next) {
68
+ fact = next;
69
+ }
70
+ /**
71
+ * The interval a config asks for, floored at {@link MIN_INTERVAL_MS}. A check
72
+ * spawns `pnpm view` in the profile, so a tight loop would hammer the
73
+ * registry; the floor makes even `0` safe.
74
+ *
75
+ * @param ms - the configured interval, or undefined for the default.
76
+ * @returns the interval the scheduler uses.
77
+ */
78
+ export function clampInterval(ms) {
79
+ return Math.max(ms ?? DEFAULT_INTERVAL_MS, MIN_INTERVAL_MS);
80
+ }
81
+ /**
82
+ * How long after mount the first check waits: two to ten minutes, jittered.
83
+ * The delay keeps the check off the startup path (a cold start must not wait
84
+ * on a registry round-trip) and off the startup stampede of `pnpm` work the
85
+ * profile is already doing.
86
+ *
87
+ * @param random - the randomness source, injectable for tests.
88
+ * @returns the delay in milliseconds.
89
+ */
90
+ export function firstDelayMs(random = Math.random) {
91
+ return 120_000 + random() * 480_000;
92
+ }
93
+ /**
94
+ * Pick the version the fact should name: the stable channel's newest release
95
+ * (`latest` tag) that is still a bundle. Prereleases ship on `next` by the
96
+ * release discipline and never move `latest`, so they are not news; a version
97
+ * that lost the bundle manifest could not be installed as an update. The list
98
+ * is newest-first, so the first match is the newest.
99
+ *
100
+ * @param list - the version list `listVersions` answered with.
101
+ * @returns the target version, or undefined when the stable channel has not moved.
102
+ */
103
+ export function updateTarget(list) {
104
+ return list.versions.find((version) => version.bundle && version.tags.includes("latest"));
105
+ }
106
+ /**
107
+ * Run one check against the host's plugin-manager and publish the fact.
108
+ *
109
+ * Every non-answer is quiet by design: a missing manager, a linked checkout
110
+ * (`not-updatable`), a registry the host cannot reach (`network`), or a stable
111
+ * channel that has not moved all leave the previous fact (or none) standing —
112
+ * an update check must never become the noisiest thing in the app.
113
+ *
114
+ * @param manager - the host plugin-manager, or undefined when the host has none.
115
+ * @returns the published fact, or undefined when the check learned nothing.
116
+ */
117
+ export async function checkForUpdate(manager) {
118
+ if (manager === undefined)
119
+ return undefined;
120
+ let list;
121
+ try {
122
+ list = await manager.listVersions(PACKAGE);
123
+ }
124
+ catch {
125
+ // `listVersions` resolves refusals into its result; a throw means the
126
+ // service itself is broken. The next tick retries; nothing is published.
127
+ return undefined;
128
+ }
129
+ if (list.status !== "listed")
130
+ return undefined;
131
+ const target = updateTarget(list);
132
+ if (target === undefined) {
133
+ setUpdateFact(undefined);
134
+ return undefined;
135
+ }
136
+ const next = {
137
+ installed: list.installed,
138
+ latest: target.version,
139
+ ...(target.publishedAt === undefined ? {} : { publishedAt: target.publishedAt }),
140
+ incompatible: target.incompatible !== undefined,
141
+ ...(target.deprecated === undefined ? {} : { deprecated: target.deprecated }),
142
+ checkedAt: Date.now(),
143
+ };
144
+ setUpdateFact(next);
145
+ return next;
146
+ }
147
+ /**
148
+ * The fact as one line, for the managed `DSH_*` variable and the log. The
149
+ * wording is the same the doctor's section reuses, so "available" never
150
+ * drifts between the two surfaces.
151
+ *
152
+ * @param update - the fact, or undefined.
153
+ * @returns the message, or an empty string when there is nothing to say.
154
+ */
155
+ export function updateFactMessage(update) {
156
+ if (update === undefined)
157
+ return "";
158
+ const marks = [];
159
+ if (update.incompatible)
160
+ marks.push("requires a newer DSH first");
161
+ if (update.deprecated !== undefined)
162
+ marks.push(`deprecated: ${update.deprecated}`);
163
+ const tail = marks.length === 0 ? "" : ` — ${marks.join("; ")}`;
164
+ return `${update.latest} available (installed ${update.installed})${tail}`;
165
+ }
166
+ /**
167
+ * Mount the update check.
168
+ *
169
+ * @param ctx - the cordis context.
170
+ * @param config - the schema-validated plugin config.
171
+ */
172
+ export async function apply(ctx, config = {}) {
173
+ if (!(config.enabled ?? true))
174
+ return;
175
+ const intervalMs = clampInterval(config.intervalMs);
176
+ const debug = (message) => ctx.logger?.debug?.(message);
177
+ const tick = async () => {
178
+ try {
179
+ // The read is the cordis-sanctioned one for a service this row does not
180
+ // inject: `ctx.get` answers undefined when the host has no
181
+ // plugin-manager (a headless harness, a bare composition), where a
182
+ // property read would throw and mark the whole component failed.
183
+ const manager = ctx.get("pluginManager");
184
+ if (manager === undefined) {
185
+ debug("wsl-update-check: the host has no plugin-manager; the check is skipped");
186
+ return;
187
+ }
188
+ const published = await checkForUpdate(manager);
189
+ if (published === undefined) {
190
+ debug("wsl-update-check: no newer stable release (or the registry was unreachable)");
191
+ return;
192
+ }
193
+ debug(`wsl-update-check: ${updateFactMessage(published)}`);
194
+ }
195
+ catch (error) {
196
+ // A check that cannot run is a next tick's business, never a session's
197
+ // error: the timer swallows everything at debug level.
198
+ debug(`wsl-update-check: the check failed (${error?.message ?? error})`);
199
+ }
200
+ };
201
+ const first = setTimeout(() => void tick(), firstDelayMs());
202
+ const repeat = setInterval(() => void tick(), intervalMs);
203
+ first.unref?.();
204
+ repeat.unref?.();
205
+ // Disposing matters: a config hot-reload re-runs apply(), and two live
206
+ // timers would double the registry traffic.
207
+ ctx.effect(() => () => {
208
+ clearTimeout(first);
209
+ clearInterval(repeat);
210
+ });
211
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * The `wsl_doctor` tool: the model runs the environment doctor itself, and
3
+ * the verdict lands in the transcript — the GUI entry that belongs entirely
4
+ * to the plugin.
5
+ *
6
+ * The doctor is this package's own diagnostic (WSL-316); exposing it as a
7
+ * tool keeps the loop cohesive: no upstream surface is required, no file is
8
+ * written into the user's workspace, and the model gets a structured digest
9
+ * (verdict, blockers, per-failure copy-paste remedies) it can narrate or
10
+ * act on. The heavy lifting is {@link doctorReport} — the sanctioned
11
+ * in-process collector that spawns the shipped CLI once with the app's own
12
+ * runtime and folds the live resident's state in; the tool adds only the
13
+ * distro resolution and the digest.
14
+ *
15
+ * The distro comes from the caller when given, else from the agent's own
16
+ * session cwd through the harness's `workingDirectory` service — the same
17
+ * resolution the preflight performs, and the reason this row mounts inside
18
+ * the `preset-wsl` block: a host-preset agent has no distro to examine.
19
+ *
20
+ * This is a TypeScript source built to `lib/wsl-doctor-tool.js`; edit THIS
21
+ * file and run `pnpm run build` — the artifact under `lib/` is generated,
22
+ * and `pnpm test` fails when it drifts.
23
+ *
24
+ * @module dsh-plugin-wsl-env/wsl-doctor-tool
25
+ */
26
+ export declare const name = "wsl-doctor-tool";
27
+ /**
28
+ * The context properties `apply` reads eagerly: the tool registry and the
29
+ * harness's `workingDirectory` service (the session's distro resolution).
30
+ * Cordis 4 refuses an undeclared read, so both must be named here. The doctor
31
+ * collector is deliberately NOT injected: no host row provides a `doctor`
32
+ * service, and a required inject would fail the whole preset mount; it is
33
+ * resolved per call through the optional `ctx.get` (which needs no inject)
34
+ * with the package's own `doctorReport` as the fallback — `doctorCollector`
35
+ * below.
36
+ */
37
+ export declare const inject: string[];
38
+ /** The tool registry slice this service consumes. */
39
+ export interface ToolRegistrySlice {
40
+ register: (tool: unknown) => unknown;
41
+ }
42
+ /** The harness's `workingDirectory` service slice (cwd resolution). */
43
+ export interface WorkingDirectoryToolSlice {
44
+ ensure: (agent: unknown, signal?: unknown) => Promise<string>;
45
+ }
46
+ /** The doctor report this tool digests — the doctor CLI's versioned shape. */
47
+ export interface DoctorReportLike {
48
+ verdict?: string;
49
+ blockers?: string[];
50
+ distroVerdicts?: Array<{
51
+ name: string;
52
+ verdict: string;
53
+ blockers: string[];
54
+ }>;
55
+ checks?: Array<{
56
+ id: string;
57
+ status: string;
58
+ title?: string;
59
+ detail?: string;
60
+ remedy?: string;
61
+ distro?: string;
62
+ }>;
63
+ summary?: Record<string, number>;
64
+ }
65
+ /** The cordis context slice this service consumes. */
66
+ export type WslDoctorToolContext = {
67
+ tools: ToolRegistrySlice;
68
+ workingDirectory: WorkingDirectoryToolSlice;
69
+ /** Optional cordis-style lookup: how production resolves `doctor` without an inject. */
70
+ get?: (name: string) => unknown;
71
+ /** The in-process collector: a provided `doctor` service, or the test seam's fake. */
72
+ doctor?: (distro: string) => Promise<DoctorReportLike>;
73
+ };
74
+ /** The tool's config: the row takes no options. */
75
+ export interface WslDoctorToolConfig {
76
+ /** Reserved; the wrapper has no options today. */
77
+ enabled?: boolean;
78
+ }
79
+ /** One failing check as the digest carries it: what failed and what to do. */
80
+ export interface FailingCheck {
81
+ id: string;
82
+ detail: string;
83
+ remedy: string;
84
+ }
85
+ /** The tool's result: the doctor's verdict, condensed for the model. */
86
+ export interface DoctorDigest {
87
+ verdict: string;
88
+ blockers: string[];
89
+ failing: FailingCheck[];
90
+ warningCount: number;
91
+ skippedCount: number;
92
+ distroVerdicts: Array<{
93
+ name: string;
94
+ verdict: string;
95
+ blockers: string[];
96
+ }>;
97
+ note: string;
98
+ }
99
+ /**
100
+ * Digest one doctor report down to what the model acts on: the verdict, the
101
+ * blockers, and every failing check with its copy-paste remedy. Warnings and
102
+ * skipped legs count but do not list — the report's own ids name them when
103
+ * the model asks.
104
+ * @param report - the collected (and live-merged) doctor report.
105
+ * @returns the digest.
106
+ */
107
+ export declare function digestReport(report: DoctorReportLike): DoctorDigest;
108
+ /**
109
+ * Render the digest as the tool's text output: one verdict line, one line
110
+ * per failing check with its remedy. The model narrates this; keeping it
111
+ * plain text keeps the transcript readable.
112
+ * @param digest - the digested report.
113
+ * @returns the multi-line text.
114
+ */
115
+ export declare function renderDigest(digest: DoctorDigest): string;
116
+ /**
117
+ * Mount the tool.
118
+ *
119
+ * @param ctx - the cordis context (the preset realm, where the tools
120
+ * registry and the workingDirectory service are reachable).
121
+ */
122
+ export declare function apply(ctx: WslDoctorToolContext): Promise<void>;
@@ -0,0 +1,161 @@
1
+ /**
2
+ * The `wsl_doctor` tool: the model runs the environment doctor itself, and
3
+ * the verdict lands in the transcript — the GUI entry that belongs entirely
4
+ * to the plugin.
5
+ *
6
+ * The doctor is this package's own diagnostic (WSL-316); exposing it as a
7
+ * tool keeps the loop cohesive: no upstream surface is required, no file is
8
+ * written into the user's workspace, and the model gets a structured digest
9
+ * (verdict, blockers, per-failure copy-paste remedies) it can narrate or
10
+ * act on. The heavy lifting is {@link doctorReport} — the sanctioned
11
+ * in-process collector that spawns the shipped CLI once with the app's own
12
+ * runtime and folds the live resident's state in; the tool adds only the
13
+ * distro resolution and the digest.
14
+ *
15
+ * The distro comes from the caller when given, else from the agent's own
16
+ * session cwd through the harness's `workingDirectory` service — the same
17
+ * resolution the preflight performs, and the reason this row mounts inside
18
+ * the `preset-wsl` block: a host-preset agent has no distro to examine.
19
+ *
20
+ * This is a TypeScript source built to `lib/wsl-doctor-tool.js`; edit THIS
21
+ * file and run `pnpm run build` — the artifact under `lib/` is generated,
22
+ * and `pnpm test` fails when it drifts.
23
+ *
24
+ * @module dsh-plugin-wsl-env/wsl-doctor-tool
25
+ */
26
+ import { defineTool } from "@deepseek-ai/dsh-tools";
27
+ import { distroOfUnc } from "./distro-route.js";
28
+ import { doctorReport } from "./index.js";
29
+ export const name = "wsl-doctor-tool";
30
+ /**
31
+ * The context properties `apply` reads eagerly: the tool registry and the
32
+ * harness's `workingDirectory` service (the session's distro resolution).
33
+ * Cordis 4 refuses an undeclared read, so both must be named here. The doctor
34
+ * collector is deliberately NOT injected: no host row provides a `doctor`
35
+ * service, and a required inject would fail the whole preset mount; it is
36
+ * resolved per call through the optional `ctx.get` (which needs no inject)
37
+ * with the package's own `doctorReport` as the fallback — `doctorCollector`
38
+ * below.
39
+ */
40
+ export const inject = ["tools", "workingDirectory"];
41
+ /**
42
+ * Digest one doctor report down to what the model acts on: the verdict, the
43
+ * blockers, and every failing check with its copy-paste remedy. Warnings and
44
+ * skipped legs count but do not list — the report's own ids name them when
45
+ * the model asks.
46
+ * @param report - the collected (and live-merged) doctor report.
47
+ * @returns the digest.
48
+ */
49
+ export function digestReport(report) {
50
+ const checks = report.checks ?? [];
51
+ const failing = checks
52
+ .filter((check) => check.status === "fail")
53
+ .map((check) => ({
54
+ id: check.id,
55
+ detail: check.detail ?? "",
56
+ remedy: check.remedy === undefined || check.remedy.length === 0 ? "no remedy — see docs/DIAGNOSTICS.md" : check.remedy,
57
+ }));
58
+ const blockers = report.blockers ?? failing.map((check) => check.id);
59
+ const verdict = report.verdict ?? (blockers.length === 0 ? "ready" : "blocked");
60
+ const warningCount = report.summary?.warn ?? checks.filter((check) => check.status === "warn").length;
61
+ const skippedCount = report.summary?.skipped ?? checks.filter((check) => check.status === "skipped").length;
62
+ return {
63
+ verdict,
64
+ blockers,
65
+ failing,
66
+ warningCount,
67
+ skippedCount,
68
+ distroVerdicts: report.distroVerdicts ?? [],
69
+ note: verdict === "ready"
70
+ ? "the first command should succeed; run the CLI (pnpm run doctor --bundle <path>) for the attachable file"
71
+ : "apply each remedy above, then call this tool again — the re-run is the re-verification",
72
+ };
73
+ }
74
+ /**
75
+ * Render the digest as the tool's text output: one verdict line, one line
76
+ * per failing check with its remedy. The model narrates this; keeping it
77
+ * plain text keeps the transcript readable.
78
+ * @param digest - the digested report.
79
+ * @returns the multi-line text.
80
+ */
81
+ export function renderDigest(digest) {
82
+ const lines = [`wsl doctor verdict: ${digest.verdict.toUpperCase()}`];
83
+ for (const check of digest.failing) {
84
+ lines.push(`fail ${check.id} — ${check.detail}`);
85
+ if (check.remedy.length > 0)
86
+ lines.push(` fix: ${check.remedy}`);
87
+ }
88
+ if (digest.failing.length === 0) {
89
+ lines.push(digest.note);
90
+ }
91
+ else {
92
+ lines.push(`${digest.warningCount} warning(s), ${digest.skippedCount} skipped leg(s) — none blocking; ${digest.note}`);
93
+ }
94
+ return lines.join("\n");
95
+ }
96
+ /**
97
+ * The doctor collector this run uses. No host row provides a `doctor`
98
+ * service, so a required inject would fail the whole preset mount; the
99
+ * collector resolves per call instead: a provided `doctor` service through
100
+ * the optional `ctx.get` (cordis answers undefined for an absent name, and a
101
+ * `get` needs no inject), else the plain `doctor` property (the test seam),
102
+ * else the package's own `doctorReport` — the sanctioned in-process
103
+ * collector, imported from the composition root.
104
+ *
105
+ * @param ctx - the cordis context the row mounted in.
106
+ * @returns the collector: distro in, versioned doctor report out.
107
+ */
108
+ async function doctorCollector(ctx) {
109
+ if (typeof ctx.get === "function") {
110
+ const provided = ctx.get("doctor");
111
+ if (typeof provided === "function")
112
+ return provided; // the provided service's contract is this module's `doctor` slice
113
+ }
114
+ else if (typeof ctx.doctor === "function") {
115
+ return ctx.doctor;
116
+ }
117
+ return doctorReport;
118
+ }
119
+ /**
120
+ * Mount the tool.
121
+ *
122
+ * @param ctx - the cordis context (the preset realm, where the tools
123
+ * registry and the workingDirectory service are reachable).
124
+ */
125
+ export async function apply(ctx) {
126
+ ctx.tools.register(defineTool({
127
+ name: "wsl_doctor",
128
+ description: "Run the WSL environment doctor for this session's distro and return the verdict: ready (the first command should succeed), or blocked with per-failure copy-paste remedies. Slow by design (~10 s): it probes wsl.exe, the sandbox, systemd and the agent chain, then re-verifies nothing silently.",
129
+ parameters: { distro: {
130
+ type: "string",
131
+ description: "Distro to examine. Omit to examine this session's own distro.",
132
+ } },
133
+ output: {
134
+ schema: {
135
+ type: "object",
136
+ additionalProperties: false,
137
+ properties: {
138
+ verdict: { type: "string", required: true, description: "ready or blocked." },
139
+ blockers: { type: "string", required: true, description: "Comma-separated blocking check ids; empty when ready." },
140
+ failing: { type: "string", required: true, description: "One line per failing check: id, detail, remedy." },
141
+ },
142
+ },
143
+ render: (_args, value) => [{ type: "text", text: value.failing }],
144
+ },
145
+ async execute(args, exec) {
146
+ let distro = args.distro ?? "";
147
+ if (distro.length === 0) {
148
+ if (exec.agent === undefined)
149
+ throw new Error("wsl_doctor requires an agent Session (or an explicit distro)");
150
+ const cwd = await ctx.workingDirectory.ensure(exec.agent, exec.signal);
151
+ distro = distroOfUnc(cwd) ?? "";
152
+ }
153
+ if (distro.length === 0) {
154
+ throw new Error("wsl_doctor could not resolve the session's distro from its working directory — pass one explicitly");
155
+ }
156
+ const doctor = await doctorCollector(ctx);
157
+ const digest = digestReport(await doctor(distro));
158
+ return { verdict: digest.verdict, blockers: digest.blockers.join(", "), failing: renderDigest(digest) };
159
+ }
160
+ }));
161
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-wsl-env",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "在 WSL 的 Linux 实例中打开项目工作区,在对应 Linux 空间中进行命令执行、运行 shell 脚本和文件访问,以获得全套 Linux Shell 工具链收益,并通过 bubblewrap 对命令进行沙箱隔离",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -11,10 +11,14 @@
11
11
  "windows"
12
12
  ],
13
13
  "type": "module",
14
- "types": "./lib/shell.d.ts",
15
- "main": "lib/shell.js",
14
+ "types": "./lib/client-host.d.ts",
15
+ "main": "lib/client-host.js",
16
16
  "exports": {
17
17
  ".": {
18
+ "types": "./lib/client-host.d.ts",
19
+ "default": "./lib/client-host.js"
20
+ },
21
+ "./shell": {
18
22
  "types": "./lib/shell.d.ts",
19
23
  "default": "./lib/shell.js"
20
24
  },
@@ -28,6 +32,22 @@
28
32
  },
29
33
  "./auto-preset/locale/en.json": "./locale/auto-preset/en.json",
30
34
  "./auto-preset/locale/zh.json": "./locale/auto-preset/zh.json",
35
+ "./cwd-prompt": {
36
+ "types": "./lib/cwd-prompt.d.ts",
37
+ "default": "./lib/cwd-prompt.js"
38
+ },
39
+ "./cwd-prompt-tool": {
40
+ "types": "./lib/cwd-prompt-tool.d.ts",
41
+ "default": "./lib/cwd-prompt-tool.js"
42
+ },
43
+ "./wsl-doctor-tool": {
44
+ "types": "./lib/wsl-doctor-tool.d.ts",
45
+ "default": "./lib/wsl-doctor-tool.js"
46
+ },
47
+ "./client": {
48
+ "types": "./client.d.ts",
49
+ "default": "./client.js"
50
+ },
31
51
  "./file-reference-wsl": {
32
52
  "types": "./lib/file-reference-wsl.d.ts",
33
53
  "default": "./lib/file-reference-wsl.js"
@@ -79,6 +99,10 @@
79
99
  },
80
100
  "./subprocess/locale/en.json": "./locale/subprocess/en.json",
81
101
  "./subprocess/locale/zh.json": "./locale/subprocess/zh.json",
102
+ "./update-check": {
103
+ "types": "./lib/update-check.d.ts",
104
+ "default": "./lib/update-check.js"
105
+ },
82
106
  "./wsl": {
83
107
  "types": "./lib/wsl.d.ts",
84
108
  "default": "./lib/wsl.js"
@@ -87,6 +111,14 @@
87
111
  "dsh": {
88
112
  "bundle": {
89
113
  "patch": "./cordis.patch.yml"
114
+ },
115
+ "client": {
116
+ "platform": "web",
117
+ "immediately": true,
118
+ "inject": [
119
+ "@deepseek-ai/dsh-client-ui-slots",
120
+ "@deepseek-ai/dsh-client-ui-conversation"
121
+ ]
90
122
  }
91
123
  },
92
124
  "files": [
@@ -96,6 +128,8 @@
96
128
  "agent/native/linux-*/dsh-wsl-agent",
97
129
  "locale/**/*.json",
98
130
  "cordis.patch.yml",
131
+ "client.js",
132
+ "client.d.ts",
99
133
  "examples/**/*.yml",
100
134
  "README.md",
101
135
  "docs/README.zh.md",
@@ -126,6 +160,8 @@
126
160
  "docs/UPSTREAM-TERMINAL-TITLE.md",
127
161
  "docs/API.md",
128
162
  "docs/ARCHITECTURE.md",
163
+ "docs/DIAGNOSTICS.md",
164
+ "docs/DIAGNOSTICS.zh.md",
129
165
  "docs/ROADMAP.md",
130
166
  "docs/ROADMAP-1.0.md",
131
167
  "CHANGELOG.md",
@@ -143,9 +179,9 @@
143
179
  "lint:types": "tsc --noEmit",
144
180
  "build": "node scripts/build.mjs",
145
181
  "lint:build": "node test/build-freshness.mjs",
146
- "test:coverage": "node scripts/coverage-gate.mjs -- node --test --test-timeout=60000 --experimental-test-coverage --test-coverage-lines=85 --test-coverage-branches=84 --test-coverage-functions=70 --test-coverage-exclude='scripts/**' --test-coverage-exclude='test/**' test/agent-exec.test.mjs test/agent-fs-script.test.mjs test/agent-protocol.test.mjs test/agent.test.mjs test/fs-substrate.test.mjs test/fs.boot.test.mjs test/composition.test.mjs test/provider.test.mjs test/file-reference-wsl.test.mjs test/fsio-agent.test.mjs test/fsio-text.test.mjs test/git-exec.test.mjs test/git-route.test.mjs test/listing.test.mjs test/paths.test.mjs test/ports.test.mjs test/preset-choice.test.mjs test/probe-cache.test.mjs test/preflight.test.mjs test/sandbox.test.mjs test/search-exec.test.mjs test/search-route.test.mjs test/shell.test.mjs test/shell-env.test.mjs test/terminal-activity.test.mjs test/terminal.test.mjs test/watcher.test.mjs test/wsl.test.mjs test/fs-decisions.test.mjs test/session-scope.test.mjs test/session-runtime.test.mjs test/native-agent.test.mjs test/peers.test.mjs test/agent-shared.test.mjs test/distro-route.test.mjs test/fs-routing.test.mjs test/doctor.test.mjs test/profile-preset.test.mjs test/packaging.test.mjs test/peer-canary.test.mjs test/probe-runner.test.mjs",
182
+ "test:coverage": "node scripts/coverage-gate.mjs -- node --test --test-timeout=60000 --experimental-test-coverage --test-coverage-lines=85 --test-coverage-branches=84 --test-coverage-functions=70 --test-coverage-exclude='scripts/**' --test-coverage-exclude='test/**' test/agent-exec.test.mjs test/agent-fs-script.test.mjs test/agent-protocol.test.mjs test/agent.test.mjs test/fs-substrate.test.mjs test/fs.boot.test.mjs test/composition.test.mjs test/provider.test.mjs test/file-reference-wsl.test.mjs test/fsio-agent.test.mjs test/fsio-text.test.mjs test/git-exec.test.mjs test/git-route.test.mjs test/listing.test.mjs test/paths.test.mjs test/ports.test.mjs test/preset-choice.test.mjs test/probe-cache.test.mjs test/preflight.test.mjs test/sandbox.test.mjs test/search-exec.test.mjs test/search-route.test.mjs test/shell.test.mjs test/shell-env.test.mjs test/terminal-activity.test.mjs test/terminal.test.mjs test/watcher.test.mjs test/wsl.test.mjs test/fs-decisions.test.mjs test/session-scope.test.mjs test/session-runtime.test.mjs test/native-agent.test.mjs test/peers.test.mjs test/agent-shared.test.mjs test/distro-route.test.mjs test/fs-routing.test.mjs test/update-check.test.mjs test/doctor.test.mjs test/profile-preset.test.mjs test/packaging.test.mjs test/peer-canary.test.mjs test/probe-runner.test.mjs test/cwd-prompt.test.mjs test/cwd-prompt-tool.test.mjs test/wsl-doctor-tool.test.mjs test/wsl-doctor-tool.test.mjs test/client-host.test.mjs test/messages.test.mjs",
147
183
  "test:syntax": "node test/syntax.mjs",
148
- "test:unit": "node scripts/test-watchdog.mjs -- node --test --test-timeout=60000 test/fs.boot.test.mjs test/fsio-text.test.mjs test/composition.test.mjs test/provider.test.mjs test/file-reference-wsl.test.mjs test/paths.test.mjs test/listing.test.mjs test/shell.test.mjs test/shell-env.test.mjs test/terminal.test.mjs test/probe-cache.test.mjs test/preflight.test.mjs test/preset-choice.test.mjs test/sandbox.test.mjs test/agent-protocol.test.mjs test/agent.test.mjs test/agent-fs-script.test.mjs test/fsio-agent.test.mjs test/fs-substrate.test.mjs test/agent-exec.test.mjs test/ports.test.mjs test/watcher.test.mjs test/wsl.test.mjs test/fs-decisions.test.mjs test/git-exec.test.mjs test/git-route.test.mjs test/search-route.test.mjs test/search-exec.test.mjs test/terminal-activity.test.mjs test/session-scope.test.mjs test/session-runtime.test.mjs test/native-agent.test.mjs test/peers.test.mjs test/agent-shared.test.mjs test/distro-route.test.mjs test/fs-routing.test.mjs test/doctor.test.mjs test/profile-preset.test.mjs test/packaging.test.mjs test/peer-canary.test.mjs test/probe-runner.test.mjs",
184
+ "test:unit": "node scripts/test-watchdog.mjs -- node --test --test-timeout=60000 test/fs.boot.test.mjs test/fsio-text.test.mjs test/composition.test.mjs test/provider.test.mjs test/file-reference-wsl.test.mjs test/paths.test.mjs test/listing.test.mjs test/shell.test.mjs test/shell-env.test.mjs test/terminal.test.mjs test/probe-cache.test.mjs test/preflight.test.mjs test/preset-choice.test.mjs test/sandbox.test.mjs test/agent-protocol.test.mjs test/agent.test.mjs test/agent-fs-script.test.mjs test/fsio-agent.test.mjs test/fs-substrate.test.mjs test/agent-exec.test.mjs test/ports.test.mjs test/watcher.test.mjs test/wsl.test.mjs test/fs-decisions.test.mjs test/git-exec.test.mjs test/git-route.test.mjs test/search-route.test.mjs test/search-exec.test.mjs test/terminal-activity.test.mjs test/session-scope.test.mjs test/session-runtime.test.mjs test/native-agent.test.mjs test/peers.test.mjs test/agent-shared.test.mjs test/distro-route.test.mjs test/fs-routing.test.mjs test/update-check.test.mjs test/doctor.test.mjs test/profile-preset.test.mjs test/packaging.test.mjs test/peer-canary.test.mjs test/probe-runner.test.mjs test/cwd-prompt.test.mjs test/cwd-prompt-tool.test.mjs test/wsl-doctor-tool.test.mjs test/wsl-doctor-tool.test.mjs test/client-host.test.mjs test/messages.test.mjs",
149
185
  "lint:style": "node test/style.mjs",
150
186
  "lint:links": "node scripts/check-links.mjs",
151
187
  "lint:requirements": "node scripts/check-requirements.mjs",
@@ -212,6 +248,7 @@
212
248
  "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.1",
213
249
  "@deepseek-ai/dsh-subprocess": "0.2.2-rc.1",
214
250
  "@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.1",
251
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
215
252
  "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.1",
216
253
  "@types/js-yaml": "^4.0.9",
217
254
  "@types/node": "~22.20.5",
@@ -227,6 +264,7 @@
227
264
  "@deepseek-ai/dsh-host-directory-picker": ">=0.2.2-rc.1",
228
265
  "@deepseek-ai/dsh-sandbox": ">=0.2.2-rc.1",
229
266
  "@deepseek-ai/dsh-subprocess": ">=0.2.2-rc.1",
267
+ "@deepseek-ai/dsh-tools": ">=0.2.2-rc.1",
230
268
  "@deepseek-ai/dsh-subprocess-local": ">=0.2.2-rc.1",
231
269
  "@deepseek-ai/dsh-typert-protocol": ">=0.2.2-rc.1",
232
270
  "@deepseek-ai/schemastery": "^3.19.0"