dsh-wsl-workspace 0.3.0 → 0.3.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/TESTING.md +80 -0
- package/package.json +2 -1
package/TESTING.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
This document describes how to verify `dsh-wsl-workspace` after a change or before a release. The suite covers unit tests, the preset-materialization integration test, a real-WSL smoke test, and a post-build lib verification gate.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Windows host with WSL2 and at least one distribution installed (`wsl.exe` on `PATH`).
|
|
8
|
+
- Node.js 24+ (the tests run with Node's built-in TypeScript support; `tsx` is not required).
|
|
9
|
+
- The DeepSeek Harness checkout (for `tsc`/`tsdown` and the `@deepseek-ai/*` type declarations the `tsconfig.json` paths point at).
|
|
10
|
+
|
|
11
|
+
## Unit tests
|
|
12
|
+
|
|
13
|
+
Run the unit tests from the plugin directory:
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
node --experimental-strip-types --test tests/variants.test.ts tests/fs-execution-context.test.ts tests/shell.test.ts tests/paths.test.ts
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Coverage:
|
|
20
|
+
|
|
21
|
+
| File | What it verifies |
|
|
22
|
+
|---|---|
|
|
23
|
+
| `tests/variants.test.ts` | The WSL preset-variant transform: world rows are dropped, the WSL realm is injected, `str-replace-editor` is re-injected exactly once (and only when the source references it), prefab-family rows (`custom-bash`, `bootstrap-filesystem`) are removed, unknown rows are preserved verbatim. |
|
|
24
|
+
| `tests/fs-execution-context.test.ts` | `WslFileSystem` inherits the calling session's cwd through `AsyncLocalStorage` on `tools/execute`; agentless calls fall back to the configured distro. |
|
|
25
|
+
| `tests/shell.test.ts` | The login-shell `cd` prefix preserves the resolved workdir (including single-quote escaping); non-login shells leave the command unchanged. |
|
|
26
|
+
| `tests/paths.test.ts` | UNC ↔ Linux path translation, `/mnt/<drive>` mapping, canonical Windows path keys, WSL username validation. |
|
|
27
|
+
|
|
28
|
+
## Preset materialization integration test
|
|
29
|
+
|
|
30
|
+
Boots the host plugin's `apply()` against a fake context with `DSH_HOME` pointed at a temp directory, then asserts the generated variant rows reference real built lib files and the composition carries the WSL execution-world realm:
|
|
31
|
+
|
|
32
|
+
```powershell
|
|
33
|
+
node tests/host-materialize.mjs
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This covers variant generation, opaque source-directory mirroring (third-party assets travel with the variant), atomic publication (a failed regeneration preserves the previous complete variant), stale-variant cleanup, and legacy `wsl` preset removal.
|
|
37
|
+
|
|
38
|
+
## Real-WSL smoke test
|
|
39
|
+
|
|
40
|
+
Requires a running WSL distribution (the first listed distro is used; infrastructure distros such as `docker-desktop` are skipped):
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
node --experimental-strip-types tests/smoke.ts
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This exercises the filesystem round-trip (resolve/write/read/edit/stat/version/listDir/contains/fileUrl), bash execution inside WSL (cwd translation, WSLENV pass-through, stdin, background jobs), Linux-workdir resolution through the session distro fact, `/mnt/<drive>` dual access, and the no-config default-distro fallback.
|
|
47
|
+
|
|
48
|
+
## Post-build lib verification
|
|
49
|
+
|
|
50
|
+
`scripts/verify-lib.mjs` parses every `lib/*.js` entry and fails the build when a bare call to a Node builtin export has no matching `node:*` import. This catches the class of bug where a symbol is used but never imported (for example `statSync` in 0.2.3, which made the Add-WSL-Workspace dialog report every path as non-existent at runtime):
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
node scripts/verify-lib.mjs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The `build` script chains it after `tsdown`:
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
pnpm build # tsdown && node scripts/verify-lib.mjs
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## End-to-end verification in the running harness
|
|
63
|
+
|
|
64
|
+
After installing the plugin into a profile and restarting `dsh web`:
|
|
65
|
+
|
|
66
|
+
1. The **W** button appears beside Settings at the sidebar foot.
|
|
67
|
+
2. Open "Add WSL workspace…", browse to a directory (e.g. `/home`), and click "Create & open" — the workspace must be created without a "path does not exist" error.
|
|
68
|
+
3. In the new session, the mode picker shows the WSL variant (e.g. `WSL · Standard mode(标准模式)`); the bash tool runs inside the distribution (`pwd` returns a Linux path, `uname -s` returns `Linux`).
|
|
69
|
+
4. `read`/`write`/`edit` operate on WSL files; Windows files stay reachable under `/mnt/<drive>`.
|
|
70
|
+
5. Switch modes (Standard / PTC / Minimal / Creative) — each lands on its WSL variant and the tool catalog matches the mode.
|
|
71
|
+
6. The plugin API responds correctly: `POST /wsl-workspace/api` with `{"method":"check","params":{"distro":"<distro>","path":"/home"}}` returns `{"ok":true,"value":{"exists":true,"isDirectory":true}}`.
|
|
72
|
+
|
|
73
|
+
## Release checklist
|
|
74
|
+
|
|
75
|
+
1. `pnpm build` — rebuilds `lib/` and runs the verification gate.
|
|
76
|
+
2. `node --experimental-strip-types --test tests/variants.test.ts tests/fs-execution-context.test.ts tests/shell.test.ts tests/paths.test.ts` — all green.
|
|
77
|
+
3. `node tests/host-materialize.mjs` — all assertions pass.
|
|
78
|
+
4. `node --experimental-strip-types tests/smoke.ts` — real-WSL round-trip passes.
|
|
79
|
+
5. `npm pack --dry-run` — confirm the tarball carries only live `lib/` chunks, `src/`, `cordis.patch.yml`, READMEs, `LICENSE`, and `NOTICE`.
|
|
80
|
+
6. Install the tarball into a clean profile (`dsh plugin --profile web add <tarball>`), restart `dsh web`, and run the end-to-end checks above.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-wsl-workspace",
|
|
3
3
|
"description": "WSL workspace support for DeepSeek Harness: add a WSL workspace from the web GUI and run the whole agent session (bash + file tools) inside the WSL distribution, VS Code Remote-WSL style. No toolchain install inside WSL required.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"src",
|
|
57
57
|
"LICENSE",
|
|
58
58
|
"NOTICE",
|
|
59
|
+
"TESTING.md",
|
|
59
60
|
"README.md",
|
|
60
61
|
"README.zh.md",
|
|
61
62
|
"README.ja.md",
|