@neuralnomads/codenomad 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -4
- package/dist/background-processes/manager.js +0 -1
- package/dist/config/schema.js +1 -0
- package/dist/filesystem/__tests__/browser.test.js +65 -0
- package/dist/filesystem/__tests__/search-cache.test.js +2 -2
- package/dist/filesystem/browser.js +25 -4
- package/dist/index.js +13 -6
- package/dist/launcher.js +12 -1
- package/dist/opencode-plugin/codenomad-opencode-plugin.tgz +0 -0
- package/dist/opencode-plugin.js +146 -0
- package/dist/opencode-plugin.test.js +28 -0
- package/dist/previews/manager.js +63 -0
- package/dist/server/__tests__/listener-base-url.test.js +30 -0
- package/dist/server/http-server.js +378 -152
- package/dist/server/listener-base-url.js +17 -0
- package/dist/server/routes/config-files.js +92 -0
- package/dist/server/routes/config-files.test.js +115 -0
- package/dist/server/routes/filesystem.js +13 -0
- package/dist/server/routes/previews.js +25 -0
- package/dist/server/routes/workspaces.js +38 -1
- package/dist/workspaces/__tests__/git-clone.test.js +142 -0
- package/dist/workspaces/__tests__/spawn.test.js +27 -9
- package/dist/workspaces/git-clone.js +148 -0
- package/dist/workspaces/manager.js +27 -6
- package/dist/workspaces/spawn.js +35 -9
- package/dist/workspaces/worktree-map.js +16 -0
- package/package.json +3 -3
- package/public/assets/FilesTab-B5ysoRLh.js +2 -0
- package/public/assets/GitChangesTab-BksCi53d.js +2 -0
- package/public/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/public/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/public/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/public/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/public/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/public/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/public/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/public/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/public/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/public/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/public/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/public/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/public/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/public/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/public/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/public/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/public/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/public/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/public/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/public/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/public/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/public/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/public/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/public/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/public/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/public/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/public/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/public/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/public/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/public/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/public/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/public/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/public/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/public/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/public/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/public/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/public/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/public/assets/{SplitFilePanel-BOHH3F--.js → SplitFilePanel-CrSfR22r.js} +1 -1
- package/public/assets/StatusTab-Dgqekgjn.js +1 -0
- package/public/assets/{align-justify-9zpyaAdy.js → align-justify-hRtBz8xe.js} +1 -1
- package/public/assets/{bundle-full-xFW13Lny.js → bundle-full-BVDA-a9Y.js} +2 -2
- package/public/assets/{diff-viewer-xG9yjpN8.js → diff-viewer-BCAI0Cw8.js} +1 -1
- package/public/assets/index-B2Qd6xQq.css +1 -0
- package/public/assets/index-BQpEhdk5.js +1 -0
- package/public/assets/index-BXIEm2zT.js +1 -0
- package/public/assets/index-CWjU9mAF.js +1 -0
- package/public/assets/index-Cvtlo58a.js +1 -0
- package/public/assets/index-DFlxnvHT.js +2 -0
- package/public/assets/index-Ddsv8Uc0.js +1 -0
- package/public/assets/index-Dn7woJnK.js +1 -0
- package/public/assets/index-DnCBfFB3.js +1 -0
- package/public/assets/index-DnXT1F8T.js +1 -0
- package/public/assets/index-Kv-3BRTi.js +1 -0
- package/public/assets/index-g-G1RiME.js +1 -0
- package/public/assets/{loading-HUhLEgb_.js → loading-bD3ppK2l.js} +1 -1
- package/public/assets/main-BsbMOeQg.js +65 -0
- package/public/assets/markdown-DJuaMC5H.js +315 -0
- package/public/assets/monaco-viewer-BFNhPQX7.js +26 -0
- package/public/assets/tool-call-BSJluZRW.js +59 -0
- package/public/assets/{unified-picker-DuNuUpLy.js → unified-picker-DmFyrIis.js} +1 -1
- package/public/assets/{wrap-text-zghCl6wN.js → wrap-text-BkcW_eTA.js} +1 -1
- package/public/index.html +4 -4
- package/public/loading.html +4 -4
- package/public/sw.js +1 -1
- package/public/ui-version.json +1 -1
- package/dist/opencode-config/README.md +0 -32
- package/dist/opencode-config/opencode.jsonc +0 -3
- package/dist/opencode-config/package-lock.json +0 -380
- package/dist/opencode-config/package.json +0 -9
- package/dist/opencode-config/plugin/codenomad.ts +0 -62
- package/dist/opencode-config/plugin/lib/background-process.ts +0 -265
- package/dist/opencode-config/plugin/lib/client.ts +0 -133
- package/dist/opencode-config/plugin/lib/request.ts +0 -214
- package/dist/opencode-config.js +0 -26
- package/public/assets/ChangesTab-ovdqLHc3.js +0 -2
- package/public/assets/DiffToolbar-B12EfXMX.js +0 -1
- package/public/assets/FilesTab-nb_itEXG.js +0 -2
- package/public/assets/GitChangesTab-DcT_4BL2.js +0 -2
- package/public/assets/StatusTab-Dyt_EG33.js +0 -1
- package/public/assets/index-7DpT014-.js +0 -1
- package/public/assets/index-BDK4V9L0.js +0 -1
- package/public/assets/index-Bx-Bezt2.js +0 -1
- package/public/assets/index-CCAZZY0l.js +0 -1
- package/public/assets/index-CEcZq5WB.js +0 -1
- package/public/assets/index-CQCmSDHL.js +0 -1
- package/public/assets/index-Cz_fl8aY.js +0 -1
- package/public/assets/index-Dcgftm1m.css +0 -1
- package/public/assets/index-m4C3yx3J.js +0 -1
- package/public/assets/index-mh_z9p40.js +0 -2
- package/public/assets/main-CKhfaeKI.js +0 -48
- package/public/assets/markdown-BeXU9Z-x.js +0 -58
- package/public/assets/monaco-viewer-BgP6xpZ6.js +0 -26
- package/public/assets/todo-D6PVVp_f.js +0 -1
- package/public/assets/tool-call-Dgn3NlA8.js +0 -60
|
@@ -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 {
|
|
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.
|
|
17
|
+
this.codeNomadPluginUrl = getCodeNomadPluginUrl();
|
|
18
18
|
}
|
|
19
19
|
list() {
|
|
20
20
|
return Array.from(this.workspaces.values());
|
|
@@ -37,14 +37,28 @@ 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
|
|
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,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
readFileInDirectory(workspaceId, directory, relativePath, options) {
|
|
53
|
+
this.requireWorkspace(workspaceId);
|
|
54
|
+
const browser = new FileSystemBrowser({ rootDir: directory });
|
|
55
|
+
const encoding = options?.encoding ?? "utf-8";
|
|
56
|
+
const contents = encoding === "base64" ? browser.readFileBase64(relativePath) : browser.readFile(relativePath);
|
|
57
|
+
return {
|
|
58
|
+
workspaceId,
|
|
59
|
+
relativePath,
|
|
60
|
+
contents,
|
|
61
|
+
encoding,
|
|
48
62
|
};
|
|
49
63
|
}
|
|
50
64
|
writeFile(workspaceId, relativePath, contents) {
|
|
@@ -52,6 +66,11 @@ export class WorkspaceManager {
|
|
|
52
66
|
const browser = new FileSystemBrowser({ rootDir: workspace.path });
|
|
53
67
|
browser.writeFile(relativePath, contents);
|
|
54
68
|
}
|
|
69
|
+
writeFileInDirectory(workspaceId, directory, relativePath, contents) {
|
|
70
|
+
this.requireWorkspace(workspaceId);
|
|
71
|
+
const browser = new FileSystemBrowser({ rootDir: directory });
|
|
72
|
+
browser.writeFile(relativePath, contents);
|
|
73
|
+
}
|
|
55
74
|
async create(folder, name) {
|
|
56
75
|
const id = `${Date.now().toString(36)}`;
|
|
57
76
|
const binary = this.options.binaryResolver.resolveDefault();
|
|
@@ -59,7 +78,7 @@ export class WorkspaceManager {
|
|
|
59
78
|
const workspacePath = path.isAbsolute(folder) ? folder : path.resolve(this.options.rootDir, folder);
|
|
60
79
|
clearWorkspaceSearchCache(workspacePath);
|
|
61
80
|
this.options.logger.info({ workspaceId: id, folder: workspacePath, binary: resolvedBinaryPath }, "Creating workspace");
|
|
62
|
-
const proxyPath = `/workspaces/${id}/
|
|
81
|
+
const proxyPath = `/workspaces/${id}/instance`;
|
|
63
82
|
const descriptor = {
|
|
64
83
|
id,
|
|
65
84
|
path: workspacePath,
|
|
@@ -77,6 +96,7 @@ export class WorkspaceManager {
|
|
|
77
96
|
const serverConfig = this.options.settings.getOwner("config", "server");
|
|
78
97
|
const envVars = serverConfig?.environmentVariables;
|
|
79
98
|
const userEnvironment = envVars && typeof envVars === "object" && !Array.isArray(envVars) ? envVars : {};
|
|
99
|
+
const opencodeConfigContent = buildOpencodeConfigContent(resolveExistingOpencodeConfigContent(userEnvironment), this.codeNomadPluginUrl);
|
|
80
100
|
const serverBaseUrl = this.options.getServerBaseUrl();
|
|
81
101
|
const normalizedServerBaseUrl = serverBaseUrl.replace(/\/+$/, "");
|
|
82
102
|
const { username: opencodeUsername, password: opencodePassword } = resolveOpencodeServerAuth({
|
|
@@ -90,7 +110,8 @@ export class WorkspaceManager {
|
|
|
90
110
|
this.opencodeAuth.set(id, { username: opencodeUsername, password: opencodePassword, authorization });
|
|
91
111
|
const environment = {
|
|
92
112
|
...userEnvironment,
|
|
93
|
-
|
|
113
|
+
OPENCODE_CONFIG_CONTENT: opencodeConfigContent,
|
|
114
|
+
OPENCODE_EXPERIMENTAL_WORKSPACES: "true",
|
|
94
115
|
CODENOMAD_INSTANCE_ID: id,
|
|
95
116
|
CODENOMAD_BASE_URL: serverBaseUrl,
|
|
96
117
|
...(this.options.nodeExtraCaCertsPath ? { NODE_EXTRA_CA_CERTS: this.options.nodeExtraCaCertsPath } : {}),
|
package/dist/workspaces/spawn.js
CHANGED
|
@@ -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
|
|
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
|
|
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) =>
|
|
191
|
-
...Array.from(WSL_PATH_ENV_KEYS).filter((key) =>
|
|
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
|
|
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
|
+
}
|
|
@@ -22,6 +22,7 @@ async function ensureGitExclude(repoRoot, logger) {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
const entries = [
|
|
25
|
+
".codenomad/background_processes/",
|
|
25
26
|
".codenomad/worktrees/",
|
|
26
27
|
".codenomad/worktreeMap.json",
|
|
27
28
|
];
|
|
@@ -96,6 +97,10 @@ export async function writeWorktreeMap(workspaceFolder, next, logger) {
|
|
|
96
97
|
if (isGitRepo) {
|
|
97
98
|
await ensureGitExclude(repoRoot, logger).catch(() => undefined);
|
|
98
99
|
}
|
|
100
|
+
if (Object.keys(next.parentSessionWorktreeSlug ?? {}).length === 0) {
|
|
101
|
+
await deleteWorktreeMap(workspaceFolder, logger);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
99
104
|
const payload = {
|
|
100
105
|
version: 1,
|
|
101
106
|
defaultWorktreeSlug: next.defaultWorktreeSlug || "root",
|
|
@@ -106,6 +111,17 @@ export async function writeWorktreeMap(workspaceFolder, next, logger) {
|
|
|
106
111
|
await fsp.writeFile(tmpPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
107
112
|
await fsp.rename(tmpPath, filePath);
|
|
108
113
|
}
|
|
114
|
+
export async function deleteWorktreeMap(workspaceFolder, logger) {
|
|
115
|
+
const { repoRoot } = await resolveRepoRoot(workspaceFolder, logger);
|
|
116
|
+
const filePath = getMapPath(repoRoot);
|
|
117
|
+
try {
|
|
118
|
+
await fsp.rm(filePath, { force: true });
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
logger?.warn?.({ err: error, filePath }, "Failed to delete worktree map");
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
109
125
|
export function worktreeMapExists(repoRoot) {
|
|
110
126
|
try {
|
|
111
127
|
return fs.existsSync(getMapPath(repoRoot));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuralnomads/codenomad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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-
|
|
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-
|
|
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
|
},
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-BFNhPQX7.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{a6 as G,m,t as h,i as s,d as u,a as C,u as J,_ as X,f as Y}from"./monaco-viewer-BFNhPQX7.js";import{d as K,b as P,c as $,n as o,S as g,a as w,z as Z,A as p,F as ee}from"./git-diff-vendor-CSgooKT_.js";import{S as te}from"./SplitFilePanel-CrSfR22r.js";import{R as V,Q as le,M as re,T as ne,C as ae,e as ie,U as se}from"./main-BsbMOeQg.js";import{W as oe}from"./wrap-text-BkcW_eTA.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";import"./index-DFlxnvHT.js";var ce=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>'),de=h("<div class=file-list-header><span class=file-list-title></span><span class=file-list-count>"),O=h('<div class="p-3 text-xs text-secondary">'),he=h("<div class=file-list-item><div class=file-list-item-content><div class=file-list-item-path><span class=file-path-text>.."),ue=h('<div class="p-3 text-xs text-error">'),ve=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>'),x=h("<div class=file-viewer-empty><span class=file-viewer-empty-text>"),fe=h('<div class="file-viewer-panel flex-1"><div>'),ge=h('<div class="h-full outline-none"tabindex=0>'),we=h("<span>"),be=h("<div class=files-tab-stats><span class=files-tab-stat><span class=files-tab-selected-path><span class=file-path-text>"),Se=h("<button type=button style=margin-inline-start:auto>"),me=h("<button type=button>"),Q=h("<button type=button class=files-header-icon-button>"),$e=h("<span class=text-error>");const ye=p(()=>X(()=>import("./monaco-viewer-BFNhPQX7.js").then(e=>e.ar),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.MonacoFileViewer})));function _e(e){return e?/\.(md|markdown|mdown|mkdn)$/i.test(e):!1}const De=e=>{const[E,L]=K(""),{isDark:q}=G(),[N,M]=K(!1);let b;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()),k=$(()=>{const r=W(),i=H();return r?i.filter(d=>String(d.name||"").toLowerCase().includes(r)):i}),y=()=>e.browserLoading()&&e.browserEntries()===null,U=()=>W()?e.t("instanceShell.filesShell.search.empty"):e.t("instanceShell.filesShell.listEmpty"),_=$(()=>_e(e.browserSelectedPath())),S=$(()=>_()&&N());P(()=>{_()||M(!1)});const T=()=>{const r=e.browserSelectedContent();r!=null&&e.onSave(r)},j=async(r,i)=>{i==null||i.stopPropagation();const d=await ie(r);se({message:d?e.t("instanceShell.filesShell.toast.copyPathSuccess"):e.t("instanceShell.filesShell.toast.copyPathError"),variant:d?"success":"error"})};P(()=>{S()&&requestAnimationFrame(()=>b==null?void 0:b.focus())});const D=()=>[(()=>{var r=ce(),i=r.firstChild,d=i.firstChild,l=d.nextSibling;return s(d,o(ne,{class:"w-4 h-4"})),l.$$input=t=>L(t.currentTarget.value),w(t=>{var a=e.t("instanceShell.filesShell.search.placeholder"),n=e.t("instanceShell.filesShell.search.ariaLabel");return a!==t.e&&u(l,"placeholder",t.e=a),n!==t.t&&u(l,"aria-label",t.t=n),t},{e:void 0,t:void 0}),w(()=>l.value=E()),r})(),(()=>{var r=de(),i=r.firstChild,d=i.nextSibling;return s(i,()=>e.t("instanceShell.filesShell.fileListTitle")),s(d,()=>k().length),r})(),o(g,{get when(){return e.parentPath()},children:r=>(()=>{var i=he(),d=i.firstChild,l=d.firstChild;return i.$$click=()=>e.onLoadEntries(r()),w(()=>u(l,"title",r())),i})()}),o(g,{get when(){return y()},get children(){var r=O();return s(r,()=>e.t("instanceInfo.loading")),r}}),o(g,{get when(){return m(()=>!e.browserError()&&!y())()&&k().length>0},get fallback(){return m(()=>!y())()?m(()=>!!e.browserError())()?(()=>{var r=ue();return s(r,()=>e.browserError()),r})():(()=>{var r=O();return s(r,U),r})():void 0},get children(){return o(ee,{get each(){return k()},children:r=>(()=>{var i=ve(),d=i.firstChild,l=d.firstChild,t=l.firstChild,a=l.nextSibling,n=a.firstChild,c=n.firstChild,f=n.nextSibling;return i.$$click=()=>{if(r.type==="directory"){e.onLoadEntries(r.path);return}e.onRequestOpenFile(r.path)},s(t,()=>r.name),s(c,()=>r.type),f.$$click=v=>void j(r.path,v),s(f,o(ae,{class:"w-3 h-3"})),w(v=>{var F=`file-list-item ${e.browserSelectedPath()===r.path?"file-list-item-active":""}`,z=r.path,R=r.path,I=e.t("instanceShell.filesShell.actions.copyPath"),A=e.t("instanceShell.filesShell.actions.copyPath");return F!==v.e&&C(i,v.e=F),z!==v.t&&u(i,"title",v.t=z),R!==v.a&&u(l,"title",v.a=R),I!==v.o&&u(f,"title",v.o=I),A!==v.i&&u(f,"aria-label",v.i=A),v},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()})}})],B=r=>{!(r.ctrlKey||r.metaKey)||r.key.toLowerCase()!=="s"||e.browserSelectedSaving()||!e.browserSelectedDirty()||(r.preventDefault(),T())};return m(()=>{const r=()=>e.browserSelectedPath()||e.browserPath(),i=()=>y()?e.t("instanceInfo.loading"):e.t("instanceShell.filesShell.viewerEmpty"),d=()=>(()=>{var l=fe(),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=x(),n=a.firstChild;return s(n,i),a})()},children:a=>o(g,{get when(){return S()},get fallback(){return o(Z,{get fallback(){return(()=>{var n=x(),c=n.firstChild;return s(c,()=>e.t("instanceInfo.loading")),n})()},get children(){return o(ye,{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 n=ge();n.$$mousedown=()=>b==null?void 0:b.focus(),n.$$keydown=B;var c=b;return typeof c=="function"?J(c,n):b=n,s(n,o(re,{get part(){return{type:"text",text:a().content}},get isDark(){return q()},escapeRawHtml:!0})),n}})})},children:a=>(()=>{var n=x(),c=n.firstChild;return s(c,a),n})()})},get children(){var a=x(),n=a.firstChild;return s(n,()=>e.t("instanceInfo.loading")),a}})),w(()=>C(t,S()?"file-viewer-content":"file-viewer-content file-viewer-content--monaco")),l})();return o(te,{get header(){return[(()=>{var l=be(),t=l.firstChild,a=t.firstChild,n=a.firstChild;return s(n,r),s(l,o(g,{get when(){return e.browserLoading()},get children(){var c=we();return s(c,()=>e.t("instanceInfo.loading")),c}}),null),s(l,o(g,{get when(){return e.browserError()},children:c=>(()=>{var f=$e();return s(f,c),f})()}),null),w(()=>u(a,"title",r())),l})(),(()=>{var l=Se();return l.$$click=()=>_()&&M(t=>!t),s(l,(()=>{var t=m(()=>!!S());return()=>t()?e.t("instanceShell.filesShell.showSource"):e.t("instanceShell.filesShell.previewMarkdown")})()),w(t=>{var a=`file-viewer-toolbar-button${S()?" active":""}`,n=!_();return a!==t.e&&C(l,t.e=a),n!==t.t&&(l.disabled=t.t=n),t},{e:void 0,t:void 0}),l})(),(()=>{var l=me();return l.$$click=()=>e.onWordWrapModeChange(e.wordWrapMode()==="on"?"off":"on"),s(l,o(oe,{class:"h-4 w-4"})),w(t=>{var a=`file-viewer-toolbar-icon-button${e.wordWrapMode()==="on"?" active":""}`,n=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=S();return a!==t.e&&C(l,t.e=a),n!==t.t&&u(l,"title",t.t=n),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=Q();return l.$$click=T,s(l,o(g,{get when(){return e.browserSelectedSaving()},get fallback(){return o(le,{class:"h-4 w-4"})},get children(){return o(V,{class:"h-4 w-4 animate-spin"})}})),w(t=>{var a=e.t("instanceShell.rightPanel.actions.save")||"Save (Ctrl+S)",n=e.t("instanceShell.rightPanel.actions.save")||"Save",c=e.browserSelectedSaving()||!e.browserSelectedDirty();return a!==t.e&&u(l,"title",t.e=a),n!==t.t&&u(l,"aria-label",t.t=n),c!==t.a&&(l.disabled=t.a=c),t},{e:void 0,t:void 0,a:void 0}),l})(),(()=>{var l=Q();return l.$$click=()=>e.onRefresh(),s(l,o(V,{get class(){return`h-4 w-4${e.browserLoading()?" animate-spin":""}`}})),w(t=>{var a=e.t("instanceShell.rightPanel.actions.refresh"),n=e.t("instanceShell.rightPanel.actions.refresh"),c=e.browserLoading();return a!==t.e&&u(l,"title",t.e=a),n!==t.t&&u(l,"aria-label",t.t=n),c!==t.a&&(l.disabled=t.a=c),t},{e:void 0,t:void 0,a:void 0}),l})()]},list:{panel:()=>o(D,{}),overlay:()=>o(D,{})},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")}})})};Y(["input","click","keydown","mousedown"]);export{De as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-viewer-BFNhPQX7.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{t as u,i as n,m as D,d as g,a as q,f as ae,h as ee,_ as re}from"./monaco-viewer-BFNhPQX7.js";import{n as i,m as ce,a as P,c as b,S as k,F as te,z as oe,A as de}from"./git-diff-vendor-CSgooKT_.js";import{u as he}from"./index-DFlxnvHT.js";import{I as ge,S as ue,H as fe,J as ve,R as me,K as ne,N as ie,O as be}from"./main-BsbMOeQg.js";import{A as $e}from"./align-justify-hRtBz8xe.js";import{W as Ce}from"./wrap-text-BkcW_eTA.js";import{S as we}from"./SplitFilePanel-CrSfR22r.js";import"./fast-diff-vendor-DgdwVvTQ.js";import"./highlight-vendor-8FKMu9os.js";const _e=[["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"}]],Se=e=>i(ge,ce(e,{name:"UnfoldVertical",iconNode:_e}));var ye=u("<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 xe=e=>{const{t:S}=he(),L=()=>e.viewMode==="split"?"unified":"split",V=()=>e.contextMode==="collapsed"?"expanded":"collapsed",F=()=>e.wordWrapMode==="on"?"off":"on",w=()=>L()==="split"?S("instanceShell.diff.switchToSplit"):S("instanceShell.diff.switchToUnified"),K=()=>V()==="collapsed"?S("instanceShell.diff.hideUnchanged"):S("instanceShell.diff.showFull"),O=()=>F()==="on"?S("instanceShell.diff.enableWordWrap"):S("instanceShell.diff.disableWordWrap");return(()=>{var U=ye(),T=U.firstChild,E=T.nextSibling,I=E.nextSibling;return T.$$click=()=>e.onViewModeChange(L()),n(T,(()=>{var c=D(()=>L()==="split");return()=>c()?i(ue,{class:"h-4 w-4","aria-hidden":"true"}):i($e,{class:"h-4 w-4","aria-hidden":"true"})})()),E.$$click=()=>e.onContextModeChange(V()),n(E,(()=>{var c=D(()=>V()==="collapsed");return()=>c()?i(fe,{class:"h-4 w-4","aria-hidden":"true"}):i(Se,{class:"h-4 w-4","aria-hidden":"true"})})()),I.$$click=()=>e.onWordWrapModeChange(F()),n(I,i(Ce,{class:"h-4 w-4","aria-hidden":"true"})),P(c=>{var N=w(),o=w(),d=K(),y=K(),x=`file-viewer-toolbar-icon-button${e.wordWrapMode==="on"?" active":""}`,W=O(),G=O();return N!==c.e&&g(T,"aria-label",c.e=N),o!==c.t&&g(T,"title",c.t=o),d!==c.a&&g(E,"aria-label",c.a=d),y!==c.o&&g(E,"title",c.o=y),x!==c.i&&q(I,c.i=x),W!==c.n&&g(I,"aria-label",c.n=W),G!==c.s&&g(I,"title",c.s=G),c},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),U})()};ae(["click"]);var H=u("<div class=file-viewer-empty><span class=file-viewer-empty-text>"),Me=u('<div class="file-viewer-panel flex-1"><div class="file-viewer-content file-viewer-content--monaco">'),ke=u('<div class="p-3 text-xs text-secondary">'),Ie=u('<span class="git-change-row-action-bar git-change-row-action-bar-vertical">'),We=u('<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">'),Le=u("<div class=git-change-section-items>"),Ve=u("<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>"),Te=u('<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">'),Ee=u("<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>"),Ae=u('<span class="status-indicator session-status-list worktree-indicator git-change-section-badge"><span class=worktree-indicator-label>'),Pe=u("<span class=files-tab-selected-path><span class=file-path-text>"),Re=u('<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>-'),ze=u("<button type=button class=files-header-icon-button style=margin-left:auto>"),De=u("<span class=text-error>");const Oe=de(()=>re(()=>import("./monaco-viewer-BFNhPQX7.js").then(e=>e.as),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.MonacoDiffViewer}))),je=e=>{const S=b(()=>e.activeSessionId()),L=b(()=>!!(S()&&S()!=="info")),V=b(()=>L()?e.entries():null),F=b(()=>{const o=V();return Array.isArray(o)?[...o].sort((d,y)=>String(d.path||"").localeCompare(String(y.path||""))):[]}),w=b(()=>ve(F())),K=b(()=>w().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})),O=b(()=>w().filter(o=>o.section==="staged")),U=b(()=>w().filter(o=>o.section==="unstaged")),T=b(()=>O().length>0&&e.commitMessage().trim().length>0&&!e.commitSubmitting()),E=b(()=>{const o=w(),d=e.selectedItemId(),y=e.mostChangedItemId(),x=o.find(W=>W.id===d)||(y?o.find(W=>W.id===y):void 0);return(x==null?void 0:x.entry)??null}),I=b(()=>L()?V()===null?e.t("instanceShell.gitChanges.loading"):w().length===0?e.t("instanceShell.gitChanges.empty"):e.t("instanceShell.filesShell.viewerEmpty"):e.t("instanceShell.gitChanges.noSessionSelected")),c=b(()=>e.selectedError()===e.t("instanceShell.gitChanges.binaryViewer"));return D(()=>{const o=K(),d=E(),y=w(),x=O(),W=U(),G=()=>(()=>{var t=Me(),r=t.firstChild;return n(r,i(k,{get when(){return e.selectedLoading()},get fallback(){return i(k,{get when(){return e.selectedError()},get fallback(){return i(k,{get when(){return D(()=>!!(d&&e.selectedBefore()!==null&&e.selectedAfter()!==null))()?{path:d.path,before:e.selectedBefore(),after:e.selectedAfter()}:null},get fallback(){return(()=>{var a=H(),s=a.firstChild;return n(s,I),a})()},children:a=>i(oe,{get fallback(){return(()=>{var s=H(),l=s.firstChild;return n(l,()=>e.t("instanceInfo.loading")),s})()},get children(){return i(Oe,{get scopeKey(){return e.scopeKey()},get path(){return String(a().path||"")},get before(){return String(a().before||"")},get after(){return String(a().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 c()?void 0:s=>{const l=e.selectedItemId();if(!l)return;const f=w().find(v=>v.id===l);f&&e.onInsertContext(f,s)}}})}})})},children:a=>(()=>{var s=H(),l=s.firstChild;return n(l,a),s})()})},get children(){var a=H(),s=a.firstChild;return n(s,()=>e.t("instanceInfo.loading")),a}})),t})(),le=()=>(()=>{var t=ke();return n(t,I),t})(),J=t=>{const r=b(()=>e.selectedBulkItemIds().has(t.id)),a=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 l=We(),f=l.firstChild,v=f.firstChild,R=v.firstChild,$=v.nextSibling,_=$.firstChild,C=_.firstChild;C.firstChild;var M=C.nextSibling;M.firstChild;var B=f.nextSibling,m=B.firstChild,A=m.firstChild,z=A.firstChild;return z.firstChild,l.$$click=h=>e.onRowClick(t,h),l.$$mousedown=h=>{(h.shiftKey||h.ctrlKey||h.metaKey)&&h.preventDefault()},n(R,()=>t.path),n(C,()=>t.additions,null),n(M,()=>t.deletions,null),A.$$click=h=>{h.stopPropagation(),s()},g(A,"title",a),g(A,"aria-label",a),n(z,i(k,{get when(){return t.section!=="staged"},get children(){return Ie()}}),null),P(h=>{var Q=`file-list-item git-change-list-item ${e.selectedItemId()===t.id?"file-list-item-active":""} ${r()?"git-change-list-item-bulk-selected":""}`,X=t.path,Y=t.path,Z=t.path,p=`git-change-row-action-glyph ${t.section==="staged"?"git-change-row-action-glyph-minus":"git-change-row-action-glyph-plus"}`;return Q!==h.e&&q(l,h.e=Q),X!==h.t&&g(l,"title",h.t=X),Y!==h.a&&g(f,"title",h.a=Y),Z!==h.o&&g(v,"title",h.o=Z),p!==h.i&&q(z,h.i=p),h},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),l})()},se=(t,r,a,s)=>(()=>{var l=Ve(),f=l.firstChild,v=f.firstChild,R=v.firstChild,$=R.nextSibling,_=v.nextSibling;return ee(f,"click",s,!0),n(R,a?i(ne,{class:"h-3.5 w-3.5"}):i(ie,{class:"h-3.5 w-3.5"})),n($,t),n(_,()=>r.length),n(l,i(k,{when:a,get children(){var C=Le();return n(C,i(te,{each:r,children:M=>J(M)})),C}}),null),l})(),j=()=>i(k,{get when(){return y.length>0},get fallback(){return le()},get children(){var t=Ee(),r=t.firstChild,a=r.firstChild,s=a.firstChild,l=s.firstChild,f=l.nextSibling,v=f.firstChild,R=s.nextSibling;return ee(a,"click",e.onToggleStagedOpen,!0),n(l,(()=>{var $=D(()=>!!e.stagedOpen());return()=>$()?i(ne,{class:"h-3.5 w-3.5"}):i(ie,{class:"h-3.5 w-3.5"})})()),n(v,()=>e.t("instanceShell.gitChanges.sections.staged")),n(f,i(k,{get when(){return e.branchLabel()},children:$=>(()=>{var _=Ae(),C=_.firstChild;return n(_,i(be,{class:"w-3.5 h-3.5","aria-hidden":"true"}),C),n(C,$),P(()=>g(_,"title",`Branch: ${$()}`)),_})()}),null),n(R,()=>x.length),n(r,i(k,{get when(){return e.stagedOpen()},get children(){var $=Te(),_=$.firstChild,C=_.firstChild,M=C.firstChild,B=M.nextSibling;return M.$$input=m=>e.onCommitMessageInput(m.currentTarget.value),B.$$click=()=>e.onSubmitCommit(),n(B,(()=>{var m=D(()=>!!e.commitSubmitting());return()=>m()?e.t("instanceShell.gitChanges.commit.submitting"):e.t("instanceShell.gitChanges.commit.submit")})()),n($,i(te,{each:x,children:m=>J(m)}),null),P(m=>{var A=e.t("instanceShell.gitChanges.commit.placeholder"),z=!T();return A!==m.e&&g(M,"placeholder",m.e=A),z!==m.t&&(B.disabled=m.t=z),m},{e:void 0,t:void 0}),P(()=>M.value=e.commitMessage()),$}}),null),n(t,()=>se(e.t("instanceShell.gitChanges.sections.unstaged"),W,e.unstagedOpen(),e.onToggleUnstagedOpen),null),t}});return i(we,{get header(){return[(()=>{var t=Pe(),r=t.firstChild;return n(r,()=>(d==null?void 0:d.path)||e.t("instanceShell.rightPanel.tabs.gitChanges")),P(()=>g(t,"title",(d==null?void 0:d.path)||e.t("instanceShell.rightPanel.tabs.gitChanges"))),t})(),(()=>{var t=Re(),r=t.firstChild,a=r.firstChild;a.firstChild;var s=r.nextSibling,l=s.firstChild;return l.firstChild,n(a,()=>o.additions,null),n(l,()=>o.deletions,null),n(t,i(k,{get when(){return e.statusError()},children:f=>(()=>{var v=De();return n(v,f),v})()}),null),t})(),(()=>{var t=ze();return t.$$click=()=>e.onRefresh(),n(t,i(me,{get class(){return`h-4 w-4${e.statusLoading()?" animate-spin":""}`}})),P(r=>{var a=e.t("instanceShell.rightPanel.actions.refresh"),s=e.t("instanceShell.rightPanel.actions.refresh"),l=!L()||e.statusLoading()||V()===null;return a!==r.e&&g(t,"title",r.e=a),s!==r.t&&g(t,"aria-label",r.t=s),l!==r.a&&(t.disabled=r.a=l),r},{e:void 0,t:void 0,a:void 0}),t})(),i(xe,{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:j,overlay:j},get viewer(){return G()},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")}})})};ae(["mousedown","click","input"]);export{je as default};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-BFNhPQX7.js";import{a as g,n as r,S as n}from"./git-diff-vendor-CSgooKT_.js";import{u as S}from"./index-DFlxnvHT.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};
|