centaurus-cli 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/AUTH_FLOW.md +138 -0
  2. package/CONFIG_GUIDE.md +255 -0
  3. package/LICENSE +21 -0
  4. package/README.md +346 -0
  5. package/dist/ai/provider-factory.d.ts +6 -0
  6. package/dist/ai/provider-factory.d.ts.map +1 -0
  7. package/dist/ai/provider-factory.js +27 -0
  8. package/dist/ai/provider-factory.js.map +1 -0
  9. package/dist/ai/providers/base.d.ts +25 -0
  10. package/dist/ai/providers/base.d.ts.map +1 -0
  11. package/dist/ai/providers/base.js +9 -0
  12. package/dist/ai/providers/base.js.map +1 -0
  13. package/dist/ai/providers/gemini.d.ts +34 -0
  14. package/dist/ai/providers/gemini.d.ts.map +1 -0
  15. package/dist/ai/providers/gemini.js +146 -0
  16. package/dist/ai/providers/gemini.js.map +1 -0
  17. package/dist/ai/types.d.ts +20 -0
  18. package/dist/ai/types.d.ts.map +1 -0
  19. package/dist/ai/types.js +2 -0
  20. package/dist/ai/types.js.map +1 -0
  21. package/dist/cli-adapter.d.ts +78 -0
  22. package/dist/cli-adapter.d.ts.map +1 -0
  23. package/dist/cli-adapter.js +605 -0
  24. package/dist/cli-adapter.js.map +1 -0
  25. package/dist/commands/CommandParser.d.ts +27 -0
  26. package/dist/commands/CommandParser.d.ts.map +1 -0
  27. package/dist/commands/CommandParser.js +238 -0
  28. package/dist/commands/CommandParser.js.map +1 -0
  29. package/dist/config/ConfigManager.d.ts +59 -0
  30. package/dist/config/ConfigManager.d.ts.map +1 -0
  31. package/dist/config/ConfigManager.js +332 -0
  32. package/dist/config/ConfigManager.js.map +1 -0
  33. package/dist/config/defaultConfig.d.ts +82 -0
  34. package/dist/config/defaultConfig.d.ts.map +1 -0
  35. package/dist/config/defaultConfig.js +88 -0
  36. package/dist/config/defaultConfig.js.map +1 -0
  37. package/dist/config/manager.d.ts +60 -0
  38. package/dist/config/manager.d.ts.map +1 -0
  39. package/dist/config/manager.js +162 -0
  40. package/dist/config/manager.js.map +1 -0
  41. package/dist/config/types.d.ts +9 -0
  42. package/dist/config/types.d.ts.map +1 -0
  43. package/dist/config/types.js +6 -0
  44. package/dist/config/types.js.map +1 -0
  45. package/dist/index-custom.d.ts +3 -0
  46. package/dist/index-custom.d.ts.map +1 -0
  47. package/dist/index-custom.js +65 -0
  48. package/dist/index-custom.js.map +1 -0
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +102 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/prompts/system-prompt.d.ts +47 -0
  54. package/dist/prompts/system-prompt.d.ts.map +1 -0
  55. package/dist/prompts/system-prompt.js +378 -0
  56. package/dist/prompts/system-prompt.js.map +1 -0
  57. package/dist/providers/GoogleProvider.d.ts +26 -0
  58. package/dist/providers/GoogleProvider.d.ts.map +1 -0
  59. package/dist/providers/GoogleProvider.js +313 -0
  60. package/dist/providers/GoogleProvider.js.map +1 -0
  61. package/dist/providers/Provider.d.ts +114 -0
  62. package/dist/providers/Provider.d.ts.map +1 -0
  63. package/dist/providers/Provider.js +44 -0
  64. package/dist/providers/Provider.js.map +1 -0
  65. package/dist/services/api-client.d.ts +282 -0
  66. package/dist/services/api-client.d.ts.map +1 -0
  67. package/dist/services/api-client.js +339 -0
  68. package/dist/services/api-client.js.map +1 -0
  69. package/dist/services/auth-handler.d.ts +30 -0
  70. package/dist/services/auth-handler.d.ts.map +1 -0
  71. package/dist/services/auth-handler.js +210 -0
  72. package/dist/services/auth-handler.js.map +1 -0
  73. package/dist/services/conversation-manager.d.ts +73 -0
  74. package/dist/services/conversation-manager.d.ts.map +1 -0
  75. package/dist/services/conversation-manager.js +128 -0
  76. package/dist/services/conversation-manager.js.map +1 -0
  77. package/dist/tests/automated-verification.d.ts +27 -0
  78. package/dist/tests/automated-verification.d.ts.map +1 -0
  79. package/dist/tests/automated-verification.js +359 -0
  80. package/dist/tests/automated-verification.js.map +1 -0
  81. package/dist/tests/integration-tests.d.ts +50 -0
  82. package/dist/tests/integration-tests.d.ts.map +1 -0
  83. package/dist/tests/integration-tests.js +648 -0
  84. package/dist/tests/integration-tests.js.map +1 -0
  85. package/dist/tools/ToolRegistry.d.ts +44 -0
  86. package/dist/tools/ToolRegistry.d.ts.map +1 -0
  87. package/dist/tools/ToolRegistry.js +494 -0
  88. package/dist/tools/ToolRegistry.js.map +1 -0
  89. package/dist/tools/command.d.ts +4 -0
  90. package/dist/tools/command.d.ts.map +1 -0
  91. package/dist/tools/command.js +117 -0
  92. package/dist/tools/command.js.map +1 -0
  93. package/dist/tools/file-ops-test.d.ts +6 -0
  94. package/dist/tools/file-ops-test.d.ts.map +1 -0
  95. package/dist/tools/file-ops-test.js +197 -0
  96. package/dist/tools/file-ops-test.js.map +1 -0
  97. package/dist/tools/file-ops.d.ts +6 -0
  98. package/dist/tools/file-ops.d.ts.map +1 -0
  99. package/dist/tools/file-ops.js +189 -0
  100. package/dist/tools/file-ops.js.map +1 -0
  101. package/dist/tools/plan-mode.d.ts +53 -0
  102. package/dist/tools/plan-mode.d.ts.map +1 -0
  103. package/dist/tools/plan-mode.js +202 -0
  104. package/dist/tools/plan-mode.js.map +1 -0
  105. package/dist/tools/registry.d.ts +30 -0
  106. package/dist/tools/registry.d.ts.map +1 -0
  107. package/dist/tools/registry.js +67 -0
  108. package/dist/tools/registry.js.map +1 -0
  109. package/dist/tools/types.d.ts +34 -0
  110. package/dist/tools/types.d.ts.map +1 -0
  111. package/dist/tools/types.js +2 -0
  112. package/dist/tools/types.js.map +1 -0
  113. package/dist/tools/web-search.d.ts +24 -0
  114. package/dist/tools/web-search.d.ts.map +1 -0
  115. package/dist/tools/web-search.js +194 -0
  116. package/dist/tools/web-search.js.map +1 -0
  117. package/dist/types/index.d.ts +32 -0
  118. package/dist/types/index.d.ts.map +1 -0
  119. package/dist/types/index.js +2 -0
  120. package/dist/types/index.js.map +1 -0
  121. package/dist/ui/DisplayHistory.d.ts +53 -0
  122. package/dist/ui/DisplayHistory.d.ts.map +1 -0
  123. package/dist/ui/DisplayHistory.js +82 -0
  124. package/dist/ui/DisplayHistory.js.map +1 -0
  125. package/dist/ui/clack-ui.d.ts +83 -0
  126. package/dist/ui/clack-ui.d.ts.map +1 -0
  127. package/dist/ui/clack-ui.js +304 -0
  128. package/dist/ui/clack-ui.js.map +1 -0
  129. package/dist/ui/components/App.d.ts +47 -0
  130. package/dist/ui/components/App.d.ts.map +1 -0
  131. package/dist/ui/components/App.js +389 -0
  132. package/dist/ui/components/App.js.map +1 -0
  133. package/dist/ui/components/AuthScreen.d.ts +8 -0
  134. package/dist/ui/components/AuthScreen.d.ts.map +1 -0
  135. package/dist/ui/components/AuthScreen.js +37 -0
  136. package/dist/ui/components/AuthScreen.js.map +1 -0
  137. package/dist/ui/components/AuthWelcomeScreen.d.ts +8 -0
  138. package/dist/ui/components/AuthWelcomeScreen.d.ts.map +1 -0
  139. package/dist/ui/components/AuthWelcomeScreen.js +34 -0
  140. package/dist/ui/components/AuthWelcomeScreen.js.map +1 -0
  141. package/dist/ui/components/CodeBlock.d.ts +9 -0
  142. package/dist/ui/components/CodeBlock.d.ts.map +1 -0
  143. package/dist/ui/components/CodeBlock.js +22 -0
  144. package/dist/ui/components/CodeBlock.js.map +1 -0
  145. package/dist/ui/components/ConfigViewer.d.ts +11 -0
  146. package/dist/ui/components/ConfigViewer.d.ts.map +1 -0
  147. package/dist/ui/components/ConfigViewer.js +27 -0
  148. package/dist/ui/components/ConfigViewer.js.map +1 -0
  149. package/dist/ui/components/ConfirmPrompt.d.ts +11 -0
  150. package/dist/ui/components/ConfirmPrompt.d.ts.map +1 -0
  151. package/dist/ui/components/ConfirmPrompt.js +55 -0
  152. package/dist/ui/components/ConfirmPrompt.js.map +1 -0
  153. package/dist/ui/components/DiffViewer.d.ts +8 -0
  154. package/dist/ui/components/DiffViewer.d.ts.map +1 -0
  155. package/dist/ui/components/DiffViewer.js +63 -0
  156. package/dist/ui/components/DiffViewer.js.map +1 -0
  157. package/dist/ui/components/DisplayItemRenderer.d.ts +18 -0
  158. package/dist/ui/components/DisplayItemRenderer.d.ts.map +1 -0
  159. package/dist/ui/components/DisplayItemRenderer.js +53 -0
  160. package/dist/ui/components/DisplayItemRenderer.js.map +1 -0
  161. package/dist/ui/components/DynamicMessage.d.ts +13 -0
  162. package/dist/ui/components/DynamicMessage.d.ts.map +1 -0
  163. package/dist/ui/components/DynamicMessage.js +27 -0
  164. package/dist/ui/components/DynamicMessage.js.map +1 -0
  165. package/dist/ui/components/ErrorBoundary.d.ts +16 -0
  166. package/dist/ui/components/ErrorBoundary.d.ts.map +1 -0
  167. package/dist/ui/components/ErrorBoundary.js +25 -0
  168. package/dist/ui/components/ErrorBoundary.js.map +1 -0
  169. package/dist/ui/components/FileOperation.d.ts +10 -0
  170. package/dist/ui/components/FileOperation.d.ts.map +1 -0
  171. package/dist/ui/components/FileOperation.js +31 -0
  172. package/dist/ui/components/FileOperation.js.map +1 -0
  173. package/dist/ui/components/InputBox.d.ts +12 -0
  174. package/dist/ui/components/InputBox.d.ts.map +1 -0
  175. package/dist/ui/components/InputBox.js +50 -0
  176. package/dist/ui/components/InputBox.js.map +1 -0
  177. package/dist/ui/components/KeyboardHelp.d.ts +7 -0
  178. package/dist/ui/components/KeyboardHelp.d.ts.map +1 -0
  179. package/dist/ui/components/KeyboardHelp.js +25 -0
  180. package/dist/ui/components/KeyboardHelp.js.map +1 -0
  181. package/dist/ui/components/LoadingIndicator.d.ts +3 -0
  182. package/dist/ui/components/LoadingIndicator.d.ts.map +1 -0
  183. package/dist/ui/components/LoadingIndicator.js +25 -0
  184. package/dist/ui/components/LoadingIndicator.js.map +1 -0
  185. package/dist/ui/components/MarkdownRenderer.d.ts +8 -0
  186. package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -0
  187. package/dist/ui/components/MarkdownRenderer.js +96 -0
  188. package/dist/ui/components/MarkdownRenderer.js.map +1 -0
  189. package/dist/ui/components/MessageBox.d.ts +10 -0
  190. package/dist/ui/components/MessageBox.d.ts.map +1 -0
  191. package/dist/ui/components/MessageBox.js +50 -0
  192. package/dist/ui/components/MessageBox.js.map +1 -0
  193. package/dist/ui/components/MessageDisplay.d.ts +8 -0
  194. package/dist/ui/components/MessageDisplay.d.ts.map +1 -0
  195. package/dist/ui/components/MessageDisplay.js +43 -0
  196. package/dist/ui/components/MessageDisplay.js.map +1 -0
  197. package/dist/ui/components/ScrollableContent.d.ts +7 -0
  198. package/dist/ui/components/ScrollableContent.d.ts.map +1 -0
  199. package/dist/ui/components/ScrollableContent.js +6 -0
  200. package/dist/ui/components/ScrollableContent.js.map +1 -0
  201. package/dist/ui/components/ScrollableMessageList.d.ts +10 -0
  202. package/dist/ui/components/ScrollableMessageList.d.ts.map +1 -0
  203. package/dist/ui/components/ScrollableMessageList.js +133 -0
  204. package/dist/ui/components/ScrollableMessageList.js.map +1 -0
  205. package/dist/ui/components/ScrollableScreen.d.ts +9 -0
  206. package/dist/ui/components/ScrollableScreen.d.ts.map +1 -0
  207. package/dist/ui/components/ScrollableScreen.js +22 -0
  208. package/dist/ui/components/ScrollableScreen.js.map +1 -0
  209. package/dist/ui/components/SelectPrompt.d.ts +12 -0
  210. package/dist/ui/components/SelectPrompt.d.ts.map +1 -0
  211. package/dist/ui/components/SelectPrompt.js +10 -0
  212. package/dist/ui/components/SelectPrompt.js.map +1 -0
  213. package/dist/ui/components/StaticMessageHistory.d.ts +14 -0
  214. package/dist/ui/components/StaticMessageHistory.d.ts.map +1 -0
  215. package/dist/ui/components/StaticMessageHistory.js +19 -0
  216. package/dist/ui/components/StaticMessageHistory.js.map +1 -0
  217. package/dist/ui/components/StatusBar.d.ts +10 -0
  218. package/dist/ui/components/StatusBar.d.ts.map +1 -0
  219. package/dist/ui/components/StatusBar.js +20 -0
  220. package/dist/ui/components/StatusBar.js.map +1 -0
  221. package/dist/ui/components/StreamingMessageDisplay.d.ts +13 -0
  222. package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -0
  223. package/dist/ui/components/StreamingMessageDisplay.js +26 -0
  224. package/dist/ui/components/StreamingMessageDisplay.js.map +1 -0
  225. package/dist/ui/components/ToolExecutionMessage.d.ts +8 -0
  226. package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -0
  227. package/dist/ui/components/ToolExecutionMessage.js +189 -0
  228. package/dist/ui/components/ToolExecutionMessage.js.map +1 -0
  229. package/dist/ui/components/ToolExecutionStatus.d.ts +10 -0
  230. package/dist/ui/components/ToolExecutionStatus.d.ts.map +1 -0
  231. package/dist/ui/components/ToolExecutionStatus.js +65 -0
  232. package/dist/ui/components/ToolExecutionStatus.js.map +1 -0
  233. package/dist/ui/components/ToolResult.d.ts +10 -0
  234. package/dist/ui/components/ToolResult.d.ts.map +1 -0
  235. package/dist/ui/components/ToolResult.js +17 -0
  236. package/dist/ui/components/ToolResult.js.map +1 -0
  237. package/dist/ui/components/WelcomeBanner.d.ts +3 -0
  238. package/dist/ui/components/WelcomeBanner.d.ts.map +1 -0
  239. package/dist/ui/components/WelcomeBanner.js +28 -0
  240. package/dist/ui/components/WelcomeBanner.js.map +1 -0
  241. package/dist/ui/components/code-block.d.ts +10 -0
  242. package/dist/ui/components/code-block.d.ts.map +1 -0
  243. package/dist/ui/components/code-block.js +74 -0
  244. package/dist/ui/components/code-block.js.map +1 -0
  245. package/dist/ui/components/confirm-prompt.d.ts +12 -0
  246. package/dist/ui/components/confirm-prompt.d.ts.map +1 -0
  247. package/dist/ui/components/confirm-prompt.js +104 -0
  248. package/dist/ui/components/confirm-prompt.js.map +1 -0
  249. package/dist/ui/components/diff-viewer.d.ts +9 -0
  250. package/dist/ui/components/diff-viewer.d.ts.map +1 -0
  251. package/dist/ui/components/diff-viewer.js +57 -0
  252. package/dist/ui/components/diff-viewer.js.map +1 -0
  253. package/dist/ui/components/input-box.d.ts +18 -0
  254. package/dist/ui/components/input-box.d.ts.map +1 -0
  255. package/dist/ui/components/input-box.js +157 -0
  256. package/dist/ui/components/input-box.js.map +1 -0
  257. package/dist/ui/components/keyboard-help.d.ts +7 -0
  258. package/dist/ui/components/keyboard-help.d.ts.map +1 -0
  259. package/dist/ui/components/keyboard-help.js +43 -0
  260. package/dist/ui/components/keyboard-help.js.map +1 -0
  261. package/dist/ui/components/loading-indicator.d.ts +3 -0
  262. package/dist/ui/components/loading-indicator.d.ts.map +1 -0
  263. package/dist/ui/components/loading-indicator.js +42 -0
  264. package/dist/ui/components/loading-indicator.js.map +1 -0
  265. package/dist/ui/components/message-display.d.ts +7 -0
  266. package/dist/ui/components/message-display.d.ts.map +1 -0
  267. package/dist/ui/components/message-display.js +104 -0
  268. package/dist/ui/components/message-display.js.map +1 -0
  269. package/dist/ui/components/misc.d.ts +28 -0
  270. package/dist/ui/components/misc.d.ts.map +1 -0
  271. package/dist/ui/components/misc.js +128 -0
  272. package/dist/ui/components/misc.js.map +1 -0
  273. package/dist/ui/components/select-prompt.d.ts +13 -0
  274. package/dist/ui/components/select-prompt.d.ts.map +1 -0
  275. package/dist/ui/components/select-prompt.js +42 -0
  276. package/dist/ui/components/select-prompt.js.map +1 -0
  277. package/dist/ui/components/status-bar.d.ts +11 -0
  278. package/dist/ui/components/status-bar.d.ts.map +1 -0
  279. package/dist/ui/components/status-bar.js +47 -0
  280. package/dist/ui/components/status-bar.js.map +1 -0
  281. package/dist/ui/components/tool-execution.d.ts +3 -0
  282. package/dist/ui/components/tool-execution.d.ts.map +1 -0
  283. package/dist/ui/components/tool-execution.js +374 -0
  284. package/dist/ui/components/tool-execution.js.map +1 -0
  285. package/dist/ui/components/tool-result.d.ts +11 -0
  286. package/dist/ui/components/tool-result.d.ts.map +1 -0
  287. package/dist/ui/components/tool-result.js +58 -0
  288. package/dist/ui/components/tool-result.js.map +1 -0
  289. package/dist/ui/components/welcome-banner.d.ts +3 -0
  290. package/dist/ui/components/welcome-banner.d.ts.map +1 -0
  291. package/dist/ui/components/welcome-banner.js +46 -0
  292. package/dist/ui/components/welcome-banner.js.map +1 -0
  293. package/dist/ui/hooks/useDisplayHistory.d.ts +13 -0
  294. package/dist/ui/hooks/useDisplayHistory.d.ts.map +1 -0
  295. package/dist/ui/hooks/useDisplayHistory.js +45 -0
  296. package/dist/ui/hooks/useDisplayHistory.js.map +1 -0
  297. package/dist/ui/render-engine.d.ts +69 -0
  298. package/dist/ui/render-engine.d.ts.map +1 -0
  299. package/dist/ui/render-engine.js +197 -0
  300. package/dist/ui/render-engine.js.map +1 -0
  301. package/dist/ui/terminal/TerminalRenderer.d.ts +84 -0
  302. package/dist/ui/terminal/TerminalRenderer.d.ts.map +1 -0
  303. package/dist/ui/terminal/TerminalRenderer.js +154 -0
  304. package/dist/ui/terminal/TerminalRenderer.js.map +1 -0
  305. package/dist/ui/terminal/TerminalUI.d.ts +139 -0
  306. package/dist/ui/terminal/TerminalUI.d.ts.map +1 -0
  307. package/dist/ui/terminal/TerminalUI.js +430 -0
  308. package/dist/ui/terminal/TerminalUI.js.map +1 -0
  309. package/dist/ui/terminal/VirtualChatBuffer.d.ts +32 -0
  310. package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +1 -0
  311. package/dist/ui/terminal/VirtualChatBuffer.js +37 -0
  312. package/dist/ui/terminal/VirtualChatBuffer.js.map +1 -0
  313. package/dist/ui/terminal-kit-base.d.ts +117 -0
  314. package/dist/ui/terminal-kit-base.d.ts.map +1 -0
  315. package/dist/ui/terminal-kit-base.js +188 -0
  316. package/dist/ui/terminal-kit-base.js.map +1 -0
  317. package/dist/utils/file.d.ts +21 -0
  318. package/dist/utils/file.d.ts.map +1 -0
  319. package/dist/utils/file.js +68 -0
  320. package/dist/utils/file.js.map +1 -0
  321. package/dist/utils/logger.d.ts +17 -0
  322. package/dist/utils/logger.d.ts.map +1 -0
  323. package/dist/utils/logger.js +57 -0
  324. package/dist/utils/logger.js.map +1 -0
  325. package/dist/utils/markdown-parser.d.ts +56 -0
  326. package/dist/utils/markdown-parser.d.ts.map +1 -0
  327. package/dist/utils/markdown-parser.js +307 -0
  328. package/dist/utils/markdown-parser.js.map +1 -0
  329. package/dist/utils/shell.d.ts +7 -0
  330. package/dist/utils/shell.d.ts.map +1 -0
  331. package/dist/utils/shell.js +62 -0
  332. package/dist/utils/shell.js.map +1 -0
  333. package/dist/utils/state.d.ts +13 -0
  334. package/dist/utils/state.d.ts.map +1 -0
  335. package/dist/utils/state.js +25 -0
  336. package/dist/utils/state.js.map +1 -0
  337. package/package.json +81 -0
  338. package/postinstall.js +46 -0
@@ -0,0 +1,117 @@
1
+ import * as shellUtils from '../utils/shell.js';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ export const executeCommandTool = {
5
+ schema: {
6
+ name: 'execute_command',
7
+ description: 'Execute a shell command in the current working directory. The command will be run in the appropriate shell for the operating system.',
8
+ parameters: {
9
+ type: 'object',
10
+ properties: {
11
+ command: {
12
+ type: 'string',
13
+ description: 'The shell command to execute',
14
+ },
15
+ },
16
+ required: ['command'],
17
+ },
18
+ },
19
+ async execute(args, context) {
20
+ const { command } = args;
21
+ // Detect risky commands
22
+ const riskyPatterns = [/rm\s+-rf/, /del\s+\/s/, /format/, /dd\s+if=/];
23
+ const isRisky = riskyPatterns.some(pattern => pattern.test(command));
24
+ const approved = await context.requireApproval(`Execute command: ${command}`, isRisky, undefined, 'execute_command', { command });
25
+ if (!approved) {
26
+ return 'Command execution cancelled by user.';
27
+ }
28
+ // Pass streaming callback to shell execution if available
29
+ const result = await shellUtils.executeCommand(command, context.cwd, context.onStreamingOutput);
30
+ let output = '';
31
+ if (result.stdout && result.stdout.trim()) {
32
+ output += `STDOUT:\n${result.stdout}\n\n`;
33
+ }
34
+ if (result.stderr && result.stderr.trim()) {
35
+ output += `STDERR:\n${result.stderr}\n\n`;
36
+ }
37
+ if (result.exitCode === 0) {
38
+ if (!result.stdout.trim() && !result.stderr.trim()) {
39
+ output += `Command executed successfully (no output)\n`;
40
+ }
41
+ output += `Exit Code: ${result.exitCode} (Success)`;
42
+ }
43
+ else {
44
+ output += `Exit Code: ${result.exitCode} (Failed)`;
45
+ }
46
+ return output;
47
+ },
48
+ };
49
+ export const grepSearchTool = {
50
+ schema: {
51
+ name: 'grep_search',
52
+ description: 'Search for text patterns in files using regex. Returns matching lines with file paths.',
53
+ parameters: {
54
+ type: 'object',
55
+ properties: {
56
+ pattern: {
57
+ type: 'string',
58
+ description: 'The regex pattern to search for',
59
+ },
60
+ directory: {
61
+ type: 'string',
62
+ description: 'Directory to search in (relative to cwd)',
63
+ },
64
+ file_pattern: {
65
+ type: 'string',
66
+ description: 'Optional: File pattern to filter (e.g., "*.ts" for TypeScript files)',
67
+ },
68
+ },
69
+ required: ['pattern'],
70
+ },
71
+ },
72
+ async execute(args, context) {
73
+ const { pattern, directory = '.', file_pattern } = args;
74
+ const searchDir = path.resolve(context.cwd, directory);
75
+ if (!fs.existsSync(searchDir)) {
76
+ throw new Error(`Directory not found: ${directory}`);
77
+ }
78
+ const results = [];
79
+ const regex = new RegExp(pattern, 'gi');
80
+ function searchInFile(filePath) {
81
+ try {
82
+ const content = fs.readFileSync(filePath, 'utf-8');
83
+ const lines = content.split('\n');
84
+ lines.forEach((line, index) => {
85
+ if (regex.test(line)) {
86
+ results.push(`${filePath}:${index + 1}: ${line.trim()}`);
87
+ }
88
+ });
89
+ }
90
+ catch (error) {
91
+ // Skip files that can't be read
92
+ }
93
+ }
94
+ function walkDirectory(dir) {
95
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
96
+ for (const entry of entries) {
97
+ const fullPath = path.join(dir, entry.name);
98
+ if (entry.isDirectory()) {
99
+ if (!entry.name.startsWith('.') && entry.name !== 'node_modules') {
100
+ walkDirectory(fullPath);
101
+ }
102
+ }
103
+ else if (entry.isFile()) {
104
+ if (!file_pattern || entry.name.match(file_pattern)) {
105
+ searchInFile(fullPath);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ walkDirectory(searchDir);
111
+ if (results.length === 0) {
112
+ return `No matches found for pattern: ${pattern}`;
113
+ }
114
+ return `Found ${results.length} matches:\n\n${results.slice(0, 50).join('\n')}${results.length > 50 ? '\n\n... and ' + (results.length - 50) + ' more matches' : ''}`;
115
+ },
116
+ };
117
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/tools/command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,kBAAkB,GAAS;IACtC,MAAM,EAAE;QACN,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,sIAAsI;QACnJ,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8BAA8B;iBAC5C;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO;QACzB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEzB,wBAAwB;QACxB,MAAM,aAAa,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAErE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,eAAe,CAC5C,oBAAoB,OAAO,EAAE,EAC7B,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,EAAE,OAAO,EAAE,CACZ,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,sCAAsC,CAAC;QAChD,CAAC;QAED,0DAA0D;QAC1D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC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,IAAI,OAAO,EAAE,CAAC;gBAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBAE5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;oBACxB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;wBACjE,aAAa,CAAC,QAAQ,CAAC,CAAC;oBAC1B,CAAC;gBACH,CAAC;qBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;oBAC1B,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;wBACpD,YAAY,CAAC,QAAQ,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,aAAa,CAAC,SAAS,CAAC,CAAC;QAEzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,iCAAiC,OAAO,EAAE,CAAC;QACpD,CAAC;QAED,OAAO,SAAS,OAAO,CAAC,MAAM,gBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAC3E,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,EACnF,EAAE,CAAC;IACL,CAAC;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Tool } from './types.js';
2
+ export declare const readFileTool: Tool;
3
+ export declare const writeFileTool: Tool;
4
+ export declare const editFileTool: Tool;
5
+ export declare const listDirectoryTool: Tool;
6
+ //# sourceMappingURL=file-ops-test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops-test.d.ts","sourceRoot":"","sources":["../../src/tools/file-ops-test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,eAAO,MAAM,YAAY,EAAE,IAoC1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,IAgG3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,IA+E1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,IAkC/B,CAAC"}
@@ -0,0 +1,197 @@
1
+ import * as path from 'path';
2
+ import * as fs from 'fs';
3
+ import * as fileUtils from '../utils/file.js';
4
+ import * as Diff from 'diff';
5
+ export const readFileTool = {
6
+ schema: {
7
+ name: 'read_file',
8
+ description: 'Read the contents of a file at the specified path. Supports optional line range parameters.',
9
+ parameters: {
10
+ type: 'object',
11
+ properties: {
12
+ file_path: {
13
+ type: 'string',
14
+ description: 'The path to the file to read (relative to current working directory)',
15
+ },
16
+ start_line: {
17
+ type: 'number',
18
+ description: 'Optional: Starting line number (1-indexed)',
19
+ },
20
+ end_line: {
21
+ type: 'number',
22
+ description: 'Optional: Ending line number (1-indexed)',
23
+ },
24
+ },
25
+ required: ['file_path'],
26
+ },
27
+ },
28
+ async execute(args, context) {
29
+ const { file_path, start_line, end_line } = args;
30
+ const fullPath = path.resolve(context.cwd, file_path);
31
+ if (!fs.existsSync(fullPath)) {
32
+ throw new Error(`File not found: ${file_path}`);
33
+ }
34
+ const content = fileUtils.readFile(fullPath, start_line, end_line);
35
+ const lineCount = content.split('\n').length;
36
+ return `File: ${file_path}\nLines: ${lineCount}\n\n${content}`;
37
+ },
38
+ };
39
+ export const writeFileTool = {
40
+ schema: {
41
+ name: 'write_file',
42
+ description: 'Create a new file or overwrite an existing file with the provided content.',
43
+ parameters: {
44
+ type: 'object',
45
+ properties: {
46
+ file_path: {
47
+ type: 'string',
48
+ description: 'The path where the file should be created/written',
49
+ },
50
+ content: {
51
+ type: 'string',
52
+ description: 'The complete content to write to the file',
53
+ },
54
+ },
55
+ required: ['file_path', 'content'],
56
+ },
57
+ },
58
+ async execute(args, context) {
59
+ const { file_path, content } = args;
60
+ const fullPath = path.resolve(context.cwd, file_path);
61
+ // Ask for approval if file exists
62
+ if (fs.existsSync(fullPath)) {
63
+ // ===============================================
64
+ // FIX: Changed from 'code' preview to 'diff' preview
65
+ // This matches the working pattern used by edit_file and new file creation
66
+ // ===============================================
67
+ // Read existing file content for diff generation
68
+ const oldContent = fs.readFileSync(fullPath, 'utf-8');
69
+ // Generate unified diff showing changes (old content vs new content)
70
+ // This uses the same Diff.createTwoFilesPatch() that edit_file uses
71
+ const patch = Diff.createTwoFilesPatch(file_path, file_path, oldContent, content, 'Current', 'New');
72
+ // Request approval with diff preview (type: 'diff' instead of 'code')
73
+ // This will use DiffViewer component which properly handles alt screen
74
+ const result = await context.requireApproval(`File ${file_path} already exists. Overwrite it?`, true, {
75
+ type: 'diff',
76
+ content: patch
77
+ }, 'write_file', { file_path, operation: 'overwrite' });
78
+ if (typeof result === 'object' && 'feedback' in result) {
79
+ // User provided feedback - throw special error with feedback
80
+ throw new Error(`USER_FEEDBACK: ${result.feedback}`);
81
+ }
82
+ if (!result) {
83
+ return 'Operation cancelled by user.';
84
+ }
85
+ }
86
+ else {
87
+ // Ask for approval to create new file with diff format (all lines as additions)
88
+ // Generate a diff showing all new lines with + prefix
89
+ const lines = content.split('\n');
90
+ const diffLines = lines.map(line => `+${line}`);
91
+ const diffContent = `--- /dev/null\n+++ ${file_path}\n@@ -0,0 +1,${lines.length} @@\n${diffLines.join('\n')}`;
92
+ const result = await context.requireApproval(`Create new file ${file_path}?`, false, {
93
+ type: 'diff',
94
+ content: diffContent
95
+ }, 'write_file', { file_path, operation: 'create' });
96
+ if (typeof result === 'object' && 'feedback' in result) {
97
+ // User provided feedback - throw special error with feedback
98
+ throw new Error(`USER_FEEDBACK: ${result.feedback}`);
99
+ }
100
+ if (!result) {
101
+ return 'Operation cancelled by user.';
102
+ }
103
+ }
104
+ fileUtils.writeFile(fullPath, content);
105
+ return `Successfully wrote ${content.length} characters to ${file_path}`;
106
+ },
107
+ };
108
+ export const editFileTool = {
109
+ schema: {
110
+ name: 'edit_file',
111
+ description: 'Search for a specific pattern in a file and replace it with new content. Shows a diff preview before applying.',
112
+ parameters: {
113
+ type: 'object',
114
+ properties: {
115
+ file_path: {
116
+ type: 'string',
117
+ description: 'The path to the file to edit',
118
+ },
119
+ search_pattern: {
120
+ type: 'string',
121
+ description: 'The exact text to search for (must appear exactly once)',
122
+ },
123
+ replacement: {
124
+ type: 'string',
125
+ description: 'The text to replace the search pattern with',
126
+ },
127
+ },
128
+ required: ['file_path', 'search_pattern', 'replacement'],
129
+ },
130
+ },
131
+ async execute(args, context) {
132
+ const { file_path, search_pattern, replacement } = args;
133
+ const fullPath = path.resolve(context.cwd, file_path);
134
+ if (!fs.existsSync(fullPath)) {
135
+ throw new Error(`File not found: ${file_path}`);
136
+ }
137
+ // Read the current content
138
+ const oldContent = fs.readFileSync(fullPath, 'utf-8');
139
+ // Check if pattern exists
140
+ if (!oldContent.includes(search_pattern)) {
141
+ throw new Error(`Pattern not found in file: ${search_pattern.substring(0, 100)}`);
142
+ }
143
+ // Count occurrences
144
+ const occurrences = oldContent.split(search_pattern).length - 1;
145
+ if (occurrences > 1) {
146
+ throw new Error(`Pattern appears ${occurrences} times. Please use a more specific pattern.`);
147
+ }
148
+ // Create the new content
149
+ const newContent = oldContent.replace(search_pattern, replacement);
150
+ // Build unified diff text for preview
151
+ const patch = Diff.createTwoFilesPatch(file_path, file_path, oldContent, newContent, '', '');
152
+ // Ask for approval with diff preview
153
+ const approved = await context.requireApproval(`Apply these changes to ${file_path}?`, false, {
154
+ type: 'diff',
155
+ content: patch
156
+ }, 'edit_file', { file_path });
157
+ if (!approved) {
158
+ return 'Operation cancelled by user.';
159
+ }
160
+ // Apply the changes
161
+ fs.writeFileSync(fullPath, newContent, 'utf-8');
162
+ return `Successfully replaced pattern in ${file_path}`;
163
+ },
164
+ };
165
+ export const listDirectoryTool = {
166
+ schema: {
167
+ name: 'list_directory',
168
+ description: 'List the contents of a directory.',
169
+ parameters: {
170
+ type: 'object',
171
+ properties: {
172
+ directory_path: {
173
+ type: 'string',
174
+ description: 'The path to the directory to list (relative to cwd)',
175
+ },
176
+ recursive: {
177
+ type: 'boolean',
178
+ description: 'Whether to list subdirectories recursively',
179
+ },
180
+ },
181
+ required: ['directory_path'],
182
+ },
183
+ },
184
+ async execute(args, context) {
185
+ const { directory_path, recursive = false } = args;
186
+ const fullPath = path.resolve(context.cwd, directory_path);
187
+ if (!fs.existsSync(fullPath)) {
188
+ throw new Error(`Directory not found: ${directory_path}`);
189
+ }
190
+ if (!fs.statSync(fullPath).isDirectory()) {
191
+ throw new Error(`Path is not a directory: ${directory_path}`);
192
+ }
193
+ const contents = fileUtils.listDirectory(fullPath, recursive);
194
+ return `Directory: ${directory_path}\nTotal items: ${contents.length}\n\n${contents.join('\n')}`;
195
+ },
196
+ };
197
+ //# sourceMappingURL=file-ops-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops-test.js","sourceRoot":"","sources":["../../src/tools/file-ops-test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,YAAY,GAAS;IAChC,MAAM,EAAE;QACN,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,6FAA6F;QAC1G,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sEAAsE;iBACpF;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4CAA4C;iBAC1D;gBACD,QAAQ,EA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c,cAAc,kBAAkB,QAAQ,CAAC,MAAM,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IACnG,CAAC;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Tool } from './types.js';
2
+ export declare const readFileTool: Tool;
3
+ export declare const writeFileTool: Tool;
4
+ export declare const editFileTool: Tool;
5
+ export declare const listDirectoryTool: Tool;
6
+ //# sourceMappingURL=file-ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops.d.ts","sourceRoot":"","sources":["../../src/tools/file-ops.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,eAAO,MAAM,YAAY,EAAE,IAoC1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,IA8E3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,IA+E1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,IAkC/B,CAAC"}
@@ -0,0 +1,189 @@
1
+ import * as path from 'path';
2
+ import * as fs from 'fs';
3
+ import * as fileUtils from '../utils/file.js';
4
+ import * as Diff from 'diff';
5
+ export const readFileTool = {
6
+ schema: {
7
+ name: 'read_file',
8
+ description: 'Read the contents of a file at the specified path. Supports optional line range parameters.',
9
+ parameters: {
10
+ type: 'object',
11
+ properties: {
12
+ file_path: {
13
+ type: 'string',
14
+ description: 'The path to the file to read (relative to current working directory)',
15
+ },
16
+ start_line: {
17
+ type: 'number',
18
+ description: 'Optional: Starting line number (1-indexed)',
19
+ },
20
+ end_line: {
21
+ type: 'number',
22
+ description: 'Optional: Ending line number (1-indexed)',
23
+ },
24
+ },
25
+ required: ['file_path'],
26
+ },
27
+ },
28
+ async execute(args, context) {
29
+ const { file_path, start_line, end_line } = args;
30
+ const fullPath = path.resolve(context.cwd, file_path);
31
+ if (!fs.existsSync(fullPath)) {
32
+ throw new Error(`File not found: ${file_path}`);
33
+ }
34
+ const content = fileUtils.readFile(fullPath, start_line, end_line);
35
+ const lineCount = content.split('\n').length;
36
+ return `File: ${file_path}\nLines: ${lineCount}\n\n${content}`;
37
+ },
38
+ };
39
+ export const writeFileTool = {
40
+ schema: {
41
+ name: 'write_file',
42
+ description: 'Create a new file or overwrite an existing file with the provided content.',
43
+ parameters: {
44
+ type: 'object',
45
+ properties: {
46
+ file_path: {
47
+ type: 'string',
48
+ description: 'The path where the file should be created/written',
49
+ },
50
+ content: {
51
+ type: 'string',
52
+ description: 'The complete content to write to the file',
53
+ },
54
+ },
55
+ required: ['file_path', 'content'],
56
+ },
57
+ },
58
+ async execute(args, context) {
59
+ const { file_path, content } = args;
60
+ const fullPath = path.resolve(context.cwd, file_path);
61
+ // Ask for approval if file exists
62
+ if (fs.existsSync(fullPath)) {
63
+ // Show preview of new content for overwrite
64
+ const language = file_path.split('.').pop() || 'text';
65
+ const result = await context.requireApproval(`File ${file_path} already exists. Overwrite it?`, true, {
66
+ type: 'code',
67
+ content,
68
+ language
69
+ }, 'write_file', { file_path, operation: 'overwrite' });
70
+ if (typeof result === 'object' && 'feedback' in result) {
71
+ // User provided feedback - throw special error with feedback
72
+ throw new Error(`USER_FEEDBACK: ${result.feedback}`);
73
+ }
74
+ if (!result) {
75
+ return 'Operation cancelled by user.';
76
+ }
77
+ }
78
+ else {
79
+ // Ask for approval to create new file with diff format (all lines as additions)
80
+ // Generate a diff showing all new lines with + prefix
81
+ const lines = content.split('\n');
82
+ const diffLines = lines.map(line => `+${line}`);
83
+ const diffContent = `--- /dev/null\n+++ ${file_path}\n@@ -0,0 +1,${lines.length} @@\n${diffLines.join('\n')}`;
84
+ const result = await context.requireApproval(`Create new file ${file_path}?`, false, {
85
+ type: 'diff',
86
+ content: diffContent
87
+ }, 'write_file', { file_path, operation: 'create' });
88
+ if (typeof result === 'object' && 'feedback' in result) {
89
+ // User provided feedback - throw special error with feedback
90
+ throw new Error(`USER_FEEDBACK: ${result.feedback}`);
91
+ }
92
+ if (!result) {
93
+ return 'Operation cancelled by user.';
94
+ }
95
+ }
96
+ fileUtils.writeFile(fullPath, content);
97
+ return `Successfully wrote ${content.length} characters to ${file_path}`;
98
+ },
99
+ };
100
+ export const editFileTool = {
101
+ schema: {
102
+ name: 'edit_file',
103
+ description: 'Search for a specific pattern in a file and replace it with new content. Shows a diff preview before applying.',
104
+ parameters: {
105
+ type: 'object',
106
+ properties: {
107
+ file_path: {
108
+ type: 'string',
109
+ description: 'The path to the file to edit',
110
+ },
111
+ search_pattern: {
112
+ type: 'string',
113
+ description: 'The exact text to search for (must appear exactly once)',
114
+ },
115
+ replacement: {
116
+ type: 'string',
117
+ description: 'The text to replace the search pattern with',
118
+ },
119
+ },
120
+ required: ['file_path', 'search_pattern', 'replacement'],
121
+ },
122
+ },
123
+ async execute(args, context) {
124
+ const { file_path, search_pattern, replacement } = args;
125
+ const fullPath = path.resolve(context.cwd, file_path);
126
+ if (!fs.existsSync(fullPath)) {
127
+ throw new Error(`File not found: ${file_path}`);
128
+ }
129
+ // Read the current content
130
+ const oldContent = fs.readFileSync(fullPath, 'utf-8');
131
+ // Check if pattern exists
132
+ if (!oldContent.includes(search_pattern)) {
133
+ throw new Error(`Pattern not found in file: ${search_pattern.substring(0, 100)}`);
134
+ }
135
+ // Count occurrences
136
+ const occurrences = oldContent.split(search_pattern).length - 1;
137
+ if (occurrences > 1) {
138
+ throw new Error(`Pattern appears ${occurrences} times. Please use a more specific pattern.`);
139
+ }
140
+ // Create the new content
141
+ const newContent = oldContent.replace(search_pattern, replacement);
142
+ // Build unified diff text for preview
143
+ const patch = Diff.createTwoFilesPatch(file_path, file_path, oldContent, newContent, '', '');
144
+ // Ask for approval with diff preview
145
+ const approved = await context.requireApproval(`Apply these changes to ${file_path}?`, false, {
146
+ type: 'diff',
147
+ content: patch
148
+ }, 'edit_file', { file_path });
149
+ if (!approved) {
150
+ return 'Operation cancelled by user.';
151
+ }
152
+ // Apply the changes
153
+ fs.writeFileSync(fullPath, newContent, 'utf-8');
154
+ return `Successfully replaced pattern in ${file_path}`;
155
+ },
156
+ };
157
+ export const listDirectoryTool = {
158
+ schema: {
159
+ name: 'list_directory',
160
+ description: 'List the contents of a directory.',
161
+ parameters: {
162
+ type: 'object',
163
+ properties: {
164
+ directory_path: {
165
+ type: 'string',
166
+ description: 'The path to the directory to list (relative to cwd)',
167
+ },
168
+ recursive: {
169
+ type: 'boolean',
170
+ description: 'Whether to list subdirectories recursively',
171
+ },
172
+ },
173
+ required: ['directory_path'],
174
+ },
175
+ },
176
+ async execute(args, context) {
177
+ const { directory_path, recursive = false } = args;
178
+ const fullPath = path.resolve(context.cwd, directory_path);
179
+ if (!fs.existsSync(fullPath)) {
180
+ throw new Error(`Directory not found: ${directory_path}`);
181
+ }
182
+ if (!fs.statSync(fullPath).isDirectory()) {
183
+ throw new Error(`Path is not a directory: ${directory_path}`);
184
+ }
185
+ const contents = fileUtils.listDirectory(fullPath, recursive);
186
+ return `Directory: ${directory_path}\nTotal items: ${contents.length}\n\n${contents.join('\n')}`;
187
+ },
188
+ };
189
+ //# sourceMappingURL=file-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops.js","sourceRoot":"","sources":["../../src/tools/file-ops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,YAAY,GAAS;IAChC,MAAM,EAAE;QACN,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,6FAA6F;QAC1G,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sEAAsE;iBACpF;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4CAA4C;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
+ */
5
+ import { Tool } from './types.js';
6
+ export interface PlanStep {
7
+ id: string;
8
+ description: string;
9
+ status: 'pending' | 'in_progress' | 'completed' | 'skipped';
10
+ estimatedComplexity?: 'low' | 'medium' | 'high';
11
+ }
12
+ export interface Plan {
13
+ title: string;
14
+ summary: string;
15
+ steps: PlanStep[];
16
+ createdAt: Date;
17
+ approved?: boolean;
18
+ }
19
+ /**
20
+ * Exit Plan Mode tool
21
+ * Similar to Claude Code's ExitPlanMode - prompts user to approve the plan before proceeding
22
+ */
23
+ export declare const exitPlanModeTool: Tool;
24
+ /**
25
+ * Get current plan status
26
+ */
27
+ export declare const getPlanStatusTool: Tool;
28
+ /**
29
+ * Update plan step status
30
+ */
31
+ export declare const updatePlanStepTool: Tool;
32
+ /**
33
+ * Approve the current plan
34
+ */
35
+ export declare function approvePlan(): void;
36
+ /**
37
+ * Clear the current plan
38
+ */
39
+ export declare function clearPlan(): void;
40
+ /**
41
+ * Get the current plan
42
+ */
43
+ export declare function getCurrentPlan(): Plan | null;
44
+ declare const _default: {
45
+ exitPlanModeTool: Tool;
46
+ getPlanStatusTool: Tool;
47
+ updatePlanStepTool: Tool;
48
+ approvePlan: typeof approvePlan;
49
+ clearPlan: typeof clearPlan;
50
+ getCurrentPlan: typeof getCurrentPlan;
51
+ };
52
+ export default _default;
53
+ //# sourceMappingURL=plan-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-mode.d.ts","sourceRoot":"","sources":["../../src/tools/plan-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAwB,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;IAC5D,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACjD;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAID;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,IAsF9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,IAsC/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,IAkDhC,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAIlC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,GAAG,IAAI,CAE5C;;;;;;;;;AAED,wBAOE"}