dsh-plugin-wsl-env 0.25.0 → 0.26.1
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 +142 -0
- package/CODE_OF_CONDUCT.md +85 -0
- package/CODE_OF_CONDUCT.zh.md +85 -0
- package/CONTRIBUTING.md +19 -3
- package/CONTRIBUTING.zh.md +200 -0
- package/README.md +55 -149
- package/SECURITY.md +2 -0
- package/SECURITY.zh.md +108 -0
- package/SUPPORT.md +4 -2
- package/SUPPORT.zh.md +99 -0
- package/client.js +409 -8
- package/cordis.patch.yml +13 -0
- package/docs/AGENT-PROTOCOL-V7.md +2 -2
- package/docs/API.md +2 -0
- package/docs/API.zh.md +38 -0
- package/docs/ARCHITECTURE.md +15 -4
- package/docs/ARCHITECTURE.zh.md +518 -0
- package/docs/COMPATIBILITY.md +2 -0
- package/docs/COMPATIBILITY.zh.md +117 -0
- package/docs/CONFIGURATION.md +7 -10
- package/docs/CONFIGURATION.zh.md +7 -9
- package/docs/DIAGNOSTICS.md +24 -0
- package/docs/DIAGNOSTICS.zh.md +13 -0
- package/docs/LIMITATIONS.md +43 -5
- package/docs/LIMITATIONS.zh.md +34 -6
- package/docs/MIGRATION.md +10 -4
- package/docs/MIGRATION.zh.md +94 -0
- package/docs/PEER-PARITY.md +75 -47
- package/docs/PERFORMANCE.md +2 -0
- package/docs/PERFORMANCE.zh.md +59 -0
- package/docs/QUICKSTART.md +29 -15
- package/docs/QUICKSTART.zh.md +25 -17
- package/docs/README.zh.md +69 -150
- package/docs/RELEASING.md +4 -3
- package/docs/REQUIREMENTS.zh.md +4 -2
- package/docs/ROADMAP-1.0.md +2 -2
- package/docs/UPSTREAM-FILE-REFERENCE-SEAM.md +1 -1
- package/docs/UPSTREAM-OPEN-IN-APP.md +33 -11
- package/docs/UPSTREAM-SESSION-NOTICE.md +7 -0
- package/docs/VALUE.md +173 -0
- package/docs/VALUE.zh.md +42 -13
- package/docs/screenshots/with-plugin.png +0 -0
- package/docs/screenshots/with-plugin.svg +59 -0
- package/docs/screenshots/with-plugin.zh.png +0 -0
- package/docs/screenshots/with-plugin.zh.svg +56 -0
- package/docs/screenshots/without-plugin.png +0 -0
- package/docs/screenshots/without-plugin.svg +50 -0
- package/docs/screenshots/without-plugin.zh.png +0 -0
- package/docs/screenshots/without-plugin.zh.svg +45 -0
- package/lib/auto-preset-seam.d.ts +45 -0
- package/lib/auto-preset-seam.js +47 -0
- package/lib/auto-preset.d.ts +33 -10
- package/lib/auto-preset.js +148 -44
- package/lib/doctor-live.d.ts +30 -0
- package/lib/doctor-live.js +37 -0
- package/lib/doctor-report.js +10 -3
- package/lib/messages.d.ts +19 -0
- package/lib/messages.js +28 -0
- package/lib/open-in-app.d.ts +206 -0
- package/lib/open-in-app.js +300 -0
- package/lib/peer-versions.d.ts +53 -0
- package/lib/peer-versions.js +137 -0
- package/lib/preset-choice.d.ts +13 -0
- package/lib/preset-choice.js +18 -1
- package/lib/status.js +2 -1
- package/lib/update-check.d.ts +2 -2
- package/lib/update-check.js +2 -2
- package/lib/wsl-doctor-command.js +4 -2
- package/package.json +55 -25
- package/scripts/doctor.mjs +127 -9
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The peer set the spawning host process resolved, handed to the doctor CLI.
|
|
3
|
+
*
|
|
4
|
+
* The doctor is a separate process on purpose (see `scripts/doctor.mjs`), and
|
|
5
|
+
* a separate Node process resolves bare imports with Node's own lookup only.
|
|
6
|
+
* That is the wrong answer for a linked plugin: the host installs a profile
|
|
7
|
+
* resolution that projects a linked plugin's declared peers onto the
|
|
8
|
+
* installation's single copies, so the doctor's `createRequire` from the
|
|
9
|
+
* plugin directory can land on an unrelated `node_modules` above the mirror
|
|
10
|
+
* (or on nothing at all) while the plugin itself loads the host's copies.
|
|
11
|
+
* This module reads what the plugin process actually resolves — the same
|
|
12
|
+
* `createRequire` lookup, already intercepted by the host when one is
|
|
13
|
+
* installed — and passes it to the child in {@link DOCTOR_PEERS_ENV}. The
|
|
14
|
+
* variable's presence, not its size, is the signal: the map can be partial or
|
|
15
|
+
* empty (a peer the host could not resolve), and the doctor still treats it as
|
|
16
|
+
* authoritative instead of looking the missing peer up again beside the
|
|
17
|
+
* plugin. The standalone CLI, which has no host and therefore no variable,
|
|
18
|
+
* keeps its own lookup and reports peers it cannot see as unchecked.
|
|
19
|
+
*
|
|
20
|
+
* This is a TypeScript source built to `lib/peer-versions.js`; edit THIS file
|
|
21
|
+
* and run `pnpm run build` — the artifact under `lib/` is generated, and
|
|
22
|
+
* `pnpm test` fails when it drifts.
|
|
23
|
+
*
|
|
24
|
+
* @module dsh-plugin-wsl-env/peer-versions
|
|
25
|
+
*/
|
|
26
|
+
import { readFileSync } from "node:fs";
|
|
27
|
+
import { createRequire } from "node:module";
|
|
28
|
+
import { dirname, join } from "node:path";
|
|
29
|
+
import { fileURLToPath } from "node:url";
|
|
30
|
+
/** The private env contract between an in-app spawner and `scripts/doctor.mjs`. */
|
|
31
|
+
export const DOCTOR_PEERS_ENV = "DSH_WSL_DOCTOR_PEERS";
|
|
32
|
+
/** The installed plugin root (`lib/`'s parent), the anchor for its own manifest. */
|
|
33
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
34
|
+
/**
|
|
35
|
+
* The peer names this package declares, in manifest order.
|
|
36
|
+
* @returns the names; an unreadable manifest lists none.
|
|
37
|
+
*/
|
|
38
|
+
function peerNames() {
|
|
39
|
+
try {
|
|
40
|
+
// The manifest is this package's own file; the shape is the declaration it ships.
|
|
41
|
+
const manifest = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8"));
|
|
42
|
+
return Object.keys(manifest.peerDependencies ?? {});
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The version declared by the nearest `package.json` above a resolved file.
|
|
50
|
+
*
|
|
51
|
+
* Exported for the coverage suite: the walk's two failure arms (a malformed
|
|
52
|
+
* manifest, and the filesystem root) are not reachable with real peers.
|
|
53
|
+
* @param file - one resolved module file.
|
|
54
|
+
* @returns the version, or undefined when no readable manifest declares one.
|
|
55
|
+
*/
|
|
56
|
+
export function versionAbove(file) {
|
|
57
|
+
let directory = dirname(file);
|
|
58
|
+
for (;;) {
|
|
59
|
+
try {
|
|
60
|
+
// A peer's manifest is its declaration file; only the version string is read.
|
|
61
|
+
const manifest = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
|
|
62
|
+
return typeof manifest.version === "string" ? manifest.version : undefined;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
const parent = dirname(directory);
|
|
66
|
+
if (parent === directory)
|
|
67
|
+
return undefined;
|
|
68
|
+
directory = parent;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Resolve one peer's version the way this process loads it.
|
|
74
|
+
*
|
|
75
|
+
* Exported for the coverage suite: a peer that does not export
|
|
76
|
+
* `./package.json` exercises the entry-file fallback.
|
|
77
|
+
*
|
|
78
|
+
* `require.resolve` runs through the host's profile resolution when there is
|
|
79
|
+
* one, so a linked plugin sees the installation's copies and a plain process
|
|
80
|
+
* sees whatever `node_modules` it would actually import. The package's
|
|
81
|
+
* `./package.json` export is preferred because it names the version directly;
|
|
82
|
+
* a package that does not export it still resolves by its entry file.
|
|
83
|
+
*
|
|
84
|
+
* @param require - the anchored resolver.
|
|
85
|
+
* @param name - the peer package.
|
|
86
|
+
* @returns the resolved version, or undefined when the peer is absent.
|
|
87
|
+
*/
|
|
88
|
+
export function resolvedPeerVersion(require, name) {
|
|
89
|
+
try {
|
|
90
|
+
return versionAbove(require.resolve(`${name}/package.json`));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// Fall through to the entry file; not every package exports its manifest.
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
return versionAbove(require.resolve(name));
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The peer versions this process resolves.
|
|
104
|
+
*
|
|
105
|
+
* Deliberately uncached: a harness upgrade or a plugin-manager reload changes
|
|
106
|
+
* the answer, and one doctor spawn costs one small resolve per peer.
|
|
107
|
+
*
|
|
108
|
+
* @returns a name → version map; empty when the manifest or the peers are
|
|
109
|
+
* unreadable.
|
|
110
|
+
*/
|
|
111
|
+
export function resolvedPeerVersions() {
|
|
112
|
+
const require = createRequire(join(ROOT, "package.json"));
|
|
113
|
+
const versions = {};
|
|
114
|
+
for (const name of peerNames()) {
|
|
115
|
+
const version = resolvedPeerVersion(require, name);
|
|
116
|
+
if (version !== undefined)
|
|
117
|
+
versions[name] = version;
|
|
118
|
+
}
|
|
119
|
+
return versions;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Overlay the resolved peer set on one doctor child environment.
|
|
123
|
+
*
|
|
124
|
+
* The variable is set even when the map is empty: its **presence** is what
|
|
125
|
+
* tells the doctor that an in-app process already attempted resolution, so a
|
|
126
|
+
* peer missing from the map means "the host could not resolve it" and must be
|
|
127
|
+
* reported as unchecked — not looked up again in the plugin's physical tree,
|
|
128
|
+
* which may hold a stale copy. Absent means the standalone CLI, which has no
|
|
129
|
+
* host resolution and keeps its own lookup.
|
|
130
|
+
*
|
|
131
|
+
* @param env - the base environment (normally a copy of `process.env`).
|
|
132
|
+
* @param versions - the map; defaults to {@link resolvedPeerVersions}.
|
|
133
|
+
* @returns the child environment to spawn with.
|
|
134
|
+
*/
|
|
135
|
+
export function withHostPeerVersions(env, versions = resolvedPeerVersions()) {
|
|
136
|
+
return { ...env, [DOCTOR_PEERS_ENV]: JSON.stringify(versions) };
|
|
137
|
+
}
|
package/lib/preset-choice.d.ts
CHANGED
|
@@ -32,6 +32,19 @@
|
|
|
32
32
|
* @returns true when this workspace opted out of the distro environment.
|
|
33
33
|
*/
|
|
34
34
|
export declare function isWindowsAccessWorkspace(cwd: string, windowsAccess: readonly string[]): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a session-creation preset id leaves the environment to this plugin.
|
|
37
|
+
*
|
|
38
|
+
* An absent id means the caller mounted nothing (the headless runner); the
|
|
39
|
+
* registry's default id means the caller passed the default explicitly, which
|
|
40
|
+
* is not a pick of a different environment. A non-default id is an operator's
|
|
41
|
+
* choice and must win.
|
|
42
|
+
*
|
|
43
|
+
* @param presetId - the preset id the session controller received.
|
|
44
|
+
* @param fallback - the registry's default id, when it exposes one.
|
|
45
|
+
* @returns true when the WSL preset may be selected for the session.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isDefaultPresetChoice(presetId: string | undefined, fallback: string | undefined): boolean;
|
|
35
48
|
/**
|
|
36
49
|
* The adoption decision.
|
|
37
50
|
*
|
package/lib/preset-choice.js
CHANGED
|
@@ -40,12 +40,29 @@ function normalizeWorkspace(value) {
|
|
|
40
40
|
export function isWindowsAccessWorkspace(cwd, windowsAccess) {
|
|
41
41
|
const target = normalizeWorkspace(cwd);
|
|
42
42
|
return windowsAccess.some((entry) => {
|
|
43
|
-
|
|
43
|
+
// The list is settings-sourced. A malformed entry is ignored rather than
|
|
44
|
+
// allowed to fail a session creation or an adoption decision.
|
|
45
|
+
if (typeof entry !== "string" || entry.trim() === "")
|
|
44
46
|
return false;
|
|
45
47
|
const base = normalizeWorkspace(entry);
|
|
46
48
|
return target === base || target.startsWith(`${base}\\`);
|
|
47
49
|
});
|
|
48
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether a session-creation preset id leaves the environment to this plugin.
|
|
53
|
+
*
|
|
54
|
+
* An absent id means the caller mounted nothing (the headless runner); the
|
|
55
|
+
* registry's default id means the caller passed the default explicitly, which
|
|
56
|
+
* is not a pick of a different environment. A non-default id is an operator's
|
|
57
|
+
* choice and must win.
|
|
58
|
+
*
|
|
59
|
+
* @param presetId - the preset id the session controller received.
|
|
60
|
+
* @param fallback - the registry's default id, when it exposes one.
|
|
61
|
+
* @returns true when the WSL preset may be selected for the session.
|
|
62
|
+
*/
|
|
63
|
+
export function isDefaultPresetChoice(presetId, fallback) {
|
|
64
|
+
return presetId === undefined || (fallback !== undefined && presetId === fallback);
|
|
65
|
+
}
|
|
49
66
|
/**
|
|
50
67
|
* The adoption decision.
|
|
51
68
|
*
|
package/lib/status.js
CHANGED
|
@@ -51,6 +51,7 @@ import { dirname, join } from "node:path";
|
|
|
51
51
|
import { listDistros, listRunningDistros } from "./wsl.js";
|
|
52
52
|
import { digestReport, sectionOf } from "./wsl-doctor-tool.js";
|
|
53
53
|
import { runDoctorCli } from "./wsl-doctor-command.js";
|
|
54
|
+
import { mergeAutoPresetSeam } from "./doctor-live.js";
|
|
54
55
|
export const name = "wsl-status";
|
|
55
56
|
/** The one route the panel fetches; it must live under the `/api` channel. */
|
|
56
57
|
export const STATUS_PATH = "/api/wsl-env/status";
|
|
@@ -302,7 +303,7 @@ export function createStatusHandler(options) {
|
|
|
302
303
|
: ["--json", "--quick", "--distro", distro];
|
|
303
304
|
const raw = await options.runCli(argv, undefined, options.timeoutMs);
|
|
304
305
|
const report = JSON.parse(raw);
|
|
305
|
-
view = viewOf(digestReport(report, distro), distro, at, repair, source);
|
|
306
|
+
view = viewOf(digestReport(mergeAutoPresetSeam(report), distro), distro, at, repair, source);
|
|
306
307
|
}
|
|
307
308
|
catch (error) {
|
|
308
309
|
view = {
|
package/lib/update-check.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The plugin's update check: notice when a newer release exists, stop there.
|
|
3
3
|
*
|
|
4
|
-
* Upgrading today means re-installing by hand (Plugins page
|
|
5
|
-
*
|
|
4
|
+
* Upgrading today means re-installing by hand (the Plugins page) and the
|
|
5
|
+
* harness's own plugin-manager already answers
|
|
6
6
|
* "which versions exist and do they fit this DSH" — `listVersions` resolves
|
|
7
7
|
* dist-tags, deprecation, and the `engines.dsh`/peer compatibility of every
|
|
8
8
|
* candidate against the running DSH. This service makes that answer arrive
|
package/lib/update-check.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The plugin's update check: notice when a newer release exists, stop there.
|
|
3
3
|
*
|
|
4
|
-
* Upgrading today means re-installing by hand (Plugins page
|
|
5
|
-
*
|
|
4
|
+
* Upgrading today means re-installing by hand (the Plugins page) and the
|
|
5
|
+
* harness's own plugin-manager already answers
|
|
6
6
|
* "which versions exist and do they fit this DSH" — `listVersions` resolves
|
|
7
7
|
* dist-tags, deprecation, and the `engines.dsh`/peer compatibility of every
|
|
8
8
|
* candidate against the running DSH. This service makes that answer arrive
|
|
@@ -31,7 +31,9 @@ import { spawn } from "node:child_process";
|
|
|
31
31
|
import { dirname, resolve } from "node:path";
|
|
32
32
|
import { fileURLToPath } from "node:url";
|
|
33
33
|
import { distroOfUnc } from "./distro-route.js";
|
|
34
|
+
import { withHostPeerVersions } from "./peer-versions.js";
|
|
34
35
|
import { digestReport, renderDigest, SECTIONS } from "./wsl-doctor-tool.js";
|
|
36
|
+
import { mergeAutoPresetSeam } from "./doctor-live.js";
|
|
35
37
|
export const name = "wsl-doctor-command";
|
|
36
38
|
/**
|
|
37
39
|
* No required inject: a headless deployment has no commands registry, and a
|
|
@@ -132,7 +134,7 @@ export function parseDoctorInput(rawInput) {
|
|
|
132
134
|
export function runDoctorCli(argv, signal, timeoutMs = DOCTOR_CLI_TIMEOUT_MS) {
|
|
133
135
|
return new Promise((resolvePromise, rejectPromise) => {
|
|
134
136
|
const child = spawn(process.execPath, [DOCTOR_SCRIPT, ...argv], {
|
|
135
|
-
env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
|
|
137
|
+
env: withHostPeerVersions({ ...process.env, ELECTRON_RUN_AS_NODE: "1" }),
|
|
136
138
|
windowsHide: true,
|
|
137
139
|
stdio: ["ignore", "pipe", "pipe"],
|
|
138
140
|
signal,
|
|
@@ -313,7 +315,7 @@ async function resolveDistro(ctx, invocation, distro) {
|
|
|
313
315
|
*/
|
|
314
316
|
export function formatDoctorReport(json, distro) {
|
|
315
317
|
const report = JSON.parse(json);
|
|
316
|
-
const digest = digestReport(report, distro.length > 0 ? distro : undefined);
|
|
318
|
+
const digest = digestReport(mergeAutoPresetSeam(report), distro.length > 0 ? distro : undefined);
|
|
317
319
|
return renderDigest(digest);
|
|
318
320
|
}
|
|
319
321
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-wsl-env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "在 WSL 的 Linux 实例中打开项目工作区,在对应 Linux 空间中进行命令执行、运行 shell 脚本和文件访问,以获得全套 Linux Shell 工具链收益,并通过 bubblewrap 对命令进行沙箱隔离",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
"dsh-plugin",
|
|
9
9
|
"cordis",
|
|
10
10
|
"wsl",
|
|
11
|
-
"
|
|
11
|
+
"wsl2",
|
|
12
|
+
"windows",
|
|
13
|
+
"linux",
|
|
14
|
+
"deepseek",
|
|
15
|
+
"ai-agent",
|
|
16
|
+
"coding-agent",
|
|
17
|
+
"bubblewrap"
|
|
12
18
|
],
|
|
13
19
|
"type": "module",
|
|
14
20
|
"types": "./lib/client-host.d.ts",
|
|
@@ -56,6 +62,10 @@
|
|
|
56
62
|
"types": "./lib/index.d.ts",
|
|
57
63
|
"default": "./lib/index.js"
|
|
58
64
|
},
|
|
65
|
+
"./open-in-app": {
|
|
66
|
+
"types": "./lib/open-in-app.d.ts",
|
|
67
|
+
"default": "./lib/open-in-app.js"
|
|
68
|
+
},
|
|
59
69
|
"./locale/en.json": "./locale/en.json",
|
|
60
70
|
"./locale/zh.json": "./locale/zh.json",
|
|
61
71
|
"./package.json": "./package.json",
|
|
@@ -124,7 +134,10 @@
|
|
|
124
134
|
"@deepseek-ai/dsh-client-ui-slots",
|
|
125
135
|
"@deepseek-ai/dsh-client-ui-layout",
|
|
126
136
|
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
127
|
-
"@deepseek-ai/dsh-client-ui-workspace"
|
|
137
|
+
"@deepseek-ai/dsh-client-ui-workspace",
|
|
138
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
139
|
+
"@deepseek-ai/dsh-client-ui-context-menu",
|
|
140
|
+
"@deepseek-ai/dsh-client-ui-session"
|
|
128
141
|
]
|
|
129
142
|
}
|
|
130
143
|
},
|
|
@@ -142,6 +155,7 @@
|
|
|
142
155
|
"docs/README.zh.md",
|
|
143
156
|
"docs/QUICKSTART.md",
|
|
144
157
|
"docs/screenshots/*.png",
|
|
158
|
+
"docs/screenshots/*.svg",
|
|
145
159
|
"docs/PERFORMANCE.md",
|
|
146
160
|
"docs/COMPATIBILITY.md",
|
|
147
161
|
"docs/CONFIGURATION.md",
|
|
@@ -182,16 +196,28 @@
|
|
|
182
196
|
"scripts/diagnose.sh",
|
|
183
197
|
"scripts/doctor.mjs",
|
|
184
198
|
"scripts/open-wsl-vscode.ps1",
|
|
185
|
-
"scripts/profile-preset.mjs"
|
|
199
|
+
"scripts/profile-preset.mjs",
|
|
200
|
+
"docs/ARCHITECTURE.zh.md",
|
|
201
|
+
"docs/API.zh.md",
|
|
202
|
+
"docs/COMPATIBILITY.zh.md",
|
|
203
|
+
"docs/MIGRATION.zh.md",
|
|
204
|
+
"docs/PERFORMANCE.zh.md",
|
|
205
|
+
"docs/VALUE.md",
|
|
206
|
+
"CONTRIBUTING.zh.md",
|
|
207
|
+
"SECURITY.zh.md",
|
|
208
|
+
"SUPPORT.zh.md",
|
|
209
|
+
"CODE_OF_CONDUCT.md",
|
|
210
|
+
"CODE_OF_CONDUCT.zh.md"
|
|
186
211
|
],
|
|
187
212
|
"scripts": {
|
|
188
213
|
"test": "pnpm run lint:style && pnpm run lint:links && pnpm run lint:requirements && pnpm run lint:docs && pnpm run test:syntax && pnpm run lint:build && pnpm run lint:types && pnpm run test:unit",
|
|
189
214
|
"lint:types": "tsc --noEmit",
|
|
190
215
|
"build": "node scripts/build.mjs",
|
|
191
216
|
"lint:build": "node test/build-freshness.mjs",
|
|
192
|
-
"test:
|
|
217
|
+
"test:browser": "node --test --test-timeout=120000 test/browser/e2e.test.mjs",
|
|
218
|
+
"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/auto-preset.test.mjs test/probe-cache.test.mjs test/writable-roots.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-command.test.mjs test/status.test.mjs test/client-host.test.mjs test/messages.test.mjs test/client.test.mjs test/open-in-app.test.mjs",
|
|
193
219
|
"test:syntax": "node test/syntax.mjs",
|
|
194
|
-
"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/writable-roots.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-command.test.mjs test/status.test.mjs test/client-host.test.mjs test/messages.test.mjs",
|
|
220
|
+
"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/writable-roots.test.mjs test/preflight.test.mjs test/preset-choice.test.mjs test/auto-preset.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-command.test.mjs test/status.test.mjs test/client-host.test.mjs test/messages.test.mjs test/client.test.mjs test/open-in-app.test.mjs",
|
|
195
221
|
"lint:style": "node test/style.mjs",
|
|
196
222
|
"lint:links": "node scripts/check-links.mjs",
|
|
197
223
|
"lint:requirements": "node scripts/check-requirements.mjs",
|
|
@@ -249,33 +275,37 @@
|
|
|
249
275
|
"@deepseek-ai/cordis": "4.1.0",
|
|
250
276
|
"@deepseek-ai/cordis-plugin-include": "1.1.0",
|
|
251
277
|
"@deepseek-ai/cordis-plugin-loader": "1.1.0",
|
|
252
|
-
"@deepseek-ai/dsh-bash-local": "0.2.2-rc.
|
|
253
|
-
"@deepseek-ai/dsh-fs": "0.2.2-rc.
|
|
254
|
-
"@deepseek-ai/dsh-fs-local": "0.2.2-rc.
|
|
255
|
-
"@deepseek-ai/dsh-fs-patch": "0.2.2-rc.
|
|
256
|
-
"@deepseek-ai/dsh-host-directory-picker": "0.2.2-rc.
|
|
257
|
-
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.
|
|
258
|
-
"@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.
|
|
259
|
-
"@deepseek-ai/dsh-subprocess": "0.2.2-rc.
|
|
260
|
-
"@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.
|
|
261
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.
|
|
278
|
+
"@deepseek-ai/dsh-bash-local": "0.2.2-rc.2",
|
|
279
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.2",
|
|
280
|
+
"@deepseek-ai/dsh-fs-local": "0.2.2-rc.2",
|
|
281
|
+
"@deepseek-ai/dsh-fs-patch": "0.2.2-rc.2",
|
|
282
|
+
"@deepseek-ai/dsh-host-directory-picker": "0.2.2-rc.2",
|
|
283
|
+
"@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
|
|
284
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
|
|
285
|
+
"@deepseek-ai/dsh-subprocess": "0.2.2-rc.2",
|
|
286
|
+
"@deepseek-ai/dsh-subprocess-local": "0.2.2-rc.2",
|
|
287
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.2",
|
|
262
288
|
"@deepseek-ai/schemastery": "3.19.0",
|
|
263
289
|
"@types/js-yaml": "^4.0.9",
|
|
264
290
|
"@types/node": "~22.20.5",
|
|
291
|
+
"esbuild": "0.25.8",
|
|
265
292
|
"js-yaml": "4.3.2",
|
|
293
|
+
"playwright": "1.65.0",
|
|
294
|
+
"react": "19.1.1",
|
|
295
|
+
"react-dom": "19.1.1",
|
|
266
296
|
"typescript": "~6.0.3"
|
|
267
297
|
},
|
|
268
298
|
"peerDependencies": {
|
|
269
299
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
270
|
-
"@deepseek-ai/dsh-bash-local": ">=0.2.2-rc.
|
|
271
|
-
"@deepseek-ai/dsh-fs": ">=0.2.2-rc.
|
|
272
|
-
"@deepseek-ai/dsh-fs-local": ">=0.2.2-rc.
|
|
273
|
-
"@deepseek-ai/dsh-fs-patch": ">=0.2.2-rc.
|
|
274
|
-
"@deepseek-ai/dsh-host-directory-picker": ">=0.2.2-rc.
|
|
275
|
-
"@deepseek-ai/dsh-sandbox": ">=0.2.2-rc.
|
|
276
|
-
"@deepseek-ai/dsh-subprocess": ">=0.2.2-rc.
|
|
277
|
-
"@deepseek-ai/dsh-tools": ">=0.2.2-rc.
|
|
278
|
-
"@deepseek-ai/dsh-subprocess-local": ">=0.2.2-rc.
|
|
300
|
+
"@deepseek-ai/dsh-bash-local": ">=0.2.2-rc.2",
|
|
301
|
+
"@deepseek-ai/dsh-fs": ">=0.2.2-rc.2",
|
|
302
|
+
"@deepseek-ai/dsh-fs-local": ">=0.2.2-rc.2",
|
|
303
|
+
"@deepseek-ai/dsh-fs-patch": ">=0.2.2-rc.2",
|
|
304
|
+
"@deepseek-ai/dsh-host-directory-picker": ">=0.2.2-rc.2",
|
|
305
|
+
"@deepseek-ai/dsh-sandbox": ">=0.2.2-rc.2",
|
|
306
|
+
"@deepseek-ai/dsh-subprocess": ">=0.2.2-rc.2",
|
|
307
|
+
"@deepseek-ai/dsh-tools": ">=0.2.2-rc.2",
|
|
308
|
+
"@deepseek-ai/dsh-subprocess-local": ">=0.2.2-rc.2",
|
|
279
309
|
"@deepseek-ai/schemastery": "^3.19.0"
|
|
280
310
|
},
|
|
281
311
|
"peerDependenciesMeta": {
|
package/scripts/doctor.mjs
CHANGED
|
@@ -802,21 +802,113 @@ function comparePrerelease(left, right) {
|
|
|
802
802
|
return 0;
|
|
803
803
|
}
|
|
804
804
|
|
|
805
|
+
/** The private env contract: the peer set the spawning host process resolved. */
|
|
806
|
+
const HOST_PEERS_ENV = "DSH_WSL_DOCTOR_PEERS";
|
|
807
|
+
|
|
808
|
+
/** Per-directory peer declarations, read once per doctor run. */
|
|
809
|
+
const peerDeclarations = new Map();
|
|
810
|
+
|
|
805
811
|
/**
|
|
806
|
-
*
|
|
812
|
+
* The peer names one package project declares.
|
|
813
|
+
*
|
|
814
|
+
* The host's linked-plugin resolution applies a peer declaration at the first
|
|
815
|
+
* ancestor `node_modules` position whose project declares the name; the
|
|
816
|
+
* physical copy there is the one that position owns. A `node_modules`
|
|
817
|
+
* directory with no manifest above it (the stale tree a harness upgrade
|
|
818
|
+
* leaves behind) declares nothing and has no vote.
|
|
819
|
+
*
|
|
820
|
+
* @param {string} directory - the project directory that owns one `node_modules`.
|
|
821
|
+
* @returns {Set<string>} its declared peer names; empty when the manifest is absent.
|
|
822
|
+
*/
|
|
823
|
+
function declaredPeers(directory) {
|
|
824
|
+
let peers = peerDeclarations.get(directory);
|
|
825
|
+
if (peers === undefined) {
|
|
826
|
+
try {
|
|
827
|
+
const manifest = /** @type {{ peerDependencies?: Record<string, string> }} */ (JSON.parse(readFileSync(join(directory, "package.json"), "utf8")));
|
|
828
|
+
peers = new Set(Object.keys(manifest.peerDependencies ?? {}));
|
|
829
|
+
} catch {
|
|
830
|
+
peers = new Set();
|
|
831
|
+
}
|
|
832
|
+
peerDeclarations.set(directory, peers);
|
|
833
|
+
}
|
|
834
|
+
return peers;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* The directory of one peer as the plugin's own package tree carries it.
|
|
839
|
+
*
|
|
840
|
+
* Scoped to the first ancestor position that declares the peer. That mirrors
|
|
841
|
+
* the runtime's projection rule and keeps a copy from a `node_modules` above
|
|
842
|
+
* the plugin (an old installation tree, or a hoisted workspace) from being
|
|
843
|
+
* reported as the plugin's peer set. When the declaring position has no
|
|
844
|
+
* copy, the peer is not installed with the plugin — the standalone process
|
|
845
|
+
* cannot see whether the runtime projects an installation copy, so it reports
|
|
846
|
+
* that as unchecked rather than failed.
|
|
847
|
+
*
|
|
848
|
+
* @param {string} packageName - the peer package.
|
|
849
|
+
* @param {string} [root] - the plugin root; defaults to this script's root.
|
|
850
|
+
* @returns the package directory, or undefined when the plugin does not carry it.
|
|
851
|
+
*/
|
|
852
|
+
export function peerPackageDir(packageName, root = ROOT) {
|
|
853
|
+
const require = createRequire(join(root, "package.json"));
|
|
854
|
+
for (const searchPath of require.resolve.paths(packageName) ?? []) {
|
|
855
|
+
if (!declaredPeers(dirname(searchPath)).has(packageName)) continue;
|
|
856
|
+
const candidate = join(searchPath, packageName);
|
|
857
|
+
return existsSync(join(candidate, "package.json")) ? candidate : undefined;
|
|
858
|
+
}
|
|
859
|
+
return undefined;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Read the installed version of one peer, or undefined when absent.
|
|
807
864
|
* @param {string} packageName - the peer package.
|
|
808
865
|
* @returns {string | undefined} the installed version.
|
|
809
866
|
*/
|
|
810
867
|
function installedPeer(packageName) {
|
|
811
|
-
const
|
|
868
|
+
const directory = peerPackageDir(packageName);
|
|
869
|
+
if (directory === undefined) return undefined;
|
|
812
870
|
try {
|
|
813
|
-
const manifest = /** @type {{ version?: string }} */ (JSON.parse(readFileSync(
|
|
871
|
+
const manifest = /** @type {{ version?: string }} */ (JSON.parse(readFileSync(join(directory, "package.json"), "utf8")));
|
|
814
872
|
return manifest.version;
|
|
815
873
|
} catch {
|
|
816
874
|
return undefined;
|
|
817
875
|
}
|
|
818
876
|
}
|
|
819
877
|
|
|
878
|
+
/**
|
|
879
|
+
* The peer versions the spawning host process resolved, or undefined when
|
|
880
|
+
* this run is the standalone CLI.
|
|
881
|
+
*
|
|
882
|
+
* Presence of the variable is the signal: the in-app spawners always set it,
|
|
883
|
+
* even when the map is empty or partial, because a JSON object can only carry
|
|
884
|
+
* the peers that resolved. A missing peer then means "the host could not
|
|
885
|
+
* resolve it" and is reported unchecked — never looked up again in the
|
|
886
|
+
* plugin's physical tree, which may hold a stale copy from an older
|
|
887
|
+
* installation. A malformed value is treated as absent: it cannot come from
|
|
888
|
+
* {@link withHostPeerVersions}, so the standalone lookup is the honest
|
|
889
|
+
* fallback.
|
|
890
|
+
*
|
|
891
|
+
* @returns the name → version map, or undefined when the variable is absent
|
|
892
|
+
* or unparseable.
|
|
893
|
+
*/
|
|
894
|
+
function hostPeerVersions() {
|
|
895
|
+
const raw = process.env[HOST_PEERS_ENV];
|
|
896
|
+
if (raw === undefined || raw.length === 0) return undefined;
|
|
897
|
+
let parsed;
|
|
898
|
+
try {
|
|
899
|
+
parsed = JSON.parse(raw);
|
|
900
|
+
} catch {
|
|
901
|
+
return undefined;
|
|
902
|
+
}
|
|
903
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
|
|
904
|
+
/** @type {Record<string, string>} */
|
|
905
|
+
const versions = {};
|
|
906
|
+
for (const [name, version] of Object.entries(parsed)) {
|
|
907
|
+
if (typeof version === "string" && version.length > 0) versions[name] = version;
|
|
908
|
+
}
|
|
909
|
+
return versions;
|
|
910
|
+
}
|
|
911
|
+
|
|
820
912
|
/**
|
|
821
913
|
* The install remedy for one distro and family.
|
|
822
914
|
* @param {string} distro - the distro name.
|
|
@@ -1765,17 +1857,43 @@ async function main(options) {
|
|
|
1765
1857
|
}
|
|
1766
1858
|
|
|
1767
1859
|
// ---- peers ---------------------------------------------------------------
|
|
1860
|
+
// The host runtime projects a linked plugin's declared peers onto the
|
|
1861
|
+
// installation's single copies, so the spawning in-app process hands its
|
|
1862
|
+
// resolved set over. When that variable is present it is authoritative even
|
|
1863
|
+
// if partial or empty: a peer it omits could not be resolved by the host,
|
|
1864
|
+
// and falling back to this process's own lookup would report a stale copy
|
|
1865
|
+
// beside the plugin. Only the standalone CLI, with no variable at all,
|
|
1866
|
+
// looks in the plugin's tree; there, a peer nobody can see is unchecked
|
|
1867
|
+
// rather than failed, because the runtime may project an installation copy.
|
|
1768
1868
|
const peers = Object.entries(manifest.peerDependencies ?? {});
|
|
1869
|
+
const hostPeers = hostPeerVersions();
|
|
1769
1870
|
const badPeers = [];
|
|
1770
1871
|
const unknownPeers = [];
|
|
1872
|
+
const uncheckedPeers = [];
|
|
1873
|
+
let matchedPeers = 0;
|
|
1771
1874
|
for (const [name, range] of peers) {
|
|
1772
|
-
const installed = installedPeer(name);
|
|
1773
|
-
if (installed === undefined)
|
|
1774
|
-
|
|
1775
|
-
|
|
1875
|
+
const installed = hostPeers === undefined ? installedPeer(name) : hostPeers[name];
|
|
1876
|
+
if (installed === undefined) {
|
|
1877
|
+
uncheckedPeers.push(name);
|
|
1878
|
+
continue;
|
|
1879
|
+
}
|
|
1880
|
+
const satisfied = peerSatisfied(installed, range);
|
|
1881
|
+
if (satisfied === false) badPeers.push(`${name}: ${installed} (want ${range})`);
|
|
1882
|
+
else if (satisfied === undefined) unknownPeers.push(`${name}: ${installed} (range ${range} unchecked)`);
|
|
1883
|
+
else matchedPeers += 1;
|
|
1884
|
+
}
|
|
1885
|
+
if (badPeers.length === 0) {
|
|
1886
|
+
const hostNote = hostPeers === undefined ? "" : " (host runtime)";
|
|
1887
|
+
const unknownNote = unknownPeers.length > 0 ? `; ${unknownPeers.length} unrecognized range` : "";
|
|
1888
|
+
const uncheckedNote = uncheckedPeers.length > 0
|
|
1889
|
+
? (hostPeers === undefined
|
|
1890
|
+
? `; ${uncheckedPeers.length} not visible to this process (the runtime projects peers from the installation)`
|
|
1891
|
+
: `; ${uncheckedPeers.length} not resolved by the host runtime`)
|
|
1892
|
+
: "";
|
|
1893
|
+
check("peers.versions", "ok", "Peer versions", `${matchedPeers} pinned peer(s) match${hostNote}${unknownNote}${uncheckedNote}`);
|
|
1894
|
+
} else {
|
|
1895
|
+
check("peers.versions", "fail", "Peer versions", badPeers.join("; "), "install the peer set this plugin pins (pnpm install in the plugin, or reinstall/upgrade it against this harness); see docs/PEER-PARITY.md");
|
|
1776
1896
|
}
|
|
1777
|
-
if (badPeers.length === 0) check("peers.versions", "ok", "Peer versions", `${peers.length} pinned peer(s) match${unknownPeers.length > 0 ? `; ${unknownPeers.length} unchecked` : ""}`);
|
|
1778
|
-
else check("peers.versions", "fail", "Peer versions", badPeers.join("; "), "install the peer set this plugin pins (pnpm install in the plugin, or reinstall/upgrade it against this harness); see docs/PEER-PARITY.md");
|
|
1779
1897
|
|
|
1780
1898
|
phase("surveys");
|
|
1781
1899
|
// ---- effective configuration (verdict inputs, reported) ------------------
|