dsh-plugin-wsl-env 0.6.0 → 0.7.2
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 +176 -0
- package/README.md +6 -6
- package/cordis.patch.yml +48 -0
- package/docs/ARCHITECTURE.md +33 -20
- package/docs/CONFIGURATION.md +2 -2
- package/docs/LIMITATIONS.md +52 -54
- package/docs/PARITY.md +18 -4
- package/docs/README.zh.md +7 -7
- package/lib/fs-decisions.js +22 -25
- package/lib/fs-routing.js +176 -0
- package/lib/git-route.js +142 -0
- package/lib/index.js +77 -307
- package/lib/listing.js +47 -0
- package/lib/picker.js +121 -17
- package/lib/search-exec.js +114 -0
- package/lib/search-route.js +95 -0
- package/lib/subprocess.js +153 -16
- package/lib/terminal-activity.js +121 -0
- package/lib/workspace-files-route.js +205 -0
- package/lib/workspace-files-wsl.js +341 -0
- package/lib/wsl.js +0 -39
- package/package.json +22 -3
- package/lib/fs-publish.js +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,182 @@ reference below points at that record's numbering.
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [0.7.2] - 2026-10-05
|
|
16
|
+
|
|
17
|
+
One theme: the root-plane routing lands - and the composition that
|
|
18
|
+
silently dropped it and the workspace-files takeover is repaired and
|
|
19
|
+
pinned by a test that runs the plugin's real patch file through the
|
|
20
|
+
loader's real patch algorithm.
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **The root-plane filesystem routes by coordinate.** The root `ctx.fs`
|
|
25
|
+
(behind the GUI's change feed and every un-mounted root consumer) is
|
|
26
|
+
replaced by a coordinate-routing variant (`lib/fs-routing.js`): distro UNC
|
|
27
|
+
identities are served by the resident agent - ext4 reads, and real watch
|
|
28
|
+
events for the change feed, which previously never fired on a 9p share -
|
|
29
|
+
while drive paths stay host-native. The root write fence retires with this
|
|
30
|
+
round: the root plane has no write consumers (the model's writes ride the
|
|
31
|
+
preset filesystems, which enforce their own containment). Design note:
|
|
32
|
+
`docs/root-fs-routing.md`.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **The 0.7.1 composition never mounted what it announced.** The
|
|
37
|
+
`workspace-files` disable, the `fs-sandbox` disable, and both replacement
|
|
38
|
+
rows were written inside a bare `insert:` list — but a patch layer is a
|
|
39
|
+
flat list: an `insert` list is data to append, never nested patches. The
|
|
40
|
+
loader therefore mounted the two disable rows as duplicate-id anonymous
|
|
41
|
+
entries that *shadowed the real upstream rows* (`EntryGroup.update` keys
|
|
42
|
+
rows by id, last occurrence wins): the running app had no root `ctx.fs`
|
|
43
|
+
and no GUI file-tree service at all, while `fs-routing` and
|
|
44
|
+
`workspace-files-wsl` - trapped inside nested `insert:` lists - never
|
|
45
|
+
started. Opening a distro workspace failed accordingly. Both takeovers are
|
|
46
|
+
now top-level entries: disable by id, then append the replacement with a
|
|
47
|
+
bare insert. `test/composition.test.mjs` runs the plugin's actual patch
|
|
48
|
+
file through the loader's actual `applyEntryPatches` over stand-in
|
|
49
|
+
upstream rows, asserting every composed row is a real named entry, ids
|
|
50
|
+
stay unique, the shipped rows are disabled under their own names, and
|
|
51
|
+
both replacements mount - the shape cannot regress silently again.
|
|
52
|
+
- The terminal-activity live check marked its shell with a runtime
|
|
53
|
+
`export`, which `/proc/<pid>/environ` never shows (it reflects the
|
|
54
|
+
exec-time block only), so the probe could never count past one and the
|
|
55
|
+
busy assertion failed deterministically. The marker now rides the spawn
|
|
56
|
+
environment - what `wsl.exe` does when it imports `DSH_TERMINAL_ID`
|
|
57
|
+
before `--exec`.
|
|
58
|
+
|
|
59
|
+
## [0.7.1] - 2026-10-04
|
|
60
|
+
|
|
61
|
+
One theme: the remaining root-plane 9P consumers move inside the distro -
|
|
62
|
+
the GUI file tree and previews, and the workspace-changes git snapshots -
|
|
63
|
+
plus the test-infrastructure maturity (a REAL-composition boot test and
|
|
64
|
+
the pure text-mechanics refusals under direct unit test) that the
|
|
65
|
+
promotion work was built on.
|
|
66
|
+
|
|
67
|
+
### Added
|
|
68
|
+
|
|
69
|
+
- **git snapshot commands run the distro's git.** `workspace-changes`
|
|
70
|
+
snapshots a workspace by spawning the host git through
|
|
71
|
+
`ctx.subprocess.spawn` — on a distro workspace that was Windows git
|
|
72
|
+
scanning the full work tree across the 9p share, the most
|
|
73
|
+
metadata-heavy operation there is. Spawns whose working directory names
|
|
74
|
+
a distro and whose argv carries none of the absolute-output discovery
|
|
75
|
+
flags are rewritten into `wsl.exe -d <distro> --cd <linux dir> --exec
|
|
76
|
+
git …` (`lib/git-route.js`). The snapshot is safe to route because it
|
|
77
|
+
already runs in a fully isolated git environment (`GIT_INDEX_FILE` /
|
|
78
|
+
`GIT_OBJECT_DIRECTORY` / `GIT_ALTERNATE_OBJECT_DIRECTORIES` in the
|
|
79
|
+
tool's private scratch — the repository's index, object store, work
|
|
80
|
+
tree, and refs stay unchanged); the route translates those path-shaped
|
|
81
|
+
env values into distro coordinates and forwards them through `WSLENV`.
|
|
82
|
+
Verified against a live distro: the snapshot sequence completes with the
|
|
83
|
+
user's index, object store, and refs untouched.
|
|
84
|
+
- **The GUI file tree and previews are served from inside the distro.**
|
|
85
|
+
`workspace-files` - the root-plane consumer behind the GUI's file tree
|
|
86
|
+
and previews - read UNC workspaces through the 9p share. The plugin
|
|
87
|
+
replaces the composition row with a distro-routed variant
|
|
88
|
+
(`lib/workspace-files-wsl.js`): listings, stats, line-paged reads and
|
|
89
|
+
byte windows for a \\wsl.localhost\\<distro> workspace run through the
|
|
90
|
+
resident agent, with the upstream refusals mirrored (not-found,
|
|
91
|
+
outside-workspace, not-directory, not-regular-file, too-large,
|
|
92
|
+
not-text) and `absolutePath` synthesized in the UNC display form so
|
|
93
|
+
the GUI is unchanged. Windows-folder sessions keep the shipped
|
|
94
|
+
host-backed service; the watch stream delegates unchanged.
|
|
95
|
+
(`lib/workspace-files-route.js` holds the pure builders/parsers;
|
|
96
|
+
`test/workspace-files-wsl.test.mjs` covers every wire shape and refusal
|
|
97
|
+
over a fake agent runner.)
|
|
98
|
+
- **bootstrap installs and reports git.** The git snapshot routing needs
|
|
99
|
+
git inside the distro; `bootstrap --install` includes it in every
|
|
100
|
+
package manager's list and the report names it alongside ripgrep (the
|
|
101
|
+
snapshot backend for workspace-changes).
|
|
102
|
+
- **A REAL-composition boot test.** The plugin's fs row is booted through
|
|
103
|
+
the cordis Loader from a test-only yml composition and asserted against
|
|
104
|
+
a live distro read (`test/fs.boot.test.mjs`), alongside direct unit
|
|
105
|
+
tests for the pure text mechanics' refusal edges
|
|
106
|
+
(`test/fsio-text.test.mjs`).
|
|
107
|
+
|
|
108
|
+
## [0.7.0] - 2026-10-04
|
|
109
|
+
|
|
110
|
+
One theme: the 9p share is out of the model's reach. Two changes land together
|
|
111
|
+
because they close the same measured gap — the file-search spawn was the one
|
|
112
|
+
model-facing I/O path that still crossed the share, in its slow direction
|
|
113
|
+
(~2 s per search where the distro's own rg answers in single-digit
|
|
114
|
+
milliseconds; `\\wsl.localhost` metadata round trips at ~17 ms per file), and
|
|
115
|
+
the share substrate was the configured way back onto that path.
|
|
116
|
+
|
|
117
|
+
### Added
|
|
118
|
+
|
|
119
|
+
- **The directory picker lists distro levels from inside the distro.** A level
|
|
120
|
+
under `\\wsl.localhost\<distro>` is served by the resident agent's
|
|
121
|
+
`ls -1ALp` in one round trip — a one-shot `wsl.exe --exec ls` when the
|
|
122
|
+
resident is out, never the host's 9p walk, which paid one metadata round
|
|
123
|
+
trip per entry plus one more per symlink, in the share's slow direction.
|
|
124
|
+
`-L` folds the per-entry symlink stat the host walk used to pay; `-p`'s
|
|
125
|
+
trailing `/` is what the row parser keys on, and a broken link drops out
|
|
126
|
+
exactly as the old per-entry `stat` dropped it. `createDirectory` follows
|
|
127
|
+
the same route (`mkdir` through the agent, one-shot otherwise). The parse
|
|
128
|
+
is the pure `parseLsListing`/`lsListingArgv` pair in `lib/listing.js`
|
|
129
|
+
(`test/listing.test.mjs`); the accepted limitation — a filename containing
|
|
130
|
+
a newline would split into two rows — is documented in LIMITATIONS.md.
|
|
131
|
+
- **The file search runs the distro's own rg.** `WslSubprocessRuntime` now
|
|
132
|
+
overrides `spawn` beside `spawnTerminal`: a spawn of the packaged ripgrep
|
|
133
|
+
binary whose working directory names a distro (a `\\wsl.localhost\<distro>`
|
|
134
|
+
UNC — the form every distro workspace search carries) is rewritten into
|
|
135
|
+
`wsl.exe -d <distro> --cd <linux dir> --exec rg …` with every argument
|
|
136
|
+
forwarded verbatim, so the tool reads the distro rg's output format and exit
|
|
137
|
+
codes unchanged. The decision is the peer-free `lib/search-route.js`
|
|
138
|
+
(mirroring `terminal-route.js`), and the rewrite delegates to the shipped
|
|
139
|
+
spawn — the handle still wraps a real host process, so the consumer's output
|
|
140
|
+
budget, spill machinery and teardown all work unchanged. One guard rides
|
|
141
|
+
the rewrite: when the tool named no search path (its pattern rides
|
|
142
|
+
`--regexp=`; a bare `--` is how it spells a path), the rewrite appends
|
|
143
|
+
`-- .` — because `wsl.exe --exec` hands distro-side rg a relay fifo on
|
|
144
|
+
stdin, and rg's readable-stdin heuristic then searches stdin instead of the
|
|
145
|
+
directory. The packaged binary saw a non-readable NUL stdin under the old
|
|
146
|
+
path, which is why the heuristic never fired there. A drive-path
|
|
147
|
+
directory keeps the host binary, which is native there; a distro without rg
|
|
148
|
+
surfaces rg's own "command not found" (exit 127) instead of a silent fall
|
|
149
|
+
back to the share — `npm run bootstrap -- <distro> --install` installs it.
|
|
150
|
+
There is no 9p path left to fall back to, by design. (`test/search-route.test.mjs`.)
|
|
151
|
+
- **The search rides the warm resident, not a one-shot spawn.** The rewrite's
|
|
152
|
+
distro command is exec'd by the resident agent — one round trip (~10 ms)
|
|
153
|
+
instead of a `wsl.exe` process startup (~400 ms) per search. The tool's
|
|
154
|
+
handle surface is small (`done` plus `collected`), and `lib/search-exec.js`
|
|
155
|
+
builds exactly that facade: the agent's out state is the lazy fallback cue,
|
|
156
|
+
delegating to the one-shot `wsl.exe --exec` handle inside `done` — never an
|
|
157
|
+
error, never the share. The tool's output budget rides the agent's
|
|
158
|
+
per-stream capture cap; cancellation and `kill()` abort the agent exec and
|
|
159
|
+
settle as the killed outcome the one-shot path reports.
|
|
160
|
+
(`test/search-exec.test.mjs`.)
|
|
161
|
+
- **Idle distro terminals are reclaimed.** The controller reclaims an
|
|
162
|
+
unattended terminal after 2 h of observed idleness, but its observation is
|
|
163
|
+
host-side and a distro terminal can never answer it: the shipped
|
|
164
|
+
shell-activity integration is gated to interactive `bash`/`zsh` launched
|
|
165
|
+
directly on a POSIX host, every branch of `inspectActivity` settles on
|
|
166
|
+
`unknown` for a `wsl.exe` terminal, and `unknown` never accumulates idle —
|
|
167
|
+
so distro terminals had to be closed by hand. The terminal is now marked at
|
|
168
|
+
launch (a per-terminal `DSH_TERMINAL_ID` through the existing `WSLENV`
|
|
169
|
+
forwarding) and its `inspectActivity` counts the marked processes through
|
|
170
|
+
the resident agent: exactly one (the shell at its prompt) is idle, more
|
|
171
|
+
than one (a running command or a nested shell) is busy, and the agent
|
|
172
|
+
being out answers `unknown` — reclamation pauses, because a probe that
|
|
173
|
+
cannot answer must not authorize a close. A nested shell keeps the
|
|
174
|
+
terminal busy by design, as does anything a shell's startup files spawn
|
|
175
|
+
with the inherited marker. `terminalIdleReclaim: false` restores
|
|
176
|
+
close-by-hand. (`lib/terminal-activity.js`, `test/terminal-activity.test.mjs`.)
|
|
177
|
+
|
|
178
|
+
### Breaking changes
|
|
179
|
+
|
|
180
|
+
- **`substrate: "share"` is refused at construction.** The Windows-side share
|
|
181
|
+
backend was the file tools' opt-out onto the 9p share; the resident agent
|
|
182
|
+
serves every distro read and write, and no file tool crosses the share any
|
|
183
|
+
more. A profile still carrying the value fails to boot with the migration
|
|
184
|
+
(`shareSubstrateRefusal`): delete the `substrate` line or set it to
|
|
185
|
+
`"agent"`. The failure message for an agent that is out
|
|
186
|
+
(`substrateFailure`) no longer offers the share as a way out and names the
|
|
187
|
+
recovery path instead. The share-only plumbing (the symlink retry, the 9p
|
|
188
|
+
publication hooks, and the `agent` and `resolveSymlinks` keys that gated
|
|
189
|
+
them) is removed with this change — `lib/fs-publish.js` with it.
|
|
190
|
+
|
|
15
191
|
## [0.6.0] - 2026-10-04
|
|
16
192
|
|
|
17
193
|
One theme: the P2 backlog from the 2026-10-03 review, closed with the same
|
package/README.md
CHANGED
|
@@ -57,11 +57,11 @@ Override a row by id in `$DSH_HOME/profiles/<name>/cordis.patch.yml`. The keys w
|
|
|
57
57
|
| `wsl-fs` | `distro` | `''` | as above |
|
|
58
58
|
| | `restrictToDistro` | `true` | refuse a path in **another distro**'s share; `/mnt/c` is inside this distro and is not affected. Refused with `FS_OUTSIDE_DISTRO`, which is not a sandbox denial and cannot be lifted by wider permissions |
|
|
59
59
|
| | `sandbox` | `true` | check `writeText` and `editText` against the policy |
|
|
60
|
-
| | `substrate` | `agent` | which I/O substrate serves the file tools
|
|
60
|
+
| | `substrate` | `agent` | which I/O substrate serves the file tools. Only the resident in-distro agent remains: reads, writes and identities run on ext4 (native symlinks and mode bits; the write guard survives to publication, kernel-enforced under a confined policy). The former `"share"` opt-out — the Windows-side host stack over the 9p share — is refused at boot; no file tool crosses the share |
|
|
61
61
|
| `directory-picker-wsl` | `includeHostHome` | `true` | also list the Windows home directory |
|
|
62
62
|
| `subprocess-wsl` | `distro` | `''` | which distro the GUI terminal opens in |
|
|
63
63
|
|
|
64
|
-
[`cordis.patch.yml`](cordis.patch.yml) is the commented reference for every shipped value. [docs/CONFIGURATION.md](docs/CONFIGURATION.md) lists the rest, including `shell`, `loginShell`, `cwd`, `timeoutMs`, `
|
|
64
|
+
[`cordis.patch.yml`](cordis.patch.yml) is the commented reference for every shipped value. [docs/CONFIGURATION.md](docs/CONFIGURATION.md) lists the rest, including `shell`, `loginShell`, `cwd`, `timeoutMs`, `preferredDistro` and `maxEntries`; [examples/profile.cordis.patch.yml](examples/profile.cordis.patch.yml) is a machine-local layer to copy from.
|
|
65
65
|
|
|
66
66
|
## Recipes
|
|
67
67
|
|
|
@@ -74,7 +74,7 @@ Override a row by id in `$DSH_HOME/profiles/<name>/cordis.patch.yml`. The keys w
|
|
|
74
74
|
(`/home/...`) on the distro's own ext4. `/mnt/c` reaches the Windows disk over
|
|
75
75
|
9p — noticeably slow for many small files; keep heavy-IO projects on the
|
|
76
76
|
distro filesystem. `npm run bootstrap -- <distro>` also reports whether
|
|
77
|
-
ripgrep and inotifywait (the search and watch backends) are in place.
|
|
77
|
+
ripgrep, git and inotifywait (the search, snapshot and watch backends) are in place.
|
|
78
78
|
- **WSLENV passthrough**: WSL imports only the variables listed in `WSLENV`.
|
|
79
79
|
This plugin admits the managed `DSH_*` namespace by prefix, translating the
|
|
80
80
|
two Windows-path ones (`DSH_HOME`, `DSH_PROFILE_DIR`) with `/p`. `PATH` is
|
|
@@ -100,7 +100,7 @@ preset-wsl (the wsl agent preset; its services run in isolate realms)
|
|
|
100
100
|
|
|
101
101
|
**Why two levels.** `wsl-shell` and `wsl-fs` live inside the `wsl` agent preset, which `auto-preset` binds whenever a session's workspace is inside the distro: a Windows-folder session keeps the stock providers, a distro session gets the WSL ones — the environment is a property of the session, not of the process. The terminal controller is the exception: it resolves its execution world through the root context, which never sees a preset's isolate realms, so `subprocess-wsl` sits at the composition level instead.
|
|
102
102
|
|
|
103
|
-
**Commands and files.** A command runs as `wsl.exe -d <distro> --cd <linux dir> --exec <login shell> -lc <cmd>` inside a distro-side bubblewrap profile assembled with the same arguments as DSH's own Linux runner, so confinement semantics and error messages match a Linux host. The file tools read and write real distro files on
|
|
103
|
+
**Commands and files.** A command runs as `wsl.exe -d <distro> --cd <linux dir> --exec <login shell> -lc <cmd>` inside a distro-side bubblewrap profile assembled with the same arguments as DSH's own Linux runner, so confinement semantics and error messages match a Linux host. The file tools read and write real distro files on the resident in-distro agent — reads, writes and identities run on ext4 with native symlinks and mode bits — and the file-search spawn is rewritten the same way: a search over a distro workspace runs the distro's own `rg` (`wsl.exe --exec`), never the Windows binary over the 9p share. Writes are checked against the same policy the command sandbox enforces.
|
|
104
104
|
|
|
105
105
|
## Sandbox
|
|
106
106
|
|
|
@@ -129,8 +129,8 @@ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#sandbox) for the design, and [do
|
|
|
129
129
|
| the terminal still opens `cmd.exe` | the `terminal-controller` row from the layer did not apply | check that `dsh --profile wsl --dump-config` shows `shell: { path: wsl.exe, name: WSL }` |
|
|
130
130
|
| changes to `lib/` have no effect | ES module cache | restart the app |
|
|
131
131
|
| `link:\\wsl.localhost\...` leaves a broken symlink | pnpm cannot link a UNC path | link a Windows path instead; developing inside the distro needs the runtime mirror, see [Development](#development) |
|
|
132
|
-
| `glob` and `grep` are slow | the Windows-
|
|
133
|
-
| the terminal reports `unknown` activity |
|
|
132
|
+
| `glob` and `grep` are slow | a distro search without rg inside the distro falls back to rg's own "command not found"; a Windows-folder search is native and unaffected | run `npm run bootstrap -- <distro> --install` (installs ripgrep); distro searches always run the distro's rg — they never walk the 9p share |
|
|
133
|
+
| the terminal reports `unknown` activity | only while the resident agent is out — distro terminals are observed from inside the distro (a `DSH_TERMINAL_ID` marker scanned in `/proc`: a shell alone is `idle`, a shell running anything is `busy`) | check the distro is running; idle terminals are reclaimed automatically after the controller's unattended timeout (2 h by default), and `terminalIdleReclaim: false` restores the close-by-hand posture |
|
|
134
134
|
| a result names an `FS_*` code | the code says what refused it, and what clears it | see the error-code table in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#error-codes) |
|
|
135
135
|
|
|
136
136
|
## Development
|
package/cordis.patch.yml
CHANGED
|
@@ -102,6 +102,54 @@
|
|
|
102
102
|
|
|
103
103
|
- id: directory-picker-browse-surface
|
|
104
104
|
name: '@deepseek-ai/dsh-client-ui-directory-picker-browse'
|
|
105
|
+
|
|
106
|
+
# ═════════════════════════════════════════════════════════════════════════════
|
|
107
|
+
# The distro-side takeovers of the two root-plane services.
|
|
108
|
+
#
|
|
109
|
+
# A patch layer is a flat list: an `id:` entry patches the shipped row, and a
|
|
110
|
+
# bare `insert:` list appends new rows as data. A disable written INSIDE an
|
|
111
|
+
# insert list is not a patch — it becomes a duplicate-id data row that shadows
|
|
112
|
+
# the real service row (the loader keys rows by id, last occurrence wins), and
|
|
113
|
+
# a nested `insert:` list is never interpreted at all. Both takeovers are
|
|
114
|
+
# therefore two top-level entries: disable the shipped row by id, then append
|
|
115
|
+
# the replacement with a bare insert. test/composition.test.mjs runs this file
|
|
116
|
+
# through the real patch algorithm to keep the shape honest.
|
|
117
|
+
# ═════════════════════════════════════════════════════════════════════════════
|
|
118
|
+
|
|
119
|
+
# The GUI file tree and previews for a distro workspace are served from inside
|
|
120
|
+
# the distro (resident agent) instead of Windows-side 9P walks. The variant
|
|
121
|
+
# extends the shipped service — a distro UNC routes distro-side, a drive path
|
|
122
|
+
# calls super (host native), the watch stream delegates unchanged — so
|
|
123
|
+
# replacing the row is safe for Windows-folder sessions too.
|
|
124
|
+
- id: workspace-files
|
|
125
|
+
disabled: true
|
|
126
|
+
|
|
127
|
+
# The root-plane filesystem routes by coordinate: distro UNC identities are
|
|
128
|
+
# served by the resident agent (real watch events, ext4 reads), drive paths
|
|
129
|
+
# stay host-native. Replaces the root fs-sandbox row, whose write fence has no
|
|
130
|
+
# root-plane consumers (the model's writes ride the preset filesystems; see
|
|
131
|
+
# docs/root-fs-routing.md).
|
|
132
|
+
- id: fs-sandbox
|
|
133
|
+
disabled: true
|
|
134
|
+
|
|
135
|
+
- insert:
|
|
136
|
+
- id: workspace-files-wsl
|
|
137
|
+
name: 'dsh-plugin-wsl-env/workspace-files-wsl'
|
|
138
|
+
config:
|
|
139
|
+
maxBytes: 2097152
|
|
140
|
+
maxFileBytes: 33554432
|
|
141
|
+
maxLines: 5000
|
|
142
|
+
maxEntries: 2000
|
|
143
|
+
|
|
144
|
+
- id: fs-routing
|
|
145
|
+
name: 'dsh-plugin-wsl-env/fs-routing'
|
|
146
|
+
config:
|
|
147
|
+
distro: ''
|
|
148
|
+
wslPath: wsl.exe
|
|
149
|
+
sandbox: true
|
|
150
|
+
maskWindowsDrive: false
|
|
151
|
+
restrictToDistro: true
|
|
152
|
+
watchMaxDepth: 0
|
|
105
153
|
# Contributes the WSL environment's facts (distro / real shell / home) to the
|
|
106
154
|
# managed DSH_* namespace that dsh-shell-env injects into every model shell
|
|
107
155
|
# call. That is DSH's sanctioned channel for shell-environment facts.
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -19,8 +19,8 @@ smaller integrations.
|
|
|
19
19
|
| Service | Class | File | What it does |
|
|
20
20
|
|---|---|---|---|
|
|
21
21
|
| `ctx.shell` | `WslShellExecutor` | [`lib/index.js`](../lib/index.js) | Runs each command as `wsl.exe -d <distro> --cd <linux dir> --exec <login shell> -lc <cmd>`, wrapped in a distro-side `bwrap` sandbox. |
|
|
22
|
-
| `ctx.fs` | `WslFileSystem` | [`lib/index.js`](../lib/index.js) | Serves the file tools from real distro files
|
|
23
|
-
| `ctx.subprocess` | `WslSubprocessRuntime` | [`lib/subprocess.js`](../lib/subprocess.js) | Opens the GUI terminal inside the distro, in the session workspace. |
|
|
22
|
+
| `ctx.fs` | `WslFileSystem` | [`lib/index.js`](../lib/index.js) | Serves the file tools from real distro files on the resident in-distro agent, on ext4 — the former Windows-side share substrate is retired (see below). |
|
|
23
|
+
| `ctx.subprocess` | `WslSubprocessRuntime` | [`lib/subprocess.js`](../lib/subprocess.js) | Opens the GUI terminal inside the distro, in the session workspace, and rewrites the file-search spawn into the distro's own rg (see below). |
|
|
24
24
|
|
|
25
25
|
`WslShellExecutor` extends the shipped `LocalBashExecutor`, and `WslFileSystem`
|
|
26
26
|
extends the shipped `LocalFileSystem`. Only the parts that need a distro are
|
|
@@ -30,7 +30,7 @@ overridden.
|
|
|
30
30
|
|
|
31
31
|
| Subpath | Class or name | File | What it does |
|
|
32
32
|
|---|---|---|---|
|
|
33
|
-
| `dsh-plugin-wsl-env/picker` | `WslDirectoryPicker` | [`lib/picker.js`](../lib/picker.js) | Adds the installed distros to the folder picker, next to the Windows home directory. |
|
|
33
|
+
| `dsh-plugin-wsl-env/picker` | `WslDirectoryPicker` | [`lib/picker.js`](../lib/picker.js) | Adds the installed distros to the folder picker, next to the Windows home directory, and lists distro levels from inside the distro (the resident's `ls`, one-shot `wsl.exe` when it is out). |
|
|
34
34
|
| `dsh-plugin-wsl-env/auto-preset` | `auto-preset` | [`lib/auto-preset.js`](../lib/auto-preset.js) | Binds the `wsl` agent preset when a new session's workspace is inside a distro. |
|
|
35
35
|
| `dsh-plugin-wsl-env/shell-env` | `wsl-shell-env` | [`lib/shell-env.js`](../lib/shell-env.js) | Contributes `DSH_WSL_DISTRO`, `DSH_WSL_SHELL`, and `DSH_WSL_HOME` to the managed `DSH_*` namespace. |
|
|
36
36
|
|
|
@@ -89,7 +89,7 @@ Three coordinate systems appear in the code:
|
|
|
89
89
|
| System | Example | Used by |
|
|
90
90
|
|---|---|---|
|
|
91
91
|
| Linux inside the distro | `/home/you/proj/a.ts` | commands, `ctx.shell` |
|
|
92
|
-
| The distro's UNC share | `\\wsl.localhost\ubuntu\home\you\proj\a.ts` | the
|
|
92
|
+
| The distro's UNC share | `\\wsl.localhost\ubuntu\home\you\proj\a.ts` | the harness's path identities (`ctx.fs` target keys), the picker and terminal routing — a coordinate, not an I/O path: no file tool reads or writes through the share |
|
|
93
93
|
| The Windows filesystem | `C:\Users\you\...`, or `/mnt/c/Users/you/...` from inside | sessions opened on a Windows folder |
|
|
94
94
|
|
|
95
95
|
[`lib/paths.js`](../lib/paths.js) converts between them. It is pure: it imports no
|
|
@@ -98,22 +98,35 @@ path sits under a writable root. The filesystem fence uses them.
|
|
|
98
98
|
|
|
99
99
|
## The filesystem substrate
|
|
100
100
|
|
|
101
|
-
`wsl-fs` serves `ctx.fs` on one
|
|
102
|
-
`substrate: share
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
(
|
|
116
|
-
|
|
101
|
+
`wsl-fs` serves `ctx.fs` on one I/O substrate: the resident in-distro agent.
|
|
102
|
+
The former Windows-side share backend (`substrate: "share"`) is retired — a
|
|
103
|
+
profile carrying the value is refused at boot, and no file tool crosses the
|
|
104
|
+
9p share. The substrate's facts:
|
|
105
|
+
|
|
106
|
+
- **Reads, writes, identities** run on ext4 through the resident; symlinks and
|
|
107
|
+
mode bits are native (every identity is a distro-side `realpath`; the
|
|
108
|
+
publication rename is the kernel's).
|
|
109
|
+
- **Guarded writes** carry their intent to the publication: a `createIfAbsent`
|
|
110
|
+
publishes with a no-replace link, closing the check-then-write window for
|
|
111
|
+
creates outright; an overwrite or edit carries its version into the write op
|
|
112
|
+
and the agent re-verifies it one syscall before the rename — a concurrent
|
|
113
|
+
writer wins, the stale write refuses with `FS_STALE_VERSION`.
|
|
114
|
+
- **Kernel enforcement** is stage two: a mutation runs on a confined resident —
|
|
115
|
+
one long-lived agent per (distro, policy), whose bwrap profile binds exactly
|
|
116
|
+
what the mode grants — so the kernel refuses what the check would have, and a
|
|
117
|
+
check bug cannot become a write outside the workspace. Escalated writes
|
|
118
|
+
(`danger-full-access`) ride the plain resident. A kernel refusal carries
|
|
119
|
+
`FS_SANDBOX_DENIED`, the same dialect as the command path.
|
|
120
|
+
- **New files** publish 0600 — the host backend's own POSIX publication
|
|
121
|
+
semantics, as on a Linux host.
|
|
122
|
+
- **Agent outage** fails closed: `FS_IO_ERROR` naming the substrate and the
|
|
123
|
+
recovery path. There is no fallback I/O; a distro without usable bwrap
|
|
124
|
+
refuses confined mutations with the bootstrap command, the same closed
|
|
125
|
+
failure the command path has.
|
|
126
|
+
|
|
127
|
+
Writes fence with the same host-side policy check (`checkedTarget`) the
|
|
128
|
+
command path uses, and the substrate does not change what `sandboxMode`
|
|
129
|
+
reports. The wire protocol the substrate speaks is documented in
|
|
117
130
|
[`agent/wsl-agent.sh`](../agent/wsl-agent.sh); the orchestration layers are
|
|
118
131
|
[`lib/fsio-agent.js`](../lib/fsio-agent.js) (fsio's mechanics over the FS
|
|
119
132
|
frames), [`lib/fs-substrate.js`](../lib/fs-substrate.js) (the provider-shaped
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -23,8 +23,7 @@ are schema defaults, listed because they are the ones worth knowing.
|
|
|
23
23
|
| | `restrictToDistro` | `true` *(shipped)* | refuse a path in **another distro**'s share. `/mnt/c` is a directory *inside* the pinned distro, so it is not affected. The refusal carries `FS_OUTSIDE_DISTRO`; that is not a sandbox decision, so the file tools do not offer a wider permission for it. Set `false` to allow another distro's share |
|
|
24
24
|
| | `sandbox` | `true` | check `writeText` and `editText` against the policy |
|
|
25
25
|
| | `maskWindowsDrive` | `false` | as on `wsl-shell`: confined fs mutations publish through a resident whose profile shadows `/mnt` (same honest limits) |
|
|
26
|
-
| | `substrate` | `agent` *(shipped)* | which I/O substrate serves the file tools
|
|
27
|
-
| | `resolveSymlinks` | `true` | *(share substrate only)* follow Linux symlinks that the share cannot traverse, such as `/etc/os-release` and `/bin` — the agent substrate follows them natively |
|
|
26
|
+
| | `substrate` | `agent` *(shipped)* | which I/O substrate serves the file tools. Only the resident in-distro agent (`lib/fs-substrate.js`) exists: reads, writes and identities run on ext4 — native symlinks, native mode bits, and the mutation guard survives to the write's atomic publication, kernel-enforced by the confined resident when the policy is confined. The former `share` opt-out (the Windows-side host stack over the 9p share) is refused at boot; delete the line |
|
|
28
27
|
| | `cwd` | `''` | base directory for relative paths; empty means the distro user's home |
|
|
29
28
|
| | `watchMaxDepth` | `0` | how deep the in-distro watch scan walks; `0` walks the whole tree. Bound it (e.g. `4`) when the watched tree holds a `node_modules` — a change below the bound is seen only when another change above it fires the same callback |
|
|
30
29
|
| `directory-picker-wsl` | `preferredDistro` | `''` *(shipped)* | the distro listed first in the picker |
|
|
@@ -34,6 +33,7 @@ are schema defaults, listed because they are the ones worth knowing.
|
|
|
34
33
|
| | `shell` | `''` | pin a shell; empty lets `wsl.exe` decide |
|
|
35
34
|
| | `loginShell` | `true` | whether a pinned shell uses login semantics |
|
|
36
35
|
| | `hostSessions` | `true` | give a session opened on a Windows folder a host `powershell.exe` in its own directory instead of the distro shell at `/mnt/<drive>/…`; `false` restores the composition-owned distro terminal for every session |
|
|
36
|
+
| | `terminalIdleReclaim` | `true` | let the controller reclaim an idle distro terminal: the launch is marked with a per-terminal `DSH_TERMINAL_ID`, and the handle's `inspectActivity` counts the marked processes through the resident agent — one (the shell at its prompt) is idle, more than one (a running command or a nested shell) is busy, `unknown` (agent out) pauses reclamation. `false` restores close-by-hand |
|
|
37
37
|
|
|
38
38
|
You can override the other keys in the same way; they keep their defaults. Those are
|
|
39
39
|
`wslPath`, `hostCwd` and `forwardEnv` on the shell and terminal rows,
|
package/docs/LIMITATIONS.md
CHANGED
|
@@ -3,35 +3,31 @@
|
|
|
3
3
|
What the plugin does not do, and why. A limitation that is documented is a design
|
|
4
4
|
boundary; one that is not is a bug report waiting to happen.
|
|
5
5
|
|
|
6
|
-
## The filesystem substrate (`wsl-fs`
|
|
6
|
+
## The filesystem substrate (`wsl-fs`)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
The file tools run on one substrate: the resident in-distro agent, on ext4 —
|
|
9
|
+
reads, writes and identities happen where the files live. The former
|
|
10
|
+
Windows-side share backend (`substrate: "share"`) is retired: a profile still
|
|
11
|
+
carrying the value is refused at boot with the migration, and no file tool
|
|
12
|
+
crosses the 9p share. What to know about the one substrate there is:
|
|
11
13
|
|
|
12
|
-
- **A new file publishes with mode 0600
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
or keep mode bits. The share substrate dies with the distro anyway; the
|
|
24
|
-
agent only adds its own failure mode, which is the one honest way to fail.
|
|
25
|
-
The failure message names the opt-out: set `substrate: "share"` in the
|
|
26
|
-
provider config to keep working on the Windows-side share while the agent
|
|
27
|
-
is out.
|
|
14
|
+
- **A new file publishes with mode 0600.** That is the host backend's own POSIX
|
|
15
|
+
publication semantics (a private 0600 staging file, renamed into place), which
|
|
16
|
+
a Linux-host DSH session has always had; the share dropped mode sets and took
|
|
17
|
+
the umask default instead, and that behaviour is gone with the share.
|
|
18
|
+
Overwrites and edits keep the original bits. Run `chmod` (or ask the model to)
|
|
19
|
+
when a new file must be executable.
|
|
20
|
+
- **When the agent is out, file operations fail closed.** The distro stopped, or
|
|
21
|
+
the resident crashed past its one rebuild: `FS_IO_ERROR` naming the substrate,
|
|
22
|
+
with the recovery path in the message. There is no fallback I/O to degrade
|
|
23
|
+
into — deliberately; the old failure message pointed at the share, and the
|
|
24
|
+
share is what this plugin exists to keep the model off.
|
|
28
25
|
- **The mutation guard survives to the write.** `createIfAbsent` publishes with
|
|
29
26
|
a no-replace link inside the distro, which closes the check-then-write window
|
|
30
27
|
for creates outright. An overwrite or edit carries the version it was based
|
|
31
28
|
on into the write op, and the agent re-verifies it against a fresh stat one
|
|
32
29
|
syscall before the rename: a concurrent writer wins and the stale write
|
|
33
|
-
refuses with `FS_STALE_VERSION`.
|
|
34
|
-
round trip to kernel-adjacent — the residual stat-then-rename pair is the
|
|
30
|
+
refuses with `FS_STALE_VERSION`. The residual stat-then-rename pair is the
|
|
35
31
|
same sliver a Linux-host session's own rename has.
|
|
36
32
|
- **Stage two routes mutations through a confined resident.** A write or edit
|
|
37
33
|
under a confined policy runs on its own long-lived agent, spawned inside the
|
|
@@ -45,19 +41,15 @@ host stack over the distro's 9p share. What differs:
|
|
|
45
41
|
the distro's `/tmp` lands in the confined mount's tmpfs, not the real `/tmp`
|
|
46
42
|
— the same hand-off rule as the commands' `/tmp`: pass files through the
|
|
47
43
|
session workspace.
|
|
48
|
-
- **`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
inside the distro), so the coarse-invalidation caveats below apply equally.
|
|
58
|
-
An inotify backend is planned, not shipped.
|
|
59
|
-
|
|
60
|
-
Everything below applies to the share substrate unless it says otherwise.
|
|
44
|
+
- **`glob` and `grep` run the distro's own rg** (`lib/search-route.js`): the
|
|
45
|
+
tool's arguments are forwarded verbatim, so results, output format and exit
|
|
46
|
+
codes are rg's own — at ext4 speed, with the distro's `.gitignore` rules.
|
|
47
|
+
A distro without rg surfaces rg's own "command not found" (exit 127);
|
|
48
|
+
`npm run bootstrap -- <distro> --install` installs it. A search whose
|
|
49
|
+
directory is a Windows folder keeps the host binary, which is native there.
|
|
50
|
+
- **`watch()` is one poll loop** (a `find -newer` scan inside the distro), so
|
|
51
|
+
the coarse-invalidation caveats below apply. An inotify backend is planned,
|
|
52
|
+
not shipped.
|
|
61
53
|
|
|
62
54
|
- **The sandbox does not govern WSL interop.** A confined command can still run a
|
|
63
55
|
Windows program, which escapes the Linux-side boundary. The plugin reports this as
|
|
@@ -77,35 +69,27 @@ Everything below applies to the share substrate unless it says otherwise.
|
|
|
77
69
|
while the file tools' fence grants the distro's *real* `/tmp`. Both are writable, so
|
|
78
70
|
neither side is refused, but a file the write tool puts in `/tmp` is invisible to
|
|
79
71
|
`bash` and vice versa. Hand a file between them through the session workspace.
|
|
80
|
-
- A distro that is stopped or unregistered while the app runs
|
|
81
|
-
|
|
82
|
-
the
|
|
83
|
-
gone.
|
|
72
|
+
- A distro that is stopped or unregistered while the app runs takes the file
|
|
73
|
+
tools' substrate with it: reads and writes report the substrate-unavailable
|
|
74
|
+
error naming the cause, and recover on the next call once the distro starts.
|
|
84
75
|
- `workspace-write` binds the workspace root as writable, and bubblewrap refuses a
|
|
85
76
|
bind whose source directory does not exist, so a session whose workspace directory was
|
|
86
77
|
deleted fails with a runner error; the plugin does not recreate it. A workdir that
|
|
87
78
|
does not exist — a configured `cwd` pointing at a deleted directory, for instance — is
|
|
88
79
|
a separate case and is now reported as an error naming that directory, because
|
|
89
80
|
`wsl.exe` would otherwise run the command in `/` and exit 0.
|
|
90
|
-
- New files get the distro's umask default (0644). A `chmod` from the Windows side on
|
|
91
|
-
a share path is silently ignored; overwrites and edits keep the original permission
|
|
92
|
-
bits. Run `chmod +x` inside the distro when you need an executable.
|
|
93
|
-
- The check before a write is "check, then write", which is not atomic. This backend
|
|
94
|
-
checks the caller's guard itself, because the Windows backend publishes a guarded
|
|
95
|
-
new file with a hard link, and the share does not support hard links. This is the
|
|
96
|
-
race that `dsh-fs-sandbox` already documents — and one reason the share substrate
|
|
97
|
-
is the documented FALLBACK rather than the main path: its publication rides the
|
|
98
|
-
unconfined agent, so it never receives the confined resident's kernel-enforced
|
|
99
|
-
containment. The agent substrate does.
|
|
100
81
|
- `watch()` observes from inside the distro (a `find -newer` poll loop, see
|
|
101
82
|
`lib/watcher.js`), so events are coarse invalidation, not per-file notifications,
|
|
102
83
|
and they arrive on the poll cadence, not instantly. A file created with an mtime
|
|
103
84
|
older than the watcher's stamp (`cp -p`, `tar -x`) is not seen until something
|
|
104
85
|
else touches the tree. Watching a 9p share from the Windows side remains
|
|
105
86
|
unsupported — the loop runs where the kernel can actually report change.
|
|
106
|
-
- `
|
|
107
|
-
|
|
108
|
-
|
|
87
|
+
- `editText` reads the whole file into memory before writing it back.
|
|
88
|
+
- The directory picker lists distro levels from inside the distro — the
|
|
89
|
+
resident's `ls -1ALp` in one round trip, a one-shot `wsl.exe --exec ls` when
|
|
90
|
+
it is out, never the 9p walk the host used to pay per entry. The listing is
|
|
91
|
+
line-parsed, so a filename containing a newline would render as two rows;
|
|
92
|
+
`/` cannot appear in a name, so nothing else can split one.
|
|
109
93
|
- Terminal routing is per-session by workspace coordinates (`subprocess-wsl.hostSessions`,
|
|
110
94
|
default on): a WSL-folder session gets the distro shell, a Windows-folder session gets
|
|
111
95
|
`powershell.exe` in its own directory. The shell MENU remains the single configured
|
|
@@ -120,5 +104,19 @@ Everything below applies to the share substrate unless it says otherwise.
|
|
|
120
104
|
Meanwhile, double-click a tab's title to rename it, or add `shellCandidates`
|
|
121
105
|
to the `terminal-controller` row in your own profile layer — a manually
|
|
122
106
|
selected shell is titled after itself.
|
|
123
|
-
-
|
|
124
|
-
|
|
107
|
+
- Distro terminals ARE reclaimed when idle — the observation is distro-side:
|
|
108
|
+
each terminal is launched with a `DSH_TERMINAL_ID` marker, and the handle's
|
|
109
|
+
`inspectActivity` counts the marked processes through the resident agent
|
|
110
|
+
(`lib/terminal-activity.js`). Exactly one (the shell at its prompt) is
|
|
111
|
+
`idle`; more than one (a command, a pipeline, a nested shell) is `busy`;
|
|
112
|
+
`unknown` — the agent out, the distro stopped — pauses reclamation, because
|
|
113
|
+
a probe that cannot answer must not authorize a close. Consequences to
|
|
114
|
+
know: a nested shell keeps the terminal busy by design (closing it would
|
|
115
|
+
lose that shell), so does any process the shell's startup files spawn with
|
|
116
|
+
the inherited marker (an `ssh-agent` launched in `.bashrc` reads as busy);
|
|
117
|
+
the idle threshold is the controller's `unattendedTimeoutMs` (2 h by
|
|
118
|
+
default); and the host-side shell-activity integration is still not armed
|
|
119
|
+
for these launches — `wsl.exe` on win32 fails its gate — which is why the
|
|
120
|
+
observation is a scan rather than shell cooperation.
|
|
121
|
+
- Windows-folder host terminals (the `powershell.exe` branch) keep the shipped
|
|
122
|
+
behaviour: `unknown` activity, no reclamation.
|
package/docs/PARITY.md
CHANGED
|
@@ -21,6 +21,13 @@ Not applicable, recorded so the gap is a decision and not an omission:
|
|
|
21
21
|
- Settings Sync, Remote-SSH tunnel chaining, Codespaces: composition-layer
|
|
22
22
|
responsibilities, not this plugin's.
|
|
23
23
|
|
|
24
|
+
> **Update (2026-10-04).** The plan's transitional invariant — `wsl.agent:
|
|
25
|
+
> false` must equal the pre-agent share-backed behaviour — is superseded: the
|
|
26
|
+
> share substrate is refused at construction, and the search spawn rides the
|
|
27
|
+
> distro's rg. The share is no longer a fallback path of this plugin; the
|
|
28
|
+
> only fallbacks left are transport-level (one-shot `wsl.exe` where the
|
|
29
|
+
> resident agent is out), never share I/O.
|
|
30
|
+
|
|
24
31
|
## Contract audit (Phase 0)
|
|
25
32
|
|
|
26
33
|
Findings from reading the harness packages inside the app bundle; each one
|
|
@@ -40,10 +47,17 @@ shaped a phase of the plan.
|
|
|
40
47
|
distro's share, rewrite the spawn to run a distro-side `rg` (falling back
|
|
41
48
|
to `grep -rE` + `find` when absent) with identical stdout conventions.
|
|
42
49
|
Under the agent, that exec rides the agent's `exec` capability.
|
|
43
|
-
**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
**LANDED (2026-10-04), as the design above has it:** `WslSubprocessRuntime`
|
|
51
|
+
.`spawn` performs the rewrite, the decision living in `lib/search-route.js`,
|
|
52
|
+
and the exec rides the agent's `exec` capability — Phase 1's resident —
|
|
53
|
+
through the minimal handle facade of `lib/search-exec.js` (the spawn seam
|
|
54
|
+
returns its handle synchronously, so the facade degrades inside `done`),
|
|
55
|
+
with the one-shot `wsl.exe --exec` handle as the fallback when the agent is
|
|
56
|
+
out. The `grep -rE` fallback is NOT implemented — grep does not read
|
|
57
|
+
`.gitignore`, so it is not an rg substitute; a missing distro rg surfaces
|
|
58
|
+
rg's own exit 127 with a bootstrap pointer instead. With the share
|
|
59
|
+
substrate retired the same day, no model-facing search crosses the 9p
|
|
60
|
+
share at all.
|
|
47
61
|
3. **`dsh-fs-local` watches with chokidar over the share** — the behaviour
|
|
48
62
|
this plugin replaces: chokidar on 9p is the unreliability that made
|
|
49
63
|
`WslFileSystem.watch` refuse. The in-distro watcher replaces it wholesale.
|