pybao-cli 1.3.62 → 1.3.64
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-G5ROIO54.js +42 -0
- package/dist/{acp-E4ORUUG6.js → acp-5GSH6EXS.js} +35 -33
- package/dist/{acp-E4ORUUG6.js.map → acp-5GSH6EXS.js.map} +1 -1
- package/dist/{agentsValidate-XGPIMBWY.js → agentsValidate-VG3EFPJY.js} +7 -7
- package/dist/{ask-2XSGPUFY.js → ask-NXWU4WXV.js} +29 -29
- package/dist/{autoUpdater-EA3SMTGS.js → autoUpdater-CS37G7JH.js} +3 -3
- package/dist/blockParser-CFQE5IAN.js +54 -0
- package/dist/blockParser-CFQE5IAN.js.map +7 -0
- package/dist/{chunk-U5LLDWEZ.js → chunk-44LIZIG4.js} +1 -1
- package/dist/{chunk-E3F3GF24.js → chunk-564FCO3O.js} +7 -7
- package/dist/{chunk-QZQWZEE4.js → chunk-62BPTM22.js} +1 -1
- package/dist/{chunk-5F7W4RBR.js → chunk-AWF22TQA.js} +1 -1
- package/dist/{chunk-E6J3J4NP.js → chunk-BEYXNT3B.js} +1 -1
- package/dist/{chunk-7T5HJASI.js → chunk-DE45OGV2.js} +3 -3
- package/dist/{chunk-EBT7XQ6S.js → chunk-E7DJCNPH.js} +3 -3
- package/dist/{chunk-HZVVMIKU.js → chunk-F7YUCKEG.js} +3 -3
- package/dist/{chunk-MHYAFWIN.js → chunk-HFVO3U7D.js} +1 -1
- package/dist/{chunk-46POHLME.js → chunk-JKZNJH4H.js} +546 -776
- package/dist/chunk-JKZNJH4H.js.map +7 -0
- package/dist/chunk-K4F43CEG.js +727 -0
- package/dist/chunk-K4F43CEG.js.map +7 -0
- package/dist/{chunk-2MUYWG5A.js → chunk-KGPZOVSK.js} +1 -1
- package/dist/{chunk-2MUYWG5A.js.map → chunk-KGPZOVSK.js.map} +1 -1
- package/dist/{chunk-C5CUCBJ4.js → chunk-L6E3GWAN.js} +2 -2
- package/dist/{chunk-H7QQQG7D.js → chunk-L7SSQIS4.js} +1 -1
- package/dist/{chunk-CAMPL4AN.js → chunk-L7XD2SDM.js} +1 -1
- package/dist/{chunk-755RLUNM.js → chunk-LATRINJL.js} +1 -1
- package/dist/{chunk-AQ2HCXCW.js → chunk-MFIUM74N.js} +1 -1
- package/dist/{chunk-UVD6OLKV.js → chunk-OOOIM522.js} +3 -3
- package/dist/{chunk-DKIGBYKF.js → chunk-PA7H4OQC.js} +2 -2
- package/dist/{chunk-DCROD4XG.js → chunk-QCC7OITN.js} +2 -2
- package/dist/chunk-QONPUH55.js +323 -0
- package/dist/chunk-QONPUH55.js.map +7 -0
- package/dist/{chunk-H6AUMJOJ.js → chunk-RQAITTSX.js} +179 -745
- package/dist/chunk-RQAITTSX.js.map +7 -0
- package/dist/{chunk-M7KNDY5P.js → chunk-T262SVHZ.js} +5 -5
- package/dist/{chunk-NTCRKERM.js → chunk-TQL2DUII.js} +3 -3
- package/dist/{chunk-63M6WU3A.js → chunk-VUS6CHKJ.js} +2 -2
- package/dist/{chunk-THCNHWHQ.js → chunk-WN2XXHNB.js} +2 -2
- package/dist/{chunk-AEWQCACK.js → chunk-XO2GLVQX.js} +4 -4
- package/dist/{chunk-NYK4S5HS.js → chunk-ZD45HTW4.js} +6 -6
- package/dist/{chunk-HZV2KUZV.js → chunk-ZZWMWREU.js} +3 -3
- package/dist/{cli-KPXNIY4B.js → cli-LTMUDVSO.js} +90 -88
- package/dist/{cli-KPXNIY4B.js.map → cli-LTMUDVSO.js.map} +1 -1
- package/dist/commands-OXAWOLWC.js +46 -0
- package/dist/{config-MF6CHCR2.js → config-LPIWUZDG.js} +4 -4
- package/dist/{context-RDXY7XES.js → context-FDY7KASK.js} +5 -5
- package/dist/{customCommands-Y6RHVSCF.js → customCommands-HL4L5XKU.js} +4 -4
- package/dist/{env-FZLSAOGM.js → env-KT3C4PNM.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/{llm-5CCL32VY.js → llm-GFTKKVTZ.js} +36 -36
- package/dist/{llmLazy-FGXF7GIC.js → llmLazy-V5UDMJXT.js} +1 -1
- package/dist/{loader-ZSTIZJIW.js → loader-7ZC2BNNC.js} +4 -4
- package/dist/lspAnchor-XFCCXSQI.js +77 -0
- package/dist/lspAnchor-XFCCXSQI.js.map +7 -0
- package/dist/manager-4UOP4R3A.js +12 -0
- package/dist/{mcp-YFO3QPJ6.js → mcp-L2JIKEWZ.js} +7 -7
- package/dist/{mentionProcessor-EMFPDQOH.js → mentionProcessor-OQ2CKQEI.js} +5 -5
- package/dist/{messages-HCJ6555M.js → messages-XGI3SVGF.js} +1 -1
- package/dist/{model-4LKKMVPC.js → model-X64ICC6T.js} +5 -5
- package/dist/{openai-JZNJGZNU.js → openai-CRIRHSVF.js} +5 -5
- package/dist/{outputStyles-U6B4LWVO.js → outputStyles-6S5IPYOE.js} +4 -4
- package/dist/{pluginRuntime-A2AWM3Q6.js → pluginRuntime-E25X4DF2.js} +6 -6
- package/dist/{pluginValidation-XB3PWUM5.js → pluginValidation-SSVRKP4T.js} +6 -6
- package/dist/prompts-SWS7INIG.js +48 -0
- package/dist/{pybAgentSessionLoad-ZKFVCJPW.js → pybAgentSessionLoad-USXXUZ4J.js} +4 -4
- package/dist/{pybAgentSessionResume-DE4JLCCC.js → pybAgentSessionResume-S7WYGRX4.js} +4 -4
- package/dist/{pybAgentStreamJsonSession-5IYZ5RHL.js → pybAgentStreamJsonSession-4LVBFH43.js} +1 -1
- package/dist/{pybHooks-Z2SZ736X.js → pybHooks-UNH6GUNG.js} +4 -4
- package/dist/query-BM2KFEDF.js +50 -0
- package/dist/{ripgrep-VP646M4W.js → ripgrep-3RK2NAQE.js} +3 -3
- package/dist/{skillMarketplace-WCGQOTNM.js → skillMarketplace-YZZMAWE3.js} +3 -3
- package/dist/smart-edit-J5J4S2TS.js +54 -0
- package/dist/smart-edit-J5J4S2TS.js.map +7 -0
- package/dist/{state-HXU5E4JD.js → state-5VXARPH2.js} +2 -2
- package/dist/{theme-MQCZHWJ2.js → theme-N7F6FII5.js} +5 -5
- package/dist/{toolPermissionSettings-XCDVYB3P.js → toolPermissionSettings-H5276GYI.js} +6 -6
- package/dist/tools-Q5R2XLVA.js +49 -0
- package/dist/tools-Q5R2XLVA.js.map +7 -0
- package/dist/{userInput-JX2UGSWD.js → userInput-VQX2KYRL.js} +32 -32
- package/package.json +1 -1
- package/dist/REPL-I2MV4CLO.js +0 -42
- package/dist/chunk-46POHLME.js.map +0 -7
- package/dist/chunk-H6AUMJOJ.js.map +0 -7
- package/dist/commands-JXQA3F7B.js +0 -46
- package/dist/prompts-SYOCBLKQ.js +0 -48
- package/dist/query-XS3ZVIZL.js +0 -50
- package/dist/tools-BLPOCGYT.js +0 -47
- /package/dist/{REPL-I2MV4CLO.js.map → REPL-G5ROIO54.js.map} +0 -0
- /package/dist/{agentsValidate-XGPIMBWY.js.map → agentsValidate-VG3EFPJY.js.map} +0 -0
- /package/dist/{ask-2XSGPUFY.js.map → ask-NXWU4WXV.js.map} +0 -0
- /package/dist/{autoUpdater-EA3SMTGS.js.map → autoUpdater-CS37G7JH.js.map} +0 -0
- /package/dist/{chunk-U5LLDWEZ.js.map → chunk-44LIZIG4.js.map} +0 -0
- /package/dist/{chunk-E3F3GF24.js.map → chunk-564FCO3O.js.map} +0 -0
- /package/dist/{chunk-QZQWZEE4.js.map → chunk-62BPTM22.js.map} +0 -0
- /package/dist/{chunk-5F7W4RBR.js.map → chunk-AWF22TQA.js.map} +0 -0
- /package/dist/{chunk-E6J3J4NP.js.map → chunk-BEYXNT3B.js.map} +0 -0
- /package/dist/{chunk-7T5HJASI.js.map → chunk-DE45OGV2.js.map} +0 -0
- /package/dist/{chunk-EBT7XQ6S.js.map → chunk-E7DJCNPH.js.map} +0 -0
- /package/dist/{chunk-HZVVMIKU.js.map → chunk-F7YUCKEG.js.map} +0 -0
- /package/dist/{chunk-MHYAFWIN.js.map → chunk-HFVO3U7D.js.map} +0 -0
- /package/dist/{chunk-C5CUCBJ4.js.map → chunk-L6E3GWAN.js.map} +0 -0
- /package/dist/{chunk-H7QQQG7D.js.map → chunk-L7SSQIS4.js.map} +0 -0
- /package/dist/{chunk-CAMPL4AN.js.map → chunk-L7XD2SDM.js.map} +0 -0
- /package/dist/{chunk-755RLUNM.js.map → chunk-LATRINJL.js.map} +0 -0
- /package/dist/{chunk-AQ2HCXCW.js.map → chunk-MFIUM74N.js.map} +0 -0
- /package/dist/{chunk-UVD6OLKV.js.map → chunk-OOOIM522.js.map} +0 -0
- /package/dist/{chunk-DKIGBYKF.js.map → chunk-PA7H4OQC.js.map} +0 -0
- /package/dist/{chunk-DCROD4XG.js.map → chunk-QCC7OITN.js.map} +0 -0
- /package/dist/{chunk-M7KNDY5P.js.map → chunk-T262SVHZ.js.map} +0 -0
- /package/dist/{chunk-NTCRKERM.js.map → chunk-TQL2DUII.js.map} +0 -0
- /package/dist/{chunk-63M6WU3A.js.map → chunk-VUS6CHKJ.js.map} +0 -0
- /package/dist/{chunk-THCNHWHQ.js.map → chunk-WN2XXHNB.js.map} +0 -0
- /package/dist/{chunk-AEWQCACK.js.map → chunk-XO2GLVQX.js.map} +0 -0
- /package/dist/{chunk-NYK4S5HS.js.map → chunk-ZD45HTW4.js.map} +0 -0
- /package/dist/{chunk-HZV2KUZV.js.map → chunk-ZZWMWREU.js.map} +0 -0
- /package/dist/{commands-JXQA3F7B.js.map → commands-OXAWOLWC.js.map} +0 -0
- /package/dist/{config-MF6CHCR2.js.map → config-LPIWUZDG.js.map} +0 -0
- /package/dist/{context-RDXY7XES.js.map → context-FDY7KASK.js.map} +0 -0
- /package/dist/{customCommands-Y6RHVSCF.js.map → customCommands-HL4L5XKU.js.map} +0 -0
- /package/dist/{env-FZLSAOGM.js.map → env-KT3C4PNM.js.map} +0 -0
- /package/dist/{llm-5CCL32VY.js.map → llm-GFTKKVTZ.js.map} +0 -0
- /package/dist/{llmLazy-FGXF7GIC.js.map → llmLazy-V5UDMJXT.js.map} +0 -0
- /package/dist/{loader-ZSTIZJIW.js.map → loader-7ZC2BNNC.js.map} +0 -0
- /package/dist/{mcp-YFO3QPJ6.js.map → manager-4UOP4R3A.js.map} +0 -0
- /package/dist/{messages-HCJ6555M.js.map → mcp-L2JIKEWZ.js.map} +0 -0
- /package/dist/{mentionProcessor-EMFPDQOH.js.map → mentionProcessor-OQ2CKQEI.js.map} +0 -0
- /package/dist/{model-4LKKMVPC.js.map → messages-XGI3SVGF.js.map} +0 -0
- /package/dist/{openai-JZNJGZNU.js.map → model-X64ICC6T.js.map} +0 -0
- /package/dist/{outputStyles-U6B4LWVO.js.map → openai-CRIRHSVF.js.map} +0 -0
- /package/dist/{pluginValidation-XB3PWUM5.js.map → outputStyles-6S5IPYOE.js.map} +0 -0
- /package/dist/{pluginRuntime-A2AWM3Q6.js.map → pluginRuntime-E25X4DF2.js.map} +0 -0
- /package/dist/{prompts-SYOCBLKQ.js.map → pluginValidation-SSVRKP4T.js.map} +0 -0
- /package/dist/{pybAgentSessionLoad-ZKFVCJPW.js.map → prompts-SWS7INIG.js.map} +0 -0
- /package/dist/{pybAgentSessionResume-DE4JLCCC.js.map → pybAgentSessionLoad-USXXUZ4J.js.map} +0 -0
- /package/dist/{pybHooks-Z2SZ736X.js.map → pybAgentSessionResume-S7WYGRX4.js.map} +0 -0
- /package/dist/{pybAgentStreamJsonSession-5IYZ5RHL.js.map → pybAgentStreamJsonSession-4LVBFH43.js.map} +0 -0
- /package/dist/{query-XS3ZVIZL.js.map → pybHooks-UNH6GUNG.js.map} +0 -0
- /package/dist/{ripgrep-VP646M4W.js.map → query-BM2KFEDF.js.map} +0 -0
- /package/dist/{skillMarketplace-WCGQOTNM.js.map → ripgrep-3RK2NAQE.js.map} +0 -0
- /package/dist/{state-HXU5E4JD.js.map → skillMarketplace-YZZMAWE3.js.map} +0 -0
- /package/dist/{theme-MQCZHWJ2.js.map → state-5VXARPH2.js.map} +0 -0
- /package/dist/{toolPermissionSettings-XCDVYB3P.js.map → theme-N7F6FII5.js.map} +0 -0
- /package/dist/{tools-BLPOCGYT.js.map → toolPermissionSettings-H5276GYI.js.map} +0 -0
- /package/dist/{userInput-JX2UGSWD.js.map → userInput-VQX2KYRL.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-L7SSQIS4.js";
|
|
3
6
|
import {
|
|
4
7
|
listPybAgentSessions
|
|
5
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-62BPTM22.js";
|
|
9
|
+
import {
|
|
10
|
+
appendSessionCustomTitleRecord,
|
|
11
|
+
appendSessionJsonlFromMessage,
|
|
12
|
+
appendSessionTagRecord
|
|
13
|
+
} from "./chunk-QCC7OITN.js";
|
|
14
|
+
import {
|
|
15
|
+
fetchCustomModels,
|
|
16
|
+
getModelFeatures
|
|
17
|
+
} from "./chunk-PA7H4OQC.js";
|
|
18
|
+
import {
|
|
19
|
+
queryLLM,
|
|
20
|
+
queryQuick,
|
|
21
|
+
verifyApiKey
|
|
22
|
+
} from "./chunk-XO2GLVQX.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-564FCO3O.js";
|
|
20
37
|
import {
|
|
21
38
|
formatValidationResult,
|
|
22
39
|
validatePluginOrMarketplacePath
|
|
23
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-E7DJCNPH.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-AWF22TQA.js";
|
|
37
54
|
import {
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
emitReminderEvent,
|
|
56
|
+
generateSystemReminders,
|
|
57
|
+
getAgentFilePath,
|
|
58
|
+
getTodos,
|
|
59
|
+
resetReminderSession,
|
|
60
|
+
setTodos,
|
|
61
|
+
systemReminderService
|
|
62
|
+
} from "./chunk-WN2XXHNB.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-VUS6CHKJ.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-LATRINJL.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-T262SVHZ.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-DKIGBYKF.js";
|
|
79
|
-
import {
|
|
80
|
-
queryLLM,
|
|
81
|
-
queryQuick,
|
|
82
|
-
verifyApiKey
|
|
83
|
-
} from "./chunk-AEWQCACK.js";
|
|
131
|
+
} from "./chunk-ZD45HTW4.js";
|
|
84
132
|
import {
|
|
85
133
|
listAllContentFiles,
|
|
86
134
|
ripGrep,
|
|
87
135
|
tree
|
|
88
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-HFVO3U7D.js";
|
|
89
137
|
import {
|
|
90
138
|
getCustomCommandDirectories,
|
|
91
139
|
hasCustomCommands,
|
|
92
140
|
loadCustomCommands,
|
|
93
141
|
reloadCustomCommands
|
|
94
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-L6E3GWAN.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-OOOIM522.js";
|
|
99
150
|
import {
|
|
100
151
|
getSettingsFileCandidates,
|
|
101
152
|
loadSettingsWithLegacyFallback
|
|
102
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-L7XD2SDM.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-THCNHWHQ.js";
|
|
116
|
-
import {
|
|
117
|
-
getSessionState
|
|
118
|
-
} from "./chunk-ERMQRV55.js";
|
|
119
|
-
import {
|
|
120
|
-
clearAgentCache,
|
|
121
|
-
getActiveAgents,
|
|
122
|
-
getAgentByType,
|
|
123
|
-
getAllAgents
|
|
124
|
-
} from "./chunk-63M6WU3A.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-755RLUNM.js";
|
|
158
158
|
import {
|
|
159
159
|
ModelManager,
|
|
160
160
|
getModelManager,
|
|
161
161
|
isDefaultSlowAndCapableModel
|
|
162
|
-
} from "./chunk-
|
|
162
|
+
} from "./chunk-F7YUCKEG.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-TQL2DUII.js";
|
|
170
170
|
import {
|
|
171
171
|
getTheme
|
|
172
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-44LIZIG4.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-ZZWMWREU.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-BEYXNT3B.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-MFIUM74N.js";
|
|
231
231
|
import {
|
|
232
232
|
MACRO
|
|
233
|
-
} from "./chunk-
|
|
233
|
+
} from "./chunk-KGPZOVSK.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-GFTKKVTZ.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-GFTKKVTZ.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,51 +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
|
-
|
|
6515
|
-
|
|
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.
|
|
6516
6518
|
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
function getPatch({
|
|
6523
|
-
filePath,
|
|
6524
|
-
fileContents,
|
|
6525
|
-
oldStr,
|
|
6526
|
-
newStr
|
|
6527
|
-
}) {
|
|
6528
|
-
return structuredPatch(
|
|
6529
|
-
filePath,
|
|
6530
|
-
filePath,
|
|
6531
|
-
fileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6532
|
-
fileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN).replace(
|
|
6533
|
-
oldStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6534
|
-
newStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN)
|
|
6535
|
-
),
|
|
6536
|
-
void 0,
|
|
6537
|
-
void 0,
|
|
6538
|
-
{ context: CONTEXT_LINES }
|
|
6539
|
-
).hunks.map((_) => ({
|
|
6540
|
-
..._,
|
|
6541
|
-
lines: _.lines.map(
|
|
6542
|
-
(_2) => _2.replaceAll(AMPERSAND_TOKEN, "&").replaceAll(DOLLAR_TOKEN, "$")
|
|
6543
|
-
)
|
|
6544
|
-
}));
|
|
6545
|
-
}
|
|
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();
|
|
6546
6524
|
|
|
6547
6525
|
// src/utils/terminal/paste.ts
|
|
6548
6526
|
function normalizeLineEndings(text) {
|
|
@@ -6572,396 +6550,49 @@ function shouldAggregatePasteChunk(input, hasPendingTimeout) {
|
|
|
6572
6550
|
return false;
|
|
6573
6551
|
}
|
|
6574
6552
|
|
|
6575
|
-
// src/utils/text/
|
|
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
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
const originalTrimmed = originalLines[i + j].trim();
|
|
6607
|
-
const searchTrimmed = searchLines[j].trim();
|
|
6608
|
-
if (originalTrimmed !== searchTrimmed) {
|
|
6609
|
-
matches = false;
|
|
6610
|
-
break;
|
|
6611
|
-
}
|
|
6612
|
-
}
|
|
6613
|
-
if (matches) {
|
|
6614
|
-
let matchStartIndex = 0;
|
|
6615
|
-
for (let k = 0; k < i; k++) {
|
|
6616
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
6617
|
-
}
|
|
6618
|
-
let matchEndIndex = matchStartIndex;
|
|
6619
|
-
for (let k = 0; k < searchLines.length; k++) {
|
|
6620
|
-
matchEndIndex += originalLines[i + k].length;
|
|
6621
|
-
if (k < searchLines.length - 1) {
|
|
6622
|
-
matchEndIndex += 1;
|
|
6623
|
-
}
|
|
6624
|
-
}
|
|
6625
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
6626
|
-
}
|
|
6627
|
-
}
|
|
6628
|
-
};
|
|
6629
|
-
var SINGLE_CANDIDATE_SIMILARITY_THRESHOLD = 0;
|
|
6630
|
-
var MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD = 0.3;
|
|
6631
|
-
var WhitespaceNormalizedReplacer = function* (content, find) {
|
|
6632
|
-
const tokens = find.split(/\s+/).filter((t) => t.length > 0);
|
|
6633
|
-
if (tokens.length === 0) return;
|
|
6634
|
-
const pattern = tokens.map((token) => token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+");
|
|
6635
|
-
try {
|
|
6636
|
-
const regex = new RegExp(pattern, "g");
|
|
6637
|
-
let match;
|
|
6638
|
-
while ((match = regex.exec(content)) !== null) {
|
|
6639
|
-
yield match[0];
|
|
6640
|
-
}
|
|
6641
|
-
} catch (e) {
|
|
6642
|
-
}
|
|
6643
|
-
};
|
|
6644
|
-
var BlockAnchorReplacer = function* (content, find) {
|
|
6645
|
-
const originalLines = content.split("\n");
|
|
6646
|
-
const searchLines = find.split("\n");
|
|
6647
|
-
if (searchLines.length < 3) {
|
|
6648
|
-
return;
|
|
6649
|
-
}
|
|
6650
|
-
if (searchLines[searchLines.length - 1] === "") {
|
|
6651
|
-
searchLines.pop();
|
|
6652
|
-
}
|
|
6653
|
-
const firstLineSearch = searchLines[0].trim();
|
|
6654
|
-
const lastLineSearch = searchLines[searchLines.length - 1].trim();
|
|
6655
|
-
const searchBlockSize = searchLines.length;
|
|
6656
|
-
const candidates = [];
|
|
6657
|
-
for (let i = 0; i < originalLines.length; i++) {
|
|
6658
|
-
if (originalLines[i].trim() !== firstLineSearch) {
|
|
6659
|
-
continue;
|
|
6660
|
-
}
|
|
6661
|
-
for (let j = i + 2; j < originalLines.length; j++) {
|
|
6662
|
-
if (originalLines[j].trim() === lastLineSearch) {
|
|
6663
|
-
candidates.push({ startLine: i, endLine: j });
|
|
6664
|
-
break;
|
|
6665
|
-
}
|
|
6666
|
-
}
|
|
6667
|
-
}
|
|
6668
|
-
if (candidates.length === 0) {
|
|
6669
|
-
return;
|
|
6670
|
-
}
|
|
6671
|
-
if (candidates.length === 1) {
|
|
6672
|
-
const { startLine, endLine } = candidates[0];
|
|
6673
|
-
const actualBlockSize = endLine - startLine + 1;
|
|
6674
|
-
let similarity = 0;
|
|
6675
|
-
let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2);
|
|
6676
|
-
if (linesToCheck > 0) {
|
|
6677
|
-
for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
|
|
6678
|
-
const originalLine = originalLines[startLine + j].trim();
|
|
6679
|
-
const searchLine = searchLines[j].trim();
|
|
6680
|
-
const maxLen = Math.max(originalLine.length, searchLine.length);
|
|
6681
|
-
if (maxLen === 0) {
|
|
6682
|
-
continue;
|
|
6683
|
-
}
|
|
6684
|
-
const distance = levenshtein(originalLine, searchLine);
|
|
6685
|
-
similarity += (1 - distance / maxLen) / linesToCheck;
|
|
6686
|
-
if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
|
|
6687
|
-
break;
|
|
6688
|
-
}
|
|
6689
|
-
}
|
|
6690
|
-
} else {
|
|
6691
|
-
similarity = 1;
|
|
6692
|
-
}
|
|
6693
|
-
if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
|
|
6694
|
-
let matchStartIndex = 0;
|
|
6695
|
-
for (let k = 0; k < startLine; k++) {
|
|
6696
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
6697
|
-
}
|
|
6698
|
-
let matchEndIndex = matchStartIndex;
|
|
6699
|
-
for (let k = startLine; k <= endLine; k++) {
|
|
6700
|
-
matchEndIndex += originalLines[k].length;
|
|
6701
|
-
if (k < endLine) {
|
|
6702
|
-
matchEndIndex += 1;
|
|
6703
|
-
}
|
|
6704
|
-
}
|
|
6705
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
6706
|
-
}
|
|
6707
|
-
return;
|
|
6708
|
-
}
|
|
6709
|
-
let bestMatch = null;
|
|
6710
|
-
let maxSimilarity = -1;
|
|
6711
|
-
for (const candidate of candidates) {
|
|
6712
|
-
const { startLine, endLine } = candidate;
|
|
6713
|
-
const actualBlockSize = endLine - startLine + 1;
|
|
6714
|
-
let similarity = 0;
|
|
6715
|
-
let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2);
|
|
6716
|
-
if (linesToCheck > 0) {
|
|
6717
|
-
for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
|
|
6718
|
-
const originalLine = originalLines[startLine + j].trim();
|
|
6719
|
-
const searchLine = searchLines[j].trim();
|
|
6720
|
-
const maxLen = Math.max(originalLine.length, searchLine.length);
|
|
6721
|
-
if (maxLen === 0) {
|
|
6722
|
-
continue;
|
|
6723
|
-
}
|
|
6724
|
-
const distance = levenshtein(originalLine, searchLine);
|
|
6725
|
-
similarity += 1 - distance / maxLen;
|
|
6726
|
-
}
|
|
6727
|
-
similarity /= linesToCheck;
|
|
6728
|
-
} else {
|
|
6729
|
-
similarity = 1;
|
|
6730
|
-
}
|
|
6731
|
-
if (similarity > maxSimilarity) {
|
|
6732
|
-
maxSimilarity = similarity;
|
|
6733
|
-
bestMatch = candidate;
|
|
6734
|
-
}
|
|
6735
|
-
}
|
|
6736
|
-
if (maxSimilarity >= MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD && bestMatch) {
|
|
6737
|
-
const { startLine, endLine } = bestMatch;
|
|
6738
|
-
let matchStartIndex = 0;
|
|
6739
|
-
for (let k = 0; k < startLine; k++) {
|
|
6740
|
-
matchStartIndex += originalLines[k].length + 1;
|
|
6741
|
-
}
|
|
6742
|
-
let matchEndIndex = matchStartIndex;
|
|
6743
|
-
for (let k = startLine; k <= endLine; k++) {
|
|
6744
|
-
matchEndIndex += originalLines[k].length;
|
|
6745
|
-
if (k < endLine) {
|
|
6746
|
-
matchEndIndex += 1;
|
|
6747
|
-
}
|
|
6748
|
-
}
|
|
6749
|
-
yield content.substring(matchStartIndex, matchEndIndex);
|
|
6750
|
-
}
|
|
6751
|
-
};
|
|
6752
|
-
var IndentationFlexibleReplacer = function* (content, find) {
|
|
6753
|
-
const removeIndentation = (text) => {
|
|
6754
|
-
const lines = text.split("\n");
|
|
6755
|
-
const nonEmptyLines = lines.filter((line) => line.trim().length > 0);
|
|
6756
|
-
if (nonEmptyLines.length === 0) return text;
|
|
6757
|
-
const minIndent = Math.min(
|
|
6758
|
-
...nonEmptyLines.map((line) => {
|
|
6759
|
-
const match = line.match(/^(\s*)/);
|
|
6760
|
-
return match ? match[1].length : 0;
|
|
6761
|
-
})
|
|
6762
|
-
);
|
|
6763
|
-
return lines.map((line) => line.trim().length === 0 ? line : line.slice(minIndent)).join("\n");
|
|
6764
|
-
};
|
|
6765
|
-
const normalizedFind = removeIndentation(find);
|
|
6766
|
-
const contentLines = content.split("\n");
|
|
6767
|
-
const findLines = find.split("\n");
|
|
6768
|
-
for (let i = 0; i <= contentLines.length - findLines.length; i++) {
|
|
6769
|
-
const block = contentLines.slice(i, i + findLines.length).join("\n");
|
|
6770
|
-
if (removeIndentation(block) === normalizedFind) {
|
|
6771
|
-
yield block;
|
|
6772
|
-
}
|
|
6773
|
-
}
|
|
6774
|
-
};
|
|
6775
|
-
var EscapeNormalizedReplacer = function* (content, find) {
|
|
6776
|
-
const unescapeString = (str) => {
|
|
6777
|
-
return str.replace(/\\(n|t|r|'|"|`|\\|\n|\$)/g, (match, capturedChar) => {
|
|
6778
|
-
switch (capturedChar) {
|
|
6779
|
-
case "n":
|
|
6780
|
-
return "\n";
|
|
6781
|
-
case "t":
|
|
6782
|
-
return " ";
|
|
6783
|
-
case "r":
|
|
6784
|
-
return "\r";
|
|
6785
|
-
case "'":
|
|
6786
|
-
return "'";
|
|
6787
|
-
case '"':
|
|
6788
|
-
return '"';
|
|
6789
|
-
case "`":
|
|
6790
|
-
return "`";
|
|
6791
|
-
case "\\":
|
|
6792
|
-
return "\\";
|
|
6793
|
-
case "\n":
|
|
6794
|
-
return "\n";
|
|
6795
|
-
case "$":
|
|
6796
|
-
return "$";
|
|
6797
|
-
default:
|
|
6798
|
-
return match;
|
|
6799
|
-
}
|
|
6800
|
-
});
|
|
6801
|
-
};
|
|
6802
|
-
const unescapedFind = unescapeString(find);
|
|
6803
|
-
if (content.includes(unescapedFind)) {
|
|
6804
|
-
yield unescapedFind;
|
|
6805
|
-
}
|
|
6806
|
-
const lines = content.split("\n");
|
|
6807
|
-
const findLines = unescapedFind.split("\n");
|
|
6808
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
6809
|
-
const block = lines.slice(i, i + findLines.length).join("\n");
|
|
6810
|
-
const unescapedBlock = unescapeString(block);
|
|
6811
|
-
if (unescapedBlock === unescapedFind) {
|
|
6812
|
-
yield block;
|
|
6813
|
-
}
|
|
6814
|
-
}
|
|
6815
|
-
};
|
|
6816
|
-
var MultiOccurrenceReplacer = function* (content, find) {
|
|
6817
|
-
let startIndex = 0;
|
|
6818
|
-
while (true) {
|
|
6819
|
-
const index = content.indexOf(find, startIndex);
|
|
6820
|
-
if (index === -1) break;
|
|
6821
|
-
yield find;
|
|
6822
|
-
startIndex = index + find.length;
|
|
6823
|
-
}
|
|
6824
|
-
};
|
|
6825
|
-
var TrimmedBoundaryReplacer = function* (content, find) {
|
|
6826
|
-
const trimmedFind = find.trim();
|
|
6827
|
-
if (trimmedFind === find) {
|
|
6828
|
-
return;
|
|
6829
|
-
}
|
|
6830
|
-
if (content.includes(trimmedFind)) {
|
|
6831
|
-
yield trimmedFind;
|
|
6832
|
-
}
|
|
6833
|
-
const lines = content.split("\n");
|
|
6834
|
-
const findLines = find.split("\n");
|
|
6835
|
-
for (let i = 0; i <= lines.length - findLines.length; i++) {
|
|
6836
|
-
const block = lines.slice(i, i + findLines.length).join("\n");
|
|
6837
|
-
if (block.trim() === trimmedFind) {
|
|
6838
|
-
yield block;
|
|
6839
|
-
}
|
|
6840
|
-
}
|
|
6841
|
-
};
|
|
6842
|
-
var ContextAwareReplacer = function* (content, find) {
|
|
6843
|
-
const findLines = find.split("\n");
|
|
6844
|
-
if (findLines.length < 3) {
|
|
6845
|
-
return;
|
|
6846
|
-
}
|
|
6847
|
-
if (findLines[findLines.length - 1] === "") {
|
|
6848
|
-
findLines.pop();
|
|
6849
|
-
}
|
|
6850
|
-
const contentLines = content.split("\n");
|
|
6851
|
-
const firstLine = findLines[0].trim();
|
|
6852
|
-
const lastLine = findLines[findLines.length - 1].trim();
|
|
6853
|
-
for (let i = 0; i < contentLines.length; i++) {
|
|
6854
|
-
if (contentLines[i].trim() !== firstLine) continue;
|
|
6855
|
-
for (let j = i + 2; j < contentLines.length; j++) {
|
|
6856
|
-
if (contentLines[j].trim() === lastLine) {
|
|
6857
|
-
const blockLines = contentLines.slice(i, j + 1);
|
|
6858
|
-
const block = blockLines.join("\n");
|
|
6859
|
-
if (blockLines.length === findLines.length) {
|
|
6860
|
-
let matchingLines = 0;
|
|
6861
|
-
let totalNonEmptyLines = 0;
|
|
6862
|
-
for (let k = 1; k < blockLines.length - 1; k++) {
|
|
6863
|
-
const blockLine = blockLines[k].trim();
|
|
6864
|
-
const findLine = findLines[k].trim();
|
|
6865
|
-
if (blockLine.length > 0 || findLine.length > 0) {
|
|
6866
|
-
totalNonEmptyLines++;
|
|
6867
|
-
if (blockLine === findLine) {
|
|
6868
|
-
matchingLines++;
|
|
6869
|
-
}
|
|
6870
|
-
}
|
|
6871
|
-
}
|
|
6872
|
-
if (totalNonEmptyLines === 0 || matchingLines / totalNonEmptyLines >= 0.5) {
|
|
6873
|
-
yield block;
|
|
6874
|
-
break;
|
|
6875
|
-
}
|
|
6876
|
-
}
|
|
6877
|
-
break;
|
|
6878
|
-
}
|
|
6879
|
-
}
|
|
6880
|
-
}
|
|
6881
|
-
};
|
|
6882
|
-
|
|
6883
|
-
// src/utils/text/smart-edit/index.ts
|
|
6884
|
-
var SmartEdit = {
|
|
6885
|
-
levenshtein,
|
|
6886
|
-
replace: (content, oldString, newString, replaceAll = false) => {
|
|
6887
|
-
if (oldString === newString) {
|
|
6888
|
-
throw new Error("oldString and newString must be different");
|
|
6889
|
-
}
|
|
6890
|
-
let notFound = true;
|
|
6891
|
-
for (const replacer of [
|
|
6892
|
-
SimpleReplacer,
|
|
6893
|
-
LineTrimmedReplacer,
|
|
6894
|
-
BlockAnchorReplacer,
|
|
6895
|
-
WhitespaceNormalizedReplacer,
|
|
6896
|
-
IndentationFlexibleReplacer,
|
|
6897
|
-
EscapeNormalizedReplacer,
|
|
6898
|
-
TrimmedBoundaryReplacer,
|
|
6899
|
-
ContextAwareReplacer,
|
|
6900
|
-
MultiOccurrenceReplacer
|
|
6901
|
-
]) {
|
|
6902
|
-
for (const search of replacer(content, oldString)) {
|
|
6903
|
-
const index = content.indexOf(search);
|
|
6904
|
-
if (index === -1) continue;
|
|
6905
|
-
notFound = false;
|
|
6906
|
-
if (replaceAll) {
|
|
6907
|
-
return content.replaceAll(search, newString);
|
|
6908
|
-
}
|
|
6909
|
-
return content.substring(0, index) + newString + content.substring(index + search.length);
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
if (notFound) {
|
|
6913
|
-
throw new Error("oldString not found in content");
|
|
6914
|
-
}
|
|
6915
|
-
return content;
|
|
6916
|
-
}
|
|
6917
|
-
};
|
|
6918
|
-
|
|
6919
|
-
// src/tools/filesystem/FileEditTool/utils.ts
|
|
6920
|
-
async function applyEdit(file_path, old_string, new_string, replace_all = false) {
|
|
6921
|
-
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
6922
|
-
let originalFile;
|
|
6923
|
-
let updatedFile;
|
|
6924
|
-
if (old_string === "") {
|
|
6925
|
-
originalFile = "";
|
|
6926
|
-
updatedFile = normalizeLineEndings(new_string);
|
|
6927
|
-
} else {
|
|
6928
|
-
const fileContent = await readFileBun(fullFilePath);
|
|
6929
|
-
if (!fileContent) {
|
|
6930
|
-
throw new Error("Could not read file");
|
|
6931
|
-
}
|
|
6932
|
-
originalFile = normalizeLineEndings(fileContent);
|
|
6933
|
-
const normalizedOldString = normalizeLineEndings(old_string);
|
|
6934
|
-
const normalizedNewString = normalizeLineEndings(new_string);
|
|
6935
|
-
const oldStringForReplace = normalizedNewString === "" && !normalizedOldString.endsWith("\n") && originalFile.includes(normalizedOldString + "\n") ? normalizedOldString + "\n" : normalizedOldString;
|
|
6936
|
-
updatedFile = SmartEdit.replace(originalFile, oldStringForReplace, normalizedNewString, replace_all);
|
|
6937
|
-
if (updatedFile === originalFile) {
|
|
6938
|
-
throw new Error(
|
|
6939
|
-
"Original and edited file match exactly. Failed to apply edit."
|
|
6940
|
-
);
|
|
6941
|
-
}
|
|
6942
|
-
}
|
|
6943
|
-
const patch = getPatch({
|
|
6944
|
-
filePath: file_path,
|
|
6945
|
-
fileContents: originalFile,
|
|
6946
|
-
oldStr: originalFile,
|
|
6947
|
-
newStr: updatedFile
|
|
6948
|
-
});
|
|
6949
|
-
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
|
+
const safeFileContents = fileContents || "";
|
|
6565
|
+
const safeOldStr = oldStr || "";
|
|
6566
|
+
const safeNewStr = newStr || "";
|
|
6567
|
+
return structuredPatch(
|
|
6568
|
+
filePath,
|
|
6569
|
+
filePath,
|
|
6570
|
+
safeFileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6571
|
+
safeFileContents.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN).replace(
|
|
6572
|
+
safeOldStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN),
|
|
6573
|
+
safeNewStr.replaceAll("&", AMPERSAND_TOKEN).replaceAll("$", DOLLAR_TOKEN)
|
|
6574
|
+
),
|
|
6575
|
+
void 0,
|
|
6576
|
+
void 0,
|
|
6577
|
+
{ context: CONTEXT_LINES }
|
|
6578
|
+
).hunks.map((_) => ({
|
|
6579
|
+
..._,
|
|
6580
|
+
lines: _.lines.map(
|
|
6581
|
+
(_2) => _2.replaceAll(AMPERSAND_TOKEN, "&").replaceAll(DOLLAR_TOKEN, "$")
|
|
6582
|
+
)
|
|
6583
|
+
}));
|
|
6950
6584
|
}
|
|
6951
6585
|
|
|
6952
6586
|
// src/tools/filesystem/FileEditTool/FileEditTool.tsx
|
|
6953
6587
|
var inputSchema3 = z3.strictObject({
|
|
6954
6588
|
file_path: z3.string().describe("The absolute path to the file to modify"),
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
replace_all: z3.boolean().optional().describe("Replace all occurences of old_string (default false)"),
|
|
6958
|
-
if_not_contains: z3.string().optional().describe("If this string is present in the file, the edit will be skipped.")
|
|
6589
|
+
edits: z3.string().describe("The SEARCH/REPLACE blocks defining the changes to be made."),
|
|
6590
|
+
verify: z3.boolean().optional().describe("Verify the edit using LSP diagnostics after application. Defaults to false.")
|
|
6959
6591
|
});
|
|
6960
|
-
var N_LINES_SNIPPET = 4;
|
|
6961
6592
|
var FileEditTool = {
|
|
6962
6593
|
name: "Edit",
|
|
6963
6594
|
async description() {
|
|
6964
|
-
return "A tool for editing files";
|
|
6595
|
+
return "A tool for editing files using SEARCH/REPLACE blocks";
|
|
6965
6596
|
},
|
|
6966
6597
|
async prompt() {
|
|
6967
6598
|
return DESCRIPTION2;
|
|
@@ -6996,78 +6627,33 @@ var FileEditTool = {
|
|
|
6996
6627
|
}
|
|
6997
6628
|
);
|
|
6998
6629
|
},
|
|
6999
|
-
renderToolUseRejectedMessage({ file_path
|
|
6630
|
+
renderToolUseRejectedMessage({ file_path } = {}, { columns, verbose } = {}) {
|
|
7000
6631
|
try {
|
|
7001
6632
|
if (!file_path) {
|
|
7002
6633
|
return /* @__PURE__ */ React12.createElement(FallbackToolUseRejectedMessage, null);
|
|
7003
6634
|
}
|
|
7004
|
-
const fullFilePath =
|
|
7005
|
-
|
|
7006
|
-
let updatedFile = "";
|
|
7007
|
-
if (old_string === "") {
|
|
7008
|
-
originalFile = "";
|
|
7009
|
-
updatedFile = normalizeLineEndings(new_string);
|
|
7010
|
-
} else {
|
|
7011
|
-
const enc = detectFileEncoding(fullFilePath);
|
|
7012
|
-
const fileContent = readFileSync2(fullFilePath, enc);
|
|
7013
|
-
originalFile = normalizeLineEndings(fileContent ?? "");
|
|
7014
|
-
const normalizedOldString = normalizeLineEndings(old_string);
|
|
7015
|
-
const normalizedNewString = normalizeLineEndings(new_string);
|
|
7016
|
-
const oldStringForReplace = normalizedNewString === "" && !normalizedOldString.endsWith("\n") && originalFile.includes(normalizedOldString + "\n") ? normalizedOldString + "\n" : normalizedOldString;
|
|
7017
|
-
updatedFile = Boolean(replace_all) ? originalFile.split(oldStringForReplace).join(normalizedNewString) : originalFile.replace(oldStringForReplace, () => normalizedNewString);
|
|
7018
|
-
if (updatedFile === originalFile) {
|
|
7019
|
-
throw new Error(
|
|
7020
|
-
"Original and edited file match exactly. Failed to apply edit."
|
|
7021
|
-
);
|
|
7022
|
-
}
|
|
7023
|
-
}
|
|
7024
|
-
const patch = getPatch({
|
|
7025
|
-
filePath: file_path,
|
|
7026
|
-
fileContents: originalFile,
|
|
7027
|
-
oldStr: originalFile,
|
|
7028
|
-
newStr: updatedFile
|
|
7029
|
-
});
|
|
7030
|
-
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(
|
|
7031
|
-
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 }))),
|
|
7032
|
-
(i) => /* @__PURE__ */ React12.createElement(Box11, { paddingLeft: 5, key: `ellipsis-${i}` }, /* @__PURE__ */ React12.createElement(Text12, { color: getTheme().secondaryText }, "..."))
|
|
7033
|
-
));
|
|
6635
|
+
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
6636
|
+
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))));
|
|
7034
6637
|
} catch (e) {
|
|
7035
6638
|
logError(e);
|
|
7036
6639
|
return /* @__PURE__ */ React12.createElement(Box11, { flexDirection: "column" }, /* @__PURE__ */ React12.createElement(Text12, null, " ", "\u23BF (No changes)"));
|
|
7037
6640
|
}
|
|
7038
6641
|
},
|
|
7039
|
-
async validateInput({ file_path,
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
7045
|
-
|
|
6642
|
+
async validateInput({ file_path, edits, verify }, { readFileTimestamps }) {
|
|
6643
|
+
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
6644
|
+
if (!fileExistsBun(fullFilePath)) {
|
|
6645
|
+
if (edits && edits.includes("<<<<<<< SEARCH") && edits.includes("=======") && edits.includes(">>>>>>> REPLACE") && edits.indexOf("<<<<<<< SEARCH") > edits.indexOf("=======")) {
|
|
6646
|
+
} else {
|
|
6647
|
+
const similarFilename = findSimilarFile(fullFilePath);
|
|
6648
|
+
let message = "File does not exist.";
|
|
6649
|
+
if (similarFilename) {
|
|
6650
|
+
message += ` Did you mean ${similarFilename}?`;
|
|
7046
6651
|
}
|
|
7047
|
-
};
|
|
7048
|
-
}
|
|
7049
|
-
const fullFilePath = isAbsolute5(file_path) ? file_path : resolve5(getCwd(), file_path);
|
|
7050
|
-
if (old_string === "") {
|
|
7051
|
-
if (!fileExistsBun(fullFilePath)) return { result: true };
|
|
7052
|
-
const existingContent = await readFileBun(fullFilePath);
|
|
7053
|
-
if (normalizeLineEndings(existingContent ?? "").trim() !== "") {
|
|
7054
6652
|
return {
|
|
7055
6653
|
result: false,
|
|
7056
|
-
message
|
|
6654
|
+
message
|
|
7057
6655
|
};
|
|
7058
6656
|
}
|
|
7059
|
-
return { result: true };
|
|
7060
|
-
}
|
|
7061
|
-
if (!fileExistsBun(fullFilePath)) {
|
|
7062
|
-
const similarFilename = findSimilarFile(fullFilePath);
|
|
7063
|
-
let message = "File does not exist.";
|
|
7064
|
-
if (similarFilename) {
|
|
7065
|
-
message += ` Did you mean ${similarFilename}?`;
|
|
7066
|
-
}
|
|
7067
|
-
return {
|
|
7068
|
-
result: false,
|
|
7069
|
-
message
|
|
7070
|
-
};
|
|
7071
6657
|
}
|
|
7072
6658
|
if (fullFilePath.endsWith(".ipynb")) {
|
|
7073
6659
|
return {
|
|
@@ -7075,67 +6661,30 @@ var FileEditTool = {
|
|
|
7075
6661
|
message: `File is a Jupyter Notebook. Use the ${NotebookEditTool.name} to edit this file.`
|
|
7076
6662
|
};
|
|
7077
6663
|
}
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
const normalizedFile = normalizeLineEndings(file ?? "");
|
|
7098
|
-
const normalizedOldString = normalizeLineEndings(old_string);
|
|
7099
|
-
if (!file) {
|
|
7100
|
-
return {
|
|
7101
|
-
result: false,
|
|
7102
|
-
message: "Could not read file.",
|
|
7103
|
-
meta: {
|
|
7104
|
-
isFilePathAbsolute: String(isAbsolute5(file_path))
|
|
7105
|
-
}
|
|
7106
|
-
};
|
|
7107
|
-
}
|
|
7108
|
-
if (if_not_contains && normalizedFile.includes(normalizeLineEndings(if_not_contains))) {
|
|
7109
|
-
return {
|
|
7110
|
-
result: false,
|
|
7111
|
-
message: `Modification skipped: The file already contains the string "${if_not_contains}".`
|
|
7112
|
-
};
|
|
7113
|
-
}
|
|
7114
|
-
if (!normalizedFile.includes(normalizedOldString)) {
|
|
7115
|
-
return {
|
|
7116
|
-
result: false,
|
|
7117
|
-
message: `String to replace not found in file.
|
|
7118
|
-
String: ${old_string}`,
|
|
7119
|
-
meta: {
|
|
7120
|
-
isFilePathAbsolute: String(isAbsolute5(file_path))
|
|
7121
|
-
}
|
|
7122
|
-
};
|
|
7123
|
-
}
|
|
7124
|
-
const matches = normalizedFile.split(normalizedOldString).length - 1;
|
|
7125
|
-
if (matches > 1 && !replace_all) {
|
|
7126
|
-
return {
|
|
7127
|
-
result: false,
|
|
7128
|
-
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.
|
|
7129
|
-
String: ${old_string}`,
|
|
7130
|
-
meta: {
|
|
7131
|
-
isFilePathAbsolute: String(isAbsolute5(file_path))
|
|
7132
|
-
}
|
|
7133
|
-
};
|
|
6664
|
+
if (fileExistsBun(fullFilePath)) {
|
|
6665
|
+
const readTimestamp = readFileTimestamps[fullFilePath];
|
|
6666
|
+
if (!readTimestamp) {
|
|
6667
|
+
return {
|
|
6668
|
+
result: false,
|
|
6669
|
+
message: "File has not been read yet. Read it first before writing to it.",
|
|
6670
|
+
meta: {
|
|
6671
|
+
isFilePathAbsolute: String(isAbsolute4(file_path))
|
|
6672
|
+
}
|
|
6673
|
+
};
|
|
6674
|
+
}
|
|
6675
|
+
const stats = statSync4(fullFilePath);
|
|
6676
|
+
const lastWriteTime = stats.mtimeMs;
|
|
6677
|
+
if (lastWriteTime > readTimestamp) {
|
|
6678
|
+
return {
|
|
6679
|
+
result: false,
|
|
6680
|
+
message: "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it."
|
|
6681
|
+
};
|
|
6682
|
+
}
|
|
7134
6683
|
}
|
|
7135
6684
|
return { result: true };
|
|
7136
6685
|
},
|
|
7137
|
-
async *call({ file_path,
|
|
7138
|
-
const fullFilePath =
|
|
6686
|
+
async *call({ file_path, edits, verify }, { readFileTimestamps }) {
|
|
6687
|
+
const fullFilePath = isAbsolute4(file_path) ? file_path : resolve4(getCwd(), file_path);
|
|
7139
6688
|
if (fileExistsBun(fullFilePath)) {
|
|
7140
6689
|
const readTimestamp = readFileTimestamps[fullFilePath];
|
|
7141
6690
|
const lastWriteTime = statSync4(fullFilePath).mtimeMs;
|
|
@@ -7145,32 +6694,91 @@ String: ${old_string}`,
|
|
|
7145
6694
|
);
|
|
7146
6695
|
}
|
|
7147
6696
|
}
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
);
|
|
6697
|
+
let editOperations = [];
|
|
6698
|
+
if (edits) {
|
|
6699
|
+
const { parseBlockEdits } = await import("./blockParser-CFQE5IAN.js");
|
|
6700
|
+
editOperations = parseBlockEdits(edits);
|
|
6701
|
+
}
|
|
6702
|
+
let currentFileContent = fileExistsBun(fullFilePath) ? normalizeLineEndings(await readFileBun(fullFilePath) ?? "") : "";
|
|
6703
|
+
const originalFileContent = currentFileContent;
|
|
6704
|
+
let totalPatch = [];
|
|
6705
|
+
const { SmartEdit } = await import("./smart-edit-J5J4S2TS.js");
|
|
6706
|
+
const { findLspAnchor } = await import("./lspAnchor-XFCCXSQI.js");
|
|
6707
|
+
for (const op of editOperations) {
|
|
6708
|
+
const normalizedSearch = normalizeLineEndings(op.search);
|
|
6709
|
+
const normalizedReplace = normalizeLineEndings(op.replace);
|
|
6710
|
+
let newContent = "";
|
|
6711
|
+
if (normalizedSearch === "") {
|
|
6712
|
+
newContent = normalizedReplace;
|
|
6713
|
+
} else {
|
|
6714
|
+
newContent = SmartEdit.replace(currentFileContent, normalizedSearch, normalizedReplace, false);
|
|
6715
|
+
if (newContent === currentFileContent) {
|
|
6716
|
+
const anchor = await findLspAnchor(fullFilePath, op.search);
|
|
6717
|
+
if (anchor) {
|
|
6718
|
+
const lines = currentFileContent.split(/\r?\n/);
|
|
6719
|
+
if (anchor.startLine < lines.length) {
|
|
6720
|
+
const endLine = Math.min(anchor.endLine, lines.length - 1);
|
|
6721
|
+
const snippetLines = lines.slice(anchor.startLine, endLine + 1);
|
|
6722
|
+
const snippet = snippetLines.join("\n");
|
|
6723
|
+
try {
|
|
6724
|
+
const newSnippet = SmartEdit.replace(snippet, normalizedSearch, normalizedReplace, false);
|
|
6725
|
+
if (newSnippet !== snippet) {
|
|
6726
|
+
const before = lines.slice(0, anchor.startLine).join("\n");
|
|
6727
|
+
const after = lines.slice(endLine + 1).join("\n");
|
|
6728
|
+
newContent = (before ? before + "\n" : "") + newSnippet + (after ? "\n" + after : "");
|
|
6729
|
+
}
|
|
6730
|
+
} catch (e) {
|
|
6731
|
+
}
|
|
6732
|
+
}
|
|
6733
|
+
}
|
|
6734
|
+
}
|
|
6735
|
+
}
|
|
6736
|
+
if (newContent === currentFileContent && normalizedSearch !== "") {
|
|
6737
|
+
throw new Error(`Could not find match for block:
|
|
6738
|
+
${op.search}`);
|
|
6739
|
+
}
|
|
6740
|
+
currentFileContent = newContent;
|
|
6741
|
+
}
|
|
6742
|
+
const updatedFile = currentFileContent;
|
|
7154
6743
|
const dir = dirname3(fullFilePath);
|
|
7155
6744
|
mkdirSync2(dir, { recursive: true });
|
|
7156
6745
|
const enc = fileExistsBun(fullFilePath) ? detectFileEncoding(fullFilePath) : "utf8";
|
|
7157
6746
|
const endings = fileExistsBun(fullFilePath) ? detectLineEndings(fullFilePath) : "LF";
|
|
7158
|
-
const originalFile = fileExistsBun(fullFilePath) ? normalizeLineEndings(await readFileBun(fullFilePath) ?? "") : "";
|
|
7159
6747
|
writeTextContent(fullFilePath, updatedFile, enc, endings);
|
|
6748
|
+
if (verify) {
|
|
6749
|
+
const { LspClientManager } = await import("./manager-4UOP4R3A.js");
|
|
6750
|
+
const client = await LspClientManager.getInstance().getClient(fullFilePath, getCwd());
|
|
6751
|
+
if (client) {
|
|
6752
|
+
const diagnostics = client.getDiagnostics(fullFilePath);
|
|
6753
|
+
const errors = diagnostics.filter((d) => d.severity === 1);
|
|
6754
|
+
if (errors.length > 0) {
|
|
6755
|
+
writeTextContent(fullFilePath, originalFileContent, enc, endings);
|
|
6756
|
+
throw new Error(`Verification Failed: ${errors.length} syntax errors detected. Reverted changes.
|
|
6757
|
+
First error: ${errors[0].message}`);
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
}
|
|
7160
6761
|
recordFileEdit(fullFilePath, updatedFile);
|
|
7161
6762
|
readFileTimestamps[fullFilePath] = statSync4(fullFilePath).mtimeMs;
|
|
7162
6763
|
emitReminderEvent("file:edited", {
|
|
7163
6764
|
filePath: fullFilePath,
|
|
7164
|
-
oldString:
|
|
7165
|
-
|
|
6765
|
+
oldString: "BLOCK_EDIT",
|
|
6766
|
+
// Simplified
|
|
6767
|
+
newString: "BLOCK_EDIT",
|
|
7166
6768
|
timestamp: Date.now(),
|
|
7167
|
-
operation:
|
|
6769
|
+
operation: "update"
|
|
6770
|
+
});
|
|
6771
|
+
const patch = getPatch({
|
|
6772
|
+
filePath: file_path,
|
|
6773
|
+
fileContents: originalFileContent,
|
|
6774
|
+
oldStr: originalFileContent,
|
|
6775
|
+
newStr: updatedFile
|
|
7168
6776
|
});
|
|
7169
6777
|
const data = {
|
|
7170
6778
|
filePath: file_path,
|
|
7171
|
-
oldString:
|
|
7172
|
-
newString:
|
|
7173
|
-
originalFile,
|
|
6779
|
+
oldString: "MULTIPLE_EDITS",
|
|
6780
|
+
newString: "MULTIPLE_EDITS",
|
|
6781
|
+
originalFile: originalFileContent,
|
|
7174
6782
|
structuredPatch: patch
|
|
7175
6783
|
};
|
|
7176
6784
|
yield {
|
|
@@ -7180,28 +6788,9 @@ String: ${old_string}`,
|
|
|
7180
6788
|
};
|
|
7181
6789
|
},
|
|
7182
6790
|
renderResultForAssistant({ filePath, originalFile, oldString, newString }) {
|
|
7183
|
-
|
|
7184
|
-
normalizeLineEndings(originalFile || ""),
|
|
7185
|
-
normalizeLineEndings(oldString),
|
|
7186
|
-
normalizeLineEndings(newString)
|
|
7187
|
-
);
|
|
7188
|
-
return `The file ${filePath} has been updated. Here's the result of running \`cat -n\` on a snippet of the edited file:
|
|
7189
|
-
${addLineNumbers({
|
|
7190
|
-
content: snippet,
|
|
7191
|
-
startLine
|
|
7192
|
-
})}`;
|
|
6791
|
+
return `The file ${filePath} has been updated successfully.`;
|
|
7193
6792
|
}
|
|
7194
6793
|
};
|
|
7195
|
-
function getSnippet(initialText, oldStr, newStr) {
|
|
7196
|
-
const before = initialText.split(oldStr)[0] ?? "";
|
|
7197
|
-
const replacementLine = before.split(/\r?\n/).length - 1;
|
|
7198
|
-
const newFileLines = initialText.replace(oldStr, newStr).split(/\r?\n/);
|
|
7199
|
-
const startLine = Math.max(0, replacementLine - N_LINES_SNIPPET);
|
|
7200
|
-
const endLine = replacementLine + N_LINES_SNIPPET + newStr.split(/\r?\n/).length;
|
|
7201
|
-
const snippetLines = newFileLines.slice(startLine, endLine + 1);
|
|
7202
|
-
const snippet = snippetLines.join("\n");
|
|
7203
|
-
return { snippet, startLine: startLine + 1 };
|
|
7204
|
-
}
|
|
7205
6794
|
|
|
7206
6795
|
// src/tools/filesystem/FileReadTool/FileReadTool.tsx
|
|
7207
6796
|
import { statSync as statSync6 } from "fs";
|
|
@@ -7249,10 +6838,10 @@ import {
|
|
|
7249
6838
|
import {
|
|
7250
6839
|
dirname as dirname4,
|
|
7251
6840
|
normalize as normalize2,
|
|
7252
|
-
resolve as
|
|
6841
|
+
resolve as resolve5,
|
|
7253
6842
|
extname as extname3,
|
|
7254
6843
|
relative as relative6,
|
|
7255
|
-
isAbsolute as
|
|
6844
|
+
isAbsolute as isAbsolute5
|
|
7256
6845
|
} from "node:path";
|
|
7257
6846
|
import { homedir as homedir5 } from "node:os";
|
|
7258
6847
|
var SecureFileService = class _SecureFileService {
|
|
@@ -7313,14 +6902,14 @@ var SecureFileService = class _SecureFileService {
|
|
|
7313
6902
|
};
|
|
7314
6903
|
}
|
|
7315
6904
|
}
|
|
7316
|
-
const absolutePath =
|
|
6905
|
+
const absolutePath = resolve5(normalizedPath);
|
|
7317
6906
|
const isInAllowedPath = Array.from(this.allowedBasePaths).some(
|
|
7318
6907
|
(basePath) => {
|
|
7319
|
-
const base =
|
|
6908
|
+
const base = resolve5(basePath);
|
|
7320
6909
|
const rel = relative6(base, absolutePath);
|
|
7321
6910
|
if (!rel || rel === "") return true;
|
|
7322
6911
|
if (rel.startsWith("..")) return false;
|
|
7323
|
-
if (
|
|
6912
|
+
if (isAbsolute5(rel)) return false;
|
|
7324
6913
|
return true;
|
|
7325
6914
|
}
|
|
7326
6915
|
);
|
|
@@ -7554,7 +7143,7 @@ var SecureFileService = class _SecureFileService {
|
|
|
7554
7143
|
}
|
|
7555
7144
|
addAllowedBasePath(basePath) {
|
|
7556
7145
|
try {
|
|
7557
|
-
const normalized = normalize2(
|
|
7146
|
+
const normalized = normalize2(resolve5(basePath));
|
|
7558
7147
|
if (!existsSync5(normalized)) {
|
|
7559
7148
|
return { success: false, error: "Base path does not exist" };
|
|
7560
7149
|
}
|
|
@@ -7943,6 +7532,9 @@ var inputSchema4 = z4.strictObject({
|
|
|
7943
7532
|
),
|
|
7944
7533
|
limit: z4.number().optional().describe(
|
|
7945
7534
|
"The number of lines to read. Only provide if the file is too large to read at once."
|
|
7535
|
+
),
|
|
7536
|
+
symbol_name: z4.string().optional().describe(
|
|
7537
|
+
"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."
|
|
7946
7538
|
)
|
|
7947
7539
|
});
|
|
7948
7540
|
var FileReadTool = {
|
|
@@ -7998,7 +7590,7 @@ var FileReadTool = {
|
|
|
7998
7590
|
renderToolUseRejectedMessage() {
|
|
7999
7591
|
return /* @__PURE__ */ React13.createElement(FallbackToolUseRejectedMessage, null);
|
|
8000
7592
|
},
|
|
8001
|
-
async validateInput({ file_path, offset, limit }) {
|
|
7593
|
+
async validateInput({ file_path, offset, limit, symbol_name }) {
|
|
8002
7594
|
const fullFilePath = normalizeFilePath(file_path);
|
|
8003
7595
|
const fileCheck = secureFileService.safeGetFileInfo(fullFilePath);
|
|
8004
7596
|
if (!fileCheck.success) {
|
|
@@ -8039,9 +7631,42 @@ var FileReadTool = {
|
|
|
8039
7631
|
}
|
|
8040
7632
|
return { result: true };
|
|
8041
7633
|
},
|
|
8042
|
-
async *call({ file_path, offset = 1, limit = void 0 }, { readFileTimestamps }) {
|
|
7634
|
+
async *call({ file_path, offset = 1, limit = void 0, symbol_name }, { readFileTimestamps }) {
|
|
8043
7635
|
const ext = path6.extname(file_path).toLowerCase();
|
|
8044
7636
|
const fullFilePath = normalizeFilePath(file_path);
|
|
7637
|
+
let startLine = offset;
|
|
7638
|
+
let finalLimit = limit;
|
|
7639
|
+
if (symbol_name) {
|
|
7640
|
+
try {
|
|
7641
|
+
const { LspClientManager } = await import("./manager-4UOP4R3A.js");
|
|
7642
|
+
const client = await LspClientManager.getInstance().getClient(fullFilePath, getCwd());
|
|
7643
|
+
if (!client) {
|
|
7644
|
+
throw new Error(`LSP client not available for ${ext}. Cannot search for symbol '${symbol_name}'.`);
|
|
7645
|
+
}
|
|
7646
|
+
const symbols = await client.documentSymbol(fullFilePath);
|
|
7647
|
+
if (!symbols || symbols.length === 0) {
|
|
7648
|
+
throw new Error(`No symbols found in file.`);
|
|
7649
|
+
}
|
|
7650
|
+
const findSymbol = (syms) => {
|
|
7651
|
+
for (const sym of syms) {
|
|
7652
|
+
if (sym.name === symbol_name) return sym;
|
|
7653
|
+
if (sym.children) {
|
|
7654
|
+
const found = findSymbol(sym.children);
|
|
7655
|
+
if (found) return found;
|
|
7656
|
+
}
|
|
7657
|
+
}
|
|
7658
|
+
return null;
|
|
7659
|
+
};
|
|
7660
|
+
const symbol = findSymbol(symbols);
|
|
7661
|
+
if (!symbol) {
|
|
7662
|
+
throw new Error(`Symbol '${symbol_name}' not found in file.`);
|
|
7663
|
+
}
|
|
7664
|
+
startLine = symbol.range.start.line + 1;
|
|
7665
|
+
finalLimit = symbol.range.end.line - symbol.range.start.line + 1;
|
|
7666
|
+
} catch (e) {
|
|
7667
|
+
throw new Error(`Symbol reading failed: ${e.message}`);
|
|
7668
|
+
}
|
|
7669
|
+
}
|
|
8045
7670
|
recordFileRead(fullFilePath);
|
|
8046
7671
|
emitReminderEvent("file:read", {
|
|
8047
7672
|
filePath: fullFilePath,
|
|
@@ -8108,10 +7733,8 @@ var FileReadTool = {
|
|
|
8108
7733
|
};
|
|
8109
7734
|
return;
|
|
8110
7735
|
}
|
|
8111
|
-
let startLine = offset;
|
|
8112
7736
|
let zeroBasedOffset = startLine === 0 ? 0 : startLine - 1;
|
|
8113
|
-
|
|
8114
|
-
if (limit) {
|
|
7737
|
+
if (limit && !symbol_name) {
|
|
8115
7738
|
try {
|
|
8116
7739
|
const fullContent = await readFileBun(fullFilePath);
|
|
8117
7740
|
if (fullContent) {
|
|
@@ -8278,7 +7901,7 @@ async function readImage(filePath, ext) {
|
|
|
8278
7901
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync4, statSync as statSync7 } from "fs";
|
|
8279
7902
|
import { Box as Box13, Text as Text14 } from "ink";
|
|
8280
7903
|
import { EOL } from "os";
|
|
8281
|
-
import { dirname as dirname5, extname as extname6, isAbsolute as
|
|
7904
|
+
import { dirname as dirname5, extname as extname6, isAbsolute as isAbsolute6, relative as relative8, resolve as resolve6 } from "path";
|
|
8282
7905
|
import * as React14 from "react";
|
|
8283
7906
|
import { z as z5 } from "zod";
|
|
8284
7907
|
|
|
@@ -8332,7 +7955,7 @@ var FileWriteTool = {
|
|
|
8332
7955
|
if (!file_path) {
|
|
8333
7956
|
return /* @__PURE__ */ React14.createElement(FallbackToolUseRejectedMessage, null);
|
|
8334
7957
|
}
|
|
8335
|
-
const fullFilePath =
|
|
7958
|
+
const fullFilePath = isAbsolute6(file_path) ? file_path : resolve6(getCwd(), file_path);
|
|
8336
7959
|
const oldFileExists = fileExistsBun(fullFilePath);
|
|
8337
7960
|
const enc = oldFileExists ? detectFileEncoding(fullFilePath) : "utf-8";
|
|
8338
7961
|
const oldContent = oldFileExists ? readFileSync4(fullFilePath, enc) : null;
|
|
@@ -8378,7 +8001,7 @@ var FileWriteTool = {
|
|
|
8378
8001
|
}
|
|
8379
8002
|
},
|
|
8380
8003
|
async validateInput({ file_path }, { readFileTimestamps }) {
|
|
8381
|
-
const fullFilePath =
|
|
8004
|
+
const fullFilePath = isAbsolute6(file_path) ? file_path : resolve6(getCwd(), file_path);
|
|
8382
8005
|
if (fullFilePath.endsWith(".ipynb")) {
|
|
8383
8006
|
return {
|
|
8384
8007
|
result: false,
|
|
@@ -8406,7 +8029,7 @@ var FileWriteTool = {
|
|
|
8406
8029
|
return { result: true };
|
|
8407
8030
|
},
|
|
8408
8031
|
async *call({ file_path, content }, { readFileTimestamps }) {
|
|
8409
|
-
const fullFilePath =
|
|
8032
|
+
const fullFilePath = isAbsolute6(file_path) ? file_path : resolve6(getCwd(), file_path);
|
|
8410
8033
|
const dir = dirname5(fullFilePath);
|
|
8411
8034
|
const oldFileExists = fileExistsBun(fullFilePath);
|
|
8412
8035
|
if (oldFileExists) {
|
|
@@ -8496,11 +8119,15 @@ var DESCRIPTION4 = `- Fast file pattern matching tool that works with any codeba
|
|
|
8496
8119
|
|
|
8497
8120
|
// src/tools/filesystem/GlobTool/GlobTool.tsx
|
|
8498
8121
|
import { existsSync as existsSync6, statSync as statSync8 } from "fs";
|
|
8499
|
-
import { isAbsolute as
|
|
8122
|
+
import { isAbsolute as isAbsolute7, join as join5, relative as relative9, resolve as resolve7 } from "path";
|
|
8123
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
8500
8124
|
var inputSchema6 = z6.strictObject({
|
|
8501
8125
|
pattern: z6.string().describe("The glob pattern to match files against"),
|
|
8502
8126
|
path: z6.string().optional().describe(
|
|
8503
8127
|
'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.'
|
|
8128
|
+
),
|
|
8129
|
+
semantic: z6.boolean().optional().describe(
|
|
8130
|
+
"Enable semantic search using LSP workspace symbols to find relevant files. Useful when you know the symbol name but not the file path."
|
|
8504
8131
|
)
|
|
8505
8132
|
});
|
|
8506
8133
|
var DEFAULT_LIMIT = 100;
|
|
@@ -8530,7 +8157,7 @@ var GlobTool = {
|
|
|
8530
8157
|
},
|
|
8531
8158
|
async validateInput({ path: path7 }) {
|
|
8532
8159
|
if (!path7) return { result: true };
|
|
8533
|
-
const absolute =
|
|
8160
|
+
const absolute = isAbsolute7(path7) ? path7 : resolve7(getCwd(), path7);
|
|
8534
8161
|
if (!existsSync6(absolute)) {
|
|
8535
8162
|
return {
|
|
8536
8163
|
result: false,
|
|
@@ -8547,10 +8174,13 @@ var GlobTool = {
|
|
|
8547
8174
|
}
|
|
8548
8175
|
return { result: true };
|
|
8549
8176
|
},
|
|
8550
|
-
renderToolUseMessage({ pattern, path: path7 }, { verbose }) {
|
|
8551
|
-
const absolutePath = path7 ?
|
|
8177
|
+
renderToolUseMessage({ pattern, path: path7, semantic }, { verbose }) {
|
|
8178
|
+
const absolutePath = path7 ? isAbsolute7(path7) ? path7 : resolve7(getCwd(), path7) : void 0;
|
|
8552
8179
|
const relativePath = absolutePath ? relative9(getCwd(), absolutePath) : void 0;
|
|
8553
|
-
|
|
8180
|
+
const parts = [`pattern: "${pattern}"`];
|
|
8181
|
+
if (path7) parts.push(`path: "${verbose ? absolutePath : relativePath}"`);
|
|
8182
|
+
if (semantic) parts.push("semantic: true");
|
|
8183
|
+
return parts.join(", ");
|
|
8554
8184
|
},
|
|
8555
8185
|
renderToolUseRejectedMessage() {
|
|
8556
8186
|
return /* @__PURE__ */ React15.createElement(FallbackToolUseRejectedMessage, null);
|
|
@@ -8561,9 +8191,9 @@ var GlobTool = {
|
|
|
8561
8191
|
}
|
|
8562
8192
|
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 }));
|
|
8563
8193
|
},
|
|
8564
|
-
async *call({ pattern, path: path7 }, { abortController }) {
|
|
8194
|
+
async *call({ pattern, path: path7, semantic }, { abortController }) {
|
|
8565
8195
|
const start = Date.now();
|
|
8566
|
-
const searchPath = path7 ?
|
|
8196
|
+
const searchPath = path7 ? isAbsolute7(path7) ? path7 : resolve7(getCwd(), path7) : getCwd();
|
|
8567
8197
|
const raw = await ripGrep(
|
|
8568
8198
|
[
|
|
8569
8199
|
"--files",
|
|
@@ -8576,7 +8206,26 @@ var GlobTool = {
|
|
|
8576
8206
|
searchPath,
|
|
8577
8207
|
abortController.signal
|
|
8578
8208
|
);
|
|
8579
|
-
|
|
8209
|
+
let files = raw.map((p) => isAbsolute7(p) ? p : join5(searchPath, p));
|
|
8210
|
+
if (semantic) {
|
|
8211
|
+
try {
|
|
8212
|
+
const { LspClientManager } = await import("./manager-4UOP4R3A.js");
|
|
8213
|
+
const symbols = await LspClientManager.getInstance().workspaceSymbol(pattern);
|
|
8214
|
+
const semanticFiles = symbols.map((s) => {
|
|
8215
|
+
let filePath = s.location?.uri || "";
|
|
8216
|
+
if (filePath.startsWith("file://")) {
|
|
8217
|
+
try {
|
|
8218
|
+
filePath = fileURLToPath2(filePath);
|
|
8219
|
+
} catch (e) {
|
|
8220
|
+
filePath = filePath.replace("file://", "");
|
|
8221
|
+
}
|
|
8222
|
+
}
|
|
8223
|
+
return filePath;
|
|
8224
|
+
}).filter(Boolean);
|
|
8225
|
+
files = Array.from(/* @__PURE__ */ new Set([...files, ...semanticFiles]));
|
|
8226
|
+
} catch (e) {
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8580
8229
|
const truncated = files.length > DEFAULT_LIMIT;
|
|
8581
8230
|
const limitedFiles = files.slice(0, DEFAULT_LIMIT);
|
|
8582
8231
|
const output = {
|
|
@@ -8629,7 +8278,8 @@ var DESCRIPTION5 = `A powerful search tool built on ripgrep
|
|
|
8629
8278
|
`;
|
|
8630
8279
|
|
|
8631
8280
|
// src/tools/search/GrepTool/GrepTool.tsx
|
|
8632
|
-
import { isAbsolute as
|
|
8281
|
+
import { isAbsolute as isAbsolute8, relative as relative10 } from "path";
|
|
8282
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
8633
8283
|
var inputSchema7 = z7.strictObject({
|
|
8634
8284
|
pattern: z7.string().describe("The regular expression pattern to search for in file contents"),
|
|
8635
8285
|
path: z7.string().optional().describe(
|
|
@@ -8665,6 +8315,12 @@ var inputSchema7 = z7.strictObject({
|
|
|
8665
8315
|
),
|
|
8666
8316
|
multiline: z7.boolean().optional().describe(
|
|
8667
8317
|
"Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false."
|
|
8318
|
+
),
|
|
8319
|
+
semantic: z7.boolean().optional().describe(
|
|
8320
|
+
"Enable semantic search using LSP workspace symbols if text search fails. Useful for finding symbols even with typos."
|
|
8321
|
+
),
|
|
8322
|
+
symbol_type: z7.string().optional().describe(
|
|
8323
|
+
'Filter semantic search by symbol type (e.g. "class", "function", "variable"). Requires semantic: true.'
|
|
8668
8324
|
)
|
|
8669
8325
|
});
|
|
8670
8326
|
var MAX_RESULT_CHARS = 2e4;
|
|
@@ -8691,7 +8347,7 @@ function toProjectRelativeIfPossible(p) {
|
|
|
8691
8347
|
const rel = relative10(projectRoot, p);
|
|
8692
8348
|
if (!rel || rel === "") return p;
|
|
8693
8349
|
if (rel.startsWith("..")) return p;
|
|
8694
|
-
if (
|
|
8350
|
+
if (isAbsolute8(rel)) return p;
|
|
8695
8351
|
return rel;
|
|
8696
8352
|
}
|
|
8697
8353
|
function formatPagination(limit, offset) {
|
|
@@ -8816,7 +8472,9 @@ ${result.filenames.join("\n")}`;
|
|
|
8816
8472
|
"-i": caseInsensitive = false,
|
|
8817
8473
|
head_limit,
|
|
8818
8474
|
offset = 0,
|
|
8819
|
-
multiline = false
|
|
8475
|
+
multiline = false,
|
|
8476
|
+
semantic = false,
|
|
8477
|
+
symbol_type
|
|
8820
8478
|
}, toolUseContext) {
|
|
8821
8479
|
const { abortController } = toolUseContext;
|
|
8822
8480
|
const start = Date.now();
|
|
@@ -8861,6 +8519,94 @@ ${result.filenames.join("\n")}`;
|
|
|
8861
8519
|
const lines = await ripGrep(args, absolutePath, abortController.signal, {
|
|
8862
8520
|
sandbox: sandboxPlan.settings.enabled ? sandboxPlan.bunShellSandboxOptions : void 0
|
|
8863
8521
|
});
|
|
8522
|
+
if (lines.length === 0 && semantic) {
|
|
8523
|
+
try {
|
|
8524
|
+
const { LspClientManager } = await import("./manager-4UOP4R3A.js");
|
|
8525
|
+
const symbols = await LspClientManager.getInstance().workspaceSymbol(String(pattern));
|
|
8526
|
+
let filtered = symbols;
|
|
8527
|
+
const symbolType = symbol_type;
|
|
8528
|
+
if (symbolType) {
|
|
8529
|
+
const type3 = symbolType.toLowerCase();
|
|
8530
|
+
const kindMap = {
|
|
8531
|
+
"file": 1,
|
|
8532
|
+
"module": 2,
|
|
8533
|
+
"namespace": 3,
|
|
8534
|
+
"package": 4,
|
|
8535
|
+
"class": 5,
|
|
8536
|
+
"method": 6,
|
|
8537
|
+
"property": 7,
|
|
8538
|
+
"field": 8,
|
|
8539
|
+
"constructor": 9,
|
|
8540
|
+
"enum": 10,
|
|
8541
|
+
"interface": 11,
|
|
8542
|
+
"function": 12,
|
|
8543
|
+
"variable": 13,
|
|
8544
|
+
"constant": 14,
|
|
8545
|
+
"string": 15,
|
|
8546
|
+
"number": 16,
|
|
8547
|
+
"boolean": 17,
|
|
8548
|
+
"array": 18,
|
|
8549
|
+
"object": 19,
|
|
8550
|
+
"key": 20,
|
|
8551
|
+
"null": 21,
|
|
8552
|
+
"enummember": 22,
|
|
8553
|
+
"struct": 23,
|
|
8554
|
+
"event": 24,
|
|
8555
|
+
"operator": 25,
|
|
8556
|
+
"typeparameter": 26
|
|
8557
|
+
};
|
|
8558
|
+
const targetKind = kindMap[type3];
|
|
8559
|
+
if (targetKind) {
|
|
8560
|
+
filtered = symbols.filter((s) => s.kind === targetKind);
|
|
8561
|
+
}
|
|
8562
|
+
}
|
|
8563
|
+
if (filtered.length > 0) {
|
|
8564
|
+
const semanticLines = filtered.map((s) => {
|
|
8565
|
+
let filePath = s.location?.uri || "";
|
|
8566
|
+
if (filePath.startsWith("file://")) {
|
|
8567
|
+
try {
|
|
8568
|
+
filePath = fileURLToPath3(filePath);
|
|
8569
|
+
} catch (e) {
|
|
8570
|
+
filePath = filePath.replace("file://", "");
|
|
8571
|
+
}
|
|
8572
|
+
}
|
|
8573
|
+
const line = (s.location?.range?.start?.line || 0) + 1;
|
|
8574
|
+
const kindNameMap = {
|
|
8575
|
+
1: "File",
|
|
8576
|
+
2: "Module",
|
|
8577
|
+
3: "Namespace",
|
|
8578
|
+
4: "Package",
|
|
8579
|
+
5: "Class",
|
|
8580
|
+
6: "Method",
|
|
8581
|
+
7: "Property",
|
|
8582
|
+
8: "Field",
|
|
8583
|
+
9: "Constructor",
|
|
8584
|
+
10: "Enum",
|
|
8585
|
+
11: "Interface",
|
|
8586
|
+
12: "Function",
|
|
8587
|
+
13: "Variable",
|
|
8588
|
+
14: "Constant",
|
|
8589
|
+
15: "String",
|
|
8590
|
+
16: "Number",
|
|
8591
|
+
17: "Boolean",
|
|
8592
|
+
18: "Array",
|
|
8593
|
+
19: "Object",
|
|
8594
|
+
20: "Key",
|
|
8595
|
+
21: "Null",
|
|
8596
|
+
22: "EnumMember",
|
|
8597
|
+
23: "Struct",
|
|
8598
|
+
24: "Event",
|
|
8599
|
+
25: "Operator",
|
|
8600
|
+
26: "TypeParameter"
|
|
8601
|
+
};
|
|
8602
|
+
const kindName = kindNameMap[s.kind] || "Unknown";
|
|
8603
|
+
return `${filePath}:${line}: ${s.name} (${kindName})`;
|
|
8604
|
+
});
|
|
8605
|
+
lines.push(...semanticLines);
|
|
8606
|
+
}
|
|
8607
|
+
} catch (e) {
|
|
8608
|
+
}
|
|
8609
|
+
}
|
|
8864
8610
|
if (output_mode === "content") {
|
|
8865
8611
|
const rewritten = lines.map((line) => {
|
|
8866
8612
|
const idx = line.indexOf(":");
|
|
@@ -10305,9 +10051,9 @@ function setTerminalTitle(title) {
|
|
|
10305
10051
|
}
|
|
10306
10052
|
}
|
|
10307
10053
|
function clearTerminal() {
|
|
10308
|
-
return new Promise((
|
|
10054
|
+
return new Promise((resolve11) => {
|
|
10309
10055
|
process.stdout.write("\x1B[2J\x1B[3J\x1B[H", () => {
|
|
10310
|
-
|
|
10056
|
+
resolve11();
|
|
10311
10057
|
});
|
|
10312
10058
|
});
|
|
10313
10059
|
}
|
|
@@ -11425,8 +11171,8 @@ var OAuthService = class {
|
|
|
11425
11171
|
await authURLHandler(manualUrl);
|
|
11426
11172
|
await openBrowser(autoUrl);
|
|
11427
11173
|
};
|
|
11428
|
-
const { authorizationCode, useManualRedirect } = await new Promise((
|
|
11429
|
-
this.pendingCodePromise = { resolve:
|
|
11174
|
+
const { authorizationCode, useManualRedirect } = await new Promise((resolve11, reject) => {
|
|
11175
|
+
this.pendingCodePromise = { resolve: resolve11, reject };
|
|
11430
11176
|
this.startLocalServer(state, onReady);
|
|
11431
11177
|
});
|
|
11432
11178
|
const {
|
|
@@ -11597,7 +11343,7 @@ async function createAndStoreApiKey(accessToken) {
|
|
|
11597
11343
|
}
|
|
11598
11344
|
saveGlobalConfig(config2);
|
|
11599
11345
|
try {
|
|
11600
|
-
const { resetAnthropicClient } = await import("./llm-
|
|
11346
|
+
const { resetAnthropicClient } = await import("./llm-GFTKKVTZ.js");
|
|
11601
11347
|
resetAnthropicClient();
|
|
11602
11348
|
} catch {
|
|
11603
11349
|
}
|
|
@@ -13967,7 +13713,7 @@ function ModelSelector({
|
|
|
13967
13713
|
setModelLoadError(
|
|
13968
13714
|
`Attempt ${attempt}/${MAX_RETRIES}: Retrying model discovery...`
|
|
13969
13715
|
);
|
|
13970
|
-
await new Promise((
|
|
13716
|
+
await new Promise((resolve11) => setTimeout(resolve11, 1e3));
|
|
13971
13717
|
}
|
|
13972
13718
|
try {
|
|
13973
13719
|
const models = await fetchModels();
|
|
@@ -15879,7 +15625,7 @@ async function refreshPluginRuntimeFromInstalls() {
|
|
|
15879
15625
|
const existingRoots = getSessionPlugins().map((p) => p.rootDir);
|
|
15880
15626
|
const dirs = Array.from(/* @__PURE__ */ new Set([...existingRoots, ...installedRoots]));
|
|
15881
15627
|
if (dirs.length === 0) return [];
|
|
15882
|
-
const { configureSessionPlugins } = await import("./pluginRuntime-
|
|
15628
|
+
const { configureSessionPlugins } = await import("./pluginRuntime-E25X4DF2.js");
|
|
15883
15629
|
const { errors } = await configureSessionPlugins({ pluginDirs: dirs });
|
|
15884
15630
|
return errors;
|
|
15885
15631
|
}
|
|
@@ -16548,7 +16294,7 @@ async function call(onDone, context) {
|
|
|
16548
16294
|
ModelConfig,
|
|
16549
16295
|
{
|
|
16550
16296
|
onClose: () => {
|
|
16551
|
-
import("./model-
|
|
16297
|
+
import("./model-X64ICC6T.js").then(({ reloadModelManager: reloadModelManager2 }) => {
|
|
16552
16298
|
reloadModelManager2();
|
|
16553
16299
|
triggerModelConfigChange();
|
|
16554
16300
|
onDone();
|
|
@@ -20607,7 +20353,7 @@ async function launchExternalEditor(initialText) {
|
|
|
20607
20353
|
}
|
|
20608
20354
|
}
|
|
20609
20355
|
try {
|
|
20610
|
-
await new Promise((
|
|
20356
|
+
await new Promise((resolve11, reject) => {
|
|
20611
20357
|
const child = spawn(
|
|
20612
20358
|
editorCommand.command,
|
|
20613
20359
|
[...editorCommand.args, filePath],
|
|
@@ -20619,7 +20365,7 @@ async function launchExternalEditor(initialText) {
|
|
|
20619
20365
|
child.on("error", reject);
|
|
20620
20366
|
child.on("exit", (code, signal) => {
|
|
20621
20367
|
if (code === 0 || code === null) {
|
|
20622
|
-
|
|
20368
|
+
resolve11();
|
|
20623
20369
|
} else {
|
|
20624
20370
|
reject(
|
|
20625
20371
|
new Error(
|
|
@@ -20670,7 +20416,7 @@ async function launchExternalEditorForFilePath(filePath) {
|
|
|
20670
20416
|
}
|
|
20671
20417
|
}
|
|
20672
20418
|
try {
|
|
20673
|
-
await new Promise((
|
|
20419
|
+
await new Promise((resolve11, reject) => {
|
|
20674
20420
|
const child = spawn(
|
|
20675
20421
|
editorCommand.command,
|
|
20676
20422
|
[...editorCommand.args, filePath],
|
|
@@ -20682,7 +20428,7 @@ async function launchExternalEditorForFilePath(filePath) {
|
|
|
20682
20428
|
child.on("error", reject);
|
|
20683
20429
|
child.on("exit", (code, signal) => {
|
|
20684
20430
|
if (code === 0 || code === null) {
|
|
20685
|
-
|
|
20431
|
+
resolve11();
|
|
20686
20432
|
} else {
|
|
20687
20433
|
reject(
|
|
20688
20434
|
new Error(
|
|
@@ -21660,7 +21406,7 @@ function getCompletionContext(args) {
|
|
|
21660
21406
|
|
|
21661
21407
|
// src/utils/completion/fileSuggestions.ts
|
|
21662
21408
|
import { existsSync as existsSync13, readdirSync as readdirSync3, statSync as statSync11 } from "fs";
|
|
21663
|
-
import { basename as basename5, dirname as dirname9, join as join9, resolve as
|
|
21409
|
+
import { basename as basename5, dirname as dirname9, join as join9, resolve as resolve8 } from "path";
|
|
21664
21410
|
function generateFileSuggestions(args) {
|
|
21665
21411
|
const { prefix, cwd: cwd2 } = args;
|
|
21666
21412
|
try {
|
|
@@ -21673,7 +21419,7 @@ function generateFileSuggestions(args) {
|
|
|
21673
21419
|
} else if (isAbsolutePath) {
|
|
21674
21420
|
searchPath = userPath;
|
|
21675
21421
|
} else {
|
|
21676
|
-
searchPath =
|
|
21422
|
+
searchPath = resolve8(cwd2, userPath);
|
|
21677
21423
|
}
|
|
21678
21424
|
const endsWithSlash = userPath.endsWith("/");
|
|
21679
21425
|
const searchStat = existsSync13(searchPath) ? statSync11(searchPath) : null;
|
|
@@ -23807,7 +23553,7 @@ function useStatusLine() {
|
|
|
23807
23553
|
// src/ui/components/PromptInput.tsx
|
|
23808
23554
|
async function interpretHashCommand(input) {
|
|
23809
23555
|
try {
|
|
23810
|
-
const { queryQuick: queryQuick2 } = await import("./llm-
|
|
23556
|
+
const { queryQuick: queryQuick2 } = await import("./llm-GFTKKVTZ.js");
|
|
23811
23557
|
const systemPrompt = [
|
|
23812
23558
|
"You're helping the user structure notes that will be added to their PYB.md file.",
|
|
23813
23559
|
"Format the user's input into a well-structured note that will be useful for later reference.",
|
|
@@ -24012,7 +23758,7 @@ function PromptInput({
|
|
|
24012
23758
|
abortController.abort();
|
|
24013
23759
|
}
|
|
24014
23760
|
setIsLoading(false);
|
|
24015
|
-
await new Promise((
|
|
23761
|
+
await new Promise((resolve11) => setTimeout(resolve11, 0));
|
|
24016
23762
|
setIsLoading(true);
|
|
24017
23763
|
let finalInput2 = cleanInput;
|
|
24018
23764
|
for (const { placeholder: placeholder2, text } of pastedTexts) {
|
|
@@ -24120,7 +23866,7 @@ function PromptInput({
|
|
|
24120
23866
|
if (messages2.length) {
|
|
24121
23867
|
if (mode === "bash") {
|
|
24122
23868
|
onQuery(messages2, newAbortController).then(async () => {
|
|
24123
|
-
const { getCwd: getCwd2 } = await import("./state-
|
|
23869
|
+
const { getCwd: getCwd2 } = await import("./state-5VXARPH2.js");
|
|
24124
23870
|
setCurrentPwd(getCwd2());
|
|
24125
23871
|
});
|
|
24126
23872
|
} else {
|
|
@@ -24480,11 +24226,11 @@ import { useCallback as useCallback14 } from "react";
|
|
|
24480
24226
|
function useCanUseTool(setToolUseConfirm) {
|
|
24481
24227
|
return useCallback14(
|
|
24482
24228
|
async (tool, input, toolUseContext, assistantMessage) => {
|
|
24483
|
-
return new Promise((
|
|
24229
|
+
return new Promise((resolve11) => {
|
|
24484
24230
|
function logCancelledEvent() {
|
|
24485
24231
|
}
|
|
24486
24232
|
function resolveWithCancelledAndAbortAllToolCalls(message) {
|
|
24487
|
-
|
|
24233
|
+
resolve11({
|
|
24488
24234
|
result: false,
|
|
24489
24235
|
message: message ? `${REJECT_MESSAGE_WITH_FEEDBACK_PREFIX}${message}` : REJECT_MESSAGE
|
|
24490
24236
|
});
|
|
@@ -24502,12 +24248,12 @@ function useCanUseTool(setToolUseConfirm) {
|
|
|
24502
24248
|
assistantMessage
|
|
24503
24249
|
).then(async (result) => {
|
|
24504
24250
|
if (result.result === true) {
|
|
24505
|
-
|
|
24251
|
+
resolve11({ result: true });
|
|
24506
24252
|
return;
|
|
24507
24253
|
}
|
|
24508
24254
|
const deniedResult = result;
|
|
24509
24255
|
if (deniedResult.shouldPromptUser === false) {
|
|
24510
|
-
|
|
24256
|
+
resolve11({ result: false, message: deniedResult.message });
|
|
24511
24257
|
return;
|
|
24512
24258
|
}
|
|
24513
24259
|
const [description2, commandPrefix] = await Promise.all([
|
|
@@ -24539,7 +24285,7 @@ function useCanUseTool(setToolUseConfirm) {
|
|
|
24539
24285
|
if (type2 === "permanent") {
|
|
24540
24286
|
} else {
|
|
24541
24287
|
}
|
|
24542
|
-
|
|
24288
|
+
resolve11({ result: true });
|
|
24543
24289
|
},
|
|
24544
24290
|
onReject(rejectionMessage) {
|
|
24545
24291
|
resolveWithCancelledAndAbortAllToolCalls(rejectionMessage);
|
|
@@ -25191,8 +24937,8 @@ var ToolUseQueue = class {
|
|
|
25191
24937
|
}
|
|
25192
24938
|
if (this.hasExecutingTools() && !this.hasCompletedResults() && !this.hasPendingProgress()) {
|
|
25193
24939
|
const promises = this.tools.filter((t) => t.status === "executing" && t.promise).map((t) => t.promise);
|
|
25194
|
-
const progressPromise = new Promise((
|
|
25195
|
-
this.progressAvailableResolve =
|
|
24940
|
+
const progressPromise = new Promise((resolve11) => {
|
|
24941
|
+
this.progressAvailableResolve = resolve11;
|
|
25196
24942
|
});
|
|
25197
24943
|
if (promises.length > 0) {
|
|
25198
24944
|
await Promise.race([...promises, progressPromise]);
|
|
@@ -26057,7 +25803,7 @@ function BinaryFeedbackView({
|
|
|
26057
25803
|
function BinaryFeedback({
|
|
26058
25804
|
m1,
|
|
26059
25805
|
m2,
|
|
26060
|
-
resolve:
|
|
25806
|
+
resolve: resolve11,
|
|
26061
25807
|
debug: debug2,
|
|
26062
25808
|
erroredToolUseIDs,
|
|
26063
25809
|
inProgressToolUseIDs,
|
|
@@ -26069,9 +25815,9 @@ function BinaryFeedback({
|
|
|
26069
25815
|
const onChoose = useCallback15(
|
|
26070
25816
|
(choice) => {
|
|
26071
25817
|
logBinaryFeedbackEvent(m1, m2, choice);
|
|
26072
|
-
|
|
25818
|
+
resolve11(getBinaryFeedbackResultForChoice(m1, m2, choice));
|
|
26073
25819
|
},
|
|
26074
|
-
[m1, m2,
|
|
25820
|
+
[m1, m2, resolve11]
|
|
26075
25821
|
);
|
|
26076
25822
|
useNotifyAfterTimeout(
|
|
26077
25823
|
`${PRODUCT_NAME} needs your input on a response comparison`
|
|
@@ -26906,7 +26652,7 @@ import { homedir as homedir7 } from "os";
|
|
|
26906
26652
|
// src/commands/agents/generation.ts
|
|
26907
26653
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
26908
26654
|
async function generateAgentWithClaude(prompt) {
|
|
26909
|
-
const { queryModel } = await import("./llm-
|
|
26655
|
+
const { queryModel } = await import("./llm-GFTKKVTZ.js");
|
|
26910
26656
|
const systemPrompt = `You are an expert at creating AI agent configurations. Based on the user's description, generate a specialized agent configuration.
|
|
26911
26657
|
|
|
26912
26658
|
Return your response as a JSON object with exactly these fields:
|
|
@@ -27203,7 +26949,7 @@ var COLOR_OPTIONS = [
|
|
|
27203
26949
|
"cyan"
|
|
27204
26950
|
];
|
|
27205
26951
|
function openInEditor(filePath) {
|
|
27206
|
-
return new Promise((
|
|
26952
|
+
return new Promise((resolve11, reject) => {
|
|
27207
26953
|
const platform = process.platform;
|
|
27208
26954
|
let command4;
|
|
27209
26955
|
let args;
|
|
@@ -27226,7 +26972,7 @@ function openInEditor(filePath) {
|
|
|
27226
26972
|
child.on("error", (err) => reject(err));
|
|
27227
26973
|
child.on(
|
|
27228
26974
|
"exit",
|
|
27229
|
-
(code) => code === 0 ?
|
|
26975
|
+
(code) => code === 0 ? resolve11() : reject(new Error(`Editor exited with ${code}`))
|
|
27230
26976
|
);
|
|
27231
26977
|
});
|
|
27232
26978
|
}
|
|
@@ -30105,7 +29851,7 @@ var BashParser = class {
|
|
|
30105
29851
|
};
|
|
30106
29852
|
|
|
30107
29853
|
// src/utils/bash-parser/validator.ts
|
|
30108
|
-
import { resolve as
|
|
29854
|
+
import { resolve as resolve9 } from "path";
|
|
30109
29855
|
async function validateSafety(script, cwd2 = process.cwd()) {
|
|
30110
29856
|
const tree2 = await BashParser.parse(script);
|
|
30111
29857
|
const root = tree2.rootNode;
|
|
@@ -30156,7 +29902,7 @@ function checkCommand(node, script, cwd2) {
|
|
|
30156
29902
|
const targetsCritical = args.some((arg) => {
|
|
30157
29903
|
if (arg.startsWith("-") || arg.startsWith("$")) return false;
|
|
30158
29904
|
try {
|
|
30159
|
-
const absPath =
|
|
29905
|
+
const absPath = resolve9(cwd2, arg).replace(/\\/g, "/");
|
|
30160
29906
|
return criticalPaths.some((critical) => {
|
|
30161
29907
|
const normalizedCritical = critical.endsWith("/") ? critical : critical + "/";
|
|
30162
29908
|
if (absPath === critical || absPath === critical.replace(/\/$/, "")) return true;
|
|
@@ -30174,7 +29920,7 @@ function checkCommand(node, script, cwd2) {
|
|
|
30174
29920
|
const targetsRoot = args.some((arg) => {
|
|
30175
29921
|
if (arg.startsWith("-") || arg.startsWith("$")) return false;
|
|
30176
29922
|
try {
|
|
30177
|
-
const absPath =
|
|
29923
|
+
const absPath = resolve9(cwd2, arg).replace(/\\/g, "/");
|
|
30178
29924
|
return absPath === "/" || /^[a-z]:\/?$/i.test(absPath);
|
|
30179
29925
|
} catch {
|
|
30180
29926
|
return arg === "/" || /^[a-z]:\/?$/i.test(arg);
|
|
@@ -30282,7 +30028,7 @@ var BashTool = {
|
|
|
30282
30028
|
async validateInput({ command: command4, timeout, dangerouslyDisableSandbox, cwd: cwd2 }, context) {
|
|
30283
30029
|
const trimmed = command4.trim();
|
|
30284
30030
|
try {
|
|
30285
|
-
await validateSafety(trimmed, cwd2 ?
|
|
30031
|
+
await validateSafety(trimmed, cwd2 ? resolve10(getCwd(), cwd2) : getCwd());
|
|
30286
30032
|
} catch (e) {
|
|
30287
30033
|
return {
|
|
30288
30034
|
result: false,
|
|
@@ -30322,7 +30068,7 @@ var BashTool = {
|
|
|
30322
30068
|
};
|
|
30323
30069
|
}
|
|
30324
30070
|
if (cwd2) {
|
|
30325
|
-
const fullTargetDir =
|
|
30071
|
+
const fullTargetDir = isAbsolute9(cwd2) ? cwd2 : resolve10(getCwd(), cwd2);
|
|
30326
30072
|
if (!isInDirectory(
|
|
30327
30073
|
relative13(getOriginalCwd(), fullTargetDir),
|
|
30328
30074
|
relative13(getCwd(), getOriginalCwd())
|
|
@@ -30342,7 +30088,7 @@ var BashTool = {
|
|
|
30342
30088
|
continue;
|
|
30343
30089
|
}
|
|
30344
30090
|
const targetDir = parts[1].replace(/^['"]|['"]$/g, "");
|
|
30345
|
-
const fullTargetDir =
|
|
30091
|
+
const fullTargetDir = isAbsolute9(targetDir) ? targetDir : resolve10(getCwd(), targetDir);
|
|
30346
30092
|
if (!isInDirectory(
|
|
30347
30093
|
relative13(getOriginalCwd(), fullTargetDir),
|
|
30348
30094
|
relative13(getCwd(), getOriginalCwd())
|
|
@@ -30396,13 +30142,39 @@ var BashTool = {
|
|
|
30396
30142
|
stderr,
|
|
30397
30143
|
bashId,
|
|
30398
30144
|
backgroundTaskId
|
|
30399
|
-
}) {
|
|
30145
|
+
}, command4) {
|
|
30400
30146
|
let trimmedStdout = stdout;
|
|
30401
30147
|
if (trimmedStdout) {
|
|
30402
30148
|
trimmedStdout = trimmedStdout.replace(/^(\s*\n)+/, "");
|
|
30403
30149
|
trimmedStdout = trimmedStdout.trimEnd();
|
|
30404
30150
|
}
|
|
30151
|
+
const lines = trimmedStdout.split("\n");
|
|
30152
|
+
if (lines.length > 500) {
|
|
30153
|
+
const errorIndex = lines.findIndex((l) => /Error:|Exception:|Failed/i.test(l));
|
|
30154
|
+
if (errorIndex !== -1) {
|
|
30155
|
+
const start = Math.max(0, errorIndex - 20);
|
|
30156
|
+
const end = Math.min(lines.length, errorIndex + 20);
|
|
30157
|
+
const head = lines.slice(0, 20).join("\n");
|
|
30158
|
+
const errorContext = lines.slice(start, end).join("\n");
|
|
30159
|
+
const tail = lines.slice(-20).join("\n");
|
|
30160
|
+
if (start > 20 && end < lines.length - 20) {
|
|
30161
|
+
trimmedStdout = `${head}
|
|
30162
|
+
... [Snip: ${start - 20} lines] ...
|
|
30163
|
+
${errorContext}
|
|
30164
|
+
... [Snip: ${lines.length - end} lines] ...
|
|
30165
|
+
${tail}`;
|
|
30166
|
+
}
|
|
30167
|
+
}
|
|
30168
|
+
}
|
|
30405
30169
|
let trimmedStderr = stderr.trim();
|
|
30170
|
+
if (trimmedStderr.includes("command not found") && command4) {
|
|
30171
|
+
const cmdParts = command4.trim().split(/\s+/);
|
|
30172
|
+
const prog = cmdParts[0];
|
|
30173
|
+
if (prog === "gti") {
|
|
30174
|
+
trimmedStderr += `
|
|
30175
|
+
Did you mean "git ${cmdParts.slice(1).join(" ")}"?`;
|
|
30176
|
+
}
|
|
30177
|
+
}
|
|
30406
30178
|
if (interrupted) {
|
|
30407
30179
|
if (trimmedStderr) trimmedStderr += EOL3;
|
|
30408
30180
|
trimmedStderr += "<error>Command was aborted before completion</error>";
|
|
@@ -30427,7 +30199,7 @@ var BashTool = {
|
|
|
30427
30199
|
const safeMode = Boolean(context?.safeMode ?? context?.options?.safeMode);
|
|
30428
30200
|
const userPrompt = typeof context?.options?.lastUserPrompt === "string" ? context.options.lastUserPrompt.trim() : "";
|
|
30429
30201
|
const commandDescription = typeof description2 === "string" ? description2.trim() : "";
|
|
30430
|
-
const effectiveCwd = cwd2 ?
|
|
30202
|
+
const effectiveCwd = cwd2 ? isAbsolute9(cwd2) ? cwd2 : resolve10(getCwd(), cwd2) : getCwd();
|
|
30431
30203
|
try {
|
|
30432
30204
|
await validateSafety(command4, effectiveCwd);
|
|
30433
30205
|
} catch (error) {
|
|
@@ -30441,7 +30213,7 @@ var BashTool = {
|
|
|
30441
30213
|
};
|
|
30442
30214
|
yield {
|
|
30443
30215
|
type: "result",
|
|
30444
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30216
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30445
30217
|
data
|
|
30446
30218
|
};
|
|
30447
30219
|
return;
|
|
@@ -30463,7 +30235,7 @@ var BashTool = {
|
|
|
30463
30235
|
};
|
|
30464
30236
|
yield {
|
|
30465
30237
|
type: "result",
|
|
30466
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30238
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30467
30239
|
data
|
|
30468
30240
|
};
|
|
30469
30241
|
return;
|
|
@@ -30495,7 +30267,7 @@ var BashTool = {
|
|
|
30495
30267
|
};
|
|
30496
30268
|
yield {
|
|
30497
30269
|
type: "result",
|
|
30498
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30270
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30499
30271
|
data
|
|
30500
30272
|
};
|
|
30501
30273
|
return;
|
|
@@ -30530,7 +30302,7 @@ var BashTool = {
|
|
|
30530
30302
|
};
|
|
30531
30303
|
yield {
|
|
30532
30304
|
type: "result",
|
|
30533
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30305
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30534
30306
|
data
|
|
30535
30307
|
};
|
|
30536
30308
|
return;
|
|
@@ -30577,7 +30349,7 @@ var BashTool = {
|
|
|
30577
30349
|
if (abortController.signal.aborted) return false;
|
|
30578
30350
|
const hostForUrl = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
30579
30351
|
const url2 = `http://${hostForUrl}:${port}/`;
|
|
30580
|
-
return await new Promise((
|
|
30352
|
+
return await new Promise((resolve11) => {
|
|
30581
30353
|
const assistantMessage = createAssistantMessage("");
|
|
30582
30354
|
if (context.messageId) {
|
|
30583
30355
|
;
|
|
@@ -30593,13 +30365,13 @@ var BashTool = {
|
|
|
30593
30365
|
suggestions: void 0,
|
|
30594
30366
|
riskScore: null,
|
|
30595
30367
|
onAbort() {
|
|
30596
|
-
|
|
30368
|
+
resolve11(false);
|
|
30597
30369
|
},
|
|
30598
30370
|
onAllow() {
|
|
30599
|
-
|
|
30371
|
+
resolve11(true);
|
|
30600
30372
|
},
|
|
30601
30373
|
onReject() {
|
|
30602
|
-
|
|
30374
|
+
resolve11(false);
|
|
30603
30375
|
}
|
|
30604
30376
|
};
|
|
30605
30377
|
setToolJSX({
|
|
@@ -30632,7 +30404,7 @@ var BashTool = {
|
|
|
30632
30404
|
};
|
|
30633
30405
|
yield {
|
|
30634
30406
|
type: "result",
|
|
30635
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30407
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30636
30408
|
data
|
|
30637
30409
|
};
|
|
30638
30410
|
return;
|
|
@@ -30658,7 +30430,7 @@ var BashTool = {
|
|
|
30658
30430
|
};
|
|
30659
30431
|
yield {
|
|
30660
30432
|
type: "result",
|
|
30661
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30433
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30662
30434
|
data
|
|
30663
30435
|
};
|
|
30664
30436
|
return;
|
|
@@ -30693,8 +30465,8 @@ var BashTool = {
|
|
|
30693
30465
|
);
|
|
30694
30466
|
let backgroundRequested = false;
|
|
30695
30467
|
let resolveBackground = null;
|
|
30696
|
-
const backgroundPromise = new Promise((
|
|
30697
|
-
resolveBackground =
|
|
30468
|
+
const backgroundPromise = new Promise((resolve11) => {
|
|
30469
|
+
resolveBackground = resolve11;
|
|
30698
30470
|
});
|
|
30699
30471
|
const requestBackground = () => {
|
|
30700
30472
|
if (backgroundRequested) return;
|
|
@@ -30737,7 +30509,7 @@ ${footerParts.join(" ")}`;
|
|
|
30737
30509
|
bashId
|
|
30738
30510
|
})),
|
|
30739
30511
|
new Promise(
|
|
30740
|
-
(
|
|
30512
|
+
(resolve11) => setTimeout(() => resolve11({ kind: "tick" }), waitMs)
|
|
30741
30513
|
)
|
|
30742
30514
|
]);
|
|
30743
30515
|
if (race.kind === "background") {
|
|
@@ -30752,7 +30524,7 @@ ${footerParts.join(" ")}`;
|
|
|
30752
30524
|
};
|
|
30753
30525
|
yield {
|
|
30754
30526
|
type: "result",
|
|
30755
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30527
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30756
30528
|
data
|
|
30757
30529
|
};
|
|
30758
30530
|
return;
|
|
@@ -30771,7 +30543,7 @@ ${footerParts.join(" ")}`;
|
|
|
30771
30543
|
if (process.env.NODE_ENV !== "test") {
|
|
30772
30544
|
getCommandFilePaths(command4, stdout).then((filePaths) => {
|
|
30773
30545
|
for (const filePath of filePaths) {
|
|
30774
|
-
const fullFilePath =
|
|
30546
|
+
const fullFilePath = isAbsolute9(filePath) ? filePath : resolve10(getCwd(), filePath);
|
|
30775
30547
|
try {
|
|
30776
30548
|
readFileTimestamps[fullFilePath] = statSync12(fullFilePath).mtimeMs;
|
|
30777
30549
|
} catch (e) {
|
|
@@ -30791,7 +30563,7 @@ ${footerParts.join(" ")}`;
|
|
|
30791
30563
|
};
|
|
30792
30564
|
yield {
|
|
30793
30565
|
type: "result",
|
|
30794
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30566
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30795
30567
|
data
|
|
30796
30568
|
};
|
|
30797
30569
|
return;
|
|
@@ -30829,7 +30601,7 @@ ${footerParts.join(" ")}`;
|
|
|
30829
30601
|
};
|
|
30830
30602
|
yield {
|
|
30831
30603
|
type: "result",
|
|
30832
|
-
resultForAssistant: this.renderResultForAssistant(data),
|
|
30604
|
+
resultForAssistant: this.renderResultForAssistant(data, command4),
|
|
30833
30605
|
data
|
|
30834
30606
|
};
|
|
30835
30607
|
} finally {
|
|
@@ -30935,8 +30707,14 @@ assistant: src/foo.c
|
|
|
30935
30707
|
</example>
|
|
30936
30708
|
|
|
30937
30709
|
<example>
|
|
30938
|
-
user:
|
|
30939
|
-
assistant: [uses
|
|
30710
|
+
user: change the greeting in hello.ts
|
|
30711
|
+
assistant: [uses Read tool to read hello.ts]
|
|
30712
|
+
[uses Edit tool with the following input]
|
|
30713
|
+
<<<<<<< SEARCH
|
|
30714
|
+
console.log("Hello, world!");
|
|
30715
|
+
=======
|
|
30716
|
+
console.log("Hello, User!");
|
|
30717
|
+
>>>>>>> REPLACE
|
|
30940
30718
|
</example>
|
|
30941
30719
|
`}
|
|
30942
30720
|
|
|
@@ -30979,19 +30757,19 @@ NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTAN
|
|
|
30979
30757
|
- 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.
|
|
30980
30758
|
- It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
30981
30759
|
- It is always better to speculatively perform multiple searches as a batch that are potentially useful.
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
30986
|
-
1. **Edit Tool**:
|
|
30987
|
-
-
|
|
30988
|
-
-
|
|
30989
|
-
-
|
|
30990
|
-
|
|
30991
|
-
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
-
|
|
30760
|
+
|
|
30761
|
+
# File Modification Strategy (The Universal Edit Tool)
|
|
30762
|
+
When you need to modify files, rely on the **Edit Tool** for almost all tasks.
|
|
30763
|
+
|
|
30764
|
+
1. **Edit Tool**: The primary tool for ALL file modifications.
|
|
30765
|
+
- **Format**: Use the **SEARCH/REPLACE Block** format to specify changes. You can provide multiple blocks in one turn.
|
|
30766
|
+
- **Capabilities**: Supports single edits, multiple edits (batching), and structural changes.
|
|
30767
|
+
- **Safety**: Powered by Atomic Verification. If any part of the edit breaks syntax or fails to match, the entire operation is rolled back.
|
|
30768
|
+
- **Resilience**: Uses a 9-layer fuzzy matching engine and LSP anchoring to find code even if line numbers or indentation are slightly off.
|
|
30769
|
+
- **Requirement**: Always READ the file first to get the context.
|
|
30770
|
+
|
|
30771
|
+
2. **Patch Tool**: Use ONLY for massive multi-file refactoring where strict atomicity across files is required.
|
|
30772
|
+
- **Note**: Prefer Edit Tool for 99% of tasks.
|
|
30995
30773
|
|
|
30996
30774
|
# Cognitive Safety & Verification
|
|
30997
30775
|
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.
|
|
@@ -31045,14 +30823,6 @@ export {
|
|
|
31045
30823
|
hasWritePermission,
|
|
31046
30824
|
grantReadPermissionForOriginalDir,
|
|
31047
30825
|
NotebookEditTool,
|
|
31048
|
-
LineTrimmedReplacer,
|
|
31049
|
-
WhitespaceNormalizedReplacer,
|
|
31050
|
-
BlockAnchorReplacer,
|
|
31051
|
-
IndentationFlexibleReplacer,
|
|
31052
|
-
EscapeNormalizedReplacer,
|
|
31053
|
-
MultiOccurrenceReplacer,
|
|
31054
|
-
TrimmedBoundaryReplacer,
|
|
31055
|
-
ContextAwareReplacer,
|
|
31056
30826
|
FileEditTool,
|
|
31057
30827
|
ParserRegistry,
|
|
31058
30828
|
loadLanguage,
|