@aiderdesk/aiderdesk 0.71.2-dev → 0.73.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/out/cli.js +1069 -16
- package/out/renderer/assets/{AgentSettings-CGvSAJzP.js → AgentSettings-B8NFKgLb.js} +133 -125
- package/out/renderer/assets/{InfoIcon-CWchJVTd.js → InfoIcon-DhMP8XnB.js} +1 -1
- package/out/renderer/assets/{Onboarding-DJOy0-Od.js → Onboarding-CmlEw4fh.js} +4 -4
- package/out/renderer/assets/{ProviderHeader-BeAt2P8D.js → ProviderHeader-DMNcKpGs.js} +519 -492
- package/out/renderer/assets/{SettingsPage-iA6BPLfI.js → SettingsPage-CmOR4wA1.js} +651 -269
- package/out/renderer/assets/{UsageDashboard-Byo1Se6j.js → UsageDashboard-BGAWd1b2.js} +3 -3
- package/out/renderer/assets/{arc-DMKtKWVp.js → arc-Jg3VSYdu.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-3BPJPVTR-B6q0Xxlt.js → architectureDiagram-3BPJPVTR-BhT1Ad0h.js} +3 -3
- package/out/renderer/assets/{blockDiagram-GPEHLZMM-CwUkQOmu.js → blockDiagram-GPEHLZMM-BZuMX6U_.js} +4 -4
- package/out/renderer/assets/{c4Diagram-AAUBKEIU-jfNF8o54.js → c4Diagram-AAUBKEIU-QL7T5rpZ.js} +2 -2
- package/out/renderer/assets/{channel-CGSP36Ng.js → channel-K2W31OE5.js} +1 -1
- package/out/renderer/assets/{chunk-2J33WTMH-m9o4-rdE.js → chunk-2J33WTMH-LumY2cbE.js} +1 -1
- package/out/renderer/assets/{chunk-4BX2VUAB-sBI0mD9g.js → chunk-4BX2VUAB-GLhRzKG1.js} +1 -1
- package/out/renderer/assets/{chunk-55IACEB6-Bi-yVgmi.js → chunk-55IACEB6-B3B3AcnH.js} +1 -1
- package/out/renderer/assets/{chunk-727SXJPM-DeJ6FAqm.js → chunk-727SXJPM-DMyZUEKf.js} +5 -5
- package/out/renderer/assets/{chunk-AQP2D5EJ-RYpGSg2J.js → chunk-AQP2D5EJ-CQsD5TCd.js} +3 -3
- package/out/renderer/assets/{chunk-FMBD7UC4-DhXJts_9.js → chunk-FMBD7UC4-x4SmU5Oe.js} +1 -1
- package/out/renderer/assets/{chunk-ND2GUHAM-BmWa3jDz.js → chunk-ND2GUHAM-pT6s9nFT.js} +1 -1
- package/out/renderer/assets/{chunk-QZHKN3VN-BDCZFGDN.js → chunk-QZHKN3VN-Cv8umQxL.js} +1 -1
- package/out/renderer/assets/{classDiagram-4FO5ZUOK-B5meZIas.js → classDiagram-4FO5ZUOK-DmOcXaER.js} +6 -6
- package/out/renderer/assets/{classDiagram-v2-Q7XG4LA2-B5meZIas.js → classDiagram-v2-Q7XG4LA2-DmOcXaER.js} +6 -6
- package/out/renderer/assets/{cose-bilkent-S5V4N54A-nN2TmyEI.js → cose-bilkent-S5V4N54A-Bi6ESdxa.js} +1 -1
- package/out/renderer/assets/{dagre-BM42HDAG-CKF8Re4C.js → dagre-BM42HDAG-BK2slT53.js} +3 -3
- package/out/renderer/assets/{diagram-2AECGRRQ-BEz7N4-p.js → diagram-2AECGRRQ-DkgLH6e2.js} +3 -3
- package/out/renderer/assets/{diagram-5GNKFQAL-DzixbxEI.js → diagram-5GNKFQAL-BwAieVd0.js} +4 -4
- package/out/renderer/assets/{diagram-KO2AKTUF-DrU3hJT-.js → diagram-KO2AKTUF-D6Km_LB9.js} +3 -3
- package/out/renderer/assets/{diagram-LMA3HP47-DeV3p8aR.js → diagram-LMA3HP47-BhWSHEeO.js} +3 -3
- package/out/renderer/assets/{diagram-OG6HWLK6-DqkXt2nH.js → diagram-OG6HWLK6-zoN4RvNr.js} +4 -4
- package/out/renderer/assets/{erDiagram-TEJ5UH35-BQPyNf4w.js → erDiagram-TEJ5UH35-DooZS_mc.js} +4 -4
- package/out/renderer/assets/{flowDiagram-I6XJVG4X-D2v6iQ98.js → flowDiagram-I6XJVG4X-CmZPvaDJ.js} +6 -6
- package/out/renderer/assets/{ganttDiagram-6RSMTGT7-CkYOeW7M.js → ganttDiagram-6RSMTGT7-Bx6OJzRM.js} +3 -3
- package/out/renderer/assets/{gitGraphDiagram-PVQCEYII-g-Uk6P-N.js → gitGraphDiagram-PVQCEYII-BPUT8Ht7.js} +4 -4
- package/out/renderer/assets/{graph-CV504Ptb.js → graph-CwC0h_b8.js} +1 -1
- package/out/renderer/assets/{index-D4QsfuBU.css → index-B3o44aT2.css} +8 -24
- package/out/renderer/assets/{index-U06SYLCN.js → index-BSFaA4XQ.js} +1 -1
- package/out/renderer/assets/{index-BijIcXFX.js → index-BrZFlbuf.js} +1 -1
- package/out/renderer/assets/{index-MWcT9iVP.js → index-CI0IUNzz.js} +12451 -3381
- package/out/renderer/assets/{index-3BRmjDVt.js → index-CXq4cCbe.js} +131 -31
- package/out/renderer/assets/{index-BRRWavZT.js → index-ChKmR4QP.js} +1 -1
- package/out/renderer/assets/{index-DWl6Lclq.js → index-DOOlJc12.js} +1 -1
- package/out/renderer/assets/{index-Bup9YtMB.js → index-DqiktxfT.js} +1 -1
- package/out/renderer/assets/{index-BKAL4gqM.js → index-Ds5GQdTm.js} +1 -1
- package/out/renderer/assets/{index-BBiLtvNT.js → index-PGLvyST0.js} +1 -1
- package/out/renderer/assets/{index-McGZ6Dx1.js → index-xI0MsLE8.js} +1 -1
- package/out/renderer/assets/{infoDiagram-5YYISTIA-D7CDIKx-.js → infoDiagram-5YYISTIA-C77gIx1a.js} +2 -2
- package/out/renderer/assets/{ishikawaDiagram-YF4QCWOH-Dy5lIJM3.js → ishikawaDiagram-YF4QCWOH-DZ8xk7_N.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-JHISSGLW-s4XQg-Ha.js → journeyDiagram-JHISSGLW-BLPdv_c5.js} +4 -4
- package/out/renderer/assets/{jsx-dev-runtime-D9-9kVso.js → jsx-dev-runtime-1M6DZ35g.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UN3LZRKU-BCWYozJY.js → kanban-definition-UN3LZRKU-CMHVN7c3.js} +2 -2
- package/out/renderer/assets/{layout-DnWGEu0W.js → layout-BJqshyQm.js} +2 -2
- package/out/renderer/assets/{linear-BP7dS-hv.js → linear-CbEhS1qE.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-RKZ34NQL-DpF4KI3g.js → mindmap-definition-RKZ34NQL-C8Cz7pQU.js} +3 -3
- package/out/renderer/assets/{pieDiagram-4H26LBE5-B6ZbPky5.js → pieDiagram-4H26LBE5-Bx5tSw6i.js} +4 -4
- package/out/renderer/assets/{quadrantDiagram-W4KKPZXB-QcDi1tPp.js → quadrantDiagram-W4KKPZXB-CX6DcDEk.js} +2 -2
- package/out/renderer/assets/{requirementDiagram-4Y6WPE33-B1JR969o.js → requirementDiagram-4Y6WPE33-qBp8nKy9.js} +3 -3
- package/out/renderer/assets/{sankeyDiagram-5OEKKPKP-BJ5rhw2A.js → sankeyDiagram-5OEKKPKP-B5zYIsBo.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-3UESZ5HK-AdtAIm4D.js → sequenceDiagram-3UESZ5HK-C57DtTdH.js} +3 -3
- package/out/renderer/assets/{stateDiagram-AJRCARHV--GQXQ4Qf.js → stateDiagram-AJRCARHV-CGRyr6CG.js} +6 -6
- package/out/renderer/assets/{stateDiagram-v2-BHNVJYJU-CQAnRm7m.js → stateDiagram-v2-BHNVJYJU-3hvBe5lv.js} +4 -4
- package/out/renderer/assets/{time-BUK5ZzpA.js → time-B3bXse3U.js} +1 -1
- package/out/renderer/assets/{timeline-definition-PNZ67QCA-CRru39WZ.js → timeline-definition-PNZ67QCA-Dpq0iPd0.js} +2 -2
- package/out/renderer/assets/{vennDiagram-CIIHVFJN-KF7qF8WR.js → vennDiagram-CIIHVFJN-_jSNuVb5.js} +1 -1
- package/out/renderer/assets/{wardley-L42UT6IY-D3pQt3SZ.js → wardley-L42UT6IY-DixmVaQZ.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-YWT4CUSO-D3zxlHug.js → wardleyDiagram-YWT4CUSO-DMK4zc32.js} +3 -3
- package/out/renderer/assets/{xychartDiagram-2RQKCTM6-B_0-TgYJ.js → xychartDiagram-2RQKCTM6-DKPuWmAF.js} +2 -2
- package/out/renderer/index.html +2 -2
- package/out/resources/connector/connector.py +6 -1
- package/out/resources/skills/extension-creator/SKILL.md +5 -5
- package/out/resources/skills/extension-creator/references/in-repo-flow.md +4 -4
- package/out/resources/skills/extension-creator/references/install-targets.md +2 -2
- package/out/resources/skills/extension-creator/references/project-global-flow.md +1 -1
- package/out/runner.js +881 -385
- package/package.json +16 -19
- package/scripts/download-probe.mjs +9 -2
- package/scripts/generate-package.mjs +1 -1
- package/out/renderer/assets/gemini-cli-BKI4k4GP.png +0 -0
- package/patches/ai-sdk-provider-gemini-cli+1.5.1.patch +0 -373
package/out/runner.js
CHANGED
|
@@ -33,11 +33,10 @@ const os = require("os");
|
|
|
33
33
|
const http = require("http");
|
|
34
34
|
const istextorbinary = require("istextorbinary");
|
|
35
35
|
const child_process = require("child_process");
|
|
36
|
-
const util = require("util");
|
|
37
36
|
const treeKill = require("tree-kill");
|
|
38
|
-
const ai = require("ai");
|
|
39
37
|
const glob = require("glob");
|
|
40
38
|
const fs$1 = require("fs");
|
|
39
|
+
const util = require("util");
|
|
41
40
|
const dotenvx = require("@dotenvx/dotenvx");
|
|
42
41
|
const YAML = require("yaml");
|
|
43
42
|
const posthogNode = require("posthog-node");
|
|
@@ -66,6 +65,7 @@ const debounce = require("lodash/debounce.js");
|
|
|
66
65
|
const crypto = require("crypto");
|
|
67
66
|
const undici = require("undici");
|
|
68
67
|
const globalAgent = require("global-agent");
|
|
68
|
+
const ai = require("ai");
|
|
69
69
|
const fileType = require("file-type");
|
|
70
70
|
const anthropic = require("@ai-sdk/anthropic");
|
|
71
71
|
const azure = require("@ai-sdk/azure");
|
|
@@ -281,6 +281,7 @@ var MessageViewMode = /* @__PURE__ */ ((MessageViewMode2) => {
|
|
|
281
281
|
return MessageViewMode2;
|
|
282
282
|
})(MessageViewMode || {});
|
|
283
283
|
var ReasoningEffort = /* @__PURE__ */ ((ReasoningEffort2) => {
|
|
284
|
+
ReasoningEffort2["Max"] = "max";
|
|
284
285
|
ReasoningEffort2["XHigh"] = "xhigh";
|
|
285
286
|
ReasoningEffort2["High"] = "high";
|
|
286
287
|
ReasoningEffort2["Medium"] = "medium";
|
|
@@ -1121,6 +1122,10 @@ class ShellDetector {
|
|
|
1121
1122
|
}
|
|
1122
1123
|
}
|
|
1123
1124
|
const getPathSeparator = () => process.platform === "win32" ? ";" : ":";
|
|
1125
|
+
const extractPathFromOutput = (output) => {
|
|
1126
|
+
const lines = output.split("\n").filter((line) => line.trim().length > 0);
|
|
1127
|
+
return (lines[lines.length - 1] || "").trim();
|
|
1128
|
+
};
|
|
1124
1129
|
const getShellPath = () => {
|
|
1125
1130
|
if (cachedPath && !isFirstCall) {
|
|
1126
1131
|
return cachedPath;
|
|
@@ -1174,32 +1179,13 @@ const getShellPath = () => {
|
|
|
1174
1179
|
let sourceCommand = "";
|
|
1175
1180
|
const homeDir = os__namespace.homedir();
|
|
1176
1181
|
if (shell.includes("zsh")) {
|
|
1177
|
-
sourceCommand = `source /etc/zprofile
|
|
1182
|
+
sourceCommand = `source /etc/zprofile >/dev/null 2>&1 || true; source ${homeDir}/.zprofile >/dev/null 2>&1 || true; source /etc/zshrc >/dev/null 2>&1 || true; source ${homeDir}/.zshrc >/dev/null 2>&1 || true; `;
|
|
1178
1183
|
} else if (shell.includes("bash")) {
|
|
1179
|
-
sourceCommand = `source /etc/profile
|
|
1184
|
+
sourceCommand = `source /etc/profile >/dev/null 2>&1 || true; source ${homeDir}/.bash_profile >/dev/null 2>&1 || true; source ${homeDir}/.bashrc >/dev/null 2>&1 || true; `;
|
|
1180
1185
|
}
|
|
1181
1186
|
const fullCommand = `${shell} -c '${sourceCommand}echo $PATH'`;
|
|
1182
|
-
shellPath =
|
|
1183
|
-
|
|
1184
|
-
timeout: isLinux2 ? 3e3 : 1e4,
|
|
1185
|
-
// Shorter timeout for Linux
|
|
1186
|
-
env: {
|
|
1187
|
-
PATH: minimalPath,
|
|
1188
|
-
SHELL: shell,
|
|
1189
|
-
USER: os__namespace.userInfo().username,
|
|
1190
|
-
HOME: homeDir,
|
|
1191
|
-
// Add ZDOTDIR for zsh users who might have custom config location
|
|
1192
|
-
ZDOTDIR: process.env.ZDOTDIR || homeDir
|
|
1193
|
-
}
|
|
1194
|
-
}).trim();
|
|
1195
|
-
logger.debug("Successfully loaded user PATH from shell config files", {
|
|
1196
|
-
fullCommand,
|
|
1197
|
-
pathLength: shellPath.split(":").length
|
|
1198
|
-
});
|
|
1199
|
-
} catch (error) {
|
|
1200
|
-
logger.error("Failed to load PATH from shell config:", error);
|
|
1201
|
-
try {
|
|
1202
|
-
shellPath = child_process.execSync(shellCommand, {
|
|
1187
|
+
shellPath = extractPathFromOutput(
|
|
1188
|
+
child_process.execSync(fullCommand, {
|
|
1203
1189
|
encoding: "utf8",
|
|
1204
1190
|
timeout: isLinux2 ? 3e3 : 1e4,
|
|
1205
1191
|
// Shorter timeout for Linux
|
|
@@ -1207,9 +1193,32 @@ const getShellPath = () => {
|
|
|
1207
1193
|
PATH: minimalPath,
|
|
1208
1194
|
SHELL: shell,
|
|
1209
1195
|
USER: os__namespace.userInfo().username,
|
|
1210
|
-
HOME:
|
|
1196
|
+
HOME: homeDir,
|
|
1197
|
+
// Add ZDOTDIR for zsh users who might have custom config location
|
|
1198
|
+
ZDOTDIR: process.env.ZDOTDIR || homeDir
|
|
1211
1199
|
}
|
|
1212
|
-
})
|
|
1200
|
+
})
|
|
1201
|
+
);
|
|
1202
|
+
logger.debug("Successfully loaded user PATH from shell config files", {
|
|
1203
|
+
fullCommand,
|
|
1204
|
+
pathLength: shellPath.split(":").length
|
|
1205
|
+
});
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
logger.error("Failed to load PATH from shell config:", error);
|
|
1208
|
+
try {
|
|
1209
|
+
shellPath = extractPathFromOutput(
|
|
1210
|
+
child_process.execSync(shellCommand, {
|
|
1211
|
+
encoding: "utf8",
|
|
1212
|
+
timeout: isLinux2 ? 3e3 : 1e4,
|
|
1213
|
+
// Shorter timeout for Linux
|
|
1214
|
+
env: {
|
|
1215
|
+
PATH: minimalPath,
|
|
1216
|
+
SHELL: shell,
|
|
1217
|
+
USER: os__namespace.userInfo().username,
|
|
1218
|
+
HOME: os__namespace.homedir()
|
|
1219
|
+
}
|
|
1220
|
+
})
|
|
1221
|
+
);
|
|
1213
1222
|
logger.debug("Loaded PATH using login shell flags");
|
|
1214
1223
|
} catch (loginError) {
|
|
1215
1224
|
logger.error("Failed to load PATH from login shell:", loginError);
|
|
@@ -1218,22 +1227,26 @@ const getShellPath = () => {
|
|
|
1218
1227
|
}
|
|
1219
1228
|
} else {
|
|
1220
1229
|
try {
|
|
1221
|
-
shellPath =
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1230
|
+
shellPath = extractPathFromOutput(
|
|
1231
|
+
child_process.execSync(`${shell} -c 'echo $PATH'`, {
|
|
1232
|
+
encoding: "utf8",
|
|
1233
|
+
timeout: 2e3,
|
|
1234
|
+
env: process.env
|
|
1235
|
+
})
|
|
1236
|
+
);
|
|
1226
1237
|
logger.debug("Quick PATH retrieval succeeded");
|
|
1227
1238
|
} catch (quickError) {
|
|
1228
1239
|
logger.debug("Quick PATH retrieval failed, falling back to login shell approach", {
|
|
1229
1240
|
error: quickError instanceof Error ? quickError.message : quickError
|
|
1230
1241
|
});
|
|
1231
|
-
shellPath =
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1242
|
+
shellPath = extractPathFromOutput(
|
|
1243
|
+
child_process.execSync(shellCommand, {
|
|
1244
|
+
encoding: "utf8",
|
|
1245
|
+
timeout: isLinux2 ? 3e3 : 1e4,
|
|
1246
|
+
// Shorter timeout for Linux
|
|
1247
|
+
env: process.env
|
|
1248
|
+
})
|
|
1249
|
+
);
|
|
1237
1250
|
logger.debug("Login shell PATH retrieval succeeded");
|
|
1238
1251
|
}
|
|
1239
1252
|
}
|
|
@@ -1397,40 +1410,6 @@ const getShellPath = () => {
|
|
|
1397
1410
|
return fallbackPath;
|
|
1398
1411
|
}
|
|
1399
1412
|
};
|
|
1400
|
-
const findExecutableInPath = (executable, checkOnly = false) => {
|
|
1401
|
-
logger.debug(`Finding executable: ${executable}`);
|
|
1402
|
-
const shellPath = getShellPath();
|
|
1403
|
-
const pathSep = getPathSeparator();
|
|
1404
|
-
const paths = shellPath.split(pathSep);
|
|
1405
|
-
const isWindows = process.platform === "win32";
|
|
1406
|
-
logger.debug(`Searching in ${paths.length} PATH directories`);
|
|
1407
|
-
const executableNames = isWindows ? [executable, `${executable}.exe`, `${executable}.cmd`, `${executable}.bat`] : [executable];
|
|
1408
|
-
let searchedPaths = 0;
|
|
1409
|
-
for (const dir of paths) {
|
|
1410
|
-
for (const execName of executableNames) {
|
|
1411
|
-
const fullPath = path__namespace.join(dir, execName);
|
|
1412
|
-
searchedPaths++;
|
|
1413
|
-
try {
|
|
1414
|
-
if (isWindows) {
|
|
1415
|
-
fs__namespace.accessSync(fullPath, fs__namespace.constants.F_OK);
|
|
1416
|
-
logger.debug(`Found executable at: ${fullPath}`);
|
|
1417
|
-
return fullPath;
|
|
1418
|
-
} else {
|
|
1419
|
-
child_process.execSync(`test -x "${fullPath}"`, { stdio: "ignore" });
|
|
1420
|
-
logger.debug(`Found executable at: ${fullPath}`);
|
|
1421
|
-
return fullPath;
|
|
1422
|
-
}
|
|
1423
|
-
} catch {
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
if (!checkOnly) {
|
|
1428
|
-
logger.error(`Executable '${executable}' not found after searching ${searchedPaths} paths`, {
|
|
1429
|
-
firstFewPaths: paths.slice(0, 5).join(", ")
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
return null;
|
|
1433
|
-
};
|
|
1434
1413
|
const getShellCommandArgs = (command) => {
|
|
1435
1414
|
return ShellDetector.getShellCommandArgs(command);
|
|
1436
1415
|
};
|
|
@@ -1501,7 +1480,6 @@ const AVAILABLE_PROVIDERS = [
|
|
|
1501
1480
|
"cerebras",
|
|
1502
1481
|
"deepseek",
|
|
1503
1482
|
"gemini",
|
|
1504
|
-
"gemini-cli",
|
|
1505
1483
|
"gpustack",
|
|
1506
1484
|
"groq",
|
|
1507
1485
|
"kimi-plan",
|
|
@@ -1541,7 +1519,6 @@ const isLmStudioProvider = (provider) => provider.name === "lmstudio";
|
|
|
1541
1519
|
const isDeepseekProvider = (provider) => provider.name === "deepseek";
|
|
1542
1520
|
const isGroqProvider = (provider) => provider.name === "groq";
|
|
1543
1521
|
const isCerebrasProvider = (provider) => provider.name === "cerebras";
|
|
1544
|
-
const isGeminiCliProvider = (provider) => provider.name === "gemini-cli";
|
|
1545
1522
|
const isBedrockProvider = (provider) => provider.name === "bedrock";
|
|
1546
1523
|
const isOpenAiCompatibleProvider = (provider) => provider.name === "openai-compatible";
|
|
1547
1524
|
const isLitellmProvider = (provider) => provider.name === "litellm";
|
|
@@ -1562,7 +1539,6 @@ const DEFAULT_PROVIDER_MODELS = {
|
|
|
1562
1539
|
cerebras: "qwen-3-235b-a22b-instruct-2507",
|
|
1563
1540
|
deepseek: "deepseek-v4-pro",
|
|
1564
1541
|
gemini: "gemini-pro-latest",
|
|
1565
|
-
"gemini-cli": "gemini-2.5-pro",
|
|
1566
1542
|
groq: "moonshotai/kimi-k2-instruct-0905",
|
|
1567
1543
|
"kimi-plan": "k2p6",
|
|
1568
1544
|
openai: "gpt-5.4",
|
|
@@ -1958,7 +1934,8 @@ const getDefaultProviderParams = (providerName) => {
|
|
|
1958
1934
|
case "zai-plan":
|
|
1959
1935
|
provider = {
|
|
1960
1936
|
name: "zai-plan",
|
|
1961
|
-
apiKey: ""
|
|
1937
|
+
apiKey: "",
|
|
1938
|
+
reasoningEffort: ReasoningEffort.Max
|
|
1962
1939
|
};
|
|
1963
1940
|
break;
|
|
1964
1941
|
case "minimax":
|
|
@@ -1976,13 +1953,8 @@ const getDefaultProviderParams = (providerName) => {
|
|
|
1976
1953
|
case "neuralwatt":
|
|
1977
1954
|
provider = {
|
|
1978
1955
|
name: "neuralwatt",
|
|
1979
|
-
apiKey: ""
|
|
1980
|
-
|
|
1981
|
-
break;
|
|
1982
|
-
case "gemini-cli":
|
|
1983
|
-
provider = {
|
|
1984
|
-
name: "gemini-cli",
|
|
1985
|
-
projectId: ""
|
|
1956
|
+
apiKey: "",
|
|
1957
|
+
reasoningEffort: ReasoningEffort.High
|
|
1986
1958
|
};
|
|
1987
1959
|
break;
|
|
1988
1960
|
default:
|
|
@@ -3455,7 +3427,6 @@ const estimateMessageTokens = (messages) => {
|
|
|
3455
3427
|
});
|
|
3456
3428
|
return textOnlyMessages.reduce((sum, msg) => sum + gpt4o.encode(typeof msg.content === "string" ? msg.content : "").length, 0) + estimatedImageTokens;
|
|
3457
3429
|
};
|
|
3458
|
-
const execFileAsync = util.promisify(child_process.execFile);
|
|
3459
3430
|
const fileLocks = /* @__PURE__ */ new Map();
|
|
3460
3431
|
const withFileLock = (filePath, operation) => {
|
|
3461
3432
|
logger.debug("Acquiring file lock:", { filePath });
|
|
@@ -3772,7 +3743,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3772
3743
|
return "Error: ripgrep binary is not available. Please try again or check the logs for details.";
|
|
3773
3744
|
}
|
|
3774
3745
|
try {
|
|
3775
|
-
const rgArgs = ["--no-heading", "--line-number", "--color", "never"
|
|
3746
|
+
const rgArgs = ["--no-heading", "--line-number", "--color", "never"];
|
|
3776
3747
|
if (!caseSensitive) {
|
|
3777
3748
|
rgArgs.push("-i");
|
|
3778
3749
|
}
|
|
@@ -3787,41 +3758,29 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3787
3758
|
args: rgArgs,
|
|
3788
3759
|
cwd: taskDir
|
|
3789
3760
|
});
|
|
3790
|
-
const { stdout, stderr } = await execFileAsync(RIPGREP_BINARY_PATH, rgArgs, {
|
|
3791
|
-
cwd: taskDir,
|
|
3792
|
-
env: { ...process.env, TERM: "dumb", PATH: getShellPath() },
|
|
3793
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
3794
|
-
windowsHide: true
|
|
3795
|
-
});
|
|
3796
|
-
logger.debug("ripgrep stdout raw:", { stdout: stdout.substring(0, 2e3) });
|
|
3797
|
-
logger.debug("ripgrep stderr:", { stderr: stderr.substring(0, 2e3) });
|
|
3798
|
-
const outputLines = stdout.split("\n").filter(Boolean);
|
|
3799
|
-
logger.debug("outputLines count:", { count: outputLines.length, lines: outputLines.slice(0, 20) });
|
|
3800
|
-
if (outputLines.length === 0) {
|
|
3801
|
-
return `No matches found for pattern '${searchTerm}' in files matching '${filePattern}'.`;
|
|
3802
|
-
}
|
|
3803
3761
|
const results = [];
|
|
3804
3762
|
const outputLineRegex = /^(.+?)([:-])(\d+)\2(.*)$/;
|
|
3805
3763
|
let pendingBeforeContext = [];
|
|
3806
3764
|
let afterContextBreak = false;
|
|
3807
|
-
|
|
3765
|
+
let stderrData = "";
|
|
3766
|
+
let lineBuffer = "";
|
|
3767
|
+
const processLine = (rawLine) => {
|
|
3808
3768
|
if (rawLine.endsWith("\r")) {
|
|
3809
3769
|
rawLine = rawLine.slice(0, -1);
|
|
3810
3770
|
}
|
|
3811
3771
|
if (rawLine === "--") {
|
|
3812
3772
|
pendingBeforeContext = [];
|
|
3813
3773
|
afterContextBreak = true;
|
|
3814
|
-
|
|
3774
|
+
return false;
|
|
3815
3775
|
}
|
|
3816
|
-
const
|
|
3817
|
-
const match = outputLineRegex.exec(line);
|
|
3776
|
+
const match = outputLineRegex.exec(rawLine);
|
|
3818
3777
|
if (!match) {
|
|
3819
|
-
|
|
3778
|
+
return false;
|
|
3820
3779
|
}
|
|
3821
3780
|
const [, rawFilePath, separator, lineNumStr, content] = match;
|
|
3822
3781
|
const lineNum = parseInt(lineNumStr, 10);
|
|
3823
3782
|
if (isNaN(lineNum)) {
|
|
3824
|
-
|
|
3783
|
+
return false;
|
|
3825
3784
|
}
|
|
3826
3785
|
const filePath = rawFilePath.startsWith("./") ? rawFilePath.slice(2) : rawFilePath;
|
|
3827
3786
|
const isMatch = separator === ":";
|
|
@@ -3850,13 +3809,96 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3850
3809
|
}
|
|
3851
3810
|
}
|
|
3852
3811
|
}
|
|
3853
|
-
|
|
3854
|
-
|
|
3812
|
+
return results.length >= maxResults;
|
|
3813
|
+
};
|
|
3814
|
+
let wasAborted = false;
|
|
3815
|
+
await new Promise((resolveStream) => {
|
|
3816
|
+
let streamResolved = false;
|
|
3817
|
+
let childProcess = null;
|
|
3818
|
+
let abortListener = null;
|
|
3819
|
+
const cleanup = () => {
|
|
3820
|
+
if (abortListener && abortSignal) {
|
|
3821
|
+
abortSignal.removeEventListener("abort", abortListener);
|
|
3822
|
+
}
|
|
3823
|
+
};
|
|
3824
|
+
const finish = () => {
|
|
3825
|
+
if (streamResolved) {
|
|
3826
|
+
return;
|
|
3827
|
+
}
|
|
3828
|
+
streamResolved = true;
|
|
3829
|
+
cleanup();
|
|
3830
|
+
resolveStream();
|
|
3831
|
+
};
|
|
3832
|
+
abortListener = () => {
|
|
3833
|
+
if (streamResolved) {
|
|
3834
|
+
return;
|
|
3835
|
+
}
|
|
3836
|
+
wasAborted = true;
|
|
3837
|
+
if (childProcess?.pid) {
|
|
3838
|
+
try {
|
|
3839
|
+
childProcess.kill("SIGKILL");
|
|
3840
|
+
} catch {
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
abortSignal?.addEventListener("abort", abortListener);
|
|
3845
|
+
try {
|
|
3846
|
+
childProcess = child_process.spawn(RIPGREP_BINARY_PATH, rgArgs, {
|
|
3847
|
+
cwd: taskDir,
|
|
3848
|
+
env: { ...process.env, TERM: "dumb", PATH: getShellPath() },
|
|
3849
|
+
windowsHide: true
|
|
3850
|
+
});
|
|
3851
|
+
} catch (spawnError) {
|
|
3852
|
+
stderrData = spawnError instanceof Error ? spawnError.message : String(spawnError);
|
|
3853
|
+
finish();
|
|
3854
|
+
return;
|
|
3855
3855
|
}
|
|
3856
|
+
childProcess.stdout?.on("data", (data) => {
|
|
3857
|
+
if (streamResolved) {
|
|
3858
|
+
return;
|
|
3859
|
+
}
|
|
3860
|
+
lineBuffer += data.toString("utf-8");
|
|
3861
|
+
const lines = lineBuffer.split("\n");
|
|
3862
|
+
lineBuffer = lines.pop() || "";
|
|
3863
|
+
for (const rawLine of lines) {
|
|
3864
|
+
if (!rawLine) {
|
|
3865
|
+
continue;
|
|
3866
|
+
}
|
|
3867
|
+
const reachedLimit = processLine(rawLine);
|
|
3868
|
+
if (reachedLimit) {
|
|
3869
|
+
try {
|
|
3870
|
+
childProcess?.kill("SIGKILL");
|
|
3871
|
+
} catch {
|
|
3872
|
+
}
|
|
3873
|
+
finish();
|
|
3874
|
+
return;
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
});
|
|
3878
|
+
childProcess.stderr?.on("data", (data) => {
|
|
3879
|
+
stderrData += data.toString("utf-8");
|
|
3880
|
+
});
|
|
3881
|
+
childProcess.on("error", (error) => {
|
|
3882
|
+
if (!streamResolved) {
|
|
3883
|
+
stderrData = error.message;
|
|
3884
|
+
finish();
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
childProcess.on("close", () => {
|
|
3888
|
+
if (!streamResolved && lineBuffer) {
|
|
3889
|
+
processLine(lineBuffer);
|
|
3890
|
+
lineBuffer = "";
|
|
3891
|
+
}
|
|
3892
|
+
finish();
|
|
3893
|
+
});
|
|
3894
|
+
});
|
|
3895
|
+
if (wasAborted || abortSignal?.aborted) {
|
|
3896
|
+
return "Operation was cancelled by user.";
|
|
3856
3897
|
}
|
|
3898
|
+
logger.debug("ripgrep results count:", { count: results.length, stderr: stderrData.substring(0, 500) });
|
|
3857
3899
|
if (results.length === 0) {
|
|
3858
|
-
if (
|
|
3859
|
-
return `Error during grep: ${
|
|
3900
|
+
if (stderrData.trim()) {
|
|
3901
|
+
return `Error during grep: ${stderrData.trim()}`;
|
|
3860
3902
|
}
|
|
3861
3903
|
return `No matches found for pattern '${searchTerm}' in files matching '${filePattern}'.`;
|
|
3862
3904
|
}
|
|
@@ -4150,8 +4192,24 @@ Format: ${format}`;
|
|
|
4150
4192
|
language: zod.z.string().optional().describe("Limit search to files of a specific programming language")
|
|
4151
4193
|
}),
|
|
4152
4194
|
execute: async (input, { toolCallId }) => {
|
|
4153
|
-
const { query: searchQuery, path: inputPath, allowTests, exact, maxTokens: paramMaxTokens, language } = input;
|
|
4154
|
-
task.addToolMessage(
|
|
4195
|
+
const { query: searchQuery, path: inputPath, allowTests, exact, maxResults: paramMaxResults, maxTokens: paramMaxTokens, language } = input;
|
|
4196
|
+
task.addToolMessage(
|
|
4197
|
+
toolCallId,
|
|
4198
|
+
POWER_TOOL_GROUP_NAME,
|
|
4199
|
+
POWER_TOOL_SEMANTIC_SEARCH,
|
|
4200
|
+
{
|
|
4201
|
+
query: searchQuery,
|
|
4202
|
+
path: inputPath,
|
|
4203
|
+
allowTests,
|
|
4204
|
+
exact,
|
|
4205
|
+
maxResults: paramMaxResults,
|
|
4206
|
+
maxTokens: paramMaxTokens,
|
|
4207
|
+
language
|
|
4208
|
+
},
|
|
4209
|
+
void 0,
|
|
4210
|
+
void 0,
|
|
4211
|
+
promptContext
|
|
4212
|
+
);
|
|
4155
4213
|
const toolName = `${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_SEMANTIC_SEARCH}`;
|
|
4156
4214
|
const questionKey = toolName;
|
|
4157
4215
|
const questionText = "Approve running codebase search?";
|
|
@@ -4159,7 +4217,9 @@ Format: ${format}`;
|
|
|
4159
4217
|
Path: ${inputPath || "."}
|
|
4160
4218
|
Allow Tests: ${allowTests}
|
|
4161
4219
|
Exact: ${exact}
|
|
4162
|
-
|
|
4220
|
+
Max Results: ${paramMaxResults ?? "default"}
|
|
4221
|
+
Max Tokens: ${paramMaxTokens}
|
|
4222
|
+
Language: ${language || "all"}`;
|
|
4163
4223
|
const [isApproved, userInput] = await approvalManager.handleToolApproval(toolName, input, questionKey, questionText, questionSubject);
|
|
4164
4224
|
if (!isApproved) {
|
|
4165
4225
|
return `Search execution denied by user. Reason: ${userInput}`;
|
|
@@ -4194,6 +4254,13 @@ Language: ${language}`;
|
|
|
4194
4254
|
"rb",
|
|
4195
4255
|
"php",
|
|
4196
4256
|
"swift",
|
|
4257
|
+
"solidity",
|
|
4258
|
+
"sol",
|
|
4259
|
+
"crystal",
|
|
4260
|
+
"cr",
|
|
4261
|
+
"haskell",
|
|
4262
|
+
"hs",
|
|
4263
|
+
"lhs",
|
|
4197
4264
|
"csharp",
|
|
4198
4265
|
"cs",
|
|
4199
4266
|
"yaml",
|
|
@@ -4210,6 +4277,7 @@ Language: ${language}`;
|
|
|
4210
4277
|
// 5 minutes
|
|
4211
4278
|
json: false,
|
|
4212
4279
|
maxTokens: effectiveMaxTokens,
|
|
4280
|
+
maxResults: paramMaxResults,
|
|
4213
4281
|
language: effectiveLanguage
|
|
4214
4282
|
});
|
|
4215
4283
|
logger.debug(`Search results: ${JSON.stringify(results)}`);
|
|
@@ -6818,7 +6886,7 @@ ${fileList}${readOnlyNote}`
|
|
|
6818
6886
|
}
|
|
6819
6887
|
/**
|
|
6820
6888
|
* Recursively strips unsupported JSON Schema 2019-09 keywords that are not
|
|
6821
|
-
* recognized by some MCP servers
|
|
6889
|
+
* recognized by some MCP servers.
|
|
6822
6890
|
*/
|
|
6823
6891
|
stripUnsupportedSchemaKeywords(schema) {
|
|
6824
6892
|
const unsupportedKeywords = [
|
|
@@ -6856,7 +6924,7 @@ ${fileList}${readOnlyNote}`
|
|
|
6856
6924
|
return processObject(schema);
|
|
6857
6925
|
}
|
|
6858
6926
|
fixInputSchema(provider, inputSchema) {
|
|
6859
|
-
if (provider === "gemini"
|
|
6927
|
+
if (provider === "gemini") {
|
|
6860
6928
|
const fixedSchema = JSON.parse(JSON.stringify(inputSchema));
|
|
6861
6929
|
const strippedSchema = this.stripUnsupportedSchemaKeywords(fixedSchema);
|
|
6862
6930
|
if (strippedSchema.properties) {
|
|
@@ -6897,45 +6965,14 @@ ${fileList}${readOnlyNote}`
|
|
|
6897
6965
|
}
|
|
6898
6966
|
return inputSchema;
|
|
6899
6967
|
}
|
|
6900
|
-
async runAgent(task, profile, prompt, mode = "agent", promptContext, initialContextMessages, initialContextFiles, systemPrompt, includeInContext = true, abortSignal, images) {
|
|
6968
|
+
async runAgent(task, profile, prompt, mode = "agent", promptContext, initialContextMessages, initialContextFiles, systemPrompt, includeInContext = true, abortSignal, images, skillsToActivate) {
|
|
6901
6969
|
let contextMessages = initialContextMessages ?? await task.getContextMessages();
|
|
6902
6970
|
let contextFiles = initialContextFiles ?? await task.getContextFiles();
|
|
6903
6971
|
if (!systemPrompt) {
|
|
6904
6972
|
systemPrompt = await this.promptsManager.getSystemPrompt(this.store.getSettings(), task, profile);
|
|
6905
6973
|
}
|
|
6906
|
-
const userRequestMessage = prompt ? {
|
|
6907
|
-
id: promptContext?.id || uuid.v4(),
|
|
6908
|
-
role: "user",
|
|
6909
|
-
content: images && images.length > 0 ? [
|
|
6910
|
-
{ type: "text", text: prompt },
|
|
6911
|
-
...images.map((dataUrl) => {
|
|
6912
|
-
const match = dataUrl.match(/^data:(image\/[^;]+);base64,(.+)$/);
|
|
6913
|
-
return {
|
|
6914
|
-
type: "image",
|
|
6915
|
-
image: match ? match[2] : dataUrl,
|
|
6916
|
-
mediaType: match ? match[1] : void 0
|
|
6917
|
-
};
|
|
6918
|
-
})
|
|
6919
|
-
] : prompt,
|
|
6920
|
-
promptContext,
|
|
6921
|
-
timestamp: Date.now()
|
|
6922
|
-
} : null;
|
|
6923
|
-
if (userRequestMessage) {
|
|
6924
|
-
logger.info("User request message created:", {
|
|
6925
|
-
id: userRequestMessage.id,
|
|
6926
|
-
contentType: typeof userRequestMessage.content === "string" ? "string" : "parts",
|
|
6927
|
-
...typeof userRequestMessage.content === "string" ? { contentPreview: userRequestMessage.content.substring(0, 200) } : {
|
|
6928
|
-
parts: userRequestMessage.content.map((part) => ({
|
|
6929
|
-
type: part.type,
|
|
6930
|
-
...part.type === "text" ? { textPreview: part.text?.substring(0, 100) } : {},
|
|
6931
|
-
...part.type === "image" ? { mediaType: part.mediaType, imagePreview: typeof part.image === "string" ? part.image.substring(0, 80) : typeof part.image } : {}
|
|
6932
|
-
}))
|
|
6933
|
-
}
|
|
6934
|
-
});
|
|
6935
|
-
}
|
|
6936
6974
|
const settings = this.store.getSettings();
|
|
6937
6975
|
const projectProfiles = this.agentProfileManager.getProjectProfiles(task.project);
|
|
6938
|
-
let resultMessages = userRequestMessage ? [userRequestMessage] : [];
|
|
6939
6976
|
const providers = this.modelManager.getProviders();
|
|
6940
6977
|
let provider = providers.find((p) => p.id === profile.provider);
|
|
6941
6978
|
let modelName = profile.model;
|
|
@@ -6951,7 +6988,9 @@ ${fileList}${readOnlyNote}`
|
|
|
6951
6988
|
promptContext,
|
|
6952
6989
|
contextMessages,
|
|
6953
6990
|
contextFiles,
|
|
6954
|
-
systemPrompt
|
|
6991
|
+
systemPrompt,
|
|
6992
|
+
images,
|
|
6993
|
+
skillsToActivate
|
|
6955
6994
|
},
|
|
6956
6995
|
task.project,
|
|
6957
6996
|
task
|
|
@@ -6968,10 +7007,56 @@ ${fileList}${readOnlyNote}`
|
|
|
6968
7007
|
contextMessages = extensionResult.contextMessages;
|
|
6969
7008
|
contextFiles = extensionResult.contextFiles;
|
|
6970
7009
|
systemPrompt = extensionResult.systemPrompt;
|
|
7010
|
+
images = extensionResult.images ?? images;
|
|
7011
|
+
skillsToActivate = extensionResult.skillsToActivate;
|
|
7012
|
+
}
|
|
7013
|
+
const userRequestMessage = prompt ? {
|
|
7014
|
+
id: promptContext?.id || uuid.v4(),
|
|
7015
|
+
role: "user",
|
|
7016
|
+
content: images && images.length > 0 ? [
|
|
7017
|
+
{ type: "text", text: prompt },
|
|
7018
|
+
...images.map((dataUrl) => {
|
|
7019
|
+
const match = dataUrl.match(/^data:(image\/[^;]+);base64,(.+)$/);
|
|
7020
|
+
return {
|
|
7021
|
+
type: "image",
|
|
7022
|
+
image: match ? match[2] : dataUrl,
|
|
7023
|
+
mediaType: match ? match[1] : void 0
|
|
7024
|
+
};
|
|
7025
|
+
})
|
|
7026
|
+
] : prompt,
|
|
7027
|
+
promptContext,
|
|
7028
|
+
timestamp: Date.now()
|
|
7029
|
+
} : null;
|
|
7030
|
+
if (userRequestMessage) {
|
|
7031
|
+
logger.info("User request message created:", {
|
|
7032
|
+
id: userRequestMessage.id,
|
|
7033
|
+
contentType: typeof userRequestMessage.content === "string" ? "string" : "parts",
|
|
7034
|
+
...typeof userRequestMessage.content === "string" ? { contentPreview: userRequestMessage.content.substring(0, 200) } : {
|
|
7035
|
+
parts: userRequestMessage.content.map((part) => ({
|
|
7036
|
+
type: part.type,
|
|
7037
|
+
...part.type === "text" ? { textPreview: part.text?.substring(0, 100) } : {},
|
|
7038
|
+
...part.type === "image" ? { mediaType: part.mediaType, imagePreview: typeof part.image === "string" ? part.image.substring(0, 80) : typeof part.image } : {}
|
|
7039
|
+
}))
|
|
7040
|
+
}
|
|
7041
|
+
});
|
|
6971
7042
|
}
|
|
7043
|
+
let resultMessages = userRequestMessage ? [userRequestMessage] : [];
|
|
6972
7044
|
if (userRequestMessage && includeInContext) {
|
|
6973
7045
|
await task.addContextMessage(userRequestMessage);
|
|
6974
7046
|
}
|
|
7047
|
+
if (skillsToActivate && skillsToActivate.length > 0) {
|
|
7048
|
+
try {
|
|
7049
|
+
const skillMessages = await task.createSkillMessages(...skillsToActivate);
|
|
7050
|
+
if (skillMessages) {
|
|
7051
|
+
for (const message of skillMessages) {
|
|
7052
|
+
await task.addContextMessage(message);
|
|
7053
|
+
resultMessages.push(message);
|
|
7054
|
+
}
|
|
7055
|
+
}
|
|
7056
|
+
} catch (error) {
|
|
7057
|
+
logger.warn(`Failed to activate skills: ${error instanceof Error ? error.message : String(error)}`);
|
|
7058
|
+
}
|
|
7059
|
+
}
|
|
6975
7060
|
if (!provider) {
|
|
6976
7061
|
logger.error(`Provider ${profile.provider} not found`);
|
|
6977
7062
|
task.addLogMessage("error", "Selected model is not configured. Select another model and try again.", true, promptContext);
|
|
@@ -7945,6 +8030,7 @@ ${fileList}${readOnlyNote}`
|
|
|
7945
8030
|
if (!abortSignal?.aborted) {
|
|
7946
8031
|
task.addLogMessage("loading", void 0, false, promptContext);
|
|
7947
8032
|
}
|
|
8033
|
+
const lastToolMessage = response.messages.findLast((m) => m.role === "tool");
|
|
7948
8034
|
response.messages.forEach((message) => {
|
|
7949
8035
|
if (message.role === "assistant") {
|
|
7950
8036
|
messages.push({
|
|
@@ -7960,6 +8046,7 @@ ${fileList}${readOnlyNote}`
|
|
|
7960
8046
|
// @ts-expect-error the id is there
|
|
7961
8047
|
id: message.id || uuid.v4(),
|
|
7962
8048
|
promptContext,
|
|
8049
|
+
usageReport: !hasAssistantMessage && message === lastToolMessage ? usageReport : void 0,
|
|
7963
8050
|
timestamp: Date.now()
|
|
7964
8051
|
});
|
|
7965
8052
|
}
|
|
@@ -7989,8 +8076,8 @@ ${fileList}${readOnlyNote}`
|
|
|
7989
8076
|
taskTokensOverride,
|
|
7990
8077
|
contextCompactionType
|
|
7991
8078
|
});
|
|
7992
|
-
const
|
|
7993
|
-
const usageReport =
|
|
8079
|
+
const lastUsageReportMessage = [...resultMessages].reverse().find((m) => (m.role === "assistant" || m.role === "tool") && m.usageReport);
|
|
8080
|
+
const usageReport = lastUsageReportMessage?.usageReport;
|
|
7994
8081
|
const maxTokens = this.modelManager.getModelSettings(provider.id, model)?.maxInputTokens;
|
|
7995
8082
|
if (!usageReport || !maxTokens) {
|
|
7996
8083
|
logger.debug("No usageReport or maxTokens", {
|
|
@@ -8941,16 +9028,20 @@ const RunPromptSchema = zod.z.object({
|
|
|
8941
9028
|
mode: zod.z.string().optional(),
|
|
8942
9029
|
images: zod.z.array(zod.z.string()).optional(),
|
|
8943
9030
|
model: zod.z.string().optional(),
|
|
8944
|
-
agentProfileId: zod.z.string().optional()
|
|
9031
|
+
agentProfileId: zod.z.string().optional(),
|
|
9032
|
+
autonomyMode: zod.z.nativeEnum(AutonomyMode).optional()
|
|
8945
9033
|
});
|
|
8946
|
-
const
|
|
8947
|
-
if (!model && !agentProfileId) {
|
|
9034
|
+
const parseTaskParams = (model, agentProfileId, autonomyMode) => {
|
|
9035
|
+
if (!model && !agentProfileId && !autonomyMode) {
|
|
8948
9036
|
return void 0;
|
|
8949
9037
|
}
|
|
8950
9038
|
const params = {};
|
|
8951
9039
|
if (agentProfileId) {
|
|
8952
9040
|
params.agentProfileId = agentProfileId;
|
|
8953
9041
|
}
|
|
9042
|
+
if (autonomyMode) {
|
|
9043
|
+
params.autonomyMode = autonomyMode;
|
|
9044
|
+
}
|
|
8954
9045
|
if (model) {
|
|
8955
9046
|
const slashIndex = model.indexOf("/");
|
|
8956
9047
|
if (slashIndex > 0) {
|
|
@@ -8996,12 +9087,12 @@ class PromptApi extends BaseApi {
|
|
|
8996
9087
|
res.status(400).json({ error: parsed.error.flatten() });
|
|
8997
9088
|
return;
|
|
8998
9089
|
}
|
|
8999
|
-
const { projectDir, taskId, prompt, mode, images, model, agentProfileId } = parsed.data;
|
|
9090
|
+
const { projectDir, taskId, prompt, mode, images, model, agentProfileId, autonomyMode } = parsed.data;
|
|
9000
9091
|
const isSSE = acceptsSSE && !acceptsJSON;
|
|
9001
9092
|
if (isSSE) {
|
|
9002
|
-
void this.handleRunPromptSSE(res, projectDir, prompt, taskId, mode, images, model, agentProfileId);
|
|
9093
|
+
void this.handleRunPromptSSE(res, projectDir, prompt, taskId, mode, images, model, agentProfileId, autonomyMode);
|
|
9003
9094
|
} else {
|
|
9004
|
-
void this.handleRunPromptJSON(res, projectDir, prompt, taskId, mode, images, model, agentProfileId);
|
|
9095
|
+
void this.handleRunPromptJSON(res, projectDir, prompt, taskId, mode, images, model, agentProfileId, autonomyMode);
|
|
9005
9096
|
}
|
|
9006
9097
|
});
|
|
9007
9098
|
router.post(
|
|
@@ -9017,22 +9108,22 @@ class PromptApi extends BaseApi {
|
|
|
9017
9108
|
})
|
|
9018
9109
|
);
|
|
9019
9110
|
}
|
|
9020
|
-
async handleRunPromptJSON(res, projectDir, prompt, taskId, mode, images, model, agentProfileId) {
|
|
9111
|
+
async handleRunPromptJSON(res, projectDir, prompt, taskId, mode, images, model, agentProfileId, autonomyMode) {
|
|
9021
9112
|
if (taskId) {
|
|
9022
9113
|
const responses = await this.eventsHandler.runPrompt(projectDir, taskId, prompt, mode, images);
|
|
9023
9114
|
res.status(200).json(responses);
|
|
9024
9115
|
} else {
|
|
9025
|
-
const taskParams =
|
|
9116
|
+
const taskParams = parseTaskParams(model, agentProfileId, autonomyMode);
|
|
9026
9117
|
const result = await this.eventsHandler.ensureProjectAndCreateTask(projectDir, taskParams);
|
|
9027
9118
|
const responses = await this.eventsHandler.runPrompt(result.projectDir, result.taskId, prompt, mode, images);
|
|
9028
9119
|
res.setHeader("X-Task-Id", result.taskId);
|
|
9029
9120
|
res.status(200).json(responses);
|
|
9030
9121
|
}
|
|
9031
9122
|
}
|
|
9032
|
-
async handleRunPromptSSE(res, projectDir, prompt, taskId, mode, images, model, agentProfileId) {
|
|
9123
|
+
async handleRunPromptSSE(res, projectDir, prompt, taskId, mode, images, model, agentProfileId, autonomyMode) {
|
|
9033
9124
|
let resolvedTaskId = taskId;
|
|
9034
9125
|
if (!resolvedTaskId) {
|
|
9035
|
-
const taskParams =
|
|
9126
|
+
const taskParams = parseTaskParams(model, agentProfileId, autonomyMode);
|
|
9036
9127
|
const result = await this.eventsHandler.ensureProjectAndCreateTask(projectDir, taskParams);
|
|
9037
9128
|
resolvedTaskId = result.taskId;
|
|
9038
9129
|
}
|
|
@@ -11055,11 +11146,11 @@ class ExtensionsApi extends BaseApi {
|
|
|
11055
11146
|
return;
|
|
11056
11147
|
}
|
|
11057
11148
|
const { extensionId, repositoryUrl, projectDir } = parsed;
|
|
11058
|
-
const
|
|
11059
|
-
if (success) {
|
|
11060
|
-
res.status(200).json({ message: "Extension installed successfully", success });
|
|
11149
|
+
const result = await this.eventsHandler.installExtension(extensionId, repositoryUrl, projectDir);
|
|
11150
|
+
if (result.success) {
|
|
11151
|
+
res.status(200).json({ message: "Extension installed successfully", success: true });
|
|
11061
11152
|
} else {
|
|
11062
|
-
res.status(500).json({ message: "Failed to install extension", success });
|
|
11153
|
+
res.status(500).json({ message: "Failed to install extension", success: false, error: result.error });
|
|
11063
11154
|
}
|
|
11064
11155
|
})
|
|
11065
11156
|
);
|
|
@@ -11087,11 +11178,11 @@ class ExtensionsApi extends BaseApi {
|
|
|
11087
11178
|
return;
|
|
11088
11179
|
}
|
|
11089
11180
|
const { extensionId, repositoryUrl, projectDir } = parsed;
|
|
11090
|
-
const
|
|
11091
|
-
if (success) {
|
|
11092
|
-
res.status(200).json({ message: "Extension updated successfully", success });
|
|
11181
|
+
const result = await this.eventsHandler.updateExtension(extensionId, repositoryUrl, projectDir);
|
|
11182
|
+
if (result.success) {
|
|
11183
|
+
res.status(200).json({ message: "Extension updated successfully", success: true });
|
|
11093
11184
|
} else {
|
|
11094
|
-
res.status(500).json({ message: "Failed to update extension", success });
|
|
11185
|
+
res.status(500).json({ message: "Failed to update extension", success: false, error: result.error });
|
|
11095
11186
|
}
|
|
11096
11187
|
})
|
|
11097
11188
|
);
|
|
@@ -13357,7 +13448,8 @@ const PROXY_ENV_VAR_NAMES = ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "http_pro
|
|
|
13357
13448
|
const getProxyEnvVars = (settings) => {
|
|
13358
13449
|
if (settings.proxy?.enabled && settings.proxy?.url) {
|
|
13359
13450
|
const url = settings.proxy.url;
|
|
13360
|
-
|
|
13451
|
+
const noProxy = settings.proxy.noProxy;
|
|
13452
|
+
const vars = {
|
|
13361
13453
|
HTTP_PROXY: url,
|
|
13362
13454
|
HTTPS_PROXY: url,
|
|
13363
13455
|
ALL_PROXY: url,
|
|
@@ -13365,6 +13457,11 @@ const getProxyEnvVars = (settings) => {
|
|
|
13365
13457
|
https_proxy: url,
|
|
13366
13458
|
all_proxy: url
|
|
13367
13459
|
};
|
|
13460
|
+
if (noProxy) {
|
|
13461
|
+
vars.NO_PROXY = noProxy;
|
|
13462
|
+
vars.no_proxy = noProxy;
|
|
13463
|
+
}
|
|
13464
|
+
return vars;
|
|
13368
13465
|
}
|
|
13369
13466
|
return Object.fromEntries(PROXY_ENV_VAR_NAMES.map((key) => [key, ""]));
|
|
13370
13467
|
};
|
|
@@ -13376,7 +13473,7 @@ class ProxyManager {
|
|
|
13376
13473
|
init(settings) {
|
|
13377
13474
|
globalAgent.bootstrap();
|
|
13378
13475
|
if (settings.proxy?.enabled && settings.proxy?.url) {
|
|
13379
|
-
this.applyProxy(settings.proxy.url);
|
|
13476
|
+
this.applyProxy(settings.proxy.url, settings.proxy.noProxy);
|
|
13380
13477
|
} else {
|
|
13381
13478
|
this.clearProxy();
|
|
13382
13479
|
}
|
|
@@ -13388,20 +13485,25 @@ class ProxyManager {
|
|
|
13388
13485
|
settingsChanged(oldSettings, newSettings) {
|
|
13389
13486
|
const oldProxy = oldSettings.proxy;
|
|
13390
13487
|
const newProxy = newSettings.proxy;
|
|
13391
|
-
if (oldProxy?.enabled !== newProxy?.enabled || oldProxy?.url !== newProxy?.url) {
|
|
13488
|
+
if (oldProxy?.enabled !== newProxy?.enabled || oldProxy?.url !== newProxy?.url || oldProxy?.noProxy !== newProxy?.noProxy) {
|
|
13392
13489
|
if (newProxy?.enabled && newProxy?.url) {
|
|
13393
13490
|
logger.info(`[ProxyManager] Applying proxy: ${newProxy.url}`);
|
|
13394
|
-
this.applyProxy(newProxy.url);
|
|
13491
|
+
this.applyProxy(newProxy.url, newProxy.noProxy);
|
|
13395
13492
|
} else if (this.currentUrl !== null) {
|
|
13396
13493
|
logger.info("[ProxyManager] Clearing proxy");
|
|
13397
13494
|
this.clearProxy();
|
|
13398
13495
|
}
|
|
13399
13496
|
}
|
|
13400
13497
|
}
|
|
13401
|
-
applyProxy(url) {
|
|
13498
|
+
applyProxy(url, noProxy) {
|
|
13402
13499
|
try {
|
|
13403
13500
|
global.GLOBAL_AGENT.HTTP_PROXY = url;
|
|
13404
|
-
|
|
13501
|
+
global.GLOBAL_AGENT.NO_PROXY = noProxy || void 0;
|
|
13502
|
+
const proxyAgent = new undici.EnvHttpProxyAgent({
|
|
13503
|
+
httpProxy: url,
|
|
13504
|
+
httpsProxy: url,
|
|
13505
|
+
noProxy: noProxy || void 0
|
|
13506
|
+
});
|
|
13405
13507
|
undici.setGlobalDispatcher(proxyAgent);
|
|
13406
13508
|
this.currentUrl = url;
|
|
13407
13509
|
logger.info(`[ProxyManager] Proxy initialized: ${url}`);
|
|
@@ -13412,6 +13514,7 @@ class ProxyManager {
|
|
|
13412
13514
|
clearProxy() {
|
|
13413
13515
|
try {
|
|
13414
13516
|
global.GLOBAL_AGENT.HTTP_PROXY = void 0;
|
|
13517
|
+
global.GLOBAL_AGENT.NO_PROXY = void 0;
|
|
13415
13518
|
undici.setGlobalDispatcher(
|
|
13416
13519
|
new undici.Agent({
|
|
13417
13520
|
headersTimeout: 30 * 60 * 1e3,
|
|
@@ -14380,6 +14483,60 @@ class WorktreeManager {
|
|
|
14380
14483
|
return void 0;
|
|
14381
14484
|
}
|
|
14382
14485
|
}
|
|
14486
|
+
/**
|
|
14487
|
+
* Check if a commit is an ancestor of another commit (or HEAD).
|
|
14488
|
+
* Returns true if `ancestorCommit` is reachable from `descendantRef`.
|
|
14489
|
+
*/
|
|
14490
|
+
async isCommitAncestorOf(worktreePath, ancestorCommit, descendantRef = "HEAD") {
|
|
14491
|
+
try {
|
|
14492
|
+
await execWithShellPath(`git merge-base --is-ancestor ${ancestorCommit} ${descendantRef}`, { cwd: worktreePath });
|
|
14493
|
+
return true;
|
|
14494
|
+
} catch {
|
|
14495
|
+
return false;
|
|
14496
|
+
}
|
|
14497
|
+
}
|
|
14498
|
+
/**
|
|
14499
|
+
* Get the "onto" commit from an active rebase.
|
|
14500
|
+
* Returns undefined if no rebase is in progress or the file doesn't exist.
|
|
14501
|
+
*/
|
|
14502
|
+
async getRebaseOntoCommit(worktreePath) {
|
|
14503
|
+
try {
|
|
14504
|
+
const { stdout: rebaseMergePath } = await execWithShellPath("git rev-parse --git-path rebase-merge", { cwd: worktreePath });
|
|
14505
|
+
const ontoPath = `${rebaseMergePath.trim()}/onto`;
|
|
14506
|
+
try {
|
|
14507
|
+
const { stdout: ontoCommit } = await execWithShellPath(`cat "${ontoPath}"`, { cwd: worktreePath });
|
|
14508
|
+
if (ontoCommit.trim()) {
|
|
14509
|
+
return ontoCommit.trim();
|
|
14510
|
+
}
|
|
14511
|
+
} catch {
|
|
14512
|
+
}
|
|
14513
|
+
const { stdout: rebaseApplyPath } = await execWithShellPath("git rev-parse --git-path rebase-apply", { cwd: worktreePath });
|
|
14514
|
+
const ontoApplyPath = `${rebaseApplyPath.trim()}/onto`;
|
|
14515
|
+
try {
|
|
14516
|
+
const { stdout: ontoCommit } = await execWithShellPath(`cat "${ontoApplyPath}"`, { cwd: worktreePath });
|
|
14517
|
+
if (ontoCommit.trim()) {
|
|
14518
|
+
return ontoCommit.trim();
|
|
14519
|
+
}
|
|
14520
|
+
} catch {
|
|
14521
|
+
}
|
|
14522
|
+
return void 0;
|
|
14523
|
+
} catch {
|
|
14524
|
+
return void 0;
|
|
14525
|
+
}
|
|
14526
|
+
}
|
|
14527
|
+
/**
|
|
14528
|
+
* Resolve a commit to the branch name that points to it.
|
|
14529
|
+
* Returns the first branch found, or undefined if no branch points to that exact commit.
|
|
14530
|
+
*/
|
|
14531
|
+
async getBranchPointingAtCommit(projectPath, commit) {
|
|
14532
|
+
try {
|
|
14533
|
+
const { stdout } = await execWithShellPath(`git branch --points-at ${commit} --format='%(refname:short)'`, { cwd: projectPath });
|
|
14534
|
+
const branches = stdout.trim().split("\n").map((b) => b.trim()).filter((b) => b && !b.includes("(") && !b.includes("HEAD"));
|
|
14535
|
+
return branches.length > 0 ? branches[0] : void 0;
|
|
14536
|
+
} catch {
|
|
14537
|
+
return void 0;
|
|
14538
|
+
}
|
|
14539
|
+
}
|
|
14383
14540
|
async getBranchesContainingCommit(projectPath, commit) {
|
|
14384
14541
|
try {
|
|
14385
14542
|
const { stdout } = await execWithShellPath(`git branch --contains ${commit} --format='%(refname:short)'`, { cwd: projectPath });
|
|
@@ -14469,7 +14626,7 @@ class WorktreeManager {
|
|
|
14469
14626
|
};
|
|
14470
14627
|
}
|
|
14471
14628
|
}
|
|
14472
|
-
async rebaseMainIntoWorktree(worktreePath, mainBranch, baseCommit) {
|
|
14629
|
+
async rebaseMainIntoWorktree(worktreePath, mainBranch, baseCommit, symlinkFolders = []) {
|
|
14473
14630
|
return await withLock(`git-rebase-${worktreePath}`, async () => {
|
|
14474
14631
|
const executedCommands = [];
|
|
14475
14632
|
let lastOutput = "";
|
|
@@ -14481,6 +14638,16 @@ class WorktreeManager {
|
|
|
14481
14638
|
const addCommand = "git add -A";
|
|
14482
14639
|
executedCommands.push(`${addCommand} (in ${worktreePath})`);
|
|
14483
14640
|
await execWithShellPath(addCommand, { cwd: worktreePath });
|
|
14641
|
+
if (symlinkFolders.length > 0) {
|
|
14642
|
+
const resetPaths = symlinkFolders.map((f) => `"${f}"`).join(" ");
|
|
14643
|
+
const resetCommand = `git reset HEAD -- ${resetPaths}`;
|
|
14644
|
+
executedCommands.push(`${resetCommand} (in ${worktreePath})`);
|
|
14645
|
+
try {
|
|
14646
|
+
await execWithShellPath(resetCommand, { cwd: worktreePath });
|
|
14647
|
+
} catch {
|
|
14648
|
+
logger.debug("Some symlink folders could not be unstaged (may not be in index)");
|
|
14649
|
+
}
|
|
14650
|
+
}
|
|
14484
14651
|
const commitCommand = `git commit --no-verify -m "TEMP_UNCOMMITTED_${Date.now()}"`;
|
|
14485
14652
|
executedCommands.push(`${commitCommand} (in ${worktreePath})`);
|
|
14486
14653
|
await execWithShellPath(commitCommand, {
|
|
@@ -14488,7 +14655,15 @@ class WorktreeManager {
|
|
|
14488
14655
|
});
|
|
14489
14656
|
logger.info("Created temporary commit for uncommitted changes");
|
|
14490
14657
|
}
|
|
14491
|
-
|
|
14658
|
+
let effectiveBaseCommit = baseCommit;
|
|
14659
|
+
if (baseCommit) {
|
|
14660
|
+
const isValid = await this.isCommitAncestorOf(worktreePath, baseCommit);
|
|
14661
|
+
if (!isValid) {
|
|
14662
|
+
logger.warn(`baseCommit ${baseCommit} is not an ancestor of HEAD, falling back to simple rebase`, { worktreePath, mainBranch });
|
|
14663
|
+
effectiveBaseCommit = void 0;
|
|
14664
|
+
}
|
|
14665
|
+
}
|
|
14666
|
+
const command = effectiveBaseCommit ? `git rebase --onto ${mainBranch} ${effectiveBaseCommit}` : `git rebase ${mainBranch}`;
|
|
14492
14667
|
executedCommands.push(`${command} (in ${worktreePath})`);
|
|
14493
14668
|
const rebaseResult = await execWithShellPath(command, {
|
|
14494
14669
|
cwd: worktreePath
|
|
@@ -14541,6 +14716,11 @@ class WorktreeManager {
|
|
|
14541
14716
|
return await withLock(`git-rebase-continue-${worktreePath}`, async () => {
|
|
14542
14717
|
const executedCommands = [];
|
|
14543
14718
|
let lastOutput = "";
|
|
14719
|
+
const ontoCommit = await this.getRebaseOntoCommit(worktreePath);
|
|
14720
|
+
let ontoBranch;
|
|
14721
|
+
if (ontoCommit) {
|
|
14722
|
+
ontoBranch = await this.getBranchPointingAtCommit(worktreePath, ontoCommit);
|
|
14723
|
+
}
|
|
14544
14724
|
try {
|
|
14545
14725
|
const command = "git rebase --continue";
|
|
14546
14726
|
executedCommands.push(`${command} (in ${worktreePath})`);
|
|
@@ -14551,6 +14731,7 @@ class WorktreeManager {
|
|
|
14551
14731
|
lastOutput = result.stdout || result.stderr || "";
|
|
14552
14732
|
await this.resetTempCommitIfExists(worktreePath);
|
|
14553
14733
|
logger.info("Successfully handled temporary commit after continue rebase");
|
|
14734
|
+
return { ontoCommit, ontoBranch };
|
|
14554
14735
|
} catch (error) {
|
|
14555
14736
|
const err = error;
|
|
14556
14737
|
logger.error(`Failed to continue rebase in ${worktreePath}:`, err);
|
|
@@ -14579,7 +14760,15 @@ class WorktreeManager {
|
|
|
14579
14760
|
if (!commits.trim()) {
|
|
14580
14761
|
return;
|
|
14581
14762
|
}
|
|
14582
|
-
|
|
14763
|
+
let effectiveBaseCommit = baseCommit;
|
|
14764
|
+
if (baseCommit) {
|
|
14765
|
+
const isValid = await this.isCommitAncestorOf(worktreePath, baseCommit);
|
|
14766
|
+
if (!isValid) {
|
|
14767
|
+
logger.warn(`baseCommit ${baseCommit} is not an ancestor of HEAD, falling back to simple rebase`, { worktreePath, mainBranch });
|
|
14768
|
+
effectiveBaseCommit = void 0;
|
|
14769
|
+
}
|
|
14770
|
+
}
|
|
14771
|
+
command = effectiveBaseCommit ? `git rebase --onto ${mainBranch} ${effectiveBaseCommit}` : `git rebase ${mainBranch}`;
|
|
14583
14772
|
executedCommands.push(`${command} (in ${worktreePath})`);
|
|
14584
14773
|
try {
|
|
14585
14774
|
const rebaseWorktreeResult = await execWithShellPath(command, {
|
|
@@ -15213,6 +15402,9 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15213
15402
|
if (!stats) {
|
|
15214
15403
|
continue;
|
|
15215
15404
|
}
|
|
15405
|
+
if (this.isSymlinkPath(worktreePath, filePath)) {
|
|
15406
|
+
continue;
|
|
15407
|
+
}
|
|
15216
15408
|
const absoluteFilePath = path.join(worktreePath, filePath);
|
|
15217
15409
|
let finalDiff = diff;
|
|
15218
15410
|
try {
|
|
@@ -15259,6 +15451,9 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15259
15451
|
if (!filePath) {
|
|
15260
15452
|
continue;
|
|
15261
15453
|
}
|
|
15454
|
+
if (this.isSymlinkPath(worktreePath, filePath)) {
|
|
15455
|
+
continue;
|
|
15456
|
+
}
|
|
15262
15457
|
const absoluteFilePath = path.join(worktreePath, filePath);
|
|
15263
15458
|
let diff = "";
|
|
15264
15459
|
try {
|
|
@@ -15309,6 +15504,9 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15309
15504
|
if (!filePath) {
|
|
15310
15505
|
continue;
|
|
15311
15506
|
}
|
|
15507
|
+
if (this.isSymlinkPath(worktreePath, filePath)) {
|
|
15508
|
+
continue;
|
|
15509
|
+
}
|
|
15312
15510
|
const absoluteFilePath = path.join(worktreePath, filePath);
|
|
15313
15511
|
let diff = "";
|
|
15314
15512
|
try {
|
|
@@ -15360,6 +15558,9 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15360
15558
|
if (!filePath) {
|
|
15361
15559
|
continue;
|
|
15362
15560
|
}
|
|
15561
|
+
if (this.isSymlinkPath(worktreePath, filePath)) {
|
|
15562
|
+
continue;
|
|
15563
|
+
}
|
|
15363
15564
|
const absoluteFilePath = path.join(worktreePath, filePath);
|
|
15364
15565
|
let diff = "";
|
|
15365
15566
|
try {
|
|
@@ -15578,7 +15779,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15578
15779
|
*/
|
|
15579
15780
|
async resetTempCommit(worktreePath) {
|
|
15580
15781
|
try {
|
|
15581
|
-
await execWithShellPath("git reset --
|
|
15782
|
+
await execWithShellPath("git reset --soft HEAD^", { cwd: worktreePath });
|
|
15582
15783
|
} catch (error) {
|
|
15583
15784
|
logger.error("Failed to reset temp commit:", error);
|
|
15584
15785
|
throw new Error(`Failed to restore uncommitted changes: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -15740,20 +15941,125 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15740
15941
|
}
|
|
15741
15942
|
}
|
|
15742
15943
|
}
|
|
15743
|
-
async
|
|
15744
|
-
logger.info("
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
}
|
|
15754
|
-
const
|
|
15755
|
-
|
|
15756
|
-
|
|
15944
|
+
async mergeWorktreeToWorktree(sourceWorktreeDir, targetWorktreeDir, includeUncommitted = false) {
|
|
15945
|
+
logger.info("Merging worktree to worktree", {
|
|
15946
|
+
sourceWorktreeDir,
|
|
15947
|
+
targetWorktreeDir,
|
|
15948
|
+
includeUncommitted
|
|
15949
|
+
});
|
|
15950
|
+
if (sourceWorktreeDir === targetWorktreeDir) {
|
|
15951
|
+
logger.warn("Source and target worktree directories are the same, skipping merge");
|
|
15952
|
+
return;
|
|
15953
|
+
}
|
|
15954
|
+
const { stdout: sourceHead } = await execWithShellPath("git rev-parse HEAD", { cwd: sourceWorktreeDir });
|
|
15955
|
+
const { stdout: targetHead } = await execWithShellPath("git rev-parse HEAD", { cwd: targetWorktreeDir });
|
|
15956
|
+
const sourceCommit = sourceHead.trim();
|
|
15957
|
+
const targetCommit = targetHead.trim();
|
|
15958
|
+
if (sourceCommit === targetCommit) {
|
|
15959
|
+
logger.info("Source and target worktrees are at the same commit, skipping commit merge");
|
|
15960
|
+
} else {
|
|
15961
|
+
const { stdout: mergeBase } = await execWithShellPath(`git merge-base ${sourceCommit} ${targetCommit}`, {
|
|
15962
|
+
cwd: targetWorktreeDir
|
|
15963
|
+
});
|
|
15964
|
+
const baseCommit = mergeBase.trim();
|
|
15965
|
+
if (baseCommit === sourceCommit) {
|
|
15966
|
+
logger.info("Source worktree has no commits ahead of target, skipping commit merge");
|
|
15967
|
+
} else if (baseCommit === targetCommit) {
|
|
15968
|
+
logger.info("Target worktree is at merge base, fast-forwarding to source HEAD");
|
|
15969
|
+
try {
|
|
15970
|
+
await execWithShellPath(`git merge --ff-only ${sourceCommit}`, { cwd: targetWorktreeDir });
|
|
15971
|
+
logger.info("Successfully fast-forwarded target worktree to source HEAD");
|
|
15972
|
+
} catch (error) {
|
|
15973
|
+
logger.error("Failed to fast-forward target worktree:", { error });
|
|
15974
|
+
throw new Error(`Failed to fast-forward target worktree to source HEAD. Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
15975
|
+
}
|
|
15976
|
+
} else {
|
|
15977
|
+
logger.info("Worktrees have diverged, cherry-picking source commits onto target");
|
|
15978
|
+
const { stdout: commits } = await execWithShellPath(`git log --reverse --format=%H ${baseCommit}..${sourceCommit}`, {
|
|
15979
|
+
cwd: sourceWorktreeDir
|
|
15980
|
+
});
|
|
15981
|
+
const commitList = commits.trim().split("\n").filter(Boolean);
|
|
15982
|
+
if (commitList.length === 0) {
|
|
15983
|
+
logger.info("No commits to cherry-pick");
|
|
15984
|
+
} else {
|
|
15985
|
+
for (const commitHash of commitList) {
|
|
15986
|
+
try {
|
|
15987
|
+
await execWithShellPath(`git cherry-pick ${commitHash}`, { cwd: targetWorktreeDir });
|
|
15988
|
+
logger.debug(`Cherry-picked commit ${commitHash.substring(0, 8)}`);
|
|
15989
|
+
} catch (error) {
|
|
15990
|
+
try {
|
|
15991
|
+
await execWithShellPath("git cherry-pick --abort", { cwd: targetWorktreeDir });
|
|
15992
|
+
} catch {
|
|
15993
|
+
}
|
|
15994
|
+
throw new Error(
|
|
15995
|
+
`Failed to cherry-pick commit ${commitHash.substring(0, 8)} onto target worktree. Cherry-pick aborted. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
15996
|
+
);
|
|
15997
|
+
}
|
|
15998
|
+
}
|
|
15999
|
+
logger.info(`Successfully cherry-picked ${commitList.length} commit(s) onto target worktree`);
|
|
16000
|
+
}
|
|
16001
|
+
}
|
|
16002
|
+
}
|
|
16003
|
+
if (includeUncommitted) {
|
|
16004
|
+
const hasChanges = await this.hasUncommittedChanges(sourceWorktreeDir);
|
|
16005
|
+
if (!hasChanges) {
|
|
16006
|
+
logger.info("No uncommitted changes in source worktree, skipping uncommitted merge");
|
|
16007
|
+
return;
|
|
16008
|
+
}
|
|
16009
|
+
const timestamp = Date.now();
|
|
16010
|
+
const stashId = `worktree-to-worktree-${timestamp}`;
|
|
16011
|
+
try {
|
|
16012
|
+
const stashResult = await this.stashUncommittedChanges(stashId, sourceWorktreeDir, "Uncommitted changes carried over to target worktree");
|
|
16013
|
+
if (!stashResult) {
|
|
16014
|
+
logger.info("No changes to carry over after stash attempt");
|
|
16015
|
+
return;
|
|
16016
|
+
}
|
|
16017
|
+
try {
|
|
16018
|
+
await this.applyStash(targetWorktreeDir, stashId);
|
|
16019
|
+
await this.applyStash(sourceWorktreeDir, stashId);
|
|
16020
|
+
} catch (error) {
|
|
16021
|
+
logger.error("Failed to apply stash to worktrees:", { error });
|
|
16022
|
+
try {
|
|
16023
|
+
await this.applyStash(sourceWorktreeDir, stashId);
|
|
16024
|
+
} catch (restoreError) {
|
|
16025
|
+
logger.error("Failed to restore stash to source worktree:", { error: restoreError, stashId });
|
|
16026
|
+
throw new Error(
|
|
16027
|
+
`Failed to apply stashed changes to target worktree and could not restore them. Stash ID "${stashId}" still exists. Manual recovery required. Original error: ${error instanceof Error ? error.message : String(error)}`
|
|
16028
|
+
);
|
|
16029
|
+
}
|
|
16030
|
+
throw new Error(
|
|
16031
|
+
`Failed to apply stashed changes to target worktree. Changes have been restored to source worktree. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
16032
|
+
);
|
|
16033
|
+
}
|
|
16034
|
+
await this.dropStash(sourceWorktreeDir, stashId);
|
|
16035
|
+
} catch (error) {
|
|
16036
|
+
logger.error("Failed to carry over uncommitted changes:", { error });
|
|
16037
|
+
throw error;
|
|
16038
|
+
}
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
16041
|
+
async close(projectDir) {
|
|
16042
|
+
logger.info("Closing worktree manager");
|
|
16043
|
+
await this.pruneDeleted(projectDir);
|
|
16044
|
+
}
|
|
16045
|
+
}
|
|
16046
|
+
const VERBOSE_COMPACT_WINDOW = 50;
|
|
16047
|
+
const VERBOSE_TOOL_INPUT_THRESHOLD = 150;
|
|
16048
|
+
var CompactionLevel = /* @__PURE__ */ ((CompactionLevel2) => {
|
|
16049
|
+
CompactionLevel2[CompactionLevel2["One"] = 1] = "One";
|
|
16050
|
+
CompactionLevel2[CompactionLevel2["Two"] = 2] = "Two";
|
|
16051
|
+
CompactionLevel2[CompactionLevel2["Three"] = 3] = "Three";
|
|
16052
|
+
CompactionLevel2[CompactionLevel2["Four"] = 4] = "Four";
|
|
16053
|
+
CompactionLevel2[CompactionLevel2["Five"] = 5] = "Five";
|
|
16054
|
+
CompactionLevel2[
|
|
16055
|
+
CompactionLevel2["Max"] = 5
|
|
16056
|
+
/* Five */
|
|
16057
|
+
] = "Max";
|
|
16058
|
+
return CompactionLevel2;
|
|
16059
|
+
})(CompactionLevel || {});
|
|
16060
|
+
const extractFilePath = (args) => {
|
|
16061
|
+
if (typeof args === "object" && args !== null && "filePath" in args) {
|
|
16062
|
+
return args.filePath;
|
|
15757
16063
|
}
|
|
15758
16064
|
return void 0;
|
|
15759
16065
|
};
|
|
@@ -15961,6 +16267,8 @@ const smartCompactMessages = async (messages, protectedMessageCount = 10, compac
|
|
|
15961
16267
|
result = compactBashOutputs(result, protectedMessageCount, compactionLevel);
|
|
15962
16268
|
result = redactFetchOutputs(result, protectedMessageCount);
|
|
15963
16269
|
result = await truncateNonPowerToolResults(result, protectedMessageCount, compactionLevel);
|
|
16270
|
+
result = removeVerboseToolCalls(result, protectedMessageCount, compactionLevel);
|
|
16271
|
+
result = removeReasoningFromAssistant(result, protectedMessageCount, compactionLevel);
|
|
15964
16272
|
result = mergeConsecutiveAssistantMessages(result);
|
|
15965
16273
|
return result;
|
|
15966
16274
|
};
|
|
@@ -16441,6 +16749,64 @@ const compactBashOutputs = (messages, protectedMessageCount = 10, compactionLeve
|
|
|
16441
16749
|
}
|
|
16442
16750
|
return messages;
|
|
16443
16751
|
};
|
|
16752
|
+
const removeVerboseToolCalls = (messages, protectedMessageCount = 10, compactionLevel = 1) => {
|
|
16753
|
+
if (compactionLevel < 4) {
|
|
16754
|
+
return messages;
|
|
16755
|
+
}
|
|
16756
|
+
const protectedStart = getProtectedStartIndex(messages, Math.max(protectedMessageCount, VERBOSE_COMPACT_WINDOW));
|
|
16757
|
+
for (let i = protectedStart - 1; i >= 0; i--) {
|
|
16758
|
+
if (i >= messages.length) {
|
|
16759
|
+
continue;
|
|
16760
|
+
}
|
|
16761
|
+
const msg = messages[i];
|
|
16762
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
16763
|
+
continue;
|
|
16764
|
+
}
|
|
16765
|
+
const toolCallIdsToRemove = [];
|
|
16766
|
+
for (let j = msg.content.length - 1; j >= 0; j--) {
|
|
16767
|
+
const part = msg.content[j];
|
|
16768
|
+
if (part.type !== "tool-call") {
|
|
16769
|
+
continue;
|
|
16770
|
+
}
|
|
16771
|
+
const inputStr = JSON.stringify(part.input);
|
|
16772
|
+
if (inputStr.length > VERBOSE_TOOL_INPUT_THRESHOLD) {
|
|
16773
|
+
toolCallIdsToRemove.push(part.toolCallId);
|
|
16774
|
+
msg.content.splice(j, 1);
|
|
16775
|
+
}
|
|
16776
|
+
}
|
|
16777
|
+
for (const toolCallId of toolCallIdsToRemove) {
|
|
16778
|
+
removeToolResult(messages, toolCallId);
|
|
16779
|
+
}
|
|
16780
|
+
if (Array.isArray(msg.content) && msg.content.length === 0) {
|
|
16781
|
+
messages.splice(i, 1);
|
|
16782
|
+
}
|
|
16783
|
+
}
|
|
16784
|
+
return messages;
|
|
16785
|
+
};
|
|
16786
|
+
const removeReasoningFromAssistant = (messages, protectedMessageCount = 10, compactionLevel = 1) => {
|
|
16787
|
+
if (compactionLevel < 5) {
|
|
16788
|
+
return messages;
|
|
16789
|
+
}
|
|
16790
|
+
const protectedStart = getProtectedStartIndex(messages, Math.max(protectedMessageCount, VERBOSE_COMPACT_WINDOW));
|
|
16791
|
+
for (let i = protectedStart - 1; i >= 0; i--) {
|
|
16792
|
+
if (i >= messages.length) {
|
|
16793
|
+
continue;
|
|
16794
|
+
}
|
|
16795
|
+
const msg = messages[i];
|
|
16796
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
16797
|
+
continue;
|
|
16798
|
+
}
|
|
16799
|
+
const hadReasoning = msg.content.some((p) => p.type === "reasoning");
|
|
16800
|
+
if (!hadReasoning) {
|
|
16801
|
+
continue;
|
|
16802
|
+
}
|
|
16803
|
+
msg.content = msg.content.filter((p) => p.type !== "reasoning");
|
|
16804
|
+
if (msg.content.length === 0) {
|
|
16805
|
+
messages.splice(i, 1);
|
|
16806
|
+
}
|
|
16807
|
+
}
|
|
16808
|
+
return messages;
|
|
16809
|
+
};
|
|
16444
16810
|
const redactFetchOutputs = (messages, protectedMessageCount = 10) => {
|
|
16445
16811
|
const protectedStart = getProtectedStartIndex(messages, protectedMessageCount);
|
|
16446
16812
|
for (let i = 0; i < protectedStart; i++) {
|
|
@@ -17168,7 +17534,7 @@ class Task {
|
|
|
17168
17534
|
}
|
|
17169
17535
|
return responses;
|
|
17170
17536
|
}
|
|
17171
|
-
async runPromptInAgent(profile, mode, prompt, promptContext = { id: uuid.v4() }, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true, images) {
|
|
17537
|
+
async runPromptInAgent(profile, mode, prompt, promptContext = { id: uuid.v4() }, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true, images, skillsToActivate) {
|
|
17172
17538
|
if (waitForCurrentAgentToFinish) {
|
|
17173
17539
|
await this.waitForCurrentAgentToFinish();
|
|
17174
17540
|
}
|
|
@@ -17191,7 +17557,8 @@ class Task {
|
|
|
17191
17557
|
systemPrompt,
|
|
17192
17558
|
true,
|
|
17193
17559
|
void 0,
|
|
17194
|
-
images
|
|
17560
|
+
images,
|
|
17561
|
+
skillsToActivate
|
|
17195
17562
|
);
|
|
17196
17563
|
if (agentMessages.length > 0) {
|
|
17197
17564
|
this.contextManager.toConnectorMessages(agentMessages).forEach((message) => {
|
|
@@ -17302,6 +17669,7 @@ ${contentText}</agent-response>`;
|
|
|
17302
17669
|
const modelId = this.getAuxiliaryModelId(agentProfile, settings.taskSettings.taskStateModel);
|
|
17303
17670
|
this.addLogMessage("loading", "Updating task state...");
|
|
17304
17671
|
const answer = await this.agent.generateText(modelId, await this.promptsManager.getUpdateTaskStatePrompt(this), wrappedMessage, this.getProjectDir());
|
|
17672
|
+
this.addLogMessage("loading", void 0, true);
|
|
17305
17673
|
if (!answer) {
|
|
17306
17674
|
logger.warn("Task state determination interrupted");
|
|
17307
17675
|
return null;
|
|
@@ -18151,42 +18519,59 @@ ${contentText}</agent-response>`;
|
|
|
18151
18519
|
const contextMessages = await this.contextManager.getContextMessages();
|
|
18152
18520
|
return this.skillManager.getSkills(contextMessages);
|
|
18153
18521
|
}
|
|
18154
|
-
async
|
|
18522
|
+
async createSkillMessages(...skillNames) {
|
|
18523
|
+
if (skillNames.length === 0) {
|
|
18524
|
+
return null;
|
|
18525
|
+
}
|
|
18155
18526
|
const contextMessages = await this.contextManager.getContextMessages();
|
|
18156
18527
|
const activatedNames = this.skillManager.getActivatedSkillNames(contextMessages);
|
|
18157
|
-
|
|
18158
|
-
|
|
18159
|
-
|
|
18528
|
+
const allMessages = [];
|
|
18529
|
+
for (const skillName of skillNames) {
|
|
18530
|
+
if (activatedNames.has(skillName)) {
|
|
18531
|
+
logger.debug("Skill already activated, skipping", { skillName });
|
|
18532
|
+
continue;
|
|
18533
|
+
}
|
|
18534
|
+
const content = await this.skillManager.getSkillContent(skillName);
|
|
18535
|
+
if (!content) {
|
|
18536
|
+
throw new Error(`Skill '${skillName}' not found`);
|
|
18537
|
+
}
|
|
18538
|
+
const [assistantMessage, toolMessage] = this.skillManager.buildActivateSkillMessages(skillName, content);
|
|
18539
|
+
await this.processResponseMessage(
|
|
18540
|
+
{
|
|
18541
|
+
id: assistantMessage.id,
|
|
18542
|
+
action: "response",
|
|
18543
|
+
content: "User requested the skill activation.",
|
|
18544
|
+
finished: true
|
|
18545
|
+
},
|
|
18546
|
+
false
|
|
18547
|
+
);
|
|
18548
|
+
const toolCallId = toolMessage.content[0].toolCallId;
|
|
18549
|
+
this.addToolMessage(
|
|
18550
|
+
toolCallId,
|
|
18551
|
+
SKILLS_TOOL_GROUP_NAME,
|
|
18552
|
+
SKILLS_TOOL_ACTIVATE_SKILL,
|
|
18553
|
+
{ skill: skillName },
|
|
18554
|
+
JSON.stringify(content),
|
|
18555
|
+
void 0,
|
|
18556
|
+
void 0,
|
|
18557
|
+
false,
|
|
18558
|
+
true
|
|
18559
|
+
);
|
|
18560
|
+
allMessages.push(assistantMessage, toolMessage);
|
|
18561
|
+
activatedNames.add(skillName);
|
|
18160
18562
|
}
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18563
|
+
return allMessages.length > 0 ? allMessages : null;
|
|
18564
|
+
}
|
|
18565
|
+
async activateSkill(skillName) {
|
|
18566
|
+
const messages = await this.createSkillMessages(skillName);
|
|
18567
|
+
if (!messages) {
|
|
18568
|
+
return null;
|
|
18569
|
+
}
|
|
18570
|
+
for (const message of messages) {
|
|
18571
|
+
this.contextManager.addContextMessage(message);
|
|
18164
18572
|
}
|
|
18165
|
-
const [assistantMessage, toolMessage] = this.skillManager.buildActivateSkillMessages(skillName, content);
|
|
18166
|
-
this.contextManager.addContextMessage(assistantMessage);
|
|
18167
|
-
this.contextManager.addContextMessage(toolMessage);
|
|
18168
|
-
await this.processResponseMessage(
|
|
18169
|
-
{
|
|
18170
|
-
id: assistantMessage.id,
|
|
18171
|
-
action: "response",
|
|
18172
|
-
content: "User requested the skill activation.",
|
|
18173
|
-
finished: true
|
|
18174
|
-
},
|
|
18175
|
-
false
|
|
18176
|
-
);
|
|
18177
|
-
const toolCallId = toolMessage.content[0].toolCallId;
|
|
18178
|
-
this.addToolMessage(
|
|
18179
|
-
toolCallId,
|
|
18180
|
-
SKILLS_TOOL_GROUP_NAME,
|
|
18181
|
-
SKILLS_TOOL_ACTIVATE_SKILL,
|
|
18182
|
-
{ skill: skillName },
|
|
18183
|
-
JSON.stringify(content),
|
|
18184
|
-
void 0,
|
|
18185
|
-
void 0,
|
|
18186
|
-
false,
|
|
18187
|
-
true
|
|
18188
|
-
);
|
|
18189
18573
|
await this.updateContextInfo();
|
|
18574
|
+
return [messages[0], messages[1]];
|
|
18190
18575
|
}
|
|
18191
18576
|
async deactivateSkill(skillName) {
|
|
18192
18577
|
const contextMessages = await this.contextManager.getContextMessages();
|
|
@@ -18700,7 +19085,7 @@ ${contentText}</agent-response>`;
|
|
|
18700
19085
|
messagesSinceLastCompaction,
|
|
18701
19086
|
smartCompactionLevel: this.smartCompactionLevel
|
|
18702
19087
|
});
|
|
18703
|
-
this.smartCompactionLevel = Math.min(this.smartCompactionLevel + 1, CompactionLevel.
|
|
19088
|
+
this.smartCompactionLevel = Math.min(this.smartCompactionLevel + 1, CompactionLevel.Max);
|
|
18704
19089
|
} else if (messagesSinceLastCompaction > 5 && this.smartCompactionLevel > CompactionLevel.One) {
|
|
18705
19090
|
logger.info("Decreasing compaction level to mild due to high message count since last compaction.", {
|
|
18706
19091
|
messagesSinceLastCompaction
|
|
@@ -19185,15 +19570,6 @@ ${error.stderr}`,
|
|
|
19185
19570
|
this.addLogMessage("error", "No active Agent profile found");
|
|
19186
19571
|
return;
|
|
19187
19572
|
}
|
|
19188
|
-
if (command.skills?.length) {
|
|
19189
|
-
for (const skillName of command.skills) {
|
|
19190
|
-
try {
|
|
19191
|
-
await this.activateSkill(skillName);
|
|
19192
|
-
} catch (error) {
|
|
19193
|
-
logger.warn(`Failed to activate skill '${skillName}' for command '${commandName}': ${error instanceof Error ? error.message : String(error)}`);
|
|
19194
|
-
}
|
|
19195
|
-
}
|
|
19196
|
-
}
|
|
19197
19573
|
const systemPrompt = await this.promptsManager.getSystemPrompt(
|
|
19198
19574
|
this.store.getSettings(),
|
|
19199
19575
|
this,
|
|
@@ -19203,7 +19579,7 @@ ${error.stderr}`,
|
|
|
19203
19579
|
const messages = command.includeContext === false ? [] : void 0;
|
|
19204
19580
|
const contextFiles = command.includeContext === false ? [] : void 0;
|
|
19205
19581
|
this.addLogMessage("loading", "Executing custom command...");
|
|
19206
|
-
await this.runPromptInAgent(profile, mode, prompt, promptContext, messages, contextFiles, systemPrompt);
|
|
19582
|
+
await this.runPromptInAgent(profile, mode, prompt, promptContext, messages, contextFiles, systemPrompt, true, true, void 0, command.skills);
|
|
19207
19583
|
} else {
|
|
19208
19584
|
this.addLogMessage("loading", "Executing custom command...");
|
|
19209
19585
|
await this.runPromptInAider(mode, prompt, promptContext);
|
|
@@ -19325,6 +19701,7 @@ ${error.stderr}`,
|
|
|
19325
19701
|
}
|
|
19326
19702
|
void this.sendUpdatedFilesUpdated();
|
|
19327
19703
|
void this.sendWorktreeIntegrationStatusUpdated();
|
|
19704
|
+
await this.updateAutocompletionData(void 0, true);
|
|
19328
19705
|
return true;
|
|
19329
19706
|
}
|
|
19330
19707
|
async mergeWorktreeToMain(squash, targetBranch, commitMessage) {
|
|
@@ -19461,6 +19838,7 @@ Only answer with the commit message, nothing else.`,
|
|
|
19461
19838
|
}
|
|
19462
19839
|
}
|
|
19463
19840
|
await this.updateTask({ workingMode: "local" });
|
|
19841
|
+
await this.updateAutocompletionData(void 0, true);
|
|
19464
19842
|
}
|
|
19465
19843
|
async switchToWorktreeWorkingMode(options) {
|
|
19466
19844
|
logger.info("Switching to worktree working mode", {
|
|
@@ -19489,10 +19867,30 @@ Only answer with the commit message, nothing else.`,
|
|
|
19489
19867
|
}
|
|
19490
19868
|
} catch (error) {
|
|
19491
19869
|
logger.error("Failed to stash uncommitted changes before worktree switch:", { error });
|
|
19492
|
-
|
|
19870
|
+
throw new Error(`Failed to stash uncommitted changes: ${error instanceof Error ? error.message : String(error)}`);
|
|
19493
19871
|
}
|
|
19494
19872
|
}
|
|
19495
|
-
await this.
|
|
19873
|
+
const existingWorktree = await this.worktreeManager.getTaskWorktree(this.project.baseDir, this.taskId);
|
|
19874
|
+
if (!existingWorktree && !this.task.worktree) {
|
|
19875
|
+
try {
|
|
19876
|
+
await this.initWorktree();
|
|
19877
|
+
} catch (error) {
|
|
19878
|
+
if (stashId) {
|
|
19879
|
+
try {
|
|
19880
|
+
await this.worktreeManager.applyStash(this.project.baseDir, stashId);
|
|
19881
|
+
await this.worktreeManager.dropStash(this.project.baseDir, stashId);
|
|
19882
|
+
} catch (restoreError) {
|
|
19883
|
+
logger.error("Failed to restore stash after worktree creation failure:", { error: restoreError, stashId });
|
|
19884
|
+
throw new Error(
|
|
19885
|
+
`Failed to create worktree and could not restore stashed changes. Stash ID "${stashId}" still exists. Manual recovery required. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
19886
|
+
);
|
|
19887
|
+
}
|
|
19888
|
+
}
|
|
19889
|
+
throw error;
|
|
19890
|
+
}
|
|
19891
|
+
} else if (existingWorktree && !this.task.worktree) {
|
|
19892
|
+
this.task.worktree = existingWorktree;
|
|
19893
|
+
}
|
|
19496
19894
|
if (stashId && this.task.worktree) {
|
|
19497
19895
|
try {
|
|
19498
19896
|
await this.worktreeManager.applyStash(this.task.worktree.path, stashId);
|
|
@@ -19502,9 +19900,26 @@ Only answer with the commit message, nothing else.`,
|
|
|
19502
19900
|
await this.worktreeManager.dropStash(this.project.baseDir, stashId);
|
|
19503
19901
|
} catch (error) {
|
|
19504
19902
|
logger.error("Failed to apply stashed changes to worktree:", { error });
|
|
19903
|
+
const originalMessage = error instanceof Error ? error.message : String(error);
|
|
19904
|
+
try {
|
|
19905
|
+
await this.worktreeManager.applyStash(this.project.baseDir, stashId);
|
|
19906
|
+
await this.worktreeManager.dropStash(this.project.baseDir, stashId);
|
|
19907
|
+
logger.info("Stashed changes restored to project root after failed apply to worktree");
|
|
19908
|
+
throw new Error(`Failed to apply stashed changes to worktree. Changes have been restored to project root. Error: ${originalMessage}`);
|
|
19909
|
+
} catch (restoreError) {
|
|
19910
|
+
if (restoreError instanceof Error && restoreError.message.includes("restored to project root")) {
|
|
19911
|
+
throw restoreError;
|
|
19912
|
+
}
|
|
19913
|
+
logger.error("Failed to restore stash to project root:", { error: restoreError, stashId });
|
|
19914
|
+
throw new Error(
|
|
19915
|
+
`Failed to apply stashed changes to worktree and could not restore them. Stash ID "${stashId}" still exists. Manual recovery required. Original error: ${originalMessage}`
|
|
19916
|
+
);
|
|
19917
|
+
}
|
|
19505
19918
|
}
|
|
19506
19919
|
}
|
|
19920
|
+
await this.updateTask({ workingMode: "worktree" });
|
|
19507
19921
|
void this.sendUpdatedFilesUpdated();
|
|
19922
|
+
await this.updateAutocompletionData(void 0, true);
|
|
19508
19923
|
}
|
|
19509
19924
|
async getLocalUncommittedFiles() {
|
|
19510
19925
|
return await this.worktreeManager.getUncommittedFiles(this.project.baseDir);
|
|
@@ -19545,6 +19960,20 @@ Only answer with the commit message, nothing else.`,
|
|
|
19545
19960
|
await this.sendUpdatedFilesUpdated();
|
|
19546
19961
|
await this.sendWorktreeIntegrationStatusUpdated();
|
|
19547
19962
|
}
|
|
19963
|
+
async mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted = false) {
|
|
19964
|
+
if (!this.task.worktree) {
|
|
19965
|
+
throw new Error("No worktree exists for this task");
|
|
19966
|
+
}
|
|
19967
|
+
logger.info("Merging worktree to worktree", {
|
|
19968
|
+
baseDir: this.project.baseDir,
|
|
19969
|
+
taskId: this.taskId,
|
|
19970
|
+
targetWorktreeDir,
|
|
19971
|
+
includeUncommitted
|
|
19972
|
+
});
|
|
19973
|
+
await this.waitForCurrentPromptToFinish();
|
|
19974
|
+
await this.worktreeManager.mergeWorktreeToWorktree(this.task.worktree.path, targetWorktreeDir, includeUncommitted);
|
|
19975
|
+
await this.sendUpdatedFilesUpdated();
|
|
19976
|
+
}
|
|
19548
19977
|
async revertLastMerge() {
|
|
19549
19978
|
if (!this.task.lastMergeState) {
|
|
19550
19979
|
throw new Error("No merge state found to revert");
|
|
@@ -19693,7 +20122,14 @@ ${diff}
|
|
|
19693
20122
|
await this.waitForCurrentPromptToFinish();
|
|
19694
20123
|
try {
|
|
19695
20124
|
this.addLogMessage("loading", `Rebasing worktree from ${effectiveFromBranch}...`);
|
|
19696
|
-
const
|
|
20125
|
+
const settings = this.store.getSettings();
|
|
20126
|
+
const symlinkFolders = settings.taskSettings.worktreeSymlinkFolders || [];
|
|
20127
|
+
const { success, error } = await this.worktreeManager.rebaseMainIntoWorktree(
|
|
20128
|
+
this.task.worktree.path,
|
|
20129
|
+
effectiveFromBranch,
|
|
20130
|
+
this.task.worktree.baseCommit,
|
|
20131
|
+
symlinkFolders
|
|
20132
|
+
);
|
|
19697
20133
|
if (success) {
|
|
19698
20134
|
const newHead = await this.worktreeManager.getHeadCommit(this.task.worktree.path);
|
|
19699
20135
|
if (newHead) {
|
|
@@ -19895,8 +20331,21 @@ ${diff}
|
|
|
19895
20331
|
await this.waitForCurrentPromptToFinish();
|
|
19896
20332
|
try {
|
|
19897
20333
|
this.addLogMessage("loading", "Continuing rebase...");
|
|
19898
|
-
await this.worktreeManager.continueRebase(this.task.worktree.path);
|
|
19899
|
-
await this.
|
|
20334
|
+
const { ontoBranch } = await this.worktreeManager.continueRebase(this.task.worktree.path);
|
|
20335
|
+
const newHead = await this.worktreeManager.getHeadCommit(this.task.worktree.path);
|
|
20336
|
+
if (newHead) {
|
|
20337
|
+
await this.saveTask({
|
|
20338
|
+
lastMergeState: void 0,
|
|
20339
|
+
worktree: {
|
|
20340
|
+
...this.task.worktree,
|
|
20341
|
+
baseCommit: newHead,
|
|
20342
|
+
// Update baseBranch if we could determine it from the rebase state, otherwise keep existing
|
|
20343
|
+
baseBranch: ontoBranch || this.task.worktree.baseBranch
|
|
20344
|
+
}
|
|
20345
|
+
});
|
|
20346
|
+
} else {
|
|
20347
|
+
await this.saveTask({ lastMergeState: void 0 });
|
|
20348
|
+
}
|
|
19900
20349
|
this.addLogMessage("info", "Rebase completed", true);
|
|
19901
20350
|
} catch (error) {
|
|
19902
20351
|
logger.error("Failed to continue rebase:", error);
|
|
@@ -21268,6 +21717,9 @@ const anthropicProviderStrategy = {
|
|
|
21268
21717
|
// Configuration helpers
|
|
21269
21718
|
getCacheControl: getAnthropicCacheControl
|
|
21270
21719
|
};
|
|
21720
|
+
const ensureV1Suffix = (baseUrl) => {
|
|
21721
|
+
return baseUrl.endsWith("/v1") ? baseUrl : `${baseUrl}/v1`;
|
|
21722
|
+
};
|
|
21271
21723
|
const loadAnthropicCompatibleModels = async (profile, settings) => {
|
|
21272
21724
|
if (!isAnthropicCompatibleProvider(profile.provider)) {
|
|
21273
21725
|
return { models: [], success: false };
|
|
@@ -21283,7 +21735,7 @@ const loadAnthropicCompatibleModels = async (profile, settings) => {
|
|
|
21283
21735
|
return { models: [], success: false };
|
|
21284
21736
|
}
|
|
21285
21737
|
try {
|
|
21286
|
-
const response = await fetch(`${effectiveBaseUrl}/
|
|
21738
|
+
const response = await fetch(`${ensureV1Suffix(effectiveBaseUrl)}/models`, {
|
|
21287
21739
|
headers: {
|
|
21288
21740
|
"x-api-key": effectiveApiKey,
|
|
21289
21741
|
"anthropic-version": "2023-06-01"
|
|
@@ -21368,7 +21820,7 @@ const createAnthropicCompatibleLlm = (profile, model, settings, projectDir) => {
|
|
|
21368
21820
|
}
|
|
21369
21821
|
const anthropicProvider = anthropic.createAnthropic({
|
|
21370
21822
|
apiKey,
|
|
21371
|
-
baseURL: baseUrl,
|
|
21823
|
+
baseURL: ensureV1Suffix(baseUrl),
|
|
21372
21824
|
headers: profile.headers
|
|
21373
21825
|
});
|
|
21374
21826
|
return anthropicProvider(model.id);
|
|
@@ -22164,81 +22616,6 @@ const geminiProviderStrategy = {
|
|
|
22164
22616
|
// Error handling
|
|
22165
22617
|
isRetryable: isGeminiRetryable
|
|
22166
22618
|
};
|
|
22167
|
-
const GEMINI_CLI_MODELS = [
|
|
22168
|
-
{
|
|
22169
|
-
id: "gemini-3.1-pro-preview",
|
|
22170
|
-
maxInputTokens: 1048576,
|
|
22171
|
-
maxOutputTokens: 65536
|
|
22172
|
-
},
|
|
22173
|
-
{
|
|
22174
|
-
id: "gemini-3-flash-preview",
|
|
22175
|
-
maxInputTokens: 1048576,
|
|
22176
|
-
maxOutputTokens: 65536
|
|
22177
|
-
},
|
|
22178
|
-
{ id: "gemini-2.5-pro", maxInputTokens: 1048576, maxOutputTokens: 65536 },
|
|
22179
|
-
{ id: "gemini-2.5-flash", maxInputTokens: 1048576, maxOutputTokens: 65536 },
|
|
22180
|
-
{ id: "gemini-2.5-flash-lite", maxInputTokens: 1048576, maxOutputTokens: 65536 }
|
|
22181
|
-
];
|
|
22182
|
-
const loadGeminiCliModels = async (profile, _settings) => {
|
|
22183
|
-
if (!isGeminiCliProvider(profile.provider)) {
|
|
22184
|
-
return { models: [], success: false };
|
|
22185
|
-
}
|
|
22186
|
-
const models = GEMINI_CLI_MODELS.map((m) => ({
|
|
22187
|
-
id: m.id,
|
|
22188
|
-
providerId: profile.id,
|
|
22189
|
-
maxInputTokens: m.maxInputTokens,
|
|
22190
|
-
maxOutputTokensLimit: m.maxOutputTokens
|
|
22191
|
-
}));
|
|
22192
|
-
return { models, success: true };
|
|
22193
|
-
};
|
|
22194
|
-
const hasGeminiCliEnvVars = () => {
|
|
22195
|
-
return findExecutableInPath("gemini") !== null;
|
|
22196
|
-
};
|
|
22197
|
-
const getGeminiCliAiderMapping = (provider, modelId, _settings, _projectDir) => {
|
|
22198
|
-
const environmentVariables = {};
|
|
22199
|
-
if (isGeminiCliProvider(provider.provider) && provider.provider.projectId) {
|
|
22200
|
-
environmentVariables.GOOGLE_CLOUD_PROJECT = provider.provider.projectId;
|
|
22201
|
-
}
|
|
22202
|
-
return {
|
|
22203
|
-
modelName: `gemini-cli/${modelId}`,
|
|
22204
|
-
environmentVariables
|
|
22205
|
-
};
|
|
22206
|
-
};
|
|
22207
|
-
const createGeminiCliLlm = async (profile, model, _settings, _projectDir, _toolSet, _systemPrompt, _providerMetadata) => {
|
|
22208
|
-
const projectId = isGeminiCliProvider(profile.provider) ? profile.provider.projectId : void 0;
|
|
22209
|
-
logger.debug("Creating Gemini CLI LLM", {
|
|
22210
|
-
model: model.id,
|
|
22211
|
-
projectId
|
|
22212
|
-
});
|
|
22213
|
-
const { createGeminiProvider } = await import("ai-sdk-provider-gemini-cli");
|
|
22214
|
-
if (projectId) {
|
|
22215
|
-
process.env.GOOGLE_CLOUD_PROJECT = projectId;
|
|
22216
|
-
}
|
|
22217
|
-
const gemini = createGeminiProvider({ authType: "oauth-personal" });
|
|
22218
|
-
return gemini(model.id);
|
|
22219
|
-
};
|
|
22220
|
-
const getGeminiCliUsageReport = (task, provider, model, usage, _providerMetadata) => {
|
|
22221
|
-
return getDefaultUsageReport(task, provider, model, usage);
|
|
22222
|
-
};
|
|
22223
|
-
const getGeminiCliProviderParameters = () => {
|
|
22224
|
-
return {};
|
|
22225
|
-
};
|
|
22226
|
-
const isGeminiCliRetryable = (error) => {
|
|
22227
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
22228
|
-
if (errorMessage.includes("GOOGLE_CLOUD_PROJECT") || errorMessage.includes("GOOGLE_CLOUD_PROJECT_ID")) {
|
|
22229
|
-
return false;
|
|
22230
|
-
}
|
|
22231
|
-
return true;
|
|
22232
|
-
};
|
|
22233
|
-
const geminiCliProviderStrategy = {
|
|
22234
|
-
createLlm: createGeminiCliLlm,
|
|
22235
|
-
getUsageReport: getGeminiCliUsageReport,
|
|
22236
|
-
loadModels: loadGeminiCliModels,
|
|
22237
|
-
hasEnvVars: hasGeminiCliEnvVars,
|
|
22238
|
-
getAiderMapping: getGeminiCliAiderMapping,
|
|
22239
|
-
getProviderParameters: getGeminiCliProviderParameters,
|
|
22240
|
-
isRetryable: isGeminiCliRetryable
|
|
22241
|
-
};
|
|
22242
22619
|
const loadGpustackModels = async (profile, settings) => {
|
|
22243
22620
|
if (!isGpustackProvider(profile.provider)) {
|
|
22244
22621
|
return { models: [], success: false };
|
|
@@ -23260,13 +23637,31 @@ const getNeuralwattUsageReport = (task, provider, model, usage, providerMetadata
|
|
|
23260
23637
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23261
23638
|
};
|
|
23262
23639
|
};
|
|
23640
|
+
const getNeuralwattProviderOptions = (llmProvider, model) => {
|
|
23641
|
+
if (!isNeuralwattProvider(llmProvider)) {
|
|
23642
|
+
return void 0;
|
|
23643
|
+
}
|
|
23644
|
+
const neuralwattProvider = llmProvider;
|
|
23645
|
+
const providerOverrides = model.providerOverrides;
|
|
23646
|
+
const reasoningEffort = providerOverrides?.reasoningEffort ?? neuralwattProvider.reasoningEffort;
|
|
23647
|
+
const mappedReasoningEffort = reasoningEffort === void 0 ? void 0 : reasoningEffort.toLowerCase();
|
|
23648
|
+
if (mappedReasoningEffort) {
|
|
23649
|
+
return {
|
|
23650
|
+
neuralwatt: {
|
|
23651
|
+
reasoningEffort: mappedReasoningEffort
|
|
23652
|
+
}
|
|
23653
|
+
};
|
|
23654
|
+
}
|
|
23655
|
+
return void 0;
|
|
23656
|
+
};
|
|
23263
23657
|
const neuralwattProviderStrategy = {
|
|
23264
23658
|
createLlm: createNeuralwattLlm,
|
|
23265
23659
|
getUsageReport: getNeuralwattUsageReport,
|
|
23266
23660
|
loadModels: loadNeuralwattModels,
|
|
23267
23661
|
hasEnvVars: hasNeuralwattEnvVars,
|
|
23268
23662
|
getAiderMapping: getNeuralwattAiderMapping,
|
|
23269
|
-
getModelInfo: getDefaultModelInfo
|
|
23663
|
+
getModelInfo: getDefaultModelInfo,
|
|
23664
|
+
getProviderOptions: getNeuralwattProviderOptions
|
|
23270
23665
|
};
|
|
23271
23666
|
const loadOllamaModels = async (profile, settings) => {
|
|
23272
23667
|
if (!isOllamaProvider(profile.provider)) {
|
|
@@ -23707,15 +24102,22 @@ const getOpenAiCompatibleProviderOptions = (provider, model) => {
|
|
|
23707
24102
|
const openAiCompatibleProvider = provider;
|
|
23708
24103
|
const providerOverrides = model.providerOverrides;
|
|
23709
24104
|
const reasoningEffort = providerOverrides?.reasoningEffort ?? openAiCompatibleProvider.reasoningEffort;
|
|
24105
|
+
const extraBody = providerOverrides?.extraBody ?? openAiCompatibleProvider.extraBody;
|
|
23710
24106
|
const mappedReasoningEffort = reasoningEffort === void 0 || reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
24107
|
+
const providerOptions = {};
|
|
23711
24108
|
if (mappedReasoningEffort) {
|
|
23712
|
-
|
|
23713
|
-
|
|
24109
|
+
providerOptions.reasoningEffort = mappedReasoningEffort;
|
|
24110
|
+
}
|
|
24111
|
+
if (extraBody) {
|
|
24112
|
+
Object.assign(providerOptions, extraBody);
|
|
24113
|
+
}
|
|
24114
|
+
if (Object.keys(providerOptions).length > 0) {
|
|
24115
|
+
logger.debug("Using provider options for OpenAI Compatible:", {
|
|
24116
|
+
mappedReasoningEffort,
|
|
24117
|
+
hasExtraBody: !!extraBody
|
|
23714
24118
|
});
|
|
23715
24119
|
return {
|
|
23716
|
-
[provider.name]:
|
|
23717
|
-
reasoningEffort: mappedReasoningEffort
|
|
23718
|
-
}
|
|
24120
|
+
[provider.name]: providerOptions
|
|
23719
24121
|
};
|
|
23720
24122
|
}
|
|
23721
24123
|
return void 0;
|
|
@@ -24573,6 +24975,7 @@ const getZaiPlanProviderOptions = (llmProvider, model) => {
|
|
|
24573
24975
|
if (isZaiPlanProvider(llmProvider)) {
|
|
24574
24976
|
const providerOverrides = model.providerOverrides;
|
|
24575
24977
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
24978
|
+
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort ?? ReasoningEffort.Max;
|
|
24576
24979
|
if (thinkingEnabled === false) {
|
|
24577
24980
|
return {
|
|
24578
24981
|
"zai-plan": {
|
|
@@ -24582,6 +24985,14 @@ const getZaiPlanProviderOptions = (llmProvider, model) => {
|
|
|
24582
24985
|
}
|
|
24583
24986
|
};
|
|
24584
24987
|
}
|
|
24988
|
+
const mappedReasoningEffort = reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
24989
|
+
if (mappedReasoningEffort) {
|
|
24990
|
+
return {
|
|
24991
|
+
"zai-plan": {
|
|
24992
|
+
reasoningEffort: mappedReasoningEffort
|
|
24993
|
+
}
|
|
24994
|
+
};
|
|
24995
|
+
}
|
|
24585
24996
|
}
|
|
24586
24997
|
return void 0;
|
|
24587
24998
|
};
|
|
@@ -24596,6 +25007,7 @@ const zaiPlanProviderStrategy = {
|
|
|
24596
25007
|
getModelInfo: getZaiPlanModelInfo,
|
|
24597
25008
|
getProviderOptions: getZaiPlanProviderOptions
|
|
24598
25009
|
};
|
|
25010
|
+
const MODEL_LOAD_TIMEOUT_MS = 3e4;
|
|
24599
25011
|
const MODELS_META_URL = "https://models.dev/api.json";
|
|
24600
25012
|
const MODELS_FILE = path.join(AIDER_DESK_DATA_DIR, "models.json");
|
|
24601
25013
|
const PROVIDER_MODELS_CACHE_FILE = path.join(AIDER_DESK_CACHE_DIR, "provider-models.json");
|
|
@@ -24622,7 +25034,6 @@ class ModelManager {
|
|
|
24622
25034
|
cerebras: cerebrasProviderStrategy,
|
|
24623
25035
|
deepseek: deepseekProviderStrategy,
|
|
24624
25036
|
gemini: geminiProviderStrategy,
|
|
24625
|
-
"gemini-cli": geminiCliProviderStrategy,
|
|
24626
25037
|
gpustack: gpustackProviderStrategy,
|
|
24627
25038
|
groq: groqProviderStrategy,
|
|
24628
25039
|
"alibaba-plan": alibabaPlanProviderStrategy,
|
|
@@ -24824,48 +25235,59 @@ class ModelManager {
|
|
|
24824
25235
|
await this.loadProviderModels(changedProviderProfiles.filter((p) => !p.disabled));
|
|
24825
25236
|
return changedProviderProfiles.length > 0 || removedProviders.length > 0;
|
|
24826
25237
|
}
|
|
24827
|
-
async
|
|
24828
|
-
|
|
24829
|
-
const
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
25238
|
+
async withModelLoadTimeout(promise, profile) {
|
|
25239
|
+
let timer;
|
|
25240
|
+
const timeout = new Promise((resolve) => {
|
|
25241
|
+
timer = setTimeout(() => {
|
|
25242
|
+
if (!this.providerModels[profile.id]) {
|
|
25243
|
+
const errorMsg = `Timed out after ${MODEL_LOAD_TIMEOUT_MS / 1e3}s while loading models`;
|
|
25244
|
+
logger.error(`Model loading timed out for provider profile ${profile.id}`);
|
|
25245
|
+
this.providerErrors[profile.id] = errorMsg;
|
|
25246
|
+
}
|
|
25247
|
+
resolve();
|
|
25248
|
+
}, MODEL_LOAD_TIMEOUT_MS);
|
|
25249
|
+
});
|
|
25250
|
+
try {
|
|
25251
|
+
return await Promise.race([promise, timeout]);
|
|
25252
|
+
} finally {
|
|
25253
|
+
if (timer) {
|
|
25254
|
+
clearTimeout(timer);
|
|
24833
25255
|
}
|
|
24834
|
-
providersByName[provider.provider.name].push(provider);
|
|
24835
25256
|
}
|
|
25257
|
+
}
|
|
25258
|
+
async loadProviderModels(providers) {
|
|
25259
|
+
this.eventManager.sendProviderModelsUpdated({ loading: true });
|
|
24836
25260
|
const toLoadPromises = [];
|
|
24837
|
-
for (const
|
|
24838
|
-
const
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
const loadModels = async () => {
|
|
24842
|
-
for (const profile of profilesForProvider) {
|
|
24843
|
-
if (profile.disabled) {
|
|
24844
|
-
logger.debug(`Skipping disabled provider profile ${profile.id}`);
|
|
24845
|
-
continue;
|
|
24846
|
-
}
|
|
24847
|
-
let providerModels = [];
|
|
24848
|
-
const response = await this.loadModelsWithRetry(strategy, profile);
|
|
24849
|
-
delete this.providerErrors[profile.id];
|
|
24850
|
-
if (response.success) {
|
|
24851
|
-
providerModels.push(...response.models);
|
|
24852
|
-
} else {
|
|
24853
|
-
if (response.error) {
|
|
24854
|
-
logger.error(`Failed to load models for provider profile ${profile.id}:`, {
|
|
24855
|
-
error: response.error
|
|
24856
|
-
});
|
|
24857
|
-
this.providerErrors[profile.id] = response.error;
|
|
24858
|
-
} else {
|
|
24859
|
-
logger.warn(`Models for provider profile '${profile.id}' were not loaded due to misconfiguration.`);
|
|
24860
|
-
}
|
|
24861
|
-
}
|
|
24862
|
-
providerModels = this.enrichWithModelInfo(providerModels, profile, strategy);
|
|
24863
|
-
providerModels = this.enrichWithOverrides(providerModels, profile.id);
|
|
24864
|
-
this.providerModels[profile.id] = providerModels;
|
|
24865
|
-
}
|
|
24866
|
-
};
|
|
24867
|
-
toLoadPromises.push(loadModels());
|
|
25261
|
+
for (const profile of providers || []) {
|
|
25262
|
+
const strategy = this.providerRegistry[profile.provider.name];
|
|
25263
|
+
if (!strategy) {
|
|
25264
|
+
continue;
|
|
24868
25265
|
}
|
|
25266
|
+
if (profile.disabled) {
|
|
25267
|
+
logger.debug(`Skipping disabled provider profile ${profile.id}`);
|
|
25268
|
+
continue;
|
|
25269
|
+
}
|
|
25270
|
+
const loadModels = async () => {
|
|
25271
|
+
let providerModels = [];
|
|
25272
|
+
const response = await this.loadModelsWithRetry(strategy, profile);
|
|
25273
|
+
delete this.providerErrors[profile.id];
|
|
25274
|
+
if (response.success) {
|
|
25275
|
+
providerModels.push(...response.models);
|
|
25276
|
+
} else {
|
|
25277
|
+
if (response.error) {
|
|
25278
|
+
logger.error(`Failed to load models for provider profile ${profile.id}:`, {
|
|
25279
|
+
error: response.error
|
|
25280
|
+
});
|
|
25281
|
+
this.providerErrors[profile.id] = response.error;
|
|
25282
|
+
} else {
|
|
25283
|
+
logger.warn(`Models for provider profile '${profile.id}' were not loaded due to misconfiguration.`);
|
|
25284
|
+
}
|
|
25285
|
+
}
|
|
25286
|
+
providerModels = this.enrichWithModelInfo(providerModels, profile, strategy);
|
|
25287
|
+
providerModels = this.enrichWithOverrides(providerModels, profile.id);
|
|
25288
|
+
this.providerModels[profile.id] = providerModels;
|
|
25289
|
+
};
|
|
25290
|
+
toLoadPromises.push(this.withModelLoadTimeout(loadModels(), profile));
|
|
24869
25291
|
}
|
|
24870
25292
|
await Promise.all(toLoadPromises);
|
|
24871
25293
|
this.eventManager.sendProviderModelsUpdated({
|
|
@@ -26638,7 +27060,7 @@ class TaskContextImpl {
|
|
|
26638
27060
|
async runPrompt(prompt, mode) {
|
|
26639
27061
|
await this.task.runPrompt(prompt, mode);
|
|
26640
27062
|
}
|
|
26641
|
-
async runPromptInAgent(profile, mode, prompt, promptContext, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true) {
|
|
27063
|
+
async runPromptInAgent(profile, mode, prompt, promptContext, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true, skillsToActivate) {
|
|
26642
27064
|
return this.task.runPromptInAgent(
|
|
26643
27065
|
profile,
|
|
26644
27066
|
mode,
|
|
@@ -26648,7 +27070,9 @@ class TaskContextImpl {
|
|
|
26648
27070
|
contextFiles,
|
|
26649
27071
|
systemPrompt,
|
|
26650
27072
|
waitForCurrentAgentToFinish,
|
|
26651
|
-
sendNotification
|
|
27073
|
+
sendNotification,
|
|
27074
|
+
void 0,
|
|
27075
|
+
skillsToActivate
|
|
26652
27076
|
);
|
|
26653
27077
|
}
|
|
26654
27078
|
async runCustomCommand(name, args = [], mode) {
|
|
@@ -26681,6 +27105,9 @@ class TaskContextImpl {
|
|
|
26681
27105
|
});
|
|
26682
27106
|
return answer;
|
|
26683
27107
|
}
|
|
27108
|
+
async answerQuestion(answer, userInput) {
|
|
27109
|
+
return this.task.answerQuestion(answer, userInput);
|
|
27110
|
+
}
|
|
26684
27111
|
addLogMessage(level, message) {
|
|
26685
27112
|
this.task.addLogMessage(level, message);
|
|
26686
27113
|
}
|
|
@@ -26688,6 +27115,9 @@ class TaskContextImpl {
|
|
|
26688
27115
|
this.task.addLogMessage("loading", message, finished);
|
|
26689
27116
|
}
|
|
26690
27117
|
// Task Management
|
|
27118
|
+
async getTaskAgentProfile() {
|
|
27119
|
+
return this.task.getTaskAgentProfile();
|
|
27120
|
+
}
|
|
26691
27121
|
async updateTask(updates) {
|
|
26692
27122
|
return this.task.updateTask(updates);
|
|
26693
27123
|
}
|
|
@@ -26730,12 +27160,21 @@ class TaskContextImpl {
|
|
|
26730
27160
|
editQueuedPrompt(promptId, newText) {
|
|
26731
27161
|
this.task.editQueuedPrompt(promptId, newText);
|
|
26732
27162
|
}
|
|
26733
|
-
//
|
|
26734
|
-
async
|
|
26735
|
-
|
|
27163
|
+
// Working Mode & Worktrees
|
|
27164
|
+
async switchToWorktreeWorkingMode(options) {
|
|
27165
|
+
await this.task.switchToWorktreeWorkingMode(options);
|
|
26736
27166
|
}
|
|
26737
|
-
async
|
|
26738
|
-
|
|
27167
|
+
async switchToLocalWorkingMode(options) {
|
|
27168
|
+
await this.task.switchToLocalWorkingMode(options);
|
|
27169
|
+
}
|
|
27170
|
+
async getLocalUncommittedFiles() {
|
|
27171
|
+
return this.task.getLocalUncommittedFiles();
|
|
27172
|
+
}
|
|
27173
|
+
async applyUncommittedChanges(targetBranch) {
|
|
27174
|
+
await this.task.applyUncommittedChanges(targetBranch);
|
|
27175
|
+
}
|
|
27176
|
+
async mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted) {
|
|
27177
|
+
await this.task.mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted);
|
|
26739
27178
|
}
|
|
26740
27179
|
}
|
|
26741
27180
|
class ProjectContextImpl {
|
|
@@ -26930,6 +27369,19 @@ class ExtensionContextImpl {
|
|
|
26930
27369
|
return false;
|
|
26931
27370
|
}
|
|
26932
27371
|
}
|
|
27372
|
+
async getElectronApp() {
|
|
27373
|
+
try {
|
|
27374
|
+
const electron = await import("electron");
|
|
27375
|
+
const app = electron?.app ?? electron?.default?.app;
|
|
27376
|
+
if (!app || typeof app.getAppMetrics !== "function") {
|
|
27377
|
+
return null;
|
|
27378
|
+
}
|
|
27379
|
+
return app;
|
|
27380
|
+
} catch (error) {
|
|
27381
|
+
this.log(`Failed to get Electron app: ${error}`, "debug");
|
|
27382
|
+
return null;
|
|
27383
|
+
}
|
|
27384
|
+
}
|
|
26933
27385
|
getMemoryContext() {
|
|
26934
27386
|
if (!this.memoryManager) {
|
|
26935
27387
|
throw new Error("MemoryManager not available");
|
|
@@ -26941,6 +27393,11 @@ class ExtensionContextImpl {
|
|
|
26941
27393
|
}
|
|
26942
27394
|
}
|
|
26943
27395
|
const CACHE_TTL_MS$1 = 24 * 60 * 60 * 1e3;
|
|
27396
|
+
const FRAMEWORK_ENUM_VALUES = {
|
|
27397
|
+
"OS.Windows": "windows",
|
|
27398
|
+
"OS.Linux": "linux",
|
|
27399
|
+
"OS.MacOS": "macos"
|
|
27400
|
+
};
|
|
26944
27401
|
class ExtensionFetcher {
|
|
26945
27402
|
cache = /* @__PURE__ */ new Map();
|
|
26946
27403
|
getAvailableExtensionsPromise = null;
|
|
@@ -27198,6 +27655,7 @@ class ExtensionFetcher {
|
|
|
27198
27655
|
return null;
|
|
27199
27656
|
}
|
|
27200
27657
|
let metadata = null;
|
|
27658
|
+
const enumValues = this.collectEnumValues(sourceFile);
|
|
27201
27659
|
const visitor = (node) => {
|
|
27202
27660
|
if (ts__namespace.isPropertyDeclaration(node) && node.modifiers?.some((m) => m.kind === ts__namespace.SyntaxKind.StaticKeyword) && ts__namespace.isIdentifier(node.name) && node.name.text === "metadata") {
|
|
27203
27661
|
if (node.initializer) {
|
|
@@ -27209,7 +27667,7 @@ class ExtensionFetcher {
|
|
|
27209
27667
|
objectLiteral = this.findVariableDeclaration(sourceFile, variableName);
|
|
27210
27668
|
}
|
|
27211
27669
|
if (objectLiteral) {
|
|
27212
|
-
const parsed = this.parseObjectLiteral(objectLiteral);
|
|
27670
|
+
const parsed = this.parseObjectLiteral(objectLiteral, enumValues);
|
|
27213
27671
|
if (parsed && typeof parsed.name === "string" && typeof parsed.version === "string") {
|
|
27214
27672
|
metadata = parsed;
|
|
27215
27673
|
}
|
|
@@ -27232,19 +27690,45 @@ class ExtensionFetcher {
|
|
|
27232
27690
|
visitor(sourceFile);
|
|
27233
27691
|
return objectLiteral;
|
|
27234
27692
|
}
|
|
27235
|
-
|
|
27693
|
+
collectEnumValues(sourceFile) {
|
|
27694
|
+
const values = { ...FRAMEWORK_ENUM_VALUES };
|
|
27695
|
+
const visitor = (node) => {
|
|
27696
|
+
if (ts__namespace.isEnumDeclaration(node) && node.name) {
|
|
27697
|
+
const enumName = node.name.text;
|
|
27698
|
+
let autoValue = 0;
|
|
27699
|
+
for (const member of node.members) {
|
|
27700
|
+
const memberName = ts__namespace.isIdentifier(member.name) || ts__namespace.isStringLiteral(member.name) ? member.name.text : member.name.getText();
|
|
27701
|
+
const key = `${enumName}.${memberName}`;
|
|
27702
|
+
if (member.initializer) {
|
|
27703
|
+
const parsed = this.parsePropertyValue(member.initializer, values);
|
|
27704
|
+
values[key] = parsed;
|
|
27705
|
+
if (typeof parsed === "number") {
|
|
27706
|
+
autoValue = parsed + 1;
|
|
27707
|
+
}
|
|
27708
|
+
} else {
|
|
27709
|
+
values[key] = autoValue;
|
|
27710
|
+
autoValue++;
|
|
27711
|
+
}
|
|
27712
|
+
}
|
|
27713
|
+
}
|
|
27714
|
+
ts__namespace.forEachChild(node, visitor);
|
|
27715
|
+
};
|
|
27716
|
+
visitor(sourceFile);
|
|
27717
|
+
return values;
|
|
27718
|
+
}
|
|
27719
|
+
parseObjectLiteral(node, enumValues) {
|
|
27236
27720
|
const result = {};
|
|
27237
27721
|
for (const property of node.properties) {
|
|
27238
27722
|
if (ts__namespace.isPropertyAssignment(property)) {
|
|
27239
27723
|
const name = ts__namespace.isIdentifier(property.name) ? property.name.text : ts__namespace.isStringLiteral(property.name) ? property.name.text : null;
|
|
27240
27724
|
if (name) {
|
|
27241
|
-
result[name] = this.parsePropertyValue(property.initializer);
|
|
27725
|
+
result[name] = this.parsePropertyValue(property.initializer, enumValues);
|
|
27242
27726
|
}
|
|
27243
27727
|
}
|
|
27244
27728
|
}
|
|
27245
27729
|
return result;
|
|
27246
27730
|
}
|
|
27247
|
-
parsePropertyValue(node) {
|
|
27731
|
+
parsePropertyValue(node, enumValues) {
|
|
27248
27732
|
if (ts__namespace.isStringLiteral(node)) {
|
|
27249
27733
|
return node.text;
|
|
27250
27734
|
} else if (ts__namespace.isNumericLiteral(node)) {
|
|
@@ -27255,10 +27739,17 @@ class ExtensionFetcher {
|
|
|
27255
27739
|
return false;
|
|
27256
27740
|
} else if (node.kind === ts__namespace.SyntaxKind.NullKeyword) {
|
|
27257
27741
|
return null;
|
|
27742
|
+
} else if (ts__namespace.isPropertyAccessExpression(node)) {
|
|
27743
|
+
const exprText = ts__namespace.isIdentifier(node.expression) ? node.expression.text : node.expression.getText();
|
|
27744
|
+
const key = `${exprText}.${node.name.text}`;
|
|
27745
|
+
if (key in enumValues) {
|
|
27746
|
+
return enumValues[key];
|
|
27747
|
+
}
|
|
27748
|
+
return void 0;
|
|
27258
27749
|
} else if (ts__namespace.isArrayLiteralExpression(node)) {
|
|
27259
|
-
return node.elements.map((elem) => this.parsePropertyValue(elem));
|
|
27750
|
+
return node.elements.map((elem) => this.parsePropertyValue(elem, enumValues));
|
|
27260
27751
|
} else if (ts__namespace.isObjectLiteralExpression(node)) {
|
|
27261
|
-
return this.parseObjectLiteral(node);
|
|
27752
|
+
return this.parseObjectLiteral(node, enumValues);
|
|
27262
27753
|
}
|
|
27263
27754
|
return void 0;
|
|
27264
27755
|
}
|
|
@@ -27824,6 +28315,7 @@ class ExtensionManager {
|
|
|
27824
28315
|
}
|
|
27825
28316
|
}
|
|
27826
28317
|
static TOOL_NAME_REGEX = /^[a-z][a-z0-9_-]*$/;
|
|
28318
|
+
static COMMAND_NAME_REGEX = /^[a-z][a-z0-9_:-]*$/;
|
|
27827
28319
|
validateToolDefinition(tool) {
|
|
27828
28320
|
const errors = [];
|
|
27829
28321
|
try {
|
|
@@ -28017,9 +28509,9 @@ class ExtensionManager {
|
|
|
28017
28509
|
try {
|
|
28018
28510
|
if (!command.name) {
|
|
28019
28511
|
errors.push("Command name must be a non-empty string");
|
|
28020
|
-
} else if (!ExtensionManager.
|
|
28512
|
+
} else if (!ExtensionManager.COMMAND_NAME_REGEX.test(command.name)) {
|
|
28021
28513
|
errors.push(
|
|
28022
|
-
`Command name '${command.name}' must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, or
|
|
28514
|
+
`Command name '${command.name}' must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, underscores, or colons (e.g., 'generate-tests', 'impl:tweak', 'command_name')`
|
|
28023
28515
|
);
|
|
28024
28516
|
}
|
|
28025
28517
|
if (!command.description || command.description.trim() === "") {
|
|
@@ -28588,7 +29080,7 @@ class ExtensionManager {
|
|
|
28588
29080
|
* @param extensionId - Extension identifier
|
|
28589
29081
|
* @param repositoryUrl - Repository URL where the extension is located
|
|
28590
29082
|
* @param project - Optional project for project-level install
|
|
28591
|
-
* @returns
|
|
29083
|
+
* @returns ExtensionOperationResult indicating success or failure with error details
|
|
28592
29084
|
*/
|
|
28593
29085
|
async installExtension(extensionId, repositoryUrl, project) {
|
|
28594
29086
|
const projectDir = project?.baseDir;
|
|
@@ -28640,10 +29132,10 @@ class ExtensionManager {
|
|
|
28640
29132
|
await this.loadExtensionsForDir(targetDir, project);
|
|
28641
29133
|
logger.info(`[Extensions] Successfully installed ${extension.name}`);
|
|
28642
29134
|
this.telemetryManager.captureExtensionInstalled(extension.name, projectDir ? "project" : "global");
|
|
28643
|
-
return true;
|
|
29135
|
+
return { success: true };
|
|
28644
29136
|
} catch (error) {
|
|
28645
29137
|
logger.error(`[Extensions] Failed to install extension '${extensionId}':`, error);
|
|
28646
|
-
return false;
|
|
29138
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
28647
29139
|
}
|
|
28648
29140
|
}
|
|
28649
29141
|
/**
|
|
@@ -28654,11 +29146,14 @@ class ExtensionManager {
|
|
|
28654
29146
|
return new Promise((resolve, reject) => {
|
|
28655
29147
|
const child = spawn("npm", ["install"], {
|
|
28656
29148
|
cwd: extensionPath,
|
|
28657
|
-
stdio: "inherit"
|
|
29149
|
+
stdio: "inherit",
|
|
29150
|
+
shell: true
|
|
28658
29151
|
});
|
|
28659
29152
|
child.on("close", (code) => {
|
|
28660
29153
|
if (code === 0) {
|
|
28661
29154
|
resolve();
|
|
29155
|
+
} else if (code === 127) {
|
|
29156
|
+
reject(new Error("npm-not-found"));
|
|
28662
29157
|
} else {
|
|
28663
29158
|
reject(new Error(`npm install failed with code ${code}`));
|
|
28664
29159
|
}
|
|
@@ -28709,7 +29204,7 @@ class ExtensionManager {
|
|
|
28709
29204
|
* @param extensionId - Extension identifier (filePath of installed extension)
|
|
28710
29205
|
* @param repositoryUrl - Repository URL where the extension is located
|
|
28711
29206
|
* @param project - Optional project for project-level extension
|
|
28712
|
-
* @returns
|
|
29207
|
+
* @returns ExtensionOperationResult indicating success or failure with error details
|
|
28713
29208
|
*/
|
|
28714
29209
|
async updateExtension(extensionId, repositoryUrl, project) {
|
|
28715
29210
|
const projectDir = project?.baseDir;
|
|
@@ -28777,10 +29272,10 @@ class ExtensionManager {
|
|
|
28777
29272
|
}
|
|
28778
29273
|
await this.loadExtensionsForDir(targetDir, project);
|
|
28779
29274
|
logger.info(`[Extensions] Successfully updated ${extension.name}`);
|
|
28780
|
-
return true;
|
|
29275
|
+
return { success: true };
|
|
28781
29276
|
} catch (error) {
|
|
28782
29277
|
logger.error(`[Extensions] Failed to update extension '${extensionId}':`, error);
|
|
28783
|
-
return false;
|
|
29278
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
28784
29279
|
}
|
|
28785
29280
|
}
|
|
28786
29281
|
/**
|
|
@@ -31145,7 +31640,7 @@ const DEFAULT_SETTINGS = {
|
|
|
31145
31640
|
theme: "dark",
|
|
31146
31641
|
font: "Sono",
|
|
31147
31642
|
renderMarkdown: true,
|
|
31148
|
-
|
|
31643
|
+
fullMessageRendering: false,
|
|
31149
31644
|
aiderDeskAutoUpdate: true,
|
|
31150
31645
|
messageViewMode: MessageViewMode.Compact,
|
|
31151
31646
|
diffViewMode: DiffViewMode.SideBySide,
|
|
@@ -31209,7 +31704,8 @@ const DEFAULT_SETTINGS = {
|
|
|
31209
31704
|
},
|
|
31210
31705
|
proxy: {
|
|
31211
31706
|
enabled: false,
|
|
31212
|
-
url: ""
|
|
31707
|
+
url: "",
|
|
31708
|
+
noProxy: ""
|
|
31213
31709
|
},
|
|
31214
31710
|
fileWatchMode: FileWatchMode.Auto
|
|
31215
31711
|
};
|