dsh-plugin-wsl-env 0.26.3 → 0.26.4

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 (46) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/CONTRIBUTING.md +25 -21
  3. package/SUPPORT.md +2 -2
  4. package/SUPPORT.zh.md +2 -2
  5. package/docs/AGENT-PROTOCOL-V7.md +4 -2
  6. package/docs/API.md +1 -0
  7. package/docs/API.zh.md +1 -0
  8. package/docs/CONFIGURATION.md +21 -5
  9. package/docs/CONFIGURATION.zh.md +17 -3
  10. package/docs/PARITY.md +3 -1
  11. package/docs/RELEASING.md +25 -3
  12. package/docs/REQUIREMENTS.zh.md +4 -4
  13. package/docs/ROADMAP-1.0.md +11 -7
  14. package/lib/agent.d.ts +54 -18
  15. package/lib/agent.js +86 -19
  16. package/lib/fs-routing.d.ts +3 -0
  17. package/lib/fs-routing.js +5 -0
  18. package/lib/fs-substrate.d.ts +1 -1
  19. package/lib/fs-substrate.js +10 -18
  20. package/lib/fsio-agent.d.ts +4 -0
  21. package/lib/fsio-agent.js +37 -10
  22. package/lib/listing.d.ts +2 -2
  23. package/lib/listing.js +5 -4
  24. package/lib/messages.d.ts +70 -0
  25. package/lib/messages.js +80 -0
  26. package/lib/open-in-app.js +12 -9
  27. package/lib/picker.d.ts +4 -1
  28. package/lib/picker.js +35 -11
  29. package/lib/ports.js +8 -1
  30. package/lib/provider-common.d.ts +22 -0
  31. package/lib/provider-common.js +18 -0
  32. package/lib/provider-marker.d.ts +23 -0
  33. package/lib/provider-marker.js +21 -0
  34. package/lib/status.js +8 -5
  35. package/lib/subprocess.d.ts +3 -0
  36. package/lib/subprocess.js +5 -0
  37. package/lib/takeover-report.js +4 -11
  38. package/lib/watcher.d.ts +1 -1
  39. package/lib/watcher.js +1 -1
  40. package/lib/wsl-doctor-command.d.ts +6 -2
  41. package/lib/wsl-doctor-command.js +24 -15
  42. package/lib/wsl-filesystem.d.ts +14 -11
  43. package/lib/wsl-filesystem.js +39 -27
  44. package/lib/wsl-shell.d.ts +42 -37
  45. package/lib/wsl-shell.js +53 -42
  46. package/package.json +1 -1
package/lib/agent.js CHANGED
@@ -23,9 +23,12 @@
23
23
  * behind a dead `wsl.exe`. The host-side watchdog is armed on the agent's
24
24
  * `ACK` — the dequeue signal — so it measures EXECUTION, never the queue
25
25
  * wait: a short-budget request queued behind a long one can no longer
26
- * kill the shared transport for a stall that was never its own. It still
27
- * catches an agent that accepted a request and then stopped answering at
28
- * all.
26
+ * kill the shared transport for a stall that was never its own. A second,
27
+ * much looser ceiling starts when the frame is WRITTEN: a resident that
28
+ * stays alive but never dequeues the request (a wedged `wait`, a blocked
29
+ * pipe) otherwise stranded it, and the serial queue behind it, forever. It
30
+ * still catches an agent that accepted a request and then stopped answering
31
+ * at all.
29
32
  * 3. **Idle agents go away.** `idleMs` after the last exchange the process is
30
33
  * killed; the next call starts a fresh one. WSL VMs are shared, but every
31
34
  * process is a promise someone has to keep.
@@ -60,6 +63,16 @@ function emptyAgentMetrics() {
60
63
  const HANDSHAKE_TIMEOUT_MS = 15000;
61
64
  /** Extra time the host watchdog waits past the request's own in-distro timeout. */
62
65
  const WATCHDOG_GRACE_MS = 13000;
66
+ /**
67
+ * How long a written frame may wait for the agent's dequeue `ACK`. The ACK is
68
+ * one line the resident prints before it runs anything, so this is not an
69
+ * execution budget; it exists to turn a resident that is alive but no longer
70
+ * dequeuing (a wedged `wait`, a blocked stdin pipe) into a bounded failure
71
+ * instead of an entry that holds the serial queue forever. Generous on
72
+ * purpose: a legitimately busy foreground command is ACKed as soon as it is
73
+ * dequeued, and only the queue wait precedes that.
74
+ */
75
+ const DISPATCH_TIMEOUT_MS = 120_000;
63
76
  /**
64
77
  * How many times a resident that reached `dead` may be revived before the
65
78
  * failure becomes permanent. Each revival gets the one permitted rebuild.
@@ -180,6 +193,7 @@ export class WslAgent {
180
193
  this.configuredSignal = config.signalTransport;
181
194
  this.configuredLease = config.leaseMs;
182
195
  this.maxPending = config.maxPending ?? MAX_PENDING_REQUESTS;
196
+ this.dispatchTimeoutMs = config.dispatchTimeoutMs ?? DISPATCH_TIMEOUT_MS;
183
197
  this.agentPid = undefined;
184
198
  this.process = null;
185
199
  this.state = "idle";
@@ -530,6 +544,7 @@ export class WslAgent {
530
544
  return;
531
545
  pending.started = true;
532
546
  this.lastAckedSeq = pending.seq;
547
+ this.releaseDispatchWatchdog(pending);
533
548
  this.recordAck(pending);
534
549
  if (pending.cancelled)
535
550
  this.armCancelSignal(pending);
@@ -672,6 +687,9 @@ export class WslAgent {
672
687
  clearTimeout(pending.watchdog);
673
688
  pending.watchdog = null;
674
689
  }
690
+ // The rebuilt agent gets a fresh ACK window too; a timer bound to the
691
+ // dead transport must not survive the relay.
692
+ this.releaseDispatchWatchdog(pending);
675
693
  relayable.push(pending);
676
694
  }
677
695
  else {
@@ -822,6 +840,7 @@ export class WslAgent {
822
840
  settled: false,
823
841
  answered: false,
824
842
  signalTimer: null,
843
+ dispatchWatchdog: null,
825
844
  armWatchdog: timeoutMs > 0
826
845
  ? () => {
827
846
  if (pending.watchdog)
@@ -888,10 +907,57 @@ export class WslAgent {
888
907
  };
889
908
  signal.addEventListener("abort", pending.onAbort, { once: true });
890
909
  }
891
- /** Send a tracked request, recording dispatch before synchronous responses. */
910
+ /**
911
+ * Send a tracked request, recording dispatch before synchronous responses.
912
+ * A written frame starts the dispatch watchdog: the ACK that arms the
913
+ * execution budget is not guaranteed to arrive at all.
914
+ *
915
+ * @param pending - the request to send.
916
+ * @returns whether the frame was written.
917
+ */
892
918
  sendPending(pending) {
893
919
  pending.sent = true;
894
- return this.writeLines(pending.lines);
920
+ if (!this.writeLines(pending.lines))
921
+ return false;
922
+ this.armDispatchWatchdog(pending);
923
+ return true;
924
+ }
925
+ /**
926
+ * Arm the frame-written watchdog: a resident that stays alive without
927
+ * dequeuing the request is a wedged transport, not a slow command.
928
+ *
929
+ * @param pending - the sent request.
930
+ */
931
+ armDispatchWatchdog(pending) {
932
+ if (pending.dispatchWatchdog)
933
+ return;
934
+ const child = this.process;
935
+ if (!child)
936
+ return;
937
+ pending.dispatchWatchdog = setTimeout(() => {
938
+ // Bind the timer to the generation it was armed on, exactly as the
939
+ // ACK-armed watchdog does.
940
+ if (this.process !== child)
941
+ return;
942
+ this.lastError = `agent did not acknowledge request ${pending.id} within ${this.dispatchTimeoutMs}ms of its dispatch`;
943
+ child.kill();
944
+ }, this.dispatchTimeoutMs);
945
+ // The transport's child process (and its pipes) already keeps the loop
946
+ // alive while there is something to time out; an idle host that has let
947
+ // every other handle go must not be held open by this diagnostic timer.
948
+ pending.dispatchWatchdog.unref?.();
949
+ }
950
+ /**
951
+ * Release the frame-written watchdog once the ACK proves the resident
952
+ * dequeued the request.
953
+ *
954
+ * @param pending - the acknowledged request.
955
+ */
956
+ releaseDispatchWatchdog(pending) {
957
+ if (!pending.dispatchWatchdog)
958
+ return;
959
+ clearTimeout(pending.dispatchWatchdog);
960
+ pending.dispatchWatchdog = null;
895
961
  }
896
962
  /** Dispatch the next shell request only after the preceding answer. */
897
963
  dispatchQueued() {
@@ -989,20 +1055,6 @@ export class WslAgent {
989
1055
  this.track({ id, kind: "exec", lines, resolve: () => resolve(), reject, timeoutMs: HANDSHAKE_TIMEOUT_MS, signal });
990
1056
  });
991
1057
  }
992
- /**
993
- * Deliver an out-of-band signal to the resident shell. The serial stdin loop
994
- * cannot consume a frame while a command runs, so cancellation is a signal;
995
- * a second `wsl.exe` is the only channel that reaches the agent while it is
996
- * blocked in `wait`.
997
- *
998
- * Only an agent that shares the distro's PID namespace is addressable: the
999
- * plain agent, or a session runtime (its prefix is a scope plus mounts, but
1000
- * no PID namespace). A confined resident runs inside a PID namespace whose
1001
- * PIDs do not exist in the distro, so signalling its HELLO PID could hit an
1002
- * unrelated process; there the KILL frame remains the (delayed) fallback.
1003
- *
1004
- * @param signal - the signal to deliver (`SIGUSR1` is the cancel trap).
1005
- */
1006
1058
  /**
1007
1059
  * The cumulative request metrics: queue wait (submission -> ACK) and execution
1008
1060
  * time (ACK -> settle) per request kind, plus the peak in-flight count.
@@ -1077,6 +1129,20 @@ export class WslAgent {
1077
1129
  else if (error !== undefined)
1078
1130
  stats.failed += 1;
1079
1131
  }
1132
+ /**
1133
+ * Deliver an out-of-band signal to the resident shell. The serial stdin loop
1134
+ * cannot consume a frame while a command runs, so cancellation is a signal;
1135
+ * a second `wsl.exe` is the only channel that reaches the agent while it is
1136
+ * blocked in `wait`.
1137
+ *
1138
+ * Only an agent that shares the distro's PID namespace is addressable: the
1139
+ * plain agent, or a session runtime (its prefix is a scope plus mounts, but
1140
+ * no PID namespace). A confined resident runs inside a PID namespace whose
1141
+ * PIDs do not exist in the distro, so signalling its HELLO PID could hit an
1142
+ * unrelated process; there the KILL frame remains the (delayed) fallback.
1143
+ *
1144
+ * @param signal - the signal to deliver (`SIGUSR1` is the cancel trap).
1145
+ */
1080
1146
  signalAgent(signal) {
1081
1147
  const pid = this.agentPid;
1082
1148
  if (pid === undefined || !this.signalable)
@@ -1207,6 +1273,7 @@ export class WslAgent {
1207
1273
  clearPending(pending) {
1208
1274
  if (pending.watchdog)
1209
1275
  clearTimeout(pending.watchdog);
1276
+ this.releaseDispatchWatchdog(pending);
1210
1277
  if (pending.signalTimer)
1211
1278
  clearTimeout(pending.signalTimer);
1212
1279
  pending.signalTimer = null;
@@ -30,6 +30,7 @@
30
30
  *
31
31
  * @module dsh-plugin-wsl-env/fs-routing
32
32
  */
33
+ import { PLUGIN_PROVIDER } from "./provider-marker.js";
33
34
  import z from "@deepseek-ai/schemastery";
34
35
  import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
35
36
  import { WslFileSystem } from "./wsl-filesystem.js";
@@ -98,6 +99,8 @@ export declare function inputIsDistro(value: string | undefined): boolean;
98
99
  * mode the distro side reports through `sandboxMode`).
99
100
  */
100
101
  export declare class WslRoutingFileSystem extends LocalFileSystem {
102
+ /** Brand for the in-app takeover report; see `provider-marker`. */
103
+ get [PLUGIN_PROVIDER](): "fs";
101
104
  static Config: z<RoutingConfig>;
102
105
  /**
103
106
  * The routed backend's constructor reads the deployment default mode from
package/lib/fs-routing.js CHANGED
@@ -31,6 +31,7 @@
31
31
  * @module dsh-plugin-wsl-env/fs-routing
32
32
  */
33
33
  import { isWslUnc, uncToPosix } from "./paths.js";
34
+ import { PLUGIN_PROVIDER } from "./provider-marker.js";
34
35
  import z from "@deepseek-ai/schemastery";
35
36
  import { LocalFileSystem } from "@deepseek-ai/dsh-fs-local";
36
37
  import { WslFileSystem } from "./wsl-filesystem.js";
@@ -103,6 +104,10 @@ export function inputIsDistro(value) {
103
104
  * mode the distro side reports through `sandboxMode`).
104
105
  */
105
106
  export class WslRoutingFileSystem extends LocalFileSystem {
107
+ /** Brand for the in-app takeover report; see `provider-marker`. */
108
+ get [PLUGIN_PROVIDER]() {
109
+ return "fs";
110
+ }
106
111
  static Config = z.intersect([
107
112
  LocalFileSystem.Config,
108
113
  z.object({
@@ -31,7 +31,7 @@
31
31
  * @module dsh-plugin-wsl-env/fs-substrate
32
32
  */
33
33
  import type { PatchHunk } from "@deepseek-ai/dsh-fs-patch";
34
- import { ResolvedTarget } from "./fsio-agent.js";
34
+ import { type ResolvedTarget } from "./fsio-agent.js";
35
35
  import { DistroFs } from "./fsio-agent.js";
36
36
  import type { WslAgent } from "./agent.js";
37
37
  /**
@@ -35,10 +35,6 @@ import { reasonToCode } from "./fsio-agent.js";
35
35
  import { applyLiteralEdit, FsCodedError, normalizeLineEndings, restoreLineEndings } from "./fsio-text.js";
36
36
  import { DistroFs } from "./fsio-agent.js";
37
37
  import { posixToUnc, uncToPosix } from "./paths.js";
38
- /**
39
- * A resolved target: the Linux spelling the model sees and the UNC identity
40
- * the harness keys on, as returned by {@linkcode AgentSubstrate#resolve}.
41
- */
42
38
  /**
43
39
  * The provider's stat/lstat row, type-spelled the way the tool layer reads it.
44
40
  *
@@ -434,20 +430,15 @@ export class AgentSubstrate {
434
430
  let destinationRow;
435
431
  let sourceFailure;
436
432
  if (options.hunks !== undefined) {
437
- try {
438
- await this.fs.writeFileAtomic(destinationPath, content, {
439
- mode: sourceInfo.mode,
440
- createIfAbsent: options.expectedDestination?.kind === "createIfAbsent" ? { displayPath: destination.displayPath } : undefined,
441
- expectedVersion: options.expectedDestination?.kind === "replaceIfVersion" ? options.expectedDestination.version : undefined,
442
- signal,
443
- agent: mutationAgent,
444
- });
445
- const published = await this.fs.stat(destinationPath, { signal });
446
- destinationRow = { version: published ? published.version : `missing:${destination.targetKey}` };
447
- }
448
- catch (error) {
449
- throw error;
450
- }
433
+ await this.fs.writeFileAtomic(destinationPath, content, {
434
+ mode: sourceInfo.mode,
435
+ createIfAbsent: options.expectedDestination?.kind === "createIfAbsent" ? { displayPath: destination.displayPath } : undefined,
436
+ expectedVersion: options.expectedDestination?.kind === "replaceIfVersion" ? options.expectedDestination.version : undefined,
437
+ signal,
438
+ agent: mutationAgent,
439
+ });
440
+ const published = await this.fs.stat(destinationPath, { signal });
441
+ destinationRow = { version: published ? published.version : `missing:${destination.targetKey}` };
451
442
  try {
452
443
  await this.fs.removeFile(sourcePath, sourceInfo.version, signal, mutationAgent);
453
444
  }
@@ -464,6 +455,7 @@ export class AgentSubstrate {
464
455
  guard: options.expectedDestination?.kind === "createIfAbsent" ? "no-replace" : "replace",
465
456
  sourceVersion: sourceInfo.version,
466
457
  destinationVersion: options.expectedDestination?.kind === "replaceIfVersion" ? options.expectedDestination.version : undefined,
458
+ size: sourceInfo.size,
467
459
  signal,
468
460
  agent: mutationAgent,
469
461
  });
@@ -376,6 +376,10 @@ export declare class DistroFs {
376
376
  sourceVersion?: string;
377
377
  /** The destination version the move was based on. */
378
378
  destinationVersion?: string;
379
+ /** The source size in bytes, when known, so the budget scales with the copy. */
380
+ size?: number;
381
+ /** Explicit budget override in ms; takes precedence over `size`. */
382
+ timeoutMs?: number;
379
383
  signal?: AbortSignal;
380
384
  agent?: WslAgent;
381
385
  }): Promise<{
package/lib/fsio-agent.js CHANGED
@@ -24,8 +24,24 @@
24
24
  import { FS_READ_CHUNK_BYTES } from "./agent-protocol.js";
25
25
  import { BINARY_SAMPLE_BYTES, FsCodedError, decodeUtf8, decodeUtf8Stream, detectLineEndings, normalizeLineEndings, throwIfAborted, } from "./fsio-text.js";
26
26
  import { posixToUnc, uncToPosix } from "./paths.js";
27
- /** One FS frame's in-distro watchdog; fs ops are short, writes bounded by content size. */
27
+ /** Base in-distro watchdog for one FS frame. */
28
28
  const FS_OP_TIMEOUT_MS = 30_000;
29
+ /** Extra in-distro budget per MiB of content the op must copy, write or move. */
30
+ const FS_OP_TIMEOUT_PER_MIB_MS = 1_000;
31
+ /** Ceiling on the size-scaled budget; a stuck op must still fail in bounded time. */
32
+ const FS_OP_TIMEOUT_MAX_MS = 10 * 60_000;
33
+ /**
34
+ * The in-distro budget for an op whose cost scales with `bytes`: a fixed 30 s
35
+ * was a false `FS_IO_ERROR` for a multi-GB `move` (the agent copies with
36
+ * `cat > tmp`) or write on a slow 9p-backed distro path.
37
+ *
38
+ * @param bytes - the content size the op must handle, when known.
39
+ * @returns the frame's timeout budget in ms, capped at ten minutes.
40
+ */
41
+ function fsOpTimeoutMs(bytes = 0) {
42
+ const scaled = FS_OP_TIMEOUT_MS + Math.ceil(bytes / (1024 * 1024)) * FS_OP_TIMEOUT_PER_MIB_MS;
43
+ return Math.min(scaled, FS_OP_TIMEOUT_MAX_MS);
44
+ }
29
45
  /**
30
46
  * Normalize one agent timestamp ("seconds.frac", 9 or 10 fractional digits
31
47
  * depending on whether stat or find produced it) into the peer's nanosecond
@@ -122,9 +138,9 @@ export class DistroFs {
122
138
  * @param agent - the agent that must run the op; the plain resident by default.
123
139
  * @returns the op's result.
124
140
  */
125
- async request(op, args, signal, agent = this.agent) {
141
+ async request(op, args, signal, agent = this.agent, timeoutMs = FS_OP_TIMEOUT_MS) {
126
142
  try {
127
- return await agent.fs({ op, args: args, timeoutMs: FS_OP_TIMEOUT_MS, signal });
143
+ return await agent.fs({ op, args: args, timeoutMs, signal });
128
144
  }
129
145
  catch (error) {
130
146
  if (signal?.aborted) {
@@ -533,7 +549,7 @@ export class DistroFs {
533
549
  createIfAbsent ? "no-replace" : "replace",
534
550
  expectedVersion ?? "-",
535
551
  content,
536
- ], signal, agent);
552
+ ], signal, agent, fsOpTimeoutMs(typeof content === "string" ? Buffer.byteLength(content, "utf8") : content.byteLength));
537
553
  if (result.exitCode === 0)
538
554
  return;
539
555
  const failure = this.fail("write", result, displayPath);
@@ -580,17 +596,28 @@ export class DistroFs {
580
596
  if (result.exitCode !== 0)
581
597
  throw this.fail("batch", result, ops.map((op) => op.op).join(","));
582
598
  const records = [];
599
+ let expected = 1;
583
600
  for (const line of result.stdout.toString("utf8").split("\n")) {
584
601
  if (line.length === 0)
585
602
  continue;
586
- if (line.startsWith("OK ")) {
587
- const bar = line.indexOf("|");
588
- records.push({ ok: true, payload: Buffer.from(line.slice(bar + 1), "base64") });
603
+ const bad = line.startsWith("BAD ");
604
+ if (!bad && !line.startsWith("OK "))
605
+ continue;
606
+ const bar = line.indexOf("|");
607
+ const indexText = line.slice(bad ? 4 : 3, bar);
608
+ const index = Number(indexText);
609
+ if (bar < 0 || !Number.isInteger(index) || index !== expected) {
610
+ throw new FsCodedError(`cannot run the batch (${ops.map((op) => op.op).join(",")}): record ${expected} was answered as "${line.slice(0, bar < 0 ? 40 : bar)}"`, "FS_IO_ERROR");
611
+ }
612
+ const rest = line.slice(bar + 1);
613
+ if (!bad) {
614
+ records.push({ ok: true, payload: Buffer.from(rest, "base64") });
589
615
  }
590
- else if (line.startsWith("BAD ")) {
591
- const [, reason, message] = line.split("|");
616
+ else {
617
+ const [reason, message] = rest.split("|");
592
618
  records.push({ ok: false, reason: reason ?? "io", message: Buffer.from(message ?? "", "base64").toString("utf8") });
593
619
  }
620
+ expected += 1;
594
621
  }
595
622
  return records;
596
623
  }
@@ -633,7 +660,7 @@ export class DistroFs {
633
660
  options.guard,
634
661
  options.sourceVersion ?? "-",
635
662
  options.destinationVersion ?? "-",
636
- ], options.signal, options.agent ?? this.agent);
663
+ ], options.signal, options.agent ?? this.agent, options.timeoutMs ?? fsOpTimeoutMs(options.size));
637
664
  if (result.exitCode !== 0)
638
665
  throw this.fail("move", result, source);
639
666
  const lines = result.stdout.toString("utf8").split("\n").filter((line) => line.length > 0);
package/lib/listing.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare function fullyQualified(path: string): boolean;
51
51
  export declare function ancestryCrumbs(target: string): ListingRow[];
52
52
  /** The three virtual roots the picker's breadcrumb trail is built from. */
53
53
  export interface PickerRoots {
54
- /** The two-category level ("工作区"): Windows paths and WSL distros. */
54
+ /** The two-category level ("Workspace"): Windows paths and WSL distros. */
55
55
  picker: string;
56
56
  /** The Windows branch's drive list. */
57
57
  windows: string;
@@ -63,7 +63,7 @@ export interface PickerRoots {
63
63
  * belongs to, then the path itself.
64
64
  *
65
65
  * The trail is what makes the two top-level categories reachable from anywhere:
66
- * every level keeps "工作区" as its first crumb, so a browse into a distro or a
66
+ * every level keeps the workspace crumb as its first, so a browse into a distro or a
67
67
  * drive never strands the user without a way back to the other world.
68
68
  *
69
69
  * Two Windows path quirks need explicit handling. `win32.dirname` treats
package/lib/listing.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * @module dsh-plugin-wsl-env/listing
12
12
  */
13
13
  import { win32 } from "node:path";
14
+ import { t } from "./messages.js";
14
15
  import { isWslUnc, uncToPosix } from "./paths.js";
15
16
  /**
16
17
  * Whether a path names one fixed filesystem location regardless of process
@@ -61,7 +62,7 @@ export function ancestryCrumbs(target) {
61
62
  * belongs to, then the path itself.
62
63
  *
63
64
  * The trail is what makes the two top-level categories reachable from anywhere:
64
- * every level keeps "工作区" as its first crumb, so a browse into a distro or a
65
+ * every level keeps the workspace crumb as its first, so a browse into a distro or a
65
66
  * drive never strands the user without a way back to the other world.
66
67
  *
67
68
  * Two Windows path quirks need explicit handling. `win32.dirname` treats
@@ -75,13 +76,13 @@ export function ancestryCrumbs(target) {
75
76
  * @returns breadcrumb rows, outermost first.
76
77
  */
77
78
  export function breadcrumbs(target, roots) {
78
- const head = [{ name: "工作区", path: roots.picker, hidden: false }];
79
+ const head = [{ name: t("pickerWorkspace", {}), path: roots.picker, hidden: false }];
79
80
  const parsed = isWslUnc(target) ? uncToPosix(target) : undefined;
80
81
  if (parsed === undefined) {
81
- return [...head, { name: "Windows 路径", path: roots.windows, hidden: false }, ...ancestryCrumbs(target)];
82
+ return [...head, { name: t("pickerWindowsPaths", {}), path: roots.windows, hidden: false }, ...ancestryCrumbs(target)];
82
83
  }
83
84
  const distroRootPath = `${roots.wsl}\\${parsed.distro}`;
84
- head.push({ name: "WSL 发行版", path: roots.wsl, hidden: false });
85
+ head.push({ name: t("pickerWslDistros", {}), path: roots.wsl, hidden: false });
85
86
  head.push({ name: parsed.distro, path: distroRootPath, hidden: false });
86
87
  let current = distroRootPath;
87
88
  for (const segment of parsed.linuxPath.split("/").filter((part) => part.length > 0)) {
package/lib/messages.d.ts CHANGED
@@ -138,6 +138,76 @@ declare const en: {
138
138
  cwd: string;
139
139
  distro: string;
140
140
  }) => string;
141
+ /** `wsl-status`: the route's method guard. */
142
+ statusMethodNotAllowed: () => string;
143
+ /** `wsl-status`: `wsl.exe -l -q` did not answer. */
144
+ statusDistroListFailed: ({ detail }: {
145
+ detail: string;
146
+ }) => string;
147
+ /** `wsl-status`: a repair POST named no distro. */
148
+ statusRepairNeedsDistro: () => string;
149
+ /** `wsl-status`: the requested name is not in `wsl.exe -l -q`. */
150
+ statusUnknownDistro: ({ distro }: {
151
+ distro: string;
152
+ }) => string;
153
+ /** `wsl-open-in-app`: the route's method guard. */
154
+ openInAppPostOnly: () => string;
155
+ /** `wsl-open-in-app`: the route requires a JSON content type. */
156
+ openInAppJsonContentType: () => string;
157
+ /** `wsl-open-in-app`: the request body did not parse as JSON. */
158
+ openInAppInvalidJson: () => string;
159
+ /** `wsl-open-in-app`: the body parsed but is not an object. */
160
+ openInAppBodyNotObject: () => string;
161
+ /** `wsl-open-in-app`: the body's `path` is not a string. */
162
+ openInAppPathMustBeString: () => string;
163
+ /** `wsl-open-in-app`: the path is not a WSL UNC workspace. */
164
+ openInAppNotWslWorkspacePath: () => string;
165
+ /** `wsl-open-in-app`: the detached launch failed. */
166
+ openInAppLaunchFailed: () => string;
167
+ /** `wsl-open-in-app`: no editor executable could be resolved. */
168
+ openInAppExecutableMissing: () => string;
169
+ /** The directory picker's root crumb, shared by every level. */
170
+ pickerWorkspace: () => string;
171
+ /** The directory picker's Windows branch label. */
172
+ pickerWindowsPaths: () => string;
173
+ /** The directory picker's WSL branch label. */
174
+ pickerWslDistros: () => string;
175
+ /** `/wsl-doctor`: the usage block a grammar violation settles with. */
176
+ doctorUsage: ({ sections }: {
177
+ sections: string;
178
+ }) => string;
179
+ /** `/wsl-doctor`: a token that matches no mode, section or distro spelling. */
180
+ doctorUnknownToken: ({ token }: {
181
+ token: string;
182
+ }) => string;
183
+ /** `/wsl-doctor`: `--distro` was not followed by a name. */
184
+ doctorDistroNeedsName: () => string;
185
+ /** `/wsl-doctor`: the CLI run was cancelled. */
186
+ doctorCliCancelled: () => string;
187
+ /** `/wsl-doctor`: the CLI produced no report before the deadline. */
188
+ doctorCliTimeout: ({ seconds }: {
189
+ seconds: number;
190
+ }) => string;
191
+ /** `/wsl-doctor`: the CLI exited without a report. `detail` is "" or ": <stderr>". */
192
+ doctorCliNoReport: ({ status, detail }: {
193
+ status: string;
194
+ detail: string;
195
+ }) => string;
196
+ /** `/wsl-doctor`: the resolved target is one named distro. */
197
+ doctorTargetDistro: ({ distro }: {
198
+ distro: string;
199
+ }) => string;
200
+ /** `/wsl-doctor`: no distro resolved, so the CLI's configured target decides. */
201
+ doctorTargetConfigured: () => string;
202
+ /** `/wsl-doctor`: the CLI run failed; `target` is the localized target phrase. */
203
+ doctorRunFailed: ({ target, message }: {
204
+ target: string;
205
+ message: string;
206
+ }) => string;
207
+ /** `/wsl-doctor`: the command-plane description. */
208
+ doctorCommandDescription: () => string;
209
+ /** `/wsl-doctor`: the input hint under the command name. */
210
+ doctorInputHint: () => string;
141
211
  /** `wsl_doctor` digest: the verdict line. `verdict` is the report's own `ready`/`blocked`. */
142
212
  doctorDigestVerdict: ({ verdict }: {
143
213
  verdict: string;
package/lib/messages.js CHANGED
@@ -106,6 +106,59 @@ const en = {
106
106
  `session runs the host (Windows) environment: commands execute in Windows PowerShell, file access crosses the ` +
107
107
  `9p share, and the distro's Linux toolchain is unavailable. Do not assume Linux commands, paths, or tooling ` +
108
108
  `here; the operator can run /wsl-doctor to diagnose the profile.`,
109
+ /** `wsl-status`: the route's method guard. */
110
+ statusMethodNotAllowed: () => "Only GET and POST are supported",
111
+ /** `wsl-status`: `wsl.exe -l -q` did not answer. */
112
+ statusDistroListFailed: ({ detail }) => `Cannot read the distro list: ${detail}`,
113
+ /** `wsl-status`: a repair POST named no distro. */
114
+ statusRepairNeedsDistro: () => "Repair requires a distro",
115
+ /** `wsl-status`: the requested name is not in `wsl.exe -l -q`. */
116
+ statusUnknownDistro: ({ distro }) => `Unknown distro: ${distro}`,
117
+ /** `wsl-open-in-app`: the route's method guard. */
118
+ openInAppPostOnly: () => "Only POST is supported",
119
+ /** `wsl-open-in-app`: the route requires a JSON content type. */
120
+ openInAppJsonContentType: () => "content-type must be application/json",
121
+ /** `wsl-open-in-app`: the request body did not parse as JSON. */
122
+ openInAppInvalidJson: () => "The request body is not valid JSON",
123
+ /** `wsl-open-in-app`: the body parsed but is not an object. */
124
+ openInAppBodyNotObject: () => "The request body must be an object",
125
+ /** `wsl-open-in-app`: the body's `path` is not a string. */
126
+ openInAppPathMustBeString: () => "path must be a string",
127
+ /** `wsl-open-in-app`: the path is not a WSL UNC workspace. */
128
+ openInAppNotWslWorkspacePath: () => "Not a WSL workspace path",
129
+ /** `wsl-open-in-app`: the detached launch failed. */
130
+ openInAppLaunchFailed: () => "VS Code failed to launch",
131
+ /** `wsl-open-in-app`: no editor executable could be resolved. */
132
+ openInAppExecutableMissing: () => "VS Code was not found; configure executable on the wsl-open-in-app row",
133
+ /** The directory picker's root crumb, shared by every level. */
134
+ pickerWorkspace: () => "Workspace",
135
+ /** The directory picker's Windows branch label. */
136
+ pickerWindowsPaths: () => "Windows paths",
137
+ /** The directory picker's WSL branch label. */
138
+ pickerWslDistros: () => "WSL distros",
139
+ /** `/wsl-doctor`: the usage block a grammar violation settles with. */
140
+ doctorUsage: ({ sections }) => `Usage: /wsl-doctor [quick|full|<section>] [--distro <name>]\n` +
141
+ `section ∈ ${sections}; an empty input means quick. Without --distro the distro is inferred from the session's working directory.`,
142
+ /** `/wsl-doctor`: a token that matches no mode, section or distro spelling. */
143
+ doctorUnknownToken: ({ token }) => `Unrecognized argument: ${token}`,
144
+ /** `/wsl-doctor`: `--distro` was not followed by a name. */
145
+ doctorDistroNeedsName: () => "--distro needs a name",
146
+ /** `/wsl-doctor`: the CLI run was cancelled. */
147
+ doctorCliCancelled: () => "the doctor CLI was cancelled",
148
+ /** `/wsl-doctor`: the CLI produced no report before the deadline. */
149
+ doctorCliTimeout: ({ seconds }) => `the doctor CLI produced no report within ${seconds} seconds; narrow to one distro with --distro <name>, or retry with quick / <section>`,
150
+ /** `/wsl-doctor`: the CLI exited without a report. `detail` is "" or ": <stderr>". */
151
+ doctorCliNoReport: ({ status, detail }) => `the doctor CLI produced no report (exit ${status})${detail}`,
152
+ /** `/wsl-doctor`: the resolved target is one named distro. */
153
+ doctorTargetDistro: ({ distro }) => `distro ${distro}`,
154
+ /** `/wsl-doctor`: no distro resolved, so the CLI's configured target decides. */
155
+ doctorTargetConfigured: () => "the configured target (no distro was resolved from the session working directory; auto checks every installed distro)",
156
+ /** `/wsl-doctor`: the CLI run failed; `target` is the localized target phrase. */
157
+ doctorRunFailed: ({ target, message }) => `doctor run failed (${target}): ${message}`,
158
+ /** `/wsl-doctor`: the command-plane description. */
159
+ doctorCommandDescription: () => "Run the WSL environment doctor (standalone CLI): the report appears here and stays out of the model conversation. No arguments means a quick check.",
160
+ /** `/wsl-doctor`: the input hint under the command name. */
161
+ doctorInputHint: () => "[quick|full|<section>] [--distro <name>]",
109
162
  /** `wsl_doctor` digest: the verdict line. `verdict` is the report's own `ready`/`blocked`. */
110
163
  doctorDigestVerdict: ({ verdict }) => `wsl doctor verdict: ${verdict}`,
111
164
  /** `wsl_doctor` digest: the host-wide group heading. */
@@ -179,6 +232,33 @@ const zh = {
179
232
  hostModePresetUnavailable: ({ cwd, distro }) => `工作区 "${cwd}" 位于 WSL 发行版 "${distro}" 内,但本 profile 未装配 WSL preset,` +
180
233
  `因此本会话运行在宿主(Windows)环境:命令经 PowerShell 执行,文件访问经过 9p 共享,发行版的 Linux 工具链不可用。` +
181
234
  `不要在此假设 Linux 命令、路径或工具;操作者可运行 /wsl-doctor 诊断该 profile。`,
235
+ statusMethodNotAllowed: () => "只支持 GET 与 POST",
236
+ statusDistroListFailed: ({ detail }) => `无法读取发行版清单:${detail}`,
237
+ statusRepairNeedsDistro: () => "修复需要指定发行版",
238
+ statusUnknownDistro: ({ distro }) => `未知发行版:${distro}`,
239
+ openInAppPostOnly: () => "只支持 POST",
240
+ openInAppJsonContentType: () => "content-type 必须是 application/json",
241
+ openInAppInvalidJson: () => "请求体不是合法 JSON",
242
+ openInAppBodyNotObject: () => "请求体必须是对象",
243
+ openInAppPathMustBeString: () => "path 必须是字符串",
244
+ openInAppNotWslWorkspacePath: () => "不是 WSL 工作区路径",
245
+ openInAppLaunchFailed: () => "VS Code 启动失败",
246
+ openInAppExecutableMissing: () => "找不到 VS Code;可在 wsl-open-in-app 行配置 executable",
247
+ pickerWorkspace: () => "工作区",
248
+ pickerWindowsPaths: () => "Windows 路径",
249
+ pickerWslDistros: () => "WSL 发行版",
250
+ doctorUsage: ({ sections }) => `用法:/wsl-doctor [quick|full|<section>] [--distro <名称>]\n` +
251
+ `section ∈ ${sections};空输入等价 quick。省略 --distro 时用当前会话的工作目录推断 distro。`,
252
+ doctorUnknownToken: ({ token }) => `无法识别的参数:${token}`,
253
+ doctorDistroNeedsName: () => "--distro 需要一个名称",
254
+ doctorCliCancelled: () => "doctor CLI 已取消",
255
+ doctorCliTimeout: ({ seconds }) => `doctor CLI 在 ${seconds} 秒内没有给出报告;用 --distro <名称> 收窄到单个发行版,或改用 quick / <分区> 重试`,
256
+ doctorCliNoReport: ({ status, detail }) => `doctor CLI 未能给出报告(exit ${status})${detail}`,
257
+ doctorTargetDistro: ({ distro }) => `发行版 ${distro}`,
258
+ doctorTargetConfigured: () => "配置指定的目标(未从会话工作目录解析出发行版,auto 会逐个检查所有已安装发行版)",
259
+ doctorRunFailed: ({ target, message }) => `doctor 运行失败(${target}):${message}`,
260
+ doctorCommandDescription: () => "运行 WSL 环境诊断(独立 doctor CLI):结果直接显示在此,不进入模型对话。省略参数为快速诊断。",
261
+ doctorInputHint: () => "[quick|full|<section>] [--distro <名称>]",
182
262
  doctorDigestVerdict: ({ verdict }) => `wsl doctor 裁决:${verdict}`,
183
263
  doctorDigestHostLabel: () => "(宿主——Windows 与全局检查)",
184
264
  doctorDigestNotRunLabel: () => "(不在本次范围)",