pybao-cli 1.3.61 → 1.3.63
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-5X765244.js +42 -0
- package/dist/{acp-LZJ5INJE.js → acp-JTKQKLVO.js} +35 -33
- package/dist/{acp-LZJ5INJE.js.map → acp-JTKQKLVO.js.map} +1 -1
- package/dist/{agentsValidate-N54BKLVP.js → agentsValidate-IYVHFZ26.js} +7 -7
- package/dist/{ask-ZKDEBYMS.js → ask-YM5GY5P3.js} +29 -29
- package/dist/{autoUpdater-EVJBALA4.js → autoUpdater-LIAZH25N.js} +3 -3
- package/dist/blockParser-CFQE5IAN.js +54 -0
- package/dist/blockParser-CFQE5IAN.js.map +7 -0
- package/dist/{chunk-UVXNKM7B.js → chunk-4HB7MQDC.js} +3 -3
- package/dist/{chunk-5532VV4Q.js → chunk-5764Z4HA.js} +3 -3
- package/dist/{chunk-3NDYIVBC.js → chunk-6OFYDHOG.js} +3 -3
- package/dist/{chunk-LPZM3TPE.js → chunk-7B65UVZB.js} +2 -2
- package/dist/{chunk-YH5MHBEP.js → chunk-AKXEHZ7A.js} +3 -3
- package/dist/{chunk-TOFBGLUH.js → chunk-B3L6T5WY.js} +5 -5
- package/dist/{chunk-6LGTEHBU.js → chunk-DGZHUQKC.js} +1 -1
- package/dist/{chunk-6LGTEHBU.js.map → chunk-DGZHUQKC.js.map} +1 -1
- package/dist/{chunk-42TRCLX2.js → chunk-DTEKTK3C.js} +3 -3
- package/dist/{chunk-QQAZYIJT.js → chunk-E4522PV7.js} +3 -3
- package/dist/{chunk-6VBVWVVU.js → chunk-EQGVECW5.js} +1 -1
- package/dist/{chunk-PBX3ZVXF.js → chunk-FSIAWTBZ.js} +4 -4
- package/dist/{chunk-Y4MFP2PI.js → chunk-FZ33A73T.js} +1 -1
- package/dist/{chunk-IIWES7RB.js → chunk-GIC3LEOF.js} +6 -6
- package/dist/{chunk-GRFWVW5Q.js → chunk-KBZBNDRL.js} +1 -1
- package/dist/{chunk-UPM6LKXT.js → chunk-MR6HRZTD.js} +1 -1
- package/dist/{chunk-HNN3HQ4F.js → chunk-NSLPJVLG.js} +1 -1
- package/dist/{chunk-JXPU7KX4.js → chunk-NZMZFOHR.js} +1 -1
- package/dist/{chunk-K27QB3XA.js → chunk-PYJ5LALG.js} +1 -1
- package/dist/{chunk-2GJIHGW2.js → chunk-QJN2OEN4.js} +1 -1
- package/dist/chunk-QONPUH55.js +323 -0
- package/dist/chunk-QONPUH55.js.map +7 -0
- package/dist/{chunk-EL5ALYRQ.js → chunk-REXF6JZS.js} +156 -745
- package/dist/chunk-REXF6JZS.js.map +7 -0
- package/dist/{chunk-IHAFN2IR.js → chunk-RPBHMFRQ.js} +2 -2
- package/dist/{chunk-6PWUBWII.js → chunk-SFR3TP23.js} +2 -2
- package/dist/{chunk-WDMJBURS.js → chunk-UDC5YCXW.js} +2 -2
- package/dist/chunk-UT7AY3SZ.js +727 -0
- package/dist/chunk-UT7AY3SZ.js.map +7 -0
- package/dist/{chunk-IAEGVIG2.js → chunk-VMXD4DPP.js} +1 -1
- package/dist/{chunk-EFIY2OBF.js → chunk-YJQFTMXY.js} +2 -2
- package/dist/{chunk-TDCCSW57.js → chunk-ZLHQG6DX.js} +7 -7
- package/dist/{chunk-YCYQLJZ4.js → chunk-ZQF3JNND.js} +543 -775
- package/dist/chunk-ZQF3JNND.js.map +7 -0
- package/dist/{cli-3ZUP2X4I.js → cli-XQPTX7DX.js} +90 -88
- package/dist/{cli-3ZUP2X4I.js.map → cli-XQPTX7DX.js.map} +1 -1
- package/dist/commands-BJHACFCG.js +46 -0
- package/dist/{config-EO6W7HT6.js → config-CZ72HP4B.js} +4 -4
- package/dist/{context-ZD3A3X7W.js → context-PYVZ2UIV.js} +5 -5
- package/dist/{customCommands-CK62GG2A.js → customCommands-SM2TONHF.js} +4 -4
- package/dist/{env-JRY7UKS5.js → env-TIOWJNM3.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/{llm-2R3YDGM5.js → llm-NW2S47DG.js} +36 -36
- package/dist/{llmLazy-DQH7QRMR.js → llmLazy-HL7WHPNN.js} +1 -1
- package/dist/{loader-AIAHQGDY.js → loader-TUZWQP7L.js} +4 -4
- package/dist/lspAnchor-2ZRP7RIX.js +77 -0
- package/dist/lspAnchor-2ZRP7RIX.js.map +7 -0
- package/dist/manager-VXNOOVJ2.js +12 -0
- package/dist/{mcp-PIZTHOTG.js → mcp-3GAO6ZWX.js} +7 -7
- package/dist/{mentionProcessor-G3HE2SGJ.js → mentionProcessor-A5H4NAU2.js} +5 -5
- package/dist/{messages-7ERVBYYH.js → messages-FIKPJNRV.js} +1 -1
- package/dist/{model-PYSWBB22.js → model-4ZGIHII2.js} +5 -5
- package/dist/{openai-5CTLKASP.js → openai-JAYMLYTY.js} +5 -5
- package/dist/{outputStyles-ZNNZXMTY.js → outputStyles-KNJY3E27.js} +4 -4
- package/dist/{pluginRuntime-EJS6GFVB.js → pluginRuntime-SHFEMATT.js} +6 -6
- package/dist/{pluginValidation-HDLXFMVA.js → pluginValidation-7LENCJCL.js} +6 -6
- package/dist/prompts-WKHO6LU3.js +48 -0
- package/dist/{pybAgentSessionLoad-EO52TKZC.js → pybAgentSessionLoad-KQDIJWHN.js} +4 -4
- package/dist/{pybAgentSessionResume-RF36X2HT.js → pybAgentSessionResume-OW7FJ3VU.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-NSBZXQNX.js → pybAgentStreamJsonSession-A7P4SBXT.js} +1 -1
- package/dist/{pybHooks-ZAJMYPMH.js → pybHooks-FBR77SZL.js} +4 -4
- package/dist/query-TTURURS2.js +50 -0
- package/dist/{ripgrep-KP4CGUAZ.js → ripgrep-2KX6Q2XT.js} +3 -3
- package/dist/{skillMarketplace-7WJ3SVIA.js → skillMarketplace-BG4Y3IXW.js} +3 -3
- package/dist/smart-edit-J5J4S2TS.js +54 -0
- package/dist/smart-edit-J5J4S2TS.js.map +7 -0
- package/dist/{state-AKOQ2NMP.js → state-E53XB637.js} +2 -2
- package/dist/{theme-D7PCPHYJ.js → theme-ZXJL5RLH.js} +5 -5
- package/dist/{toolPermissionSettings-GYB4MNUP.js → toolPermissionSettings-3JMTQH6J.js} +6 -6
- package/dist/tools-AFRLWREJ.js +49 -0
- package/dist/tools-AFRLWREJ.js.map +7 -0
- package/dist/{userInput-LIQKUPCD.js → userInput-CQQYFYGG.js} +32 -32
- package/package.json +1 -1
- package/dist/REPL-AIFVTVNV.js +0 -42
- package/dist/chunk-EL5ALYRQ.js.map +0 -7
- package/dist/chunk-YCYQLJZ4.js.map +0 -7
- package/dist/commands-GURVRN72.js +0 -46
- package/dist/prompts-NGAMEMXP.js +0 -48
- package/dist/query-SZRZBXEO.js +0 -50
- package/dist/tools-KFBHBGPN.js +0 -47
- /package/dist/{REPL-AIFVTVNV.js.map → REPL-5X765244.js.map} +0 -0
- /package/dist/{agentsValidate-N54BKLVP.js.map → agentsValidate-IYVHFZ26.js.map} +0 -0
- /package/dist/{ask-ZKDEBYMS.js.map → ask-YM5GY5P3.js.map} +0 -0
- /package/dist/{autoUpdater-EVJBALA4.js.map → autoUpdater-LIAZH25N.js.map} +0 -0
- /package/dist/{chunk-UVXNKM7B.js.map → chunk-4HB7MQDC.js.map} +0 -0
- /package/dist/{chunk-5532VV4Q.js.map → chunk-5764Z4HA.js.map} +0 -0
- /package/dist/{chunk-3NDYIVBC.js.map → chunk-6OFYDHOG.js.map} +0 -0
- /package/dist/{chunk-LPZM3TPE.js.map → chunk-7B65UVZB.js.map} +0 -0
- /package/dist/{chunk-YH5MHBEP.js.map → chunk-AKXEHZ7A.js.map} +0 -0
- /package/dist/{chunk-TOFBGLUH.js.map → chunk-B3L6T5WY.js.map} +0 -0
- /package/dist/{chunk-42TRCLX2.js.map → chunk-DTEKTK3C.js.map} +0 -0
- /package/dist/{chunk-QQAZYIJT.js.map → chunk-E4522PV7.js.map} +0 -0
- /package/dist/{chunk-6VBVWVVU.js.map → chunk-EQGVECW5.js.map} +0 -0
- /package/dist/{chunk-PBX3ZVXF.js.map → chunk-FSIAWTBZ.js.map} +0 -0
- /package/dist/{chunk-Y4MFP2PI.js.map → chunk-FZ33A73T.js.map} +0 -0
- /package/dist/{chunk-IIWES7RB.js.map → chunk-GIC3LEOF.js.map} +0 -0
- /package/dist/{chunk-GRFWVW5Q.js.map → chunk-KBZBNDRL.js.map} +0 -0
- /package/dist/{chunk-UPM6LKXT.js.map → chunk-MR6HRZTD.js.map} +0 -0
- /package/dist/{chunk-HNN3HQ4F.js.map → chunk-NSLPJVLG.js.map} +0 -0
- /package/dist/{chunk-JXPU7KX4.js.map → chunk-NZMZFOHR.js.map} +0 -0
- /package/dist/{chunk-K27QB3XA.js.map → chunk-PYJ5LALG.js.map} +0 -0
- /package/dist/{chunk-2GJIHGW2.js.map → chunk-QJN2OEN4.js.map} +0 -0
- /package/dist/{chunk-IHAFN2IR.js.map → chunk-RPBHMFRQ.js.map} +0 -0
- /package/dist/{chunk-6PWUBWII.js.map → chunk-SFR3TP23.js.map} +0 -0
- /package/dist/{chunk-WDMJBURS.js.map → chunk-UDC5YCXW.js.map} +0 -0
- /package/dist/{chunk-IAEGVIG2.js.map → chunk-VMXD4DPP.js.map} +0 -0
- /package/dist/{chunk-EFIY2OBF.js.map → chunk-YJQFTMXY.js.map} +0 -0
- /package/dist/{chunk-TDCCSW57.js.map → chunk-ZLHQG6DX.js.map} +0 -0
- /package/dist/{commands-GURVRN72.js.map → commands-BJHACFCG.js.map} +0 -0
- /package/dist/{config-EO6W7HT6.js.map → config-CZ72HP4B.js.map} +0 -0
- /package/dist/{context-ZD3A3X7W.js.map → context-PYVZ2UIV.js.map} +0 -0
- /package/dist/{customCommands-CK62GG2A.js.map → customCommands-SM2TONHF.js.map} +0 -0
- /package/dist/{env-JRY7UKS5.js.map → env-TIOWJNM3.js.map} +0 -0
- /package/dist/{llm-2R3YDGM5.js.map → llm-NW2S47DG.js.map} +0 -0
- /package/dist/{llmLazy-DQH7QRMR.js.map → llmLazy-HL7WHPNN.js.map} +0 -0
- /package/dist/{loader-AIAHQGDY.js.map → loader-TUZWQP7L.js.map} +0 -0
- /package/dist/{mcp-PIZTHOTG.js.map → manager-VXNOOVJ2.js.map} +0 -0
- /package/dist/{messages-7ERVBYYH.js.map → mcp-3GAO6ZWX.js.map} +0 -0
- /package/dist/{mentionProcessor-G3HE2SGJ.js.map → mentionProcessor-A5H4NAU2.js.map} +0 -0
- /package/dist/{model-PYSWBB22.js.map → messages-FIKPJNRV.js.map} +0 -0
- /package/dist/{openai-5CTLKASP.js.map → model-4ZGIHII2.js.map} +0 -0
- /package/dist/{outputStyles-ZNNZXMTY.js.map → openai-JAYMLYTY.js.map} +0 -0
- /package/dist/{pluginValidation-HDLXFMVA.js.map → outputStyles-KNJY3E27.js.map} +0 -0
- /package/dist/{pluginRuntime-EJS6GFVB.js.map → pluginRuntime-SHFEMATT.js.map} +0 -0
- /package/dist/{prompts-NGAMEMXP.js.map → pluginValidation-7LENCJCL.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-EO52TKZC.js.map → prompts-WKHO6LU3.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-RF36X2HT.js.map → pybAgentSessionLoad-KQDIJWHN.js.map} +0 -0
- /package/dist/{pybHooks-ZAJMYPMH.js.map → pybAgentSessionResume-OW7FJ3VU.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-NSBZXQNX.js.map → pybAgentStreamJsonSession-A7P4SBXT.js.map} +0 -0
- /package/dist/{query-SZRZBXEO.js.map → pybHooks-FBR77SZL.js.map} +0 -0
- /package/dist/{ripgrep-KP4CGUAZ.js.map → query-TTURURS2.js.map} +0 -0
- /package/dist/{skillMarketplace-7WJ3SVIA.js.map → ripgrep-2KX6Q2XT.js.map} +0 -0
- /package/dist/{state-AKOQ2NMP.js.map → skillMarketplace-BG4Y3IXW.js.map} +0 -0
- /package/dist/{theme-D7PCPHYJ.js.map → state-E53XB637.js.map} +0 -0
- /package/dist/{toolPermissionSettings-GYB4MNUP.js.map → theme-ZXJL5RLH.js.map} +0 -0
- /package/dist/{tools-KFBHBGPN.js.map → toolPermissionSettings-3JMTQH6J.js.map} +0 -0
- /package/dist/{userInput-LIQKUPCD.js.map → userInput-CQQYFYGG.js.map} +0 -0
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { createRequire as __pybCreateRequire } from "node:module";
|
|
2
2
|
const require = __pybCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
loadPybAgentSessionMessages
|
|
5
|
+
} from "./chunk-FZ33A73T.js";
|
|
3
6
|
import {
|
|
4
7
|
listPybAgentSessions
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NZMZFOHR.js";
|
|
9
|
+
import {
|
|
10
|
+
appendSessionCustomTitleRecord,
|
|
11
|
+
appendSessionJsonlFromMessage,
|
|
12
|
+
appendSessionTagRecord
|
|
13
|
+
} from "./chunk-SFR3TP23.js";
|
|
14
|
+
import {
|
|
15
|
+
fetchCustomModels,
|
|
16
|
+
getModelFeatures
|
|
17
|
+
} from "./chunk-RPBHMFRQ.js";
|
|
18
|
+
import {
|
|
19
|
+
queryLLM,
|
|
20
|
+
queryQuick,
|
|
21
|
+
verifyApiKey
|
|
22
|
+
} from "./chunk-FSIAWTBZ.js";
|
|
6
23
|
import {
|
|
7
24
|
DEFAULT_TIMEOUT_MS,
|
|
8
25
|
FallbackToolUseRejectedMessage,
|
|
@@ -16,11 +33,11 @@ import {
|
|
|
16
33
|
listMCPServers,
|
|
17
34
|
loadMergedSettings,
|
|
18
35
|
normalizeSandboxRuntimeConfigFromSettings
|
|
19
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ZLHQG6DX.js";
|
|
20
37
|
import {
|
|
21
38
|
formatValidationResult,
|
|
22
39
|
validatePluginOrMarketplacePath
|
|
23
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-AKXEHZ7A.js";
|
|
24
41
|
import {
|
|
25
42
|
addMarketplace,
|
|
26
43
|
disableSkillPlugin,
|
|
@@ -33,15 +50,55 @@ import {
|
|
|
33
50
|
refreshMarketplaceAsync,
|
|
34
51
|
removeMarketplace,
|
|
35
52
|
uninstallSkillPlugin
|
|
36
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-MR6HRZTD.js";
|
|
37
54
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
emitReminderEvent,
|
|
56
|
+
generateSystemReminders,
|
|
57
|
+
getAgentFilePath,
|
|
58
|
+
getTodos,
|
|
59
|
+
resetReminderSession,
|
|
60
|
+
setTodos,
|
|
61
|
+
systemReminderService
|
|
62
|
+
} from "./chunk-7B65UVZB.js";
|
|
40
63
|
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
getSessionState
|
|
65
|
+
} from "./chunk-ERMQRV55.js";
|
|
66
|
+
import {
|
|
67
|
+
clearAgentCache,
|
|
68
|
+
getActiveAgents,
|
|
69
|
+
getAgentByType,
|
|
70
|
+
getAllAgents
|
|
71
|
+
} from "./chunk-UDC5YCXW.js";
|
|
72
|
+
import {
|
|
73
|
+
API_ERROR_MESSAGE_PREFIX,
|
|
74
|
+
CANCEL_MESSAGE,
|
|
75
|
+
CREDIT_BALANCE_TOO_LOW_ERROR_MESSAGE,
|
|
76
|
+
INTERRUPT_MESSAGE,
|
|
77
|
+
INTERRUPT_MESSAGE_FOR_TOOL_USE,
|
|
78
|
+
INVALID_API_KEY_ERROR_MESSAGE,
|
|
79
|
+
NO_CONTENT_MESSAGE,
|
|
80
|
+
NO_RESPONSE_REQUESTED,
|
|
81
|
+
PROMPT_TOO_LONG_ERROR_MESSAGE,
|
|
82
|
+
REJECT_MESSAGE,
|
|
83
|
+
REJECT_MESSAGE_WITH_FEEDBACK_PREFIX,
|
|
84
|
+
SYNTHETIC_ASSISTANT_MESSAGES,
|
|
85
|
+
createAssistantMessage,
|
|
86
|
+
createProgressMessage,
|
|
87
|
+
createUserMessage,
|
|
88
|
+
extractTag,
|
|
89
|
+
getErroredToolUseMessages,
|
|
90
|
+
getInProgressToolUseIDs,
|
|
91
|
+
getLastAssistantMessageId,
|
|
92
|
+
getToolUseID,
|
|
93
|
+
getUnresolvedToolUseIDs,
|
|
94
|
+
isEmptyMessageText,
|
|
95
|
+
isNotEmptyMessage,
|
|
96
|
+
normalizeMessages,
|
|
97
|
+
normalizeMessagesForAPI,
|
|
98
|
+
processUserInput,
|
|
99
|
+
reorderMessages,
|
|
100
|
+
stripSystemMessages
|
|
101
|
+
} from "./chunk-VMXD4DPP.js";
|
|
45
102
|
import {
|
|
46
103
|
getRequestStatus,
|
|
47
104
|
setRequestStatus,
|
|
@@ -58,7 +115,7 @@ import {
|
|
|
58
115
|
runStopHooks,
|
|
59
116
|
runUserPromptSubmitHooks,
|
|
60
117
|
updateHookTranscriptForMessages
|
|
61
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-B3L6T5WY.js";
|
|
62
119
|
import {
|
|
63
120
|
getPybAgentSessionId,
|
|
64
121
|
setPybAgentSessionId
|
|
@@ -71,105 +128,48 @@ import {
|
|
|
71
128
|
getOutputStyleSystemPromptAdditions,
|
|
72
129
|
resolveOutputStyleName,
|
|
73
130
|
setCurrentOutputStyle
|
|
74
|
-
} from "./chunk-
|
|
75
|
-
import {
|
|
76
|
-
fetchCustomModels,
|
|
77
|
-
getModelFeatures
|
|
78
|
-
} from "./chunk-IHAFN2IR.js";
|
|
79
|
-
import {
|
|
80
|
-
queryLLM,
|
|
81
|
-
queryQuick,
|
|
82
|
-
verifyApiKey
|
|
83
|
-
} from "./chunk-PBX3ZVXF.js";
|
|
131
|
+
} from "./chunk-GIC3LEOF.js";
|
|
84
132
|
import {
|
|
85
133
|
listAllContentFiles,
|
|
86
134
|
ripGrep,
|
|
87
135
|
tree
|
|
88
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-EQGVECW5.js";
|
|
89
137
|
import {
|
|
90
138
|
getCustomCommandDirectories,
|
|
91
139
|
hasCustomCommands,
|
|
92
140
|
loadCustomCommands,
|
|
93
141
|
reloadCustomCommands
|
|
94
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-YJQFTMXY.js";
|
|
143
|
+
import {
|
|
144
|
+
getSessionPlugins
|
|
145
|
+
} from "./chunk-BJSWTHRM.js";
|
|
95
146
|
import {
|
|
96
147
|
loadToolPermissionContextFromDisk,
|
|
97
148
|
persistToolPermissionUpdateToDisk
|
|
98
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-4HB7MQDC.js";
|
|
99
150
|
import {
|
|
100
151
|
getSettingsFileCandidates,
|
|
101
152
|
loadSettingsWithLegacyFallback
|
|
102
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-KBZBNDRL.js";
|
|
103
154
|
import {
|
|
104
155
|
applyToolPermissionContextUpdate,
|
|
105
156
|
createDefaultToolPermissionContext
|
|
106
157
|
} from "./chunk-UNNVICVU.js";
|
|
107
|
-
import {
|
|
108
|
-
emitReminderEvent,
|
|
109
|
-
generateSystemReminders,
|
|
110
|
-
getAgentFilePath,
|
|
111
|
-
getTodos,
|
|
112
|
-
resetReminderSession,
|
|
113
|
-
setTodos,
|
|
114
|
-
systemReminderService
|
|
115
|
-
} from "./chunk-LPZM3TPE.js";
|
|
116
|
-
import {
|
|
117
|
-
getSessionState
|
|
118
|
-
} from "./chunk-ERMQRV55.js";
|
|
119
|
-
import {
|
|
120
|
-
clearAgentCache,
|
|
121
|
-
getActiveAgents,
|
|
122
|
-
getAgentByType,
|
|
123
|
-
getAllAgents
|
|
124
|
-
} from "./chunk-WDMJBURS.js";
|
|
125
|
-
import {
|
|
126
|
-
getSessionPlugins
|
|
127
|
-
} from "./chunk-BJSWTHRM.js";
|
|
128
|
-
import {
|
|
129
|
-
API_ERROR_MESSAGE_PREFIX,
|
|
130
|
-
CANCEL_MESSAGE,
|
|
131
|
-
CREDIT_BALANCE_TOO_LOW_ERROR_MESSAGE,
|
|
132
|
-
INTERRUPT_MESSAGE,
|
|
133
|
-
INTERRUPT_MESSAGE_FOR_TOOL_USE,
|
|
134
|
-
INVALID_API_KEY_ERROR_MESSAGE,
|
|
135
|
-
NO_CONTENT_MESSAGE,
|
|
136
|
-
NO_RESPONSE_REQUESTED,
|
|
137
|
-
PROMPT_TOO_LONG_ERROR_MESSAGE,
|
|
138
|
-
REJECT_MESSAGE,
|
|
139
|
-
REJECT_MESSAGE_WITH_FEEDBACK_PREFIX,
|
|
140
|
-
SYNTHETIC_ASSISTANT_MESSAGES,
|
|
141
|
-
createAssistantMessage,
|
|
142
|
-
createProgressMessage,
|
|
143
|
-
createUserMessage,
|
|
144
|
-
extractTag,
|
|
145
|
-
getErroredToolUseMessages,
|
|
146
|
-
getInProgressToolUseIDs,
|
|
147
|
-
getLastAssistantMessageId,
|
|
148
|
-
getToolUseID,
|
|
149
|
-
getUnresolvedToolUseIDs,
|
|
150
|
-
isEmptyMessageText,
|
|
151
|
-
isNotEmptyMessage,
|
|
152
|
-
normalizeMessages,
|
|
153
|
-
normalizeMessagesForAPI,
|
|
154
|
-
processUserInput,
|
|
155
|
-
reorderMessages,
|
|
156
|
-
stripSystemMessages
|
|
157
|
-
} from "./chunk-IAEGVIG2.js";
|
|
158
158
|
import {
|
|
159
159
|
ModelManager,
|
|
160
160
|
getModelManager,
|
|
161
161
|
isDefaultSlowAndCapableModel
|
|
162
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-6OFYDHOG.js";
|
|
163
163
|
import {
|
|
164
164
|
getCodeStyle,
|
|
165
165
|
getContext,
|
|
166
166
|
getGitState,
|
|
167
167
|
getIsGit,
|
|
168
168
|
getProjectDocs
|
|
169
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-5764Z4HA.js";
|
|
170
170
|
import {
|
|
171
171
|
getTheme
|
|
172
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-QJN2OEN4.js";
|
|
173
173
|
import {
|
|
174
174
|
DEFAULT_GLOBAL_CONFIG,
|
|
175
175
|
enableConfigs,
|
|
@@ -182,7 +182,7 @@ import {
|
|
|
182
182
|
saveGlobalConfig,
|
|
183
183
|
setAllPointersToModel,
|
|
184
184
|
setModelPointer
|
|
185
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-E4522PV7.js";
|
|
186
186
|
import {
|
|
187
187
|
AbortError
|
|
188
188
|
} from "./chunk-RQVLBMP7.js";
|
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
getCurrentRequest,
|
|
192
192
|
logUserFriendly,
|
|
193
193
|
markPhase
|
|
194
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-NSLPJVLG.js";
|
|
195
195
|
import {
|
|
196
196
|
ASCII_LOGO,
|
|
197
197
|
BunShell,
|
|
@@ -227,10 +227,10 @@ import {
|
|
|
227
227
|
renderBashNotification,
|
|
228
228
|
setActivePlanConversationKey,
|
|
229
229
|
setCwd
|
|
230
|
-
} from "./chunk-
|
|
230
|
+
} from "./chunk-PYJ5LALG.js";
|
|
231
231
|
import {
|
|
232
232
|
MACRO
|
|
233
|
-
} from "./chunk-
|
|
233
|
+
} from "./chunk-DGZHUQKC.js";
|
|
234
234
|
import {
|
|
235
235
|
formatTotalCost,
|
|
236
236
|
getTotalAPIDuration,
|
|
@@ -245,7 +245,7 @@ import {
|
|
|
245
245
|
// src/tools/system/BashTool/BashTool.tsx
|
|
246
246
|
import { statSync as statSync12 } from "fs";
|
|
247
247
|
import { EOL as EOL3 } from "os";
|
|
248
|
-
import { isAbsolute as
|
|
248
|
+
import { isAbsolute as isAbsolute9, relative as relative13, resolve as resolve10 } from "path";
|
|
249
249
|
import * as React109 from "react";
|
|
250
250
|
import { z as z16 } from "zod";
|
|
251
251
|
|
|
@@ -418,7 +418,7 @@ var getCommandSubcommandPrefix = memoize(
|
|
|
418
418
|
var getCommandPrefix = memoize(
|
|
419
419
|
async (command4, abortSignal) => {
|
|
420
420
|
const { systemPrompt, userPrompt } = buildBashCommandPrefixDetectionPrompt(command4);
|
|
421
|
-
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryQuick: queryQuick2 } = await import("./llm-
|
|
421
|
+
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryQuick: queryQuick2 } = await import("./llm-NW2S47DG.js");
|
|
422
422
|
const response = await queryQuick2({
|
|
423
423
|
systemPrompt,
|
|
424
424
|
userPrompt,
|
|
@@ -941,8 +941,8 @@ async function shouldAllowNetworkRequest(query2) {
|
|
|
941
941
|
}
|
|
942
942
|
async function serializePermissionPrompt(task) {
|
|
943
943
|
let release = null;
|
|
944
|
-
const next = new Promise((
|
|
945
|
-
release =
|
|
944
|
+
const next = new Promise((resolve11) => {
|
|
945
|
+
release = resolve11;
|
|
946
946
|
});
|
|
947
947
|
const prev = active.permissionPromptChain;
|
|
948
948
|
active.permissionPromptChain = prev.then(() => next);
|
|
@@ -975,18 +975,18 @@ async function cleanupSandboxNetworkInfrastructure() {
|
|
|
975
975
|
active.sessionDeniedHosts.clear();
|
|
976
976
|
active.inflightPermissionRequests.clear();
|
|
977
977
|
await Promise.allSettled([
|
|
978
|
-
httpServer ? new Promise((
|
|
978
|
+
httpServer ? new Promise((resolve11) => {
|
|
979
979
|
try {
|
|
980
|
-
httpServer.close(() =>
|
|
980
|
+
httpServer.close(() => resolve11());
|
|
981
981
|
} catch {
|
|
982
|
-
|
|
982
|
+
resolve11();
|
|
983
983
|
}
|
|
984
984
|
}) : Promise.resolve(),
|
|
985
|
-
socksServer ? new Promise((
|
|
985
|
+
socksServer ? new Promise((resolve11) => {
|
|
986
986
|
try {
|
|
987
|
-
socksServer.close(() =>
|
|
987
|
+
socksServer.close(() => resolve11());
|
|
988
988
|
} catch {
|
|
989
|
-
|
|
989
|
+
resolve11();
|
|
990
990
|
}
|
|
991
991
|
}) : Promise.resolve()
|
|
992
992
|
]);
|
|
@@ -1176,7 +1176,7 @@ async function startHttpProxy() {
|
|
|
1176
1176
|
clientSocket.on("data", onData);
|
|
1177
1177
|
});
|
|
1178
1178
|
active.httpProxyServer = server;
|
|
1179
|
-
return new Promise((
|
|
1179
|
+
return new Promise((resolve11, reject) => {
|
|
1180
1180
|
server.once("error", reject);
|
|
1181
1181
|
server.once("listening", () => {
|
|
1182
1182
|
const addr = server.address();
|
|
@@ -1185,7 +1185,7 @@ async function startHttpProxy() {
|
|
|
1185
1185
|
return;
|
|
1186
1186
|
}
|
|
1187
1187
|
server.unref();
|
|
1188
|
-
|
|
1188
|
+
resolve11(addr.port);
|
|
1189
1189
|
});
|
|
1190
1190
|
server.listen(0, "127.0.0.1");
|
|
1191
1191
|
});
|
|
@@ -1295,7 +1295,7 @@ async function startSocks5Proxy() {
|
|
|
1295
1295
|
socket.on("data", onData);
|
|
1296
1296
|
});
|
|
1297
1297
|
active.socksProxyServer = server;
|
|
1298
|
-
return new Promise((
|
|
1298
|
+
return new Promise((resolve11, reject) => {
|
|
1299
1299
|
server.once("error", reject);
|
|
1300
1300
|
server.once("listening", () => {
|
|
1301
1301
|
const addr = server.address();
|
|
@@ -1304,7 +1304,7 @@ async function startSocks5Proxy() {
|
|
|
1304
1304
|
return;
|
|
1305
1305
|
}
|
|
1306
1306
|
server.unref();
|
|
1307
|
-
|
|
1307
|
+
resolve11(addr.port);
|
|
1308
1308
|
});
|
|
1309
1309
|
server.listen(0, "127.0.0.1");
|
|
1310
1310
|
});
|
|
@@ -4458,7 +4458,7 @@ function formatParseError(error) {
|
|
|
4458
4458
|
return error instanceof Error ? error.message : String(error);
|
|
4459
4459
|
}
|
|
4460
4460
|
async function defaultGateQuery(args) {
|
|
4461
|
-
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryLLM: queryLLM2 } = await import("./llm-
|
|
4461
|
+
const { API_ERROR_MESSAGE_PREFIX: API_ERROR_MESSAGE_PREFIX2, queryLLM: queryLLM2 } = await import("./llm-NW2S47DG.js");
|
|
4462
4462
|
const messages = [
|
|
4463
4463
|
{
|
|
4464
4464
|
type: "user",
|
|
@@ -5645,9 +5645,9 @@ function Select({
|
|
|
5645
5645
|
}
|
|
5646
5646
|
|
|
5647
5647
|
// src/tools/filesystem/FileEditTool/FileEditTool.tsx
|
|
5648
|
-
import { mkdirSync as mkdirSync2,
|
|
5648
|
+
import { mkdirSync as mkdirSync2, statSync as statSync4 } from "fs";
|
|
5649
5649
|
import { Box as Box11, Text as Text12 } from "ink";
|
|
5650
|
-
import { dirname as dirname3, isAbsolute as
|
|
5650
|
+
import { dirname as dirname3, isAbsolute as isAbsolute4, relative as relative5, resolve as resolve4 } from "path";
|
|
5651
5651
|
import * as React12 from "react";
|
|
5652
5652
|
import { z as z3 } from "zod";
|
|
5653
5653
|
|
|
@@ -6498,50 +6498,29 @@ var NotebookEditTool = {
|
|
|
6498
6498
|
};
|
|
6499
6499
|
|
|
6500
6500
|
// src/tools/filesystem/FileEditTool/prompt.ts
|
|
6501
|
-
var DESCRIPTION2 = `Performs smart string replacements in files.
|
|
6501
|
+
var DESCRIPTION2 = `Performs smart string replacements in files using SEARCH/REPLACE blocks.
|
|
6502
6502
|
|
|
6503
6503
|
Usage:
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6504
|
+
1. **Read First**: You must use your \`Read\` tool at least once before editing.
|
|
6505
|
+
2. **Block Format**: Provide changes as one or more SEARCH/REPLACE blocks.
|
|
6506
|
+
\`\`\`
|
|
6507
|
+
<<<<<<< SEARCH
|
|
6508
|
+
[original code to replace]
|
|
6509
|
+
=======
|
|
6510
|
+
[new code to insert]
|
|
6511
|
+
>>>>>>> REPLACE
|
|
6512
|
+
\`\`\`
|
|
6513
|
+
3. **Multiple Edits**: You can provide multiple blocks in a single turn to perform batch edits.
|
|
6514
|
+
4. **Context**: Include enough surrounding lines in the SEARCH block to ensure uniqueness.
|
|
6515
|
+
5. **Indentation**: Preserve the exact indentation (tabs/spaces) of the original file in your SEARCH block.
|
|
6516
|
+
6. **Smart Matching**: The tool uses a fuzzy matching engine and LSP anchoring. It can locate code even if there are minor differences in whitespace or indentation.
|
|
6517
|
+
7. **Thinking**: You can include "thinking" text between blocks; the tool will ignore it.
|
|
6515
6518
|
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
function getPatch({
|
|
6522
|
-
filePath,
|
|
6523
|
-
fileContents,
|
|
6524
|
-
oldStr,
|
|
6525
|
-
newStr
|
|
6526
|
-
}) {
|
|
6527
|
-
return structuredPatch(
|
|
6528
|
-
filePath,
|
|
6529
|
-
filePath,
|
|
6530
|
-
fileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6531
|
-
fileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN).replace(
|
|
6532
|
-
oldStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6533
|
-
newStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN)
|
|
6534
|
-
),
|
|
6535
|
-
void 0,
|
|
6536
|
-
void 0,
|
|
6537
|
-
{ context: CONTEXT_LINES }
|
|
6538
|
-
).hunks.map((_) => ({
|
|
6539
|
-
..._,
|
|
6540
|
-
lines: _.lines.map(
|
|
6541
|
-
(_2) => _2.replaceAll(AMPERSAND_TOKEN, "&").replaceAll(DOLLAR_TOKEN, "$")
|
|
6542
|
-
)
|
|
6543
|
-
}));
|
|
6544
|
-
}
|
|
6519
|
+
Notes:
|
|
6520
|
+
- The edit will FAIL if the SEARCH block matches multiple locations (ambiguous). Provide more context.
|
|
6521
|
+
- To delete code, leave the REPLACE section empty.
|
|
6522
|
+
- ALWAYS prefer editing existing files. NEVER write new files unless explicitly required.
|
|
6523
|
+
`.trim();
|
|
6545
6524
|
|
|
6546
6525
|
// src/utils/terminal/paste.ts
|
|
6547
6526
|
function normalizeLineEndings(text) {
|
|
@@ -6571,396 +6550,46 @@ function shouldAggregatePasteChunk(input, hasPendingTimeout) {
|
|
|
6571
6550
|
return false;
|
|
6572
6551
|
}
|
|
6573
6552
|
|
|
6574
|
-
// src/utils/text/
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
}
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
}
|
|
6602
|
-
for (let i = 0; i <= originalLines.length - searchLines.length; i++) {
|
|
6603
|
-
let matches = true;
|
|
6604
|
-
for (let j = 0; j < searchLines.length; j++) {
|
|
6605
|
-
const originalTrimmed = originalLines[i + j].trim();
|
|
6606
|
-
const searchTrimmed = searchLines[j].trim();
|
|
6607
|
-
if (originalTrimmed !== searchTrimmed) {
|
|
6608
|
-
matches = false;
|
|
6609
|
-
break;
|
|
6610
|
-
}
|
|
6611
|
-
}
|
|
6612
|
-
if (matches) {
|
|
6613
|
-
let matchStartIndex = 0;
|
|
6614
|
-
for (let k = 0; k < i; k++) {
|
|
6615
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
6616
|
-
}
|
|
6617
|
-
let matchEndIndex = matchStartIndex;
|
|
6618
|
-
for (let k = 0; k < searchLines.length; k++) {
|
|
6619
|
-
matchEndIndex += originalLines[i + k].length;
|
|
6620
|
-
if (k < searchLines.length - 1) {
|
|
6621
|
-
matchEndIndex += 1;
|
|
6622
|
-
}
|
|
6623
|
-
}
|
|
6624
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
6625
|
-
}
|
|
6626
|
-
}
|
|
6627
|
-
};
|
|
6628
|
-
var SINGLE_CANDIDATE_SIMILARITY_THRESHOLD = 0;
|
|
6629
|
-
var MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD = 0.3;
|
|
6630
|
-
var WhitespaceNormalizedReplacer = function* (content, find) {
|
|
6631
|
-
const tokens = find.split(/\s+/).filter((t) => t.length > 0);
|
|
6632
|
-
if (tokens.length === 0) return;
|
|
6633
|
-
const pattern = tokens.map((token) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+");
|
|
6634
|
-
try {
|
|
6635
|
-
const regex = new RegExp(pattern, "g");
|
|
6636
|
-
let match;
|
|
6637
|
-
while ((match = regex.exec(content)) !== null) {
|
|
6638
|
-
yield match[0];
|
|
6639
|
-
}
|
|
6640
|
-
} catch (e) {
|
|
6641
|
-
}
|
|
6642
|
-
};
|
|
6643
|
-
var BlockAnchorReplacer = function* (content, find) {
|
|
6644
|
-
const originalLines = content.split("\n");
|
|
6645
|
-
const searchLines = find.split("\n");
|
|
6646
|
-
if (searchLines.length < 3) {
|
|
6647
|
-
return;
|
|
6648
|
-
}
|
|
6649
|
-
if (searchLines[searchLines.length - 1] === "") {
|
|
6650
|
-
searchLines.pop();
|
|
6651
|
-
}
|
|
6652
|
-
const firstLineSearch = searchLines[0].trim();
|
|
6653
|
-
const lastLineSearch = searchLines[searchLines.length - 1].trim();
|
|
6654
|
-
const searchBlockSize = searchLines.length;
|
|
6655
|
-
const candidates = [];
|
|
6656
|
-
for (let i = 0; i < originalLines.length; i++) {
|
|
6657
|
-
if (originalLines[i].trim() !== firstLineSearch) {
|
|
6658
|
-
continue;
|
|
6659
|
-
}
|
|
6660
|
-
for (let j = i + 2; j < originalLines.length; j++) {
|
|
6661
|
-
if (originalLines[j].trim() === lastLineSearch) {
|
|
6662
|
-
candidates.push({ startLine: i, endLine: j });
|
|
6663
|
-
break;
|
|
6664
|
-
}
|
|
6665
|
-
}
|
|
6666
|
-
}
|
|
6667
|
-
if (candidates.length === 0) {
|
|
6668
|
-
return;
|
|
6669
|
-
}
|
|
6670
|
-
if (candidates.length === 1) {
|
|
6671
|
-
const { startLine, endLine } = candidates[0];
|
|
6672
|
-
const actualBlockSize = endLine - startLine + 1;
|
|
6673
|
-
let similarity = 0;
|
|
6674
|
-
let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2);
|
|
6675
|
-
if (linesToCheck > 0) {
|
|
6676
|
-
for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
|
|
6677
|
-
const originalLine = originalLines[startLine + j].trim();
|
|
6678
|
-
const searchLine = searchLines[j].trim();
|
|
6679
|
-
const maxLen = Math.max(originalLine.length, searchLine.length);
|
|
6680
|
-
if (maxLen === 0) {
|
|
6681
|
-
continue;
|
|
6682
|
-
}
|
|
6683
|
-
const distance = levenshtein(originalLine, searchLine);
|
|
6684
|
-
similarity += (1 - distance / maxLen) / linesToCheck;
|
|
6685
|
-
if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
|
|
6686
|
-
break;
|
|
6687
|
-
}
|
|
6688
|
-
}
|
|
6689
|
-
} else {
|
|
6690
|
-
similarity = 1;
|
|
6691
|
-
}
|
|
6692
|
-
if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
|
|
6693
|
-
let matchStartIndex = 0;
|
|
6694
|
-
for (let k = 0; k < startLine; k++) {
|
|
6695
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
6696
|
-
}
|
|
6697
|
-
let matchEndIndex = matchStartIndex;
|
|
6698
|
-
for (let k = startLine; k <= endLine; k++) {
|
|
6699
|
-
matchEndIndex += originalLines[k].length;
|
|
6700
|
-
if (k < endLine) {
|
|
6701
|
-
matchEndIndex += 1;
|
|
6702
|
-
}
|
|
6703
|
-
}
|
|
6704
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
6705
|
-
}
|
|
6706
|
-
return;
|
|
6707
|
-
}
|
|
6708
|
-
let bestMatch = null;
|
|
6709
|
-
let maxSimilarity = -1;
|
|
6710
|
-
for (const candidate of candidates) {
|
|
6711
|
-
const { startLine, endLine } = candidate;
|
|
6712
|
-
const actualBlockSize = endLine - startLine + 1;
|
|
6713
|
-
let similarity = 0;
|
|
6714
|
-
let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2);
|
|
6715
|
-
if (linesToCheck > 0) {
|
|
6716
|
-
for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
|
|
6717
|
-
const originalLine = originalLines[startLine + j].trim();
|
|
6718
|
-
const searchLine = searchLines[j].trim();
|
|
6719
|
-
const maxLen = Math.max(originalLine.length, searchLine.length);
|
|
6720
|
-
if (maxLen === 0) {
|
|
6721
|
-
continue;
|
|
6722
|
-
}
|
|
6723
|
-
const distance = levenshtein(originalLine, searchLine);
|
|
6724
|
-
similarity += 1 - distance / maxLen;
|
|
6725
|
-
}
|
|
6726
|
-
similarity /= linesToCheck;
|
|
6727
|
-
} else {
|
|
6728
|
-
similarity = 1;
|
|
6729
|
-
}
|
|
6730
|
-
if (similarity > maxSimilarity) {
|
|
6731
|
-
maxSimilarity = similarity;
|
|
6732
|
-
bestMatch = candidate;
|
|
6733
|
-
}
|
|
6734
|
-
}
|
|
6735
|
-
if (maxSimilarity >= MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD && bestMatch) {
|
|
6736
|
-
const { startLine, endLine } = bestMatch;
|
|
6737
|
-
let matchStartIndex = 0;
|
|
6738
|
-
for (let k = 0; k < startLine; k++) {
|
|
6739
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
6740
|
-
}
|
|
6741
|
-
let matchEndIndex = matchStartIndex;
|
|
6742
|
-
for (let k = startLine; k <= endLine; k++) {
|
|
6743
|
-
matchEndIndex += originalLines[k].length;
|
|
6744
|
-
if (k < endLine) {
|
|
6745
|
-
matchEndIndex += 1;
|
|
6746
|
-
}
|
|
6747
|
-
}
|
|
6748
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
6749
|
-
}
|
|
6750
|
-
};
|
|
6751
|
-
var IndentationFlexibleReplacer = function* (content, find) {
|
|
6752
|
-
const removeIndentation = (text) => {
|
|
6753
|
-
const lines = text.split("\n");
|
|
6754
|
-
const nonEmptyLines = lines.filter((line) => line.trim().length > 0);
|
|
6755
|
-
if (nonEmptyLines.length === 0) return text;
|
|
6756
|
-
const minIndent = Math.min(
|
|
6757
|
-
...nonEmptyLines.map((line) => {
|
|
6758
|
-
const match = line.match(/^(\s*)/);
|
|
6759
|
-
return match ? match[1].length : 0;
|
|
6760
|
-
})
|
|
6761
|
-
);
|
|
6762
|
-
return lines.map((line) => line.trim().length === 0 ? line : line.slice(minIndent)).join("\n");
|
|
6763
|
-
};
|
|
6764
|
-
const normalizedFind = removeIndentation(find);
|
|
6765
|
-
const contentLines = content.split("\n");
|
|
6766
|
-
const findLines = find.split("\n");
|
|
6767
|
-
for (let i = 0; i <= contentLines.length - findLines.length; i++) {
|
|
6768
|
-
const block = contentLines.slice(i, i + findLines.length).join("\n");
|
|
6769
|
-
if (removeIndentation(block) === normalizedFind) {
|
|
6770
|
-
yield block;
|
|
6771
|
-
}
|
|
6772
|
-
}
|
|
6773
|
-
};
|
|
6774
|
-
var EscapeNormalizedReplacer = function* (content, find) {
|
|
6775
|
-
const unescapeString = (str) => {
|
|
6776
|
-
return str.replace(/\\(n|t|r|'|"|`|\\|\n|\$)/g, (match, capturedChar) => {
|
|
6777
|
-
switch (capturedChar) {
|
|
6778
|
-
case "n":
|
|
6779
|
-
return "\n";
|
|
6780
|
-
case "t":
|
|
6781
|
-
return " ";
|
|
6782
|
-
case "r":
|
|
6783
|
-
return "\r";
|
|
6784
|
-
case "'":
|
|
6785
|
-
return "'";
|
|
6786
|
-
case '"':
|
|
6787
|
-
return '"';
|
|
6788
|
-
case "`":
|
|
6789
|
-
return "`";
|
|
6790
|
-
case "\\":
|
|
6791
|
-
return "\\";
|
|
6792
|
-
case "\n":
|
|
6793
|
-
return "\n";
|
|
6794
|
-
case "$":
|
|
6795
|
-
return "$";
|
|
6796
|
-
default:
|
|
6797
|
-
return match;
|
|
6798
|
-
}
|
|
6799
|
-
});
|
|
6800
|
-
};
|
|
6801
|
-
const unescapedFind = unescapeString(find);
|
|
6802
|
-
if (content.includes(unescapedFind)) {
|
|
6803
|
-
yield unescapedFind;
|
|
6804
|
-
}
|
|
6805
|
-
const lines = content.split("\n");
|
|
6806
|
-
const findLines = unescapedFind.split("\n");
|
|
6807
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
6808
|
-
const block = lines.slice(i, i + findLines.length).join("\n");
|
|
6809
|
-
const unescapedBlock = unescapeString(block);
|
|
6810
|
-
if (unescapedBlock === unescapedFind) {
|
|
6811
|
-
yield block;
|
|
6812
|
-
}
|
|
6813
|
-
}
|
|
6814
|
-
};
|
|
6815
|
-
var MultiOccurrenceReplacer = function* (content, find) {
|
|
6816
|
-
let startIndex = 0;
|
|
6817
|
-
while (true) {
|
|
6818
|
-
const index = content.indexOf(find, startIndex);
|
|
6819
|
-
if (index === -1) break;
|
|
6820
|
-
yield find;
|
|
6821
|
-
startIndex = index + find.length;
|
|
6822
|
-
}
|
|
6823
|
-
};
|
|
6824
|
-
var TrimmedBoundaryReplacer = function* (content, find) {
|
|
6825
|
-
const trimmedFind = find.trim();
|
|
6826
|
-
if (trimmedFind === find) {
|
|
6827
|
-
return;
|
|
6828
|
-
}
|
|
6829
|
-
if (content.includes(trimmedFind)) {
|
|
6830
|
-
yield trimmedFind;
|
|
6831
|
-
}
|
|
6832
|
-
const lines = content.split("\n");
|
|
6833
|
-
const findLines = find.split("\n");
|
|
6834
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
6835
|
-
const block = lines.slice(i, i + findLines.length).join("\n");
|
|
6836
|
-
if (block.trim() === trimmedFind) {
|
|
6837
|
-
yield block;
|
|
6838
|
-
}
|
|
6839
|
-
}
|
|
6840
|
-
};
|
|
6841
|
-
var ContextAwareReplacer = function* (content, find) {
|
|
6842
|
-
const findLines = find.split("\n");
|
|
6843
|
-
if (findLines.length < 3) {
|
|
6844
|
-
return;
|
|
6845
|
-
}
|
|
6846
|
-
if (findLines[findLines.length - 1] === "") {
|
|
6847
|
-
findLines.pop();
|
|
6848
|
-
}
|
|
6849
|
-
const contentLines = content.split("\n");
|
|
6850
|
-
const firstLine = findLines[0].trim();
|
|
6851
|
-
const lastLine = findLines[findLines.length - 1].trim();
|
|
6852
|
-
for (let i = 0; i < contentLines.length; i++) {
|
|
6853
|
-
if (contentLines[i].trim() !== firstLine) continue;
|
|
6854
|
-
for (let j = i + 2; j < contentLines.length; j++) {
|
|
6855
|
-
if (contentLines[j].trim() === lastLine) {
|
|
6856
|
-
const blockLines = contentLines.slice(i, j + 1);
|
|
6857
|
-
const block = blockLines.join("\n");
|
|
6858
|
-
if (blockLines.length === findLines.length) {
|
|
6859
|
-
let matchingLines = 0;
|
|
6860
|
-
let totalNonEmptyLines = 0;
|
|
6861
|
-
for (let k = 1; k < blockLines.length - 1; k++) {
|
|
6862
|
-
const blockLine = blockLines[k].trim();
|
|
6863
|
-
const findLine = findLines[k].trim();
|
|
6864
|
-
if (blockLine.length > 0 || findLine.length > 0) {
|
|
6865
|
-
totalNonEmptyLines++;
|
|
6866
|
-
if (blockLine === findLine) {
|
|
6867
|
-
matchingLines++;
|
|
6868
|
-
}
|
|
6869
|
-
}
|
|
6870
|
-
}
|
|
6871
|
-
if (totalNonEmptyLines === 0 || matchingLines / totalNonEmptyLines >= 0.5) {
|
|
6872
|
-
yield block;
|
|
6873
|
-
break;
|
|
6874
|
-
}
|
|
6875
|
-
}
|
|
6876
|
-
break;
|
|
6877
|
-
}
|
|
6878
|
-
}
|
|
6879
|
-
}
|
|
6880
|
-
};
|
|
6881
|
-
|
|
6882
|
-
// src/utils/text/smart-edit/index.ts
|
|
6883
|
-
var SmartEdit = {
|
|
6884
|
-
levenshtein,
|
|
6885
|
-
replace: (content, oldString, newString, replaceAll = false) => {
|
|
6886
|
-
if (oldString === newString) {
|
|
6887
|
-
throw new Error("oldString and newString must be different");
|
|
6888
|
-
}
|
|
6889
|
-
let notFound = true;
|
|
6890
|
-
for (const replacer of [
|
|
6891
|
-
SimpleReplacer,
|
|
6892
|
-
LineTrimmedReplacer,
|
|
6893
|
-
BlockAnchorReplacer,
|
|
6894
|
-
WhitespaceNormalizedReplacer,
|
|
6895
|
-
IndentationFlexibleReplacer,
|
|
6896
|
-
EscapeNormalizedReplacer,
|
|
6897
|
-
TrimmedBoundaryReplacer,
|
|
6898
|
-
ContextAwareReplacer,
|
|
6899
|
-
MultiOccurrenceReplacer
|
|
6900
|
-
]) {
|
|
6901
|
-
for (const search of replacer(content, oldString)) {
|
|
6902
|
-
const index = content.indexOf(search);
|
|
6903
|
-
if (index === -1) continue;
|
|
6904
|
-
notFound = false;
|
|
6905
|
-
if (replaceAll) {
|
|
6906
|
-
return content.replaceAll(search, newString);
|
|
6907
|
-
}
|
|
6908
|
-
return content.substring(0, index) + newString + content.substring(index + search.length);
|
|
6909
|
-
}
|
|
6910
|
-
}
|
|
6911
|
-
if (notFound) {
|
|
6912
|
-
throw new Error("oldString not found in content");
|
|
6913
|
-
}
|
|
6914
|
-
return content;
|
|
6915
|
-
}
|
|
6916
|
-
};
|
|
6917
|
-
|
|
6918
|
-
// src/tools/filesystem/FileEditTool/utils.ts
|
|
6919
|
-
async function applyEdit(file_path, old_string, new_string, replace_all = false) {
|
|
6920
|
-
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
6921
|
-
let originalFile;
|
|
6922
|
-
let updatedFile;
|
|
6923
|
-
if (old_string === "") {
|
|
6924
|
-
originalFile = "";
|
|
6925
|
-
updatedFile = normalizeLineEndings(new_string);
|
|
6926
|
-
} else {
|
|
6927
|
-
const fileContent = await readFileBun(fullFilePath);
|
|
6928
|
-
if (!fileContent) {
|
|
6929
|
-
throw new Error("Could not read file");
|
|
6930
|
-
}
|
|
6931
|
-
originalFile = normalizeLineEndings(fileContent);
|
|
6932
|
-
const normalizedOldString = normalizeLineEndings(old_string);
|
|
6933
|
-
const normalizedNewString = normalizeLineEndings(new_string);
|
|
6934
|
-
const oldStringForReplace = normalizedNewString === "" && !normalizedOldString.endsWith("\n") && originalFile.includes(normalizedOldString + "\n") ? normalizedOldString + "\n" : normalizedOldString;
|
|
6935
|
-
updatedFile = SmartEdit.replace(originalFile, oldStringForReplace, normalizedNewString, replace_all);
|
|
6936
|
-
if (updatedFile === originalFile) {
|
|
6937
|
-
throw new Error(
|
|
6938
|
-
"Original and edited file match exactly. Failed to apply edit."
|
|
6939
|
-
);
|
|
6940
|
-
}
|
|
6941
|
-
}
|
|
6942
|
-
const patch = getPatch({
|
|
6943
|
-
filePath: file_path,
|
|
6944
|
-
fileContents: originalFile,
|
|
6945
|
-
oldStr: originalFile,
|
|
6946
|
-
newStr: updatedFile
|
|
6947
|
-
});
|
|
6948
|
-
return { patch, updatedFile };
|
|
6553
|
+
// src/utils/text/diff.ts
|
|
6554
|
+
import { structuredPatch } from "diff";
|
|
6555
|
+
var CONTEXT_LINES = 3;
|
|
6556
|
+
var AMPERSAND_TOKEN = "<<:AMPERSAND_TOKEN:>>";
|
|
6557
|
+
var DOLLAR_TOKEN = "<<:DOLLAR_TOKEN:>>";
|
|
6558
|
+
function getPatch({
|
|
6559
|
+
filePath,
|
|
6560
|
+
fileContents,
|
|
6561
|
+
oldStr,
|
|
6562
|
+
newStr
|
|
6563
|
+
}) {
|
|
6564
|
+
return structuredPatch(
|
|
6565
|
+
filePath,
|
|
6566
|
+
filePath,
|
|
6567
|
+
fileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6568
|
+
fileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN).replace(
|
|
6569
|
+
oldStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6570
|
+
newStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN)
|
|
6571
|
+
),
|
|
6572
|
+
void 0,
|
|
6573
|
+
void 0,
|
|
6574
|
+
{ context: CONTEXT_LINES }
|
|
6575
|
+
).hunks.map((_) => ({
|
|
6576
|
+
..._,
|
|
6577
|
+
lines: _.lines.map(
|
|
6578
|
+
(_2) => _2.replaceAll(AMPERSAND_TOKEN, "&").replaceAll(DOLLAR_TOKEN, "$")
|
|
6579
|
+
)
|
|
6580
|
+
}));
|
|
6949
6581
|
}
|
|
6950
6582
|
|
|
6951
6583
|
// src/tools/filesystem/FileEditTool/FileEditTool.tsx
|
|
6952
6584
|
var inputSchema3 = z3.strictObject({
|
|
6953
6585
|
file_path: z3.string().describe("The absolute path to the file to modify"),
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
replace_all: z3.boolean().optional().describe("Replace all occurences of old_string (default false)"),
|
|
6957
|
-
if_not_contains: z3.string().optional().describe("If this string is present in the file, the edit will be skipped.")
|
|
6586
|
+
edits: z3.string().describe("The SEARCH/REPLACE blocks defining the changes to be made."),
|
|
6587
|
+
verify: z3.boolean().optional().describe("Verify the edit using LSP diagnostics after application. Defaults to false.")
|
|
6958
6588
|
});
|
|
6959
|
-
var N_LINES_SNIPPET = 4;
|
|
6960
6589
|
var FileEditTool = {
|
|
6961
6590
|
name: "Edit",
|
|
6962
6591
|
async description() {
|
|
6963
|
-
return "A tool for editing files";
|
|
6592
|
+
return "A tool for editing files using SEARCH/REPLACE blocks";
|
|
6964
6593
|
},
|
|
6965
6594
|
async prompt() {
|
|
6966
6595
|
return DESCRIPTION2;
|
|
@@ -6995,78 +6624,33 @@ var FileEditTool = {
|
|
|
6995
6624
|
}
|
|
6996
6625
|
);
|
|
6997
6626
|
},
|
|
6998
|
-
renderToolUseRejectedMessage({ file_path
|
|
6627
|
+
renderToolUseRejectedMessage({ file_path } = {}, { columns, verbose } = {}) {
|
|
6999
6628
|
try {
|
|
7000
6629
|
if (!file_path) {
|
|
7001
6630
|
return /* @__PURE__ */ React12.createElement(FallbackToolUseRejectedMessage, null);
|
|
7002
6631
|
}
|
|
7003
|
-
const fullFilePath =
|
|
7004
|
-
|
|
7005
|
-
let updatedFile = "";
|
|
7006
|
-
if (old_string === "") {
|
|
7007
|
-
originalFile = "";
|
|
7008
|
-
updatedFile = normalizeLineEndings(new_string);
|
|
7009
|
-
} else {
|
|
7010
|
-
const enc = detectFileEncoding(fullFilePath);
|
|
7011
|
-
const fileContent = readFileSync2(fullFilePath, enc);
|
|
7012
|
-
originalFile = normalizeLineEndings(fileContent ?? "");
|
|
7013
|
-
const normalizedOldString = normalizeLineEndings(old_string);
|
|
7014
|
-
const normalizedNewString = normalizeLineEndings(new_string);
|
|
7015
|
-
const oldStringForReplace = normalizedNewString === "" && !normalizedOldString.endsWith("\n") && originalFile.includes(normalizedOldString + "\n") ? normalizedOldString + "\n" : normalizedOldString;
|
|
7016
|
-
updatedFile = Boolean(replace_all) ? originalFile.split(oldStringForReplace).join(normalizedNewString) : originalFile.replace(oldStringForReplace, () => normalizedNewString);
|
|
7017
|
-
if (updatedFile === originalFile) {
|
|
7018
|
-
throw new Error(
|
|
7019
|
-
"Original and edited file match exactly. Failed to apply edit."
|
|
7020
|
-
);
|
|
7021
|
-
}
|
|
7022
|
-
}
|
|
7023
|
-
const patch = getPatch({
|
|
7024
|
-
filePath: file_path,
|
|
7025
|
-
fileContents: originalFile,
|
|
7026
|
-
oldStr: originalFile,
|
|
7027
|
-
newStr: updatedFile
|
|
7028
|
-
});
|
|
7029
|
-
return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text12, null, " ", "\u23BF", " ", /* @__PURE__ */ React12.createElement(Text12, { color: getTheme().error }, "User rejected ", old_string === "" ? "write" : "update", " to", " "), /* @__PURE__ */ React12.createElement(Text12, { bold: true }, verbose ? file_path : relative5(getCwd(), file_path))), intersperse(
|
|
7030
|
-
patch.map((patch2) => /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column", paddingLeft: 5, key: patch2.newStart }, /* @__PURE__ */ React12.createElement(StructuredDiff, { patch: patch2, dim: true, width: columns - 12 }))),
|
|
7031
|
-
(i) => /* @__PURE__ */ React12.createElement(Box11, { paddingLeft: 5, key: `ellipsis-${i}` }, /* @__PURE__ */ React12.createElement(Text12, { color: getTheme().secondaryText }, "..."))
|
|
7032
|
-
));
|
|
6632
|
+
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
6633
|
+
return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text12, null, " ", "\u23BF", " ", /* @__PURE__ */ React12.createElement(Text12, { color: getTheme().error }, "User rejected edit to", " "), /* @__PURE__ */ React12.createElement(Text12, { bold: true }, verbose ? file_path : relative5(getCwd(), file_path))));
|
|
7033
6634
|
} catch (e) {
|
|
7034
6635
|
logError(e);
|
|
7035
6636
|
return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text12, null, " ", "\u23BF (No changes)"));
|
|
7036
6637
|
}
|
|
7037
6638
|
},
|
|
7038
|
-
async validateInput({ file_path,
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
6639
|
+
async validateInput({ file_path, edits, verify }, { readFileTimestamps }) {
|
|
6640
|
+
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
6641
|
+
if (!fileExistsBun(fullFilePath)) {
|
|
6642
|
+
if (edits && edits.includes("<<<<<<< SEARCH") && edits.includes("=======") && edits.includes(">>>>>>> REPLACE") && edits.indexOf("<<<<<<< SEARCH") > edits.indexOf("=======")) {
|
|
6643
|
+
} else {
|
|
6644
|
+
const similarFilename = findSimilarFile(fullFilePath);
|
|
6645
|
+
let message = "File does not exist.";
|
|
6646
|
+
if (similarFilename) {
|
|
6647
|
+
message += ` Did you mean ${similarFilename}?`;
|
|
7045
6648
|
}
|
|
7046
|
-
};
|
|
7047
|
-
}
|
|
7048
|
-
const fullFilePath = isAbsolute5(file_path) ? file_path : resolve5(getCwd(), file_path);
|
|
7049
|
-
if (old_string === "") {
|
|
7050
|
-
if (!fileExistsBun(fullFilePath)) return { result: true };
|
|
7051
|
-
const existingContent = await readFileBun(fullFilePath);
|
|
7052
|
-
if (normalizeLineEndings(existingContent ?? "").trim() !== "") {
|
|
7053
6649
|
return {
|
|
7054
6650
|
result: false,
|
|
7055
|
-
message
|
|
6651
|
+
message
|
|
7056
6652
|
};
|
|
7057
6653
|
}
|
|
7058
|
-
return { result: true };
|
|
7059
|
-
}
|
|
7060
|
-
if (!fileExistsBun(fullFilePath)) {
|
|
7061
|
-
const similarFilename = findSimilarFile(fullFilePath);
|
|
7062
|
-
let message = "File does not exist.";
|
|
7063
|
-
if (similarFilename) {
|
|
7064
|
-
message += ` Did you mean ${similarFilename}?`;
|
|
7065
|
-
}
|
|
7066
|
-
return {
|
|
7067
|
-
result: false,
|
|
7068
|
-
message
|
|
7069
|
-
};
|
|
7070
6654
|
}
|
|
7071
6655
|
if (fullFilePath.endsWith(".ipynb")) {
|
|
7072
6656
|
return {
|
|
@@ -7074,67 +6658,30 @@ var FileEditTool = {
|
|
|
7074
6658
|
message: `File is a Jupyter Notebook. Use the ${NotebookEditTool.name} to edit this file.`
|
|
7075
6659
|
};
|
|
7076
6660
|
}
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
const normalizedFile = normalizeLineEndings(file ?? "");
|
|
7097
|
-
const normalizedOldString = normalizeLineEndings(old_string);
|
|
7098
|
-
if (!file) {
|
|
7099
|
-
return {
|
|
7100
|
-
result: false,
|
|
7101
|
-
message: "Could not read file.",
|
|
7102
|
-
meta: {
|
|
7103
|
-
isFilePathAbsolute: String(isAbsolute5(file_path))
|
|
7104
|
-
}
|
|
7105
|
-
};
|
|
7106
|
-
}
|
|
7107
|
-
if (if_not_contains && normalizedFile.includes(normalizeLineEndings(if_not_contains))) {
|
|
7108
|
-
return {
|
|
7109
|
-
result: false,
|
|
7110
|
-
message: `Modification skipped: The file already contains the string "${if_not_contains}".`
|
|
7111
|
-
};
|
|
7112
|
-
}
|
|
7113
|
-
if (!normalizedFile.includes(normalizedOldString)) {
|
|
7114
|
-
return {
|
|
7115
|
-
result: false,
|
|
7116
|
-
message: `String to replace not found in file.
|
|
7117
|
-
String: ${old_string}`,
|
|
7118
|
-
meta: {
|
|
7119
|
-
isFilePathAbsolute: String(isAbsolute5(file_path))
|
|
7120
|
-
}
|
|
7121
|
-
};
|
|
7122
|
-
}
|
|
7123
|
-
const matches = normalizedFile.split(normalizedOldString).length - 1;
|
|
7124
|
-
if (matches > 1 && !replace_all) {
|
|
7125
|
-
return {
|
|
7126
|
-
result: false,
|
|
7127
|
-
message: `Found ${matches} matches of the string to replace, but replace_all is false. To replace all occurrences, set replace_all to true. To replace only one occurrence, please provide more context to uniquely identify the instance.
|
|
7128
|
-
String: ${old_string}`,
|
|
7129
|
-
meta: {
|
|
7130
|
-
isFilePathAbsolute: String(isAbsolute5(file_path))
|
|
7131
|
-
}
|
|
7132
|
-
};
|
|
6661
|
+
if (fileExistsBun(fullFilePath)) {
|
|
6662
|
+
const readTimestamp = readFileTimestamps[fullFilePath];
|
|
6663
|
+
if (!readTimestamp) {
|
|
6664
|
+
return {
|
|
6665
|
+
result: false,
|
|
6666
|
+
message: "File has not been read yet. Read it first before writing to it.",
|
|
6667
|
+
meta: {
|
|
6668
|
+
isFilePathAbsolute: String(isAbsolute4(file_path))
|
|
6669
|
+
}
|
|
6670
|
+
};
|
|
6671
|
+
}
|
|
6672
|
+
const stats = statSync4(fullFilePath);
|
|
6673
|
+
const lastWriteTime = stats.mtimeMs;
|
|
6674
|
+
if (lastWriteTime > readTimestamp) {
|
|
6675
|
+
return {
|
|
6676
|
+
result: false,
|
|
6677
|
+
message: "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it."
|
|
6678
|
+
};
|
|
6679
|
+
}
|
|
7133
6680
|
}
|
|
7134
6681
|
return { result: true };
|
|
7135
6682
|
},
|
|
7136
|
-
async *call({ file_path,
|
|
7137
|
-
const fullFilePath =
|
|
6683
|
+
async *call({ file_path, edits, verify }, { readFileTimestamps }) {
|
|
6684
|
+
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
7138
6685
|
if (fileExistsBun(fullFilePath)) {
|
|
7139
6686
|
const readTimestamp = readFileTimestamps[fullFilePath];
|
|
7140
6687
|
const lastWriteTime = statSync4(fullFilePath).mtimeMs;
|
|
@@ -7144,32 +6691,91 @@ String: ${old_string}`,
|
|
|
7144
6691
|
);
|
|
7145
6692
|
}
|
|
7146
6693
|
}
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
);
|
|
6694
|
+
let editOperations = [];
|
|
6695
|
+
if (edits) {
|
|
6696
|
+
const { parseBlockEdits } = await import("./blockParser-CFQE5IAN.js");
|
|
6697
|
+
editOperations = parseBlockEdits(edits);
|
|
6698
|
+
}
|
|
6699
|
+
let currentFileContent = fileExistsBun(fullFilePath) ? normalizeLineEndings(await readFileBun(fullFilePath) ?? "") : "";
|
|
6700
|
+
const originalFileContent = currentFileContent;
|
|
6701
|
+
let totalPatch = [];
|
|
6702
|
+
const { SmartEdit } = await import("./smart-edit-J5J4S2TS.js");
|
|
6703
|
+
const { findLspAnchor } = await import("./lspAnchor-2ZRP7RIX.js");
|
|
6704
|
+
for (const op of editOperations) {
|
|
6705
|
+
const normalizedSearch = normalizeLineEndings(op.search);
|
|
6706
|
+
const normalizedReplace = normalizeLineEndings(op.replace);
|
|
6707
|
+
let newContent = "";
|
|
6708
|
+
if (normalizedSearch === "") {
|
|
6709
|
+
newContent = normalizedReplace;
|
|
6710
|
+
} else {
|
|
6711
|
+
newContent = SmartEdit.replace(currentFileContent, normalizedSearch, normalizedReplace, false);
|
|
6712
|
+
if (newContent === currentFileContent) {
|
|
6713
|
+
const anchor = await findLspAnchor(fullFilePath, op.search);
|
|
6714
|
+
if (anchor) {
|
|
6715
|
+
const lines = currentFileContent.split(/\r?\n/);
|
|
6716
|
+
if (anchor.startLine < lines.length) {
|
|
6717
|
+
const endLine = Math.min(anchor.endLine, lines.length - 1);
|
|
6718
|
+
const snippetLines = lines.slice(anchor.startLine, endLine + 1);
|
|
6719
|
+
const snippet = snippetLines.join("\n");
|
|
6720
|
+
try {
|
|
6721
|
+
const newSnippet = SmartEdit.replace(snippet, normalizedSearch, normalizedReplace, false);
|
|
6722
|
+
if (newSnippet !== snippet) {
|
|
6723
|
+
const before = lines.slice(0, anchor.startLine).join("\n");
|
|
6724
|
+
const after = lines.slice(endLine + 1).join("\n");
|
|
6725
|
+
newContent = (before ? before + "\n" : "") + newSnippet + (after ? "\n" + after : "");
|
|
6726
|
+
}
|
|
6727
|
+
} catch (e) {
|
|
6728
|
+
}
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
}
|
|
6732
|
+
}
|
|
6733
|
+
if (newContent === currentFileContent && normalizedSearch !== "") {
|
|
6734
|
+
throw new Error(`Could not find match for block:
|
|
6735
|
+
${op.search}`);
|
|
6736
|
+
}
|
|
6737
|
+
currentFileContent = newContent;
|
|
6738
|
+
}
|
|
6739
|
+
const updatedFile = currentFileContent;
|
|
7153
6740
|
const dir = dirname3(fullFilePath);
|
|
7154
6741
|
mkdirSync2(dir, { recursive: true });
|
|
7155
6742
|
const enc = fileExistsBun(fullFilePath) ? detectFileEncoding(fullFilePath) : "utf8";
|
|
7156
6743
|
const endings = fileExistsBun(fullFilePath) ? detectLineEndings(fullFilePath) : "LF";
|
|
7157
|
-
const originalFile = fileExistsBun(fullFilePath) ? normalizeLineEndings(await readFileBun(fullFilePath) ?? "") : "";
|
|
7158
6744
|
writeTextContent(fullFilePath, updatedFile, enc, endings);
|
|
6745
|
+
if (verify) {
|
|
6746
|
+
const { LspClientManager } = await import("./manager-VXNOOVJ2.js");
|
|
6747
|
+
const client = await LspClientManager.getInstance().getClient(fullFilePath, getCwd());
|
|
6748
|
+
if (client) {
|
|
6749
|
+
const diagnostics = client.getDiagnostics(fullFilePath);
|
|
6750
|
+
const errors = diagnostics.filter((d) => d.severity === 1);
|
|
6751
|
+
if (errors.length > 0) {
|
|
6752
|
+
writeTextContent(fullFilePath, originalFileContent, enc, endings);
|
|
6753
|
+
throw new Error(`Verification Failed: ${errors.length} syntax errors detected. Reverted changes.
|
|
6754
|
+
First error: ${errors[0].message}`);
|
|
6755
|
+
}
|
|
6756
|
+
}
|
|
6757
|
+
}
|
|
7159
6758
|
recordFileEdit(fullFilePath, updatedFile);
|
|
7160
6759
|
readFileTimestamps[fullFilePath] = statSync4(fullFilePath).mtimeMs;
|
|
7161
6760
|
emitReminderEvent("file:edited", {
|
|
7162
6761
|
filePath: fullFilePath,
|
|
7163
|
-
oldString:
|
|
7164
|
-
|
|
6762
|
+
oldString: "BLOCK_EDIT",
|
|
6763
|
+
// Simplified
|
|
6764
|
+
newString: "BLOCK_EDIT",
|
|
7165
6765
|
timestamp: Date.now(),
|
|
7166
|
-
operation:
|
|
6766
|
+
operation: "update"
|
|
6767
|
+
});
|
|
6768
|
+
const patch = getPatch({
|
|
6769
|
+
filePath: file_path,
|
|
6770
|
+
fileContents: originalFileContent,
|
|
6771
|
+
oldStr: originalFileContent,
|
|
6772
|
+
newStr: updatedFile
|
|
7167
6773
|
});
|
|
7168
6774
|
const data = {
|
|
7169
6775
|
filePath: file_path,
|
|
7170
|
-
oldString:
|
|
7171
|
-
newString:
|
|
7172
|
-
originalFile,
|
|
6776
|
+
oldString: "MULTIPLE_EDITS",
|
|
6777
|
+
newString: "MULTIPLE_EDITS",
|
|
6778
|
+
originalFile: originalFileContent,
|
|
7173
6779
|
structuredPatch: patch
|
|
7174
6780
|
};
|
|
7175
6781
|
yield {
|
|
@@ -7179,28 +6785,9 @@ String: ${old_string}`,
|
|
|
7179
6785
|
};
|
|
7180
6786
|
},
|
|
7181
6787
|
renderResultForAssistant({ filePath, originalFile, oldString, newString }) {
|
|
7182
|
-
|
|
7183
|
-
normalizeLineEndings(originalFile || ""),
|
|
7184
|
-
normalizeLineEndings(oldString),
|
|
7185
|
-
normalizeLineEndings(newString)
|
|
7186
|
-
);
|
|
7187
|
-
return `The file ${filePath} has been updated. Here's the result of running \`cat -n\` on a snippet of the edited file:
|
|
7188
|
-
${addLineNumbers({
|
|
7189
|
-
content: snippet,
|
|
7190
|
-
startLine
|
|
7191
|
-
})}`;
|
|
6788
|
+
return `The file ${filePath} has been updated successfully.`;
|
|
7192
6789
|
}
|
|
7193
6790
|
};
|
|
7194
|
-
function getSnippet(initialText, oldStr, newStr) {
|
|
7195
|
-
const before = initialText.split(oldStr)[0] ?? "";
|
|
7196
|
-
const replacementLine = before.split(/\r?\n/).length - 1;
|
|
7197
|
-
const newFileLines = initialText.replace(oldStr, newStr).split(/\r?\n/);
|
|
7198
|
-
const startLine = Math.max(0, replacementLine - N_LINES_SNIPPET);
|
|
7199
|
-
const endLine = replacementLine + N_LINES_SNIPPET + newStr.split(/\r?\n/).length;
|
|
7200
|
-
const snippetLines = newFileLines.slice(startLine, endLine + 1);
|
|
7201
|
-
const snippet = snippetLines.join("\n");
|
|
7202
|
-
return { snippet, startLine: startLine + 1 };
|
|
7203
|
-
}
|
|
7204
6791
|
|
|
7205
6792
|
// src/tools/filesystem/FileReadTool/FileReadTool.tsx
|
|
7206
6793
|
import { statSync as statSync6 } from "fs";
|
|
@@ -7248,10 +6835,10 @@ import {
|
|
|
7248
6835
|
import {
|
|
7249
6836
|
dirname as dirname4,
|
|
7250
6837
|
normalize as normalize2,
|
|
7251
|
-
resolve as
|
|
6838
|
+
resolve as resolve5,
|
|
7252
6839
|
extname as extname3,
|
|
7253
6840
|
relative as relative6,
|
|
7254
|
-
isAbsolute as
|
|
6841
|
+
isAbsolute as isAbsolute5
|
|
7255
6842
|
} from "node:path";
|
|
7256
6843
|
import { homedir as homedir5 } from "node:os";
|
|
7257
6844
|
var SecureFileService = class _SecureFileService {
|
|
@@ -7312,14 +6899,14 @@ var SecureFileService = class _SecureFileService {
|
|
|
7312
6899
|
};
|
|
7313
6900
|
}
|
|
7314
6901
|
}
|
|
7315
|
-
const absolutePath =
|
|
6902
|
+
const absolutePath = resolve5(normalizedPath);
|
|
7316
6903
|
const isInAllowedPath = Array.from(this.allowedBasePaths).some(
|
|
7317
6904
|
(basePath) => {
|
|
7318
|
-
const base =
|
|
6905
|
+
const base = resolve5(basePath);
|
|
7319
6906
|
const rel = relative6(base, absolutePath);
|
|
7320
6907
|
if (!rel || rel === "") return true;
|
|
7321
6908
|
if (rel.startsWith("..")) return false;
|
|
7322
|
-
if (
|
|
6909
|
+
if (isAbsolute5(rel)) return false;
|
|
7323
6910
|
return true;
|
|
7324
6911
|
}
|
|
7325
6912
|
);
|
|
@@ -7553,7 +7140,7 @@ var SecureFileService = class _SecureFileService {
|
|
|
7553
7140
|
}
|
|
7554
7141
|
addAllowedBasePath(basePath) {
|
|
7555
7142
|
try {
|
|
7556
|
-
const normalized = normalize2(
|
|
7143
|
+
const normalized = normalize2(resolve5(basePath));
|
|
7557
7144
|
if (!existsSync5(normalized)) {
|
|
7558
7145
|
return { success: false, error: "Base path does not exist" };
|
|
7559
7146
|
}
|
|
@@ -7942,6 +7529,9 @@ var inputSchema4 = z4.strictObject({
|
|
|
7942
7529
|
),
|
|
7943
7530
|
limit: z4.number().optional().describe(
|
|
7944
7531
|
"The number of lines to read. Only provide if the file is too large to read at once."
|
|
7532
|
+
),
|
|
7533
|
+
symbol_name: z4.string().optional().describe(
|
|
7534
|
+
"The name of the symbol (class, function, etc.) to read. If provided, the tool will use LSP to find the symbol definition and read the corresponding lines, ignoring offset/limit."
|
|
7945
7535
|
)
|
|
7946
7536
|
});
|
|
7947
7537
|
var FileReadTool = {
|
|
@@ -7997,7 +7587,7 @@ var FileReadTool = {
|
|
|
7997
7587
|
renderToolUseRejectedMessage() {
|
|
7998
7588
|
return /* @__PURE__ */ React13.createElement(FallbackToolUseRejectedMessage, null);
|
|
7999
7589
|
},
|
|
8000
|
-
async validateInput({ file_path, offset, limit }) {
|
|
7590
|
+
async validateInput({ file_path, offset, limit, symbol_name }) {
|
|
8001
7591
|
const fullFilePath = normalizeFilePath(file_path);
|
|
8002
7592
|
const fileCheck = secureFileService.safeGetFileInfo(fullFilePath);
|
|
8003
7593
|
if (!fileCheck.success) {
|
|
@@ -8038,9 +7628,42 @@ var FileReadTool = {
|
|
|
8038
7628
|
}
|
|
8039
7629
|
return { result: true };
|
|
8040
7630
|
},
|
|
8041
|
-
async *call({ file_path, offset = 1, limit = void 0 }, { readFileTimestamps }) {
|
|
7631
|
+
async *call({ file_path, offset = 1, limit = void 0, symbol_name }, { readFileTimestamps }) {
|
|
8042
7632
|
const ext = path6.extname(file_path).toLowerCase();
|
|
8043
7633
|
const fullFilePath = normalizeFilePath(file_path);
|
|
7634
|
+
let startLine = offset;
|
|
7635
|
+
let finalLimit = limit;
|
|
7636
|
+
if (symbol_name) {
|
|
7637
|
+
try {
|
|
7638
|
+
const { LspClientManager } = await import("./manager-VXNOOVJ2.js");
|
|
7639
|
+
const client = await LspClientManager.getInstance().getClient(fullFilePath, getCwd());
|
|
7640
|
+
if (!client) {
|
|
7641
|
+
throw new Error(`LSP client not available for ${ext}. Cannot search for symbol '${symbol_name}'.`);
|
|
7642
|
+
}
|
|
7643
|
+
const symbols = await client.documentSymbol(fullFilePath);
|
|
7644
|
+
if (!symbols || symbols.length === 0) {
|
|
7645
|
+
throw new Error(`No symbols found in file.`);
|
|
7646
|
+
}
|
|
7647
|
+
const findSymbol = (syms) => {
|
|
7648
|
+
for (const sym of syms) {
|
|
7649
|
+
if (sym.name === symbol_name) return sym;
|
|
7650
|
+
if (sym.children) {
|
|
7651
|
+
const found = findSymbol(sym.children);
|
|
7652
|
+
if (found) return found;
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
return null;
|
|
7656
|
+
};
|
|
7657
|
+
const symbol = findSymbol(symbols);
|
|
7658
|
+
if (!symbol) {
|
|
7659
|
+
throw new Error(`Symbol '${symbol_name}' not found in file.`);
|
|
7660
|
+
}
|
|
7661
|
+
startLine = symbol.range.start.line + 1;
|
|
7662
|
+
finalLimit = symbol.range.end.line - symbol.range.start.line + 1;
|
|
7663
|
+
} catch (e) {
|
|
7664
|
+
throw new Error(`Symbol reading failed: ${e.message}`);
|
|
7665
|
+
}
|
|
7666
|
+
}
|
|
8044
7667
|
recordFileRead(fullFilePath);
|
|
8045
7668
|
emitReminderEvent("file:read", {
|
|
8046
7669
|
filePath: fullFilePath,
|
|
@@ -8107,10 +7730,8 @@ var FileReadTool = {
|
|
|
8107
7730
|
};
|
|
8108
7731
|
return;
|
|
8109
7732
|
}
|
|
8110
|
-
let startLine = offset;
|
|
8111
7733
|
let zeroBasedOffset = startLine === 0 ? 0 : startLine - 1;
|
|
8112
|
-
|
|
8113
|
-
if (limit) {
|
|
7734
|
+
if (limit && !symbol_name) {
|
|
8114
7735
|
try {
|
|
8115
7736
|
const fullContent = await readFileBun(fullFilePath);
|
|
8116
7737
|
if (fullContent) {
|
|
@@ -8277,7 +7898,7 @@ async function readImage(filePath, ext) {
|
|
|
8277
7898
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync4, statSync as statSync7 } from "fs";
|
|
8278
7899
|
import { Box as Box13, Text as Text14 } from "ink";
|
|
8279
7900
|
import { EOL } from "os";
|
|
8280
|
-
import { dirname as dirname5, extname as extname6, isAbsolute as
|
|
7901
|
+
import { dirname as dirname5, extname as extname6, isAbsolute as isAbsolute6, relative as relative8, resolve as resolve6 } from "path";
|
|
8281
7902
|
import * as React14 from "react";
|
|
8282
7903
|
import { z as z5 } from "zod";
|
|
8283
7904
|
|
|
@@ -8331,7 +7952,7 @@ var FileWriteTool = {
|
|
|
8331
7952
|
if (!file_path) {
|
|
8332
7953
|
return /* @__PURE__ */ React14.createElement(FallbackToolUseRejectedMessage, null);
|
|
8333
7954
|
}
|
|
8334
|
-
const fullFilePath =
|
|
7955
|
+
const fullFilePath = isAbsolute6(file_path) ? file_path : resolve6(getCwd(), file_path);
|
|
8335
7956
|
const oldFileExists = fileExistsBun(fullFilePath);
|
|
8336
7957
|
const enc = oldFileExists ? detectFileEncoding(fullFilePath) : "utf-8";
|
|
8337
7958
|
const oldContent = oldFileExists ? readFileSync4(fullFilePath, enc) : null;
|
|
@@ -8377,7 +7998,7 @@ var FileWriteTool = {
|
|
|
8377
7998
|
}
|
|
8378
7999
|
},
|
|
8379
8000
|
async validateInput({ file_path }, { readFileTimestamps }) {
|
|
8380
|
-
const fullFilePath =
|
|
8001
|
+
const fullFilePath = isAbsolute6(file_path) ? file_path : resolve6(getCwd(), file_path);
|
|
8381
8002
|
if (fullFilePath.endsWith(".ipynb")) {
|
|
8382
8003
|
return {
|
|
8383
8004
|
result: false,
|
|
@@ -8405,7 +8026,7 @@ var FileWriteTool = {
|
|
|
8405
8026
|
return { result: true };
|
|
8406
8027
|
},
|
|
8407
8028
|
async *call({ file_path, content }, { readFileTimestamps }) {
|
|
8408
|
-
const fullFilePath =
|
|
8029
|
+
const fullFilePath = isAbsolute6(file_path) ? file_path : resolve6(getCwd(), file_path);
|
|
8409
8030
|
const dir = dirname5(fullFilePath);
|
|
8410
8031
|
const oldFileExists = fileExistsBun(fullFilePath);
|
|
8411
8032
|
if (oldFileExists) {
|
|
@@ -8495,11 +8116,15 @@ var DESCRIPTION4 = `- Fast file pattern matching tool that works with any codeba
|
|
|
8495
8116
|
|
|
8496
8117
|
// src/tools/filesystem/GlobTool/GlobTool.tsx
|
|
8497
8118
|
import { existsSync as existsSync6, statSync as statSync8 } from "fs";
|
|
8498
|
-
import { isAbsolute as
|
|
8119
|
+
import { isAbsolute as isAbsolute7, join as join5, relative as relative9, resolve as resolve7 } from "path";
|
|
8120
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8499
8121
|
var inputSchema6 = z6.strictObject({
|
|
8500
8122
|
pattern: z6.string().describe("The glob pattern to match files against"),
|
|
8501
8123
|
path: z6.string().optional().describe(
|
|
8502
8124
|
'The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.'
|
|
8125
|
+
),
|
|
8126
|
+
semantic: z6.boolean().optional().describe(
|
|
8127
|
+
"Enable semantic search using LSP workspace symbols to find relevant files. Useful when you know the symbol name but not the file path."
|
|
8503
8128
|
)
|
|
8504
8129
|
});
|
|
8505
8130
|
var DEFAULT_LIMIT = 100;
|
|
@@ -8529,7 +8154,7 @@ var GlobTool = {
|
|
|
8529
8154
|
},
|
|
8530
8155
|
async validateInput({ path: path7 }) {
|
|
8531
8156
|
if (!path7) return { result: true };
|
|
8532
|
-
const absolute =
|
|
8157
|
+
const absolute = isAbsolute7(path7) ? path7 : resolve7(getCwd(), path7);
|
|
8533
8158
|
if (!existsSync6(absolute)) {
|
|
8534
8159
|
return {
|
|
8535
8160
|
result: false,
|
|
@@ -8546,10 +8171,13 @@ var GlobTool = {
|
|
|
8546
8171
|
}
|
|
8547
8172
|
return { result: true };
|
|
8548
8173
|
},
|
|
8549
|
-
renderToolUseMessage({ pattern, path: path7 }, { verbose }) {
|
|
8550
|
-
const absolutePath = path7 ?
|
|
8174
|
+
renderToolUseMessage({ pattern, path: path7, semantic }, { verbose }) {
|
|
8175
|
+
const absolutePath = path7 ? isAbsolute7(path7) ? path7 : resolve7(getCwd(), path7) : void 0;
|
|
8551
8176
|
const relativePath = absolutePath ? relative9(getCwd(), absolutePath) : void 0;
|
|
8552
|
-
|
|
8177
|
+
const parts = [`pattern: "${pattern}"`];
|
|
8178
|
+
if (path7) parts.push(`path: "${verbose ? absolutePath : relativePath}"`);
|
|
8179
|
+
if (semantic) parts.push("semantic: true");
|
|
8180
|
+
return parts.join(", ");
|
|
8553
8181
|
},
|
|
8554
8182
|
renderToolUseRejectedMessage() {
|
|
8555
8183
|
return /* @__PURE__ */ React15.createElement(FallbackToolUseRejectedMessage, null);
|
|
@@ -8560,9 +8188,9 @@ var GlobTool = {
|
|
|
8560
8188
|
}
|
|
8561
8189
|
return /* @__PURE__ */ React15.createElement(Box14, { justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React15.createElement(Box14, { flexDirection: "row" }, /* @__PURE__ */ React15.createElement(Text15, null, "\xA0\xA0\u23BF \xA0Found "), /* @__PURE__ */ React15.createElement(Text15, { bold: true }, output.numFiles, " "), /* @__PURE__ */ React15.createElement(Text15, null, output.numFiles === 0 || output.numFiles > 1 ? "files" : "file")), /* @__PURE__ */ React15.createElement(Cost, { costUSD: 0, durationMs: output.durationMs, debug: false }));
|
|
8562
8190
|
},
|
|
8563
|
-
async *call({ pattern, path: path7 }, { abortController }) {
|
|
8191
|
+
async *call({ pattern, path: path7, semantic }, { abortController }) {
|
|
8564
8192
|
const start = Date.now();
|
|
8565
|
-
const searchPath = path7 ?
|
|
8193
|
+
const searchPath = path7 ? isAbsolute7(path7) ? path7 : resolve7(getCwd(), path7) : getCwd();
|
|
8566
8194
|
const raw = await ripGrep(
|
|
8567
8195
|
[
|
|
8568
8196
|
"--files",
|
|
@@ -8575,7 +8203,26 @@ var GlobTool = {
|
|
|
8575
8203
|
searchPath,
|
|
8576
8204
|
abortController.signal
|
|
8577
8205
|
);
|
|
8578
|
-
|
|
8206
|
+
let files = raw.map((p) => isAbsolute7(p) ? p : join5(searchPath, p));
|
|
8207
|
+
if (semantic) {
|
|
8208
|
+
try {
|
|
8209
|
+
const { LspClientManager } = await import("./manager-VXNOOVJ2.js");
|
|
8210
|
+
const symbols = await LspClientManager.getInstance().workspaceSymbol(pattern);
|
|
8211
|
+
const semanticFiles = symbols.map((s) => {
|
|
8212
|
+
let filePath = s.location?.uri || "";
|
|
8213
|
+
if (filePath.startsWith("file://")) {
|
|
8214
|
+
try {
|
|
8215
|
+
filePath = fileURLToPath2(filePath);
|
|
8216
|
+
} catch (e) {
|
|
8217
|
+
filePath = filePath.replace("file://", "");
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
8220
|
+
return filePath;
|
|
8221
|
+
}).filter(Boolean);
|
|
8222
|
+
files = Array.from(/* @__PURE__ */ new Set([...files, ...semanticFiles]));
|
|
8223
|
+
} catch (e) {
|
|
8224
|
+
}
|
|
8225
|
+
}
|
|
8579
8226
|
const truncated = files.length > DEFAULT_LIMIT;
|
|
8580
8227
|
const limitedFiles = files.slice(0, DEFAULT_LIMIT);
|
|
8581
8228
|
const output = {
|
|
@@ -8628,7 +8275,8 @@ var DESCRIPTION5 = `A powerful search tool built on ripgrep
|
|
|
8628
8275
|
`;
|
|
8629
8276
|
|
|
8630
8277
|
// src/tools/search/GrepTool/GrepTool.tsx
|
|
8631
|
-
import { isAbsolute as
|
|
8278
|
+
import { isAbsolute as isAbsolute8, relative as relative10 } from "path";
|
|
8279
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8632
8280
|
var inputSchema7 = z7.strictObject({
|
|
8633
8281
|
pattern: z7.string().describe("The regular expression pattern to search for in file contents"),
|
|
8634
8282
|
path: z7.string().optional().describe(
|
|
@@ -8664,6 +8312,12 @@ var inputSchema7 = z7.strictObject({
|
|
|
8664
8312
|
),
|
|
8665
8313
|
multiline: z7.boolean().optional().describe(
|
|
8666
8314
|
"Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false."
|
|
8315
|
+
),
|
|
8316
|
+
semantic: z7.boolean().optional().describe(
|
|
8317
|
+
"Enable semantic search using LSP workspace symbols if text search fails. Useful for finding symbols even with typos."
|
|
8318
|
+
),
|
|
8319
|
+
symbol_type: z7.string().optional().describe(
|
|
8320
|
+
'Filter semantic search by symbol type (e.g. "class", "function", "variable"). Requires semantic: true.'
|
|
8667
8321
|
)
|
|
8668
8322
|
});
|
|
8669
8323
|
var MAX_RESULT_CHARS = 2e4;
|
|
@@ -8690,7 +8344,7 @@ function toProjectRelativeIfPossible(p) {
|
|
|
8690
8344
|
const rel = relative10(projectRoot, p);
|
|
8691
8345
|
if (!rel || rel === "") return p;
|
|
8692
8346
|
if (rel.startsWith("..")) return p;
|
|
8693
|
-
if (
|
|
8347
|
+
if (isAbsolute8(rel)) return p;
|
|
8694
8348
|
return rel;
|
|
8695
8349
|
}
|
|
8696
8350
|
function formatPagination(limit, offset) {
|
|
@@ -8815,7 +8469,9 @@ ${result.filenames.join("\n")}`;
|
|
|
8815
8469
|
"-i": caseInsensitive = false,
|
|
8816
8470
|
head_limit,
|
|
8817
8471
|
offset = 0,
|
|
8818
|
-
multiline = false
|
|
8472
|
+
multiline = false,
|
|
8473
|
+
semantic = false,
|
|
8474
|
+
symbol_type
|
|
8819
8475
|
}, toolUseContext) {
|
|
8820
8476
|
const { abortController } = toolUseContext;
|
|
8821
8477
|
const start = Date.now();
|
|
@@ -8860,6 +8516,94 @@ ${result.filenames.join("\n")}`;
|
|
|
8860
8516
|
const lines = await ripGrep(args, absolutePath, abortController.signal, {
|
|
8861
8517
|
sandbox: sandboxPlan.settings.enabled ? sandboxPlan.bunShellSandboxOptions : void 0
|
|
8862
8518
|
});
|
|
8519
|
+
if (lines.length === 0 && semantic) {
|
|
8520
|
+
try {
|
|
8521
|
+
const { LspClientManager } = await import("./manager-VXNOOVJ2.js");
|
|
8522
|
+
const symbols = await LspClientManager.getInstance().workspaceSymbol(String(pattern));
|
|
8523
|
+
let filtered = symbols;
|
|
8524
|
+
const symbolType = symbol_type;
|
|
8525
|
+
if (symbolType) {
|
|
8526
|
+
const type3 = symbolType.toLowerCase();
|
|
8527
|
+
const kindMap = {
|
|
8528
|
+
"file": 1,
|
|
8529
|
+
"module": 2,
|
|
8530
|
+
"namespace": 3,
|
|
8531
|
+
"package": 4,
|
|
8532
|
+
"class": 5,
|
|
8533
|
+
"method": 6,
|
|
8534
|
+
"property": 7,
|
|
8535
|
+
"field": 8,
|
|
8536
|
+
"constructor": 9,
|
|
8537
|
+
"enum": 10,
|
|
8538
|
+
"interface": 11,
|
|
8539
|
+
"function": 12,
|
|
8540
|
+
"variable": 13,
|
|
8541
|
+
"constant": 14,
|
|
8542
|
+
"string": 15,
|
|
8543
|
+
"number": 16,
|
|
8544
|
+
"boolean": 17,
|
|
8545
|
+
"array": 18,
|
|
8546
|
+
"object": 19,
|
|
8547
|
+
"key": 20,
|
|
8548
|
+
"null": 21,
|
|
8549
|
+
"enummember": 22,
|
|
8550
|
+
"struct": 23,
|
|
8551
|
+
"event": 24,
|
|
8552
|
+
"operator": 25,
|
|
8553
|
+
"typeparameter": 26
|
|
8554
|
+
};
|
|
8555
|
+
const targetKind = kindMap[type3];
|
|
8556
|
+
if (targetKind) {
|
|
8557
|
+
filtered = symbols.filter((s) => s.kind === targetKind);
|
|
8558
|
+
}
|
|
8559
|
+
}
|
|
8560
|
+
if (filtered.length > 0) {
|
|
8561
|
+
const semanticLines = filtered.map((s) => {
|
|
8562
|
+
let filePath = s.location?.uri || "";
|
|
8563
|
+
if (filePath.startsWith("file://")) {
|
|
8564
|
+
try {
|
|
8565
|
+
filePath = fileURLToPath3(filePath);
|
|
8566
|
+
} catch (e) {
|
|
8567
|
+
filePath = filePath.replace("file://", "");
|
|
8568
|
+
}
|
|
8569
|
+
}
|
|
8570
|
+
const line = (s.location?.range?.start?.line || 0) + 1;
|
|
8571
|
+
const kindNameMap = {
|
|
8572
|
+
1: "File",
|
|
8573
|
+
2: "Module",
|
|
8574
|
+
3: "Namespace",
|
|
8575
|
+
4: "Package",
|
|
8576
|
+
5: "Class",
|
|
8577
|
+
6: "Method",
|
|
8578
|
+
7: "Property",
|
|
8579
|
+
8: "Field",
|
|
8580
|
+
9: "Constructor",
|
|
8581
|
+
10: "Enum",
|
|
8582
|
+
11: "Interface",
|
|
8583
|
+
12: "Function",
|
|
8584
|
+
13: "Variable",
|
|
8585
|
+
14: "Constant",
|
|
8586
|
+
15: "String",
|
|
8587
|
+
16: "Number",
|
|
8588
|
+
17: "Boolean",
|
|
8589
|
+
18: "Array",
|
|
8590
|
+
19: "Object",
|
|
8591
|
+
20: "Key",
|
|
8592
|
+
21: "Null",
|
|
8593
|
+
22: "EnumMember",
|
|
8594
|
+
23: "Struct",
|
|
8595
|
+
24: "Event",
|
|
8596
|
+
25: "Operator",
|
|
8597
|
+
26: "TypeParameter"
|
|
8598
|
+
};
|
|
8599
|
+
const kindName = kindNameMap[s.kind] || "Unknown";
|
|
8600
|
+
return `${filePath}:${line}: ${s.name} (${kindName})`;
|
|
8601
|
+
});
|
|
8602
|
+
lines.push(...semanticLines);
|
|
8603
|
+
}
|
|
8604
|
+
} catch (e) {
|
|
8605
|
+
}
|
|
8606
|
+
}
|
|
8863
8607
|
if (output_mode === "content") {
|
|
8864
8608
|
const rewritten = lines.map((line) => {
|
|
8865
8609
|
const idx = line.indexOf(":");
|
|
@@ -10304,9 +10048,9 @@ function setTerminalTitle(title) {
|
|
|
10304
10048
|
}
|
|
10305
10049
|
}
|
|
10306
10050
|
function clearTerminal() {
|
|
10307
|
-
return new Promise((
|
|
10051
|
+
return new Promise((resolve11) => {
|
|
10308
10052
|
process.stdout.write("\x1B[2J\x1B[3J\x1B[H", () => {
|
|
10309
|
-
|
|
10053
|
+
resolve11();
|
|
10310
10054
|
});
|
|
10311
10055
|
});
|
|
10312
10056
|
}
|
|
@@ -11424,8 +11168,8 @@ var OAuthService = class {
|
|
|
11424
11168
|
await authURLHandler(manualUrl);
|
|
11425
11169
|
await openBrowser(autoUrl);
|
|
11426
11170
|
};
|
|
11427
|
-
const { authorizationCode, useManualRedirect } = await new Promise((
|
|
11428
|
-
this.pendingCodePromise = { resolve:
|
|
11171
|
+
const { authorizationCode, useManualRedirect } = await new Promise((resolve11, reject) => {
|
|
11172
|
+
this.pendingCodePromise = { resolve: resolve11, reject };
|
|
11429
11173
|
this.startLocalServer(state, onReady);
|
|
11430
11174
|
});
|
|
11431
11175
|
const {
|
|
@@ -11596,7 +11340,7 @@ async function createAndStoreApiKey(accessToken) {
|
|
|
11596
11340
|
}
|
|
11597
11341
|
saveGlobalConfig(config2);
|
|
11598
11342
|
try {
|
|
11599
|
-
const { resetAnthropicClient } = await import("./llm-
|
|
11343
|
+
const { resetAnthropicClient } = await import("./llm-NW2S47DG.js");
|
|
11600
11344
|
resetAnthropicClient();
|
|
11601
11345
|
} catch {
|
|
11602
11346
|
}
|
|
@@ -13966,7 +13710,7 @@ function ModelSelector({
|
|
|
13966
13710
|
setModelLoadError(
|
|
13967
13711
|
`Attempt ${attempt}/${MAX_RETRIES}: Retrying model discovery...`
|
|
13968
13712
|
);
|
|
13969
|
-
await new Promise((
|
|
13713
|
+
await new Promise((resolve11) => setTimeout(resolve11, 1e3));
|
|
13970
13714
|
}
|
|
13971
13715
|
try {
|
|
13972
13716
|
const models = await fetchModels();
|
|
@@ -15878,7 +15622,7 @@ async function refreshPluginRuntimeFromInstalls() {
|
|
|
15878
15622
|
const existingRoots = getSessionPlugins().map((p) => p.rootDir);
|
|
15879
15623
|
const dirs = Array.from(/* @__PURE__ */ new Set([...existingRoots, ...installedRoots]));
|
|
15880
15624
|
if (dirs.length === 0) return [];
|
|
15881
|
-
const { configureSessionPlugins } = await import("./pluginRuntime-
|
|
15625
|
+
const { configureSessionPlugins } = await import("./pluginRuntime-SHFEMATT.js");
|
|
15882
15626
|
const { errors } = await configureSessionPlugins({ pluginDirs: dirs });
|
|
15883
15627
|
return errors;
|
|
15884
15628
|
}
|
|
@@ -16547,7 +16291,7 @@ async function call(onDone, context) {
|
|
|
16547
16291
|
ModelConfig,
|
|
16548
16292
|
{
|
|
16549
16293
|
onClose: () => {
|
|
16550
|
-
import("./model-
|
|
16294
|
+
import("./model-4ZGIHII2.js").then(({ reloadModelManager: reloadModelManager2 }) => {
|
|
16551
16295
|
reloadModelManager2();
|
|
16552
16296
|
triggerModelConfigChange();
|
|
16553
16297
|
onDone();
|
|
@@ -20606,7 +20350,7 @@ async function launchExternalEditor(initialText) {
|
|
|
20606
20350
|
}
|
|
20607
20351
|
}
|
|
20608
20352
|
try {
|
|
20609
|
-
await new Promise((
|
|
20353
|
+
await new Promise((resolve11, reject) => {
|
|
20610
20354
|
const child = spawn(
|
|
20611
20355
|
editorCommand.command,
|
|
20612
20356
|
[...editorCommand.args, filePath],
|
|
@@ -20618,7 +20362,7 @@ async function launchExternalEditor(initialText) {
|
|
|
20618
20362
|
child.on("error", reject);
|
|
20619
20363
|
child.on("exit", (code, signal) => {
|
|
20620
20364
|
if (code === 0 || code === null) {
|
|
20621
|
-
|
|
20365
|
+
resolve11();
|
|
20622
20366
|
} else {
|
|
20623
20367
|
reject(
|
|
20624
20368
|
new Error(
|
|
@@ -20669,7 +20413,7 @@ async function launchExternalEditorForFilePath(filePath) {
|
|
|
20669
20413
|
}
|
|
20670
20414
|
}
|
|
20671
20415
|
try {
|
|
20672
|
-
await new Promise((
|
|
20416
|
+
await new Promise((resolve11, reject) => {
|
|
20673
20417
|
const child = spawn(
|
|
20674
20418
|
editorCommand.command,
|
|
20675
20419
|
[...editorCommand.args, filePath],
|
|
@@ -20681,7 +20425,7 @@ async function launchExternalEditorForFilePath(filePath) {
|
|
|
20681
20425
|
child.on("error", reject);
|
|
20682
20426
|
child.on("exit", (code, signal) => {
|
|
20683
20427
|
if (code === 0 || code === null) {
|
|
20684
|
-
|
|
20428
|
+
resolve11();
|
|
20685
20429
|
} else {
|
|
20686
20430
|
reject(
|
|
20687
20431
|
new Error(
|
|
@@ -21659,7 +21403,7 @@ function getCompletionContext(args) {
|
|
|
21659
21403
|
|
|
21660
21404
|
// src/utils/completion/fileSuggestions.ts
|
|
21661
21405
|
import { existsSync as existsSync13, readdirSync as readdirSync3, statSync as statSync11 } from "fs";
|
|
21662
|
-
import { basename as basename5, dirname as dirname9, join as join9, resolve as
|
|
21406
|
+
import { basename as basename5, dirname as dirname9, join as join9, resolve as resolve8 } from "path";
|
|
21663
21407
|
function generateFileSuggestions(args) {
|
|
21664
21408
|
const { prefix, cwd: cwd2 } = args;
|
|
21665
21409
|
try {
|
|
@@ -21672,7 +21416,7 @@ function generateFileSuggestions(args) {
|
|
|
21672
21416
|
} else if (isAbsolutePath) {
|
|
21673
21417
|
searchPath = userPath;
|
|
21674
21418
|
} else {
|
|
21675
|
-
searchPath =
|
|
21419
|
+
searchPath = resolve8(cwd2, userPath);
|
|
21676
21420
|
}
|
|
21677
21421
|
const endsWithSlash = userPath.endsWith("/");
|
|
21678
21422
|
const searchStat = existsSync13(searchPath) ? statSync11(searchPath) : null;
|
|
@@ -23806,7 +23550,7 @@ function useStatusLine() {
|
|
|
23806
23550
|
// src/ui/components/PromptInput.tsx
|
|
23807
23551
|
async function interpretHashCommand(input) {
|
|
23808
23552
|
try {
|
|
23809
|
-
const { queryQuick: queryQuick2 } = await import("./llm-
|
|
23553
|
+
const { queryQuick: queryQuick2 } = await import("./llm-NW2S47DG.js");
|
|
23810
23554
|
const systemPrompt = [
|
|
23811
23555
|
"You're helping the user structure notes that will be added to their PYB.md file.",
|
|
23812
23556
|
"Format the user's input into a well-structured note that will be useful for later reference.",
|
|
@@ -24011,7 +23755,7 @@ function PromptInput({
|
|
|
24011
23755
|
abortController.abort();
|
|
24012
23756
|
}
|
|
24013
23757
|
setIsLoading(false);
|
|
24014
|
-
await new Promise((
|
|
23758
|
+
await new Promise((resolve11) => setTimeout(resolve11, 0));
|
|
24015
23759
|
setIsLoading(true);
|
|
24016
23760
|
let finalInput2 = cleanInput;
|
|
24017
23761
|
for (const { placeholder: placeholder2, text } of pastedTexts) {
|
|
@@ -24119,7 +23863,7 @@ function PromptInput({
|
|
|
24119
23863
|
if (messages2.length) {
|
|
24120
23864
|
if (mode === "bash") {
|
|
24121
23865
|
onQuery(messages2, newAbortController).then(async () => {
|
|
24122
|
-
const { getCwd: getCwd2 } = await import("./state-
|
|
23866
|
+
const { getCwd: getCwd2 } = await import("./state-E53XB637.js");
|
|
24123
23867
|
setCurrentPwd(getCwd2());
|
|
24124
23868
|
});
|
|
24125
23869
|
} else {
|
|
@@ -24479,11 +24223,11 @@ import { useCallback as useCallback14 } from "react";
|
|
|
24479
24223
|
function useCanUseTool(setToolUseConfirm) {
|
|
24480
24224
|
return useCallback14(
|
|
24481
24225
|
async (tool, input, toolUseContext, assistantMessage) => {
|
|
24482
|
-
return new Promise((
|
|
24226
|
+
return new Promise((resolve11) => {
|
|
24483
24227
|
function logCancelledEvent() {
|
|
24484
24228
|
}
|
|
24485
24229
|
function resolveWithCancelledAndAbortAllToolCalls(message) {
|
|
24486
|
-
|
|
24230
|
+
resolve11({
|
|
24487
24231
|
result: false,
|
|
24488
24232
|
message: message ? `${REJECT_MESSAGE_WITH_FEEDBACK_PREFIX}${message}` : REJECT_MESSAGE
|
|
24489
24233
|
});
|
|
@@ -24501,12 +24245,12 @@ function useCanUseTool(setToolUseConfirm) {
|
|
|
24501
24245
|
assistantMessage
|
|
24502
24246
|
).then(async (result) => {
|
|
24503
24247
|
if (result.result === true) {
|
|
24504
|
-
|
|
24248
|
+
resolve11({ result: true });
|
|
24505
24249
|
return;
|
|
24506
24250
|
}
|
|
24507
24251
|
const deniedResult = result;
|
|
24508
24252
|
if (deniedResult.shouldPromptUser === false) {
|
|
24509
|
-
|
|
24253
|
+
resolve11({ result: false, message: deniedResult.message });
|
|
24510
24254
|
return;
|
|
24511
24255
|
}
|
|
24512
24256
|
const [description2, commandPrefix] = await Promise.all([
|
|
@@ -24538,7 +24282,7 @@ function useCanUseTool(setToolUseConfirm) {
|
|
|
24538
24282
|
if (type2 === "permanent") {
|
|
24539
24283
|
} else {
|
|
24540
24284
|
}
|
|
24541
|
-
|
|
24285
|
+
resolve11({ result: true });
|
|
24542
24286
|
},
|
|
24543
24287
|
onReject(rejectionMessage) {
|
|
24544
24288
|
resolveWithCancelledAndAbortAllToolCalls(rejectionMessage);
|
|
@@ -25190,8 +24934,8 @@ var ToolUseQueue = class {
|
|
|
25190
24934
|
}
|
|
25191
24935
|
if (this.hasExecutingTools() && !this.hasCompletedResults() && !this.hasPendingProgress()) {
|
|
25192
24936
|
const promises = this.tools.filter((t) => t.status === "executing" && t.promise).map((t) => t.promise);
|
|
25193
|
-
const progressPromise = new Promise((
|
|
25194
|
-
this.progressAvailableResolve =
|
|
24937
|
+
const progressPromise = new Promise((resolve11) => {
|
|
24938
|
+
this.progressAvailableResolve = resolve11;
|
|
25195
24939
|
});
|
|
25196
24940
|
if (promises.length > 0) {
|
|
25197
24941
|
await Promise.race([...promises, progressPromise]);
|
|
@@ -26056,7 +25800,7 @@ function BinaryFeedbackView({
|
|
|
26056
25800
|
function BinaryFeedback({
|
|
26057
25801
|
m1,
|
|
26058
25802
|
m2,
|
|
26059
|
-
resolve:
|
|
25803
|
+
resolve: resolve11,
|
|
26060
25804
|
debug: debug2,
|
|
26061
25805
|
erroredToolUseIDs,
|
|
26062
25806
|
inProgressToolUseIDs,
|
|
@@ -26068,9 +25812,9 @@ function BinaryFeedback({
|
|
|
26068
25812
|
const onChoose = useCallback15(
|
|
26069
25813
|
(choice) => {
|
|
26070
25814
|
logBinaryFeedbackEvent(m1, m2, choice);
|
|
26071
|
-
|
|
25815
|
+
resolve11(getBinaryFeedbackResultForChoice(m1, m2, choice));
|
|
26072
25816
|
},
|
|
26073
|
-
[m1, m2,
|
|
25817
|
+
[m1, m2, resolve11]
|
|
26074
25818
|
);
|
|
26075
25819
|
useNotifyAfterTimeout(
|
|
26076
25820
|
`${PRODUCT_NAME} needs your input on a response comparison`
|
|
@@ -26905,7 +26649,7 @@ import { homedir as homedir7 } from "os";
|
|
|
26905
26649
|
// src/commands/agents/generation.ts
|
|
26906
26650
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
26907
26651
|
async function generateAgentWithClaude(prompt) {
|
|
26908
|
-
const { queryModel } = await import("./llm-
|
|
26652
|
+
const { queryModel } = await import("./llm-NW2S47DG.js");
|
|
26909
26653
|
const systemPrompt = `You are an expert at creating AI agent configurations. Based on the user's description, generate a specialized agent configuration.
|
|
26910
26654
|
|
|
26911
26655
|
Return your response as a JSON object with exactly these fields:
|
|
@@ -27202,7 +26946,7 @@ var COLOR_OPTIONS = [
|
|
|
27202
26946
|
"cyan"
|
|
27203
26947
|
];
|
|
27204
26948
|
function openInEditor(filePath) {
|
|
27205
|
-
return new Promise((
|
|
26949
|
+
return new Promise((resolve11, reject) => {
|
|
27206
26950
|
const platform = process.platform;
|
|
27207
26951
|
let command4;
|
|
27208
26952
|
let args;
|
|
@@ -27225,7 +26969,7 @@ function openInEditor(filePath) {
|
|
|
27225
26969
|
child.on("error", (err) => reject(err));
|
|
27226
26970
|
child.on(
|
|
27227
26971
|
"exit",
|
|
27228
|
-
(code) => code === 0 ?
|
|
26972
|
+
(code) => code === 0 ? resolve11() : reject(new Error(`Editor exited with ${code}`))
|
|
27229
26973
|
);
|
|
27230
26974
|
});
|
|
27231
26975
|
}
|
|
@@ -30104,7 +29848,7 @@ var BashParser = class {
|
|
|
30104
29848
|
};
|
|
30105
29849
|
|
|
30106
29850
|
// src/utils/bash-parser/validator.ts
|
|
30107
|
-
import { resolve as
|
|
29851
|
+
import { resolve as resolve9 } from "path";
|
|
30108
29852
|
async function validateSafety(script, cwd2 = process.cwd()) {
|
|
30109
29853
|
const tree2 = await BashParser.parse(script);
|
|
30110
29854
|
const root = tree2.rootNode;
|
|
@@ -30155,7 +29899,7 @@ function checkCommand(node, script, cwd2) {
|
|
|
30155
29899
|
const targetsCritical = args.some((arg) => {
|
|
30156
29900
|
if (arg.startsWith("-") || arg.startsWith("$")) return false;
|
|
30157
29901
|
try {
|
|
30158
|
-
const absPath =
|
|
29902
|
+
const absPath = resolve9(cwd2, arg).replace(/\\/g, "/");
|
|
30159
29903
|
return criticalPaths.some((critical) => {
|
|
30160
29904
|
const normalizedCritical = critical.endsWith("/") ? critical : critical + "/";
|
|
30161
29905
|
if (absPath === critical || absPath === critical.replace(/\/$/, "")) return true;
|
|
@@ -30173,7 +29917,7 @@ function checkCommand(node, script, cwd2) {
|
|
|
30173
29917
|
const targetsRoot = args.some((arg) => {
|
|
30174
29918
|
if (arg.startsWith("-") || arg.startsWith("$")) return false;
|
|
30175
29919
|
try {
|
|
30176
|
-
const absPath =
|
|
29920
|
+
const absPath = resolve9(cwd2, arg).replace(/\\/g, "/");
|
|
30177
29921
|
return absPath === "/" || /^[a-z]:\/?$/i.test(absPath);
|
|
30178
29922
|
} catch {
|
|
30179
29923
|
return arg === "/" || /^[a-z]:\/?$/i.test(arg);
|
|
@@ -30281,7 +30025,7 @@ var BashTool = {
|
|
|
30281
30025
|
async validateInput({ command: command4, timeout, dangerouslyDisableSandbox, cwd: cwd2 }, context) {
|
|
30282
30026
|
const trimmed = command4.trim();
|
|
30283
30027
|
try {
|
|
30284
|
-
await validateSafety(trimmed, cwd2 ?
|
|
30028
|
+
await validateSafety(trimmed, cwd2 ? resolve10(getCwd(), cwd2) : getCwd());
|
|
30285
30029
|
} catch (e) {
|
|
30286
30030
|
return {
|
|
30287
30031
|
result: false,
|
|
@@ -30321,7 +30065,7 @@ var BashTool = {
|
|
|
30321
30065
|
};
|
|
30322
30066
|
}
|
|
30323
30067
|
if (cwd2) {
|
|
30324
|
-
const fullTargetDir =
|
|
30068
|
+
const fullTargetDir = isAbsolute9(cwd2) ? cwd2 : resolve10(getCwd(), cwd2);
|
|
30325
30069
|
if (!isInDirectory(
|
|
30326
30070
|
relative13(getOriginalCwd(), fullTargetDir),
|
|
30327
30071
|
relative13(getCwd(), getOriginalCwd())
|
|
@@ -30341,7 +30085,7 @@ var BashTool = {
|
|
|
30341
30085
|
continue;
|
|
30342
30086
|
}
|
|
30343
30087
|
const targetDir = parts[1].replace(/^['"]|['"]$/g, "");
|
|
30344
|
-
const fullTargetDir =
|
|
30088
|
+
const fullTargetDir = isAbsolute9(targetDir) ? targetDir : resolve10(getCwd(), targetDir);
|
|
30345
30089
|
if (!isInDirectory(
|
|
30346
30090
|
relative13(getOriginalCwd(), fullTargetDir),
|
|
30347
30091
|
relative13(getCwd(), getOriginalCwd())
|
|
@@ -30395,13 +30139,39 @@ var BashTool = {
|
|
|
30395
30139
|
stderr,
|
|
30396
30140
|
bashId,
|
|
30397
30141
|
backgroundTaskId
|
|
30398
|
-
}) {
|
|
30142
|
+
}, command4) {
|
|
30399
30143
|
let trimmedStdout = stdout;
|
|
30400
30144
|
if (trimmedStdout) {
|
|
30401
30145
|
trimmedStdout = trimmedStdout.replace(/^(\s*\n)+/, "");
|
|
30402
30146
|
trimmedStdout = trimmedStdout.trimEnd();
|
|
30403
30147
|
}
|
|
30148
|
+
const lines = trimmedStdout.split("\n");
|
|
30149
|
+
if (lines.length > 500) {
|
|
30150
|
+
const errorIndex = lines.findIndex((l) => /Error:|Exception:|Failed/i.test(l));
|
|
30151
|
+
if (errorIndex !== -1) {
|
|
30152
|
+
const start = Math.max(0, errorIndex - 20);
|
|
30153
|
+
const end = Math.min(lines.length, errorIndex + 20);
|
|
30154
|
+
const head = lines.slice(0, 20).join("\n");
|
|
30155
|
+
const errorContext = lines.slice(start, end).join("\n");
|
|
30156
|
+
const tail = lines.slice(-20).join("\n");
|
|
30157
|
+
if (start > 20 && end < lines.length - 20) {
|
|
30158
|
+
trimmedStdout = `${head}
|
|
30159
|
+
... [Snip: ${start - 20} lines] ...
|
|
30160
|
+
${errorContext}
|
|
30161
|
+
... [Snip: ${lines.length - end} lines] ...
|
|
30162
|
+
${tail}`;
|
|
30163
|
+
}
|
|
30164
|
+
}
|
|
30165
|
+
}
|
|
30404
30166
|
let trimmedStderr = stderr.trim();
|
|
30167
|
+
if (trimmedStderr.includes("command not found") && command4) {
|
|
30168
|
+
const cmdParts = command4.trim().split(/\s+/);
|
|
30169
|
+
const prog = cmdParts[0];
|
|
30170
|
+
if (prog === "gti") {
|
|
30171
|
+
trimmedStderr += `
|
|
30172
|
+
Did you mean "git ${cmdParts.slice(1).join(" ")}"?`;
|
|
30173
|
+
}
|
|
30174
|
+
}
|
|
30405
30175
|
if (interrupted) {
|
|
30406
30176
|
if (trimmedStderr) trimmedStderr += EOL3;
|
|
30407
30177
|
trimmedStderr += "<error>Command was aborted before completion</error>";
|
|
@@ -30426,7 +30196,7 @@ var BashTool = {
|
|
|
30426
30196
|
const safeMode = Boolean(context?.safeMode ?? context?.options?.safeMode);
|
|
30427
30197
|
const userPrompt = typeof context?.options?.lastUserPrompt === "string" ? context.options.lastUserPrompt.trim() : "";
|
|
30428
30198
|
const commandDescription = typeof description2 === "string" ? description2.trim() : "";
|
|
30429
|
-
const effectiveCwd = cwd2 ?
|
|
30199
|
+
const effectiveCwd = cwd2 ? isAbsolute9(cwd2) ? cwd2 : resolve10(getCwd(), cwd2) : getCwd();
|
|
30430
30200
|
try {
|
|
30431
30201
|
await validateSafety(command4, effectiveCwd);
|
|
30432
30202
|
} catch (error) {
|
|
@@ -30440,7 +30210,7 @@ var BashTool = {
|
|
|
30440
30210
|
};
|
|
30441
30211
|
yield {
|
|
30442
30212
|
type: "result",
|
|
30443
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30213
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30444
30214
|
data
|
|
30445
30215
|
};
|
|
30446
30216
|
return;
|
|
@@ -30462,7 +30232,7 @@ var BashTool = {
|
|
|
30462
30232
|
};
|
|
30463
30233
|
yield {
|
|
30464
30234
|
type: "result",
|
|
30465
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30235
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30466
30236
|
data
|
|
30467
30237
|
};
|
|
30468
30238
|
return;
|
|
@@ -30494,7 +30264,7 @@ var BashTool = {
|
|
|
30494
30264
|
};
|
|
30495
30265
|
yield {
|
|
30496
30266
|
type: "result",
|
|
30497
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30267
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30498
30268
|
data
|
|
30499
30269
|
};
|
|
30500
30270
|
return;
|
|
@@ -30529,7 +30299,7 @@ var BashTool = {
|
|
|
30529
30299
|
};
|
|
30530
30300
|
yield {
|
|
30531
30301
|
type: "result",
|
|
30532
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30302
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30533
30303
|
data
|
|
30534
30304
|
};
|
|
30535
30305
|
return;
|
|
@@ -30576,7 +30346,7 @@ var BashTool = {
|
|
|
30576
30346
|
if (abortController.signal.aborted) return false;
|
|
30577
30347
|
const hostForUrl = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
30578
30348
|
const url2 = `http://${hostForUrl}:${port}/`;
|
|
30579
|
-
return await new Promise((
|
|
30349
|
+
return await new Promise((resolve11) => {
|
|
30580
30350
|
const assistantMessage = createAssistantMessage("");
|
|
30581
30351
|
if (context.messageId) {
|
|
30582
30352
|
;
|
|
@@ -30592,13 +30362,13 @@ var BashTool = {
|
|
|
30592
30362
|
suggestions: void 0,
|
|
30593
30363
|
riskScore: null,
|
|
30594
30364
|
onAbort() {
|
|
30595
|
-
|
|
30365
|
+
resolve11(false);
|
|
30596
30366
|
},
|
|
30597
30367
|
onAllow() {
|
|
30598
|
-
|
|
30368
|
+
resolve11(true);
|
|
30599
30369
|
},
|
|
30600
30370
|
onReject() {
|
|
30601
|
-
|
|
30371
|
+
resolve11(false);
|
|
30602
30372
|
}
|
|
30603
30373
|
};
|
|
30604
30374
|
setToolJSX({
|
|
@@ -30631,7 +30401,7 @@ var BashTool = {
|
|
|
30631
30401
|
};
|
|
30632
30402
|
yield {
|
|
30633
30403
|
type: "result",
|
|
30634
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30404
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30635
30405
|
data
|
|
30636
30406
|
};
|
|
30637
30407
|
return;
|
|
@@ -30657,7 +30427,7 @@ var BashTool = {
|
|
|
30657
30427
|
};
|
|
30658
30428
|
yield {
|
|
30659
30429
|
type: "result",
|
|
30660
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30430
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30661
30431
|
data
|
|
30662
30432
|
};
|
|
30663
30433
|
return;
|
|
@@ -30692,8 +30462,8 @@ var BashTool = {
|
|
|
30692
30462
|
);
|
|
30693
30463
|
let backgroundRequested = false;
|
|
30694
30464
|
let resolveBackground = null;
|
|
30695
|
-
const backgroundPromise = new Promise((
|
|
30696
|
-
resolveBackground =
|
|
30465
|
+
const backgroundPromise = new Promise((resolve11) => {
|
|
30466
|
+
resolveBackground = resolve11;
|
|
30697
30467
|
});
|
|
30698
30468
|
const requestBackground = () => {
|
|
30699
30469
|
if (backgroundRequested) return;
|
|
@@ -30736,7 +30506,7 @@ ${footerParts.join(" ")}`;
|
|
|
30736
30506
|
bashId
|
|
30737
30507
|
})),
|
|
30738
30508
|
new Promise(
|
|
30739
|
-
(
|
|
30509
|
+
(resolve11) => setTimeout(() => resolve11({ kind: "tick" }), waitMs)
|
|
30740
30510
|
)
|
|
30741
30511
|
]);
|
|
30742
30512
|
if (race.kind === "background") {
|
|
@@ -30751,7 +30521,7 @@ ${footerParts.join(" ")}`;
|
|
|
30751
30521
|
};
|
|
30752
30522
|
yield {
|
|
30753
30523
|
type: "result",
|
|
30754
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30524
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30755
30525
|
data
|
|
30756
30526
|
};
|
|
30757
30527
|
return;
|
|
@@ -30770,7 +30540,7 @@ ${footerParts.join(" ")}`;
|
|
|
30770
30540
|
if (process.env.NODE_ENV !== "test") {
|
|
30771
30541
|
getCommandFilePaths(command4, stdout).then((filePaths) => {
|
|
30772
30542
|
for (const filePath of filePaths) {
|
|
30773
|
-
const fullFilePath =
|
|
30543
|
+
const fullFilePath = isAbsolute9(filePath) ? filePath : resolve10(getCwd(), filePath);
|
|
30774
30544
|
try {
|
|
30775
30545
|
readFileTimestamps[fullFilePath] = statSync12(fullFilePath).mtimeMs;
|
|
30776
30546
|
} catch (e) {
|
|
@@ -30790,7 +30560,7 @@ ${footerParts.join(" ")}`;
|
|
|
30790
30560
|
};
|
|
30791
30561
|
yield {
|
|
30792
30562
|
type: "result",
|
|
30793
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30563
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30794
30564
|
data
|
|
30795
30565
|
};
|
|
30796
30566
|
return;
|
|
@@ -30828,7 +30598,7 @@ ${footerParts.join(" ")}`;
|
|
|
30828
30598
|
};
|
|
30829
30599
|
yield {
|
|
30830
30600
|
type: "result",
|
|
30831
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30601
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30832
30602
|
data
|
|
30833
30603
|
};
|
|
30834
30604
|
} finally {
|
|
@@ -30934,8 +30704,14 @@ assistant: src/foo.c
|
|
|
30934
30704
|
</example>
|
|
30935
30705
|
|
|
30936
30706
|
<example>
|
|
30937
|
-
user:
|
|
30938
|
-
assistant: [uses
|
|
30707
|
+
user: change the greeting in hello.ts
|
|
30708
|
+
assistant: [uses Read tool to read hello.ts]
|
|
30709
|
+
[uses Edit tool with the following input]
|
|
30710
|
+
<<<<<<< SEARCH
|
|
30711
|
+
console.log("Hello, world!");
|
|
30712
|
+
=======
|
|
30713
|
+
console.log("Hello, User!");
|
|
30714
|
+
>>>>>>> REPLACE
|
|
30939
30715
|
</example>
|
|
30940
30716
|
`}
|
|
30941
30717
|
|
|
@@ -30978,19 +30754,19 @@ NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTAN
|
|
|
30978
30754
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.
|
|
30979
30755
|
- It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
30980
30756
|
- It is always better to speculatively perform multiple searches as a batch that are potentially useful.
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
1. **Edit Tool**:
|
|
30986
|
-
-
|
|
30987
|
-
-
|
|
30988
|
-
-
|
|
30989
|
-
|
|
30990
|
-
-
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
-
|
|
30757
|
+
|
|
30758
|
+
# File Modification Strategy (The Universal Edit Tool)
|
|
30759
|
+
When you need to modify files, rely on the **Edit Tool** for almost all tasks.
|
|
30760
|
+
|
|
30761
|
+
1. **Edit Tool**: The primary tool for ALL file modifications.
|
|
30762
|
+
- **Format**: Use the **SEARCH/REPLACE Block** format to specify changes. You can provide multiple blocks in one turn.
|
|
30763
|
+
- **Capabilities**: Supports single edits, multiple edits (batching), and structural changes.
|
|
30764
|
+
- **Safety**: Powered by Atomic Verification. If any part of the edit breaks syntax or fails to match, the entire operation is rolled back.
|
|
30765
|
+
- **Resilience**: Uses a 9-layer fuzzy matching engine and LSP anchoring to find code even if line numbers or indentation are slightly off.
|
|
30766
|
+
- **Requirement**: Always READ the file first to get the context.
|
|
30767
|
+
|
|
30768
|
+
2. **Patch Tool**: Use ONLY for massive multi-file refactoring where strict atomicity across files is required.
|
|
30769
|
+
- **Note**: Prefer Edit Tool for 99% of tasks.
|
|
30994
30770
|
|
|
30995
30771
|
# Cognitive Safety & Verification
|
|
30996
30772
|
1. **Modification Check**: Before editing, you MUST verify if the change is already present (e.g. use \`grep\` or \`read\`). Do not rely on your memory or previous turns.
|
|
@@ -31044,14 +30820,6 @@ export {
|
|
|
31044
30820
|
hasWritePermission,
|
|
31045
30821
|
grantReadPermissionForOriginalDir,
|
|
31046
30822
|
NotebookEditTool,
|
|
31047
|
-
LineTrimmedReplacer,
|
|
31048
|
-
WhitespaceNormalizedReplacer,
|
|
31049
|
-
BlockAnchorReplacer,
|
|
31050
|
-
IndentationFlexibleReplacer,
|
|
31051
|
-
EscapeNormalizedReplacer,
|
|
31052
|
-
MultiOccurrenceReplacer,
|
|
31053
|
-
TrimmedBoundaryReplacer,
|
|
31054
|
-
ContextAwareReplacer,
|
|
31055
30823
|
FileEditTool,
|
|
31056
30824
|
ParserRegistry,
|
|
31057
30825
|
loadLanguage,
|