dsh-plugin-wsl-env 0.7.5 → 0.9.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.
- package/CHANGELOG.md +345 -8
- package/CONTRIBUTING.md +221 -68
- package/README.md +50 -35
- package/SECURITY.md +18 -2
- package/SUPPORT.md +23 -7
- package/cordis.patch.yml +9 -0
- package/docs/ARCHITECTURE.md +200 -57
- package/docs/CONFIGURATION.md +180 -16
- package/docs/LIMITATIONS.md +91 -33
- package/docs/PARITY.md +66 -38
- package/docs/PEER-PARITY.md +95 -32
- package/docs/README.zh.md +49 -31
- package/docs/UPSTREAM-FSIO-EXPORT.md +159 -50
- package/docs/UPSTREAM-TERMINAL-TITLE.md +49 -14
- package/lib/agent-confined.d.ts +42 -0
- package/lib/agent-confined.js +25 -41
- package/lib/agent-errors.d.ts +31 -0
- package/lib/agent-errors.js +19 -16
- package/lib/agent-exec.d.ts +159 -0
- package/lib/agent-exec.js +151 -165
- package/lib/agent-protocol.d.ts +192 -0
- package/lib/agent-protocol.js +76 -100
- package/lib/agent-shared.d.ts +27 -0
- package/lib/agent-shared.js +12 -12
- package/lib/agent.d.ts +353 -0
- package/lib/agent.js +536 -552
- package/lib/auto-preset.d.ts +110 -0
- package/lib/auto-preset.js +157 -141
- package/lib/bwrap.d.ts +90 -0
- package/lib/bwrap.js +18 -18
- package/lib/file-reference-wsl.d.ts +160 -0
- package/lib/file-reference-wsl.js +192 -173
- package/lib/fs-decisions.d.ts +107 -0
- package/lib/fs-decisions.js +64 -60
- package/lib/fs-routing.d.ts +182 -0
- package/lib/fs-routing.js +173 -116
- package/lib/fs-substrate.d.ts +258 -0
- package/lib/fs-substrate.js +248 -248
- package/lib/fs.d.ts +10 -0
- package/lib/fs.js +5 -0
- package/lib/fsio-agent.d.ts +307 -0
- package/lib/fsio-agent.js +414 -410
- package/lib/fsio-text.d.ts +115 -0
- package/lib/fsio-text.js +104 -84
- package/lib/git-route.d.ts +100 -0
- package/lib/git-route.js +46 -47
- package/lib/index.d.ts +1003 -0
- package/lib/index.js +1106 -1003
- package/lib/listing.d.ts +114 -0
- package/lib/listing.js +68 -55
- package/lib/paths.d.ts +182 -0
- package/lib/paths.js +134 -109
- package/lib/picker.d.ts +266 -0
- package/lib/picker.js +371 -351
- package/lib/ports.d.ts +44 -0
- package/lib/ports.js +39 -29
- package/lib/preflight.d.ts +91 -0
- package/lib/preflight.js +94 -0
- package/lib/preset-choice.d.ts +33 -0
- package/lib/preset-choice.js +15 -7
- package/lib/probe-cache.d.ts +51 -0
- package/lib/probe-cache.js +43 -29
- package/lib/sandbox-core.d.ts +149 -0
- package/lib/sandbox-core.js +239 -87
- package/lib/sandbox.d.ts +48 -0
- package/lib/sandbox.js +4 -4
- package/lib/search-exec.d.ts +96 -0
- package/lib/search-exec.js +52 -79
- package/lib/search-route.d.ts +75 -0
- package/lib/search-route.js +30 -31
- package/lib/shell-env.d.ts +88 -0
- package/lib/shell-env.js +78 -74
- package/lib/shell.d.ts +10 -0
- package/lib/shell.js +5 -0
- package/lib/subprocess.d.ts +313 -0
- package/lib/subprocess.js +267 -262
- package/lib/terminal-activity.d.ts +98 -0
- package/lib/terminal-activity.js +29 -39
- package/lib/terminal-route.d.ts +27 -0
- package/lib/terminal-route.js +16 -8
- package/lib/watcher.d.ts +77 -0
- package/lib/watcher.js +120 -126
- package/lib/workspace-files-route.d.ts +132 -0
- package/lib/workspace-files-route.js +73 -81
- package/lib/workspace-files-wsl.d.ts +257 -0
- package/lib/workspace-files-wsl.js +311 -251
- package/lib/wsl.d.ts +266 -0
- package/lib/wsl.js +150 -155
- package/locale/preflight/en.json +6 -0
- package/locale/preflight/zh.json +6 -0
- package/package.json +78 -22
- package/scripts/diagnose.sh +92 -0
package/lib/listing.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure listing helpers for the WSL directory picker, kept dependency-free so
|
|
3
|
+
* they can be unit-tested without installing the DSH peers the service itself
|
|
4
|
+
* imports. Ported from `@deepseek-ai/dsh-host-directory-picker-browse` so the
|
|
5
|
+
* picker behaves exactly like the shipped browse backend on ordinary paths.
|
|
6
|
+
*
|
|
7
|
+
* This is a TypeScript source built to `lib/listing.js`; edit THIS file and
|
|
8
|
+
* run `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
9
|
+
* fails when it drifts.
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-plugin-wsl/listing
|
|
12
|
+
*/
|
|
13
|
+
/** One picker row: a display name, its jump target, and the dot-entry flag. */
|
|
14
|
+
export interface ListingRow {
|
|
15
|
+
/** The row's display name. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** The row's jump target, Windows spelling. */
|
|
18
|
+
path: string;
|
|
19
|
+
/** Whether the entry is a dot-entry. */
|
|
20
|
+
hidden: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether a path names one fixed filesystem location regardless of process
|
|
24
|
+
* state. On Windows only drive-qualified (`C:\…`) or complete UNC
|
|
25
|
+
* (`\\server\share…`) forms qualify — which is what lets a distro root like
|
|
26
|
+
* `\\wsl.localhost\ubuntu` be adopted as a workspace, while the bare share root
|
|
27
|
+
* `\\wsl.localhost` is correctly rejected as a directory.
|
|
28
|
+
*
|
|
29
|
+
* @param path - candidate path.
|
|
30
|
+
* @returns whether the path is fully qualified.
|
|
31
|
+
*/
|
|
32
|
+
export declare function fullyQualified(path: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Ancestor chain from the filesystem root to `target` inclusive — the
|
|
35
|
+
* breadcrumb rows of a listing, every one a jump target. On a UNC path the walk
|
|
36
|
+
* terminates at the share root, whose `dirname` is itself.
|
|
37
|
+
*
|
|
38
|
+
* The `win32` flavour is explicit, not the platform default: these helpers
|
|
39
|
+
* serve Windows paths only, and the bare `node:path` functions are POSIX on
|
|
40
|
+
* Linux, where a UNC path parses as a single relative segment and the chain
|
|
41
|
+
* collapses to `['.', <whole path>]`. Walking up from inside a distro also
|
|
42
|
+
* yields the share root WITH its trailing separator (`\\wsl.localhost\ubuntu\`)
|
|
43
|
+
* — canonicalized by {@link breadcrumbs}, and asserted by the tests.
|
|
44
|
+
*
|
|
45
|
+
* `win32.basename` of a drive root (`C:\`) is empty, so the root crumb falls
|
|
46
|
+
* back to its own path rather than rendering blank.
|
|
47
|
+
*
|
|
48
|
+
* @param target - an absolute Windows path.
|
|
49
|
+
* @returns the ancestry, outermost first.
|
|
50
|
+
*/
|
|
51
|
+
export declare function ancestryCrumbs(target: string): ListingRow[];
|
|
52
|
+
/**
|
|
53
|
+
* Breadcrumb rows for a level, with the WSL share head prepended for anything
|
|
54
|
+
* inside a distro.
|
|
55
|
+
*
|
|
56
|
+
* Two Windows path quirks make this more than a relabel. `win32.dirname` treats
|
|
57
|
+
* `\\server\share` as a volume root and never yields the share itself, so the
|
|
58
|
+
* WSL row has to be synthesized; and `win32.basename` of that same share root is
|
|
59
|
+
* the empty string, so the distro row is named from the parsed distro instead.
|
|
60
|
+
* Without both fixes, browsing into a distro would render a blank breadcrumb and
|
|
61
|
+
* offer no way back to the distro list.
|
|
62
|
+
*
|
|
63
|
+
* @param target - the directory being listed.
|
|
64
|
+
* @param providerRoot - the share root acting as the WSL row's jump target.
|
|
65
|
+
* @returns breadcrumb rows, outermost first.
|
|
66
|
+
*/
|
|
67
|
+
export declare function breadcrumbs(target: string, providerRoot: string): ListingRow[];
|
|
68
|
+
/**
|
|
69
|
+
* Insert a streamed candidate into the name-sorted bounded window, evicting the
|
|
70
|
+
* name-largest candidate when the window exceeds `keep`. Keeps memory O(keep)
|
|
71
|
+
* regardless of how many children a level holds, so a pathological directory
|
|
72
|
+
* cannot make the picker allocate one row per entry.
|
|
73
|
+
*
|
|
74
|
+
* @template {{name: string}} T
|
|
75
|
+
* @param window - the name-ascending window, mutated in place.
|
|
76
|
+
* @param candidate - the streamed candidate to place.
|
|
77
|
+
* @param keep - the window bound.
|
|
78
|
+
* @returns true when an eviction happened (the level has more candidates).
|
|
79
|
+
*/
|
|
80
|
+
export declare function boundedInsert<T extends {
|
|
81
|
+
name: string;
|
|
82
|
+
}>(window: T[], candidate: T, keep: number): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The distro-side argv one picker level is listed with.
|
|
85
|
+
*
|
|
86
|
+
* `-1` is one entry per line, `-A` keeps dot-entries but drops `.` and `..`,
|
|
87
|
+
* `-L` follows symlinks so a link to a directory reports as a directory and a
|
|
88
|
+
* broken link drops out (exactly what the per-entry `stat` the host path used
|
|
89
|
+
* to pay one 9p round trip for), and `-p` marks directories with the trailing
|
|
90
|
+
* `/` the parser keys on.
|
|
91
|
+
*
|
|
92
|
+
* @param linuxDir - the absolute Linux directory to list.
|
|
93
|
+
* @returns the argv for the agent or a `wsl.exe --exec` launch.
|
|
94
|
+
*/
|
|
95
|
+
export declare function lsListingArgv(linuxDir: string): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Parse one `ls -1ALp` listing into the picker's rows.
|
|
98
|
+
*
|
|
99
|
+
* A line is a row when it ends with `/` — a directory, or a symlink `-L`
|
|
100
|
+
* resolved to one; files and dangling links are skipped, matching the host
|
|
101
|
+
* path's behaviour. The parse reads the listing as UTF-8 lines, so a filename
|
|
102
|
+
* containing a newline would split into two rows — the same limitation class
|
|
103
|
+
* the one-shot transport has always had, accepted here with the 9p walk it
|
|
104
|
+
* replaces.
|
|
105
|
+
*
|
|
106
|
+
* @param stdout - the listing's raw stdout.
|
|
107
|
+
* @param parent - the listed directory, in the UNC form the rows carry.
|
|
108
|
+
* @param maxEntries - the row bound; a level with more is flagged truncated.
|
|
109
|
+
* @returns the first `maxEntries` rows and whether the level had more.
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseLsListing(stdout: string | Buffer, parent: string, maxEntries: number): {
|
|
112
|
+
rows: ListingRow[];
|
|
113
|
+
truncated: boolean;
|
|
114
|
+
};
|
package/lib/listing.js
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* imports. Ported from `@deepseek-ai/dsh-host-directory-picker-browse` so the
|
|
5
5
|
* picker behaves exactly like the shipped browse backend on ordinary paths.
|
|
6
6
|
*
|
|
7
|
+
* This is a TypeScript source built to `lib/listing.js`; edit THIS file and
|
|
8
|
+
* run `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
9
|
+
* fails when it drifts.
|
|
10
|
+
*
|
|
7
11
|
* @module dsh-plugin-wsl/listing
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
13
|
import { win32 } from "node:path";
|
|
11
14
|
import { isWslUnc, uncToPosix } from "./paths.js";
|
|
12
|
-
|
|
13
15
|
/**
|
|
14
16
|
* Whether a path names one fixed filesystem location regardless of process
|
|
15
17
|
* state. On Windows only drive-qualified (`C:\…`) or complete UNC
|
|
@@ -21,9 +23,8 @@ import { isWslUnc, uncToPosix } from "./paths.js";
|
|
|
21
23
|
* @returns whether the path is fully qualified.
|
|
22
24
|
*/
|
|
23
25
|
export function fullyQualified(path) {
|
|
24
|
-
|
|
26
|
+
return win32.isAbsolute(path) && /^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)/.test(path);
|
|
25
27
|
}
|
|
26
|
-
|
|
27
28
|
/**
|
|
28
29
|
* Ancestor chain from the filesystem root to `target` inclusive — the
|
|
29
30
|
* breadcrumb rows of a listing, every one a jump target. On a UNC path the walk
|
|
@@ -43,18 +44,18 @@ export function fullyQualified(path) {
|
|
|
43
44
|
* @returns the ancestry, outermost first.
|
|
44
45
|
*/
|
|
45
46
|
export function ancestryCrumbs(target) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
const crumbs = [];
|
|
48
|
+
let current = target;
|
|
49
|
+
for (;;) {
|
|
50
|
+
const parent = win32.dirname(current);
|
|
51
|
+
// `basename` of a volume root is empty (`C:\`), so the root crumb falls
|
|
52
|
+
// back to its own path rather than rendering blank.
|
|
53
|
+
crumbs.unshift({ name: win32.basename(current) || current, path: current, hidden: false });
|
|
54
|
+
if (parent === current)
|
|
55
|
+
return crumbs;
|
|
56
|
+
current = parent;
|
|
57
|
+
}
|
|
56
58
|
}
|
|
57
|
-
|
|
58
59
|
/**
|
|
59
60
|
* Breadcrumb rows for a level, with the WSL share head prepended for anything
|
|
60
61
|
* inside a distro.
|
|
@@ -71,46 +72,57 @@ export function ancestryCrumbs(target) {
|
|
|
71
72
|
* @returns breadcrumb rows, outermost first.
|
|
72
73
|
*/
|
|
73
74
|
export function breadcrumbs(target, providerRoot) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
const crumbs = ancestryCrumbs(target);
|
|
76
|
+
const head = crumbs[0];
|
|
77
|
+
if (head === undefined)
|
|
78
|
+
return [{ name: "WSL", path: providerRoot, hidden: false }];
|
|
79
|
+
const parsed = isWslUnc(head.path) ? uncToPosix(head.path) : undefined;
|
|
80
|
+
if (parsed !== undefined && parsed.linuxPath === "/") {
|
|
81
|
+
// `win32.dirname` reports the share root with a trailing separator
|
|
82
|
+
// (`\\wsl.localhost\ubuntu\`); rewrite the row to the canonical distro root
|
|
83
|
+
// so crumb paths match what distroRoot() and the picker produce elsewhere.
|
|
84
|
+
crumbs[0] = { name: parsed.distro, path: `${providerRoot}\\${parsed.distro}`, hidden: false };
|
|
85
|
+
crumbs.unshift({ name: "WSL", path: providerRoot, hidden: false });
|
|
86
|
+
}
|
|
87
|
+
return crumbs;
|
|
86
88
|
}
|
|
87
|
-
|
|
88
89
|
/**
|
|
89
90
|
* Insert a streamed candidate into the name-sorted bounded window, evicting the
|
|
90
91
|
* name-largest candidate when the window exceeds `keep`. Keeps memory O(keep)
|
|
91
92
|
* regardless of how many children a level holds, so a pathological directory
|
|
92
93
|
* cannot make the picker allocate one row per entry.
|
|
93
94
|
*
|
|
95
|
+
* @template {{name: string}} T
|
|
94
96
|
* @param window - the name-ascending window, mutated in place.
|
|
95
97
|
* @param candidate - the streamed candidate to place.
|
|
96
98
|
* @param keep - the window bound.
|
|
97
99
|
* @returns true when an eviction happened (the level has more candidates).
|
|
98
100
|
*/
|
|
99
101
|
export function boundedInsert(window, candidate, keep) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
const last = window.at(-1);
|
|
103
|
+
if (window.length === keep && last !== undefined && candidate.name.localeCompare(last.name) >= 0)
|
|
104
|
+
return true;
|
|
105
|
+
let lo = 0;
|
|
106
|
+
let hi = window.length;
|
|
107
|
+
while (lo < hi) {
|
|
108
|
+
const mid = (lo + hi) >>> 1;
|
|
109
|
+
const midRow = window[mid];
|
|
110
|
+
// mid < hi <= window.length, so the row is always defined; the check is
|
|
111
|
+
// for the checker, and it ends the search instead of throwing if that
|
|
112
|
+
// invariant were ever broken.
|
|
113
|
+
if (midRow === undefined)
|
|
114
|
+
break;
|
|
115
|
+
if (candidate.name.localeCompare(midRow.name) < 0)
|
|
116
|
+
hi = mid;
|
|
117
|
+
else
|
|
118
|
+
lo = mid + 1;
|
|
119
|
+
}
|
|
120
|
+
window.splice(lo, 0, candidate);
|
|
121
|
+
if (window.length <= keep)
|
|
122
|
+
return false;
|
|
123
|
+
window.pop();
|
|
124
|
+
return true;
|
|
112
125
|
}
|
|
113
|
-
|
|
114
126
|
/**
|
|
115
127
|
* The distro-side argv one picker level is listed with.
|
|
116
128
|
*
|
|
@@ -124,9 +136,8 @@ export function boundedInsert(window, candidate, keep) {
|
|
|
124
136
|
* @returns the argv for the agent or a `wsl.exe --exec` launch.
|
|
125
137
|
*/
|
|
126
138
|
export function lsListingArgv(linuxDir) {
|
|
127
|
-
|
|
139
|
+
return ["ls", "-1ALp", "--", linuxDir];
|
|
128
140
|
}
|
|
129
|
-
|
|
130
141
|
/**
|
|
131
142
|
* Parse one `ls -1ALp` listing into the picker's rows.
|
|
132
143
|
*
|
|
@@ -143,17 +154,19 @@ export function lsListingArgv(linuxDir) {
|
|
|
143
154
|
* @returns the first `maxEntries` rows and whether the level had more.
|
|
144
155
|
*/
|
|
145
156
|
export function parseLsListing(stdout, parent, maxEntries) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
const rows = [];
|
|
158
|
+
let truncated = false;
|
|
159
|
+
for (const line of String(stdout).split("\n")) {
|
|
160
|
+
if (!line.endsWith("/"))
|
|
161
|
+
continue;
|
|
162
|
+
const name = line.slice(0, -1);
|
|
163
|
+
if (name.length === 0)
|
|
164
|
+
continue;
|
|
165
|
+
if (rows.length === maxEntries) {
|
|
166
|
+
truncated = true;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
rows.push({ name, path: win32.join(parent, name), hidden: name.startsWith(".") });
|
|
155
170
|
}
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
return { rows, truncated };
|
|
171
|
+
return { rows, truncated };
|
|
159
172
|
}
|
package/lib/paths.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path translation between the three coordinate systems a WSL-backed session
|
|
3
|
+
* touches:
|
|
4
|
+
*
|
|
5
|
+
* 1. Linux/POSIX paths inside the distro /home/andy/proj/src/a.ts
|
|
6
|
+
* 2. WSL's Windows UNC share \\wsl.localhost\ubuntu\home\andy\proj\src\a.ts
|
|
7
|
+
* 3. The Windows filesystem itself C:\Users\andyz\... -> /mnt/c/Users/andyz/...
|
|
8
|
+
*
|
|
9
|
+
* The harness host can reach (2) directly with Node's fs, which is what makes
|
|
10
|
+
* reads and ripgrep searches work without any in-distro helper. Commands must
|
|
11
|
+
* run inside the distro, so the shell executor speaks (1).
|
|
12
|
+
*
|
|
13
|
+
* These helpers are pure and dependency-free so they can be unit-tested without
|
|
14
|
+
* booting Cordis.
|
|
15
|
+
*
|
|
16
|
+
* This is a TypeScript source built to `lib/paths.js`; edit THIS file and run
|
|
17
|
+
* `pnpm run build` — the artifact under `lib/` is generated, and `pnpm test`
|
|
18
|
+
* fails when it drifts.
|
|
19
|
+
*
|
|
20
|
+
* @module dsh-plugin-wsl/paths
|
|
21
|
+
*/
|
|
22
|
+
/** A distro identity and the Linux path inside it, as {@link uncToPosix} returns. */
|
|
23
|
+
export interface DistroPath {
|
|
24
|
+
/** The distro name the UNC named. */
|
|
25
|
+
distro: string;
|
|
26
|
+
/** An absolute POSIX path inside that distro. */
|
|
27
|
+
linuxPath: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* What the two world-path translators may consult: the pinned distro and the
|
|
31
|
+
* fallback directory for relative input.
|
|
32
|
+
*/
|
|
33
|
+
export interface WorldPathOptions {
|
|
34
|
+
/**
|
|
35
|
+
* The pinned distro, which maps a POSIX-absolute input onto its UNC identity
|
|
36
|
+
* in {@link toWorldPath}.
|
|
37
|
+
*/
|
|
38
|
+
distro?: string;
|
|
39
|
+
/** The directory relative input resolves against. */
|
|
40
|
+
cwd?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether a string is the WSL UNC share rather than an ordinary Windows path.
|
|
44
|
+
*
|
|
45
|
+
* @param value - candidate path.
|
|
46
|
+
* @returns true for `\\wsl.localhost\...` and `\\wsl$\...`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isWslUnc(value: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a string is POSIX-absolute. On Windows `path.isAbsolute('/home/x')`
|
|
51
|
+
* is also true, so the WSL mapper must test this before falling back to the
|
|
52
|
+
* host helpers.
|
|
53
|
+
*
|
|
54
|
+
* @param value - candidate path.
|
|
55
|
+
* @returns true when the path starts with a single forward slash.
|
|
56
|
+
*/
|
|
57
|
+
export declare function isPosixAbsolute(value: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a path names a location only relative to a base. The fs provider
|
|
60
|
+
* consults its default workdir exactly for this input; every absolute form —
|
|
61
|
+
* POSIX, drive, WSL UNC, or any other UNC share — is a location in its own
|
|
62
|
+
* right and short-circuits before a base is ever needed.
|
|
63
|
+
*
|
|
64
|
+
* @param value - candidate path.
|
|
65
|
+
* @returns true when the path names no absolute location.
|
|
66
|
+
*/
|
|
67
|
+
export declare function isRelativeWorldPath(value: string): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether a world path is a granted root or lies beneath it, compared in the
|
|
70
|
+
* coordinate system the two spellings share.
|
|
71
|
+
*
|
|
72
|
+
* A grant is written in the vocabulary of the world it governs: the Windows
|
|
73
|
+
* sandbox hands out drive and UNC paths, while a distro-side grant is a Linux
|
|
74
|
+
* path such as `/tmp`. Passing the distro maps a Linux grant onto the same UNC
|
|
75
|
+
* share as the target, so `\\wsl.localhost\ubuntu\home\andy` can be compared
|
|
76
|
+
* with `/home/andy`. Mixed pairs that share no vocabulary report no containment
|
|
77
|
+
* — the conservative answer, never a textual guess.
|
|
78
|
+
*
|
|
79
|
+
* @param target - the path being tested, in any coordinate system.
|
|
80
|
+
* @param root - the granted root, in any coordinate system.
|
|
81
|
+
* @param options - the distro that maps a Linux root onto its UNC share.
|
|
82
|
+
* @returns true when target is root itself or a descendant of it.
|
|
83
|
+
*/
|
|
84
|
+
export declare function isWorldPathUnder(target: string, root: string, options?: WorldPathOptions): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Map a Linux path inside a distro onto the UNC path the host can read.
|
|
87
|
+
*
|
|
88
|
+
* @param distro - distro name, e.g. `ubuntu`.
|
|
89
|
+
* @param linuxPath - absolute Linux path, e.g. `/home/andy/proj`.
|
|
90
|
+
* @returns the equivalent `\\wsl.localhost\<distro>\...` path.
|
|
91
|
+
*/
|
|
92
|
+
export declare function posixToUnc(distro: string, linuxPath: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* Map a WSL UNC path back onto the distro and Linux path it names.
|
|
95
|
+
*
|
|
96
|
+
* @param uncPath - a `\\wsl.localhost\<distro>\...` path; absent is not a UNC path.
|
|
97
|
+
* @returns the distro and Linux path, or undefined for any other path.
|
|
98
|
+
*/
|
|
99
|
+
export declare function uncToPosix(uncPath?: string): DistroPath | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a UNC path belongs to the named distro. Used to confine the WSL
|
|
102
|
+
* filesystem backend to one distro instead of silently serving every mounted
|
|
103
|
+
* share.
|
|
104
|
+
*
|
|
105
|
+
* @param uncPath - candidate UNC path.
|
|
106
|
+
* @param distro - the distro this session is pinned to.
|
|
107
|
+
* @returns true when the path is the same distro (case-insensitive).
|
|
108
|
+
*/
|
|
109
|
+
export declare function isUnderDistro(uncPath: string, distro: string): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* A WSL UNC that names a distro OTHER than the pinned one — the shape both
|
|
112
|
+
* shell seams refuse: the shell executor will not run commands in it (running
|
|
113
|
+
* there would mean silently switching distros on path similarity), and the
|
|
114
|
+
* shell-env facts describe only the pinned distro, so a foreign session gets
|
|
115
|
+
* no facts rather than another distro's home and shell.
|
|
116
|
+
*
|
|
117
|
+
* @param value - the candidate path (any spelling; non-UNC values are not foreign).
|
|
118
|
+
* @param distro - the pinned distro name.
|
|
119
|
+
* @returns true when the value is a WSL UNC under a different distro.
|
|
120
|
+
*/
|
|
121
|
+
export declare function isAnotherDistrosUnc(value: string, distro: string): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Translate a Windows drive path into its WSL interop mount.
|
|
124
|
+
*
|
|
125
|
+
* @param winPath - e.g. `C:\Users\andyz\Documents`.
|
|
126
|
+
* @returns e.g. `/mnt/c/Users/andyz/Documents`, or undefined for a non-drive path.
|
|
127
|
+
*/
|
|
128
|
+
export declare function windowsToLinuxMount(winPath: string): string | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Resolve a caller-supplied workdir into a path `wsl.exe --cd` accepts.
|
|
131
|
+
*
|
|
132
|
+
* Accepts every coordinate system, because the tool layer passes whatever the
|
|
133
|
+
* session cwd is (a UNC path once the workspace is a WSL folder) while a human
|
|
134
|
+
* editing the profile is likely to write a plain Linux path.
|
|
135
|
+
*
|
|
136
|
+
* @param value - the path to translate.
|
|
137
|
+
* @param options - the pinned distro and the fallback directory for relative input.
|
|
138
|
+
* @returns an absolute Linux path, or the input unchanged when it cannot be mapped.
|
|
139
|
+
*/
|
|
140
|
+
export declare function toLinuxPath(value: string, options?: WorldPathOptions): string;
|
|
141
|
+
/**
|
|
142
|
+
* Resolve a caller-supplied path into the UNC coordinate system the host's fs
|
|
143
|
+
* calls use. Linux paths from the model, UNC paths from the harness, and
|
|
144
|
+
* Windows paths from the host all have to land somewhere real.
|
|
145
|
+
*
|
|
146
|
+
* @param value - the path to translate.
|
|
147
|
+
* @param options - the PINNED DISTRO (required: a POSIX-absolute input mints
|
|
148
|
+
* its UNC identity) and the fallback directory for relative input.
|
|
149
|
+
* @returns an absolute host path (UNC for anything inside the distro).
|
|
150
|
+
*/
|
|
151
|
+
export declare function toWorldPath(value: string, options?: WorldPathOptions): string;
|
|
152
|
+
/**
|
|
153
|
+
* Render a world path back into the form the model and the UI should see: a
|
|
154
|
+
* Linux path inside the distro, and the ordinary Windows path everywhere else.
|
|
155
|
+
* `FsTarget.targetKey` stays the UNC path (the contract treats it as opaque);
|
|
156
|
+
* only `displayPath` is rewritten.
|
|
157
|
+
*
|
|
158
|
+
* @param worldPath - an absolute host path.
|
|
159
|
+
* @param distro - the distro whose paths should be shown as Linux paths.
|
|
160
|
+
* @returns the display path.
|
|
161
|
+
*/
|
|
162
|
+
export declare function toDisplayPath(worldPath: string, distro: string): string;
|
|
163
|
+
/** The provider root of the WSL UNC share — the level that holds one entry per distro. */
|
|
164
|
+
export declare const UNC_PROVIDER_ROOT = "\\\\wsl.localhost";
|
|
165
|
+
/**
|
|
166
|
+
* The UNC root of one distro, which is the mount point of that distro's `/`.
|
|
167
|
+
* This is a complete UNC path (`\\server\share`), which is what the directory
|
|
168
|
+
* picker's fully-qualified check requires and what the workspace registry
|
|
169
|
+
* accepts as a project directory.
|
|
170
|
+
*
|
|
171
|
+
* @param distro - distro name.
|
|
172
|
+
* @returns e.g. `\\wsl.localhost\ubuntu`.
|
|
173
|
+
*/
|
|
174
|
+
export declare function distroRoot(distro: string): string;
|
|
175
|
+
/**
|
|
176
|
+
* Whether a path names the WSL share's root rather than a distro inside it.
|
|
177
|
+
* Both share spellings and a trailing separator are accepted.
|
|
178
|
+
*
|
|
179
|
+
* @param value - candidate path.
|
|
180
|
+
* @returns true for `\\wsl.localhost` and `\\wsl$` in any casing.
|
|
181
|
+
*/
|
|
182
|
+
export declare function isProviderRoot(value: string): boolean;
|