@neuralnomads/codenomad 0.13.3 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/auth/manager.js +5 -1
  2. package/dist/background-processes/manager.js +164 -25
  3. package/dist/cli-upgrade.js +53 -0
  4. package/dist/cli-upgrade.test.js +31 -0
  5. package/dist/config/schema.js +1 -0
  6. package/dist/events/bus.js +4 -0
  7. package/dist/filesystem/browser.js +15 -1
  8. package/dist/index.js +79 -11
  9. package/dist/opencode-config/package-lock.json +380 -0
  10. package/dist/opencode-config/package.json +2 -2
  11. package/dist/opencode-config/plugin/lib/background-process.ts +14 -2
  12. package/dist/plugins/voice-mode.js +2 -1
  13. package/dist/server/__tests__/network-addresses.test.js +68 -0
  14. package/dist/server/__tests__/remote-proxy.test.js +204 -0
  15. package/dist/server/http-server.js +292 -47
  16. package/dist/server/network-addresses.js +43 -1
  17. package/dist/server/remote-proxy.js +466 -0
  18. package/dist/server/routes/background-processes.js +19 -1
  19. package/dist/server/routes/meta.js +0 -3
  20. package/dist/server/routes/plugin.js +5 -1
  21. package/dist/server/routes/remote-proxy.js +42 -0
  22. package/dist/server/routes/remote-servers.js +142 -0
  23. package/dist/server/routes/settings.js +1 -1
  24. package/dist/server/routes/sidecars.js +46 -0
  25. package/dist/server/routes/workspaces.js +118 -0
  26. package/dist/settings/migrate.js +5 -0
  27. package/dist/settings/service.js +64 -4
  28. package/dist/sidecars/manager.js +193 -0
  29. package/dist/workspaces/__tests__/git-worktrees.test.js +43 -0
  30. package/dist/workspaces/__tests__/spawn.test.js +140 -0
  31. package/dist/workspaces/git-mutations.js +98 -0
  32. package/dist/workspaces/git-status.js +323 -0
  33. package/dist/workspaces/git-worktrees.js +18 -1
  34. package/dist/workspaces/manager.js +11 -4
  35. package/dist/workspaces/opencode-auth.js +18 -0
  36. package/dist/workspaces/opencode-auth.test.js +34 -0
  37. package/dist/workspaces/runtime.js +56 -78
  38. package/dist/workspaces/spawn.js +219 -0
  39. package/dist/workspaces/worktree-directory.js +74 -0
  40. package/package.json +1 -1
  41. package/public/assets/ChangesTab-ovdqLHc3.js +2 -0
  42. package/public/assets/DiffToolbar-B12EfXMX.js +1 -0
  43. package/public/assets/FilesTab-nb_itEXG.js +2 -0
  44. package/public/assets/GitChangesTab-DcT_4BL2.js +2 -0
  45. package/public/assets/{SplitFilePanel-DwrJM7GQ.js → SplitFilePanel-BOHH3F--.js} +1 -1
  46. package/public/assets/StatusTab-Dyt_EG33.js +1 -0
  47. package/public/assets/align-justify-9zpyaAdy.js +1 -0
  48. package/public/assets/{bundle-full-JwmTIwMd.js → bundle-full-xFW13Lny.js} +1 -1
  49. package/public/assets/diff-viewer-xG9yjpN8.js +1 -0
  50. package/public/assets/git-diff-vendor-CSgooKT_.js +52 -0
  51. package/public/assets/index-7DpT014-.js +1 -0
  52. package/public/assets/index-BDK4V9L0.js +1 -0
  53. package/public/assets/index-Bx-Bezt2.js +1 -0
  54. package/public/assets/index-CCAZZY0l.js +1 -0
  55. package/public/assets/index-CEcZq5WB.js +1 -0
  56. package/public/assets/index-CQCmSDHL.js +1 -0
  57. package/public/assets/{index-CkYwnPl7.js → index-Cz_fl8aY.js} +1 -1
  58. package/public/assets/index-Dcgftm1m.css +1 -0
  59. package/public/assets/index-m4C3yx3J.js +1 -0
  60. package/public/assets/index-mh_z9p40.js +2 -0
  61. package/public/assets/{loading-CfqkoCbA.js → loading-HUhLEgb_.js} +1 -1
  62. package/public/assets/main-CKhfaeKI.js +48 -0
  63. package/public/assets/{markdown-D2uUJada.js → markdown-BeXU9Z-x.js} +22 -22
  64. package/public/assets/monaco-viewer-BgP6xpZ6.js +26 -0
  65. package/public/assets/{todo-i3zWdksA.js → todo-D6PVVp_f.js} +1 -1
  66. package/public/assets/tool-call-Dgn3NlA8.js +60 -0
  67. package/public/assets/unified-picker-DuNuUpLy.js +1 -0
  68. package/public/assets/wrap-text-zghCl6wN.js +1 -0
  69. package/public/index.html +5 -5
  70. package/public/loading.html +5 -5
  71. package/public/sw.js +1 -1
  72. package/public/ui-version.json +1 -1
  73. package/public/assets/ChangesTab-X8IIoIdB.js +0 -2
  74. package/public/assets/DiffToolbar-Djg0ksr_.js +0 -1
  75. package/public/assets/FilesTab-BpYPA_Zr.js +0 -2
  76. package/public/assets/GitChangesTab-DeGsV8--.js +0 -2
  77. package/public/assets/StatusTab-mT1B3wST.js +0 -1
  78. package/public/assets/diff-viewer-CKnTxbWB.js +0 -1
  79. package/public/assets/git-diff-vendor-CAv-4upN.js +0 -52
  80. package/public/assets/index-BEzx5r3P.css +0 -1
  81. package/public/assets/index-BHjkPi4D.js +0 -1
  82. package/public/assets/index-CUkIenrg.js +0 -1
  83. package/public/assets/index-D9RMxxcS.js +0 -1
  84. package/public/assets/index-DiFfJ0HM.js +0 -1
  85. package/public/assets/index-LmDdmmJP.js +0 -1
  86. package/public/assets/index-UaIyK67v.js +0 -1
  87. package/public/assets/index-lhjxIgwf.js +0 -2
  88. package/public/assets/index-xsUu1uOf.js +0 -1
  89. package/public/assets/main-B3yZBpaS.js +0 -56
  90. package/public/assets/monaco-viewer-UU9TfOpS.js +0 -15
  91. package/public/assets/tool-call-Bl3Lai68.js +0 -60
  92. package/public/assets/unified-picker-B506AoQt.js +0 -1
@@ -1,10 +1,28 @@
1
1
  import crypto from "node:crypto";
2
2
  export const OPENCODE_SERVER_USERNAME_ENV = "OPENCODE_SERVER_USERNAME";
3
3
  export const OPENCODE_SERVER_PASSWORD_ENV = "OPENCODE_SERVER_PASSWORD";
4
+ export const OPENCODE_SERVER_BASE_URL_ENV = "OPENCODE_SERVER_BASE_URL";
4
5
  export const DEFAULT_OPENCODE_USERNAME = "codenomad";
5
6
  export function generateOpencodeServerPassword() {
6
7
  return crypto.randomBytes(32).toString("base64url");
7
8
  }
9
+ function readConfiguredValue(key, ...sources) {
10
+ for (const source of sources) {
11
+ const value = source?.[key];
12
+ if (typeof value === "string" && value.trim().length > 0) {
13
+ return value;
14
+ }
15
+ }
16
+ return undefined;
17
+ }
18
+ export function resolveOpencodeServerAuth(options = {}) {
19
+ const generatePassword = options.generatePassword ?? generateOpencodeServerPassword;
20
+ const username = readConfiguredValue(OPENCODE_SERVER_USERNAME_ENV, options.userEnvironment, options.processEnv) ??
21
+ DEFAULT_OPENCODE_USERNAME;
22
+ const password = readConfiguredValue(OPENCODE_SERVER_PASSWORD_ENV, options.userEnvironment, options.processEnv) ??
23
+ generatePassword();
24
+ return { username, password };
25
+ }
8
26
  export function buildOpencodeBasicAuthHeader(params) {
9
27
  const username = params.username;
10
28
  const password = params.password;
@@ -0,0 +1,34 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import { resolveOpencodeServerAuth } from "./opencode-auth";
4
+ describe("resolveOpencodeServerAuth", () => {
5
+ it("uses configured OpenCode auth from workspace environment", () => {
6
+ const auth = resolveOpencodeServerAuth({
7
+ userEnvironment: {
8
+ OPENCODE_SERVER_USERNAME: "alice",
9
+ OPENCODE_SERVER_PASSWORD: "secret",
10
+ },
11
+ processEnv: {},
12
+ generatePassword: () => "generated",
13
+ });
14
+ assert.deepEqual(auth, { username: "alice", password: "secret" });
15
+ });
16
+ it("uses process environment when workspace environment does not provide credentials", () => {
17
+ const auth = resolveOpencodeServerAuth({
18
+ userEnvironment: {},
19
+ processEnv: {
20
+ OPENCODE_SERVER_PASSWORD: "process-secret",
21
+ },
22
+ generatePassword: () => "generated",
23
+ });
24
+ assert.deepEqual(auth, { username: "codenomad", password: "process-secret" });
25
+ });
26
+ it("falls back to generated credentials", () => {
27
+ const auth = resolveOpencodeServerAuth({
28
+ userEnvironment: {},
29
+ processEnv: {},
30
+ generatePassword: () => "generated",
31
+ });
32
+ assert.deepEqual(auth, { username: "codenomad", password: "generated" });
33
+ });
34
+ });
@@ -1,77 +1,9 @@
1
1
  import { spawn, spawnSync } from "child_process";
2
2
  import { existsSync, statSync } from "fs";
3
3
  import path from "path";
4
- export const WINDOWS_CMD_EXTENSIONS = new Set([".cmd", ".bat"]);
5
- export const WINDOWS_POWERSHELL_EXTENSIONS = new Set([".ps1"]);
6
- const VERSION_REGEX = /([0-9]+\.[0-9]+\.[0-9A-Za-z.-]+)/;
7
- export function buildSpawnSpec(binaryPath, args) {
8
- if (process.platform !== "win32") {
9
- return { command: binaryPath, args, options: {} };
10
- }
11
- const extension = path.extname(binaryPath).toLowerCase();
12
- if (WINDOWS_CMD_EXTENSIONS.has(extension)) {
13
- const comspec = process.env.ComSpec || "cmd.exe";
14
- // cmd.exe requires the full command as a single string.
15
- // Using the ""<script> <args>"" pattern ensures paths with spaces are handled.
16
- const commandLine = `""${binaryPath}" ${args.join(" ")}"`;
17
- return {
18
- command: comspec,
19
- args: ["/d", "/s", "/c", commandLine],
20
- options: { windowsVerbatimArguments: true },
21
- };
22
- }
23
- if (WINDOWS_POWERSHELL_EXTENSIONS.has(extension)) {
24
- // powershell.exe ships with Windows. (pwsh may not.)
25
- return {
26
- command: "powershell.exe",
27
- args: ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", binaryPath, ...args],
28
- options: {},
29
- };
30
- }
31
- return { command: binaryPath, args, options: {} };
32
- }
33
- export function probeBinaryVersion(binaryPath) {
34
- if (!binaryPath) {
35
- return { valid: false, error: "Missing binary path" };
36
- }
37
- const spec = buildSpawnSpec(binaryPath, ["--version"]);
38
- try {
39
- const result = spawnSync(spec.command, spec.args, {
40
- encoding: "utf8",
41
- windowsVerbatimArguments: Boolean(spec.options.windowsVerbatimArguments),
42
- });
43
- if (result.error) {
44
- return { valid: false, error: result.error.message };
45
- }
46
- if (result.status !== 0) {
47
- const stderr = result.stderr?.trim();
48
- const stdout = result.stdout?.trim();
49
- const combined = stderr || stdout;
50
- const error = combined ? `Exited with code ${result.status}: ${combined}` : `Exited with code ${result.status}`;
51
- return { valid: false, error };
52
- }
53
- const stdoutLines = String(result.stdout ?? "")
54
- .split(/\r?\n/)
55
- .map((line) => line.trim())
56
- .filter((line) => line.length > 0);
57
- const stderrLines = String(result.stderr ?? "")
58
- .split(/\r?\n/)
59
- .map((line) => line.trim())
60
- .filter((line) => line.length > 0);
61
- // Prefer stdout; fall back to stderr (some tools report version there).
62
- const reported = stdoutLines[0] ?? stderrLines[0];
63
- if (!reported) {
64
- return { valid: true };
65
- }
66
- const versionMatch = reported.match(VERSION_REGEX);
67
- const version = versionMatch?.[1];
68
- return { valid: true, version, reported };
69
- }
70
- catch (error) {
71
- return { valid: false, error: error instanceof Error ? error.message : String(error) };
72
- }
73
- }
4
+ import { buildSpawnSpec, buildWslSignalSpec } from "./spawn";
74
5
  const SENSITIVE_ENV_KEY = /(PASSWORD|TOKEN|SECRET)/i;
6
+ const WSL_PID_MARKER = "__CODENOMAD_WSL_PID__:";
75
7
  function redactEnvironment(env) {
76
8
  const redacted = {};
77
9
  for (const [key, value] of Object.entries(env)) {
@@ -91,7 +23,8 @@ export class WorkspaceRuntime {
91
23
  }
92
24
  async launch(options) {
93
25
  this.validateFolder(options.folder);
94
- const args = ["serve", "--port", "0", "--print-logs", "--log-level", "DEBUG"];
26
+ const logLevel = typeof options.logLevel === "string" ? options.logLevel.toUpperCase() : "DEBUG";
27
+ const args = ["serve", "--port", "0", "--print-logs", "--log-level", logLevel];
95
28
  const env = { ...process.env, ...(options.environment ?? {}) };
96
29
  let exitResolve = null;
97
30
  const exitPromise = new Promise((resolveExit) => {
@@ -114,7 +47,13 @@ export class WorkspaceRuntime {
114
47
  return combined.join("\n");
115
48
  };
116
49
  return new Promise((resolve, reject) => {
117
- const spec = buildSpawnSpec(options.binaryPath, args);
50
+ const propagatedEnvKeys = Object.keys(options.environment ?? {});
51
+ const spec = buildSpawnSpec(options.binaryPath, args, {
52
+ cwd: options.folder,
53
+ env,
54
+ propagateEnvKeys: propagatedEnvKeys,
55
+ wslPidMarker: WSL_PID_MARKER,
56
+ });
118
57
  const commandLine = [spec.command, ...spec.args].join(" ");
119
58
  this.logger.info({
120
59
  workspaceId: options.workspaceId,
@@ -133,13 +72,17 @@ export class WorkspaceRuntime {
133
72
  }, "OpenCode spawn environment");
134
73
  const detached = process.platform !== "win32";
135
74
  const child = spawn(spec.command, spec.args, {
136
- cwd: options.folder,
137
- env,
75
+ cwd: spec.cwd,
76
+ env: spec.env,
138
77
  stdio: ["ignore", "pipe", "pipe"],
139
78
  detached,
140
79
  ...spec.options,
141
80
  });
142
- const managed = { child, requestedStop: false };
81
+ const managed = {
82
+ child,
83
+ requestedStop: false,
84
+ ...(spec.wsl ? { wsl: { distro: spec.wsl.distro, linuxPid: null } } : {}),
85
+ };
143
86
  this.processes.set(options.workspaceId, managed);
144
87
  let stdoutBuffer = "";
145
88
  let stderrBuffer = "";
@@ -209,6 +152,14 @@ export class WorkspaceRuntime {
209
152
  const trimmed = line.trim();
210
153
  if (!trimmed)
211
154
  continue;
155
+ if (managed.wsl && trimmed.startsWith(WSL_PID_MARKER)) {
156
+ const linuxPid = Number.parseInt(trimmed.slice(WSL_PID_MARKER.length), 10);
157
+ if (Number.isFinite(linuxPid) && linuxPid > 0) {
158
+ managed.wsl.linuxPid = linuxPid;
159
+ this.logger.debug({ workspaceId: options.workspaceId, linuxPid }, "Captured WSL OpenCode PID");
160
+ }
161
+ continue;
162
+ }
212
163
  recentStdout.push(trimmed);
213
164
  if (recentStdout.length > MAX_OUTPUT_LINES) {
214
165
  recentStdout.shift();
@@ -313,11 +264,38 @@ export class WorkspaceRuntime {
313
264
  return false;
314
265
  }
315
266
  };
267
+ const trySignalWslProcess = (signal) => {
268
+ if (process.platform !== "win32" || !managed.wsl?.linuxPid) {
269
+ return false;
270
+ }
271
+ try {
272
+ const spec = buildWslSignalSpec(managed.wsl.distro, managed.wsl.linuxPid, signal);
273
+ const result = spawnSync(spec.command, spec.args, { encoding: "utf8" });
274
+ const exitCode = result.status;
275
+ if (exitCode === 0) {
276
+ return true;
277
+ }
278
+ const stderr = (result.stderr ?? "").toString().toLowerCase();
279
+ const stdout = (result.stdout ?? "").toString().toLowerCase();
280
+ const combined = `${stdout}\n${stderr}`;
281
+ if (combined.includes("no such process") || combined.includes("not found")) {
282
+ return true;
283
+ }
284
+ this.logger.debug({ workspaceId, pid, linuxPid: managed.wsl.linuxPid, distro: managed.wsl.distro, exitCode, stderr: result.stderr, stdout: result.stdout }, "WSL kill failed");
285
+ return false;
286
+ }
287
+ catch (error) {
288
+ this.logger.debug({ workspaceId, pid, linuxPid: managed.wsl.linuxPid, distro: managed.wsl.distro, err: error }, "WSL kill failed to execute");
289
+ return false;
290
+ }
291
+ };
316
292
  const sendStopSignal = (signal) => {
317
293
  if (process.platform === "win32") {
318
- // Best-effort: terminate the whole process tree rooted at pid.
319
- // Use /F only for escalation.
320
- tryTaskkill(signal === "SIGKILL");
294
+ // WSL-backed launches need a Linux signal first because the tracked Windows PID belongs to wsl.exe.
295
+ if (!trySignalWslProcess(signal)) {
296
+ // Fallback to the Windows process tree rooted at pid. Use /F only for escalation.
297
+ tryTaskkill(signal === "SIGKILL");
298
+ }
321
299
  return;
322
300
  }
323
301
  // Prefer process-group signaling so wrapper launchers (bun/node) don't orphan the real server.
@@ -0,0 +1,219 @@
1
+ import { spawnSync } from "child_process";
2
+ import path from "path";
3
+ export const WINDOWS_CMD_EXTENSIONS = new Set([".cmd", ".bat"]);
4
+ export const WINDOWS_POWERSHELL_EXTENSIONS = new Set([".ps1"]);
5
+ const VERSION_REGEX = /([0-9]+\.[0-9]+\.[0-9A-Za-z.-]+)/;
6
+ const WSL_UNC_PATH_REGEX = /^\\\\wsl(?:\.localhost|\$)\\([^\\/]+)(?:[\\/](.*))?$/i;
7
+ const WSL_PATH_ENV_KEYS = new Set(["OPENCODE_CONFIG_DIR", "NODE_EXTRA_CA_CERTS"]);
8
+ export function parseWslUncPath(input) {
9
+ const normalized = input.trim().replace(/\//g, "\\");
10
+ const match = normalized.match(WSL_UNC_PATH_REGEX);
11
+ if (!match) {
12
+ return null;
13
+ }
14
+ const distro = match[1] ?? "";
15
+ const remainder = match[2] ?? "";
16
+ const segments = remainder.split(/\\+/).filter((segment) => segment.length > 0);
17
+ return {
18
+ distro,
19
+ linuxPath: segments.length > 0 ? `/${segments.join("/")}` : "/",
20
+ };
21
+ }
22
+ export function resolveWslWorkingDirectory(folder, distro) {
23
+ const wslFolder = parseWslUncPath(folder);
24
+ if (wslFolder) {
25
+ return wslFolder.distro.toLowerCase() === distro.toLowerCase() ? { kind: "linux", path: wslFolder.linuxPath } : null;
26
+ }
27
+ const windowsFolder = normalizeWindowsPath(folder);
28
+ return windowsFolder ? { kind: "windows", path: windowsFolder } : null;
29
+ }
30
+ export function buildWindowsSpawnSpec(binaryPath, args, options = {}) {
31
+ const wslPath = parseWslUncPath(binaryPath);
32
+ if (wslPath) {
33
+ return buildWslSpawnSpec(wslPath, args, options);
34
+ }
35
+ const extension = path.extname(binaryPath).toLowerCase();
36
+ if (WINDOWS_CMD_EXTENSIONS.has(extension)) {
37
+ const comspec = process.env.ComSpec || "cmd.exe";
38
+ // cmd.exe requires the full command as a single string.
39
+ // Using the ""<script> <args>"" pattern ensures paths with spaces are handled.
40
+ const commandLine = `""${binaryPath}" ${args.join(" ")}"`;
41
+ return {
42
+ command: comspec,
43
+ args: ["/d", "/s", "/c", commandLine],
44
+ options: { windowsVerbatimArguments: true },
45
+ cwd: options.cwd,
46
+ env: options.env,
47
+ };
48
+ }
49
+ if (WINDOWS_POWERSHELL_EXTENSIONS.has(extension)) {
50
+ // powershell.exe ships with Windows. (pwsh may not.)
51
+ return {
52
+ command: "powershell.exe",
53
+ args: ["-NoProfile", "-ExecutionPolicy", "Bypass", "-File", binaryPath, ...args],
54
+ options: {},
55
+ cwd: options.cwd,
56
+ env: options.env,
57
+ };
58
+ }
59
+ return {
60
+ command: binaryPath,
61
+ args,
62
+ options: {},
63
+ cwd: options.cwd,
64
+ env: options.env,
65
+ };
66
+ }
67
+ export function buildSpawnSpec(binaryPath, args, options = {}) {
68
+ if (process.platform !== "win32") {
69
+ return {
70
+ command: binaryPath,
71
+ args,
72
+ options: {},
73
+ cwd: options.cwd,
74
+ env: options.env,
75
+ };
76
+ }
77
+ return buildWindowsSpawnSpec(binaryPath, args, options);
78
+ }
79
+ export function buildWslSignalSpec(distro, linuxPid, signal) {
80
+ return {
81
+ command: "wsl.exe",
82
+ args: ["--distribution", distro, "--exec", "kill", signal === "SIGKILL" ? "-KILL" : "-TERM", String(linuxPid)],
83
+ options: {},
84
+ wsl: { distro },
85
+ };
86
+ }
87
+ export function probeBinaryVersion(binaryPath) {
88
+ if (!binaryPath) {
89
+ return { valid: false, error: "Missing binary path" };
90
+ }
91
+ try {
92
+ const spec = buildSpawnSpec(binaryPath, ["--version"]);
93
+ const result = spawnSync(spec.command, spec.args, {
94
+ encoding: "utf8",
95
+ cwd: spec.cwd,
96
+ env: spec.env,
97
+ windowsVerbatimArguments: Boolean(spec.options.windowsVerbatimArguments),
98
+ });
99
+ if (result.error) {
100
+ return { valid: false, error: result.error.message };
101
+ }
102
+ if (result.status !== 0) {
103
+ const stderr = result.stderr?.trim();
104
+ const stdout = result.stdout?.trim();
105
+ const combined = stderr || stdout;
106
+ const error = combined ? `Exited with code ${result.status}: ${combined}` : `Exited with code ${result.status}`;
107
+ return { valid: false, error };
108
+ }
109
+ const stdoutLines = String(result.stdout ?? "")
110
+ .split(/\r?\n/)
111
+ .map((line) => line.trim())
112
+ .filter((line) => line.length > 0);
113
+ const stderrLines = String(result.stderr ?? "")
114
+ .split(/\r?\n/)
115
+ .map((line) => line.trim())
116
+ .filter((line) => line.length > 0);
117
+ // Prefer stdout; fall back to stderr (some tools report version there).
118
+ const reported = stdoutLines[0] ?? stderrLines[0];
119
+ if (!reported) {
120
+ return { valid: true };
121
+ }
122
+ const versionMatch = reported.match(VERSION_REGEX);
123
+ const version = versionMatch?.[1];
124
+ return { valid: true, version, reported };
125
+ }
126
+ catch (error) {
127
+ return { valid: false, error: error instanceof Error ? error.message : String(error) };
128
+ }
129
+ }
130
+ function buildWslSpawnSpec(wslPath, args, options) {
131
+ const workingDirectory = options.cwd ? resolveWslWorkingDirectory(options.cwd, wslPath.distro) : undefined;
132
+ if (options.cwd && !workingDirectory) {
133
+ throw new Error(`Unable to translate workspace folder for WSL binary in distro "${wslPath.distro}": ${options.cwd}`);
134
+ }
135
+ const wslArgs = ["--distribution", wslPath.distro];
136
+ const shouldWrapWithShell = Boolean(options.wslPidMarker) || workingDirectory?.kind === "windows";
137
+ if (!shouldWrapWithShell && workingDirectory?.kind === "linux") {
138
+ wslArgs.push("--cd", workingDirectory.path);
139
+ }
140
+ if (shouldWrapWithShell) {
141
+ const launchScript = buildWslLaunchScript(workingDirectory ?? undefined, options.wslPidMarker);
142
+ wslArgs.push("--exec", "sh", "-lc", launchScript, "codenomad-wsl-launch");
143
+ if (workingDirectory) {
144
+ wslArgs.push(workingDirectory.path);
145
+ }
146
+ wslArgs.push(wslPath.linuxPath, ...args);
147
+ }
148
+ else {
149
+ wslArgs.push("--exec", wslPath.linuxPath, ...args);
150
+ }
151
+ return {
152
+ command: "wsl.exe",
153
+ args: wslArgs,
154
+ options: {},
155
+ env: buildWslEnvironment(options.env, options.propagateEnvKeys),
156
+ wsl: { distro: wslPath.distro, pidMarker: options.wslPidMarker },
157
+ };
158
+ }
159
+ function buildWslLaunchScript(workingDirectory, pidMarker) {
160
+ const steps = [];
161
+ if (pidMarker) {
162
+ steps.push(`printf '%s%s\\n' '${pidMarker}' "$$"`);
163
+ }
164
+ if (workingDirectory?.kind === "linux") {
165
+ steps.push('cd "$1"');
166
+ steps.push("shift");
167
+ }
168
+ else if (workingDirectory?.kind === "windows") {
169
+ steps.push('cd "$(wslpath -au "$1")"');
170
+ steps.push("shift");
171
+ }
172
+ steps.push('exec "$@"');
173
+ return steps.join(" && ");
174
+ }
175
+ function normalizeWindowsPath(input) {
176
+ const normalized = path.win32.normalize(input.trim().replace(/\//g, "\\"));
177
+ if (!normalized) {
178
+ return null;
179
+ }
180
+ if (/^[A-Za-z]:/.test(normalized) || normalized.startsWith("\\\\")) {
181
+ return normalized;
182
+ }
183
+ return null;
184
+ }
185
+ function buildWslEnvironment(env, propagateEnvKeys) {
186
+ if (!env) {
187
+ return env;
188
+ }
189
+ const keysToPropagate = Array.from(new Set([
190
+ ...(propagateEnvKeys ?? []).filter((key) => env[key] !== undefined),
191
+ ...Array.from(WSL_PATH_ENV_KEYS).filter((key) => env[key] !== undefined),
192
+ ]));
193
+ if (keysToPropagate.length === 0) {
194
+ return env;
195
+ }
196
+ const next = { ...env };
197
+ const entries = (next.WSLENV ?? "").split(":").filter((entry) => entry.length > 0);
198
+ const byName = new Map(entries.map((entry) => [entry.split("/")[0] ?? entry, entry]));
199
+ for (const key of keysToPropagate) {
200
+ const existingEntry = byName.get(key);
201
+ if (existingEntry) {
202
+ byName.set(key, ensureWslenvEntry(existingEntry, WSL_PATH_ENV_KEYS.has(key)));
203
+ continue;
204
+ }
205
+ byName.set(key, WSL_PATH_ENV_KEYS.has(key) ? `${key}/p` : key);
206
+ }
207
+ next.WSLENV = Array.from(byName.values()).join(":");
208
+ return next;
209
+ }
210
+ function ensureWslenvEntry(entry, requiresPathTranslation) {
211
+ if (!requiresPathTranslation) {
212
+ return entry;
213
+ }
214
+ const [name, rawFlags = ""] = entry.split("/");
215
+ if (rawFlags.includes("p")) {
216
+ return entry;
217
+ }
218
+ return rawFlags.length > 0 ? `${name}/${rawFlags}p` : `${name}/p`;
219
+ }
@@ -0,0 +1,74 @@
1
+ import { realpath } from "fs/promises";
2
+ import { listWorktrees, resolveRepoRoot } from "./git-worktrees";
3
+ const WORKTREE_CACHE_TTL_MS = 2000;
4
+ const worktreeCache = new Map();
5
+ async function normalizeDirectoryPath(directory) {
6
+ const trimmed = (directory ?? "").trim();
7
+ if (!trimmed)
8
+ return "";
9
+ try {
10
+ return await realpath(trimmed);
11
+ }
12
+ catch {
13
+ return trimmed;
14
+ }
15
+ }
16
+ async function getCachedWorktrees(params) {
17
+ const cached = worktreeCache.get(params.workspaceId);
18
+ const now = Date.now();
19
+ if (cached && cached.expiresAt > now) {
20
+ return cached;
21
+ }
22
+ const { repoRoot } = await resolveRepoRoot(params.workspacePath, params.logger);
23
+ const worktrees = await listWorktrees({ repoRoot, workspaceFolder: params.workspacePath, logger: params.logger });
24
+ const entry = {
25
+ expiresAt: now + WORKTREE_CACHE_TTL_MS,
26
+ repoRoot,
27
+ worktrees: await Promise.all(worktrees.map(async (wt) => ({
28
+ slug: wt.slug,
29
+ directory: wt.directory,
30
+ normalizedDirectory: await normalizeDirectoryPath(wt.directory),
31
+ }))),
32
+ };
33
+ worktreeCache.set(params.workspaceId, entry);
34
+ return entry;
35
+ }
36
+ export async function resolveWorktreeDirectory(params) {
37
+ const cached = await getCachedWorktrees({
38
+ workspaceId: params.workspaceId,
39
+ workspacePath: params.workspacePath,
40
+ logger: params.logger,
41
+ });
42
+ const match = cached.worktrees.find((wt) => wt.slug === params.worktreeSlug);
43
+ if (match) {
44
+ return match.directory;
45
+ }
46
+ worktreeCache.delete(params.workspaceId);
47
+ const refreshed = await getCachedWorktrees({
48
+ workspaceId: params.workspaceId,
49
+ workspacePath: params.workspacePath,
50
+ logger: params.logger,
51
+ });
52
+ return refreshed.worktrees.find((wt) => wt.slug === params.worktreeSlug)?.directory ?? null;
53
+ }
54
+ export async function resolveWorktreeSlugForDirectory(params) {
55
+ const target = await normalizeDirectoryPath(params.directory ?? "");
56
+ if (!target)
57
+ return null;
58
+ const cached = await getCachedWorktrees({
59
+ workspaceId: params.workspaceId,
60
+ workspacePath: params.workspacePath,
61
+ logger: params.logger,
62
+ });
63
+ const match = cached.worktrees.find((wt) => wt.normalizedDirectory === target);
64
+ if (match) {
65
+ return match.slug;
66
+ }
67
+ worktreeCache.delete(params.workspaceId);
68
+ const refreshed = await getCachedWorktrees({
69
+ workspaceId: params.workspaceId,
70
+ workspacePath: params.workspacePath,
71
+ logger: params.logger,
72
+ });
73
+ return refreshed.worktrees.find((wt) => wt.normalizedDirectory === target)?.slug ?? null;
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuralnomads/codenomad",
3
- "version": "0.13.3",
3
+ "version": "0.15.0",
4
4
  "description": "CodeNomad Server",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-BgP6xpZ6.js","assets/git-diff-vendor-CSgooKT_.js","assets/fast-diff-vendor-DgdwVvTQ.js","assets/highlight-vendor-8FKMu9os.js","assets/git-diff-vendor-HAZkIolJ.css"])))=>i.map(i=>d[i]);
2
+ import{_ as K}from"./index-mh_z9p40.js";import{m as B,t as g,i as a,d as w,a as z,f as N}from"./monaco-viewer-BgP6xpZ6.js";import{c as f,n as c,a as L,F,S as W,z as j,A as q}from"./git-diff-vendor-CSgooKT_.js";import{D as G}from"./DiffToolbar-B12EfXMX.js";import{S as H}from"./SplitFilePanel-BOHH3F--.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";import"./main-CKhfaeKI.js";import"./align-justify-9zpyaAdy.js";import"./wrap-text-zghCl6wN.js";var J=g('<div class="file-viewer-panel flex-1"><div class="file-viewer-content file-viewer-content--monaco">'),T=g("<div class=file-viewer-empty><span class=file-viewer-empty-text>"),Q=g('<div class="p-3 text-xs text-secondary">'),E=g("<div><div class=file-list-item-content><div class=file-list-item-path><span class=file-path-text></span></div><div class=file-list-item-stats><span class=file-list-item-additions>+</span><span class=file-list-item-deletions>-"),U=g("<span class=files-tab-selected-path><span class=file-path-text>"),X=g('<div class=files-tab-stats style="flex:0 0 auto"><span class="files-tab-stat files-tab-stat-additions"><span class=files-tab-stat-value>+</span></span><span class="files-tab-stat files-tab-stat-deletions"><span class=files-tab-stat-value>-'),Y=g("<div style=margin-left:auto>");const Z=q(()=>K(()=>import("./monaco-viewer-BgP6xpZ6.js").then(e=>e.ad),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.MonacoDiffViewer}))),ce=e=>{const M=f(()=>e.activeSessionId()),S=f(()=>!!(M()&&M()!=="info")),D=f(()=>S()?e.activeSessionDiffs():null),m=f(()=>{const n=D();return Array.isArray(n)?[...n].sort((i,l)=>String(i.file||"").localeCompare(String(l.file||""))):[]}),R=f(()=>m().reduce((n,i)=>(n.additions+=typeof i.additions=="number"?i.additions:0,n.deletions+=typeof i.deletions=="number"?i.deletions:0,n),{additions:0,deletions:0})),I=f(()=>{const n=m();return n.length===0?null:n.reduce((i,l)=>{const v=typeof(i==null?void 0:i.additions)=="number"?i.additions:0,y=typeof(i==null?void 0:i.deletions)=="number"?i.deletions:0,x=v+y,k=typeof(l==null?void 0:l.additions)=="number"?l.additions:0,t=typeof(l==null?void 0:l.deletions)=="number"?l.deletions:0,r=k+t;return r>x?l:r<x?i:String(l.file||"").localeCompare(String((i==null?void 0:i.file)||""))<0?l:i},n[0])}),P=f(()=>{const n=e.selectedFile(),i=m();if(n){const l=i.find(v=>v.file===n);if(l)return l}return I()}),O=f(()=>`${e.instanceId}:${S()?M():"no-session"}`),V=f(()=>{if(!S())return e.t("instanceShell.sessionChanges.noSessionSelected");const n=D();return n===void 0?e.t("instanceShell.sessionChanges.loading"):!Array.isArray(n)||n.length===0?e.t("instanceShell.sessionChanges.empty"):e.t("instanceShell.filesShell.viewerEmpty")}),A=f(()=>{const n=P();return n!=null&&n.file?String(n.file):e.t("instanceShell.rightPanel.tabs.changes")});return B(()=>{const n=m(),i=R(),l=P(),v=()=>(()=>{var t=J(),r=t.firstChild;return a(r,c(W,{get when(){return l&&S()&&n.length>0?l:null},get fallback(){return(()=>{var d=T(),s=d.firstChild;return a(s,V),d})()},children:d=>c(j,{get fallback(){return(()=>{var s=T(),u=s.firstChild;return a(u,()=>e.t("instanceInfo.loading")),s})()},get children(){return c(Z,{get scopeKey(){return O()},get path(){return String(d().file||"")},get patch(){return String(d().patch||"")},get viewMode(){return e.diffViewMode()},get contextMode(){return e.diffContextMode()},get wordWrap(){return e.diffWordWrapMode()}})}})})),t})(),y=()=>(()=>{var t=Q();return a(t,V),t})();return c(H,{get header(){return[(()=>{var t=U(),r=t.firstChild;return a(r,A),L(()=>w(t,"title",A())),t})(),(()=>{var t=X(),r=t.firstChild,d=r.firstChild;d.firstChild;var s=r.nextSibling,u=s.firstChild;return u.firstChild,a(d,()=>i.additions,null),a(u,()=>i.deletions,null),t})(),(()=>{var t=Y();return a(t,c(G,{get viewMode(){return e.diffViewMode()},get contextMode(){return e.diffContextMode()},get wordWrapMode(){return e.diffWordWrapMode()},get onViewModeChange(){return e.onViewModeChange},get onContextModeChange(){return e.onContextModeChange},get onWordWrapModeChange(){return e.onWordWrapModeChange}})),t})()]},list:{panel:()=>c(W,{get when(){return n.length>0},get fallback(){return y()},get children(){return c(F,{each:n,children:t=>(()=>{var r=E(),d=r.firstChild,s=d.firstChild,u=s.firstChild,b=s.nextSibling,h=b.firstChild;h.firstChild;var C=h.nextSibling;return C.firstChild,r.$$click=()=>{e.onSelectFile(t.file,e.isPhoneLayout())},a(u,()=>t.file),a(h,()=>t.additions,null),a(C,()=>t.deletions,null),L(o=>{var _=`file-list-item ${(l==null?void 0:l.file)===t.file?"file-list-item-active":""}`,$=t.file;return _!==o.e&&z(r,o.e=_),$!==o.t&&w(s,"title",o.t=$),o},{e:void 0,t:void 0}),r})()})}}),overlay:()=>c(W,{get when(){return n.length>0},get fallback(){return y()},get children(){return c(F,{each:n,children:t=>(()=>{var r=E(),d=r.firstChild,s=d.firstChild,u=s.firstChild,b=s.nextSibling,h=b.firstChild;h.firstChild;var C=h.nextSibling;return C.firstChild,r.$$click=()=>{e.onSelectFile(t.file,!0)},a(u,()=>t.file),a(h,()=>t.additions,null),a(C,()=>t.deletions,null),L(o=>{var _=`file-list-item ${(l==null?void 0:l.file)===t.file?"file-list-item-active":""}`,$=t.file,p=t.file;return _!==o.e&&z(r,o.e=_),$!==o.t&&w(r,"title",o.t=$),p!==o.a&&w(s,"title",o.a=p),o},{e:void 0,t:void 0,a:void 0}),r})()})}})},get viewer(){return v()},get listOpen(){return e.listOpen()},get onToggleList(){return e.onToggleList},get splitWidth(){return e.splitWidth()},get onResizeMouseDown(){return e.onResizeMouseDown},get onResizeTouchStart(){return e.onResizeTouchStart},get isPhoneLayout(){return e.isPhoneLayout()},get overlayAriaLabel(){return e.t("instanceShell.rightPanel.tabs.changes")}})})};N(["click"]);export{ce as default};
@@ -0,0 +1 @@
1
+ import{t as g,i as c,m as W,d as i,a as S,f as C}from"./monaco-viewer-BgP6xpZ6.js";import{u as T}from"./index-mh_z9p40.js";import{n as o,m as $,a as V}from"./git-diff-vendor-CSgooKT_.js";import{I as U,S as A,U as I}from"./main-CKhfaeKI.js";import{A as D}from"./align-justify-9zpyaAdy.js";import{W as E}from"./wrap-text-zghCl6wN.js";const F=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],H=t=>o(U,$(t,{name:"UnfoldVertical",iconNode:F}));var N=g("<div class=file-viewer-toolbar><button type=button class=file-viewer-toolbar-icon-button></button><button type=button class=file-viewer-toolbar-icon-button></button><button type=button>");const B=t=>{const{t:a}=T(),d=()=>t.viewMode==="split"?"unified":"split",s=()=>t.contextMode==="collapsed"?"expanded":"collapsed",f=()=>t.wordWrapMode==="on"?"off":"on",h=()=>d()==="split"?a("instanceShell.diff.switchToSplit"):a("instanceShell.diff.switchToUnified"),v=()=>s()==="collapsed"?a("instanceShell.diff.hideUnchanged"):a("instanceShell.diff.showFull"),u=()=>f()==="on"?a("instanceShell.diff.enableWordWrap"):a("instanceShell.diff.disableWordWrap");return(()=>{var b=N(),n=b.firstChild,l=n.nextSibling,r=l.nextSibling;return n.$$click=()=>t.onViewModeChange(d()),c(n,(()=>{var e=W(()=>d()==="split");return()=>e()?o(A,{class:"h-4 w-4","aria-hidden":"true"}):o(D,{class:"h-4 w-4","aria-hidden":"true"})})()),l.$$click=()=>t.onContextModeChange(s()),c(l,(()=>{var e=W(()=>s()==="collapsed");return()=>e()?o(I,{class:"h-4 w-4","aria-hidden":"true"}):o(H,{class:"h-4 w-4","aria-hidden":"true"})})()),r.$$click=()=>t.onWordWrapModeChange(f()),c(r,o(E,{class:"h-4 w-4","aria-hidden":"true"})),V(e=>{var m=h(),w=h(),M=v(),p=v(),x=`file-viewer-toolbar-icon-button${t.wordWrapMode==="on"?" active":""}`,k=u(),y=u();return m!==e.e&&i(n,"aria-label",e.e=m),w!==e.t&&i(n,"title",e.t=w),M!==e.a&&i(l,"aria-label",e.a=M),p!==e.o&&i(l,"title",e.o=p),x!==e.i&&S(r,e.i=x),k!==e.n&&i(r,"aria-label",e.n=k),y!==e.s&&i(r,"title",e.s=y),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),b})()};C(["click"]);export{B as D};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-BgP6xpZ6.js","assets/git-diff-vendor-CSgooKT_.js","assets/fast-diff-vendor-DgdwVvTQ.js","assets/highlight-vendor-8FKMu9os.js","assets/git-diff-vendor-HAZkIolJ.css"])))=>i.map(i=>d[i]);
2
+ import{_ as G}from"./index-mh_z9p40.js";import{Z as J,m,t as h,i as s,d as u,a as C,u as U,f as X}from"./monaco-viewer-BgP6xpZ6.js";import{n as o,m as Y,d as A,b as P,c as $,S as g,a as w,z as p,A as ee,F as te}from"./git-diff-vendor-CSgooKT_.js";import{S as le}from"./SplitFilePanel-BOHH3F--.js";import{I as ne,R as K,M as re,V as ae,C as ie,z as se,W as oe}from"./main-CKhfaeKI.js";import{W as ce}from"./wrap-text-zghCl6wN.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";const de=[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]],he=e=>o(ne,Y(e,{name:"Save",iconNode:de}));var ue=h('<div class="px-2 py-2 border-b border-base"><div class=selector-input-group><div class="flex items-center gap-2 px-3 text-muted"></div><input type=text class=selector-input>'),ve=h("<div class=file-list-header><span class=file-list-title></span><span class=file-list-count>"),q=h('<div class="p-3 text-xs text-secondary">'),fe=h("<div class=file-list-item><div class=file-list-item-content><div class=file-list-item-path><span class=file-path-text>.."),ge=h('<div class="p-3 text-xs text-error">'),we=h('<div><div class=file-list-item-content><div class=file-list-item-path><span class=file-path-text></span></div><div class="flex items-center gap-2 shrink-0"><div class=file-list-item-stats><span class="text-[10px] text-secondary"></span></div><button type=button class=git-change-row-action>'),k=h("<div class=file-viewer-empty><span class=file-viewer-empty-text>"),Se=h('<div class="file-viewer-panel flex-1"><div>'),be=h('<div class="h-full outline-none"tabindex=0>'),me=h("<span>"),$e=h("<div class=files-tab-stats><span class=files-tab-stat><span class=files-tab-selected-path><span class=file-path-text>"),ye=h("<button type=button style=margin-inline-start:auto>"),_e=h("<button type=button>"),O=h("<button type=button class=files-header-icon-button>"),Ce=h("<span class=text-error>");const ke=ee(()=>G(()=>import("./monaco-viewer-BgP6xpZ6.js").then(e=>e.ae),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.MonacoFileViewer})));function xe(e){return e?/\.(md|markdown|mdown|mkdn)$/i.test(e):!1}const Ie=e=>{const[E,L]=A(""),{isDark:N}=J(),[Q,M]=A(!1);let S;P(()=>{e.browserPath(),L("")});const H=$(()=>[...e.browserEntries()||[]].sort((i,d)=>{const l=i.type==="directory"?0:1,t=d.type==="directory"?0:1;return l!==t?l-t:String(i.name||"").localeCompare(String(d.name||""))})),W=$(()=>E().trim().toLowerCase()),x=$(()=>{const n=W(),i=H();return n?i.filter(d=>String(d.name||"").toLowerCase().includes(n)):i}),y=()=>e.browserLoading()&&e.browserEntries()===null,Z=()=>W()?e.t("instanceShell.filesShell.search.empty"):e.t("instanceShell.filesShell.listEmpty"),_=$(()=>xe(e.browserSelectedPath())),b=$(()=>_()&&Q());P(()=>{_()||M(!1)});const D=()=>{const n=e.browserSelectedContent();n!=null&&e.onSave(n)},j=async(n,i)=>{i==null||i.stopPropagation();const d=await se(n);oe({message:d?e.t("instanceShell.filesShell.toast.copyPathSuccess"):e.t("instanceShell.filesShell.toast.copyPathError"),variant:d?"success":"error"})};P(()=>{b()&&requestAnimationFrame(()=>S==null?void 0:S.focus())});const T=()=>[(()=>{var n=ue(),i=n.firstChild,d=i.firstChild,l=d.nextSibling;return s(d,o(ae,{class:"w-4 h-4"})),l.$$input=t=>L(t.currentTarget.value),w(t=>{var a=e.t("instanceShell.filesShell.search.placeholder"),r=e.t("instanceShell.filesShell.search.ariaLabel");return a!==t.e&&u(l,"placeholder",t.e=a),r!==t.t&&u(l,"aria-label",t.t=r),t},{e:void 0,t:void 0}),w(()=>l.value=E()),n})(),(()=>{var n=ve(),i=n.firstChild,d=i.nextSibling;return s(i,()=>e.t("instanceShell.filesShell.fileListTitle")),s(d,()=>x().length),n})(),o(g,{get when(){return e.parentPath()},children:n=>(()=>{var i=fe(),d=i.firstChild,l=d.firstChild;return i.$$click=()=>e.onLoadEntries(n()),w(()=>u(l,"title",n())),i})()}),o(g,{get when(){return y()},get children(){var n=q();return s(n,()=>e.t("instanceInfo.loading")),n}}),o(g,{get when(){return m(()=>!e.browserError()&&!y())()&&x().length>0},get fallback(){return m(()=>!y())()?m(()=>!!e.browserError())()?(()=>{var n=ge();return s(n,()=>e.browserError()),n})():(()=>{var n=q();return s(n,Z),n})():void 0},get children(){return o(te,{get each(){return x()},children:n=>(()=>{var i=we(),d=i.firstChild,l=d.firstChild,t=l.firstChild,a=l.nextSibling,r=a.firstChild,c=r.firstChild,f=r.nextSibling;return i.$$click=()=>{if(n.type==="directory"){e.onLoadEntries(n.path);return}e.onRequestOpenFile(n.path)},s(t,()=>n.name),s(c,()=>n.type),f.$$click=v=>void j(n.path,v),s(f,o(ie,{class:"w-3 h-3"})),w(v=>{var z=`file-list-item ${e.browserSelectedPath()===n.path?"file-list-item-active":""}`,F=n.path,I=n.path,R=e.t("instanceShell.filesShell.actions.copyPath"),V=e.t("instanceShell.filesShell.actions.copyPath");return z!==v.e&&C(i,v.e=z),F!==v.t&&u(i,"title",v.t=F),I!==v.a&&u(l,"title",v.a=I),R!==v.o&&u(f,"title",v.o=R),V!==v.i&&u(f,"aria-label",v.i=V),v},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()})}})],B=n=>{!(n.ctrlKey||n.metaKey)||n.key.toLowerCase()!=="s"||e.browserSelectedSaving()||!e.browserSelectedDirty()||(n.preventDefault(),D())};return m(()=>{const n=()=>e.browserSelectedPath()||e.browserPath(),i=()=>y()?e.t("instanceInfo.loading"):e.t("instanceShell.filesShell.viewerEmpty"),d=()=>(()=>{var l=Se(),t=l.firstChild;return s(t,o(g,{get when(){return e.browserSelectedLoading()},get fallback(){return o(g,{get when(){return e.browserSelectedError()},get fallback(){return o(g,{get when(){return m(()=>!!(e.browserSelectedPath()&&e.browserSelectedContent()!==null))()?{path:e.browserSelectedPath(),content:e.browserSelectedContent()}:null},get fallback(){return(()=>{var a=k(),r=a.firstChild;return s(r,i),a})()},children:a=>o(g,{get when(){return b()},get fallback(){return o(p,{get fallback(){return(()=>{var r=k(),c=r.firstChild;return s(c,()=>e.t("instanceInfo.loading")),r})()},get children(){return o(ke,{get scopeKey(){return e.scopeKey()},get path(){return a().path},get content(){return a().content},get wordWrap(){return e.wordWrapMode()},get onSave(){return e.onSave},get onContentChange(){return e.onContentChange}})}})},get children(){var r=be();r.$$mousedown=()=>S==null?void 0:S.focus(),r.$$keydown=B;var c=S;return typeof c=="function"?U(c,r):S=r,s(r,o(re,{get part(){return{type:"text",text:a().content}},get isDark(){return N()},escapeRawHtml:!0})),r}})})},children:a=>(()=>{var r=k(),c=r.firstChild;return s(c,a),r})()})},get children(){var a=k(),r=a.firstChild;return s(r,()=>e.t("instanceInfo.loading")),a}})),w(()=>C(t,b()?"file-viewer-content":"file-viewer-content file-viewer-content--monaco")),l})();return o(le,{get header(){return[(()=>{var l=$e(),t=l.firstChild,a=t.firstChild,r=a.firstChild;return s(r,n),s(l,o(g,{get when(){return e.browserLoading()},get children(){var c=me();return s(c,()=>e.t("instanceInfo.loading")),c}}),null),s(l,o(g,{get when(){return e.browserError()},children:c=>(()=>{var f=Ce();return s(f,c),f})()}),null),w(()=>u(a,"title",n())),l})(),(()=>{var l=ye();return l.$$click=()=>_()&&M(t=>!t),s(l,(()=>{var t=m(()=>!!b());return()=>t()?e.t("instanceShell.filesShell.showSource"):e.t("instanceShell.filesShell.previewMarkdown")})()),w(t=>{var a=`file-viewer-toolbar-button${b()?" active":""}`,r=!_();return a!==t.e&&C(l,t.e=a),r!==t.t&&(l.disabled=t.t=r),t},{e:void 0,t:void 0}),l})(),(()=>{var l=_e();return l.$$click=()=>e.onWordWrapModeChange(e.wordWrapMode()==="on"?"off":"on"),s(l,o(ce,{class:"h-4 w-4"})),w(t=>{var a=`file-viewer-toolbar-icon-button${e.wordWrapMode()==="on"?" active":""}`,r=e.wordWrapMode()==="on"?e.t("instanceShell.filesShell.disableWordWrap"):e.t("instanceShell.filesShell.enableWordWrap"),c=e.wordWrapMode()==="on"?e.t("instanceShell.filesShell.disableWordWrap"):e.t("instanceShell.filesShell.enableWordWrap"),f=b();return a!==t.e&&C(l,t.e=a),r!==t.t&&u(l,"title",t.t=r),c!==t.a&&u(l,"aria-label",t.a=c),f!==t.o&&(l.disabled=t.o=f),t},{e:void 0,t:void 0,a:void 0,o:void 0}),l})(),(()=>{var l=O();return l.$$click=D,s(l,o(g,{get when(){return e.browserSelectedSaving()},get fallback(){return o(he,{class:"h-4 w-4"})},get children(){return o(K,{class:"h-4 w-4 animate-spin"})}})),w(t=>{var a=e.t("instanceShell.rightPanel.actions.save")||"Save (Ctrl+S)",r=e.t("instanceShell.rightPanel.actions.save")||"Save",c=e.browserSelectedSaving()||!e.browserSelectedDirty();return a!==t.e&&u(l,"title",t.e=a),r!==t.t&&u(l,"aria-label",t.t=r),c!==t.a&&(l.disabled=t.a=c),t},{e:void 0,t:void 0,a:void 0}),l})(),(()=>{var l=O();return l.$$click=()=>e.onRefresh(),s(l,o(K,{get class(){return`h-4 w-4${e.browserLoading()?" animate-spin":""}`}})),w(t=>{var a=e.t("instanceShell.rightPanel.actions.refresh"),r=e.t("instanceShell.rightPanel.actions.refresh"),c=e.browserLoading();return a!==t.e&&u(l,"title",t.e=a),r!==t.t&&u(l,"aria-label",t.t=r),c!==t.a&&(l.disabled=t.a=c),t},{e:void 0,t:void 0,a:void 0}),l})()]},list:{panel:()=>o(T,{}),overlay:()=>o(T,{})},get viewer(){return d()},get listOpen(){return e.listOpen()},get onToggleList(){return e.onToggleList},get splitWidth(){return e.splitWidth()},get onResizeMouseDown(){return e.onResizeMouseDown},get onResizeTouchStart(){return e.onResizeTouchStart},get isPhoneLayout(){return e.isPhoneLayout()},get overlayAriaLabel(){return e.t("instanceShell.rightPanel.tabs.files")}})})};X(["input","click","keydown","mousedown"]);export{Ie as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-BgP6xpZ6.js","assets/git-diff-vendor-CSgooKT_.js","assets/fast-diff-vendor-DgdwVvTQ.js","assets/highlight-vendor-8FKMu9os.js","assets/git-diff-vendor-HAZkIolJ.css"])))=>i.map(i=>d[i]);
2
+ import{_ as se}from"./index-mh_z9p40.js";import{m as R,t as h,i as n,d as b,h as U,a as Q,f as le}from"./monaco-viewer-BgP6xpZ6.js";import{n as r,m as re,c as m,a as L,S as w,F as j,z as ce,A as oe}from"./git-diff-vendor-CSgooKT_.js";import{D as de}from"./DiffToolbar-B12EfXMX.js";import{S as ge}from"./SplitFilePanel-BOHH3F--.js";import{I as he,P as ue,R as fe,Q as H,T as J}from"./main-CKhfaeKI.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";import"./align-justify-9zpyaAdy.js";import"./wrap-text-zghCl6wN.js";const me=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],ve=e=>r(he,re(e,{name:"GitBranch",iconNode:me}));var V=h("<div class=file-viewer-empty><span class=file-viewer-empty-text>"),Ce=h('<div class="file-viewer-panel flex-1"><div class="file-viewer-content file-viewer-content--monaco">'),$e=h('<div class="p-3 text-xs text-secondary">'),be=h('<span class="git-change-row-action-bar git-change-row-action-bar-vertical">'),_e=h('<div><div class=file-list-item-content><div class=file-list-item-path><span class=file-path-text></span></div><div class=git-change-list-item-right><div class=file-list-item-stats><span class=file-list-item-additions>+</span><span class=file-list-item-deletions>-</span></div></div></div><div class=git-change-list-item-actions-zone><div class=git-change-list-item-actions><button type=button class=git-change-row-action><span aria-hidden=true><span class="git-change-row-action-bar git-change-row-action-bar-horizontal">'),we=h("<div class=git-change-section-items>"),Se=h("<div class=git-change-section><button type=button class=git-change-section-header><span class=git-change-section-header-main><span class=git-change-section-chevron></span><span class=git-change-section-title></span></span><span class=git-change-section-count>"),ye=h('<div class=git-change-section-items><div class=git-change-commit-box><div class=git-change-commit-input-wrap><textarea class=git-change-commit-input rows=1></textarea><button type=button class="git-change-commit-button git-change-commit-button-overlay">'),xe=h("<div class=git-change-sections><div class=git-change-section><button type=button class=git-change-section-header><span class=git-change-section-header-main><span class=git-change-section-chevron></span><span class=git-change-section-title-row><span class=git-change-section-title></span></span></span><span class=git-change-section-count>"),Ie=h('<span class="status-indicator session-status-list worktree-indicator git-change-section-badge"><span class=worktree-indicator-label>'),Me=h("<span class=files-tab-selected-path><span class=file-path-text>"),ke=h('<div class=files-tab-stats style="flex:0 0 auto"><span class="files-tab-stat files-tab-stat-additions"><span class=files-tab-stat-value>+</span></span><span class="files-tab-stat files-tab-stat-deletions"><span class=files-tab-stat-value>-'),Le=h("<button type=button class=files-header-icon-button style=margin-left:auto>"),Ee=h("<span class=text-error>");const Pe=oe(()=>se(()=>import("./monaco-viewer-BgP6xpZ6.js").then(e=>e.ad),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.MonacoDiffViewer}))),Ke=e=>{const A=m(()=>e.activeSessionId()),W=m(()=>!!(A()&&A()!=="info")),T=m(()=>W()?e.entries():null),X=m(()=>{const o=T();return Array.isArray(o)?[...o].sort((d,x)=>String(d.path||"").localeCompare(String(x.path||""))):[]}),S=m(()=>ue(X())),Y=m(()=>S().reduce((o,d)=>(o.additions+=typeof d.additions=="number"?d.additions:0,o.deletions+=typeof d.deletions=="number"?d.deletions:0,o),{additions:0,deletions:0})),z=m(()=>S().filter(o=>o.section==="staged")),Z=m(()=>S().filter(o=>o.section==="unstaged")),p=m(()=>z().length>0&&e.commitMessage().trim().length>0&&!e.commitSubmitting()),ee=m(()=>{const o=S(),d=e.selectedItemId(),x=e.mostChangedItemId(),I=o.find(E=>E.id===d)||(x?o.find(E=>E.id===x):void 0);return(I==null?void 0:I.entry)??null}),D=m(()=>W()?T()===null?e.t("instanceShell.gitChanges.loading"):S().length===0?e.t("instanceShell.gitChanges.empty"):e.t("instanceShell.filesShell.viewerEmpty"):e.t("instanceShell.gitChanges.noSessionSelected")),te=m(()=>e.selectedError()===e.t("instanceShell.gitChanges.binaryViewer"));return R(()=>{const o=Y(),d=ee(),x=S(),I=z(),E=Z(),ne=()=>(()=>{var t=Ce(),l=t.firstChild;return n(l,r(w,{get when(){return e.selectedLoading()},get fallback(){return r(w,{get when(){return e.selectedError()},get fallback(){return r(w,{get when(){return R(()=>!!(d&&e.selectedBefore()!==null&&e.selectedAfter()!==null))()?{path:d.path,before:e.selectedBefore(),after:e.selectedAfter()}:null},get fallback(){return(()=>{var i=V(),s=i.firstChild;return n(s,D),i})()},children:i=>r(ce,{get fallback(){return(()=>{var s=V(),a=s.firstChild;return n(a,()=>e.t("instanceInfo.loading")),s})()},get children(){return r(Pe,{get scopeKey(){return e.scopeKey()},get path(){return String(i().path||"")},get before(){return String(i().before||"")},get after(){return String(i().after||"")},get viewMode(){return e.diffViewMode()},get contextMode(){return e.diffContextMode()},get wordWrap(){return e.diffWordWrapMode()},get insertContextLabel(){return e.t("instanceShell.gitChanges.actions.insertContext")},get onRequestInsertContext(){return te()?void 0:s=>{const a=e.selectedItemId();if(!a)return;const g=S().find(u=>u.id===a);g&&e.onInsertContext(g,s)}}})}})})},children:i=>(()=>{var s=V(),a=s.firstChild;return n(a,i),s})()})},get children(){var i=V(),s=i.firstChild;return n(s,()=>e.t("instanceInfo.loading")),i}})),t})(),ie=()=>(()=>{var t=$e();return n(t,D),t})(),B=t=>{const l=m(()=>e.selectedBulkItemIds().has(t.id)),i=t.section==="staged"?e.t("instanceShell.gitChanges.actions.unstage"):e.t("instanceShell.gitChanges.actions.stage"),s=()=>{t.section==="staged"?e.onUnstageFile(t):e.onStageFile(t)};return(()=>{var a=_e(),g=a.firstChild,u=g.firstChild,M=u.firstChild,v=u.nextSibling,$=v.firstChild,C=$.firstChild;C.firstChild;var _=C.nextSibling;_.firstChild;var P=g.nextSibling,f=P.firstChild,y=f.firstChild,k=y.firstChild;return k.firstChild,a.$$click=c=>e.onRowClick(t,c),a.$$mousedown=c=>{(c.shiftKey||c.ctrlKey||c.metaKey)&&c.preventDefault()},n(M,()=>t.path),n(C,()=>t.additions,null),n(_,()=>t.deletions,null),y.$$click=c=>{c.stopPropagation(),s()},b(y,"title",i),b(y,"aria-label",i),n(k,r(w,{get when(){return t.section!=="staged"},get children(){return be()}}),null),L(c=>{var F=`file-list-item git-change-list-item ${e.selectedItemId()===t.id?"file-list-item-active":""} ${l()?"git-change-list-item-bulk-selected":""}`,G=t.path,K=t.path,q=t.path,N=`git-change-row-action-glyph ${t.section==="staged"?"git-change-row-action-glyph-minus":"git-change-row-action-glyph-plus"}`;return F!==c.e&&Q(a,c.e=F),G!==c.t&&b(a,"title",c.t=G),K!==c.a&&b(g,"title",c.a=K),q!==c.o&&b(u,"title",c.o=q),N!==c.i&&Q(k,c.i=N),c},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),a})()},ae=(t,l,i,s)=>(()=>{var a=Se(),g=a.firstChild,u=g.firstChild,M=u.firstChild,v=M.nextSibling,$=u.nextSibling;return U(g,"click",s,!0),n(M,i?r(H,{class:"h-3.5 w-3.5"}):r(J,{class:"h-3.5 w-3.5"})),n(v,t),n($,()=>l.length),n(a,r(w,{when:i,get children(){var C=we();return n(C,r(j,{each:l,children:_=>B(_)})),C}}),null),a})(),O=()=>r(w,{get when(){return x.length>0},get fallback(){return ie()},get children(){var t=xe(),l=t.firstChild,i=l.firstChild,s=i.firstChild,a=s.firstChild,g=a.nextSibling,u=g.firstChild,M=s.nextSibling;return U(i,"click",e.onToggleStagedOpen,!0),n(a,(()=>{var v=R(()=>!!e.stagedOpen());return()=>v()?r(H,{class:"h-3.5 w-3.5"}):r(J,{class:"h-3.5 w-3.5"})})()),n(u,()=>e.t("instanceShell.gitChanges.sections.staged")),n(g,r(w,{get when(){return e.branchLabel()},children:v=>(()=>{var $=Ie(),C=$.firstChild;return n($,r(ve,{class:"w-3.5 h-3.5","aria-hidden":"true"}),C),n(C,v),L(()=>b($,"title",`Branch: ${v()}`)),$})()}),null),n(M,()=>I.length),n(l,r(w,{get when(){return e.stagedOpen()},get children(){var v=ye(),$=v.firstChild,C=$.firstChild,_=C.firstChild,P=_.nextSibling;return _.$$input=f=>e.onCommitMessageInput(f.currentTarget.value),P.$$click=()=>e.onSubmitCommit(),n(P,(()=>{var f=R(()=>!!e.commitSubmitting());return()=>f()?e.t("instanceShell.gitChanges.commit.submitting"):e.t("instanceShell.gitChanges.commit.submit")})()),n(v,r(j,{each:I,children:f=>B(f)}),null),L(f=>{var y=e.t("instanceShell.gitChanges.commit.placeholder"),k=!p();return y!==f.e&&b(_,"placeholder",f.e=y),k!==f.t&&(P.disabled=f.t=k),f},{e:void 0,t:void 0}),L(()=>_.value=e.commitMessage()),v}}),null),n(t,()=>ae(e.t("instanceShell.gitChanges.sections.unstaged"),E,e.unstagedOpen(),e.onToggleUnstagedOpen),null),t}});return r(ge,{get header(){return[(()=>{var t=Me(),l=t.firstChild;return n(l,()=>(d==null?void 0:d.path)||e.t("instanceShell.rightPanel.tabs.gitChanges")),L(()=>b(t,"title",(d==null?void 0:d.path)||e.t("instanceShell.rightPanel.tabs.gitChanges"))),t})(),(()=>{var t=ke(),l=t.firstChild,i=l.firstChild;i.firstChild;var s=l.nextSibling,a=s.firstChild;return a.firstChild,n(i,()=>o.additions,null),n(a,()=>o.deletions,null),n(t,r(w,{get when(){return e.statusError()},children:g=>(()=>{var u=Ee();return n(u,g),u})()}),null),t})(),(()=>{var t=Le();return t.$$click=()=>e.onRefresh(),n(t,r(fe,{get class(){return`h-4 w-4${e.statusLoading()?" animate-spin":""}`}})),L(l=>{var i=e.t("instanceShell.rightPanel.actions.refresh"),s=e.t("instanceShell.rightPanel.actions.refresh"),a=!W()||e.statusLoading()||T()===null;return i!==l.e&&b(t,"title",l.e=i),s!==l.t&&b(t,"aria-label",l.t=s),a!==l.a&&(t.disabled=l.a=a),l},{e:void 0,t:void 0,a:void 0}),t})(),r(de,{get viewMode(){return e.diffViewMode()},get contextMode(){return e.diffContextMode()},get wordWrapMode(){return e.diffWordWrapMode()},get onViewModeChange(){return e.onViewModeChange},get onContextModeChange(){return e.onContextModeChange},get onWordWrapModeChange(){return e.onWordWrapModeChange}})]},list:{panel:O,overlay:O},get viewer(){return ne()},get listOpen(){return e.listOpen()},get onToggleList(){return e.onToggleList},get splitWidth(){return e.splitWidth()},get onResizeMouseDown(){return e.onResizeMouseDown},get onResizeTouchStart(){return e.onResizeTouchStart},get isPhoneLayout(){return e.isPhoneLayout()},get overlayAriaLabel(){return e.t("instanceShell.rightPanel.tabs.gitChanges")}})})};le(["mousedown","click","input"]);export{Ke as default};
@@ -1 +1 @@
1
- import{t as d,i as l,d as m,j as s,m as b,g as _,f as w}from"./monaco-viewer-UU9TfOpS.js";import{a as g,n as r,S as n}from"./git-diff-vendor-CAv-4upN.js";import{u as S}from"./index-lhjxIgwf.js";var y=d("<div class=file-list-overlay role=dialog><div class=file-list-scroll>");const L=e=>(()=>{var t=y(),a=t.firstChild;return l(a,()=>e.children),g(()=>m(t,"aria-label",e.ariaLabel)),t})();var C=d('<div class=files-split><div class=file-list-panel><div class=file-list-scroll></div></div><div class=file-split-handle role=separator aria-orientation=vertical aria-label="Resize file list">'),x=d("<div class=files-tab-container><div class=files-tab-header><div class=files-tab-header-row><button type=button class=files-toggle-button></button></div></div><div class=files-tab-body>");const z=e=>{const{t}=S();return(()=>{var a=x(),c=a.firstChild,o=c.firstChild,u=o.firstChild,h=c.nextSibling;return s(u,"click",e.onToggleList,!0),l(u,(()=>{var i=b(()=>!!e.listOpen);return()=>i()?t("instanceShell.filesShell.hideFiles"):t("instanceShell.filesShell.showFiles")})()),l(o,()=>e.header,null),l(h,r(n,{get when(){return b(()=>!e.isPhoneLayout)()&&e.listOpen},get fallback(){return e.viewer},get children(){var i=C(),v=i.firstChild,$=v.firstChild,f=v.nextSibling;return l($,()=>e.list.panel()),s(f,"touchstart",e.onResizeTouchStart,!0),s(f,"mousedown",e.onResizeMouseDown,!0),l(i,()=>e.viewer,null),g(O=>_(i,"--files-pane-width",`${e.splitWidth}px`)),i}}),null),l(h,r(n,{get when(){return e.isPhoneLayout},get children(){return r(n,{get when(){return e.listOpen},get children(){return r(L,{get ariaLabel(){return e.overlayAriaLabel},get children(){return e.list.overlay()}})}})}}),null),a})()};w(["click","mousedown","touchstart"]);export{z as S};
1
+ import{t as d,i as l,d as m,h as s,m as b,g as _,f as w}from"./monaco-viewer-BgP6xpZ6.js";import{a as g,n as r,S as n}from"./git-diff-vendor-CSgooKT_.js";import{u as S}from"./index-mh_z9p40.js";var y=d("<div class=file-list-overlay role=dialog><div class=file-list-scroll>");const L=e=>(()=>{var t=y(),a=t.firstChild;return l(a,()=>e.children),g(()=>m(t,"aria-label",e.ariaLabel)),t})();var C=d('<div class=files-split><div class=file-list-panel><div class=file-list-scroll></div></div><div class=file-split-handle role=separator aria-orientation=vertical aria-label="Resize file list">'),x=d("<div class=files-tab-container><div class=files-tab-header><div class=files-tab-header-row><button type=button class=files-toggle-button></button></div></div><div class=files-tab-body>");const z=e=>{const{t}=S();return(()=>{var a=x(),c=a.firstChild,o=c.firstChild,u=o.firstChild,h=c.nextSibling;return s(u,"click",e.onToggleList,!0),l(u,(()=>{var i=b(()=>!!e.listOpen);return()=>i()?t("instanceShell.filesShell.hideFiles"):t("instanceShell.filesShell.showFiles")})()),l(o,()=>e.header,null),l(h,r(n,{get when(){return b(()=>!e.isPhoneLayout)()&&e.listOpen},get fallback(){return e.viewer},get children(){var i=C(),v=i.firstChild,$=v.firstChild,f=v.nextSibling;return l($,()=>e.list.panel()),s(f,"touchstart",e.onResizeTouchStart,!0),s(f,"mousedown",e.onResizeMouseDown,!0),l(i,()=>e.viewer,null),g(O=>_(i,"--files-pane-width",`${e.splitWidth}px`)),i}}),null),l(h,r(n,{get when(){return e.isPhoneLayout},get children(){return r(n,{get when(){return e.listOpen},get children(){return r(L,{get ariaLabel(){return e.overlayAriaLabel},get children(){return e.list.overlay()}})}})}}),null),a})()};w(["click","mousedown","touchstart"]);export{z as S};