pybao-cli 1.3.79 → 1.3.81
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/dist/REPL-N4B3JZBZ.js +42 -0
- package/dist/{acp-32X2ORWD.js → acp-4HKKXFYQ.js} +29 -28
- package/dist/{acp-32X2ORWD.js.map → acp-4HKKXFYQ.js.map} +1 -1
- package/dist/{agentsValidate-M2NLS6KJ.js → agentsValidate-Y7ESIGWC.js} +7 -7
- package/dist/{ask-APOBPV6G.js → ask-BFLAH7SK.js} +25 -25
- package/dist/{autoUpdater-MEG3J4ZP.js → autoUpdater-ZP62GDO2.js} +3 -3
- package/dist/{chunk-RL522VQA.js → chunk-26R2U6DS.js} +243 -417
- package/dist/chunk-26R2U6DS.js.map +7 -0
- package/dist/{chunk-TZHR6HNQ.js → chunk-2BT4P5FY.js} +2 -2
- package/dist/{chunk-2P7BUT6Q.js → chunk-2JAKX7IR.js} +3 -3
- package/dist/{llm-TOJ4LFPH.js → chunk-2RR4H3L6.js} +28 -57
- package/dist/chunk-2RR4H3L6.js.map +7 -0
- package/dist/{chunk-Q5GLVET5.js → chunk-4YJ6DHQK.js} +38 -42
- package/dist/{chunk-Q5GLVET5.js.map → chunk-4YJ6DHQK.js.map} +2 -2
- package/dist/{chunk-MHYEZGJE.js → chunk-5RVP5P5Y.js} +2 -2
- package/dist/{chunk-KUOHKADR.js → chunk-5YU3ZWG6.js} +4 -4
- package/dist/{chunk-FFNEPND5.js → chunk-65MNQP3U.js} +3 -3
- package/dist/{chunk-22FCTCIV.js → chunk-72RJTELO.js} +1 -1
- package/dist/{chunk-Y24AKIQ4.js → chunk-AED6OYMI.js} +3 -3
- package/dist/{chunk-PK4LECKI.js → chunk-BAGUGUP3.js} +2 -2
- package/dist/{chunk-UIB4DXAE.js → chunk-BXF5H7EN.js} +1 -1
- package/dist/{chunk-IEKZ4CWY.js → chunk-D364WNKJ.js} +59 -48
- package/dist/chunk-D364WNKJ.js.map +7 -0
- package/dist/{chunk-3TLFBSQO.js → chunk-IV73XFVG.js} +3 -3
- package/dist/{chunk-T3YJGBT6.js → chunk-JEHHIOUO.js} +1 -1
- package/dist/{chunk-GPR72UXL.js → chunk-KZGNQII5.js} +4 -4
- package/dist/{chunk-B3TQNKEC.js → chunk-LLNNHSE3.js} +1 -1
- package/dist/{chunk-JIWMGSZC.js → chunk-LVTQN4RG.js} +1 -1
- package/dist/{chunk-MEKNF2BX.js → chunk-MTSI5244.js} +2 -2
- package/dist/{chunk-SS6ICJFN.js → chunk-P2VXE3TJ.js} +3 -3
- package/dist/{chunk-FE2DB2XA.js → chunk-PYRG5FKD.js} +1 -1
- package/dist/{chunk-RVNK6V3Z.js → chunk-Q653YYZS.js} +1 -1
- package/dist/{chunk-YDVLI6LP.js → chunk-R56S2D3A.js} +5 -3
- package/dist/{chunk-YDVLI6LP.js.map → chunk-R56S2D3A.js.map} +2 -2
- package/dist/{chunk-ZBZ3REJN.js → chunk-RPQ3FFN6.js} +3 -3
- package/dist/{chunk-Y3NWIKWN.js → chunk-TE7EYQKI.js} +2 -2
- package/dist/{chunk-4ESLYQDR.js → chunk-TMIQYE2C.js} +3 -3
- package/dist/{chunk-PDSCF233.js → chunk-UGJJDTVJ.js} +1 -1
- package/dist/{chunk-3PUCUH4D.js → chunk-UUGAVZ5R.js} +2 -2
- package/dist/{chunk-MBT675J6.js → chunk-VQYBUOUL.js} +1 -1
- package/dist/{cli-2KE3PWBY.js → cli-KITOXFPL.js} +80 -80
- package/dist/commands-GPZL7LEO.js +46 -0
- package/dist/{config-5S7M57PH.js → config-EVFJADC4.js} +4 -4
- package/dist/{context-X33OOXZW.js → context-DZU6TVXM.js} +5 -5
- package/dist/{customCommands-PDRM6IC2.js → customCommands-3ZEKZS64.js} +4 -4
- package/dist/{env-UFICMT75.js → env-KJ3YKVKD.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/llm-LVHJBUBU.js +80 -0
- package/dist/{llmLazy-DIIIURE4.js → llmLazy-E37BRRJL.js} +1 -1
- package/dist/{loader-ZIYIIHU4.js → loader-CJQYGIOX.js} +4 -4
- package/dist/{lspAnchor-QDIBSYKN.js → lspAnchor-VYW6TBK6.js} +4 -4
- package/dist/{manager-VKVZBKNY.js → manager-2E6RCOPM.js} +4 -4
- package/dist/{mcp-L4M5UE4A.js → mcp-32PUNKEE.js} +7 -7
- package/dist/{mentionProcessor-UMLTSEAK.js → mentionProcessor-YQUVBGUO.js} +5 -5
- package/dist/{messages-MYZABIFA.js → messages-S6XJLYHT.js} +1 -1
- package/dist/{model-ZLM7F2D5.js → model-KERYS7VW.js} +5 -5
- package/dist/{openai-XNZOUIOB.js → openai-LIOQRL5O.js} +5 -5
- package/dist/{outputStyles-RMGJWCUZ.js → outputStyles-M7AT5V2E.js} +4 -4
- package/dist/{pluginRuntime-OOG6EE3L.js → pluginRuntime-RPOZH24G.js} +6 -6
- package/dist/{pluginValidation-YN7HPE4Y.js → pluginValidation-3PNCKYDB.js} +6 -6
- package/dist/prompts-HL3TSDJY.js +48 -0
- package/dist/{pybAgentSessionLoad-LLFNXD4G.js → pybAgentSessionLoad-U343Y3XU.js} +4 -4
- package/dist/{pybAgentSessionResume-Z5LKVRC5.js → pybAgentSessionResume-747QQNMS.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-KUTJM63D.js → pybAgentStreamJsonSession-B25HH4BN.js} +1 -1
- package/dist/{pybHooks-HJWMWWWF.js → pybHooks-7EEKA766.js} +4 -4
- package/dist/query-LXPSR7ZB.js +50 -0
- package/dist/{ripgrep-LU5NTUF2.js → ripgrep-US75RUV3.js} +3 -3
- package/dist/{skillMarketplace-ATR76CC3.js → skillMarketplace-P4P7ZUPT.js} +3 -3
- package/dist/{chunk-IZ3M5OX4.js → smart-edit-AWHJDSU6.js} +37 -9
- package/dist/{chunk-IZ3M5OX4.js.map → smart-edit-AWHJDSU6.js.map} +3 -3
- package/dist/{state-C7DZ3IXR.js → state-36K5VF3G.js} +2 -2
- package/dist/{theme-XKQRSGQE.js → theme-7R3CIM3B.js} +5 -5
- package/dist/{toolPermissionSettings-KFWCSV6G.js → toolPermissionSettings-4YLPKZWJ.js} +6 -6
- package/dist/tools-3JTWQRFN.js +51 -0
- package/dist/tools-3JTWQRFN.js.map +7 -0
- package/dist/{userInput-I53JLE7C.js → userInput-TBU35CMG.js} +27 -27
- package/package.json +5 -3
- package/dist/REPL-RYMDCVU6.js +0 -42
- package/dist/chunk-IEKZ4CWY.js.map +0 -7
- package/dist/chunk-RL522VQA.js.map +0 -7
- package/dist/chunk-XI4LTVYT.js +0 -17
- package/dist/chunk-XI4LTVYT.js.map +0 -7
- package/dist/commands-WJSK5CQI.js +0 -46
- package/dist/llm-TOJ4LFPH.js.map +0 -7
- package/dist/prompts-TVJAY7YX.js +0 -48
- package/dist/query-IMKUC25L.js +0 -50
- package/dist/smart-edit-677MCQMW.js +0 -56
- package/dist/smart-edit-677MCQMW.js.map +0 -7
- package/dist/tools-223LNUWS.js +0 -50
- /package/dist/{REPL-RYMDCVU6.js.map → REPL-N4B3JZBZ.js.map} +0 -0
- /package/dist/{agentsValidate-M2NLS6KJ.js.map → agentsValidate-Y7ESIGWC.js.map} +0 -0
- /package/dist/{ask-APOBPV6G.js.map → ask-BFLAH7SK.js.map} +0 -0
- /package/dist/{autoUpdater-MEG3J4ZP.js.map → autoUpdater-ZP62GDO2.js.map} +0 -0
- /package/dist/{chunk-TZHR6HNQ.js.map → chunk-2BT4P5FY.js.map} +0 -0
- /package/dist/{chunk-2P7BUT6Q.js.map → chunk-2JAKX7IR.js.map} +0 -0
- /package/dist/{chunk-MHYEZGJE.js.map → chunk-5RVP5P5Y.js.map} +0 -0
- /package/dist/{chunk-KUOHKADR.js.map → chunk-5YU3ZWG6.js.map} +0 -0
- /package/dist/{chunk-FFNEPND5.js.map → chunk-65MNQP3U.js.map} +0 -0
- /package/dist/{chunk-22FCTCIV.js.map → chunk-72RJTELO.js.map} +0 -0
- /package/dist/{chunk-Y24AKIQ4.js.map → chunk-AED6OYMI.js.map} +0 -0
- /package/dist/{chunk-PK4LECKI.js.map → chunk-BAGUGUP3.js.map} +0 -0
- /package/dist/{chunk-UIB4DXAE.js.map → chunk-BXF5H7EN.js.map} +0 -0
- /package/dist/{chunk-3TLFBSQO.js.map → chunk-IV73XFVG.js.map} +0 -0
- /package/dist/{chunk-T3YJGBT6.js.map → chunk-JEHHIOUO.js.map} +0 -0
- /package/dist/{chunk-GPR72UXL.js.map → chunk-KZGNQII5.js.map} +0 -0
- /package/dist/{chunk-B3TQNKEC.js.map → chunk-LLNNHSE3.js.map} +0 -0
- /package/dist/{chunk-JIWMGSZC.js.map → chunk-LVTQN4RG.js.map} +0 -0
- /package/dist/{chunk-MEKNF2BX.js.map → chunk-MTSI5244.js.map} +0 -0
- /package/dist/{chunk-SS6ICJFN.js.map → chunk-P2VXE3TJ.js.map} +0 -0
- /package/dist/{chunk-FE2DB2XA.js.map → chunk-PYRG5FKD.js.map} +0 -0
- /package/dist/{chunk-RVNK6V3Z.js.map → chunk-Q653YYZS.js.map} +0 -0
- /package/dist/{chunk-ZBZ3REJN.js.map → chunk-RPQ3FFN6.js.map} +0 -0
- /package/dist/{chunk-Y3NWIKWN.js.map → chunk-TE7EYQKI.js.map} +0 -0
- /package/dist/{chunk-4ESLYQDR.js.map → chunk-TMIQYE2C.js.map} +0 -0
- /package/dist/{chunk-PDSCF233.js.map → chunk-UGJJDTVJ.js.map} +0 -0
- /package/dist/{chunk-3PUCUH4D.js.map → chunk-UUGAVZ5R.js.map} +0 -0
- /package/dist/{chunk-MBT675J6.js.map → chunk-VQYBUOUL.js.map} +0 -0
- /package/dist/{cli-2KE3PWBY.js.map → cli-KITOXFPL.js.map} +0 -0
- /package/dist/{commands-WJSK5CQI.js.map → commands-GPZL7LEO.js.map} +0 -0
- /package/dist/{config-5S7M57PH.js.map → config-EVFJADC4.js.map} +0 -0
- /package/dist/{context-X33OOXZW.js.map → context-DZU6TVXM.js.map} +0 -0
- /package/dist/{customCommands-PDRM6IC2.js.map → customCommands-3ZEKZS64.js.map} +0 -0
- /package/dist/{env-UFICMT75.js.map → env-KJ3YKVKD.js.map} +0 -0
- /package/dist/{llmLazy-DIIIURE4.js.map → llm-LVHJBUBU.js.map} +0 -0
- /package/dist/{loader-ZIYIIHU4.js.map → llmLazy-E37BRRJL.js.map} +0 -0
- /package/dist/{manager-VKVZBKNY.js.map → loader-CJQYGIOX.js.map} +0 -0
- /package/dist/{lspAnchor-QDIBSYKN.js.map → lspAnchor-VYW6TBK6.js.map} +0 -0
- /package/dist/{mcp-L4M5UE4A.js.map → manager-2E6RCOPM.js.map} +0 -0
- /package/dist/{messages-MYZABIFA.js.map → mcp-32PUNKEE.js.map} +0 -0
- /package/dist/{mentionProcessor-UMLTSEAK.js.map → mentionProcessor-YQUVBGUO.js.map} +0 -0
- /package/dist/{model-ZLM7F2D5.js.map → messages-S6XJLYHT.js.map} +0 -0
- /package/dist/{openai-XNZOUIOB.js.map → model-KERYS7VW.js.map} +0 -0
- /package/dist/{outputStyles-RMGJWCUZ.js.map → openai-LIOQRL5O.js.map} +0 -0
- /package/dist/{pluginValidation-YN7HPE4Y.js.map → outputStyles-M7AT5V2E.js.map} +0 -0
- /package/dist/{pluginRuntime-OOG6EE3L.js.map → pluginRuntime-RPOZH24G.js.map} +0 -0
- /package/dist/{prompts-TVJAY7YX.js.map → pluginValidation-3PNCKYDB.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-LLFNXD4G.js.map → prompts-HL3TSDJY.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-Z5LKVRC5.js.map → pybAgentSessionLoad-U343Y3XU.js.map} +0 -0
- /package/dist/{pybHooks-HJWMWWWF.js.map → pybAgentSessionResume-747QQNMS.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-KUTJM63D.js.map → pybAgentStreamJsonSession-B25HH4BN.js.map} +0 -0
- /package/dist/{query-IMKUC25L.js.map → pybHooks-7EEKA766.js.map} +0 -0
- /package/dist/{ripgrep-LU5NTUF2.js.map → query-LXPSR7ZB.js.map} +0 -0
- /package/dist/{skillMarketplace-ATR76CC3.js.map → ripgrep-US75RUV3.js.map} +0 -0
- /package/dist/{state-C7DZ3IXR.js.map → skillMarketplace-P4P7ZUPT.js.map} +0 -0
- /package/dist/{theme-XKQRSGQE.js.map → state-36K5VF3G.js.map} +0 -0
- /package/dist/{toolPermissionSettings-KFWCSV6G.js.map → theme-7R3CIM3B.js.map} +0 -0
- /package/dist/{tools-223LNUWS.js.map → toolPermissionSettings-4YLPKZWJ.js.map} +0 -0
- /package/dist/{userInput-I53JLE7C.js.map → userInput-TBU35CMG.js.map} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createRequire as __pybCreateRequire } from "node:module";
|
|
2
2
|
const require = __pybCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
queryQuick
|
|
5
|
+
} from "./chunk-2RR4H3L6.js";
|
|
3
6
|
import {
|
|
4
7
|
AskUserQuestionTool,
|
|
5
8
|
BashTool,
|
|
@@ -17,11 +20,8 @@ import {
|
|
|
17
20
|
SkillTool,
|
|
18
21
|
SlashCommandTool,
|
|
19
22
|
TodoWriteTool,
|
|
20
|
-
WebFetchTool,
|
|
21
|
-
WebSearchTool,
|
|
22
23
|
applyMarkdown,
|
|
23
24
|
countTokens,
|
|
24
|
-
fileExistsBun,
|
|
25
25
|
getAbsolutePath,
|
|
26
26
|
getAgentPrompt,
|
|
27
27
|
getMaxThinkingTokens,
|
|
@@ -30,59 +30,49 @@ import {
|
|
|
30
30
|
hasWritePermission,
|
|
31
31
|
loadLanguage,
|
|
32
32
|
query
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-4YJ6DHQK.js";
|
|
34
34
|
import {
|
|
35
35
|
queryLLM
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-5YU3ZWG6.js";
|
|
37
37
|
import {
|
|
38
38
|
FallbackToolUseRejectedMessage,
|
|
39
39
|
MCPTool,
|
|
40
40
|
getClients,
|
|
41
41
|
getMCPTools
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-KZGNQII5.js";
|
|
43
43
|
import {
|
|
44
44
|
generateAgentId
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-TE7EYQKI.js";
|
|
46
46
|
import {
|
|
47
47
|
getActiveAgents,
|
|
48
48
|
getAgentByType,
|
|
49
49
|
getAvailableAgentTypes
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-UUGAVZ5R.js";
|
|
51
51
|
import {
|
|
52
52
|
INTERRUPT_MESSAGE,
|
|
53
53
|
createAssistantMessage,
|
|
54
54
|
createUserMessage,
|
|
55
55
|
getLastAssistantMessageId
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-JEHHIOUO.js";
|
|
57
57
|
import {
|
|
58
58
|
filesToTree,
|
|
59
59
|
ripGrep
|
|
60
|
-
} from "./chunk-
|
|
61
|
-
import {
|
|
62
|
-
BlockAnchorReplacer,
|
|
63
|
-
ContextAwareReplacer,
|
|
64
|
-
EscapeNormalizedReplacer,
|
|
65
|
-
IndentationFlexibleReplacer,
|
|
66
|
-
LineTrimmedReplacer,
|
|
67
|
-
MultiOccurrenceReplacer,
|
|
68
|
-
TrimmedBoundaryReplacer,
|
|
69
|
-
WhitespaceNormalizedReplacer
|
|
70
|
-
} from "./chunk-IZ3M5OX4.js";
|
|
60
|
+
} from "./chunk-VQYBUOUL.js";
|
|
71
61
|
import {
|
|
72
62
|
LspClientManager
|
|
73
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-D364WNKJ.js";
|
|
74
64
|
import {
|
|
75
65
|
getModelManager
|
|
76
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-RPQ3FFN6.js";
|
|
77
67
|
import {
|
|
78
68
|
getContext
|
|
79
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-2JAKX7IR.js";
|
|
80
70
|
import {
|
|
81
71
|
getTheme
|
|
82
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-LLNNHSE3.js";
|
|
83
73
|
import {
|
|
84
74
|
debug
|
|
85
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-PYRG5FKD.js";
|
|
86
76
|
import {
|
|
87
77
|
BunShell,
|
|
88
78
|
getCwd,
|
|
@@ -91,7 +81,7 @@ import {
|
|
|
91
81
|
logError,
|
|
92
82
|
overwriteLog,
|
|
93
83
|
readTaskOutput
|
|
94
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-Q653YYZS.js";
|
|
95
85
|
import {
|
|
96
86
|
formatDuration,
|
|
97
87
|
formatNumber
|
|
@@ -757,9 +747,9 @@ async function analyzeOutputWithLsp(output, exitCode) {
|
|
|
757
747
|
if (warningCount > 0) parts.push(`${warningCount} Warning${warningCount === 1 ? "" : "s"}`);
|
|
758
748
|
if (exitCode !== 0) {
|
|
759
749
|
try {
|
|
760
|
-
const { LspClientManager: LspClientManager2 } = await import("./manager-
|
|
750
|
+
const { LspClientManager: LspClientManager2 } = await import("./manager-2E6RCOPM.js");
|
|
761
751
|
const { isAbsolute: isAbsolute3, resolve: resolve3 } = await import("path");
|
|
762
|
-
const { getCwd: getCwd2 } = await import("./state-
|
|
752
|
+
const { getCwd: getCwd2 } = await import("./state-36K5VF3G.js");
|
|
763
753
|
const lines = output.split("\n");
|
|
764
754
|
const uniqueFiles = /* @__PURE__ */ new Set();
|
|
765
755
|
const lspSuggestions = [];
|
|
@@ -1119,7 +1109,7 @@ var DeleteTool = {
|
|
|
1119
1109
|
}
|
|
1120
1110
|
if (!force) {
|
|
1121
1111
|
try {
|
|
1122
|
-
const { LspClientManager: LspClientManager2 } = await import("./manager-
|
|
1112
|
+
const { LspClientManager: LspClientManager2 } = await import("./manager-2E6RCOPM.js");
|
|
1123
1113
|
const manager = LspClientManager2.getInstance();
|
|
1124
1114
|
const client = await manager.getClientForFile(fullPath);
|
|
1125
1115
|
if (!client) {
|
|
@@ -1403,7 +1393,7 @@ var LSTool = {
|
|
|
1403
1393
|
const stats = {};
|
|
1404
1394
|
if (semantic) {
|
|
1405
1395
|
try {
|
|
1406
|
-
const { LspClientManager: LspClientManager2 } = await import("./manager-
|
|
1396
|
+
const { LspClientManager: LspClientManager2 } = await import("./manager-2E6RCOPM.js");
|
|
1407
1397
|
const BATCH_SIZE = 10;
|
|
1408
1398
|
const processedFilesList = [];
|
|
1409
1399
|
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
@@ -2730,365 +2720,15 @@ var LspTool = {
|
|
|
2730
2720
|
}
|
|
2731
2721
|
};
|
|
2732
2722
|
|
|
2733
|
-
// src/tools/
|
|
2734
|
-
import { z as z7 } from "zod";
|
|
2735
|
-
|
|
2736
|
-
// src/utils/diff/patch-manager.ts
|
|
2737
|
-
var PatchManager = class {
|
|
2738
|
-
static applyTransactional(patches, fileContents, options = { strategy: "strict" }) {
|
|
2739
|
-
const result = {
|
|
2740
|
-
success: true,
|
|
2741
|
-
partialSuccess: false,
|
|
2742
|
-
committedFiles: [],
|
|
2743
|
-
failedFiles: [],
|
|
2744
|
-
newContents: /* @__PURE__ */ new Map(),
|
|
2745
|
-
errors: /* @__PURE__ */ new Map()
|
|
2746
|
-
};
|
|
2747
|
-
const tempResults = /* @__PURE__ */ new Map();
|
|
2748
|
-
for (const patch of patches) {
|
|
2749
|
-
const content = fileContents.get(patch.filePath);
|
|
2750
|
-
if (content === void 0) {
|
|
2751
|
-
result.failedFiles.push(patch.filePath);
|
|
2752
|
-
result.errors.set(patch.filePath, "File not found in provided contents");
|
|
2753
|
-
result.success = false;
|
|
2754
|
-
continue;
|
|
2755
|
-
}
|
|
2756
|
-
try {
|
|
2757
|
-
const newContent = this.apply(content, patch.hunks);
|
|
2758
|
-
tempResults.set(patch.filePath, newContent);
|
|
2759
|
-
} catch (error) {
|
|
2760
|
-
result.failedFiles.push(patch.filePath);
|
|
2761
|
-
result.errors.set(patch.filePath, error.message);
|
|
2762
|
-
result.success = false;
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
if (options.strategy === "strict") {
|
|
2766
|
-
if (!result.success) {
|
|
2767
|
-
result.committedFiles = [];
|
|
2768
|
-
result.newContents.clear();
|
|
2769
|
-
} else {
|
|
2770
|
-
for (const [file, content] of tempResults) {
|
|
2771
|
-
result.committedFiles.push(file);
|
|
2772
|
-
result.newContents.set(file, content);
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
} else {
|
|
2776
|
-
for (const [file, content] of tempResults) {
|
|
2777
|
-
result.committedFiles.push(file);
|
|
2778
|
-
result.newContents.set(file, content);
|
|
2779
|
-
}
|
|
2780
|
-
if (result.failedFiles.length > 0 && result.committedFiles.length > 0) {
|
|
2781
|
-
result.partialSuccess = true;
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
return result;
|
|
2785
|
-
}
|
|
2786
|
-
static parseMultiFileDiff(diff) {
|
|
2787
|
-
const lines = diff.split("\n");
|
|
2788
|
-
const patches = [];
|
|
2789
|
-
let currentPatch = null;
|
|
2790
|
-
let currentHunk = null;
|
|
2791
|
-
for (const line of lines) {
|
|
2792
|
-
if (line.startsWith("---")) {
|
|
2793
|
-
if (currentHunk && currentPatch) {
|
|
2794
|
-
currentPatch.hunks.push(currentHunk);
|
|
2795
|
-
currentHunk = null;
|
|
2796
|
-
}
|
|
2797
|
-
const pathPart = line.substring(3).trim();
|
|
2798
|
-
continue;
|
|
2799
|
-
}
|
|
2800
|
-
if (line.startsWith("+++")) {
|
|
2801
|
-
const pathPart = line.substring(3).trim();
|
|
2802
|
-
let filePath = pathPart;
|
|
2803
|
-
if (filePath.startsWith("b/")) {
|
|
2804
|
-
filePath = filePath.substring(2);
|
|
2805
|
-
} else if (filePath.startsWith("a/")) {
|
|
2806
|
-
filePath = filePath.substring(2);
|
|
2807
|
-
}
|
|
2808
|
-
currentPatch = {
|
|
2809
|
-
filePath,
|
|
2810
|
-
hunks: []
|
|
2811
|
-
};
|
|
2812
|
-
patches.push(currentPatch);
|
|
2813
|
-
continue;
|
|
2814
|
-
}
|
|
2815
|
-
if (line.startsWith("@@")) {
|
|
2816
|
-
if (!currentPatch) {
|
|
2817
|
-
continue;
|
|
2818
|
-
}
|
|
2819
|
-
if (currentHunk) {
|
|
2820
|
-
currentPatch.hunks.push(currentHunk);
|
|
2821
|
-
}
|
|
2822
|
-
currentHunk = {
|
|
2823
|
-
header: line,
|
|
2824
|
-
oldLines: [],
|
|
2825
|
-
newLines: []
|
|
2826
|
-
};
|
|
2827
|
-
continue;
|
|
2828
|
-
}
|
|
2829
|
-
if (currentHunk) {
|
|
2830
|
-
if (line.startsWith(" ")) {
|
|
2831
|
-
currentHunk.oldLines.push(line.slice(1));
|
|
2832
|
-
currentHunk.newLines.push(line.slice(1));
|
|
2833
|
-
} else if (line.startsWith("-")) {
|
|
2834
|
-
currentHunk.oldLines.push(line.slice(1));
|
|
2835
|
-
} else if (line.startsWith("+")) {
|
|
2836
|
-
currentHunk.newLines.push(line.slice(1));
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
}
|
|
2840
|
-
if (currentHunk && currentPatch) {
|
|
2841
|
-
currentPatch.hunks.push(currentHunk);
|
|
2842
|
-
}
|
|
2843
|
-
return patches;
|
|
2844
|
-
}
|
|
2845
|
-
static parse(diff) {
|
|
2846
|
-
const patches = this.parseMultiFileDiff(diff);
|
|
2847
|
-
if (patches.length === 0) {
|
|
2848
|
-
return this.parseRawHunks(diff);
|
|
2849
|
-
}
|
|
2850
|
-
return patches.flatMap((p) => p.hunks);
|
|
2851
|
-
}
|
|
2852
|
-
static parseRawHunks(diff) {
|
|
2853
|
-
const lines = diff.split("\n");
|
|
2854
|
-
const hunks = [];
|
|
2855
|
-
let currentHunk = null;
|
|
2856
|
-
for (const line of lines) {
|
|
2857
|
-
if (line.startsWith("---") || line.startsWith("+++")) continue;
|
|
2858
|
-
if (line.startsWith("@@")) {
|
|
2859
|
-
if (currentHunk) hunks.push(currentHunk);
|
|
2860
|
-
currentHunk = { header: line, oldLines: [], newLines: [] };
|
|
2861
|
-
continue;
|
|
2862
|
-
}
|
|
2863
|
-
if (currentHunk) {
|
|
2864
|
-
if (line.startsWith(" ")) {
|
|
2865
|
-
currentHunk.oldLines.push(line.slice(1));
|
|
2866
|
-
currentHunk.newLines.push(line.slice(1));
|
|
2867
|
-
} else if (line.startsWith("-")) {
|
|
2868
|
-
currentHunk.oldLines.push(line.slice(1));
|
|
2869
|
-
} else if (line.startsWith("+")) {
|
|
2870
|
-
currentHunk.newLines.push(line.slice(1));
|
|
2871
|
-
}
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
|
-
if (currentHunk) hunks.push(currentHunk);
|
|
2875
|
-
return hunks;
|
|
2876
|
-
}
|
|
2877
|
-
static apply(content, hunks) {
|
|
2878
|
-
const lines = content.split("\n");
|
|
2879
|
-
const replacements = [];
|
|
2880
|
-
let searchStartIndex = 0;
|
|
2881
|
-
for (const hunk of hunks) {
|
|
2882
|
-
let matchIndex = this.findContext(lines, hunk.oldLines, searchStartIndex);
|
|
2883
|
-
let oldLinesLength = hunk.oldLines.length;
|
|
2884
|
-
let newLines = hunk.newLines;
|
|
2885
|
-
if (matchIndex === -1 && hunk.oldLines.length > 0 && hunk.oldLines[hunk.oldLines.length - 1].trim() === "") {
|
|
2886
|
-
const reducedContext = hunk.oldLines.slice(0, -1);
|
|
2887
|
-
matchIndex = this.findContext(lines, reducedContext, searchStartIndex);
|
|
2888
|
-
if (matchIndex !== -1) {
|
|
2889
|
-
oldLinesLength = reducedContext.length;
|
|
2890
|
-
if (newLines.length > 0 && newLines[newLines.length - 1].trim() === "") {
|
|
2891
|
-
newLines = newLines.slice(0, -1);
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
if (matchIndex === -1) {
|
|
2896
|
-
throw new Error(`Could not find context for hunk: ${hunk.header}`);
|
|
2897
|
-
}
|
|
2898
|
-
replacements.push({
|
|
2899
|
-
start: matchIndex,
|
|
2900
|
-
length: oldLinesLength,
|
|
2901
|
-
newLines
|
|
2902
|
-
});
|
|
2903
|
-
searchStartIndex = matchIndex + oldLinesLength;
|
|
2904
|
-
}
|
|
2905
|
-
replacements.sort((a, b) => b.start - a.start);
|
|
2906
|
-
const resultLines = [...lines];
|
|
2907
|
-
for (const rep of replacements) {
|
|
2908
|
-
resultLines.splice(rep.start, rep.length, ...rep.newLines);
|
|
2909
|
-
}
|
|
2910
|
-
return resultLines.join("\n");
|
|
2911
|
-
}
|
|
2912
|
-
static findContext(lines, context, startIndex) {
|
|
2913
|
-
if (context.length === 0) return startIndex;
|
|
2914
|
-
for (let i = startIndex; i <= lines.length - context.length; i++) {
|
|
2915
|
-
let match = true;
|
|
2916
|
-
for (let j = 0; j < context.length; j++) {
|
|
2917
|
-
if (lines[i + j] !== context[j]) {
|
|
2918
|
-
match = false;
|
|
2919
|
-
break;
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
if (match) {
|
|
2923
|
-
return i;
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
const contentFromStart = lines.slice(startIndex).join("\n");
|
|
2927
|
-
const contextStr = context.join("\n");
|
|
2928
|
-
const strategies = [
|
|
2929
|
-
LineTrimmedReplacer,
|
|
2930
|
-
WhitespaceNormalizedReplacer,
|
|
2931
|
-
BlockAnchorReplacer,
|
|
2932
|
-
IndentationFlexibleReplacer,
|
|
2933
|
-
EscapeNormalizedReplacer,
|
|
2934
|
-
TrimmedBoundaryReplacer,
|
|
2935
|
-
ContextAwareReplacer,
|
|
2936
|
-
MultiOccurrenceReplacer
|
|
2937
|
-
];
|
|
2938
|
-
for (const replacer of strategies) {
|
|
2939
|
-
for (const match of replacer(contentFromStart, contextStr)) {
|
|
2940
|
-
const matchIndex = contentFromStart.indexOf(match);
|
|
2941
|
-
if (matchIndex !== -1) {
|
|
2942
|
-
const linesBefore = contentFromStart.substring(0, matchIndex).split("\n");
|
|
2943
|
-
const lineOffset = linesBefore.length - 1;
|
|
2944
|
-
return startIndex + lineOffset;
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
return -1;
|
|
2949
|
-
}
|
|
2950
|
-
};
|
|
2951
|
-
|
|
2952
|
-
// src/tools/filesystem/PatchTool/PatchTool.tsx
|
|
2953
|
-
import { readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
2954
|
-
|
|
2955
|
-
// src/tools/filesystem/PatchTool/prompt.ts
|
|
2956
|
-
var DESCRIPTION5 = `Apply a unified diff patch to one or more files.
|
|
2957
|
-
|
|
2958
|
-
Usage:
|
|
2959
|
-
- Provide a standard unified diff string (starting with \`--- a/file\` and \`+++ b/file\`).
|
|
2960
|
-
- The tool uses "Smart Patch" logic: it ignores strict line numbers in the diff header and uses context lines (starting with space) to locate the code block.
|
|
2961
|
-
- **Smart Context**: It tolerates minor indentation/whitespace differences between the diff context and the actual file (Fuzzy Matching).
|
|
2962
|
-
- **Atomic Transaction**: Supports applying changes to MULTIPLE files in a single atomic operation. If any file fails to patch (even after fuzzy matching), NO files will be changed (Strict Atomicity).
|
|
2963
|
-
- **Rich Feedback**: If a patch fails, the tool provides a detailed report explaining which file failed and why, allowing you to self-correct or fallback to EditTool.
|
|
2964
|
-
|
|
2965
|
-
When to use:
|
|
2966
|
-
- Complex refactoring involving multiple files (e.g., changing a function signature in .h and .cpp).
|
|
2967
|
-
- Applying structured changes where context is critical.
|
|
2968
|
-
- When you want to ensure atomicity across multiple file edits.
|
|
2969
|
-
|
|
2970
|
-
Example:
|
|
2971
|
-
\`\`\`diff
|
|
2972
|
-
--- src/utils.ts
|
|
2973
|
-
+++ src/utils.ts
|
|
2974
|
-
@@ -10,3 +10,3 @@
|
|
2975
|
-
function add(a, b) {
|
|
2976
|
-
- return a + b;
|
|
2977
|
-
+ return a + b + 0;
|
|
2978
|
-
}
|
|
2979
|
-
\`\`\`
|
|
2980
|
-
`;
|
|
2981
|
-
|
|
2982
|
-
// src/tools/filesystem/PatchTool/PatchTool.tsx
|
|
2723
|
+
// src/tools/mcp/ReadMcpResourceTool/ReadMcpResourceTool.tsx
|
|
2983
2724
|
import { Box as Box7, Text as Text7 } from "ink";
|
|
2984
2725
|
import React7 from "react";
|
|
2985
|
-
|
|
2986
|
-
patch: z7.string().describe("The unified diff to apply. Must include file headers (---/+++)")
|
|
2987
|
-
});
|
|
2988
|
-
var PatchTool = {
|
|
2989
|
-
name: "Patch",
|
|
2990
|
-
async description() {
|
|
2991
|
-
return "Apply a unified diff patch to one or more files";
|
|
2992
|
-
},
|
|
2993
|
-
async prompt() {
|
|
2994
|
-
return DESCRIPTION5;
|
|
2995
|
-
},
|
|
2996
|
-
inputSchema: inputSchema7,
|
|
2997
|
-
userFacingName() {
|
|
2998
|
-
return "Patch";
|
|
2999
|
-
},
|
|
3000
|
-
async isEnabled() {
|
|
3001
|
-
return true;
|
|
3002
|
-
},
|
|
3003
|
-
isReadOnly() {
|
|
3004
|
-
return false;
|
|
3005
|
-
},
|
|
3006
|
-
isConcurrencySafe() {
|
|
3007
|
-
return false;
|
|
3008
|
-
},
|
|
3009
|
-
needsPermissions() {
|
|
3010
|
-
return true;
|
|
3011
|
-
},
|
|
3012
|
-
renderToolUseMessage(input, { verbose }) {
|
|
3013
|
-
return `Applying patch...`;
|
|
3014
|
-
},
|
|
3015
|
-
renderToolResultMessage(result) {
|
|
3016
|
-
const count = result.metadata?.files_changed?.length ?? 0;
|
|
3017
|
-
return /* @__PURE__ */ React7.createElement(Box7, { flexDirection: "column" }, /* @__PURE__ */ React7.createElement(Text7, null, "Patch applied successfully to ", count, " files."));
|
|
3018
|
-
},
|
|
3019
|
-
async validateInput({ patch }) {
|
|
3020
|
-
if (!patch || patch.trim().length === 0) {
|
|
3021
|
-
return { result: false, message: "Patch content is required" };
|
|
3022
|
-
}
|
|
3023
|
-
return { result: true };
|
|
3024
|
-
},
|
|
3025
|
-
async *call(input, context) {
|
|
3026
|
-
const { patch } = input;
|
|
3027
|
-
const patches = PatchManager.parseMultiFileDiff(patch);
|
|
3028
|
-
if (patches.length === 0) {
|
|
3029
|
-
throw new Error("No valid hunks found in patch. Ensure standard Unified Diff format with file headers (---/+++).");
|
|
3030
|
-
}
|
|
3031
|
-
const fileContents = /* @__PURE__ */ new Map();
|
|
3032
|
-
const resolvedPaths = /* @__PURE__ */ new Map();
|
|
3033
|
-
for (const p of patches) {
|
|
3034
|
-
let filePath = p.filePath.trim();
|
|
3035
|
-
if (!fileExistsBun(filePath) && (filePath.startsWith("a/") || filePath.startsWith("b/"))) {
|
|
3036
|
-
const stripped = filePath.substring(2);
|
|
3037
|
-
if (fileExistsBun(stripped)) {
|
|
3038
|
-
filePath = stripped;
|
|
3039
|
-
}
|
|
3040
|
-
}
|
|
3041
|
-
if (!fileExistsBun(filePath)) {
|
|
3042
|
-
throw new Error(`Target file not found: ${filePath}`);
|
|
3043
|
-
}
|
|
3044
|
-
resolvedPaths.set(p.filePath, filePath);
|
|
3045
|
-
const content = readFileSync4(filePath, "utf-8");
|
|
3046
|
-
fileContents.set(p.filePath, content);
|
|
3047
|
-
}
|
|
3048
|
-
const result = PatchManager.applyTransactional(patches, fileContents, { strategy: "strict" });
|
|
3049
|
-
if (!result.success) {
|
|
3050
|
-
const failures = result.failedFiles.map((f) => {
|
|
3051
|
-
const err = result.errors.get(f) || "Unknown error";
|
|
3052
|
-
return `- ${f}: ${err}`;
|
|
3053
|
-
}).join("\n");
|
|
3054
|
-
throw new Error(
|
|
3055
|
-
`Patch failed (Atomic Rollback). No files were changed.
|
|
3056
|
-
Failures:
|
|
3057
|
-
${failures}
|
|
3058
|
-
Recommendation: Use 'Edit' tool for failed files or fix the patch context.`
|
|
3059
|
-
);
|
|
3060
|
-
}
|
|
3061
|
-
const changedFiles = [];
|
|
3062
|
-
for (const [patchPath, newContent] of result.newContents) {
|
|
3063
|
-
const absPath = resolvedPaths.get(patchPath);
|
|
3064
|
-
if (absPath) {
|
|
3065
|
-
writeFileSync2(absPath, newContent);
|
|
3066
|
-
changedFiles.push(absPath);
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
yield {
|
|
3070
|
-
type: "result",
|
|
3071
|
-
data: {
|
|
3072
|
-
output: `Successfully applied patch to ${changedFiles.length} files:
|
|
3073
|
-
${changedFiles.map((f) => `- ${f}`).join("\n")}`,
|
|
3074
|
-
metadata: {
|
|
3075
|
-
files_changed: changedFiles
|
|
3076
|
-
}
|
|
3077
|
-
},
|
|
3078
|
-
resultForAssistant: `Successfully applied patch to ${changedFiles.length} files: ${changedFiles.join(", ")}`
|
|
3079
|
-
};
|
|
3080
|
-
}
|
|
3081
|
-
};
|
|
3082
|
-
|
|
3083
|
-
// src/tools/mcp/ReadMcpResourceTool/ReadMcpResourceTool.tsx
|
|
3084
|
-
import { Box as Box8, Text as Text8 } from "ink";
|
|
3085
|
-
import React8 from "react";
|
|
3086
|
-
import { z as z8 } from "zod";
|
|
2726
|
+
import { z as z7 } from "zod";
|
|
3087
2727
|
import { ReadResourceResultSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
3088
2728
|
|
|
3089
2729
|
// src/tools/mcp/ReadMcpResourceTool/prompt.ts
|
|
3090
2730
|
var TOOL_NAME2 = "ReadMcpResourceTool";
|
|
3091
|
-
var
|
|
2731
|
+
var DESCRIPTION5 = `Reads a specific resource from an MCP server.
|
|
3092
2732
|
- server: The name of the MCP server to read from
|
|
3093
2733
|
- uri: The URI of the resource to read
|
|
3094
2734
|
|
|
@@ -3101,19 +2741,19 @@ Parameters:
|
|
|
3101
2741
|
- uri (required): The URI of the resource to read`;
|
|
3102
2742
|
|
|
3103
2743
|
// src/tools/mcp/ReadMcpResourceTool/ReadMcpResourceTool.tsx
|
|
3104
|
-
var
|
|
3105
|
-
server:
|
|
3106
|
-
uri:
|
|
2744
|
+
var inputSchema7 = z7.strictObject({
|
|
2745
|
+
server: z7.string().describe("The MCP server name"),
|
|
2746
|
+
uri: z7.string().describe("The resource URI to read")
|
|
3107
2747
|
});
|
|
3108
2748
|
var ReadMcpResourceTool = {
|
|
3109
2749
|
name: TOOL_NAME2,
|
|
3110
2750
|
async description() {
|
|
3111
|
-
return
|
|
2751
|
+
return DESCRIPTION5;
|
|
3112
2752
|
},
|
|
3113
2753
|
async prompt() {
|
|
3114
2754
|
return PROMPT5;
|
|
3115
2755
|
},
|
|
3116
|
-
inputSchema:
|
|
2756
|
+
inputSchema: inputSchema7,
|
|
3117
2757
|
userFacingName() {
|
|
3118
2758
|
return "readMcpResource";
|
|
3119
2759
|
},
|
|
@@ -3168,11 +2808,11 @@ var ReadMcpResourceTool = {
|
|
|
3168
2808
|
return `Read resource "${uri}" from server "${server}"`;
|
|
3169
2809
|
},
|
|
3170
2810
|
renderToolUseRejectedMessage() {
|
|
3171
|
-
return /* @__PURE__ */
|
|
2811
|
+
return /* @__PURE__ */ React7.createElement(FallbackToolUseRejectedMessage, null);
|
|
3172
2812
|
},
|
|
3173
2813
|
renderToolResultMessage(output) {
|
|
3174
2814
|
const count = output.contents?.length ?? 0;
|
|
3175
|
-
return /* @__PURE__ */
|
|
2815
|
+
return /* @__PURE__ */ React7.createElement(Box7, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React7.createElement(Box7, { flexDirection: "row" }, /* @__PURE__ */ React7.createElement(Text7, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React7.createElement(Text7, { bold: true }, "Read MCP resource"), /* @__PURE__ */ React7.createElement(Text7, null, count ? ` (${count} part${count === 1 ? "" : "s"})` : "")), /* @__PURE__ */ React7.createElement(Cost, { costUSD: 0, durationMs: 0, debug: false }));
|
|
3176
2816
|
},
|
|
3177
2817
|
renderResultForAssistant(output) {
|
|
3178
2818
|
return JSON.stringify(output);
|
|
@@ -3213,11 +2853,11 @@ var ReadMcpResourceTool = {
|
|
|
3213
2853
|
|
|
3214
2854
|
// src/tools/agent/TaskTool/TaskTool.tsx
|
|
3215
2855
|
import { last, memoize } from "lodash-es";
|
|
3216
|
-
import
|
|
3217
|
-
import { Box as
|
|
3218
|
-
import { z as
|
|
2856
|
+
import React8 from "react";
|
|
2857
|
+
import { Box as Box8, Text as Text8 } from "ink";
|
|
2858
|
+
import { z as z8 } from "zod";
|
|
3219
2859
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
3220
|
-
import { existsSync as existsSync5, readFileSync as
|
|
2860
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
3221
2861
|
|
|
3222
2862
|
// src/utils/agent/transcripts.ts
|
|
3223
2863
|
var transcripts = /* @__PURE__ */ new Map();
|
|
@@ -3313,17 +2953,17 @@ assistant: "I'm going to use the Task tool to launch the with the greeting-respo
|
|
|
3313
2953
|
var TOOL_NAME3 = "Task";
|
|
3314
2954
|
|
|
3315
2955
|
// src/tools/agent/TaskTool/TaskTool.tsx
|
|
3316
|
-
var
|
|
3317
|
-
description:
|
|
3318
|
-
prompt:
|
|
3319
|
-
subagent_type:
|
|
3320
|
-
model:
|
|
2956
|
+
var inputSchema8 = z8.object({
|
|
2957
|
+
description: z8.string().describe("A short (3-5 word) description of the task"),
|
|
2958
|
+
prompt: z8.string().describe("The task for the agent to perform"),
|
|
2959
|
+
subagent_type: z8.string().describe("The type of specialized agent to use for this task"),
|
|
2960
|
+
model: z8.enum(["sonnet", "opus", "haiku"]).optional().describe(
|
|
3321
2961
|
"Optional model to use for this agent. If not specified, inherits from parent. Prefer haiku for quick, straightforward tasks to minimize cost and latency."
|
|
3322
2962
|
),
|
|
3323
|
-
resume:
|
|
2963
|
+
resume: z8.string().optional().describe(
|
|
3324
2964
|
"Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript."
|
|
3325
2965
|
),
|
|
3326
|
-
run_in_background:
|
|
2966
|
+
run_in_background: z8.boolean().optional().describe(
|
|
3327
2967
|
"Set to true to run this agent in the background. Use TaskOutput to read the output later."
|
|
3328
2968
|
)
|
|
3329
2969
|
});
|
|
@@ -3393,7 +3033,7 @@ function applyAgentPermissionMode(base, options) {
|
|
|
3393
3033
|
function readJsonArrayFile(path) {
|
|
3394
3034
|
if (!existsSync5(path)) return null;
|
|
3395
3035
|
try {
|
|
3396
|
-
const raw =
|
|
3036
|
+
const raw = readFileSync4(path, "utf8");
|
|
3397
3037
|
const parsed = JSON.parse(raw);
|
|
3398
3038
|
return Array.isArray(parsed) ? parsed : null;
|
|
3399
3039
|
} catch {
|
|
@@ -3474,7 +3114,7 @@ function buildForkContextForAgent(options) {
|
|
|
3474
3114
|
}
|
|
3475
3115
|
var TaskTool = {
|
|
3476
3116
|
name: TOOL_NAME3,
|
|
3477
|
-
inputSchema:
|
|
3117
|
+
inputSchema: inputSchema8,
|
|
3478
3118
|
async description() {
|
|
3479
3119
|
return "Launch a new task";
|
|
3480
3120
|
},
|
|
@@ -3537,20 +3177,20 @@ var TaskTool = {
|
|
|
3537
3177
|
return description;
|
|
3538
3178
|
},
|
|
3539
3179
|
renderToolUseRejectedMessage() {
|
|
3540
|
-
return /* @__PURE__ */
|
|
3180
|
+
return /* @__PURE__ */ React8.createElement(FallbackToolUseRejectedMessage, null);
|
|
3541
3181
|
},
|
|
3542
3182
|
renderToolResultMessage(output, { verbose }) {
|
|
3543
3183
|
const theme = getTheme();
|
|
3544
3184
|
if (output.status === "async_launched") {
|
|
3545
3185
|
const hint = output.prompt ? " (down arrow \u2193 to manage \xB7 ctrl+o to expand)" : " (down arrow \u2193 to manage)";
|
|
3546
|
-
return /* @__PURE__ */
|
|
3547
|
-
|
|
3186
|
+
return /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "column" }, /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "row" }, /* @__PURE__ */ React8.createElement(Text8, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React8.createElement(Text8, null, "Backgrounded agent", !verbose && /* @__PURE__ */ React8.createElement(Text8, { dimColor: true }, hint))), verbose && output.prompt && /* @__PURE__ */ React8.createElement(
|
|
3187
|
+
Box8,
|
|
3548
3188
|
{
|
|
3549
3189
|
paddingLeft: 2,
|
|
3550
3190
|
borderLeftStyle: "single",
|
|
3551
3191
|
borderLeftColor: theme.secondaryBorder
|
|
3552
3192
|
},
|
|
3553
|
-
/* @__PURE__ */
|
|
3193
|
+
/* @__PURE__ */ React8.createElement(Text8, { color: theme.secondaryText, wrap: "wrap" }, output.prompt)
|
|
3554
3194
|
));
|
|
3555
3195
|
}
|
|
3556
3196
|
const summary = [
|
|
@@ -3558,32 +3198,32 @@ var TaskTool = {
|
|
|
3558
3198
|
`${formatNumber(output.totalTokens)} tokens`,
|
|
3559
3199
|
formatDuration(output.totalDurationMs)
|
|
3560
3200
|
];
|
|
3561
|
-
return /* @__PURE__ */
|
|
3562
|
-
|
|
3201
|
+
return /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "column" }, verbose && output.prompt && /* @__PURE__ */ React8.createElement(
|
|
3202
|
+
Box8,
|
|
3563
3203
|
{
|
|
3564
3204
|
paddingLeft: 2,
|
|
3565
3205
|
borderLeftStyle: "single",
|
|
3566
3206
|
borderLeftColor: theme.secondaryBorder
|
|
3567
3207
|
},
|
|
3568
|
-
/* @__PURE__ */
|
|
3208
|
+
/* @__PURE__ */ React8.createElement(Text8, { color: theme.secondaryText, wrap: "wrap" }, maybeTruncateVerboseToolOutput(output.prompt, {
|
|
3569
3209
|
maxLines: 120,
|
|
3570
3210
|
maxChars: 2e4
|
|
3571
3211
|
}).text)
|
|
3572
|
-
), verbose && output.content.length > 0 && /* @__PURE__ */
|
|
3573
|
-
|
|
3212
|
+
), verbose && output.content.length > 0 && /* @__PURE__ */ React8.createElement(
|
|
3213
|
+
Box8,
|
|
3574
3214
|
{
|
|
3575
3215
|
paddingLeft: 2,
|
|
3576
3216
|
borderLeftStyle: "single",
|
|
3577
3217
|
borderLeftColor: theme.secondaryBorder
|
|
3578
3218
|
},
|
|
3579
|
-
/* @__PURE__ */
|
|
3219
|
+
/* @__PURE__ */ React8.createElement(Text8, { wrap: "wrap" }, maybeTruncateVerboseToolOutput(
|
|
3580
3220
|
output.content.map((b) => b.text).join("\n"),
|
|
3581
3221
|
{
|
|
3582
3222
|
maxLines: 200,
|
|
3583
3223
|
maxChars: 4e4
|
|
3584
3224
|
}
|
|
3585
3225
|
).text)
|
|
3586
|
-
), /* @__PURE__ */
|
|
3226
|
+
), /* @__PURE__ */ React8.createElement(Box8, { flexDirection: "row" }, /* @__PURE__ */ React8.createElement(Text8, null, "\xA0\xA0\u23BF \xA0"), /* @__PURE__ */ React8.createElement(Text8, { dimColor: true }, "Done (", summary.join(" \xB7 "), ")")));
|
|
3587
3227
|
},
|
|
3588
3228
|
renderResultForAssistant(output) {
|
|
3589
3229
|
if (output.status === "async_launched")
|
|
@@ -3908,6 +3548,194 @@ var TaskTool = {
|
|
|
3908
3548
|
}
|
|
3909
3549
|
};
|
|
3910
3550
|
|
|
3551
|
+
// src/tools/WebFetcher/WebFetcherTool.tsx
|
|
3552
|
+
import { z as z9 } from "zod";
|
|
3553
|
+
|
|
3554
|
+
// src/tools/WebFetcher/WebFetcher.ts
|
|
3555
|
+
import fetch from "node-fetch";
|
|
3556
|
+
import { AbortController as AbortController2 } from "abort-controller";
|
|
3557
|
+
import { parse } from "node-html-parser";
|
|
3558
|
+
import TurndownService from "turndown";
|
|
3559
|
+
import { gfm } from "turndown-plugin-gfm";
|
|
3560
|
+
var WebFetcher = class {
|
|
3561
|
+
DEFAULT_TIMEOUT = 30;
|
|
3562
|
+
// seconds
|
|
3563
|
+
MAX_RESPONSE_SIZE = 5 * 1024 * 1024;
|
|
3564
|
+
// 5MB
|
|
3565
|
+
CACHE_TTL = 15 * 60 * 1e3;
|
|
3566
|
+
// 15 minutes
|
|
3567
|
+
MAX_ANALYSIS_CONTENT_LENGTH = 5e4;
|
|
3568
|
+
// ~15k tokens
|
|
3569
|
+
turndownService;
|
|
3570
|
+
cache = /* @__PURE__ */ new Map();
|
|
3571
|
+
constructor() {
|
|
3572
|
+
this.turndownService = new TurndownService({
|
|
3573
|
+
headingStyle: "atx",
|
|
3574
|
+
codeBlockStyle: "fenced",
|
|
3575
|
+
bulletListMarker: "-",
|
|
3576
|
+
// Explicitly set bullet marker
|
|
3577
|
+
emDelimiter: "*"
|
|
3578
|
+
});
|
|
3579
|
+
this.turndownService.use(gfm);
|
|
3580
|
+
}
|
|
3581
|
+
async execute(input) {
|
|
3582
|
+
let content;
|
|
3583
|
+
let isCached = false;
|
|
3584
|
+
const format = input.format || "markdown";
|
|
3585
|
+
const cached = this.cache.get(input.url);
|
|
3586
|
+
if (cached) {
|
|
3587
|
+
if (Date.now() - cached.timestamp < this.CACHE_TTL) {
|
|
3588
|
+
content = cached.content;
|
|
3589
|
+
isCached = true;
|
|
3590
|
+
} else {
|
|
3591
|
+
this.cache.delete(input.url);
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
if (!isCached) {
|
|
3595
|
+
const timeout = (input.timeout || this.DEFAULT_TIMEOUT) * 1e3;
|
|
3596
|
+
const controller = new AbortController2();
|
|
3597
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
3598
|
+
try {
|
|
3599
|
+
const response = await fetch(input.url, {
|
|
3600
|
+
method: "GET",
|
|
3601
|
+
headers: {
|
|
3602
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
|
3603
|
+
},
|
|
3604
|
+
signal: controller.signal
|
|
3605
|
+
});
|
|
3606
|
+
if (!response.ok) {
|
|
3607
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
3608
|
+
}
|
|
3609
|
+
const contentLength = response.headers.get("content-length");
|
|
3610
|
+
if (contentLength && parseInt(contentLength) > this.MAX_RESPONSE_SIZE) {
|
|
3611
|
+
throw new Error("Response too large (exceeds 5MB limit)");
|
|
3612
|
+
}
|
|
3613
|
+
const contentType = response.headers.get("content-type") || "";
|
|
3614
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3615
|
+
if (arrayBuffer.byteLength > this.MAX_RESPONSE_SIZE) {
|
|
3616
|
+
throw new Error("Response too large (exceeds 5MB limit)");
|
|
3617
|
+
}
|
|
3618
|
+
const text = new TextDecoder().decode(arrayBuffer);
|
|
3619
|
+
let rawContent = text;
|
|
3620
|
+
if (contentType.includes("text/html")) {
|
|
3621
|
+
if (format === "markdown") {
|
|
3622
|
+
const cleanedHtml = this.cleanHtml(text);
|
|
3623
|
+
rawContent = this.turndownService.turndown(cleanedHtml);
|
|
3624
|
+
} else if (format === "text") {
|
|
3625
|
+
const cleanedHtml = this.cleanHtml(text);
|
|
3626
|
+
const root = parse(cleanedHtml);
|
|
3627
|
+
rawContent = root.textContent.trim();
|
|
3628
|
+
} else if (format === "html") {
|
|
3629
|
+
rawContent = this.cleanHtml(text);
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
content = rawContent;
|
|
3633
|
+
this.cache.set(input.url, { content, timestamp: Date.now() });
|
|
3634
|
+
} finally {
|
|
3635
|
+
clearTimeout(timeoutId);
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
if (input.prompt) {
|
|
3639
|
+
const truncatedContent = content.length > this.MAX_ANALYSIS_CONTENT_LENGTH ? content.substring(0, this.MAX_ANALYSIS_CONTENT_LENGTH) + "\n\n[Content truncated due to length]" : content;
|
|
3640
|
+
const systemPrompt = [
|
|
3641
|
+
"You are analyzing web content based on a user's specific request.",
|
|
3642
|
+
"The content has been extracted from a webpage and converted to markdown.",
|
|
3643
|
+
"Provide a focused response that directly addresses the user's prompt."
|
|
3644
|
+
];
|
|
3645
|
+
const userPrompt = `Here is the content from ${input.url}:
|
|
3646
|
+
|
|
3647
|
+
${truncatedContent}
|
|
3648
|
+
|
|
3649
|
+
User request: ${input.prompt}`;
|
|
3650
|
+
const aiResponse = await queryQuick({
|
|
3651
|
+
systemPrompt,
|
|
3652
|
+
userPrompt,
|
|
3653
|
+
enablePromptCaching: false
|
|
3654
|
+
});
|
|
3655
|
+
const aiText = aiResponse.message.content.filter((c) => c.type === "text").map((c) => c.text).join("");
|
|
3656
|
+
return {
|
|
3657
|
+
url: input.url,
|
|
3658
|
+
title: input.url,
|
|
3659
|
+
content: aiText,
|
|
3660
|
+
metadata: {
|
|
3661
|
+
mode: "analysis",
|
|
3662
|
+
format,
|
|
3663
|
+
cached: isCached
|
|
3664
|
+
}
|
|
3665
|
+
};
|
|
3666
|
+
}
|
|
3667
|
+
return {
|
|
3668
|
+
url: input.url,
|
|
3669
|
+
title: input.url,
|
|
3670
|
+
// Temporary title
|
|
3671
|
+
content,
|
|
3672
|
+
metadata: {
|
|
3673
|
+
mode: "fetch",
|
|
3674
|
+
format,
|
|
3675
|
+
cached: isCached
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
}
|
|
3679
|
+
cleanHtml(html) {
|
|
3680
|
+
const root = parse(html);
|
|
3681
|
+
const elementsToRemove = root.querySelectorAll("script, style, nav, footer, iframe, noscript, object, embed");
|
|
3682
|
+
elementsToRemove.forEach((el) => el.remove());
|
|
3683
|
+
return root.toString();
|
|
3684
|
+
}
|
|
3685
|
+
};
|
|
3686
|
+
|
|
3687
|
+
// src/tools/WebFetcher/WebFetcherTool.tsx
|
|
3688
|
+
import React9 from "react";
|
|
3689
|
+
import { Box as Box9, Text as Text9 } from "ink";
|
|
3690
|
+
var inputSchema9 = z9.strictObject({
|
|
3691
|
+
url: z9.string().url().describe("The URL to fetch content from"),
|
|
3692
|
+
prompt: z9.string().optional().describe("Optional prompt to perform AI analysis on the content"),
|
|
3693
|
+
format: z9.enum(["markdown", "html", "text"]).optional().describe("Output format (default: markdown)"),
|
|
3694
|
+
timeout: z9.number().optional().describe("Timeout in seconds (default: 30)")
|
|
3695
|
+
});
|
|
3696
|
+
var WebFetcherTool = {
|
|
3697
|
+
name: "web_fetcher",
|
|
3698
|
+
async description() {
|
|
3699
|
+
return "Fetch and analyze web content. Supports HTML cleaning, Markdown conversion, and AI-powered analysis.";
|
|
3700
|
+
},
|
|
3701
|
+
userFacingName: () => "Web Fetcher",
|
|
3702
|
+
inputSchema: inputSchema9,
|
|
3703
|
+
isReadOnly: () => true,
|
|
3704
|
+
isConcurrencySafe: () => true,
|
|
3705
|
+
async isEnabled() {
|
|
3706
|
+
return true;
|
|
3707
|
+
},
|
|
3708
|
+
needsPermissions() {
|
|
3709
|
+
return true;
|
|
3710
|
+
},
|
|
3711
|
+
async prompt() {
|
|
3712
|
+
return "Fetch and analyze web content. Supports HTML cleaning, Markdown conversion, and AI-powered analysis.";
|
|
3713
|
+
},
|
|
3714
|
+
renderResultForAssistant(output) {
|
|
3715
|
+
if (output.metadata.mode === "analysis") {
|
|
3716
|
+
return output.content;
|
|
3717
|
+
}
|
|
3718
|
+
return `Content from ${output.url} (Format: ${output.metadata.format}):
|
|
3719
|
+
|
|
3720
|
+
${output.content}`;
|
|
3721
|
+
},
|
|
3722
|
+
renderToolUseMessage(input) {
|
|
3723
|
+
return `Fetching ${input.url}${input.prompt ? ` with prompt: "${input.prompt}"` : ""}`;
|
|
3724
|
+
},
|
|
3725
|
+
renderToolResultMessage(output) {
|
|
3726
|
+
return /* @__PURE__ */ React9.createElement(Box9, { flexDirection: "column" }, /* @__PURE__ */ React9.createElement(Text9, null, "Fetched ", output.url, " (", output.metadata.mode, ")"));
|
|
3727
|
+
},
|
|
3728
|
+
async *call(input, context) {
|
|
3729
|
+
const fetcher = new WebFetcher();
|
|
3730
|
+
const result = await fetcher.execute(input);
|
|
3731
|
+
yield {
|
|
3732
|
+
type: "result",
|
|
3733
|
+
data: result,
|
|
3734
|
+
resultForAssistant: this.renderResultForAssistant(result)
|
|
3735
|
+
};
|
|
3736
|
+
}
|
|
3737
|
+
};
|
|
3738
|
+
|
|
3911
3739
|
// src/tools/index.ts
|
|
3912
3740
|
var getAllTools = () => [
|
|
3913
3741
|
TaskTool,
|
|
@@ -3924,10 +3752,8 @@ var getAllTools = () => [
|
|
|
3924
3752
|
FileWriteTool,
|
|
3925
3753
|
DeleteTool,
|
|
3926
3754
|
NotebookEditTool,
|
|
3927
|
-
PatchTool,
|
|
3928
3755
|
TodoWriteTool,
|
|
3929
|
-
|
|
3930
|
-
WebFetchTool,
|
|
3756
|
+
WebFetcherTool,
|
|
3931
3757
|
AskUserQuestionTool,
|
|
3932
3758
|
EnterPlanModeTool,
|
|
3933
3759
|
ExitPlanModeTool,
|