dsh-plugin-wsl-env 0.24.0 → 0.25.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 (59) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +6 -3
  3. package/SECURITY.md +10 -0
  4. package/cordis.patch.yml +4 -0
  5. package/docs/ARCHITECTURE.md +28 -9
  6. package/docs/CONFIGURATION.md +43 -0
  7. package/docs/CONFIGURATION.zh.md +36 -0
  8. package/docs/DIAGNOSTICS.md +4 -2
  9. package/docs/DIAGNOSTICS.zh.md +3 -1
  10. package/docs/LIMITATIONS.md +17 -4
  11. package/docs/LIMITATIONS.zh.md +11 -3
  12. package/docs/MIGRATION.md +1 -1
  13. package/docs/PEER-PARITY.md +4 -4
  14. package/docs/QUICKSTART.md +12 -5
  15. package/docs/QUICKSTART.zh.md +8 -2
  16. package/docs/README.zh.md +6 -3
  17. package/docs/RELEASING.md +17 -13
  18. package/docs/REQUIREMENTS.zh.md +3 -2
  19. package/docs/UPSTREAM-FSIO-EXPORT.md +5 -4
  20. package/docs/UPSTREAM-PROMPT-ADAPTERS.md +85 -0
  21. package/docs/root-fs-routing.md +1 -1
  22. package/lib/agent-confined.d.ts +7 -1
  23. package/lib/agent-confined.js +3 -3
  24. package/lib/bwrap.d.ts +14 -0
  25. package/lib/bwrap.js +11 -0
  26. package/lib/cwd-prompt.d.ts +41 -3
  27. package/lib/cwd-prompt.js +125 -8
  28. package/lib/doctor-report.d.ts +50 -0
  29. package/lib/doctor-report.js +172 -0
  30. package/lib/fs-routing.d.ts +1 -1
  31. package/lib/fs-routing.js +1 -1
  32. package/lib/fs.d.ts +1 -1
  33. package/lib/fs.js +1 -1
  34. package/lib/index.d.ts +6 -1464
  35. package/lib/index.js +5 -2120
  36. package/lib/messages.d.ts +1 -1
  37. package/lib/messages.js +3 -3
  38. package/lib/preflight.d.ts +7 -4
  39. package/lib/preflight.js +27 -13
  40. package/lib/provider-common.d.ts +58 -0
  41. package/lib/provider-common.js +123 -0
  42. package/lib/sandbox-core.d.ts +1 -0
  43. package/lib/sandbox-core.js +4 -2
  44. package/lib/session-runtime.d.ts +7 -1
  45. package/lib/session-runtime.js +9 -2
  46. package/lib/shell.d.ts +1 -1
  47. package/lib/shell.js +1 -1
  48. package/lib/writable-roots.d.ts +109 -0
  49. package/lib/writable-roots.js +257 -0
  50. package/lib/wsl-doctor-tool.js +2 -2
  51. package/lib/wsl-filesystem.d.ts +692 -0
  52. package/lib/wsl-filesystem.js +897 -0
  53. package/lib/wsl-shell.d.ts +742 -0
  54. package/lib/wsl-shell.js +965 -0
  55. package/lib/wsl.d.ts +1 -1
  56. package/lib/wsl.js +1 -1
  57. package/package.json +4 -3
  58. package/scripts/doctor.mjs +1 -1
  59. package/scripts/profile-preset.mjs +17 -5
package/lib/wsl.d.ts CHANGED
@@ -179,7 +179,7 @@ export interface WslTerminalOptions {
179
179
  /**
180
180
  * The `wsl.exe` argv that opens one interactive shell inside a distro.
181
181
  *
182
- * This is the terminal twin of the command form built in `lib/index.js`, with
182
+ * This is the terminal twin of the command form built in `lib/wsl-shell.js`, with
183
183
  * three deliberate differences:
184
184
  *
185
185
  * - There is no command string. With no pinned shell the launch ends here and
package/lib/wsl.js CHANGED
@@ -241,7 +241,7 @@ export function interactiveShellArgs(shellPath, login) {
241
241
  /**
242
242
  * The `wsl.exe` argv that opens one interactive shell inside a distro.
243
243
  *
244
- * This is the terminal twin of the command form built in `lib/index.js`, with
244
+ * This is the terminal twin of the command form built in `lib/wsl-shell.js`, with
245
245
  * three deliberate differences:
246
246
  *
247
247
  * - There is no command string. With no pinned shell the launch ends here and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-wsl-env",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "在 WSL 的 Linux 实例中打开项目工作区,在对应 Linux 空间中进行命令执行、运行 shell 脚本和文件访问,以获得全套 Linux Shell 工具链收益,并通过 bubblewrap 对命令进行沙箱隔离",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -154,6 +154,7 @@
154
154
  "docs/root-fs-routing.md",
155
155
  "docs/VALUE.zh.md",
156
156
  "docs/UPSTREAM-OPEN-IN-APP.md",
157
+ "docs/UPSTREAM-PROMPT-ADAPTERS.md",
157
158
  "docs/adr/0002-native-agent.md",
158
159
  "docs/PARITY.md",
159
160
  "docs/PEER-PARITY.md",
@@ -188,9 +189,9 @@
188
189
  "lint:types": "tsc --noEmit",
189
190
  "build": "node scripts/build.mjs",
190
191
  "lint:build": "node test/build-freshness.mjs",
191
- "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-command.test.mjs test/status.test.mjs test/client-host.test.mjs test/messages.test.mjs",
192
+ "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/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",
192
193
  "test:syntax": "node test/syntax.mjs",
193
- "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-command.test.mjs test/status.test.mjs test/client-host.test.mjs test/messages.test.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",
194
195
  "lint:style": "node test/style.mjs",
195
196
  "lint:links": "node scripts/check-links.mjs",
196
197
  "lint:requirements": "node scripts/check-requirements.mjs",
@@ -84,7 +84,7 @@ import { parseListeningPorts, procNetScript } from "../lib/ports.js";
84
84
  // `test/doctor.test.mjs` compares the copy against the lib export to pin it
85
85
  // against drift.
86
86
  //
87
- // Inlined from `src/index.ts` `effectiveMaskWindowsDrive`:
87
+ // Inlined from `src/provider-common.ts` `effectiveMaskWindowsDrive`:
88
88
  /**
89
89
  * Whether confined profiles shadow `/mnt` under this config.
90
90
  *
@@ -12,6 +12,7 @@
12
12
  *
13
13
  * node scripts/profile-preset.mjs [--distro Debian] [--session-sandbox false|auto]
14
14
  * [--sandbox false] [--mask-windows-drive true] [--agent-backend native]
15
+ * [--writable-roots '~/.npm,~/.cache']
15
16
  * [--out <profile/cordis.patch.yml>] [--check <file>] [--force]
16
17
  *
17
18
  * With no `--out`/`--check`, the block (with the edits) goes to stdout.
@@ -110,7 +111,7 @@ function setKey(lines, id, key, value) {
110
111
  /**
111
112
  * Apply the supported edits to a preset block.
112
113
  * @param {string} block - the block from {@link presetBlock}.
113
- * @param {{ distro?: string, sessionSandbox?: boolean | "auto", sandbox?: boolean, maskWindowsDrive?: boolean, agentBackend?: string }} edits - the edits.
114
+ * @param {{ distro?: string, sessionSandbox?: boolean | "auto", sandbox?: boolean, maskWindowsDrive?: boolean, agentBackend?: string, writableRoots?: string[] }} edits - the edits.
114
115
  * @returns {string} the edited block.
115
116
  */
116
117
  export function applyEdits(block, edits) {
@@ -127,18 +128,25 @@ export function applyEdits(block, edits) {
127
128
  setKey(lines, "wsl-fs", key, value);
128
129
  }
129
130
  if (edits.agentBackend !== undefined) setKey(lines, "wsl-shell", "agentBackend", edits.agentBackend);
131
+ if (edits.writableRoots !== undefined) {
132
+ // A flow sequence is valid YAML and keeps the helper's one-line-per-key
133
+ // edit shape; the rows themselves take a real list once the block is merged.
134
+ const value = JSON.stringify(edits.writableRoots);
135
+ setKey(lines, "wsl-shell", "writableRoots", value);
136
+ setKey(lines, "wsl-fs", "writableRoots", value);
137
+ }
130
138
  return lines.join("\n");
131
139
  }
132
140
 
133
141
  /**
134
142
  * Parse the helper's arguments.
135
143
  * @param {string[]} argv - `process.argv.slice(2)`.
136
- * @returns {{ edits: Record<string, string | boolean>, out?: string, check?: string, force: boolean }} the options.
144
+ * @returns {{ edits: Record<string, string | boolean | string[]>, out?: string, check?: string, force: boolean }} the options.
137
145
  */
138
146
  function parseArgs(argv) {
139
- /** @type {Record<string, string | boolean>} */
147
+ /** @type {Record<string, string | boolean | string[]>} */
140
148
  const edits = {};
141
- /** @type {{ edits: Record<string, string | boolean>, out?: string, check?: string, force: boolean }} */
149
+ /** @type {{ edits: Record<string, string | boolean | string[]>, out?: string, check?: string, force: boolean }} */
142
150
  const options = { edits, force: false };
143
151
  for (let i = 0; i < argv.length; i += 1) {
144
152
  const arg = argv[i] ?? "";
@@ -153,13 +161,17 @@ function parseArgs(argv) {
153
161
  else if (flag === "--agent-backend") {
154
162
  if (!["auto", "native", "shell"].includes(value)) throw new Error(`profile-preset: --agent-backend must be auto, native or shell (got "${value}")`);
155
163
  edits.agentBackend = value;
164
+ } else if (flag === "--writable-roots") {
165
+ const roots = value.split(",").map((root) => root.trim()).filter((root) => root.length > 0);
166
+ if (roots.length === 0) throw new Error("profile-preset: --writable-roots needs a comma-separated list of distro paths");
167
+ edits.writableRoots = roots;
156
168
  } else if (flag === "--out") options.out = value;
157
169
  else if (flag === "--check") options.check = value;
158
170
  else if (flag === "--force") {
159
171
  options.force = true;
160
172
  i -= 1;
161
173
  } else if (flag === "--help" || flag === "-h") {
162
- console.log("node scripts/profile-preset.mjs [--distro NAME] [--session-sandbox true|false|auto] [--sandbox true|false] [--mask-windows-drive true|false] [--agent-backend auto|native|shell] [--out FILE] [--check FILE] [--force]");
174
+ console.log("node scripts/profile-preset.mjs [--distro NAME] [--session-sandbox true|false|auto] [--sandbox true|false] [--mask-windows-drive true|false] [--agent-backend auto|native|shell] [--writable-roots 'PATH,...'] [--out FILE] [--check FILE] [--force]");
163
175
  process.exit(0);
164
176
  } else throw new Error(`profile-preset: unknown option "${arg}"`);
165
177
  }