@neuralnomads/codenomad 0.15.0 → 0.16.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 (131) hide show
  1. package/dist/filesystem/__tests__/browser.test.js +65 -0
  2. package/dist/filesystem/__tests__/search-cache.test.js +2 -2
  3. package/dist/filesystem/browser.js +25 -4
  4. package/dist/index.js +4 -0
  5. package/dist/opencode-plugin/codenomad-opencode-plugin.tgz +0 -0
  6. package/dist/opencode-plugin.js +146 -0
  7. package/dist/opencode-plugin.test.js +28 -0
  8. package/dist/previews/manager.js +63 -0
  9. package/dist/server/http-server.js +372 -14
  10. package/dist/server/routes/filesystem.js +13 -0
  11. package/dist/server/routes/previews.js +25 -0
  12. package/dist/server/routes/workspaces.js +23 -1
  13. package/dist/workspaces/__tests__/git-clone.test.js +141 -0
  14. package/dist/workspaces/__tests__/spawn.test.js +26 -8
  15. package/dist/workspaces/git-clone.js +148 -0
  16. package/dist/workspaces/manager.js +8 -5
  17. package/dist/workspaces/spawn.js +35 -9
  18. package/package.json +3 -3
  19. package/public/assets/{ChangesTab-ovdqLHc3.js → ChangesTab-CxrJwz2Z.js} +2 -2
  20. package/public/assets/{DiffToolbar-B12EfXMX.js → DiffToolbar-CqJttTgx.js} +1 -1
  21. package/public/assets/{FilesTab-nb_itEXG.js → FilesTab-tBrdrLID.js} +2 -2
  22. package/public/assets/GitChangesTab-DUUJn4Va.js +2 -0
  23. package/public/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  24. package/public/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  25. package/public/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  26. package/public/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  27. package/public/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  28. package/public/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  29. package/public/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  30. package/public/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  31. package/public/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  32. package/public/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  33. package/public/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  34. package/public/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  35. package/public/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  36. package/public/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  37. package/public/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  38. package/public/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  39. package/public/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  40. package/public/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  41. package/public/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  42. package/public/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  43. package/public/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  44. package/public/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  45. package/public/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  46. package/public/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  47. package/public/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  48. package/public/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  49. package/public/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  50. package/public/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  51. package/public/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  52. package/public/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  53. package/public/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  54. package/public/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  55. package/public/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  56. package/public/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  57. package/public/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  58. package/public/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  59. package/public/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  60. package/public/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  61. package/public/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  62. package/public/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  63. package/public/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  64. package/public/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  65. package/public/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  66. package/public/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  67. package/public/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  68. package/public/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  69. package/public/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  70. package/public/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  71. package/public/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  72. package/public/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  73. package/public/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  74. package/public/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  75. package/public/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  76. package/public/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  77. package/public/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  78. package/public/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  79. package/public/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  80. package/public/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  81. package/public/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  82. package/public/assets/{SplitFilePanel-BOHH3F--.js → SplitFilePanel-CiZrHI3o.js} +1 -1
  83. package/public/assets/StatusTab-DN31GijL.js +1 -0
  84. package/public/assets/{align-justify-9zpyaAdy.js → align-justify-CKbOni6U.js} +1 -1
  85. package/public/assets/{bundle-full-xFW13Lny.js → bundle-full-B_MbXXHv.js} +1 -1
  86. package/public/assets/{diff-viewer-xG9yjpN8.js → diff-viewer-CersJruo.js} +1 -1
  87. package/public/assets/index-BTenW4sL.js +1 -0
  88. package/public/assets/index-BsYORY4z.js +1 -0
  89. package/public/assets/index-BvfQjuig.js +1 -0
  90. package/public/assets/{index-CCAZZY0l.js → index-CK51N0B7.js} +1 -1
  91. package/public/assets/index-Chghci_R.js +1 -0
  92. package/public/assets/{index-Cz_fl8aY.js → index-DYa3o0_M.js} +1 -1
  93. package/public/assets/index-DskBWxXS.js +2 -0
  94. package/public/assets/index-DslkXxdb.js +1 -0
  95. package/public/assets/index-UCZ7MxNK.js +1 -0
  96. package/public/assets/index-i5UooSrU.css +1 -0
  97. package/public/assets/{loading-HUhLEgb_.js → loading-hkCubi3k.js} +1 -1
  98. package/public/assets/main-CXJTHRp1.js +62 -0
  99. package/public/assets/markdown-Cy9tCAXp.js +315 -0
  100. package/public/assets/monaco-viewer-B3iAKbO0.js +26 -0
  101. package/public/assets/tool-call-DhWimeRu.js +59 -0
  102. package/public/assets/{unified-picker-DuNuUpLy.js → unified-picker-C47f5lFi.js} +1 -1
  103. package/public/assets/{wrap-text-zghCl6wN.js → wrap-text-hwXbREuU.js} +1 -1
  104. package/public/index.html +4 -4
  105. package/public/loading.html +4 -4
  106. package/public/sw.js +1 -1
  107. package/public/ui-version.json +1 -1
  108. package/dist/opencode-config/README.md +0 -32
  109. package/dist/opencode-config/opencode.jsonc +0 -3
  110. package/dist/opencode-config/package-lock.json +0 -380
  111. package/dist/opencode-config/package.json +0 -9
  112. package/dist/opencode-config/plugin/codenomad.ts +0 -62
  113. package/dist/opencode-config/plugin/lib/background-process.ts +0 -265
  114. package/dist/opencode-config/plugin/lib/client.ts +0 -133
  115. package/dist/opencode-config/plugin/lib/request.ts +0 -214
  116. package/dist/opencode-config.js +0 -26
  117. package/public/assets/GitChangesTab-DcT_4BL2.js +0 -2
  118. package/public/assets/StatusTab-Dyt_EG33.js +0 -1
  119. package/public/assets/index-7DpT014-.js +0 -1
  120. package/public/assets/index-BDK4V9L0.js +0 -1
  121. package/public/assets/index-Bx-Bezt2.js +0 -1
  122. package/public/assets/index-CEcZq5WB.js +0 -1
  123. package/public/assets/index-CQCmSDHL.js +0 -1
  124. package/public/assets/index-Dcgftm1m.css +0 -1
  125. package/public/assets/index-m4C3yx3J.js +0 -1
  126. package/public/assets/index-mh_z9p40.js +0 -2
  127. package/public/assets/main-CKhfaeKI.js +0 -48
  128. package/public/assets/markdown-BeXU9Z-x.js +0 -58
  129. package/public/assets/monaco-viewer-BgP6xpZ6.js +0 -26
  130. package/public/assets/todo-D6PVVp_f.js +0 -1
  131. package/public/assets/tool-call-Dgn3NlA8.js +0 -60
@@ -0,0 +1,141 @@
1
+ import assert from "node:assert/strict";
2
+ import { execFileSync } from "node:child_process";
3
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { homedir, tmpdir } from "node:os";
5
+ import path from "node:path";
6
+ import { describe, it } from "node:test";
7
+ import { cloneGitRepository } from "../git-clone";
8
+ function createBareRepository(repoPath) {
9
+ execFileSync("git", ["init", "--bare", repoPath], { stdio: "ignore" });
10
+ }
11
+ async function expectCloneError(callback, expectedStatusCode, messagePattern) {
12
+ await assert.rejects(callback, (error) => {
13
+ assert.equal(typeof error, "object");
14
+ assert.equal(error.statusCode, expectedStatusCode);
15
+ assert.match(String(error.message ?? ""), messagePattern);
16
+ return true;
17
+ });
18
+ }
19
+ describe("cloneGitRepository", () => {
20
+ it("clones into a missing destination", async () => {
21
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
22
+ const sourceRepo = path.join(temp, "source.git");
23
+ const destinationPath = path.join(temp, "cloned-repo");
24
+ try {
25
+ createBareRepository(sourceRepo);
26
+ const result = await cloneGitRepository({
27
+ repositoryUrl: sourceRepo,
28
+ destinationPath,
29
+ });
30
+ assert.equal(result.path, destinationPath);
31
+ assert.equal(existsSync(path.join(destinationPath, ".git")), true);
32
+ }
33
+ finally {
34
+ rmSync(temp, { recursive: true, force: true });
35
+ }
36
+ });
37
+ it("rejects non-empty destinations when cleanup is not enabled", async () => {
38
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
39
+ const sourceRepo = path.join(temp, "source.git");
40
+ const destinationPath = path.join(temp, "existing-destination");
41
+ const sentinelPath = path.join(destinationPath, "keep.txt");
42
+ try {
43
+ createBareRepository(sourceRepo);
44
+ mkdirSync(destinationPath, { recursive: true });
45
+ writeFileSync(sentinelPath, "keep");
46
+ await expectCloneError(() => cloneGitRepository({ repositoryUrl: sourceRepo, destinationPath }), 409, /Destination folder is not empty/);
47
+ assert.equal(readFileSync(sentinelPath, "utf8"), "keep");
48
+ }
49
+ finally {
50
+ rmSync(temp, { recursive: true, force: true });
51
+ }
52
+ });
53
+ it("preserves the existing destination when cleanup is enabled but clone fails", async () => {
54
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
55
+ const missingRepo = path.join(temp, "missing.git");
56
+ const destinationPath = path.join(temp, "existing-destination");
57
+ const sentinelPath = path.join(destinationPath, "keep.txt");
58
+ try {
59
+ mkdirSync(destinationPath, { recursive: true });
60
+ writeFileSync(sentinelPath, "keep");
61
+ await expectCloneError(() => cloneGitRepository({ repositoryUrl: missingRepo, destinationPath, cleanup: true }), 409, /does not appear to be a git repository|does not exist|not found/i);
62
+ assert.equal(readFileSync(sentinelPath, "utf8"), "keep");
63
+ assert.equal(existsSync(destinationPath), true);
64
+ }
65
+ finally {
66
+ rmSync(temp, { recursive: true, force: true });
67
+ }
68
+ });
69
+ it("replaces the existing destination only after a successful cleanup clone", async () => {
70
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
71
+ const sourceRepo = path.join(temp, "source.git");
72
+ const destinationPath = path.join(temp, "existing-destination");
73
+ const sentinelPath = path.join(destinationPath, "keep.txt");
74
+ try {
75
+ createBareRepository(sourceRepo);
76
+ mkdirSync(destinationPath, { recursive: true });
77
+ writeFileSync(sentinelPath, "keep");
78
+ const result = await cloneGitRepository({
79
+ repositoryUrl: sourceRepo,
80
+ destinationPath,
81
+ cleanup: true,
82
+ });
83
+ assert.equal(result.path, destinationPath);
84
+ assert.equal(existsSync(path.join(destinationPath, ".git")), true);
85
+ assert.equal(existsSync(sentinelPath), false);
86
+ }
87
+ finally {
88
+ rmSync(temp, { recursive: true, force: true });
89
+ }
90
+ });
91
+ it("rejects filesystem root destinations", async () => {
92
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
93
+ const sourceRepo = path.join(temp, "source.git");
94
+ try {
95
+ createBareRepository(sourceRepo);
96
+ await expectCloneError(() => cloneGitRepository({
97
+ repositoryUrl: sourceRepo,
98
+ destinationPath: path.parse(process.cwd()).root,
99
+ cleanup: true,
100
+ }), 400, /filesystem root/);
101
+ }
102
+ finally {
103
+ rmSync(temp, { recursive: true, force: true });
104
+ }
105
+ });
106
+ it("rejects home directory destinations", async () => {
107
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
108
+ const sourceRepo = path.join(temp, "source.git");
109
+ try {
110
+ createBareRepository(sourceRepo);
111
+ await expectCloneError(() => cloneGitRepository({
112
+ repositoryUrl: sourceRepo,
113
+ destinationPath: homedir(),
114
+ cleanup: true,
115
+ }), 400, /home folder/);
116
+ }
117
+ finally {
118
+ rmSync(temp, { recursive: true, force: true });
119
+ }
120
+ });
121
+ it("supports destinations directly under a Windows drive root", { skip: process.platform !== "win32" }, async () => {
122
+ const temp = mkdtempSync(path.join(tmpdir(), "codenomad-git-clone-"));
123
+ const sourceRepo = path.join(temp, "source.git");
124
+ const root = path.parse(process.cwd()).root;
125
+ const destinationPath = path.join(root, `codenomad-git-clone-root-${Date.now()}-${Math.random().toString(36).slice(2)}`);
126
+ try {
127
+ createBareRepository(sourceRepo);
128
+ rmSync(destinationPath, { recursive: true, force: true });
129
+ const result = await cloneGitRepository({
130
+ repositoryUrl: sourceRepo,
131
+ destinationPath,
132
+ });
133
+ assert.equal(result.path, destinationPath);
134
+ assert.equal(existsSync(destinationPath), true);
135
+ }
136
+ finally {
137
+ rmSync(destinationPath, { recursive: true, force: true });
138
+ rmSync(temp, { recursive: true, force: true });
139
+ }
140
+ });
141
+ });
@@ -34,12 +34,12 @@ describe("buildWindowsSpawnSpec", () => {
34
34
  const spec = buildWindowsSpawnSpec(String.raw `\\wsl.localhost\Ubuntu\home\dev\.opencode\bin\opencode`, ["serve", "--port", "0"], {
35
35
  cwd: String.raw `\\wsl.localhost\Ubuntu\home\dev\workspace`,
36
36
  env: {
37
- OPENCODE_CONFIG_DIR: String.raw `C:\Users\dev\AppData\Roaming\CodeNomad\opencode-config`,
37
+ OPENCODE_CONFIG_CONTENT: JSON.stringify({ plugin: ["file:///C:/Users/dev/AppData/Roaming/CodeNomad/plugin.tgz"] }),
38
38
  CODENOMAD_INSTANCE_ID: "workspace-123",
39
39
  OPENCODE_SERVER_BASE_URL: "https://127.0.0.1:4321/workspaces/workspace-123/worktrees/root/instance",
40
40
  OPENCODE_SERVER_PASSWORD: "secret",
41
41
  },
42
- propagateEnvKeys: ["OPENCODE_CONFIG_DIR", "CODENOMAD_INSTANCE_ID", "OPENCODE_SERVER_BASE_URL", "OPENCODE_SERVER_PASSWORD"],
42
+ propagateEnvKeys: ["OPENCODE_CONFIG_CONTENT", "CODENOMAD_INSTANCE_ID", "OPENCODE_SERVER_BASE_URL", "OPENCODE_SERVER_PASSWORD"],
43
43
  });
44
44
  assert.equal(spec.command, "wsl.exe");
45
45
  assert.deepEqual(spec.args, [
@@ -54,17 +54,35 @@ describe("buildWindowsSpawnSpec", () => {
54
54
  "0",
55
55
  ]);
56
56
  assert.equal(spec.cwd, undefined);
57
- assert.equal(spec.env?.WSLENV, "OPENCODE_CONFIG_DIR/p:CODENOMAD_INSTANCE_ID:OPENCODE_SERVER_BASE_URL:OPENCODE_SERVER_PASSWORD");
57
+ assert.equal(spec.env?.WSLENV, "OPENCODE_CONFIG_CONTENT:CODENOMAD_INSTANCE_ID:OPENCODE_SERVER_BASE_URL:OPENCODE_SERVER_PASSWORD");
58
58
  });
59
- it("upgrades existing WSLENV path entries to include /p", () => {
59
+ it("preserves non-path OPENCODE_CONFIG_CONTENT WSLENV entries", () => {
60
60
  const spec = buildWindowsSpawnSpec(String.raw `\\wsl.localhost\Ubuntu\home\dev\.opencode\bin\opencode`, ["serve"], {
61
61
  env: {
62
- OPENCODE_CONFIG_DIR: String.raw `C:\Users\dev\AppData\Roaming\CodeNomad\opencode-config`,
63
- WSLENV: "OPENCODE_CONFIG_DIR:CODENOMAD_INSTANCE_ID/u",
62
+ OPENCODE_CONFIG_CONTENT: JSON.stringify({ plugin: ["file:///C:/Users/dev/AppData/Roaming/CodeNomad/plugin.tgz"] }),
63
+ WSLENV: "OPENCODE_CONFIG_CONTENT:CODENOMAD_INSTANCE_ID/u",
64
64
  },
65
- propagateEnvKeys: ["OPENCODE_CONFIG_DIR", "CODENOMAD_INSTANCE_ID"],
65
+ propagateEnvKeys: ["OPENCODE_CONFIG_CONTENT", "CODENOMAD_INSTANCE_ID"],
66
66
  });
67
- assert.equal(spec.env?.WSLENV, "OPENCODE_CONFIG_DIR/p:CODENOMAD_INSTANCE_ID/u");
67
+ assert.equal(spec.env?.WSLENV, "OPENCODE_CONFIG_CONTENT:CODENOMAD_INSTANCE_ID/u");
68
+ });
69
+ it("rewrites packaged plugin paths for WSL before launching", () => {
70
+ const spec = buildWindowsSpawnSpec(String.raw `\\wsl.localhost\Ubuntu\home\dev\.opencode\bin\opencode`, ["serve"], {
71
+ env: {
72
+ OPENCODE_CONFIG_CONTENT: JSON.stringify({
73
+ plugin: [
74
+ "@codenomad/codenomad-opencode-plugin@file:C:/Users/dev/AppData/Roaming/CodeNomad/codenomad-opencode-plugin.tgz",
75
+ ],
76
+ }),
77
+ },
78
+ propagateEnvKeys: ["OPENCODE_CONFIG_CONTENT"],
79
+ });
80
+ assert.equal(spec.command, "wsl.exe");
81
+ assert.equal(spec.env?.CODENOMAD_OPENCODE_PLUGIN_WSL_PATH, String.raw `C:\Users\dev\AppData\Roaming\CodeNomad\codenomad-opencode-plugin.tgz`);
82
+ assert.match(spec.env?.OPENCODE_CONFIG_CONTENT ?? "", /__CODENOMAD_OPENCODE_PLUGIN_WSL_PATH__/);
83
+ assert.equal(spec.env?.WSLENV, "OPENCODE_CONFIG_CONTENT:CODENOMAD_OPENCODE_PLUGIN_WSL_PATH/p");
84
+ assert.deepEqual(spec.args.slice(0, 4), ["--distribution", "Ubuntu", "--exec", "sh"]);
85
+ assert.match(spec.args[5] ?? "", /CODENOMAD_OPENCODE_PLUGIN_WSL_PATH/);
68
86
  });
69
87
  it("propagates inherited known path variables even when they are not explicitly requested", () => {
70
88
  const spec = buildWindowsSpawnSpec(String.raw `\\wsl.localhost\Ubuntu\home\dev\.opencode\bin\opencode`, ["serve"], {
@@ -0,0 +1,148 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { spawn } from "child_process";
4
+ import { homedir } from "os";
5
+ class GitCloneError extends Error {
6
+ constructor(message, statusCode = 400) {
7
+ super(message);
8
+ this.name = "GitCloneError";
9
+ this.statusCode = statusCode;
10
+ }
11
+ }
12
+ function formatErrorMessage(error, fallback) {
13
+ if (error instanceof Error && error.message.trim().length > 0) {
14
+ return error.message;
15
+ }
16
+ return fallback;
17
+ }
18
+ function normalizePathForComparison(filePath) {
19
+ const resolvedPath = path.resolve(filePath);
20
+ const rootPath = path.parse(resolvedPath).root;
21
+ const trimmedPath = resolvedPath === rootPath ? rootPath : resolvedPath.replace(/[\\/]+$/, "");
22
+ return process.platform === "win32" ? trimmedPath.toLowerCase() : trimmedPath;
23
+ }
24
+ function assertDestinationPathIsSafe(destinationPath) {
25
+ const normalizedDestinationPath = normalizePathForComparison(destinationPath);
26
+ const normalizedRootPath = normalizePathForComparison(path.parse(destinationPath).root);
27
+ if (normalizedDestinationPath === normalizedRootPath) {
28
+ throw new GitCloneError("Destination path cannot be a filesystem root", 400);
29
+ }
30
+ const normalizedHomePath = normalizePathForComparison(homedir());
31
+ if (normalizedDestinationPath === normalizedHomePath) {
32
+ throw new GitCloneError("Destination path cannot be the home folder", 400);
33
+ }
34
+ }
35
+ function createSiblingUniquePath(destinationPath, label) {
36
+ const parentPath = path.dirname(destinationPath);
37
+ const baseName = path.basename(destinationPath);
38
+ return path.join(parentPath, `${baseName}.${label}-${Date.now()}-${Math.random().toString(36).slice(2)}`);
39
+ }
40
+ function runGitClone(repositoryUrl, destinationPath) {
41
+ return new Promise((resolve, reject) => {
42
+ const parentPath = path.dirname(destinationPath);
43
+ const child = spawn("git", ["clone", "--", repositoryUrl, destinationPath], {
44
+ cwd: parentPath,
45
+ stdio: ["ignore", "pipe", "pipe"],
46
+ });
47
+ let stderr = "";
48
+ child.stderr?.on("data", (chunk) => {
49
+ stderr += chunk.toString();
50
+ });
51
+ child.once("error", (error) => {
52
+ reject(new GitCloneError(error.message || "Failed to start git clone", 500));
53
+ });
54
+ child.once("close", (code) => {
55
+ if (code === 0) {
56
+ resolve();
57
+ return;
58
+ }
59
+ reject(new GitCloneError(stderr.trim() || `git clone failed with code ${code}`, 409));
60
+ });
61
+ });
62
+ }
63
+ function assertDestinationIsUsable(destinationPath, cleanup) {
64
+ if (!fs.existsSync(destinationPath))
65
+ return;
66
+ const stat = fs.statSync(destinationPath);
67
+ if (!stat.isDirectory()) {
68
+ throw new GitCloneError("Destination path exists and is not a folder", 409);
69
+ }
70
+ if (cleanup) {
71
+ return;
72
+ }
73
+ const entries = fs.readdirSync(destinationPath);
74
+ if (entries.length > 0) {
75
+ throw new GitCloneError("Destination folder is not empty", 409);
76
+ }
77
+ }
78
+ function ensureDestinationParentExists(destinationPath) {
79
+ const parentPath = path.dirname(destinationPath);
80
+ if (fs.existsSync(parentPath))
81
+ return;
82
+ fs.mkdirSync(parentPath, { recursive: true });
83
+ }
84
+ async function replaceDestinationAfterSuccessfulClone(repositoryUrl, destinationPath) {
85
+ const tempClonePath = createSiblingUniquePath(destinationPath, "clone");
86
+ let backupPath = null;
87
+ let preserveBackup = false;
88
+ try {
89
+ await runGitClone(repositoryUrl, tempClonePath);
90
+ backupPath = createSiblingUniquePath(destinationPath, "backup");
91
+ fs.renameSync(destinationPath, backupPath);
92
+ try {
93
+ fs.renameSync(tempClonePath, destinationPath);
94
+ }
95
+ catch (error) {
96
+ try {
97
+ fs.renameSync(backupPath, destinationPath);
98
+ backupPath = null;
99
+ }
100
+ catch (restoreError) {
101
+ preserveBackup = true;
102
+ throw new GitCloneError(`Failed to replace clone destination and restore previous contents: ${formatErrorMessage(restoreError, "restore failed")}`, 500);
103
+ }
104
+ throw new GitCloneError(`Failed to replace clone destination: ${formatErrorMessage(error, "rename failed")}`, 500);
105
+ }
106
+ fs.rmSync(backupPath, { recursive: true, force: true });
107
+ backupPath = null;
108
+ }
109
+ catch (error) {
110
+ if (error instanceof GitCloneError) {
111
+ throw error;
112
+ }
113
+ throw new GitCloneError(`Failed to prepare clone destination: ${formatErrorMessage(error, "unknown error")}`, 500);
114
+ }
115
+ finally {
116
+ if (backupPath && !preserveBackup && fs.existsSync(backupPath)) {
117
+ fs.rmSync(backupPath, { recursive: true, force: true });
118
+ }
119
+ if (fs.existsSync(tempClonePath)) {
120
+ fs.rmSync(tempClonePath, { recursive: true, force: true });
121
+ }
122
+ }
123
+ }
124
+ export function isGitCloneError(error) {
125
+ return error instanceof GitCloneError;
126
+ }
127
+ export async function cloneGitRepository(params) {
128
+ const repositoryUrl = params.repositoryUrl.trim();
129
+ const requestedDestinationPath = params.destinationPath.trim();
130
+ if (!repositoryUrl) {
131
+ throw new GitCloneError("Repository URL is required", 400);
132
+ }
133
+ if (!path.isAbsolute(requestedDestinationPath)) {
134
+ throw new GitCloneError("Destination path must be absolute", 400);
135
+ }
136
+ const destinationPath = path.resolve(requestedDestinationPath);
137
+ assertDestinationPathIsSafe(destinationPath);
138
+ ensureDestinationParentExists(destinationPath);
139
+ const destinationExists = fs.existsSync(destinationPath);
140
+ assertDestinationIsUsable(destinationPath, Boolean(params.cleanup));
141
+ if (destinationExists && params.cleanup) {
142
+ await replaceDestinationAfterSuccessfulClone(repositoryUrl, destinationPath);
143
+ }
144
+ else {
145
+ await runGitClone(repositoryUrl, destinationPath);
146
+ }
147
+ return { path: destinationPath };
148
+ }
@@ -5,7 +5,7 @@ import { FileSystemBrowser } from "../filesystem/browser";
5
5
  import { searchWorkspaceFiles } from "../filesystem/search";
6
6
  import { clearWorkspaceSearchCache } from "../filesystem/search-cache";
7
7
  import { WorkspaceRuntime } from "./runtime";
8
- import { getOpencodeConfigDir } from "../opencode-config.js";
8
+ import { buildOpencodeConfigContent, getCodeNomadPluginUrl, resolveExistingOpencodeConfigContent, } from "../opencode-plugin.js";
9
9
  import { OPENCODE_SERVER_BASE_URL_ENV, buildOpencodeBasicAuthHeader, OPENCODE_SERVER_PASSWORD_ENV, OPENCODE_SERVER_USERNAME_ENV, resolveOpencodeServerAuth, } from "./opencode-auth";
10
10
  const STARTUP_STABILITY_DELAY_MS = 1500;
11
11
  export class WorkspaceManager {
@@ -14,7 +14,7 @@ export class WorkspaceManager {
14
14
  this.workspaces = new Map();
15
15
  this.opencodeAuth = new Map();
16
16
  this.runtime = new WorkspaceRuntime(this.options.eventBus, this.options.logger);
17
- this.opencodeConfigDir = getOpencodeConfigDir();
17
+ this.codeNomadPluginUrl = getCodeNomadPluginUrl();
18
18
  }
19
19
  list() {
20
20
  return Array.from(this.workspaces.values());
@@ -37,14 +37,16 @@ export class WorkspaceManager {
37
37
  const workspace = this.requireWorkspace(workspaceId);
38
38
  return searchWorkspaceFiles(workspace.path, query, options);
39
39
  }
40
- readFile(workspaceId, relativePath) {
40
+ readFile(workspaceId, relativePath, options) {
41
41
  const workspace = this.requireWorkspace(workspaceId);
42
42
  const browser = new FileSystemBrowser({ rootDir: workspace.path });
43
- const contents = browser.readFile(relativePath);
43
+ const encoding = options?.encoding ?? "utf-8";
44
+ const contents = encoding === "base64" ? browser.readFileBase64(relativePath) : browser.readFile(relativePath);
44
45
  return {
45
46
  workspaceId,
46
47
  relativePath,
47
48
  contents,
49
+ encoding,
48
50
  };
49
51
  }
50
52
  writeFile(workspaceId, relativePath, contents) {
@@ -77,6 +79,7 @@ export class WorkspaceManager {
77
79
  const serverConfig = this.options.settings.getOwner("config", "server");
78
80
  const envVars = serverConfig?.environmentVariables;
79
81
  const userEnvironment = envVars && typeof envVars === "object" && !Array.isArray(envVars) ? envVars : {};
82
+ const opencodeConfigContent = buildOpencodeConfigContent(resolveExistingOpencodeConfigContent(userEnvironment), this.codeNomadPluginUrl);
80
83
  const serverBaseUrl = this.options.getServerBaseUrl();
81
84
  const normalizedServerBaseUrl = serverBaseUrl.replace(/\/+$/, "");
82
85
  const { username: opencodeUsername, password: opencodePassword } = resolveOpencodeServerAuth({
@@ -90,7 +93,7 @@ export class WorkspaceManager {
90
93
  this.opencodeAuth.set(id, { username: opencodeUsername, password: opencodePassword, authorization });
91
94
  const environment = {
92
95
  ...userEnvironment,
93
- OPENCODE_CONFIG_DIR: this.opencodeConfigDir,
96
+ OPENCODE_CONFIG_CONTENT: opencodeConfigContent,
94
97
  CODENOMAD_INSTANCE_ID: id,
95
98
  CODENOMAD_BASE_URL: serverBaseUrl,
96
99
  ...(this.options.nodeExtraCaCertsPath ? { NODE_EXTRA_CA_CERTS: this.options.nodeExtraCaCertsPath } : {}),
@@ -4,7 +4,11 @@ export const WINDOWS_CMD_EXTENSIONS = new Set([".cmd", ".bat"]);
4
4
  export const WINDOWS_POWERSHELL_EXTENSIONS = new Set([".ps1"]);
5
5
  const VERSION_REGEX = /([0-9]+\.[0-9]+\.[0-9A-Za-z.-]+)/;
6
6
  const WSL_UNC_PATH_REGEX = /^\\\\wsl(?:\.localhost|\$)\\([^\\/]+)(?:[\\/](.*))?$/i;
7
- const WSL_PATH_ENV_KEYS = new Set(["OPENCODE_CONFIG_DIR", "NODE_EXTRA_CA_CERTS"]);
7
+ const CODENOMAD_PLUGIN_PACKAGE_NAME = "@codenomad/codenomad-opencode-plugin";
8
+ const WSL_PLUGIN_PATH_ENV = "CODENOMAD_OPENCODE_PLUGIN_WSL_PATH";
9
+ const WSL_PLUGIN_PATH_PLACEHOLDER = "__CODENOMAD_OPENCODE_PLUGIN_WSL_PATH__";
10
+ const CODENOMAD_PLUGIN_FILE_SPEC_REGEX = new RegExp(`(${escapeRegex(CODENOMAD_PLUGIN_PACKAGE_NAME)}@file:)([A-Za-z]:[^"\\r\\n]+?\\.tgz)`);
11
+ const WSL_PATH_ENV_KEYS = new Set(["NODE_EXTRA_CA_CERTS", WSL_PLUGIN_PATH_ENV]);
8
12
  export function parseWslUncPath(input) {
9
13
  const normalized = input.trim().replace(/\//g, "\\");
10
14
  const match = normalized.match(WSL_UNC_PATH_REGEX);
@@ -129,16 +133,18 @@ export function probeBinaryVersion(binaryPath) {
129
133
  }
130
134
  function buildWslSpawnSpec(wslPath, args, options) {
131
135
  const workingDirectory = options.cwd ? resolveWslWorkingDirectory(options.cwd, wslPath.distro) : undefined;
136
+ const env = buildWslEnvironment(options.env, options.propagateEnvKeys);
137
+ const shouldTranslatePluginPath = Boolean(env?.[WSL_PLUGIN_PATH_ENV]);
132
138
  if (options.cwd && !workingDirectory) {
133
139
  throw new Error(`Unable to translate workspace folder for WSL binary in distro "${wslPath.distro}": ${options.cwd}`);
134
140
  }
135
141
  const wslArgs = ["--distribution", wslPath.distro];
136
- const shouldWrapWithShell = Boolean(options.wslPidMarker) || workingDirectory?.kind === "windows";
142
+ const shouldWrapWithShell = Boolean(options.wslPidMarker) || workingDirectory?.kind === "windows" || shouldTranslatePluginPath;
137
143
  if (!shouldWrapWithShell && workingDirectory?.kind === "linux") {
138
144
  wslArgs.push("--cd", workingDirectory.path);
139
145
  }
140
146
  if (shouldWrapWithShell) {
141
- const launchScript = buildWslLaunchScript(workingDirectory ?? undefined, options.wslPidMarker);
147
+ const launchScript = buildWslLaunchScript(workingDirectory ?? undefined, options.wslPidMarker, shouldTranslatePluginPath);
142
148
  wslArgs.push("--exec", "sh", "-lc", launchScript, "codenomad-wsl-launch");
143
149
  if (workingDirectory) {
144
150
  wslArgs.push(workingDirectory.path);
@@ -152,11 +158,11 @@ function buildWslSpawnSpec(wslPath, args, options) {
152
158
  command: "wsl.exe",
153
159
  args: wslArgs,
154
160
  options: {},
155
- env: buildWslEnvironment(options.env, options.propagateEnvKeys),
161
+ env,
156
162
  wsl: { distro: wslPath.distro, pidMarker: options.wslPidMarker },
157
163
  };
158
164
  }
159
- function buildWslLaunchScript(workingDirectory, pidMarker) {
165
+ function buildWslLaunchScript(workingDirectory, pidMarker, translatePluginPath) {
160
166
  const steps = [];
161
167
  if (pidMarker) {
162
168
  steps.push(`printf '%s%s\\n' '${pidMarker}' "$$"`);
@@ -169,6 +175,9 @@ function buildWslLaunchScript(workingDirectory, pidMarker) {
169
175
  steps.push('cd "$(wslpath -au "$1")"');
170
176
  steps.push("shift");
171
177
  }
178
+ if (translatePluginPath) {
179
+ steps.push(`if [ -n "$${WSL_PLUGIN_PATH_ENV}" ] && [ -n "$OPENCODE_CONFIG_CONTENT" ]; then escaped_plugin_path=$(printf '%s' "$${WSL_PLUGIN_PATH_ENV}" | sed 's/[\\&|]/\\\\&/g'); OPENCODE_CONFIG_CONTENT=$(printf '%s' "$OPENCODE_CONFIG_CONTENT" | sed "s|${WSL_PLUGIN_PATH_PLACEHOLDER}|$escaped_plugin_path|g"); export OPENCODE_CONFIG_CONTENT; unset ${WSL_PLUGIN_PATH_ENV}; fi`);
180
+ }
172
181
  steps.push('exec "$@"');
173
182
  return steps.join(" && ");
174
183
  }
@@ -186,14 +195,15 @@ function buildWslEnvironment(env, propagateEnvKeys) {
186
195
  if (!env) {
187
196
  return env;
188
197
  }
198
+ const next = { ...env };
199
+ rewriteOpencodePluginPathForWsl(next);
189
200
  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),
201
+ ...(propagateEnvKeys ?? []).filter((key) => next[key] !== undefined),
202
+ ...Array.from(WSL_PATH_ENV_KEYS).filter((key) => next[key] !== undefined),
192
203
  ]));
193
204
  if (keysToPropagate.length === 0) {
194
- return env;
205
+ return next;
195
206
  }
196
- const next = { ...env };
197
207
  const entries = (next.WSLENV ?? "").split(":").filter((entry) => entry.length > 0);
198
208
  const byName = new Map(entries.map((entry) => [entry.split("/")[0] ?? entry, entry]));
199
209
  for (const key of keysToPropagate) {
@@ -207,6 +217,19 @@ function buildWslEnvironment(env, propagateEnvKeys) {
207
217
  next.WSLENV = Array.from(byName.values()).join(":");
208
218
  return next;
209
219
  }
220
+ function rewriteOpencodePluginPathForWsl(env) {
221
+ const content = env.OPENCODE_CONFIG_CONTENT;
222
+ if (!content) {
223
+ return;
224
+ }
225
+ const match = content.match(CODENOMAD_PLUGIN_FILE_SPEC_REGEX);
226
+ const hostPath = match?.[2];
227
+ if (!hostPath) {
228
+ return;
229
+ }
230
+ env.OPENCODE_CONFIG_CONTENT = content.replace(hostPath, WSL_PLUGIN_PATH_PLACEHOLDER);
231
+ env[WSL_PLUGIN_PATH_ENV] = path.win32.normalize(hostPath);
232
+ }
210
233
  function ensureWslenvEntry(entry, requiresPathTranslation) {
211
234
  if (!requiresPathTranslation) {
212
235
  return entry;
@@ -217,3 +240,6 @@ function ensureWslenvEntry(entry, requiresPathTranslation) {
217
240
  }
218
241
  return rawFlags.length > 0 ? `${name}/${rawFlags}p` : `${name}/p`;
219
242
  }
243
+ function escapeRegex(input) {
244
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
245
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuralnomads/codenomad",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "CodeNomad Server",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -17,10 +17,10 @@
17
17
  "codenomad": "dist/bin.js"
18
18
  },
19
19
  "scripts": {
20
- "build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json && node ./scripts/copy-auth-pages.mjs && npm run prepare-config",
20
+ "build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json && node ./scripts/copy-auth-pages.mjs && npm run prepare-plugin",
21
21
  "build:ui": "npm run build --prefix ../ui",
22
22
  "prepare-ui": "node ./scripts/copy-ui-dist.mjs",
23
- "prepare-config": "node ./scripts/copy-opencode-config.mjs",
23
+ "prepare-plugin": "node ./scripts/package-opencode-plugin.mjs",
24
24
  "dev": "cross-env CODENOMAD_DEV=1 CODENOMAD_SERVER_PASSWORD=codenomad-dev CLI_UI_DEV_SERVER=http://localhost:3000 CLI_HTTPS=false CLI_HTTP=true tsx src/index.ts",
25
25
  "typecheck": "tsc --noEmit -p tsconfig.json"
26
26
  },
@@ -1,2 +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};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-B3iAKbO0.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-DskBWxXS.js";import{m as B,t as g,i as a,d as w,a as z,f as N}from"./monaco-viewer-B3iAKbO0.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-CqJttTgx.js";import{S as H}from"./SplitFilePanel-CiZrHI3o.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";import"./main-CXJTHRp1.js";import"./align-justify-CKbOni6U.js";import"./wrap-text-hwXbREuU.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-B3iAKbO0.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};
@@ -1 +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};
1
+ import{t as g,i as c,m as W,d as i,a as S,f as C}from"./monaco-viewer-B3iAKbO0.js";import{u as T}from"./index-DskBWxXS.js";import{n as o,m as $,a as V}from"./git-diff-vendor-CSgooKT_.js";import{I as U,S as A,O as I}from"./main-CXJTHRp1.js";import{A as D}from"./align-justify-CKbOni6U.js";import{W as E}from"./wrap-text-hwXbREuU.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 z=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{z as D};
@@ -1,2 +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};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-B3iAKbO0.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-DskBWxXS.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-B3iAKbO0.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-CiZrHI3o.js";import{I as ne,R as K,M as re,P as ae,C as ie,e as se,Q as oe}from"./main-CXJTHRp1.js";import{W as ce}from"./wrap-text-hwXbREuU.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-B3iAKbO0.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:Q}=J(),[N,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=$(()=>_()&&N());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 F=`file-list-item ${e.browserSelectedPath()===n.path?"file-list-item-active":""}`,z=n.path,I=n.path,R=e.t("instanceShell.filesShell.actions.copyPath"),V=e.t("instanceShell.filesShell.actions.copyPath");return F!==v.e&&C(i,v.e=F),z!==v.t&&u(i,"title",v.t=z),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 Q()},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};