@aiderdesk/aiderdesk 0.71.2-dev → 0.72.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 +87 -3
- package/out/renderer/assets/{AgentSettings-CGvSAJzP.js → AgentSettings-CEw1Tgyu.js} +133 -125
- package/out/renderer/assets/{InfoIcon-CWchJVTd.js → InfoIcon-B6bij_VJ.js} +1 -1
- package/out/renderer/assets/{Onboarding-DJOy0-Od.js → Onboarding-C2CtQOko.js} +4 -4
- package/out/renderer/assets/{ProviderHeader-BeAt2P8D.js → ProviderHeader-BCrdzdGT.js} +384 -165
- package/out/renderer/assets/{SettingsPage-iA6BPLfI.js → SettingsPage-CNCsKRS7.js} +647 -265
- package/out/renderer/assets/{UsageDashboard-Byo1Se6j.js → UsageDashboard-DtZ8GTj6.js} +3 -3
- package/out/renderer/assets/{arc-DMKtKWVp.js → arc-DnyT8oZ2.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-3BPJPVTR-B6q0Xxlt.js → architectureDiagram-3BPJPVTR-Dus_2n--.js} +3 -3
- package/out/renderer/assets/{blockDiagram-GPEHLZMM-CwUkQOmu.js → blockDiagram-GPEHLZMM-A3REgcbw.js} +4 -4
- package/out/renderer/assets/{c4Diagram-AAUBKEIU-jfNF8o54.js → c4Diagram-AAUBKEIU-DksErR7z.js} +2 -2
- package/out/renderer/assets/{channel-CGSP36Ng.js → channel-DkjNDJNa.js} +1 -1
- package/out/renderer/assets/{chunk-2J33WTMH-m9o4-rdE.js → chunk-2J33WTMH-CrUC6pnQ.js} +1 -1
- package/out/renderer/assets/{chunk-4BX2VUAB-sBI0mD9g.js → chunk-4BX2VUAB-BulXGa1B.js} +1 -1
- package/out/renderer/assets/{chunk-55IACEB6-Bi-yVgmi.js → chunk-55IACEB6-pQjPbAe9.js} +1 -1
- package/out/renderer/assets/{chunk-727SXJPM-DeJ6FAqm.js → chunk-727SXJPM-BcqphFMh.js} +5 -5
- package/out/renderer/assets/{chunk-AQP2D5EJ-RYpGSg2J.js → chunk-AQP2D5EJ-DCREtqoW.js} +3 -3
- package/out/renderer/assets/{chunk-FMBD7UC4-DhXJts_9.js → chunk-FMBD7UC4-LFUgit2t.js} +1 -1
- package/out/renderer/assets/{chunk-ND2GUHAM-BmWa3jDz.js → chunk-ND2GUHAM-Bkunzp-9.js} +1 -1
- package/out/renderer/assets/{chunk-QZHKN3VN-BDCZFGDN.js → chunk-QZHKN3VN-foWYS4_y.js} +1 -1
- package/out/renderer/assets/{classDiagram-4FO5ZUOK-B5meZIas.js → classDiagram-4FO5ZUOK-CVbKiC6R.js} +6 -6
- package/out/renderer/assets/{classDiagram-v2-Q7XG4LA2-B5meZIas.js → classDiagram-v2-Q7XG4LA2-CVbKiC6R.js} +6 -6
- package/out/renderer/assets/{cose-bilkent-S5V4N54A-nN2TmyEI.js → cose-bilkent-S5V4N54A-Bw7reEuM.js} +1 -1
- package/out/renderer/assets/{dagre-BM42HDAG-CKF8Re4C.js → dagre-BM42HDAG-oGURKg82.js} +3 -3
- package/out/renderer/assets/{diagram-2AECGRRQ-BEz7N4-p.js → diagram-2AECGRRQ-kaoJ1YpU.js} +3 -3
- package/out/renderer/assets/{diagram-5GNKFQAL-DzixbxEI.js → diagram-5GNKFQAL-EvoHkNwk.js} +4 -4
- package/out/renderer/assets/{diagram-KO2AKTUF-DrU3hJT-.js → diagram-KO2AKTUF-D5N5hwBV.js} +3 -3
- package/out/renderer/assets/{diagram-LMA3HP47-DeV3p8aR.js → diagram-LMA3HP47-kKi9mSGe.js} +3 -3
- package/out/renderer/assets/{diagram-OG6HWLK6-DqkXt2nH.js → diagram-OG6HWLK6-BWJ9L5AP.js} +4 -4
- package/out/renderer/assets/{erDiagram-TEJ5UH35-BQPyNf4w.js → erDiagram-TEJ5UH35-d1W9ONuu.js} +4 -4
- package/out/renderer/assets/{flowDiagram-I6XJVG4X-D2v6iQ98.js → flowDiagram-I6XJVG4X-u5Xk-TTj.js} +6 -6
- package/out/renderer/assets/{ganttDiagram-6RSMTGT7-CkYOeW7M.js → ganttDiagram-6RSMTGT7-DiheBMSM.js} +3 -3
- package/out/renderer/assets/{gitGraphDiagram-PVQCEYII-g-Uk6P-N.js → gitGraphDiagram-PVQCEYII-B7hUlCNM.js} +4 -4
- package/out/renderer/assets/{graph-CV504Ptb.js → graph-D7JlCUW0.js} +1 -1
- package/out/renderer/assets/{index-U06SYLCN.js → index-3OKQF96N.js} +1 -1
- package/out/renderer/assets/{index-3BRmjDVt.js → index-BgXUknVd.js} +129 -30
- package/out/renderer/assets/{index-BKAL4gqM.js → index-ClS76F34.js} +1 -1
- package/out/renderer/assets/{index-BBiLtvNT.js → index-CzGef_M5.js} +1 -1
- package/out/renderer/assets/{index-BRRWavZT.js → index-D8P2TG70.js} +1 -1
- package/out/renderer/assets/{index-D4QsfuBU.css → index-DJwDiyPe.css} +8 -0
- package/out/renderer/assets/{index-Bup9YtMB.js → index-DOl0MdBC.js} +1 -1
- package/out/renderer/assets/{index-DWl6Lclq.js → index-DcFrLBMu.js} +1 -1
- package/out/renderer/assets/{index-McGZ6Dx1.js → index-Duwg55fn.js} +1 -1
- package/out/renderer/assets/{index-MWcT9iVP.js → index-biM8l5ZN.js} +3377 -1970
- package/out/renderer/assets/{index-BijIcXFX.js → index-gnQtDa4r.js} +1 -1
- package/out/renderer/assets/{infoDiagram-5YYISTIA-D7CDIKx-.js → infoDiagram-5YYISTIA-BNOwcP8d.js} +2 -2
- package/out/renderer/assets/{ishikawaDiagram-YF4QCWOH-Dy5lIJM3.js → ishikawaDiagram-YF4QCWOH-DZGvMXcI.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-JHISSGLW-s4XQg-Ha.js → journeyDiagram-JHISSGLW-BF-SCAHN.js} +4 -4
- package/out/renderer/assets/{jsx-dev-runtime-D9-9kVso.js → jsx-dev-runtime-BZnUoQef.js} +1 -1
- package/out/renderer/assets/{kanban-definition-UN3LZRKU-BCWYozJY.js → kanban-definition-UN3LZRKU-Cp9SfO9v.js} +2 -2
- package/out/renderer/assets/{layout-DnWGEu0W.js → layout-BxWwRUTm.js} +2 -2
- package/out/renderer/assets/{linear-BP7dS-hv.js → linear-Cpdxqlgb.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-RKZ34NQL-DpF4KI3g.js → mindmap-definition-RKZ34NQL-BtGsJF8k.js} +3 -3
- package/out/renderer/assets/{pieDiagram-4H26LBE5-B6ZbPky5.js → pieDiagram-4H26LBE5-choZS41J.js} +4 -4
- package/out/renderer/assets/{quadrantDiagram-W4KKPZXB-QcDi1tPp.js → quadrantDiagram-W4KKPZXB-CSEwIgFD.js} +2 -2
- package/out/renderer/assets/{requirementDiagram-4Y6WPE33-B1JR969o.js → requirementDiagram-4Y6WPE33-sCdLoMf0.js} +3 -3
- package/out/renderer/assets/{sankeyDiagram-5OEKKPKP-BJ5rhw2A.js → sankeyDiagram-5OEKKPKP-DunA5v4o.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-3UESZ5HK-AdtAIm4D.js → sequenceDiagram-3UESZ5HK-Cwz8rZA1.js} +3 -3
- package/out/renderer/assets/{stateDiagram-AJRCARHV--GQXQ4Qf.js → stateDiagram-AJRCARHV-VCMhb3e-.js} +6 -6
- package/out/renderer/assets/{stateDiagram-v2-BHNVJYJU-CQAnRm7m.js → stateDiagram-v2-BHNVJYJU-B9OcfdsH.js} +4 -4
- package/out/renderer/assets/{time-BUK5ZzpA.js → time-CtsiuOCL.js} +1 -1
- package/out/renderer/assets/{timeline-definition-PNZ67QCA-CRru39WZ.js → timeline-definition-PNZ67QCA-B36Hc_gQ.js} +2 -2
- package/out/renderer/assets/{vennDiagram-CIIHVFJN-KF7qF8WR.js → vennDiagram-CIIHVFJN-Dt2oWHz0.js} +1 -1
- package/out/renderer/assets/{wardley-L42UT6IY-D3pQt3SZ.js → wardley-L42UT6IY-DkWaUY9X.js} +1 -1
- package/out/renderer/assets/{wardleyDiagram-YWT4CUSO-D3zxlHug.js → wardleyDiagram-YWT4CUSO-BHFM3JNH.js} +3 -3
- package/out/renderer/assets/{xychartDiagram-2RQKCTM6-B_0-TgYJ.js → xychartDiagram-2RQKCTM6-2wqqMVJ7.js} +2 -2
- package/out/renderer/index.html +2 -2
- package/out/resources/connector/connector.py +6 -1
- package/out/runner.js +752 -313
- package/package.json +15 -19
- package/scripts/download-probe.mjs +9 -2
- package/scripts/generate-package.mjs +0 -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";
|
|
@@ -1397,40 +1398,6 @@ const getShellPath = () => {
|
|
|
1397
1398
|
return fallbackPath;
|
|
1398
1399
|
}
|
|
1399
1400
|
};
|
|
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
1401
|
const getShellCommandArgs = (command) => {
|
|
1435
1402
|
return ShellDetector.getShellCommandArgs(command);
|
|
1436
1403
|
};
|
|
@@ -1501,7 +1468,6 @@ const AVAILABLE_PROVIDERS = [
|
|
|
1501
1468
|
"cerebras",
|
|
1502
1469
|
"deepseek",
|
|
1503
1470
|
"gemini",
|
|
1504
|
-
"gemini-cli",
|
|
1505
1471
|
"gpustack",
|
|
1506
1472
|
"groq",
|
|
1507
1473
|
"kimi-plan",
|
|
@@ -1541,7 +1507,6 @@ const isLmStudioProvider = (provider) => provider.name === "lmstudio";
|
|
|
1541
1507
|
const isDeepseekProvider = (provider) => provider.name === "deepseek";
|
|
1542
1508
|
const isGroqProvider = (provider) => provider.name === "groq";
|
|
1543
1509
|
const isCerebrasProvider = (provider) => provider.name === "cerebras";
|
|
1544
|
-
const isGeminiCliProvider = (provider) => provider.name === "gemini-cli";
|
|
1545
1510
|
const isBedrockProvider = (provider) => provider.name === "bedrock";
|
|
1546
1511
|
const isOpenAiCompatibleProvider = (provider) => provider.name === "openai-compatible";
|
|
1547
1512
|
const isLitellmProvider = (provider) => provider.name === "litellm";
|
|
@@ -1562,7 +1527,6 @@ const DEFAULT_PROVIDER_MODELS = {
|
|
|
1562
1527
|
cerebras: "qwen-3-235b-a22b-instruct-2507",
|
|
1563
1528
|
deepseek: "deepseek-v4-pro",
|
|
1564
1529
|
gemini: "gemini-pro-latest",
|
|
1565
|
-
"gemini-cli": "gemini-2.5-pro",
|
|
1566
1530
|
groq: "moonshotai/kimi-k2-instruct-0905",
|
|
1567
1531
|
"kimi-plan": "k2p6",
|
|
1568
1532
|
openai: "gpt-5.4",
|
|
@@ -1958,7 +1922,8 @@ const getDefaultProviderParams = (providerName) => {
|
|
|
1958
1922
|
case "zai-plan":
|
|
1959
1923
|
provider = {
|
|
1960
1924
|
name: "zai-plan",
|
|
1961
|
-
apiKey: ""
|
|
1925
|
+
apiKey: "",
|
|
1926
|
+
reasoningEffort: ReasoningEffort.Max
|
|
1962
1927
|
};
|
|
1963
1928
|
break;
|
|
1964
1929
|
case "minimax":
|
|
@@ -1976,13 +1941,8 @@ const getDefaultProviderParams = (providerName) => {
|
|
|
1976
1941
|
case "neuralwatt":
|
|
1977
1942
|
provider = {
|
|
1978
1943
|
name: "neuralwatt",
|
|
1979
|
-
apiKey: ""
|
|
1980
|
-
|
|
1981
|
-
break;
|
|
1982
|
-
case "gemini-cli":
|
|
1983
|
-
provider = {
|
|
1984
|
-
name: "gemini-cli",
|
|
1985
|
-
projectId: ""
|
|
1944
|
+
apiKey: "",
|
|
1945
|
+
reasoningEffort: ReasoningEffort.High
|
|
1986
1946
|
};
|
|
1987
1947
|
break;
|
|
1988
1948
|
default:
|
|
@@ -3455,7 +3415,6 @@ const estimateMessageTokens = (messages) => {
|
|
|
3455
3415
|
});
|
|
3456
3416
|
return textOnlyMessages.reduce((sum, msg) => sum + gpt4o.encode(typeof msg.content === "string" ? msg.content : "").length, 0) + estimatedImageTokens;
|
|
3457
3417
|
};
|
|
3458
|
-
const execFileAsync = util.promisify(child_process.execFile);
|
|
3459
3418
|
const fileLocks = /* @__PURE__ */ new Map();
|
|
3460
3419
|
const withFileLock = (filePath, operation) => {
|
|
3461
3420
|
logger.debug("Acquiring file lock:", { filePath });
|
|
@@ -3772,7 +3731,7 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3772
3731
|
return "Error: ripgrep binary is not available. Please try again or check the logs for details.";
|
|
3773
3732
|
}
|
|
3774
3733
|
try {
|
|
3775
|
-
const rgArgs = ["--no-heading", "--line-number", "--color", "never"
|
|
3734
|
+
const rgArgs = ["--no-heading", "--line-number", "--color", "never"];
|
|
3776
3735
|
if (!caseSensitive) {
|
|
3777
3736
|
rgArgs.push("-i");
|
|
3778
3737
|
}
|
|
@@ -3787,41 +3746,29 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3787
3746
|
args: rgArgs,
|
|
3788
3747
|
cwd: taskDir
|
|
3789
3748
|
});
|
|
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
3749
|
const results = [];
|
|
3804
3750
|
const outputLineRegex = /^(.+?)([:-])(\d+)\2(.*)$/;
|
|
3805
3751
|
let pendingBeforeContext = [];
|
|
3806
3752
|
let afterContextBreak = false;
|
|
3807
|
-
|
|
3753
|
+
let stderrData = "";
|
|
3754
|
+
let lineBuffer = "";
|
|
3755
|
+
const processLine = (rawLine) => {
|
|
3808
3756
|
if (rawLine.endsWith("\r")) {
|
|
3809
3757
|
rawLine = rawLine.slice(0, -1);
|
|
3810
3758
|
}
|
|
3811
3759
|
if (rawLine === "--") {
|
|
3812
3760
|
pendingBeforeContext = [];
|
|
3813
3761
|
afterContextBreak = true;
|
|
3814
|
-
|
|
3762
|
+
return false;
|
|
3815
3763
|
}
|
|
3816
|
-
const
|
|
3817
|
-
const match = outputLineRegex.exec(line);
|
|
3764
|
+
const match = outputLineRegex.exec(rawLine);
|
|
3818
3765
|
if (!match) {
|
|
3819
|
-
|
|
3766
|
+
return false;
|
|
3820
3767
|
}
|
|
3821
3768
|
const [, rawFilePath, separator, lineNumStr, content] = match;
|
|
3822
3769
|
const lineNum = parseInt(lineNumStr, 10);
|
|
3823
3770
|
if (isNaN(lineNum)) {
|
|
3824
|
-
|
|
3771
|
+
return false;
|
|
3825
3772
|
}
|
|
3826
3773
|
const filePath = rawFilePath.startsWith("./") ? rawFilePath.slice(2) : rawFilePath;
|
|
3827
3774
|
const isMatch = separator === ":";
|
|
@@ -3850,13 +3797,96 @@ Do not use escape characters \\ in the string like \\n or \\" and others. Do not
|
|
|
3850
3797
|
}
|
|
3851
3798
|
}
|
|
3852
3799
|
}
|
|
3853
|
-
|
|
3854
|
-
|
|
3800
|
+
return results.length >= maxResults;
|
|
3801
|
+
};
|
|
3802
|
+
let wasAborted = false;
|
|
3803
|
+
await new Promise((resolveStream) => {
|
|
3804
|
+
let streamResolved = false;
|
|
3805
|
+
let childProcess = null;
|
|
3806
|
+
let abortListener = null;
|
|
3807
|
+
const cleanup = () => {
|
|
3808
|
+
if (abortListener && abortSignal) {
|
|
3809
|
+
abortSignal.removeEventListener("abort", abortListener);
|
|
3810
|
+
}
|
|
3811
|
+
};
|
|
3812
|
+
const finish = () => {
|
|
3813
|
+
if (streamResolved) {
|
|
3814
|
+
return;
|
|
3815
|
+
}
|
|
3816
|
+
streamResolved = true;
|
|
3817
|
+
cleanup();
|
|
3818
|
+
resolveStream();
|
|
3819
|
+
};
|
|
3820
|
+
abortListener = () => {
|
|
3821
|
+
if (streamResolved) {
|
|
3822
|
+
return;
|
|
3823
|
+
}
|
|
3824
|
+
wasAborted = true;
|
|
3825
|
+
if (childProcess?.pid) {
|
|
3826
|
+
try {
|
|
3827
|
+
childProcess.kill("SIGKILL");
|
|
3828
|
+
} catch {
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3831
|
+
};
|
|
3832
|
+
abortSignal?.addEventListener("abort", abortListener);
|
|
3833
|
+
try {
|
|
3834
|
+
childProcess = child_process.spawn(RIPGREP_BINARY_PATH, rgArgs, {
|
|
3835
|
+
cwd: taskDir,
|
|
3836
|
+
env: { ...process.env, TERM: "dumb", PATH: getShellPath() },
|
|
3837
|
+
windowsHide: true
|
|
3838
|
+
});
|
|
3839
|
+
} catch (spawnError) {
|
|
3840
|
+
stderrData = spawnError instanceof Error ? spawnError.message : String(spawnError);
|
|
3841
|
+
finish();
|
|
3842
|
+
return;
|
|
3855
3843
|
}
|
|
3844
|
+
childProcess.stdout?.on("data", (data) => {
|
|
3845
|
+
if (streamResolved) {
|
|
3846
|
+
return;
|
|
3847
|
+
}
|
|
3848
|
+
lineBuffer += data.toString("utf-8");
|
|
3849
|
+
const lines = lineBuffer.split("\n");
|
|
3850
|
+
lineBuffer = lines.pop() || "";
|
|
3851
|
+
for (const rawLine of lines) {
|
|
3852
|
+
if (!rawLine) {
|
|
3853
|
+
continue;
|
|
3854
|
+
}
|
|
3855
|
+
const reachedLimit = processLine(rawLine);
|
|
3856
|
+
if (reachedLimit) {
|
|
3857
|
+
try {
|
|
3858
|
+
childProcess?.kill("SIGKILL");
|
|
3859
|
+
} catch {
|
|
3860
|
+
}
|
|
3861
|
+
finish();
|
|
3862
|
+
return;
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
});
|
|
3866
|
+
childProcess.stderr?.on("data", (data) => {
|
|
3867
|
+
stderrData += data.toString("utf-8");
|
|
3868
|
+
});
|
|
3869
|
+
childProcess.on("error", (error) => {
|
|
3870
|
+
if (!streamResolved) {
|
|
3871
|
+
stderrData = error.message;
|
|
3872
|
+
finish();
|
|
3873
|
+
}
|
|
3874
|
+
});
|
|
3875
|
+
childProcess.on("close", () => {
|
|
3876
|
+
if (!streamResolved && lineBuffer) {
|
|
3877
|
+
processLine(lineBuffer);
|
|
3878
|
+
lineBuffer = "";
|
|
3879
|
+
}
|
|
3880
|
+
finish();
|
|
3881
|
+
});
|
|
3882
|
+
});
|
|
3883
|
+
if (wasAborted || abortSignal?.aborted) {
|
|
3884
|
+
return "Operation was cancelled by user.";
|
|
3856
3885
|
}
|
|
3886
|
+
logger.debug("ripgrep results count:", { count: results.length, stderr: stderrData.substring(0, 500) });
|
|
3857
3887
|
if (results.length === 0) {
|
|
3858
|
-
if (
|
|
3859
|
-
return `Error during grep: ${
|
|
3888
|
+
if (stderrData.trim()) {
|
|
3889
|
+
return `Error during grep: ${stderrData.trim()}`;
|
|
3860
3890
|
}
|
|
3861
3891
|
return `No matches found for pattern '${searchTerm}' in files matching '${filePattern}'.`;
|
|
3862
3892
|
}
|
|
@@ -4150,8 +4180,24 @@ Format: ${format}`;
|
|
|
4150
4180
|
language: zod.z.string().optional().describe("Limit search to files of a specific programming language")
|
|
4151
4181
|
}),
|
|
4152
4182
|
execute: async (input, { toolCallId }) => {
|
|
4153
|
-
const { query: searchQuery, path: inputPath, allowTests, exact, maxTokens: paramMaxTokens, language } = input;
|
|
4154
|
-
task.addToolMessage(
|
|
4183
|
+
const { query: searchQuery, path: inputPath, allowTests, exact, maxResults: paramMaxResults, maxTokens: paramMaxTokens, language } = input;
|
|
4184
|
+
task.addToolMessage(
|
|
4185
|
+
toolCallId,
|
|
4186
|
+
POWER_TOOL_GROUP_NAME,
|
|
4187
|
+
POWER_TOOL_SEMANTIC_SEARCH,
|
|
4188
|
+
{
|
|
4189
|
+
query: searchQuery,
|
|
4190
|
+
path: inputPath,
|
|
4191
|
+
allowTests,
|
|
4192
|
+
exact,
|
|
4193
|
+
maxResults: paramMaxResults,
|
|
4194
|
+
maxTokens: paramMaxTokens,
|
|
4195
|
+
language
|
|
4196
|
+
},
|
|
4197
|
+
void 0,
|
|
4198
|
+
void 0,
|
|
4199
|
+
promptContext
|
|
4200
|
+
);
|
|
4155
4201
|
const toolName = `${POWER_TOOL_GROUP_NAME}${TOOL_GROUP_NAME_SEPARATOR}${POWER_TOOL_SEMANTIC_SEARCH}`;
|
|
4156
4202
|
const questionKey = toolName;
|
|
4157
4203
|
const questionText = "Approve running codebase search?";
|
|
@@ -4159,7 +4205,9 @@ Format: ${format}`;
|
|
|
4159
4205
|
Path: ${inputPath || "."}
|
|
4160
4206
|
Allow Tests: ${allowTests}
|
|
4161
4207
|
Exact: ${exact}
|
|
4162
|
-
|
|
4208
|
+
Max Results: ${paramMaxResults ?? "default"}
|
|
4209
|
+
Max Tokens: ${paramMaxTokens}
|
|
4210
|
+
Language: ${language || "all"}`;
|
|
4163
4211
|
const [isApproved, userInput] = await approvalManager.handleToolApproval(toolName, input, questionKey, questionText, questionSubject);
|
|
4164
4212
|
if (!isApproved) {
|
|
4165
4213
|
return `Search execution denied by user. Reason: ${userInput}`;
|
|
@@ -4194,6 +4242,13 @@ Language: ${language}`;
|
|
|
4194
4242
|
"rb",
|
|
4195
4243
|
"php",
|
|
4196
4244
|
"swift",
|
|
4245
|
+
"solidity",
|
|
4246
|
+
"sol",
|
|
4247
|
+
"crystal",
|
|
4248
|
+
"cr",
|
|
4249
|
+
"haskell",
|
|
4250
|
+
"hs",
|
|
4251
|
+
"lhs",
|
|
4197
4252
|
"csharp",
|
|
4198
4253
|
"cs",
|
|
4199
4254
|
"yaml",
|
|
@@ -4210,6 +4265,7 @@ Language: ${language}`;
|
|
|
4210
4265
|
// 5 minutes
|
|
4211
4266
|
json: false,
|
|
4212
4267
|
maxTokens: effectiveMaxTokens,
|
|
4268
|
+
maxResults: paramMaxResults,
|
|
4213
4269
|
language: effectiveLanguage
|
|
4214
4270
|
});
|
|
4215
4271
|
logger.debug(`Search results: ${JSON.stringify(results)}`);
|
|
@@ -6818,7 +6874,7 @@ ${fileList}${readOnlyNote}`
|
|
|
6818
6874
|
}
|
|
6819
6875
|
/**
|
|
6820
6876
|
* Recursively strips unsupported JSON Schema 2019-09 keywords that are not
|
|
6821
|
-
* recognized by some MCP servers
|
|
6877
|
+
* recognized by some MCP servers.
|
|
6822
6878
|
*/
|
|
6823
6879
|
stripUnsupportedSchemaKeywords(schema) {
|
|
6824
6880
|
const unsupportedKeywords = [
|
|
@@ -6856,7 +6912,7 @@ ${fileList}${readOnlyNote}`
|
|
|
6856
6912
|
return processObject(schema);
|
|
6857
6913
|
}
|
|
6858
6914
|
fixInputSchema(provider, inputSchema) {
|
|
6859
|
-
if (provider === "gemini"
|
|
6915
|
+
if (provider === "gemini") {
|
|
6860
6916
|
const fixedSchema = JSON.parse(JSON.stringify(inputSchema));
|
|
6861
6917
|
const strippedSchema = this.stripUnsupportedSchemaKeywords(fixedSchema);
|
|
6862
6918
|
if (strippedSchema.properties) {
|
|
@@ -6897,45 +6953,14 @@ ${fileList}${readOnlyNote}`
|
|
|
6897
6953
|
}
|
|
6898
6954
|
return inputSchema;
|
|
6899
6955
|
}
|
|
6900
|
-
async runAgent(task, profile, prompt, mode = "agent", promptContext, initialContextMessages, initialContextFiles, systemPrompt, includeInContext = true, abortSignal, images) {
|
|
6956
|
+
async runAgent(task, profile, prompt, mode = "agent", promptContext, initialContextMessages, initialContextFiles, systemPrompt, includeInContext = true, abortSignal, images, skillsToActivate) {
|
|
6901
6957
|
let contextMessages = initialContextMessages ?? await task.getContextMessages();
|
|
6902
6958
|
let contextFiles = initialContextFiles ?? await task.getContextFiles();
|
|
6903
6959
|
if (!systemPrompt) {
|
|
6904
6960
|
systemPrompt = await this.promptsManager.getSystemPrompt(this.store.getSettings(), task, profile);
|
|
6905
6961
|
}
|
|
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
6962
|
const settings = this.store.getSettings();
|
|
6937
6963
|
const projectProfiles = this.agentProfileManager.getProjectProfiles(task.project);
|
|
6938
|
-
let resultMessages = userRequestMessage ? [userRequestMessage] : [];
|
|
6939
6964
|
const providers = this.modelManager.getProviders();
|
|
6940
6965
|
let provider = providers.find((p) => p.id === profile.provider);
|
|
6941
6966
|
let modelName = profile.model;
|
|
@@ -6951,7 +6976,9 @@ ${fileList}${readOnlyNote}`
|
|
|
6951
6976
|
promptContext,
|
|
6952
6977
|
contextMessages,
|
|
6953
6978
|
contextFiles,
|
|
6954
|
-
systemPrompt
|
|
6979
|
+
systemPrompt,
|
|
6980
|
+
images,
|
|
6981
|
+
skillsToActivate
|
|
6955
6982
|
},
|
|
6956
6983
|
task.project,
|
|
6957
6984
|
task
|
|
@@ -6968,10 +6995,56 @@ ${fileList}${readOnlyNote}`
|
|
|
6968
6995
|
contextMessages = extensionResult.contextMessages;
|
|
6969
6996
|
contextFiles = extensionResult.contextFiles;
|
|
6970
6997
|
systemPrompt = extensionResult.systemPrompt;
|
|
6998
|
+
images = extensionResult.images ?? images;
|
|
6999
|
+
skillsToActivate = extensionResult.skillsToActivate;
|
|
7000
|
+
}
|
|
7001
|
+
const userRequestMessage = prompt ? {
|
|
7002
|
+
id: promptContext?.id || uuid.v4(),
|
|
7003
|
+
role: "user",
|
|
7004
|
+
content: images && images.length > 0 ? [
|
|
7005
|
+
{ type: "text", text: prompt },
|
|
7006
|
+
...images.map((dataUrl) => {
|
|
7007
|
+
const match = dataUrl.match(/^data:(image\/[^;]+);base64,(.+)$/);
|
|
7008
|
+
return {
|
|
7009
|
+
type: "image",
|
|
7010
|
+
image: match ? match[2] : dataUrl,
|
|
7011
|
+
mediaType: match ? match[1] : void 0
|
|
7012
|
+
};
|
|
7013
|
+
})
|
|
7014
|
+
] : prompt,
|
|
7015
|
+
promptContext,
|
|
7016
|
+
timestamp: Date.now()
|
|
7017
|
+
} : null;
|
|
7018
|
+
if (userRequestMessage) {
|
|
7019
|
+
logger.info("User request message created:", {
|
|
7020
|
+
id: userRequestMessage.id,
|
|
7021
|
+
contentType: typeof userRequestMessage.content === "string" ? "string" : "parts",
|
|
7022
|
+
...typeof userRequestMessage.content === "string" ? { contentPreview: userRequestMessage.content.substring(0, 200) } : {
|
|
7023
|
+
parts: userRequestMessage.content.map((part) => ({
|
|
7024
|
+
type: part.type,
|
|
7025
|
+
...part.type === "text" ? { textPreview: part.text?.substring(0, 100) } : {},
|
|
7026
|
+
...part.type === "image" ? { mediaType: part.mediaType, imagePreview: typeof part.image === "string" ? part.image.substring(0, 80) : typeof part.image } : {}
|
|
7027
|
+
}))
|
|
7028
|
+
}
|
|
7029
|
+
});
|
|
6971
7030
|
}
|
|
7031
|
+
let resultMessages = userRequestMessage ? [userRequestMessage] : [];
|
|
6972
7032
|
if (userRequestMessage && includeInContext) {
|
|
6973
7033
|
await task.addContextMessage(userRequestMessage);
|
|
6974
7034
|
}
|
|
7035
|
+
if (skillsToActivate && skillsToActivate.length > 0) {
|
|
7036
|
+
try {
|
|
7037
|
+
const skillMessages = await task.createSkillMessages(...skillsToActivate);
|
|
7038
|
+
if (skillMessages) {
|
|
7039
|
+
for (const message of skillMessages) {
|
|
7040
|
+
await task.addContextMessage(message);
|
|
7041
|
+
resultMessages.push(message);
|
|
7042
|
+
}
|
|
7043
|
+
}
|
|
7044
|
+
} catch (error) {
|
|
7045
|
+
logger.warn(`Failed to activate skills: ${error instanceof Error ? error.message : String(error)}`);
|
|
7046
|
+
}
|
|
7047
|
+
}
|
|
6975
7048
|
if (!provider) {
|
|
6976
7049
|
logger.error(`Provider ${profile.provider} not found`);
|
|
6977
7050
|
task.addLogMessage("error", "Selected model is not configured. Select another model and try again.", true, promptContext);
|
|
@@ -11055,11 +11128,11 @@ class ExtensionsApi extends BaseApi {
|
|
|
11055
11128
|
return;
|
|
11056
11129
|
}
|
|
11057
11130
|
const { extensionId, repositoryUrl, projectDir } = parsed;
|
|
11058
|
-
const
|
|
11059
|
-
if (success) {
|
|
11060
|
-
res.status(200).json({ message: "Extension installed successfully", success });
|
|
11131
|
+
const result = await this.eventsHandler.installExtension(extensionId, repositoryUrl, projectDir);
|
|
11132
|
+
if (result.success) {
|
|
11133
|
+
res.status(200).json({ message: "Extension installed successfully", success: true });
|
|
11061
11134
|
} else {
|
|
11062
|
-
res.status(500).json({ message: "Failed to install extension", success });
|
|
11135
|
+
res.status(500).json({ message: "Failed to install extension", success: false, error: result.error });
|
|
11063
11136
|
}
|
|
11064
11137
|
})
|
|
11065
11138
|
);
|
|
@@ -11087,11 +11160,11 @@ class ExtensionsApi extends BaseApi {
|
|
|
11087
11160
|
return;
|
|
11088
11161
|
}
|
|
11089
11162
|
const { extensionId, repositoryUrl, projectDir } = parsed;
|
|
11090
|
-
const
|
|
11091
|
-
if (success) {
|
|
11092
|
-
res.status(200).json({ message: "Extension updated successfully", success });
|
|
11163
|
+
const result = await this.eventsHandler.updateExtension(extensionId, repositoryUrl, projectDir);
|
|
11164
|
+
if (result.success) {
|
|
11165
|
+
res.status(200).json({ message: "Extension updated successfully", success: true });
|
|
11093
11166
|
} else {
|
|
11094
|
-
res.status(500).json({ message: "Failed to update extension", success });
|
|
11167
|
+
res.status(500).json({ message: "Failed to update extension", success: false, error: result.error });
|
|
11095
11168
|
}
|
|
11096
11169
|
})
|
|
11097
11170
|
);
|
|
@@ -13357,7 +13430,8 @@ const PROXY_ENV_VAR_NAMES = ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "http_pro
|
|
|
13357
13430
|
const getProxyEnvVars = (settings) => {
|
|
13358
13431
|
if (settings.proxy?.enabled && settings.proxy?.url) {
|
|
13359
13432
|
const url = settings.proxy.url;
|
|
13360
|
-
|
|
13433
|
+
const noProxy = settings.proxy.noProxy;
|
|
13434
|
+
const vars = {
|
|
13361
13435
|
HTTP_PROXY: url,
|
|
13362
13436
|
HTTPS_PROXY: url,
|
|
13363
13437
|
ALL_PROXY: url,
|
|
@@ -13365,6 +13439,11 @@ const getProxyEnvVars = (settings) => {
|
|
|
13365
13439
|
https_proxy: url,
|
|
13366
13440
|
all_proxy: url
|
|
13367
13441
|
};
|
|
13442
|
+
if (noProxy) {
|
|
13443
|
+
vars.NO_PROXY = noProxy;
|
|
13444
|
+
vars.no_proxy = noProxy;
|
|
13445
|
+
}
|
|
13446
|
+
return vars;
|
|
13368
13447
|
}
|
|
13369
13448
|
return Object.fromEntries(PROXY_ENV_VAR_NAMES.map((key) => [key, ""]));
|
|
13370
13449
|
};
|
|
@@ -13376,7 +13455,7 @@ class ProxyManager {
|
|
|
13376
13455
|
init(settings) {
|
|
13377
13456
|
globalAgent.bootstrap();
|
|
13378
13457
|
if (settings.proxy?.enabled && settings.proxy?.url) {
|
|
13379
|
-
this.applyProxy(settings.proxy.url);
|
|
13458
|
+
this.applyProxy(settings.proxy.url, settings.proxy.noProxy);
|
|
13380
13459
|
} else {
|
|
13381
13460
|
this.clearProxy();
|
|
13382
13461
|
}
|
|
@@ -13388,20 +13467,25 @@ class ProxyManager {
|
|
|
13388
13467
|
settingsChanged(oldSettings, newSettings) {
|
|
13389
13468
|
const oldProxy = oldSettings.proxy;
|
|
13390
13469
|
const newProxy = newSettings.proxy;
|
|
13391
|
-
if (oldProxy?.enabled !== newProxy?.enabled || oldProxy?.url !== newProxy?.url) {
|
|
13470
|
+
if (oldProxy?.enabled !== newProxy?.enabled || oldProxy?.url !== newProxy?.url || oldProxy?.noProxy !== newProxy?.noProxy) {
|
|
13392
13471
|
if (newProxy?.enabled && newProxy?.url) {
|
|
13393
13472
|
logger.info(`[ProxyManager] Applying proxy: ${newProxy.url}`);
|
|
13394
|
-
this.applyProxy(newProxy.url);
|
|
13473
|
+
this.applyProxy(newProxy.url, newProxy.noProxy);
|
|
13395
13474
|
} else if (this.currentUrl !== null) {
|
|
13396
13475
|
logger.info("[ProxyManager] Clearing proxy");
|
|
13397
13476
|
this.clearProxy();
|
|
13398
13477
|
}
|
|
13399
13478
|
}
|
|
13400
13479
|
}
|
|
13401
|
-
applyProxy(url) {
|
|
13480
|
+
applyProxy(url, noProxy) {
|
|
13402
13481
|
try {
|
|
13403
13482
|
global.GLOBAL_AGENT.HTTP_PROXY = url;
|
|
13404
|
-
|
|
13483
|
+
global.GLOBAL_AGENT.NO_PROXY = noProxy || void 0;
|
|
13484
|
+
const proxyAgent = new undici.EnvHttpProxyAgent({
|
|
13485
|
+
httpProxy: url,
|
|
13486
|
+
httpsProxy: url,
|
|
13487
|
+
noProxy: noProxy || void 0
|
|
13488
|
+
});
|
|
13405
13489
|
undici.setGlobalDispatcher(proxyAgent);
|
|
13406
13490
|
this.currentUrl = url;
|
|
13407
13491
|
logger.info(`[ProxyManager] Proxy initialized: ${url}`);
|
|
@@ -13412,6 +13496,7 @@ class ProxyManager {
|
|
|
13412
13496
|
clearProxy() {
|
|
13413
13497
|
try {
|
|
13414
13498
|
global.GLOBAL_AGENT.HTTP_PROXY = void 0;
|
|
13499
|
+
global.GLOBAL_AGENT.NO_PROXY = void 0;
|
|
13415
13500
|
undici.setGlobalDispatcher(
|
|
13416
13501
|
new undici.Agent({
|
|
13417
13502
|
headersTimeout: 30 * 60 * 1e3,
|
|
@@ -14380,6 +14465,60 @@ class WorktreeManager {
|
|
|
14380
14465
|
return void 0;
|
|
14381
14466
|
}
|
|
14382
14467
|
}
|
|
14468
|
+
/**
|
|
14469
|
+
* Check if a commit is an ancestor of another commit (or HEAD).
|
|
14470
|
+
* Returns true if `ancestorCommit` is reachable from `descendantRef`.
|
|
14471
|
+
*/
|
|
14472
|
+
async isCommitAncestorOf(worktreePath, ancestorCommit, descendantRef = "HEAD") {
|
|
14473
|
+
try {
|
|
14474
|
+
await execWithShellPath(`git merge-base --is-ancestor ${ancestorCommit} ${descendantRef}`, { cwd: worktreePath });
|
|
14475
|
+
return true;
|
|
14476
|
+
} catch {
|
|
14477
|
+
return false;
|
|
14478
|
+
}
|
|
14479
|
+
}
|
|
14480
|
+
/**
|
|
14481
|
+
* Get the "onto" commit from an active rebase.
|
|
14482
|
+
* Returns undefined if no rebase is in progress or the file doesn't exist.
|
|
14483
|
+
*/
|
|
14484
|
+
async getRebaseOntoCommit(worktreePath) {
|
|
14485
|
+
try {
|
|
14486
|
+
const { stdout: rebaseMergePath } = await execWithShellPath("git rev-parse --git-path rebase-merge", { cwd: worktreePath });
|
|
14487
|
+
const ontoPath = `${rebaseMergePath.trim()}/onto`;
|
|
14488
|
+
try {
|
|
14489
|
+
const { stdout: ontoCommit } = await execWithShellPath(`cat "${ontoPath}"`, { cwd: worktreePath });
|
|
14490
|
+
if (ontoCommit.trim()) {
|
|
14491
|
+
return ontoCommit.trim();
|
|
14492
|
+
}
|
|
14493
|
+
} catch {
|
|
14494
|
+
}
|
|
14495
|
+
const { stdout: rebaseApplyPath } = await execWithShellPath("git rev-parse --git-path rebase-apply", { cwd: worktreePath });
|
|
14496
|
+
const ontoApplyPath = `${rebaseApplyPath.trim()}/onto`;
|
|
14497
|
+
try {
|
|
14498
|
+
const { stdout: ontoCommit } = await execWithShellPath(`cat "${ontoApplyPath}"`, { cwd: worktreePath });
|
|
14499
|
+
if (ontoCommit.trim()) {
|
|
14500
|
+
return ontoCommit.trim();
|
|
14501
|
+
}
|
|
14502
|
+
} catch {
|
|
14503
|
+
}
|
|
14504
|
+
return void 0;
|
|
14505
|
+
} catch {
|
|
14506
|
+
return void 0;
|
|
14507
|
+
}
|
|
14508
|
+
}
|
|
14509
|
+
/**
|
|
14510
|
+
* Resolve a commit to the branch name that points to it.
|
|
14511
|
+
* Returns the first branch found, or undefined if no branch points to that exact commit.
|
|
14512
|
+
*/
|
|
14513
|
+
async getBranchPointingAtCommit(projectPath, commit) {
|
|
14514
|
+
try {
|
|
14515
|
+
const { stdout } = await execWithShellPath(`git branch --points-at ${commit} --format='%(refname:short)'`, { cwd: projectPath });
|
|
14516
|
+
const branches = stdout.trim().split("\n").map((b) => b.trim()).filter((b) => b && !b.includes("(") && !b.includes("HEAD"));
|
|
14517
|
+
return branches.length > 0 ? branches[0] : void 0;
|
|
14518
|
+
} catch {
|
|
14519
|
+
return void 0;
|
|
14520
|
+
}
|
|
14521
|
+
}
|
|
14383
14522
|
async getBranchesContainingCommit(projectPath, commit) {
|
|
14384
14523
|
try {
|
|
14385
14524
|
const { stdout } = await execWithShellPath(`git branch --contains ${commit} --format='%(refname:short)'`, { cwd: projectPath });
|
|
@@ -14488,7 +14627,15 @@ class WorktreeManager {
|
|
|
14488
14627
|
});
|
|
14489
14628
|
logger.info("Created temporary commit for uncommitted changes");
|
|
14490
14629
|
}
|
|
14491
|
-
|
|
14630
|
+
let effectiveBaseCommit = baseCommit;
|
|
14631
|
+
if (baseCommit) {
|
|
14632
|
+
const isValid = await this.isCommitAncestorOf(worktreePath, baseCommit);
|
|
14633
|
+
if (!isValid) {
|
|
14634
|
+
logger.warn(`baseCommit ${baseCommit} is not an ancestor of HEAD, falling back to simple rebase`, { worktreePath, mainBranch });
|
|
14635
|
+
effectiveBaseCommit = void 0;
|
|
14636
|
+
}
|
|
14637
|
+
}
|
|
14638
|
+
const command = effectiveBaseCommit ? `git rebase --onto ${mainBranch} ${effectiveBaseCommit}` : `git rebase ${mainBranch}`;
|
|
14492
14639
|
executedCommands.push(`${command} (in ${worktreePath})`);
|
|
14493
14640
|
const rebaseResult = await execWithShellPath(command, {
|
|
14494
14641
|
cwd: worktreePath
|
|
@@ -14541,6 +14688,11 @@ class WorktreeManager {
|
|
|
14541
14688
|
return await withLock(`git-rebase-continue-${worktreePath}`, async () => {
|
|
14542
14689
|
const executedCommands = [];
|
|
14543
14690
|
let lastOutput = "";
|
|
14691
|
+
const ontoCommit = await this.getRebaseOntoCommit(worktreePath);
|
|
14692
|
+
let ontoBranch;
|
|
14693
|
+
if (ontoCommit) {
|
|
14694
|
+
ontoBranch = await this.getBranchPointingAtCommit(worktreePath, ontoCommit);
|
|
14695
|
+
}
|
|
14544
14696
|
try {
|
|
14545
14697
|
const command = "git rebase --continue";
|
|
14546
14698
|
executedCommands.push(`${command} (in ${worktreePath})`);
|
|
@@ -14551,6 +14703,7 @@ class WorktreeManager {
|
|
|
14551
14703
|
lastOutput = result.stdout || result.stderr || "";
|
|
14552
14704
|
await this.resetTempCommitIfExists(worktreePath);
|
|
14553
14705
|
logger.info("Successfully handled temporary commit after continue rebase");
|
|
14706
|
+
return { ontoCommit, ontoBranch };
|
|
14554
14707
|
} catch (error) {
|
|
14555
14708
|
const err = error;
|
|
14556
14709
|
logger.error(`Failed to continue rebase in ${worktreePath}:`, err);
|
|
@@ -14579,7 +14732,15 @@ class WorktreeManager {
|
|
|
14579
14732
|
if (!commits.trim()) {
|
|
14580
14733
|
return;
|
|
14581
14734
|
}
|
|
14582
|
-
|
|
14735
|
+
let effectiveBaseCommit = baseCommit;
|
|
14736
|
+
if (baseCommit) {
|
|
14737
|
+
const isValid = await this.isCommitAncestorOf(worktreePath, baseCommit);
|
|
14738
|
+
if (!isValid) {
|
|
14739
|
+
logger.warn(`baseCommit ${baseCommit} is not an ancestor of HEAD, falling back to simple rebase`, { worktreePath, mainBranch });
|
|
14740
|
+
effectiveBaseCommit = void 0;
|
|
14741
|
+
}
|
|
14742
|
+
}
|
|
14743
|
+
command = effectiveBaseCommit ? `git rebase --onto ${mainBranch} ${effectiveBaseCommit}` : `git rebase ${mainBranch}`;
|
|
14583
14744
|
executedCommands.push(`${command} (in ${worktreePath})`);
|
|
14584
14745
|
try {
|
|
14585
14746
|
const rebaseWorktreeResult = await execWithShellPath(command, {
|
|
@@ -15578,7 +15739,7 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15578
15739
|
*/
|
|
15579
15740
|
async resetTempCommit(worktreePath) {
|
|
15580
15741
|
try {
|
|
15581
|
-
await execWithShellPath("git reset --
|
|
15742
|
+
await execWithShellPath("git reset --soft HEAD^", { cwd: worktreePath });
|
|
15582
15743
|
} catch (error) {
|
|
15583
15744
|
logger.error("Failed to reset temp commit:", error);
|
|
15584
15745
|
throw new Error(`Failed to restore uncommitted changes: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -15740,15 +15901,120 @@ Git output: ${err.stderr || err.stdout || err.message}`
|
|
|
15740
15901
|
}
|
|
15741
15902
|
}
|
|
15742
15903
|
}
|
|
15904
|
+
async mergeWorktreeToWorktree(sourceWorktreeDir, targetWorktreeDir, includeUncommitted = false) {
|
|
15905
|
+
logger.info("Merging worktree to worktree", {
|
|
15906
|
+
sourceWorktreeDir,
|
|
15907
|
+
targetWorktreeDir,
|
|
15908
|
+
includeUncommitted
|
|
15909
|
+
});
|
|
15910
|
+
if (sourceWorktreeDir === targetWorktreeDir) {
|
|
15911
|
+
logger.warn("Source and target worktree directories are the same, skipping merge");
|
|
15912
|
+
return;
|
|
15913
|
+
}
|
|
15914
|
+
const { stdout: sourceHead } = await execWithShellPath("git rev-parse HEAD", { cwd: sourceWorktreeDir });
|
|
15915
|
+
const { stdout: targetHead } = await execWithShellPath("git rev-parse HEAD", { cwd: targetWorktreeDir });
|
|
15916
|
+
const sourceCommit = sourceHead.trim();
|
|
15917
|
+
const targetCommit = targetHead.trim();
|
|
15918
|
+
if (sourceCommit === targetCommit) {
|
|
15919
|
+
logger.info("Source and target worktrees are at the same commit, skipping commit merge");
|
|
15920
|
+
} else {
|
|
15921
|
+
const { stdout: mergeBase } = await execWithShellPath(`git merge-base ${sourceCommit} ${targetCommit}`, {
|
|
15922
|
+
cwd: targetWorktreeDir
|
|
15923
|
+
});
|
|
15924
|
+
const baseCommit = mergeBase.trim();
|
|
15925
|
+
if (baseCommit === sourceCommit) {
|
|
15926
|
+
logger.info("Source worktree has no commits ahead of target, skipping commit merge");
|
|
15927
|
+
} else if (baseCommit === targetCommit) {
|
|
15928
|
+
logger.info("Target worktree is at merge base, fast-forwarding to source HEAD");
|
|
15929
|
+
try {
|
|
15930
|
+
await execWithShellPath(`git merge --ff-only ${sourceCommit}`, { cwd: targetWorktreeDir });
|
|
15931
|
+
logger.info("Successfully fast-forwarded target worktree to source HEAD");
|
|
15932
|
+
} catch (error) {
|
|
15933
|
+
logger.error("Failed to fast-forward target worktree:", { error });
|
|
15934
|
+
throw new Error(`Failed to fast-forward target worktree to source HEAD. Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
15935
|
+
}
|
|
15936
|
+
} else {
|
|
15937
|
+
logger.info("Worktrees have diverged, cherry-picking source commits onto target");
|
|
15938
|
+
const { stdout: commits } = await execWithShellPath(`git log --reverse --format=%H ${baseCommit}..${sourceCommit}`, {
|
|
15939
|
+
cwd: sourceWorktreeDir
|
|
15940
|
+
});
|
|
15941
|
+
const commitList = commits.trim().split("\n").filter(Boolean);
|
|
15942
|
+
if (commitList.length === 0) {
|
|
15943
|
+
logger.info("No commits to cherry-pick");
|
|
15944
|
+
} else {
|
|
15945
|
+
for (const commitHash of commitList) {
|
|
15946
|
+
try {
|
|
15947
|
+
await execWithShellPath(`git cherry-pick ${commitHash}`, { cwd: targetWorktreeDir });
|
|
15948
|
+
logger.debug(`Cherry-picked commit ${commitHash.substring(0, 8)}`);
|
|
15949
|
+
} catch (error) {
|
|
15950
|
+
try {
|
|
15951
|
+
await execWithShellPath("git cherry-pick --abort", { cwd: targetWorktreeDir });
|
|
15952
|
+
} catch {
|
|
15953
|
+
}
|
|
15954
|
+
throw new Error(
|
|
15955
|
+
`Failed to cherry-pick commit ${commitHash.substring(0, 8)} onto target worktree. Cherry-pick aborted. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
15956
|
+
);
|
|
15957
|
+
}
|
|
15958
|
+
}
|
|
15959
|
+
logger.info(`Successfully cherry-picked ${commitList.length} commit(s) onto target worktree`);
|
|
15960
|
+
}
|
|
15961
|
+
}
|
|
15962
|
+
}
|
|
15963
|
+
if (includeUncommitted) {
|
|
15964
|
+
const hasChanges = await this.hasUncommittedChanges(sourceWorktreeDir);
|
|
15965
|
+
if (!hasChanges) {
|
|
15966
|
+
logger.info("No uncommitted changes in source worktree, skipping uncommitted merge");
|
|
15967
|
+
return;
|
|
15968
|
+
}
|
|
15969
|
+
const timestamp = Date.now();
|
|
15970
|
+
const stashId = `worktree-to-worktree-${timestamp}`;
|
|
15971
|
+
try {
|
|
15972
|
+
const stashResult = await this.stashUncommittedChanges(stashId, sourceWorktreeDir, "Uncommitted changes carried over to target worktree");
|
|
15973
|
+
if (!stashResult) {
|
|
15974
|
+
logger.info("No changes to carry over after stash attempt");
|
|
15975
|
+
return;
|
|
15976
|
+
}
|
|
15977
|
+
try {
|
|
15978
|
+
await this.applyStash(targetWorktreeDir, stashId);
|
|
15979
|
+
await this.applyStash(sourceWorktreeDir, stashId);
|
|
15980
|
+
} catch (error) {
|
|
15981
|
+
logger.error("Failed to apply stash to worktrees:", { error });
|
|
15982
|
+
try {
|
|
15983
|
+
await this.applyStash(sourceWorktreeDir, stashId);
|
|
15984
|
+
} catch (restoreError) {
|
|
15985
|
+
logger.error("Failed to restore stash to source worktree:", { error: restoreError, stashId });
|
|
15986
|
+
throw new Error(
|
|
15987
|
+
`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)}`
|
|
15988
|
+
);
|
|
15989
|
+
}
|
|
15990
|
+
throw new Error(
|
|
15991
|
+
`Failed to apply stashed changes to target worktree. Changes have been restored to source worktree. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
15992
|
+
);
|
|
15993
|
+
}
|
|
15994
|
+
await this.dropStash(sourceWorktreeDir, stashId);
|
|
15995
|
+
} catch (error) {
|
|
15996
|
+
logger.error("Failed to carry over uncommitted changes:", { error });
|
|
15997
|
+
throw error;
|
|
15998
|
+
}
|
|
15999
|
+
}
|
|
16000
|
+
}
|
|
15743
16001
|
async close(projectDir) {
|
|
15744
16002
|
logger.info("Closing worktree manager");
|
|
15745
16003
|
await this.pruneDeleted(projectDir);
|
|
15746
16004
|
}
|
|
15747
16005
|
}
|
|
16006
|
+
const VERBOSE_COMPACT_WINDOW = 50;
|
|
16007
|
+
const VERBOSE_TOOL_INPUT_THRESHOLD = 150;
|
|
15748
16008
|
var CompactionLevel = /* @__PURE__ */ ((CompactionLevel2) => {
|
|
15749
16009
|
CompactionLevel2[CompactionLevel2["One"] = 1] = "One";
|
|
15750
16010
|
CompactionLevel2[CompactionLevel2["Two"] = 2] = "Two";
|
|
15751
16011
|
CompactionLevel2[CompactionLevel2["Three"] = 3] = "Three";
|
|
16012
|
+
CompactionLevel2[CompactionLevel2["Four"] = 4] = "Four";
|
|
16013
|
+
CompactionLevel2[CompactionLevel2["Five"] = 5] = "Five";
|
|
16014
|
+
CompactionLevel2[
|
|
16015
|
+
CompactionLevel2["Max"] = 5
|
|
16016
|
+
/* Five */
|
|
16017
|
+
] = "Max";
|
|
15752
16018
|
return CompactionLevel2;
|
|
15753
16019
|
})(CompactionLevel || {});
|
|
15754
16020
|
const extractFilePath = (args) => {
|
|
@@ -15961,6 +16227,8 @@ const smartCompactMessages = async (messages, protectedMessageCount = 10, compac
|
|
|
15961
16227
|
result = compactBashOutputs(result, protectedMessageCount, compactionLevel);
|
|
15962
16228
|
result = redactFetchOutputs(result, protectedMessageCount);
|
|
15963
16229
|
result = await truncateNonPowerToolResults(result, protectedMessageCount, compactionLevel);
|
|
16230
|
+
result = removeVerboseToolCalls(result, protectedMessageCount, compactionLevel);
|
|
16231
|
+
result = removeReasoningFromAssistant(result, protectedMessageCount, compactionLevel);
|
|
15964
16232
|
result = mergeConsecutiveAssistantMessages(result);
|
|
15965
16233
|
return result;
|
|
15966
16234
|
};
|
|
@@ -16441,6 +16709,64 @@ const compactBashOutputs = (messages, protectedMessageCount = 10, compactionLeve
|
|
|
16441
16709
|
}
|
|
16442
16710
|
return messages;
|
|
16443
16711
|
};
|
|
16712
|
+
const removeVerboseToolCalls = (messages, protectedMessageCount = 10, compactionLevel = 1) => {
|
|
16713
|
+
if (compactionLevel < 4) {
|
|
16714
|
+
return messages;
|
|
16715
|
+
}
|
|
16716
|
+
const protectedStart = getProtectedStartIndex(messages, Math.max(protectedMessageCount, VERBOSE_COMPACT_WINDOW));
|
|
16717
|
+
for (let i = protectedStart - 1; i >= 0; i--) {
|
|
16718
|
+
if (i >= messages.length) {
|
|
16719
|
+
continue;
|
|
16720
|
+
}
|
|
16721
|
+
const msg = messages[i];
|
|
16722
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
16723
|
+
continue;
|
|
16724
|
+
}
|
|
16725
|
+
const toolCallIdsToRemove = [];
|
|
16726
|
+
for (let j = msg.content.length - 1; j >= 0; j--) {
|
|
16727
|
+
const part = msg.content[j];
|
|
16728
|
+
if (part.type !== "tool-call") {
|
|
16729
|
+
continue;
|
|
16730
|
+
}
|
|
16731
|
+
const inputStr = JSON.stringify(part.input);
|
|
16732
|
+
if (inputStr.length > VERBOSE_TOOL_INPUT_THRESHOLD) {
|
|
16733
|
+
toolCallIdsToRemove.push(part.toolCallId);
|
|
16734
|
+
msg.content.splice(j, 1);
|
|
16735
|
+
}
|
|
16736
|
+
}
|
|
16737
|
+
for (const toolCallId of toolCallIdsToRemove) {
|
|
16738
|
+
removeToolResult(messages, toolCallId);
|
|
16739
|
+
}
|
|
16740
|
+
if (Array.isArray(msg.content) && msg.content.length === 0) {
|
|
16741
|
+
messages.splice(i, 1);
|
|
16742
|
+
}
|
|
16743
|
+
}
|
|
16744
|
+
return messages;
|
|
16745
|
+
};
|
|
16746
|
+
const removeReasoningFromAssistant = (messages, protectedMessageCount = 10, compactionLevel = 1) => {
|
|
16747
|
+
if (compactionLevel < 5) {
|
|
16748
|
+
return messages;
|
|
16749
|
+
}
|
|
16750
|
+
const protectedStart = getProtectedStartIndex(messages, Math.max(protectedMessageCount, VERBOSE_COMPACT_WINDOW));
|
|
16751
|
+
for (let i = protectedStart - 1; i >= 0; i--) {
|
|
16752
|
+
if (i >= messages.length) {
|
|
16753
|
+
continue;
|
|
16754
|
+
}
|
|
16755
|
+
const msg = messages[i];
|
|
16756
|
+
if (msg.role !== "assistant" || !Array.isArray(msg.content)) {
|
|
16757
|
+
continue;
|
|
16758
|
+
}
|
|
16759
|
+
const hadReasoning = msg.content.some((p) => p.type === "reasoning");
|
|
16760
|
+
if (!hadReasoning) {
|
|
16761
|
+
continue;
|
|
16762
|
+
}
|
|
16763
|
+
msg.content = msg.content.filter((p) => p.type !== "reasoning");
|
|
16764
|
+
if (msg.content.length === 0) {
|
|
16765
|
+
messages.splice(i, 1);
|
|
16766
|
+
}
|
|
16767
|
+
}
|
|
16768
|
+
return messages;
|
|
16769
|
+
};
|
|
16444
16770
|
const redactFetchOutputs = (messages, protectedMessageCount = 10) => {
|
|
16445
16771
|
const protectedStart = getProtectedStartIndex(messages, protectedMessageCount);
|
|
16446
16772
|
for (let i = 0; i < protectedStart; i++) {
|
|
@@ -17168,7 +17494,7 @@ class Task {
|
|
|
17168
17494
|
}
|
|
17169
17495
|
return responses;
|
|
17170
17496
|
}
|
|
17171
|
-
async runPromptInAgent(profile, mode, prompt, promptContext = { id: uuid.v4() }, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true, images) {
|
|
17497
|
+
async runPromptInAgent(profile, mode, prompt, promptContext = { id: uuid.v4() }, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true, images, skillsToActivate) {
|
|
17172
17498
|
if (waitForCurrentAgentToFinish) {
|
|
17173
17499
|
await this.waitForCurrentAgentToFinish();
|
|
17174
17500
|
}
|
|
@@ -17191,7 +17517,8 @@ class Task {
|
|
|
17191
17517
|
systemPrompt,
|
|
17192
17518
|
true,
|
|
17193
17519
|
void 0,
|
|
17194
|
-
images
|
|
17520
|
+
images,
|
|
17521
|
+
skillsToActivate
|
|
17195
17522
|
);
|
|
17196
17523
|
if (agentMessages.length > 0) {
|
|
17197
17524
|
this.contextManager.toConnectorMessages(agentMessages).forEach((message) => {
|
|
@@ -17302,6 +17629,7 @@ ${contentText}</agent-response>`;
|
|
|
17302
17629
|
const modelId = this.getAuxiliaryModelId(agentProfile, settings.taskSettings.taskStateModel);
|
|
17303
17630
|
this.addLogMessage("loading", "Updating task state...");
|
|
17304
17631
|
const answer = await this.agent.generateText(modelId, await this.promptsManager.getUpdateTaskStatePrompt(this), wrappedMessage, this.getProjectDir());
|
|
17632
|
+
this.addLogMessage("loading", void 0, true);
|
|
17305
17633
|
if (!answer) {
|
|
17306
17634
|
logger.warn("Task state determination interrupted");
|
|
17307
17635
|
return null;
|
|
@@ -18151,42 +18479,59 @@ ${contentText}</agent-response>`;
|
|
|
18151
18479
|
const contextMessages = await this.contextManager.getContextMessages();
|
|
18152
18480
|
return this.skillManager.getSkills(contextMessages);
|
|
18153
18481
|
}
|
|
18154
|
-
async
|
|
18482
|
+
async createSkillMessages(...skillNames) {
|
|
18483
|
+
if (skillNames.length === 0) {
|
|
18484
|
+
return null;
|
|
18485
|
+
}
|
|
18155
18486
|
const contextMessages = await this.contextManager.getContextMessages();
|
|
18156
18487
|
const activatedNames = this.skillManager.getActivatedSkillNames(contextMessages);
|
|
18157
|
-
|
|
18158
|
-
|
|
18159
|
-
|
|
18488
|
+
const allMessages = [];
|
|
18489
|
+
for (const skillName of skillNames) {
|
|
18490
|
+
if (activatedNames.has(skillName)) {
|
|
18491
|
+
logger.debug("Skill already activated, skipping", { skillName });
|
|
18492
|
+
continue;
|
|
18493
|
+
}
|
|
18494
|
+
const content = await this.skillManager.getSkillContent(skillName);
|
|
18495
|
+
if (!content) {
|
|
18496
|
+
throw new Error(`Skill '${skillName}' not found`);
|
|
18497
|
+
}
|
|
18498
|
+
const [assistantMessage, toolMessage] = this.skillManager.buildActivateSkillMessages(skillName, content);
|
|
18499
|
+
await this.processResponseMessage(
|
|
18500
|
+
{
|
|
18501
|
+
id: assistantMessage.id,
|
|
18502
|
+
action: "response",
|
|
18503
|
+
content: "User requested the skill activation.",
|
|
18504
|
+
finished: true
|
|
18505
|
+
},
|
|
18506
|
+
false
|
|
18507
|
+
);
|
|
18508
|
+
const toolCallId = toolMessage.content[0].toolCallId;
|
|
18509
|
+
this.addToolMessage(
|
|
18510
|
+
toolCallId,
|
|
18511
|
+
SKILLS_TOOL_GROUP_NAME,
|
|
18512
|
+
SKILLS_TOOL_ACTIVATE_SKILL,
|
|
18513
|
+
{ skill: skillName },
|
|
18514
|
+
JSON.stringify(content),
|
|
18515
|
+
void 0,
|
|
18516
|
+
void 0,
|
|
18517
|
+
false,
|
|
18518
|
+
true
|
|
18519
|
+
);
|
|
18520
|
+
allMessages.push(assistantMessage, toolMessage);
|
|
18521
|
+
activatedNames.add(skillName);
|
|
18160
18522
|
}
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18523
|
+
return allMessages.length > 0 ? allMessages : null;
|
|
18524
|
+
}
|
|
18525
|
+
async activateSkill(skillName) {
|
|
18526
|
+
const messages = await this.createSkillMessages(skillName);
|
|
18527
|
+
if (!messages) {
|
|
18528
|
+
return null;
|
|
18529
|
+
}
|
|
18530
|
+
for (const message of messages) {
|
|
18531
|
+
this.contextManager.addContextMessage(message);
|
|
18164
18532
|
}
|
|
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
18533
|
await this.updateContextInfo();
|
|
18534
|
+
return [messages[0], messages[1]];
|
|
18190
18535
|
}
|
|
18191
18536
|
async deactivateSkill(skillName) {
|
|
18192
18537
|
const contextMessages = await this.contextManager.getContextMessages();
|
|
@@ -18700,7 +19045,7 @@ ${contentText}</agent-response>`;
|
|
|
18700
19045
|
messagesSinceLastCompaction,
|
|
18701
19046
|
smartCompactionLevel: this.smartCompactionLevel
|
|
18702
19047
|
});
|
|
18703
|
-
this.smartCompactionLevel = Math.min(this.smartCompactionLevel + 1, CompactionLevel.
|
|
19048
|
+
this.smartCompactionLevel = Math.min(this.smartCompactionLevel + 1, CompactionLevel.Max);
|
|
18704
19049
|
} else if (messagesSinceLastCompaction > 5 && this.smartCompactionLevel > CompactionLevel.One) {
|
|
18705
19050
|
logger.info("Decreasing compaction level to mild due to high message count since last compaction.", {
|
|
18706
19051
|
messagesSinceLastCompaction
|
|
@@ -19185,15 +19530,6 @@ ${error.stderr}`,
|
|
|
19185
19530
|
this.addLogMessage("error", "No active Agent profile found");
|
|
19186
19531
|
return;
|
|
19187
19532
|
}
|
|
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
19533
|
const systemPrompt = await this.promptsManager.getSystemPrompt(
|
|
19198
19534
|
this.store.getSettings(),
|
|
19199
19535
|
this,
|
|
@@ -19203,7 +19539,7 @@ ${error.stderr}`,
|
|
|
19203
19539
|
const messages = command.includeContext === false ? [] : void 0;
|
|
19204
19540
|
const contextFiles = command.includeContext === false ? [] : void 0;
|
|
19205
19541
|
this.addLogMessage("loading", "Executing custom command...");
|
|
19206
|
-
await this.runPromptInAgent(profile, mode, prompt, promptContext, messages, contextFiles, systemPrompt);
|
|
19542
|
+
await this.runPromptInAgent(profile, mode, prompt, promptContext, messages, contextFiles, systemPrompt, true, true, void 0, command.skills);
|
|
19207
19543
|
} else {
|
|
19208
19544
|
this.addLogMessage("loading", "Executing custom command...");
|
|
19209
19545
|
await this.runPromptInAider(mode, prompt, promptContext);
|
|
@@ -19325,6 +19661,7 @@ ${error.stderr}`,
|
|
|
19325
19661
|
}
|
|
19326
19662
|
void this.sendUpdatedFilesUpdated();
|
|
19327
19663
|
void this.sendWorktreeIntegrationStatusUpdated();
|
|
19664
|
+
await this.updateAutocompletionData(void 0, true);
|
|
19328
19665
|
return true;
|
|
19329
19666
|
}
|
|
19330
19667
|
async mergeWorktreeToMain(squash, targetBranch, commitMessage) {
|
|
@@ -19461,6 +19798,7 @@ Only answer with the commit message, nothing else.`,
|
|
|
19461
19798
|
}
|
|
19462
19799
|
}
|
|
19463
19800
|
await this.updateTask({ workingMode: "local" });
|
|
19801
|
+
await this.updateAutocompletionData(void 0, true);
|
|
19464
19802
|
}
|
|
19465
19803
|
async switchToWorktreeWorkingMode(options) {
|
|
19466
19804
|
logger.info("Switching to worktree working mode", {
|
|
@@ -19489,10 +19827,30 @@ Only answer with the commit message, nothing else.`,
|
|
|
19489
19827
|
}
|
|
19490
19828
|
} catch (error) {
|
|
19491
19829
|
logger.error("Failed to stash uncommitted changes before worktree switch:", { error });
|
|
19492
|
-
|
|
19830
|
+
throw new Error(`Failed to stash uncommitted changes: ${error instanceof Error ? error.message : String(error)}`);
|
|
19493
19831
|
}
|
|
19494
19832
|
}
|
|
19495
|
-
await this.
|
|
19833
|
+
const existingWorktree = await this.worktreeManager.getTaskWorktree(this.project.baseDir, this.taskId);
|
|
19834
|
+
if (!existingWorktree && !this.task.worktree) {
|
|
19835
|
+
try {
|
|
19836
|
+
await this.initWorktree();
|
|
19837
|
+
} catch (error) {
|
|
19838
|
+
if (stashId) {
|
|
19839
|
+
try {
|
|
19840
|
+
await this.worktreeManager.applyStash(this.project.baseDir, stashId);
|
|
19841
|
+
await this.worktreeManager.dropStash(this.project.baseDir, stashId);
|
|
19842
|
+
} catch (restoreError) {
|
|
19843
|
+
logger.error("Failed to restore stash after worktree creation failure:", { error: restoreError, stashId });
|
|
19844
|
+
throw new Error(
|
|
19845
|
+
`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)}`
|
|
19846
|
+
);
|
|
19847
|
+
}
|
|
19848
|
+
}
|
|
19849
|
+
throw error;
|
|
19850
|
+
}
|
|
19851
|
+
} else if (existingWorktree && !this.task.worktree) {
|
|
19852
|
+
this.task.worktree = existingWorktree;
|
|
19853
|
+
}
|
|
19496
19854
|
if (stashId && this.task.worktree) {
|
|
19497
19855
|
try {
|
|
19498
19856
|
await this.worktreeManager.applyStash(this.task.worktree.path, stashId);
|
|
@@ -19502,9 +19860,26 @@ Only answer with the commit message, nothing else.`,
|
|
|
19502
19860
|
await this.worktreeManager.dropStash(this.project.baseDir, stashId);
|
|
19503
19861
|
} catch (error) {
|
|
19504
19862
|
logger.error("Failed to apply stashed changes to worktree:", { error });
|
|
19863
|
+
const originalMessage = error instanceof Error ? error.message : String(error);
|
|
19864
|
+
try {
|
|
19865
|
+
await this.worktreeManager.applyStash(this.project.baseDir, stashId);
|
|
19866
|
+
await this.worktreeManager.dropStash(this.project.baseDir, stashId);
|
|
19867
|
+
logger.info("Stashed changes restored to project root after failed apply to worktree");
|
|
19868
|
+
throw new Error(`Failed to apply stashed changes to worktree. Changes have been restored to project root. Error: ${originalMessage}`);
|
|
19869
|
+
} catch (restoreError) {
|
|
19870
|
+
if (restoreError instanceof Error && restoreError.message.includes("restored to project root")) {
|
|
19871
|
+
throw restoreError;
|
|
19872
|
+
}
|
|
19873
|
+
logger.error("Failed to restore stash to project root:", { error: restoreError, stashId });
|
|
19874
|
+
throw new Error(
|
|
19875
|
+
`Failed to apply stashed changes to worktree and could not restore them. Stash ID "${stashId}" still exists. Manual recovery required. Original error: ${originalMessage}`
|
|
19876
|
+
);
|
|
19877
|
+
}
|
|
19505
19878
|
}
|
|
19506
19879
|
}
|
|
19880
|
+
await this.updateTask({ workingMode: "worktree" });
|
|
19507
19881
|
void this.sendUpdatedFilesUpdated();
|
|
19882
|
+
await this.updateAutocompletionData(void 0, true);
|
|
19508
19883
|
}
|
|
19509
19884
|
async getLocalUncommittedFiles() {
|
|
19510
19885
|
return await this.worktreeManager.getUncommittedFiles(this.project.baseDir);
|
|
@@ -19545,6 +19920,20 @@ Only answer with the commit message, nothing else.`,
|
|
|
19545
19920
|
await this.sendUpdatedFilesUpdated();
|
|
19546
19921
|
await this.sendWorktreeIntegrationStatusUpdated();
|
|
19547
19922
|
}
|
|
19923
|
+
async mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted = false) {
|
|
19924
|
+
if (!this.task.worktree) {
|
|
19925
|
+
throw new Error("No worktree exists for this task");
|
|
19926
|
+
}
|
|
19927
|
+
logger.info("Merging worktree to worktree", {
|
|
19928
|
+
baseDir: this.project.baseDir,
|
|
19929
|
+
taskId: this.taskId,
|
|
19930
|
+
targetWorktreeDir,
|
|
19931
|
+
includeUncommitted
|
|
19932
|
+
});
|
|
19933
|
+
await this.waitForCurrentPromptToFinish();
|
|
19934
|
+
await this.worktreeManager.mergeWorktreeToWorktree(this.task.worktree.path, targetWorktreeDir, includeUncommitted);
|
|
19935
|
+
await this.sendUpdatedFilesUpdated();
|
|
19936
|
+
}
|
|
19548
19937
|
async revertLastMerge() {
|
|
19549
19938
|
if (!this.task.lastMergeState) {
|
|
19550
19939
|
throw new Error("No merge state found to revert");
|
|
@@ -19895,8 +20284,21 @@ ${diff}
|
|
|
19895
20284
|
await this.waitForCurrentPromptToFinish();
|
|
19896
20285
|
try {
|
|
19897
20286
|
this.addLogMessage("loading", "Continuing rebase...");
|
|
19898
|
-
await this.worktreeManager.continueRebase(this.task.worktree.path);
|
|
19899
|
-
await this.
|
|
20287
|
+
const { ontoBranch } = await this.worktreeManager.continueRebase(this.task.worktree.path);
|
|
20288
|
+
const newHead = await this.worktreeManager.getHeadCommit(this.task.worktree.path);
|
|
20289
|
+
if (newHead) {
|
|
20290
|
+
await this.saveTask({
|
|
20291
|
+
lastMergeState: void 0,
|
|
20292
|
+
worktree: {
|
|
20293
|
+
...this.task.worktree,
|
|
20294
|
+
baseCommit: newHead,
|
|
20295
|
+
// Update baseBranch if we could determine it from the rebase state, otherwise keep existing
|
|
20296
|
+
baseBranch: ontoBranch || this.task.worktree.baseBranch
|
|
20297
|
+
}
|
|
20298
|
+
});
|
|
20299
|
+
} else {
|
|
20300
|
+
await this.saveTask({ lastMergeState: void 0 });
|
|
20301
|
+
}
|
|
19900
20302
|
this.addLogMessage("info", "Rebase completed", true);
|
|
19901
20303
|
} catch (error) {
|
|
19902
20304
|
logger.error("Failed to continue rebase:", error);
|
|
@@ -22164,81 +22566,6 @@ const geminiProviderStrategy = {
|
|
|
22164
22566
|
// Error handling
|
|
22165
22567
|
isRetryable: isGeminiRetryable
|
|
22166
22568
|
};
|
|
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
22569
|
const loadGpustackModels = async (profile, settings) => {
|
|
22243
22570
|
if (!isGpustackProvider(profile.provider)) {
|
|
22244
22571
|
return { models: [], success: false };
|
|
@@ -23260,13 +23587,31 @@ const getNeuralwattUsageReport = (task, provider, model, usage, providerMetadata
|
|
|
23260
23587
|
agentTotalCost: task.task.agentTotalCost + messageCost
|
|
23261
23588
|
};
|
|
23262
23589
|
};
|
|
23590
|
+
const getNeuralwattProviderOptions = (llmProvider, model) => {
|
|
23591
|
+
if (!isNeuralwattProvider(llmProvider)) {
|
|
23592
|
+
return void 0;
|
|
23593
|
+
}
|
|
23594
|
+
const neuralwattProvider = llmProvider;
|
|
23595
|
+
const providerOverrides = model.providerOverrides;
|
|
23596
|
+
const reasoningEffort = providerOverrides?.reasoningEffort ?? neuralwattProvider.reasoningEffort;
|
|
23597
|
+
const mappedReasoningEffort = reasoningEffort === void 0 ? void 0 : reasoningEffort.toLowerCase();
|
|
23598
|
+
if (mappedReasoningEffort) {
|
|
23599
|
+
return {
|
|
23600
|
+
neuralwatt: {
|
|
23601
|
+
reasoningEffort: mappedReasoningEffort
|
|
23602
|
+
}
|
|
23603
|
+
};
|
|
23604
|
+
}
|
|
23605
|
+
return void 0;
|
|
23606
|
+
};
|
|
23263
23607
|
const neuralwattProviderStrategy = {
|
|
23264
23608
|
createLlm: createNeuralwattLlm,
|
|
23265
23609
|
getUsageReport: getNeuralwattUsageReport,
|
|
23266
23610
|
loadModels: loadNeuralwattModels,
|
|
23267
23611
|
hasEnvVars: hasNeuralwattEnvVars,
|
|
23268
23612
|
getAiderMapping: getNeuralwattAiderMapping,
|
|
23269
|
-
getModelInfo: getDefaultModelInfo
|
|
23613
|
+
getModelInfo: getDefaultModelInfo,
|
|
23614
|
+
getProviderOptions: getNeuralwattProviderOptions
|
|
23270
23615
|
};
|
|
23271
23616
|
const loadOllamaModels = async (profile, settings) => {
|
|
23272
23617
|
if (!isOllamaProvider(profile.provider)) {
|
|
@@ -24573,6 +24918,7 @@ const getZaiPlanProviderOptions = (llmProvider, model) => {
|
|
|
24573
24918
|
if (isZaiPlanProvider(llmProvider)) {
|
|
24574
24919
|
const providerOverrides = model.providerOverrides;
|
|
24575
24920
|
const thinkingEnabled = providerOverrides?.thinkingEnabled ?? llmProvider.thinkingEnabled ?? true;
|
|
24921
|
+
const reasoningEffort = providerOverrides?.reasoningEffort ?? llmProvider.reasoningEffort ?? ReasoningEffort.Max;
|
|
24576
24922
|
if (thinkingEnabled === false) {
|
|
24577
24923
|
return {
|
|
24578
24924
|
"zai-plan": {
|
|
@@ -24582,6 +24928,14 @@ const getZaiPlanProviderOptions = (llmProvider, model) => {
|
|
|
24582
24928
|
}
|
|
24583
24929
|
};
|
|
24584
24930
|
}
|
|
24931
|
+
const mappedReasoningEffort = reasoningEffort === ReasoningEffort.None ? void 0 : reasoningEffort.toLowerCase();
|
|
24932
|
+
if (mappedReasoningEffort) {
|
|
24933
|
+
return {
|
|
24934
|
+
"zai-plan": {
|
|
24935
|
+
reasoningEffort: mappedReasoningEffort
|
|
24936
|
+
}
|
|
24937
|
+
};
|
|
24938
|
+
}
|
|
24585
24939
|
}
|
|
24586
24940
|
return void 0;
|
|
24587
24941
|
};
|
|
@@ -24596,6 +24950,7 @@ const zaiPlanProviderStrategy = {
|
|
|
24596
24950
|
getModelInfo: getZaiPlanModelInfo,
|
|
24597
24951
|
getProviderOptions: getZaiPlanProviderOptions
|
|
24598
24952
|
};
|
|
24953
|
+
const MODEL_LOAD_TIMEOUT_MS = 3e4;
|
|
24599
24954
|
const MODELS_META_URL = "https://models.dev/api.json";
|
|
24600
24955
|
const MODELS_FILE = path.join(AIDER_DESK_DATA_DIR, "models.json");
|
|
24601
24956
|
const PROVIDER_MODELS_CACHE_FILE = path.join(AIDER_DESK_CACHE_DIR, "provider-models.json");
|
|
@@ -24622,7 +24977,6 @@ class ModelManager {
|
|
|
24622
24977
|
cerebras: cerebrasProviderStrategy,
|
|
24623
24978
|
deepseek: deepseekProviderStrategy,
|
|
24624
24979
|
gemini: geminiProviderStrategy,
|
|
24625
|
-
"gemini-cli": geminiCliProviderStrategy,
|
|
24626
24980
|
gpustack: gpustackProviderStrategy,
|
|
24627
24981
|
groq: groqProviderStrategy,
|
|
24628
24982
|
"alibaba-plan": alibabaPlanProviderStrategy,
|
|
@@ -24824,48 +25178,59 @@ class ModelManager {
|
|
|
24824
25178
|
await this.loadProviderModels(changedProviderProfiles.filter((p) => !p.disabled));
|
|
24825
25179
|
return changedProviderProfiles.length > 0 || removedProviders.length > 0;
|
|
24826
25180
|
}
|
|
24827
|
-
async
|
|
24828
|
-
|
|
24829
|
-
const
|
|
24830
|
-
|
|
24831
|
-
|
|
24832
|
-
|
|
25181
|
+
async withModelLoadTimeout(promise, profile) {
|
|
25182
|
+
let timer;
|
|
25183
|
+
const timeout = new Promise((resolve) => {
|
|
25184
|
+
timer = setTimeout(() => {
|
|
25185
|
+
if (!this.providerModels[profile.id]) {
|
|
25186
|
+
const errorMsg = `Timed out after ${MODEL_LOAD_TIMEOUT_MS / 1e3}s while loading models`;
|
|
25187
|
+
logger.error(`Model loading timed out for provider profile ${profile.id}`);
|
|
25188
|
+
this.providerErrors[profile.id] = errorMsg;
|
|
25189
|
+
}
|
|
25190
|
+
resolve();
|
|
25191
|
+
}, MODEL_LOAD_TIMEOUT_MS);
|
|
25192
|
+
});
|
|
25193
|
+
try {
|
|
25194
|
+
return await Promise.race([promise, timeout]);
|
|
25195
|
+
} finally {
|
|
25196
|
+
if (timer) {
|
|
25197
|
+
clearTimeout(timer);
|
|
24833
25198
|
}
|
|
24834
|
-
providersByName[provider.provider.name].push(provider);
|
|
24835
25199
|
}
|
|
25200
|
+
}
|
|
25201
|
+
async loadProviderModels(providers) {
|
|
25202
|
+
this.eventManager.sendProviderModelsUpdated({ loading: true });
|
|
24836
25203
|
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());
|
|
25204
|
+
for (const profile of providers || []) {
|
|
25205
|
+
const strategy = this.providerRegistry[profile.provider.name];
|
|
25206
|
+
if (!strategy) {
|
|
25207
|
+
continue;
|
|
24868
25208
|
}
|
|
25209
|
+
if (profile.disabled) {
|
|
25210
|
+
logger.debug(`Skipping disabled provider profile ${profile.id}`);
|
|
25211
|
+
continue;
|
|
25212
|
+
}
|
|
25213
|
+
const loadModels = async () => {
|
|
25214
|
+
let providerModels = [];
|
|
25215
|
+
const response = await this.loadModelsWithRetry(strategy, profile);
|
|
25216
|
+
delete this.providerErrors[profile.id];
|
|
25217
|
+
if (response.success) {
|
|
25218
|
+
providerModels.push(...response.models);
|
|
25219
|
+
} else {
|
|
25220
|
+
if (response.error) {
|
|
25221
|
+
logger.error(`Failed to load models for provider profile ${profile.id}:`, {
|
|
25222
|
+
error: response.error
|
|
25223
|
+
});
|
|
25224
|
+
this.providerErrors[profile.id] = response.error;
|
|
25225
|
+
} else {
|
|
25226
|
+
logger.warn(`Models for provider profile '${profile.id}' were not loaded due to misconfiguration.`);
|
|
25227
|
+
}
|
|
25228
|
+
}
|
|
25229
|
+
providerModels = this.enrichWithModelInfo(providerModels, profile, strategy);
|
|
25230
|
+
providerModels = this.enrichWithOverrides(providerModels, profile.id);
|
|
25231
|
+
this.providerModels[profile.id] = providerModels;
|
|
25232
|
+
};
|
|
25233
|
+
toLoadPromises.push(this.withModelLoadTimeout(loadModels(), profile));
|
|
24869
25234
|
}
|
|
24870
25235
|
await Promise.all(toLoadPromises);
|
|
24871
25236
|
this.eventManager.sendProviderModelsUpdated({
|
|
@@ -26638,7 +27003,7 @@ class TaskContextImpl {
|
|
|
26638
27003
|
async runPrompt(prompt, mode) {
|
|
26639
27004
|
await this.task.runPrompt(prompt, mode);
|
|
26640
27005
|
}
|
|
26641
|
-
async runPromptInAgent(profile, mode, prompt, promptContext, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true) {
|
|
27006
|
+
async runPromptInAgent(profile, mode, prompt, promptContext, contextMessages, contextFiles, systemPrompt, waitForCurrentAgentToFinish = true, sendNotification = true, skillsToActivate) {
|
|
26642
27007
|
return this.task.runPromptInAgent(
|
|
26643
27008
|
profile,
|
|
26644
27009
|
mode,
|
|
@@ -26648,7 +27013,9 @@ class TaskContextImpl {
|
|
|
26648
27013
|
contextFiles,
|
|
26649
27014
|
systemPrompt,
|
|
26650
27015
|
waitForCurrentAgentToFinish,
|
|
26651
|
-
sendNotification
|
|
27016
|
+
sendNotification,
|
|
27017
|
+
void 0,
|
|
27018
|
+
skillsToActivate
|
|
26652
27019
|
);
|
|
26653
27020
|
}
|
|
26654
27021
|
async runCustomCommand(name, args = [], mode) {
|
|
@@ -26681,6 +27048,9 @@ class TaskContextImpl {
|
|
|
26681
27048
|
});
|
|
26682
27049
|
return answer;
|
|
26683
27050
|
}
|
|
27051
|
+
async answerQuestion(answer, userInput) {
|
|
27052
|
+
return this.task.answerQuestion(answer, userInput);
|
|
27053
|
+
}
|
|
26684
27054
|
addLogMessage(level, message) {
|
|
26685
27055
|
this.task.addLogMessage(level, message);
|
|
26686
27056
|
}
|
|
@@ -26688,6 +27058,9 @@ class TaskContextImpl {
|
|
|
26688
27058
|
this.task.addLogMessage("loading", message, finished);
|
|
26689
27059
|
}
|
|
26690
27060
|
// Task Management
|
|
27061
|
+
async getTaskAgentProfile() {
|
|
27062
|
+
return this.task.getTaskAgentProfile();
|
|
27063
|
+
}
|
|
26691
27064
|
async updateTask(updates) {
|
|
26692
27065
|
return this.task.updateTask(updates);
|
|
26693
27066
|
}
|
|
@@ -26730,12 +27103,21 @@ class TaskContextImpl {
|
|
|
26730
27103
|
editQueuedPrompt(promptId, newText) {
|
|
26731
27104
|
this.task.editQueuedPrompt(promptId, newText);
|
|
26732
27105
|
}
|
|
26733
|
-
//
|
|
26734
|
-
async
|
|
26735
|
-
|
|
27106
|
+
// Working Mode & Worktrees
|
|
27107
|
+
async switchToWorktreeWorkingMode(options) {
|
|
27108
|
+
await this.task.switchToWorktreeWorkingMode(options);
|
|
26736
27109
|
}
|
|
26737
|
-
async
|
|
26738
|
-
|
|
27110
|
+
async switchToLocalWorkingMode(options) {
|
|
27111
|
+
await this.task.switchToLocalWorkingMode(options);
|
|
27112
|
+
}
|
|
27113
|
+
async getLocalUncommittedFiles() {
|
|
27114
|
+
return this.task.getLocalUncommittedFiles();
|
|
27115
|
+
}
|
|
27116
|
+
async applyUncommittedChanges(targetBranch) {
|
|
27117
|
+
await this.task.applyUncommittedChanges(targetBranch);
|
|
27118
|
+
}
|
|
27119
|
+
async mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted) {
|
|
27120
|
+
await this.task.mergeWorktreeToWorktree(targetWorktreeDir, includeUncommitted);
|
|
26739
27121
|
}
|
|
26740
27122
|
}
|
|
26741
27123
|
class ProjectContextImpl {
|
|
@@ -26930,6 +27312,19 @@ class ExtensionContextImpl {
|
|
|
26930
27312
|
return false;
|
|
26931
27313
|
}
|
|
26932
27314
|
}
|
|
27315
|
+
async getElectronApp() {
|
|
27316
|
+
try {
|
|
27317
|
+
const electron = await import("electron");
|
|
27318
|
+
const app = electron?.app ?? electron?.default?.app;
|
|
27319
|
+
if (!app || typeof app.getAppMetrics !== "function") {
|
|
27320
|
+
return null;
|
|
27321
|
+
}
|
|
27322
|
+
return app;
|
|
27323
|
+
} catch (error) {
|
|
27324
|
+
this.log(`Failed to get Electron app: ${error}`, "debug");
|
|
27325
|
+
return null;
|
|
27326
|
+
}
|
|
27327
|
+
}
|
|
26933
27328
|
getMemoryContext() {
|
|
26934
27329
|
if (!this.memoryManager) {
|
|
26935
27330
|
throw new Error("MemoryManager not available");
|
|
@@ -26941,6 +27336,11 @@ class ExtensionContextImpl {
|
|
|
26941
27336
|
}
|
|
26942
27337
|
}
|
|
26943
27338
|
const CACHE_TTL_MS$1 = 24 * 60 * 60 * 1e3;
|
|
27339
|
+
const FRAMEWORK_ENUM_VALUES = {
|
|
27340
|
+
"OS.Windows": "windows",
|
|
27341
|
+
"OS.Linux": "linux",
|
|
27342
|
+
"OS.MacOS": "macos"
|
|
27343
|
+
};
|
|
26944
27344
|
class ExtensionFetcher {
|
|
26945
27345
|
cache = /* @__PURE__ */ new Map();
|
|
26946
27346
|
getAvailableExtensionsPromise = null;
|
|
@@ -27198,6 +27598,7 @@ class ExtensionFetcher {
|
|
|
27198
27598
|
return null;
|
|
27199
27599
|
}
|
|
27200
27600
|
let metadata = null;
|
|
27601
|
+
const enumValues = this.collectEnumValues(sourceFile);
|
|
27201
27602
|
const visitor = (node) => {
|
|
27202
27603
|
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
27604
|
if (node.initializer) {
|
|
@@ -27209,7 +27610,7 @@ class ExtensionFetcher {
|
|
|
27209
27610
|
objectLiteral = this.findVariableDeclaration(sourceFile, variableName);
|
|
27210
27611
|
}
|
|
27211
27612
|
if (objectLiteral) {
|
|
27212
|
-
const parsed = this.parseObjectLiteral(objectLiteral);
|
|
27613
|
+
const parsed = this.parseObjectLiteral(objectLiteral, enumValues);
|
|
27213
27614
|
if (parsed && typeof parsed.name === "string" && typeof parsed.version === "string") {
|
|
27214
27615
|
metadata = parsed;
|
|
27215
27616
|
}
|
|
@@ -27232,19 +27633,45 @@ class ExtensionFetcher {
|
|
|
27232
27633
|
visitor(sourceFile);
|
|
27233
27634
|
return objectLiteral;
|
|
27234
27635
|
}
|
|
27235
|
-
|
|
27636
|
+
collectEnumValues(sourceFile) {
|
|
27637
|
+
const values = { ...FRAMEWORK_ENUM_VALUES };
|
|
27638
|
+
const visitor = (node) => {
|
|
27639
|
+
if (ts__namespace.isEnumDeclaration(node) && node.name) {
|
|
27640
|
+
const enumName = node.name.text;
|
|
27641
|
+
let autoValue = 0;
|
|
27642
|
+
for (const member of node.members) {
|
|
27643
|
+
const memberName = ts__namespace.isIdentifier(member.name) || ts__namespace.isStringLiteral(member.name) ? member.name.text : member.name.getText();
|
|
27644
|
+
const key = `${enumName}.${memberName}`;
|
|
27645
|
+
if (member.initializer) {
|
|
27646
|
+
const parsed = this.parsePropertyValue(member.initializer, values);
|
|
27647
|
+
values[key] = parsed;
|
|
27648
|
+
if (typeof parsed === "number") {
|
|
27649
|
+
autoValue = parsed + 1;
|
|
27650
|
+
}
|
|
27651
|
+
} else {
|
|
27652
|
+
values[key] = autoValue;
|
|
27653
|
+
autoValue++;
|
|
27654
|
+
}
|
|
27655
|
+
}
|
|
27656
|
+
}
|
|
27657
|
+
ts__namespace.forEachChild(node, visitor);
|
|
27658
|
+
};
|
|
27659
|
+
visitor(sourceFile);
|
|
27660
|
+
return values;
|
|
27661
|
+
}
|
|
27662
|
+
parseObjectLiteral(node, enumValues) {
|
|
27236
27663
|
const result = {};
|
|
27237
27664
|
for (const property of node.properties) {
|
|
27238
27665
|
if (ts__namespace.isPropertyAssignment(property)) {
|
|
27239
27666
|
const name = ts__namespace.isIdentifier(property.name) ? property.name.text : ts__namespace.isStringLiteral(property.name) ? property.name.text : null;
|
|
27240
27667
|
if (name) {
|
|
27241
|
-
result[name] = this.parsePropertyValue(property.initializer);
|
|
27668
|
+
result[name] = this.parsePropertyValue(property.initializer, enumValues);
|
|
27242
27669
|
}
|
|
27243
27670
|
}
|
|
27244
27671
|
}
|
|
27245
27672
|
return result;
|
|
27246
27673
|
}
|
|
27247
|
-
parsePropertyValue(node) {
|
|
27674
|
+
parsePropertyValue(node, enumValues) {
|
|
27248
27675
|
if (ts__namespace.isStringLiteral(node)) {
|
|
27249
27676
|
return node.text;
|
|
27250
27677
|
} else if (ts__namespace.isNumericLiteral(node)) {
|
|
@@ -27255,10 +27682,17 @@ class ExtensionFetcher {
|
|
|
27255
27682
|
return false;
|
|
27256
27683
|
} else if (node.kind === ts__namespace.SyntaxKind.NullKeyword) {
|
|
27257
27684
|
return null;
|
|
27685
|
+
} else if (ts__namespace.isPropertyAccessExpression(node)) {
|
|
27686
|
+
const exprText = ts__namespace.isIdentifier(node.expression) ? node.expression.text : node.expression.getText();
|
|
27687
|
+
const key = `${exprText}.${node.name.text}`;
|
|
27688
|
+
if (key in enumValues) {
|
|
27689
|
+
return enumValues[key];
|
|
27690
|
+
}
|
|
27691
|
+
return void 0;
|
|
27258
27692
|
} else if (ts__namespace.isArrayLiteralExpression(node)) {
|
|
27259
|
-
return node.elements.map((elem) => this.parsePropertyValue(elem));
|
|
27693
|
+
return node.elements.map((elem) => this.parsePropertyValue(elem, enumValues));
|
|
27260
27694
|
} else if (ts__namespace.isObjectLiteralExpression(node)) {
|
|
27261
|
-
return this.parseObjectLiteral(node);
|
|
27695
|
+
return this.parseObjectLiteral(node, enumValues);
|
|
27262
27696
|
}
|
|
27263
27697
|
return void 0;
|
|
27264
27698
|
}
|
|
@@ -27824,6 +28258,7 @@ class ExtensionManager {
|
|
|
27824
28258
|
}
|
|
27825
28259
|
}
|
|
27826
28260
|
static TOOL_NAME_REGEX = /^[a-z][a-z0-9_-]*$/;
|
|
28261
|
+
static COMMAND_NAME_REGEX = /^[a-z][a-z0-9_:-]*$/;
|
|
27827
28262
|
validateToolDefinition(tool) {
|
|
27828
28263
|
const errors = [];
|
|
27829
28264
|
try {
|
|
@@ -28017,9 +28452,9 @@ class ExtensionManager {
|
|
|
28017
28452
|
try {
|
|
28018
28453
|
if (!command.name) {
|
|
28019
28454
|
errors.push("Command name must be a non-empty string");
|
|
28020
|
-
} else if (!ExtensionManager.
|
|
28455
|
+
} else if (!ExtensionManager.COMMAND_NAME_REGEX.test(command.name)) {
|
|
28021
28456
|
errors.push(
|
|
28022
|
-
`Command name '${command.name}' must start with a lowercase letter and contain only lowercase letters, numbers, hyphens, or
|
|
28457
|
+
`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
28458
|
);
|
|
28024
28459
|
}
|
|
28025
28460
|
if (!command.description || command.description.trim() === "") {
|
|
@@ -28588,7 +29023,7 @@ class ExtensionManager {
|
|
|
28588
29023
|
* @param extensionId - Extension identifier
|
|
28589
29024
|
* @param repositoryUrl - Repository URL where the extension is located
|
|
28590
29025
|
* @param project - Optional project for project-level install
|
|
28591
|
-
* @returns
|
|
29026
|
+
* @returns ExtensionOperationResult indicating success or failure with error details
|
|
28592
29027
|
*/
|
|
28593
29028
|
async installExtension(extensionId, repositoryUrl, project) {
|
|
28594
29029
|
const projectDir = project?.baseDir;
|
|
@@ -28640,10 +29075,10 @@ class ExtensionManager {
|
|
|
28640
29075
|
await this.loadExtensionsForDir(targetDir, project);
|
|
28641
29076
|
logger.info(`[Extensions] Successfully installed ${extension.name}`);
|
|
28642
29077
|
this.telemetryManager.captureExtensionInstalled(extension.name, projectDir ? "project" : "global");
|
|
28643
|
-
return true;
|
|
29078
|
+
return { success: true };
|
|
28644
29079
|
} catch (error) {
|
|
28645
29080
|
logger.error(`[Extensions] Failed to install extension '${extensionId}':`, error);
|
|
28646
|
-
return false;
|
|
29081
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
28647
29082
|
}
|
|
28648
29083
|
}
|
|
28649
29084
|
/**
|
|
@@ -28654,11 +29089,14 @@ class ExtensionManager {
|
|
|
28654
29089
|
return new Promise((resolve, reject) => {
|
|
28655
29090
|
const child = spawn("npm", ["install"], {
|
|
28656
29091
|
cwd: extensionPath,
|
|
28657
|
-
stdio: "inherit"
|
|
29092
|
+
stdio: "inherit",
|
|
29093
|
+
shell: true
|
|
28658
29094
|
});
|
|
28659
29095
|
child.on("close", (code) => {
|
|
28660
29096
|
if (code === 0) {
|
|
28661
29097
|
resolve();
|
|
29098
|
+
} else if (code === 127) {
|
|
29099
|
+
reject(new Error("npm-not-found"));
|
|
28662
29100
|
} else {
|
|
28663
29101
|
reject(new Error(`npm install failed with code ${code}`));
|
|
28664
29102
|
}
|
|
@@ -28709,7 +29147,7 @@ class ExtensionManager {
|
|
|
28709
29147
|
* @param extensionId - Extension identifier (filePath of installed extension)
|
|
28710
29148
|
* @param repositoryUrl - Repository URL where the extension is located
|
|
28711
29149
|
* @param project - Optional project for project-level extension
|
|
28712
|
-
* @returns
|
|
29150
|
+
* @returns ExtensionOperationResult indicating success or failure with error details
|
|
28713
29151
|
*/
|
|
28714
29152
|
async updateExtension(extensionId, repositoryUrl, project) {
|
|
28715
29153
|
const projectDir = project?.baseDir;
|
|
@@ -28777,10 +29215,10 @@ class ExtensionManager {
|
|
|
28777
29215
|
}
|
|
28778
29216
|
await this.loadExtensionsForDir(targetDir, project);
|
|
28779
29217
|
logger.info(`[Extensions] Successfully updated ${extension.name}`);
|
|
28780
|
-
return true;
|
|
29218
|
+
return { success: true };
|
|
28781
29219
|
} catch (error) {
|
|
28782
29220
|
logger.error(`[Extensions] Failed to update extension '${extensionId}':`, error);
|
|
28783
|
-
return false;
|
|
29221
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
28784
29222
|
}
|
|
28785
29223
|
}
|
|
28786
29224
|
/**
|
|
@@ -31209,7 +31647,8 @@ const DEFAULT_SETTINGS = {
|
|
|
31209
31647
|
},
|
|
31210
31648
|
proxy: {
|
|
31211
31649
|
enabled: false,
|
|
31212
|
-
url: ""
|
|
31650
|
+
url: "",
|
|
31651
|
+
noProxy: ""
|
|
31213
31652
|
},
|
|
31214
31653
|
fileWatchMode: FileWatchMode.Auto
|
|
31215
31654
|
};
|