centaurus-cli 3.0.1 → 3.1.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 (552) hide show
  1. package/dist/ai/types.js +0 -1
  2. package/dist/ai/types.js.map +1 -1
  3. package/dist/cli-adapter.js +5047 -5158
  4. package/dist/cli-adapter.js.map +1 -1
  5. package/dist/commands/CommandParser.js +372 -315
  6. package/dist/commands/CommandParser.js.map +1 -1
  7. package/dist/config/build-config.js +11 -42
  8. package/dist/config/build-config.js.map +1 -1
  9. package/dist/config/defaultConfig.js +94 -82
  10. package/dist/config/defaultConfig.js.map +1 -1
  11. package/dist/config/manager.js +144 -160
  12. package/dist/config/manager.js.map +1 -1
  13. package/dist/config/mcp-config-manager.js +411 -364
  14. package/dist/config/mcp-config-manager.js.map +1 -1
  15. package/dist/config/models.js +118 -185
  16. package/dist/config/models.js.map +1 -1
  17. package/dist/config/slash-commands.js +186 -184
  18. package/dist/config/slash-commands.js.map +1 -1
  19. package/dist/config/types.js +33 -26
  20. package/dist/config/types.js.map +1 -1
  21. package/dist/context/command-detector.js +63 -67
  22. package/dist/context/command-detector.js.map +1 -1
  23. package/dist/context/context-manager.js +533 -518
  24. package/dist/context/context-manager.js.map +1 -1
  25. package/dist/context/handlers/docker-handler.js +518 -576
  26. package/dist/context/handlers/docker-handler.js.map +1 -1
  27. package/dist/context/handlers/ssh-handler.js +1050 -1109
  28. package/dist/context/handlers/ssh-handler.js.map +1 -1
  29. package/dist/context/handlers/wsl-handler.js +558 -630
  30. package/dist/context/handlers/wsl-handler.js.map +1 -1
  31. package/dist/context/index.js +42 -6
  32. package/dist/context/index.js.map +1 -1
  33. package/dist/context/subshell-handler.js +0 -4
  34. package/dist/context/subshell-handler.js.map +1 -1
  35. package/dist/context/types.js +20 -31
  36. package/dist/context/types.js.map +1 -1
  37. package/dist/hooks/useConnectivity.js +13 -10
  38. package/dist/hooks/useConnectivity.js.map +1 -1
  39. package/dist/hooks/useTerminalDimensions.js +67 -79
  40. package/dist/hooks/useTerminalDimensions.js.map +1 -1
  41. package/dist/index.js +228 -251
  42. package/dist/index.js.map +1 -1
  43. package/dist/mcp/mcp-command-handler.js +297 -260
  44. package/dist/mcp/mcp-command-handler.js.map +1 -1
  45. package/dist/mcp/mcp-server-manager.js +139 -155
  46. package/dist/mcp/mcp-server-manager.js.map +1 -1
  47. package/dist/mcp/mcp-tool-wrapper.js +74 -94
  48. package/dist/mcp/mcp-tool-wrapper.js.map +1 -1
  49. package/dist/services/ai-autocomplete-agent.js +169 -181
  50. package/dist/services/ai-autocomplete-agent.js.map +1 -1
  51. package/dist/services/ai-context-injector.js +180 -93
  52. package/dist/services/ai-context-injector.js.map +1 -1
  53. package/dist/services/ai-service-client.js +513 -456
  54. package/dist/services/ai-service-client.js.map +1 -1
  55. package/dist/services/api-client.js +443 -441
  56. package/dist/services/api-client.js.map +1 -1
  57. package/dist/services/auth-handler.js +162 -198
  58. package/dist/services/auth-handler.js.map +1 -1
  59. package/dist/services/background-task-manager.js +258 -282
  60. package/dist/services/background-task-manager.js.map +1 -1
  61. package/dist/services/checkpoint-manager.js +1526 -1512
  62. package/dist/services/checkpoint-manager.js.map +1 -1
  63. package/dist/services/clipboard-service.js +151 -200
  64. package/dist/services/clipboard-service.js.map +1 -1
  65. package/dist/services/connectivity-manager.js +63 -65
  66. package/dist/services/connectivity-manager.js.map +1 -1
  67. package/dist/services/conversation-manager.js +118 -121
  68. package/dist/services/conversation-manager.js.map +1 -1
  69. package/dist/services/environment-context-injector.js +160 -187
  70. package/dist/services/environment-context-injector.js.map +1 -1
  71. package/dist/services/fast-context-agent.js +203 -243
  72. package/dist/services/fast-context-agent.js.map +1 -1
  73. package/dist/services/input-detection-agent.js +190 -202
  74. package/dist/services/input-detection-agent.js.map +1 -1
  75. package/dist/services/input-requirement-detector.js +155 -189
  76. package/dist/services/input-requirement-detector.js.map +1 -1
  77. package/dist/services/local-chat-storage.js +342 -365
  78. package/dist/services/local-chat-storage.js.map +1 -1
  79. package/dist/services/monitored-shell-manager.js +225 -233
  80. package/dist/services/monitored-shell-manager.js.map +1 -1
  81. package/dist/services/ollama-service.js +293 -310
  82. package/dist/services/ollama-service.js.map +1 -1
  83. package/dist/services/rules-storage.js +142 -0
  84. package/dist/services/rules-storage.js.map +1 -0
  85. package/dist/services/session-quota-manager.js +219 -235
  86. package/dist/services/session-quota-manager.js.map +1 -1
  87. package/dist/services/shell-input-agent.js +299 -334
  88. package/dist/services/shell-input-agent.js.map +1 -1
  89. package/dist/services/sub-agent-manager.js +459 -501
  90. package/dist/services/sub-agent-manager.js.map +1 -1
  91. package/dist/services/warpify-detector.js +133 -183
  92. package/dist/services/warpify-detector.js.map +1 -1
  93. package/dist/services/workflow-storage.js +202 -217
  94. package/dist/services/workflow-storage.js.map +1 -1
  95. package/dist/test-ssh-handler.js +148 -193
  96. package/dist/test-ssh-handler.js.map +1 -1
  97. package/dist/tools/add-mcp.js +161 -0
  98. package/dist/tools/add-mcp.js.map +1 -0
  99. package/dist/tools/background-command.js +240 -273
  100. package/dist/tools/background-command.js.map +1 -1
  101. package/dist/tools/command.js +447 -440
  102. package/dist/tools/command.js.map +1 -1
  103. package/dist/tools/create-image.js +172 -202
  104. package/dist/tools/create-image.js.map +1 -1
  105. package/dist/tools/enter-remote-session.js +169 -215
  106. package/dist/tools/enter-remote-session.js.map +1 -1
  107. package/dist/tools/fast-context.js +60 -67
  108. package/dist/tools/fast-context.js.map +1 -1
  109. package/dist/tools/file-ops.js +601 -572
  110. package/dist/tools/file-ops.js.map +1 -1
  111. package/dist/tools/find-files.js +262 -303
  112. package/dist/tools/find-files.js.map +1 -1
  113. package/dist/tools/get-diff.js +423 -406
  114. package/dist/tools/get-diff.js.map +1 -1
  115. package/dist/tools/grep-search.js +966 -948
  116. package/dist/tools/grep-search.js.map +1 -1
  117. package/dist/tools/inspect-symbol.js +308 -323
  118. package/dist/tools/inspect-symbol.js.map +1 -1
  119. package/dist/tools/plan-mode.js +459 -503
  120. package/dist/tools/plan-mode.js.map +1 -1
  121. package/dist/tools/read-binary-file.js +160 -190
  122. package/dist/tools/read-binary-file.js.map +1 -1
  123. package/dist/tools/registry.js +100 -84
  124. package/dist/tools/registry.js.map +1 -1
  125. package/dist/tools/reproduce_issue.js +170 -151
  126. package/dist/tools/reproduce_issue.js.map +1 -1
  127. package/dist/tools/sub-agent.js +223 -228
  128. package/dist/tools/sub-agent.js.map +1 -1
  129. package/dist/tools/task-complete.js +28 -27
  130. package/dist/tools/task-complete.js.map +1 -1
  131. package/dist/tools/types.js +0 -1
  132. package/dist/tools/types.js.map +1 -1
  133. package/dist/tools/validation.js +96 -118
  134. package/dist/tools/validation.js.map +1 -1
  135. package/dist/tools/web-search.js +194 -194
  136. package/dist/tools/web-search.js.map +1 -1
  137. package/dist/tools/workflow-tool.js +77 -82
  138. package/dist/tools/workflow-tool.js.map +1 -1
  139. package/dist/types/index.js +0 -1
  140. package/dist/types/index.js.map +1 -1
  141. package/dist/types/rule.js +1 -0
  142. package/dist/types/rule.js.map +1 -0
  143. package/dist/types/workflow.js +0 -7
  144. package/dist/types/workflow.js.map +1 -1
  145. package/dist/ui/components/AgentTimer.js +24 -25
  146. package/dist/ui/components/AgentTimer.js.map +1 -1
  147. package/dist/ui/components/App.js +3266 -3263
  148. package/dist/ui/components/App.js.map +1 -1
  149. package/dist/ui/components/AuthScreen.js +22 -34
  150. package/dist/ui/components/AuthScreen.js.map +1 -1
  151. package/dist/ui/components/AuthWelcomeScreen.js +30 -24
  152. package/dist/ui/components/AuthWelcomeScreen.js.map +1 -1
  153. package/dist/ui/components/Breadcrumbs.js +53 -82
  154. package/dist/ui/components/Breadcrumbs.js.map +1 -1
  155. package/dist/ui/components/CircularSelectInput.js +59 -67
  156. package/dist/ui/components/CircularSelectInput.js.map +1 -1
  157. package/dist/ui/components/ClipboardFileAutocomplete.js +78 -39
  158. package/dist/ui/components/ClipboardFileAutocomplete.js.map +1 -1
  159. package/dist/ui/components/CodeBlock.js +24 -42
  160. package/dist/ui/components/CodeBlock.js.map +1 -1
  161. package/dist/ui/components/ConfigViewer.js +18 -25
  162. package/dist/ui/components/ConfigViewer.js.map +1 -1
  163. package/dist/ui/components/ConfirmPrompt.js +49 -71
  164. package/dist/ui/components/ConfirmPrompt.js.map +1 -1
  165. package/dist/ui/components/ConnectionStatusMessage.js +32 -83
  166. package/dist/ui/components/ConnectionStatusMessage.js.map +1 -1
  167. package/dist/ui/components/ContextWindowIndicator.js +34 -49
  168. package/dist/ui/components/ContextWindowIndicator.js.map +1 -1
  169. package/dist/ui/components/DetailedPlanReviewScreen.js +104 -106
  170. package/dist/ui/components/DetailedPlanReviewScreen.js.map +1 -1
  171. package/dist/ui/components/DiffViewer.js +68 -121
  172. package/dist/ui/components/DiffViewer.js.map +1 -1
  173. package/dist/ui/components/ErrorBoundary.js +40 -48
  174. package/dist/ui/components/ErrorBoundary.js.map +1 -1
  175. package/dist/ui/components/FileCreationPreview.js +29 -60
  176. package/dist/ui/components/FileCreationPreview.js.map +1 -1
  177. package/dist/ui/components/FileOperation.js +34 -29
  178. package/dist/ui/components/FileOperation.js.map +1 -1
  179. package/dist/ui/components/FileTagAutocomplete.js +55 -25
  180. package/dist/ui/components/FileTagAutocomplete.js.map +1 -1
  181. package/dist/ui/components/FontRecommendation.js.map +1 -1
  182. package/dist/ui/components/GitDiffBreadcrumb.js +29 -0
  183. package/dist/ui/components/GitDiffBreadcrumb.js.map +1 -0
  184. package/dist/ui/components/InputBox.js +1620 -2150
  185. package/dist/ui/components/InputBox.js.map +1 -1
  186. package/dist/ui/components/InteractiveShell.js +234 -352
  187. package/dist/ui/components/InteractiveShell.js.map +1 -1
  188. package/dist/ui/components/KeyboardHelp.js +34 -35
  189. package/dist/ui/components/KeyboardHelp.js.map +1 -1
  190. package/dist/ui/components/LoadingIndicator.js +22 -25
  191. package/dist/ui/components/LoadingIndicator.js.map +1 -1
  192. package/dist/ui/components/MCPAddScreen.js +40 -51
  193. package/dist/ui/components/MCPAddScreen.js.map +1 -1
  194. package/dist/ui/components/MCPListScreen.js +40 -48
  195. package/dist/ui/components/MCPListScreen.js.map +1 -1
  196. package/dist/ui/components/MCPServerListScreen.js +49 -56
  197. package/dist/ui/components/MCPServerListScreen.js.map +1 -1
  198. package/dist/ui/components/MarkdownRenderer.js +69 -96
  199. package/dist/ui/components/MarkdownRenderer.js.map +1 -1
  200. package/dist/ui/components/MessageBox.js +66 -48
  201. package/dist/ui/components/MessageBox.js.map +1 -1
  202. package/dist/ui/components/MessageDisplay.js +150 -142
  203. package/dist/ui/components/MessageDisplay.js.map +1 -1
  204. package/dist/ui/components/MonitorModeAIPanel.js +46 -65
  205. package/dist/ui/components/MonitorModeAIPanel.js.map +1 -1
  206. package/dist/ui/components/MultiLineInput.js +243 -277
  207. package/dist/ui/components/MultiLineInput.js.map +1 -1
  208. package/dist/ui/components/PasswordPrompt.js +37 -18
  209. package/dist/ui/components/PasswordPrompt.js.map +1 -1
  210. package/dist/ui/components/PlanAcceptedMessage.js +27 -38
  211. package/dist/ui/components/PlanAcceptedMessage.js.map +1 -1
  212. package/dist/ui/components/PlanReviewScreen.js +46 -50
  213. package/dist/ui/components/PlanReviewScreen.js.map +1 -1
  214. package/dist/ui/components/RulesEditorScreen.js +81 -0
  215. package/dist/ui/components/RulesEditorScreen.js.map +1 -0
  216. package/dist/ui/components/SelectPrompt.js +19 -8
  217. package/dist/ui/components/SelectPrompt.js.map +1 -1
  218. package/dist/ui/components/ShimmerText.js +44 -0
  219. package/dist/ui/components/ShimmerText.js.map +1 -0
  220. package/dist/ui/components/SlashCommandAutocomplete.js +49 -22
  221. package/dist/ui/components/SlashCommandAutocomplete.js.map +1 -1
  222. package/dist/ui/components/StatusBar.js +56 -87
  223. package/dist/ui/components/StatusBar.js.map +1 -1
  224. package/dist/ui/components/StreamingMessageDisplay.js +116 -99
  225. package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
  226. package/dist/ui/components/TaskCompletedMessage.js +28 -23
  227. package/dist/ui/components/TaskCompletedMessage.js.map +1 -1
  228. package/dist/ui/components/TaskProgressIndicator.js +44 -70
  229. package/dist/ui/components/TaskProgressIndicator.js.map +1 -1
  230. package/dist/ui/components/ThinkingDisplay.js +44 -41
  231. package/dist/ui/components/ThinkingDisplay.js.map +1 -1
  232. package/dist/ui/components/ToolExecutionMessage.js +772 -1326
  233. package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
  234. package/dist/ui/components/ToolExecutionStatus.js +53 -84
  235. package/dist/ui/components/ToolExecutionStatus.js.map +1 -1
  236. package/dist/ui/components/ToolResult.js +22 -15
  237. package/dist/ui/components/ToolResult.js.map +1 -1
  238. package/dist/ui/components/VersionUpdatePrompt.js +88 -120
  239. package/dist/ui/components/VersionUpdatePrompt.js.map +1 -1
  240. package/dist/ui/components/WelcomeBanner.js +176 -26
  241. package/dist/ui/components/WelcomeBanner.js.map +1 -1
  242. package/dist/ui/components/WorkflowCreatorScreen.js +94 -161
  243. package/dist/ui/components/WorkflowCreatorScreen.js.map +1 -1
  244. package/dist/utils/ansi-encoder.js +30 -61
  245. package/dist/utils/ansi-encoder.js.map +1 -1
  246. package/dist/utils/chat-formatter.js +327 -305
  247. package/dist/utils/chat-formatter.js.map +1 -1
  248. package/dist/utils/command-history.js +152 -174
  249. package/dist/utils/command-history.js.map +1 -1
  250. package/dist/utils/context-sanitizer.js +49 -112
  251. package/dist/utils/context-sanitizer.js.map +1 -1
  252. package/dist/utils/conversation-logger.js +292 -324
  253. package/dist/utils/conversation-logger.js.map +1 -1
  254. package/dist/utils/custom-commands-manager.js +126 -131
  255. package/dist/utils/custom-commands-manager.js.map +1 -1
  256. package/dist/utils/editor-utils.js +732 -837
  257. package/dist/utils/editor-utils.js.map +1 -1
  258. package/dist/utils/file.js +174 -213
  259. package/dist/utils/file.js.map +1 -1
  260. package/dist/utils/git-stats.js +169 -0
  261. package/dist/utils/git-stats.js.map +1 -0
  262. package/dist/utils/input-classifier.js +960 -482
  263. package/dist/utils/input-classifier.js.map +1 -1
  264. package/dist/utils/logger.js +48 -73
  265. package/dist/utils/logger.js.map +1 -1
  266. package/dist/utils/markdown-parser.js +277 -310
  267. package/dist/utils/markdown-parser.js.map +1 -1
  268. package/dist/utils/rule-reference-resolver.js +54 -0
  269. package/dist/utils/rule-reference-resolver.js.map +1 -0
  270. package/dist/utils/shell.js +144 -156
  271. package/dist/utils/shell.js.map +1 -1
  272. package/dist/utils/state.js +23 -22
  273. package/dist/utils/state.js.map +1 -1
  274. package/dist/utils/syntax-checker.js +279 -327
  275. package/dist/utils/syntax-checker.js.map +1 -1
  276. package/dist/utils/terminal-output.js +199 -302
  277. package/dist/utils/terminal-output.js.map +1 -1
  278. package/dist/utils/text-clipboard.js +47 -70
  279. package/dist/utils/text-clipboard.js.map +1 -1
  280. package/dist/utils/unicode-sanitizer.js +134 -197
  281. package/dist/utils/unicode-sanitizer.js.map +1 -1
  282. package/dist/utils/version-checker.js +46 -56
  283. package/dist/utils/version-checker.js.map +1 -1
  284. package/package.json +6 -4
  285. package/dist/ai/types.d.ts +0 -20
  286. package/dist/ai/types.d.ts.map +0 -1
  287. package/dist/cli-adapter.d.ts +0 -514
  288. package/dist/cli-adapter.d.ts.map +0 -1
  289. package/dist/commands/CommandParser.d.ts +0 -27
  290. package/dist/commands/CommandParser.d.ts.map +0 -1
  291. package/dist/config/build-config.d.ts +0 -42
  292. package/dist/config/build-config.d.ts.map +0 -1
  293. package/dist/config/defaultConfig.d.ts +0 -79
  294. package/dist/config/defaultConfig.d.ts.map +0 -1
  295. package/dist/config/manager.d.ts +0 -62
  296. package/dist/config/manager.d.ts.map +0 -1
  297. package/dist/config/mcp-config-manager.d.ts +0 -79
  298. package/dist/config/mcp-config-manager.d.ts.map +0 -1
  299. package/dist/config/models.d.ts +0 -83
  300. package/dist/config/models.d.ts.map +0 -1
  301. package/dist/config/slash-commands.d.ts +0 -23
  302. package/dist/config/slash-commands.d.ts.map +0 -1
  303. package/dist/config/types.d.ts +0 -35
  304. package/dist/config/types.d.ts.map +0 -1
  305. package/dist/context/command-detector.d.ts +0 -50
  306. package/dist/context/command-detector.d.ts.map +0 -1
  307. package/dist/context/context-manager.d.ts +0 -157
  308. package/dist/context/context-manager.d.ts.map +0 -1
  309. package/dist/context/handlers/docker-handler.d.ts +0 -130
  310. package/dist/context/handlers/docker-handler.d.ts.map +0 -1
  311. package/dist/context/handlers/ssh-handler.d.ts +0 -201
  312. package/dist/context/handlers/ssh-handler.d.ts.map +0 -1
  313. package/dist/context/handlers/wsl-handler.d.ts +0 -146
  314. package/dist/context/handlers/wsl-handler.d.ts.map +0 -1
  315. package/dist/context/index.d.ts +0 -8
  316. package/dist/context/index.d.ts.map +0 -1
  317. package/dist/context/subshell-handler.d.ts +0 -165
  318. package/dist/context/subshell-handler.d.ts.map +0 -1
  319. package/dist/context/types.d.ts +0 -70
  320. package/dist/context/types.d.ts.map +0 -1
  321. package/dist/hooks/useConnectivity.d.ts +0 -2
  322. package/dist/hooks/useConnectivity.d.ts.map +0 -1
  323. package/dist/hooks/useTerminalDimensions.d.ts +0 -41
  324. package/dist/hooks/useTerminalDimensions.d.ts.map +0 -1
  325. package/dist/index.d.ts +0 -9
  326. package/dist/index.d.ts.map +0 -1
  327. package/dist/mcp/mcp-command-handler.d.ts +0 -47
  328. package/dist/mcp/mcp-command-handler.d.ts.map +0 -1
  329. package/dist/mcp/mcp-server-manager.d.ts +0 -30
  330. package/dist/mcp/mcp-server-manager.d.ts.map +0 -1
  331. package/dist/mcp/mcp-tool-wrapper.d.ts +0 -12
  332. package/dist/mcp/mcp-tool-wrapper.d.ts.map +0 -1
  333. package/dist/services/ai-autocomplete-agent.d.ts +0 -39
  334. package/dist/services/ai-autocomplete-agent.d.ts.map +0 -1
  335. package/dist/services/ai-context-injector.d.ts +0 -41
  336. package/dist/services/ai-context-injector.d.ts.map +0 -1
  337. package/dist/services/ai-service-client.d.ts +0 -128
  338. package/dist/services/ai-service-client.d.ts.map +0 -1
  339. package/dist/services/api-client.d.ts +0 -353
  340. package/dist/services/api-client.d.ts.map +0 -1
  341. package/dist/services/auth-handler.d.ts +0 -30
  342. package/dist/services/auth-handler.d.ts.map +0 -1
  343. package/dist/services/background-task-manager.d.ts +0 -114
  344. package/dist/services/background-task-manager.d.ts.map +0 -1
  345. package/dist/services/checkpoint-manager.d.ts +0 -204
  346. package/dist/services/checkpoint-manager.d.ts.map +0 -1
  347. package/dist/services/clipboard-service.d.ts +0 -37
  348. package/dist/services/clipboard-service.d.ts.map +0 -1
  349. package/dist/services/connectivity-manager.d.ts +0 -18
  350. package/dist/services/connectivity-manager.d.ts.map +0 -1
  351. package/dist/services/conversation-manager.d.ts +0 -73
  352. package/dist/services/conversation-manager.d.ts.map +0 -1
  353. package/dist/services/environment-context-injector.d.ts +0 -69
  354. package/dist/services/environment-context-injector.d.ts.map +0 -1
  355. package/dist/services/fast-context-agent.d.ts +0 -12
  356. package/dist/services/fast-context-agent.d.ts.map +0 -1
  357. package/dist/services/input-detection-agent.d.ts +0 -40
  358. package/dist/services/input-detection-agent.d.ts.map +0 -1
  359. package/dist/services/input-requirement-detector.d.ts +0 -28
  360. package/dist/services/input-requirement-detector.d.ts.map +0 -1
  361. package/dist/services/local-chat-storage.d.ts +0 -182
  362. package/dist/services/local-chat-storage.d.ts.map +0 -1
  363. package/dist/services/monitored-shell-manager.d.ts +0 -120
  364. package/dist/services/monitored-shell-manager.d.ts.map +0 -1
  365. package/dist/services/ollama-service.d.ts +0 -197
  366. package/dist/services/ollama-service.d.ts.map +0 -1
  367. package/dist/services/session-quota-manager.d.ts +0 -101
  368. package/dist/services/session-quota-manager.d.ts.map +0 -1
  369. package/dist/services/shell-input-agent.d.ts +0 -89
  370. package/dist/services/shell-input-agent.d.ts.map +0 -1
  371. package/dist/services/sub-agent-manager.d.ts +0 -140
  372. package/dist/services/sub-agent-manager.d.ts.map +0 -1
  373. package/dist/services/warpify-detector.d.ts +0 -43
  374. package/dist/services/warpify-detector.d.ts.map +0 -1
  375. package/dist/services/workflow-storage.d.ts +0 -72
  376. package/dist/services/workflow-storage.d.ts.map +0 -1
  377. package/dist/test-ssh-handler.d.ts +0 -8
  378. package/dist/test-ssh-handler.d.ts.map +0 -1
  379. package/dist/tools/background-command.d.ts +0 -11
  380. package/dist/tools/background-command.d.ts.map +0 -1
  381. package/dist/tools/command.d.ts +0 -3
  382. package/dist/tools/command.d.ts.map +0 -1
  383. package/dist/tools/create-image.d.ts +0 -10
  384. package/dist/tools/create-image.d.ts.map +0 -1
  385. package/dist/tools/enter-remote-session.d.ts +0 -48
  386. package/dist/tools/enter-remote-session.d.ts.map +0 -1
  387. package/dist/tools/fast-context.d.ts +0 -3
  388. package/dist/tools/fast-context.d.ts.map +0 -1
  389. package/dist/tools/file-ops.d.ts +0 -7
  390. package/dist/tools/file-ops.d.ts.map +0 -1
  391. package/dist/tools/find-files.d.ts +0 -49
  392. package/dist/tools/find-files.d.ts.map +0 -1
  393. package/dist/tools/get-diff.d.ts +0 -14
  394. package/dist/tools/get-diff.d.ts.map +0 -1
  395. package/dist/tools/grep-search.d.ts +0 -155
  396. package/dist/tools/grep-search.d.ts.map +0 -1
  397. package/dist/tools/inspect-symbol.d.ts +0 -32
  398. package/dist/tools/inspect-symbol.d.ts.map +0 -1
  399. package/dist/tools/plan-mode.d.ts +0 -140
  400. package/dist/tools/plan-mode.d.ts.map +0 -1
  401. package/dist/tools/read-binary-file.d.ts +0 -10
  402. package/dist/tools/read-binary-file.d.ts.map +0 -1
  403. package/dist/tools/registry.d.ts +0 -31
  404. package/dist/tools/registry.d.ts.map +0 -1
  405. package/dist/tools/reproduce_issue.d.ts +0 -2
  406. package/dist/tools/reproduce_issue.d.ts.map +0 -1
  407. package/dist/tools/sub-agent.d.ts +0 -9
  408. package/dist/tools/sub-agent.d.ts.map +0 -1
  409. package/dist/tools/task-complete.d.ts +0 -3
  410. package/dist/tools/task-complete.d.ts.map +0 -1
  411. package/dist/tools/types.d.ts +0 -40
  412. package/dist/tools/types.d.ts.map +0 -1
  413. package/dist/tools/validation.d.ts +0 -47
  414. package/dist/tools/validation.d.ts.map +0 -1
  415. package/dist/tools/web-search.d.ts +0 -24
  416. package/dist/tools/web-search.d.ts.map +0 -1
  417. package/dist/tools/workflow-tool.d.ts +0 -11
  418. package/dist/tools/workflow-tool.d.ts.map +0 -1
  419. package/dist/types/index.d.ts +0 -123
  420. package/dist/types/index.d.ts.map +0 -1
  421. package/dist/types/workflow.d.ts +0 -110
  422. package/dist/types/workflow.d.ts.map +0 -1
  423. package/dist/ui/components/AgentTimer.d.ts +0 -7
  424. package/dist/ui/components/AgentTimer.d.ts.map +0 -1
  425. package/dist/ui/components/App.d.ts +0 -197
  426. package/dist/ui/components/App.d.ts.map +0 -1
  427. package/dist/ui/components/AuthScreen.d.ts +0 -8
  428. package/dist/ui/components/AuthScreen.d.ts.map +0 -1
  429. package/dist/ui/components/AuthWelcomeScreen.d.ts +0 -8
  430. package/dist/ui/components/AuthWelcomeScreen.d.ts.map +0 -1
  431. package/dist/ui/components/Breadcrumbs.d.ts +0 -13
  432. package/dist/ui/components/Breadcrumbs.d.ts.map +0 -1
  433. package/dist/ui/components/CircularSelectInput.d.ts +0 -24
  434. package/dist/ui/components/CircularSelectInput.d.ts.map +0 -1
  435. package/dist/ui/components/ClipboardFileAutocomplete.d.ts +0 -10
  436. package/dist/ui/components/ClipboardFileAutocomplete.d.ts.map +0 -1
  437. package/dist/ui/components/CodeBlock.d.ts +0 -9
  438. package/dist/ui/components/CodeBlock.d.ts.map +0 -1
  439. package/dist/ui/components/ConfigViewer.d.ts +0 -11
  440. package/dist/ui/components/ConfigViewer.d.ts.map +0 -1
  441. package/dist/ui/components/ConfirmPrompt.d.ts +0 -13
  442. package/dist/ui/components/ConfirmPrompt.d.ts.map +0 -1
  443. package/dist/ui/components/ConnectionStatusMessage.d.ts +0 -17
  444. package/dist/ui/components/ConnectionStatusMessage.d.ts.map +0 -1
  445. package/dist/ui/components/ContextWindowIndicator.d.ts +0 -8
  446. package/dist/ui/components/ContextWindowIndicator.d.ts.map +0 -1
  447. package/dist/ui/components/DetailedPlanReviewScreen.d.ts +0 -17
  448. package/dist/ui/components/DetailedPlanReviewScreen.d.ts.map +0 -1
  449. package/dist/ui/components/DiffViewer.d.ts +0 -9
  450. package/dist/ui/components/DiffViewer.d.ts.map +0 -1
  451. package/dist/ui/components/ErrorBoundary.d.ts +0 -17
  452. package/dist/ui/components/ErrorBoundary.d.ts.map +0 -1
  453. package/dist/ui/components/FileCreationPreview.d.ts +0 -8
  454. package/dist/ui/components/FileCreationPreview.d.ts.map +0 -1
  455. package/dist/ui/components/FileOperation.d.ts +0 -10
  456. package/dist/ui/components/FileOperation.d.ts.map +0 -1
  457. package/dist/ui/components/FileTagAutocomplete.d.ts +0 -11
  458. package/dist/ui/components/FileTagAutocomplete.d.ts.map +0 -1
  459. package/dist/ui/components/FontRecommendation.d.ts +0 -1
  460. package/dist/ui/components/FontRecommendation.d.ts.map +0 -1
  461. package/dist/ui/components/InputBox.d.ts +0 -42
  462. package/dist/ui/components/InputBox.d.ts.map +0 -1
  463. package/dist/ui/components/InteractiveShell.d.ts +0 -30
  464. package/dist/ui/components/InteractiveShell.d.ts.map +0 -1
  465. package/dist/ui/components/KeyboardHelp.d.ts +0 -7
  466. package/dist/ui/components/KeyboardHelp.d.ts.map +0 -1
  467. package/dist/ui/components/LoadingIndicator.d.ts +0 -3
  468. package/dist/ui/components/LoadingIndicator.d.ts.map +0 -1
  469. package/dist/ui/components/MCPAddScreen.d.ts +0 -13
  470. package/dist/ui/components/MCPAddScreen.d.ts.map +0 -1
  471. package/dist/ui/components/MCPListScreen.d.ts +0 -17
  472. package/dist/ui/components/MCPListScreen.d.ts.map +0 -1
  473. package/dist/ui/components/MCPServerListScreen.d.ts +0 -16
  474. package/dist/ui/components/MCPServerListScreen.d.ts.map +0 -1
  475. package/dist/ui/components/MarkdownRenderer.d.ts +0 -8
  476. package/dist/ui/components/MarkdownRenderer.d.ts.map +0 -1
  477. package/dist/ui/components/MessageBox.d.ts +0 -10
  478. package/dist/ui/components/MessageBox.d.ts.map +0 -1
  479. package/dist/ui/components/MessageDisplay.d.ts +0 -14
  480. package/dist/ui/components/MessageDisplay.d.ts.map +0 -1
  481. package/dist/ui/components/MonitorModeAIPanel.d.ts +0 -23
  482. package/dist/ui/components/MonitorModeAIPanel.d.ts.map +0 -1
  483. package/dist/ui/components/MultiLineInput.d.ts +0 -13
  484. package/dist/ui/components/MultiLineInput.d.ts.map +0 -1
  485. package/dist/ui/components/PasswordPrompt.d.ts +0 -9
  486. package/dist/ui/components/PasswordPrompt.d.ts.map +0 -1
  487. package/dist/ui/components/PlanAcceptedMessage.d.ts +0 -20
  488. package/dist/ui/components/PlanAcceptedMessage.d.ts.map +0 -1
  489. package/dist/ui/components/PlanReviewScreen.d.ts +0 -14
  490. package/dist/ui/components/PlanReviewScreen.d.ts.map +0 -1
  491. package/dist/ui/components/SelectPrompt.d.ts +0 -12
  492. package/dist/ui/components/SelectPrompt.d.ts.map +0 -1
  493. package/dist/ui/components/SlashCommandAutocomplete.d.ts +0 -13
  494. package/dist/ui/components/SlashCommandAutocomplete.d.ts.map +0 -1
  495. package/dist/ui/components/StatusBar.d.ts +0 -14
  496. package/dist/ui/components/StatusBar.d.ts.map +0 -1
  497. package/dist/ui/components/StreamingMessageDisplay.d.ts +0 -15
  498. package/dist/ui/components/StreamingMessageDisplay.d.ts.map +0 -1
  499. package/dist/ui/components/TaskCompletedMessage.d.ts +0 -14
  500. package/dist/ui/components/TaskCompletedMessage.d.ts.map +0 -1
  501. package/dist/ui/components/TaskProgressIndicator.d.ts +0 -18
  502. package/dist/ui/components/TaskProgressIndicator.d.ts.map +0 -1
  503. package/dist/ui/components/ThinkingDisplay.d.ts +0 -15
  504. package/dist/ui/components/ThinkingDisplay.d.ts.map +0 -1
  505. package/dist/ui/components/ToolExecutionMessage.d.ts +0 -8
  506. package/dist/ui/components/ToolExecutionMessage.d.ts.map +0 -1
  507. package/dist/ui/components/ToolExecutionStatus.d.ts +0 -10
  508. package/dist/ui/components/ToolExecutionStatus.d.ts.map +0 -1
  509. package/dist/ui/components/ToolResult.d.ts +0 -10
  510. package/dist/ui/components/ToolResult.d.ts.map +0 -1
  511. package/dist/ui/components/VersionUpdatePrompt.d.ts +0 -9
  512. package/dist/ui/components/VersionUpdatePrompt.d.ts.map +0 -1
  513. package/dist/ui/components/WelcomeBanner.d.ts +0 -3
  514. package/dist/ui/components/WelcomeBanner.d.ts.map +0 -1
  515. package/dist/ui/components/WorkflowCreatorScreen.d.ts +0 -25
  516. package/dist/ui/components/WorkflowCreatorScreen.d.ts.map +0 -1
  517. package/dist/utils/ansi-encoder.d.ts +0 -7
  518. package/dist/utils/ansi-encoder.d.ts.map +0 -1
  519. package/dist/utils/chat-formatter.d.ts +0 -12
  520. package/dist/utils/chat-formatter.d.ts.map +0 -1
  521. package/dist/utils/command-history.d.ts +0 -24
  522. package/dist/utils/command-history.d.ts.map +0 -1
  523. package/dist/utils/context-sanitizer.d.ts +0 -50
  524. package/dist/utils/context-sanitizer.d.ts.map +0 -1
  525. package/dist/utils/conversation-logger.d.ts +0 -142
  526. package/dist/utils/conversation-logger.d.ts.map +0 -1
  527. package/dist/utils/custom-commands-manager.d.ts +0 -59
  528. package/dist/utils/custom-commands-manager.d.ts.map +0 -1
  529. package/dist/utils/editor-utils.d.ts +0 -101
  530. package/dist/utils/editor-utils.d.ts.map +0 -1
  531. package/dist/utils/file.d.ts +0 -61
  532. package/dist/utils/file.d.ts.map +0 -1
  533. package/dist/utils/input-classifier.d.ts +0 -25
  534. package/dist/utils/input-classifier.d.ts.map +0 -1
  535. package/dist/utils/logger.d.ts +0 -17
  536. package/dist/utils/logger.d.ts.map +0 -1
  537. package/dist/utils/markdown-parser.d.ts +0 -60
  538. package/dist/utils/markdown-parser.d.ts.map +0 -1
  539. package/dist/utils/shell.d.ts +0 -47
  540. package/dist/utils/shell.d.ts.map +0 -1
  541. package/dist/utils/state.d.ts +0 -13
  542. package/dist/utils/state.d.ts.map +0 -1
  543. package/dist/utils/syntax-checker.d.ts +0 -24
  544. package/dist/utils/syntax-checker.d.ts.map +0 -1
  545. package/dist/utils/terminal-output.d.ts +0 -25
  546. package/dist/utils/terminal-output.d.ts.map +0 -1
  547. package/dist/utils/text-clipboard.d.ts +0 -12
  548. package/dist/utils/text-clipboard.d.ts.map +0 -1
  549. package/dist/utils/unicode-sanitizer.d.ts +0 -44
  550. package/dist/utils/unicode-sanitizer.d.ts.map +0 -1
  551. package/dist/utils/version-checker.d.ts +0 -14
  552. package/dist/utils/version-checker.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"environment-context-injector.js","sourceRoot":"","sources":["../../src/services/environment-context-injector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAW,MAAM,IAAI,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAgBlC;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IAC7B,aAAa,GAAsC,IAAI,CAAC;IACxD,OAAO,GAAW,EAAE,CAAC;IAE7B;;;;OAIG;IACH,aAAa,CAAC,WAAoB;QAChC,MAAM,UAAU,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAEhD,8CAA8C;QAC9C,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YACtD,oCAAoC;YACpC,OAAO;gBACL,GAAG,IAAI,CAAC,aAAa;gBACrB,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aAC/B,CAAC;QACJ,CAAC;QAED,uBAAuB;QACvB,MAAM,OAAO,GAA+B;YAC1C,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE;YAC3B,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE;YAC3B,KAAK,EAAE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,CAAC;YACvB,OAAO,YAAY,CAAC,CAAC,iCAAiC;QACxD,CAAC;QAED,OAAO,MAAM,CAAC,CAAC,2CAA2C;IAC5D,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,oCAAoC;YACpC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,SAAS,CAAC;QAC/D,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,iBAAiB,CAAC,GAAW;QACnC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,QAAQ,CAAC,+BAA+B,EAAE;gBACxD,GAAG;gBACH,QAAQ,EAAE,OAAO;gBACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;aAClC,CAAC,CAAC,IAAI,EAAE,CAAC;YAEV,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,sCAAsC;YACtC,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
1
+ {"version":3,"sources":["../../src/services/environment-context-injector.ts"],"sourcesContent":["/**\r\n * Environment Context Injector\r\n * \r\n * Detects runtime environment information (OS, shell, CWD, git root, etc.)\r\n * and formats it for injection into the system prompt to provide the AI\r\n * with context about the user's environment.\r\n */\r\n\r\nimport { platform, type, release, userInfo, homedir } from 'os';\r\nimport { execSync } from 'child_process';\r\nimport { readFileSync } from 'fs';\r\nimport { join } from 'path';\r\n\r\n/**\r\n * Enhanced environment context with detailed system information\r\n */\r\nexport interface EnhancedEnvironmentContext {\r\n osName: string; // e.g., \"Windows 11\", \"Ubuntu 22.04\"\r\n osType: string; // e.g., \"Windows\", \"Linux\", \"Darwin\"\r\n shell: string; // e.g., \"PowerShell\", \"bash\", \"zsh\"\r\n username: string; // Current user\r\n cwd: string; // Current working directory\r\n projectRoot: string; // Git root or CWD if not in git repo\r\n date: string; // Current date in ISO format\r\n}\r\n\r\n/**\r\n * Environment Context Injector class\r\n * Handles detection and formatting of environment context for AI prompts\r\n */\r\nexport class EnvironmentContextInjector {\r\n private cachedContext: EnhancedEnvironmentContext | null = null;\r\n private lastCwd: string = '';\r\n\r\n /**\r\n * Detect current environment context\r\n * Uses caching to avoid re-detecting on every request\r\n * Updates cache when CWD changes\r\n */\r\n detectContext(cwdOverride?: string): EnhancedEnvironmentContext {\r\n const currentCwd = cwdOverride || process.cwd();\r\n\r\n // Return cached context if CWD hasn't changed\r\n if (this.cachedContext && this.lastCwd === currentCwd) {\r\n // Update date even when using cache\r\n return {\r\n ...this.cachedContext,\r\n date: new Date().toISOString(),\r\n };\r\n }\r\n\r\n // Detect fresh context\r\n const context: EnhancedEnvironmentContext = {\r\n osName: this.detectOSName(),\r\n osType: this.detectOSType(),\r\n shell: this.detectShell(),\r\n username: this.detectUsername(),\r\n cwd: currentCwd,\r\n projectRoot: this.detectProjectRoot(currentCwd),\r\n date: new Date().toISOString(),\r\n };\r\n\r\n // Cache the context\r\n this.cachedContext = context;\r\n this.lastCwd = currentCwd;\r\n\r\n return context;\r\n }\r\n\r\n /**\r\n * Format context as structured markdown block for system prompt\r\n */\r\n formatContextBlock(context: EnhancedEnvironmentContext): string {\r\n let block = '\\n\\n# ENVIRONMENT CONTEXT\\n\\n';\r\n block += 'The following information describes your current execution environment:\\n\\n';\r\n block += `- **Operating System**: ${context.osName} (${context.osType})\\n`;\r\n block += `- **Shell**: ${context.shell}\\n`;\r\n block += `- **Username**: ${context.username}\\n`;\r\n block += `- **Current Working Directory**: ${context.cwd}\\n`;\r\n block += `- **Project Root**: ${context.projectRoot}\\n`;\r\n block += `- **Current Date**: ${context.date}\\n`;\r\n block += '\\n';\r\n block += '**Important**: Use this context to generate platform-specific commands and appropriate file paths.\\n';\r\n block += 'All file operations and commands will execute relative to the Current Working Directory.\\n\\n';\r\n\r\n return block;\r\n }\r\n\r\n /**\r\n * Get enhanced system prompt with injected environment context\r\n * Prepends context block to the base system prompt\r\n */\r\n getEnhancedSystemPrompt(basePrompt: string, cwdOverride?: string): string {\r\n const context = this.detectContext(cwdOverride);\r\n const contextBlock = this.formatContextBlock(context);\r\n\r\n // Prepend context block to base prompt\r\n return contextBlock + basePrompt;\r\n }\r\n\r\n /**\r\n * Detect detailed OS name with version\r\n */\r\n private detectOSName(): string {\r\n const osType = platform();\r\n const osRelease = release();\r\n\r\n try {\r\n if (osType === 'win32') {\r\n // Try to get Windows version name\r\n const version = execSync('wmic os get Caption', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] });\r\n const match = version.match(/Microsoft Windows [^\\r\\n]+/);\r\n if (match) {\r\n return match[0].trim();\r\n }\r\n return `Windows ${osRelease}`;\r\n } else if (osType === 'darwin') {\r\n // macOS\r\n const version = execSync('sw_vers -productVersion', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] });\r\n return `macOS ${version.trim()}`;\r\n } else if (osType === 'linux') {\r\n // Try to read /etc/os-release for Linux distribution info\r\n try {\r\n const osReleaseContent = readFileSync('/etc/os-release', 'utf-8');\r\n const prettyNameMatch = osReleaseContent.match(/PRETTY_NAME=\"([^\"]+)\"/);\r\n if (prettyNameMatch) {\r\n return prettyNameMatch[1];\r\n }\r\n } catch {\r\n // Fall through to generic Linux\r\n }\r\n return `Linux ${osRelease}`;\r\n }\r\n } catch (error) {\r\n // Fall back to basic info if detection fails\r\n }\r\n\r\n return `${type()} ${osRelease}`;\r\n }\r\n\r\n /**\r\n * Detect OS type (simplified)\r\n */\r\n private detectOSType(): string {\r\n const osType = platform();\r\n\r\n if (osType === 'win32') return 'Windows';\r\n if (osType === 'darwin') return 'Darwin';\r\n if (osType === 'linux') return 'Linux';\r\n\r\n return type();\r\n }\r\n\r\n /**\r\n * Detect current shell\r\n */\r\n private detectShell(): string {\r\n // Check SHELL environment variable (Unix-like systems)\r\n if (process.env.SHELL) {\r\n const shellPath = process.env.SHELL;\r\n const shellName = shellPath.split('/').pop() || shellPath.split('\\\\').pop();\r\n return shellName || 'unknown';\r\n }\r\n\r\n // Check for PowerShell on Windows\r\n if (process.env.PSModulePath) {\r\n return 'PowerShell';\r\n }\r\n\r\n // Check COMSPEC for Windows Command Prompt\r\n if (process.env.COMSPEC) {\r\n const comspec = process.env.COMSPEC;\r\n if (comspec.toLowerCase().includes('cmd.exe')) {\r\n return 'cmd';\r\n }\r\n }\r\n\r\n // Fallback: detect from platform\r\n const osType = platform();\r\n if (osType === 'win32') {\r\n return 'PowerShell'; // Default assumption for Windows\r\n }\r\n\r\n return 'bash'; // Default assumption for Unix-like systems\r\n }\r\n\r\n /**\r\n * Detect current username\r\n */\r\n private detectUsername(): string {\r\n try {\r\n const user = userInfo();\r\n return user.username;\r\n } catch (error) {\r\n // Fallback to environment variables\r\n return process.env.USER || process.env.USERNAME || 'unknown';\r\n }\r\n }\r\n\r\n /**\r\n * Detect git repository root\r\n * Falls back to CWD if not in a git repository\r\n */\r\n private detectProjectRoot(cwd: string): string {\r\n try {\r\n const gitRoot = execSync('git rev-parse --show-toplevel', {\r\n cwd,\r\n encoding: 'utf-8',\r\n stdio: ['pipe', 'pipe', 'ignore'],\r\n }).trim();\r\n\r\n return gitRoot;\r\n } catch (error) {\r\n // Not in a git repository, return CWD\r\n return cwd;\r\n }\r\n }\r\n\r\n /**\r\n * Clear cached context (useful for testing or manual refresh)\r\n */\r\n clearCache(): void {\r\n this.cachedContext = null;\r\n this.lastCwd = '';\r\n }\r\n}\r\n\r\n// Export singleton instance\r\nexport const environ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9B,YAAM,YAAY,UAAU,MAAM,GAAG,EAAE,IAAI,KAAK,UAAU,MAAM,IAAI,EAAE,IAAI;AAC1E,aAAO,aAAa;AAAA,IACtB;AAGA,QAAI,QAAQ,IAAI,cAAc;AAC5B,aAAO;AAAA,IACT;AAGA,QAAI,QAAQ,IAAI,SAAS;AACvB,YAAM,UAAU,QAAQ,IAAI;AAC5B,UAAI,QAAQ,YAAY,EAAE,SAAS,SAAS,GAAG;AAC7C,eAAO;AAAA,MACT;AAAA,IACF;AAGA,UAAM,SAAS,SAAS;AACxB,QAAI,WAAW,SAAS;AACtB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,iBAAyB;AAC/B,QAAI;AACF,YAAM,OAAO,SAAS;AACtB,aAAO,KAAK;AAAA,IACd,SAAS,OAAO;AAEd,aAAO,QAAQ,IAAI,QAAQ,QAAQ,IAAI,YAAY;AAAA,IACrD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,kBAAkB,KAAqB;AAC7C,QAAI;AACF,YAAM,UAAU,SAAS,iCAAiC;AAAA,QACxD;AAAA,QACA,UAAU;AAAA,QACV,OAAO,CAAC,QAAQ,QAAQ,QAAQ;AAAA,MAClC,CAAC,EAAE,KAAK;AAER,aAAO;AAAA,IACT,SAAS,OAAO;AAEd,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,aAAmB;AACjB,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AACF;AAGO,MAAM,6BAA6B,IAAI,2BAA2B;","names":[]}
@@ -1,253 +1,213 @@
1
- import { aiServiceClient } from './ai-service-client.js';
2
- import * as os from 'os';
3
- export class FastContextAgent {
4
- toolRegistry;
5
- model = 'zai-org/glm-4.7-maas';
6
- constructor(toolRegistry) {
7
- this.toolRegistry = toolRegistry;
8
- }
9
- sanitizeOutput(output) {
10
- // Remove null bytes and other non-printable characters that might cause Vertex AI errors
11
- // Keep newlines, tabs, and standard printable characters
12
- return output.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '');
13
- }
14
- parseFilesFromOutput(toolName, output) {
15
- const files = [];
16
- const lines = output.split('\n');
17
- if (toolName === 'grep_search') {
18
- // Grep often returns "file:line:content" or just "file"
19
- // We need to be careful not to match line numbers or context
20
- for (const line of lines) {
21
- const trimmed = line.trim();
22
- if (!trimmed)
23
- continue;
24
- // Skip lines that look like just numbers (common in some grep outputs for counts)
25
- if (/^\d+$/.test(trimmed))
26
- continue;
27
- // Typical grep output with line number: "path/to/file.ts:123: content"
28
- // Or just path: "path/to/file.ts"
29
- // Heuristic: take part before the first colon, or the whole line if no colon
30
- // But avoid "Found 5 matches" type lines
31
- if (trimmed.startsWith('Found ') || trimmed.startsWith('Match '))
32
- continue;
33
- const parts = trimmed.split(':');
34
- const candidate = parts[0].trim();
35
- // Validate candidate is likely a file path
36
- // Should have an extension or contain path separators, and NOT be just numbers
37
- if (this.isValidFilePath(candidate)) {
38
- files.push(candidate);
39
- }
40
- }
1
+ import { aiServiceClient } from "./ai-service-client.js";
2
+ import * as os from "os";
3
+ class FastContextAgent {
4
+ toolRegistry;
5
+ model = "zai-org/glm-4.7-maas";
6
+ constructor(toolRegistry) {
7
+ this.toolRegistry = toolRegistry;
8
+ }
9
+ sanitizeOutput(output) {
10
+ return output.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "");
11
+ }
12
+ parseFilesFromOutput(toolName, output) {
13
+ const files = [];
14
+ const lines = output.split("\n");
15
+ if (toolName === "grep_search") {
16
+ for (const line of lines) {
17
+ const trimmed = line.trim();
18
+ if (!trimmed) continue;
19
+ if (/^\d+$/.test(trimmed)) continue;
20
+ if (trimmed.startsWith("Found ") || trimmed.startsWith("Match ")) continue;
21
+ const parts = trimmed.split(":");
22
+ const candidate = parts[0].trim();
23
+ if (this.isValidFilePath(candidate)) {
24
+ files.push(candidate);
41
25
  }
42
- else if (toolName === 'find_files') {
43
- // find_files usually returns one file per line
44
- for (const line of lines) {
45
- const trimmed = line.trim();
46
- if (this.isValidFilePath(trimmed)) {
47
- files.push(trimmed);
48
- }
49
- }
26
+ }
27
+ } else if (toolName === "find_files") {
28
+ for (const line of lines) {
29
+ const trimmed = line.trim();
30
+ if (this.isValidFilePath(trimmed)) {
31
+ files.push(trimmed);
50
32
  }
51
- else if (toolName === 'view_file' || toolName === 'read_file') {
52
- // We can't easily extracting the filename from the output content unless it's in the header
53
- // The tool output usually starts with "File: <path>"
54
- const match = output.match(/^File: (.+)/);
55
- if (match) {
56
- files.push(match[1]);
57
- }
58
- }
59
- return files;
60
- }
61
- isValidFilePath(pathStr) {
62
- // Basic validation:
63
- // 1. Not empty
64
- // 2. Not just numbers
65
- // 3. Not a common system message (e.g. "No matches")
66
- // 4. Has some file-like characteristics (extension or path separator) OR just is a string that doesn't look like garbage
67
- if (!pathStr || pathStr.length === 0)
68
- return false;
69
- if (/^\d+$/.test(pathStr))
70
- return false; // purely numeric
71
- if (pathStr.includes('No matches') || pathStr.includes('Found '))
72
- return false;
73
- // Exclude common noise
74
- if (pathStr.startsWith('Total:') || pathStr.startsWith('Size:'))
75
- return false;
76
- // Exclude grep output noise
77
- if (pathStr.includes('(showing first') && pathStr.includes('matches)'))
78
- return false;
79
- return true;
33
+ }
34
+ } else if (toolName === "view_file" || toolName === "read_file") {
35
+ const match = output.match(/^File: (.+)/);
36
+ if (match) {
37
+ files.push(match[1]);
38
+ }
80
39
  }
81
- async search(query, workingDirectory, parentContext) {
82
- const startTime = Date.now();
83
- const scannedFiles = new Set();
84
- // Import logger if not already imported at the top of the file
85
- // We'll use console.log here or logInfo/logDebug if available
86
- const logToTerminal = (msg) => {
87
- if (parentContext.onStreamingOutput) {
88
- // Pass debug logging through stderr or a custom type so it's visible in logs
89
- parentContext.onStreamingOutput(`[FastContextAgent] ${msg}\n`, 'stderr', 'fast_context_search');
90
- }
91
- };
92
- logToTerminal(`Starting search for query: "${query}" in ${workingDirectory}`);
93
- const messages = [
94
- {
95
- role: 'system',
96
- content: `You are a Fast Context Retrieval Agent. Your goal is to find precise code snippets and context for the user's query within 8 turns.
97
-
98
- Rules:
99
- 1. Use massive parallel tool calling. You have NO limits on parallel tool calls, make as many as you need to find the context quickly.
100
- 2. PRIORITIZE: 'grep_search' for specific code patterns, 'find_files' to locate files by name, and 'view_file' to inspect content.
101
- 3. Be aggressive with 'grep_search'. If you have a theory, search for it.
102
- 4. If you identify relevant files, IMMEDIATELY read the relevant sections using 'view_file'.
103
- 5. You have a strict 8-turn limit.
104
- - Turn 1: Broad search (grep, find_files).
105
- - Turn 2: Investigate findings (view_file).
106
- - Turn 3-7: Refine search or read more.
107
- - Turn 8: Finalize.
108
-
109
- Examples for Parallel Tool Calling:
110
- - When encountering a new directory: call \`list_dir\` on it, AND \`grep_search\` for common keywords concurrently.
111
- - When looking for a class definition: call \`find_files\` with class name AND \`grep_search\` with "class ClassName".
112
- - Once you get 10 files from \`grep_search\`, make 10 parallel \`view_file\` tool calls to read them all at once. DO NOT read them one by one.
113
-
114
- Output format:
115
- When you have found the answer or reached the end, return a comprehensive markdown summary.
116
- Include:
117
- - **Relevant Files**: List of files with paths and brief description of relevance.
118
- - **Key Snippets**: Important lines of code (with line numbers).
119
- - **Context**: Explanation of how the code works or answers the query.
120
-
40
+ return files;
41
+ }
42
+ isValidFilePath(pathStr) {
43
+ if (!pathStr || pathStr.length === 0) return false;
44
+ if (/^\d+$/.test(pathStr)) return false;
45
+ if (pathStr.includes("No matches") || pathStr.includes("Found ")) return false;
46
+ if (pathStr.startsWith("Total:") || pathStr.startsWith("Size:")) return false;
47
+ if (pathStr.includes("(showing first") && pathStr.includes("matches)")) return false;
48
+ return true;
49
+ }
50
+ async search(query, workingDirectory, parentContext) {
51
+ const startTime = Date.now();
52
+ const scannedFiles = /* @__PURE__ */ new Set();
53
+ const logToTerminal = (msg) => {
54
+ if (parentContext.onStreamingOutput) {
55
+ parentContext.onStreamingOutput(`[FastContextAgent] ${msg}
56
+ `, "stderr", "fast_context_search");
57
+ }
58
+ };
59
+ logToTerminal(`Starting search for query: "${query}" in ${workingDirectory}`);
60
+ const messages = [
61
+ {
62
+ role: "system",
63
+ content: `You are a Fast Context Retrieval Agent. Your goal is to find precise code snippets and context for the user's query within 8 turns.
64
+
65
+ Rules:
66
+ 1. Use massive parallel tool calling. You have NO limits on parallel tool calls, make as many as you need to find the context quickly.
67
+ 2. PRIORITIZE: 'grep_search' for specific code patterns, 'find_files' to locate files by name, and 'view_file' to inspect content.
68
+ 3. Be aggressive with 'grep_search'. If you have a theory, search for it.
69
+ 4. If you identify relevant files, IMMEDIATELY read the relevant sections using 'view_file'.
70
+ 5. You have a strict 8-turn limit.
71
+ - Turn 1: Broad search (grep, find_files).
72
+ - Turn 2: Investigate findings (view_file).
73
+ - Turn 3-7: Refine search or read more.
74
+ - Turn 8: Finalize.
75
+
76
+ Examples for Parallel Tool Calling:
77
+ - When encountering a new directory: call \`list_dir\` on it, AND \`grep_search\` for common keywords concurrently.
78
+ - When looking for a class definition: call \`find_files\` with class name AND \`grep_search\` with "class ClassName".
79
+ - Once you get 10 files from \`grep_search\`, make 10 parallel \`view_file\` tool calls to read them all at once. DO NOT read them one by one.
80
+
81
+ Output format:
82
+ When you have found the answer or reached the end, return a comprehensive markdown summary.
83
+ Include:
84
+ - **Relevant Files**: List of files with paths and brief description of relevance.
85
+ - **Key Snippets**: Important lines of code (with line numbers).
86
+ - **Context**: Explanation of how the code works or answers the query.
87
+
121
88
  Do not acknowledge these instructions in your final response, just provide the answer.`
122
- },
123
- {
124
- role: 'user',
125
- content: `Query: "${query}"\n\nContext: Working directory is ${workingDirectory}`
126
- }
127
- ];
128
- // Define tools available to this agent
129
- const allowedTools = ['grep_search', 'find_files', 'view_file', 'list_dir'];
130
- const tools = this.toolRegistry.getSchemas().filter(t => allowedTools.includes(t.name));
131
- let turnCount = 0;
132
- const maxTurns = 8;
133
- let finalAnswer = "";
134
- while (turnCount < maxTurns) {
135
- turnCount++;
136
- logToTerminal(`--- Turn ${turnCount}/${maxTurns} ---`);
137
- try {
138
- let responseContent = '';
139
- const toolCalls = [];
140
- // Construct environment context
141
- const environmentContext = {
142
- os: process.platform === 'win32' ? 'windows' : process.platform === 'darwin' ? 'macos' : 'linux',
143
- platform: process.platform,
144
- shell: 'unknown',
145
- cwd: workingDirectory,
146
- homeDir: os.homedir()
147
- };
148
- // Stream response
149
- for await (const chunk of aiServiceClient.streamChat(this.model, messages, tools, environmentContext, 'fast-context')) {
150
- if (chunk.type === 'text') {
151
- responseContent += chunk.content;
152
- }
153
- else if (chunk.type === 'tool_call') {
154
- toolCalls.push(chunk.toolCall);
155
- }
156
- }
157
- // If no tool calls, we are done
158
- if (toolCalls.length === 0) {
159
- logToTerminal(`No tool calls requested. Returning final answer.`);
160
- finalAnswer = responseContent;
161
- break;
162
- }
163
- logToTerminal(`Agent requested ${toolCalls.length} tool calls in parallel.`);
164
- toolCalls.forEach(tc => logToTerminal(` -> ${tc.name}(${JSON.stringify(tc.arguments)})`));
165
- // Append assistant message with tool calls
166
- messages.push({
167
- role: 'assistant',
168
- content: responseContent,
169
- tool_calls: toolCalls
170
- });
171
- // Execute tools in parallel
172
- const toolResults = await Promise.all(toolCalls.map(async (call) => {
173
- try {
174
- const execContext = {
175
- ...parentContext,
176
- cwd: workingDirectory,
177
- requireApproval: async () => true, // Auto-approve read-only tools
178
- };
179
- const result = await this.toolRegistry.execute(call.name, call.arguments, execContext);
180
- let output = result.success ? result.result : `Error: ${result.error}`;
181
- // Sanitize output to prevent Vertex AI errors
182
- output = this.sanitizeOutput(output);
183
- // Track stats
184
- if (result.success) {
185
- const files = this.parseFilesFromOutput(call.name, output);
186
- if (files.length > 0) {
187
- files.forEach(f => scannedFiles.add(f));
188
- if (parentContext.onStreamingOutput) {
189
- parentContext.onStreamingOutput(JSON.stringify({ type: 'scanned_files', files: Array.from(scannedFiles).slice(-4) }) + '\n', 'stdout', 'fast_context_search');
190
- }
191
- }
192
- }
193
- return {
194
- tool_call_id: call.id,
195
- name: call.name,
196
- output: output
197
- };
198
- }
199
- catch (e) {
200
- return {
201
- tool_call_id: call.id,
202
- name: call.name,
203
- output: `System Error executing tool: ${e.message}`
204
- };
205
- }
206
- }));
207
- logToTerminal(`Completed ${toolResults.length} tool calls.`);
208
- // Append tool results
209
- for (const res of toolResults) {
210
- messages.push({
211
- role: 'tool',
212
- tool_call_id: res.tool_call_id,
213
- content: res.output
214
- });
215
- }
216
- }
217
- catch (error) {
218
- finalAnswer = `Error during Fast Context search: ${error}`;
219
- break;
220
- }
89
+ },
90
+ {
91
+ role: "user",
92
+ content: `Query: "${query}"
93
+
94
+ Context: Working directory is ${workingDirectory}`
95
+ }
96
+ ];
97
+ const allowedTools = ["grep_search", "find_files", "view_file", "list_dir"];
98
+ const tools = this.toolRegistry.getSchemas().filter((t) => allowedTools.includes(t.name));
99
+ let turnCount = 0;
100
+ const maxTurns = 8;
101
+ let finalAnswer = "";
102
+ while (turnCount < maxTurns) {
103
+ turnCount++;
104
+ logToTerminal(`--- Turn ${turnCount}/${maxTurns} ---`);
105
+ try {
106
+ let responseContent = "";
107
+ const toolCalls = [];
108
+ const environmentContext = {
109
+ os: process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux",
110
+ platform: process.platform,
111
+ shell: "unknown",
112
+ cwd: workingDirectory,
113
+ homeDir: os.homedir()
114
+ };
115
+ for await (const chunk of aiServiceClient.streamChat(
116
+ this.model,
117
+ messages,
118
+ tools,
119
+ environmentContext,
120
+ "fast-context"
121
+ )) {
122
+ if (chunk.type === "text") {
123
+ responseContent += chunk.content;
124
+ } else if (chunk.type === "tool_call") {
125
+ toolCalls.push(chunk.toolCall);
126
+ }
221
127
  }
222
- // If the loop finishes without an explicit final answer (unlikely if toolCalls.length > 0 was the break condition),
223
- // we might take the last content. But usually the model will output text when it's done.
224
- // If the loop exits specifically because maxTurns was reached, we should use the last assistant message if it was text,
225
- // or generate a final summary. For now, we'll assume the last message content is relevant.
226
- if (turnCount >= maxTurns && !finalAnswer) {
227
- logToTerminal(`Reached max turns (${maxTurns}) without a final text response. Using fallback.`);
228
- // Check if we have a text response in the last turn
229
- const lastMsg = messages[messages.length - 1];
230
- if (lastMsg.role === 'assistant' && lastMsg.content) {
231
- finalAnswer = lastMsg.content;
232
- }
233
- else {
234
- finalAnswer = "Search limit reached. Please try a more specific query.";
235
- }
128
+ if (toolCalls.length === 0) {
129
+ logToTerminal(`No tool calls requested. Returning final answer.`);
130
+ finalAnswer = responseContent;
131
+ break;
236
132
  }
237
- else {
238
- logToTerminal(`Search completed successfully in ${turnCount} turns.`);
133
+ logToTerminal(`Agent requested ${toolCalls.length} tool calls in parallel.`);
134
+ toolCalls.forEach((tc) => logToTerminal(` -> ${tc.name}(${JSON.stringify(tc.arguments)})`));
135
+ messages.push({
136
+ role: "assistant",
137
+ content: responseContent,
138
+ tool_calls: toolCalls
139
+ });
140
+ const toolResults = await Promise.all(toolCalls.map(async (call) => {
141
+ try {
142
+ const execContext = {
143
+ ...parentContext,
144
+ cwd: workingDirectory,
145
+ requireApproval: async () => true
146
+ // Auto-approve read-only tools
147
+ };
148
+ const result = await this.toolRegistry.execute(call.name, call.arguments, execContext);
149
+ let output = result.success ? result.result : `Error: ${result.error}`;
150
+ output = this.sanitizeOutput(output);
151
+ if (result.success) {
152
+ const files = this.parseFilesFromOutput(call.name, output);
153
+ if (files.length > 0) {
154
+ files.forEach((f) => scannedFiles.add(f));
155
+ if (parentContext.onStreamingOutput) {
156
+ parentContext.onStreamingOutput(JSON.stringify({ type: "scanned_files", files: Array.from(scannedFiles).slice(-4) }) + "\n", "stdout", "fast_context_search");
157
+ }
158
+ }
159
+ }
160
+ return {
161
+ tool_call_id: call.id,
162
+ name: call.name,
163
+ output
164
+ };
165
+ } catch (e) {
166
+ return {
167
+ tool_call_id: call.id,
168
+ name: call.name,
169
+ output: `System Error executing tool: ${e.message}`
170
+ };
171
+ }
172
+ }));
173
+ logToTerminal(`Completed ${toolResults.length} tool calls.`);
174
+ for (const res of toolResults) {
175
+ messages.push({
176
+ role: "tool",
177
+ tool_call_id: res.tool_call_id,
178
+ content: res.output
179
+ });
239
180
  }
240
- const duration = Date.now() - startTime;
241
- const stats = {
242
- filesSearched: scannedFiles.size,
243
- duration,
244
- scannedFiles: Array.from(scannedFiles)
245
- };
246
- const response = {
247
- answer: finalAnswer,
248
- stats
249
- };
250
- return JSON.stringify(response);
181
+ } catch (error) {
182
+ finalAnswer = `Error during Fast Context search: ${error}`;
183
+ break;
184
+ }
185
+ }
186
+ if (turnCount >= maxTurns && !finalAnswer) {
187
+ logToTerminal(`Reached max turns (${maxTurns}) without a final text response. Using fallback.`);
188
+ const lastMsg = messages[messages.length - 1];
189
+ if (lastMsg.role === "assistant" && lastMsg.content) {
190
+ finalAnswer = lastMsg.content;
191
+ } else {
192
+ finalAnswer = "Search limit reached. Please try a more specific query.";
193
+ }
194
+ } else {
195
+ logToTerminal(`Search completed successfully in ${turnCount} turns.`);
251
196
  }
197
+ const duration = Date.now() - startTime;
198
+ const stats = {
199
+ filesSearched: scannedFiles.size,
200
+ duration,
201
+ scannedFiles: Array.from(scannedFiles)
202
+ };
203
+ const response = {
204
+ answer: finalAnswer,
205
+ stats
206
+ };
207
+ return JSON.stringify(response);
208
+ }
252
209
  }
210
+ export {
211
+ FastContextAgent
212
+ };
253
213
  //# sourceMappingURL=fast-context-agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fast-context-agent.js","sourceRoot":"","sources":["../../src/services/fast-context-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAqB,MAAM,wBAAwB,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAazB,MAAM,OAAO,gBAAgB;IACjB,YAAY,CAAe;IAC3B,KAAK,GAAG,sBAAsB,CAAC;IAEvC,YAAY,YAA0B;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAEO,cAAc,CAAC,MAAc;Q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AO,EAAE,CAAC;gBAClD,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACJ,WAAW,GAAG,yDAAyD,CAAC;YAC5E,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,aAAa,CAAC,oCAAoC,SAAS,SAAS,CAAC,CAAC;QAC1E,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QACxC,MAAM,KAAK,GAAqB;YAC5B,aAAa,EAAE,YAAY,CAAC,IAAI;YAChC,QAAQ;YACR,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC;SACzC,CAAC;QAEF,MAAM,QAAQ,GAAwB;YAClC,MAAM,EAAE,WAAW;YACnB,KAAK;SACR,CAAC;QAEF,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;CACJ"}
1
+ {"version":3,"sources":["../../src/services/fast-context-agent.ts"],"sourcesContent":["import { ToolRegistry } from '../tools/registry.js';\r\nimport { aiServiceClient, Message, ToolCall } from './ai-service-client.js';\r\nimport { ToolExecutionContext, ToolSchema } from '../tools/types.js';\r\nimport * as os from 'os';\r\n\r\ninterface FastContextStats {\r\n filesSearched: number;\r\n duration: number;\r\n scannedFiles: string[];\r\n}\r\n\r\ninterface FastContextResponse {\r\n answer: string;\r\n stats: FastContextStats;\r\n}\r\n\r\nexport class FastContextAgent {\r\n private toolRegistry: ToolRegistry;\r\n private model = 'zai-org/glm-4.7-maas';\r\n\r\n constructor(toolRegistry: ToolRegistry) {\r\n this.toolRegistry = toolRegistry;\r\n }\r\n\r\n private sanitizeOutput(output: string): string {\r\n // Remove null bytes and other non-printable characters that might cause Vertex AI errors\r\n // Keep newlines, tabs, and standard printable characters\r\n return output.replace(/[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]/g, '');\r\n }\r\n\r\n private parseFilesFromOutput(toolName: string, output: string): string[] {\r\n const files: string[] = [];\r\n const lines = output.split('\\n');\r\n\r\n if (toolName === 'grep_search') {\r\n // Grep often returns \"file:line:content\" or just \"file\"\r\n // We need to be careful not to match line numbers or context\r\n for (const line of lines) {\r\n const trimmed = line.trim();\r\n if (!trimmed) continue;\r\n\r\n // Skip lines that look like just numbers (common in some grep outputs for counts)\r\n if (/^\\d+$/.test(trimmed)) continue;\r\n\r\n // Typical grep output with line number: \"path/to/file.ts:123: content\"\r\n // Or just path: \"path/to/file.ts\"\r\n\r\n // Heuristic: take part before the first colon, or the whole line if no colon\r\n // But avoid \"Found 5 matches\" type lines\r\n if (trimmed.startsWith('Found ') || trimmed.startsWith('Match ')) continue;\r\n\r\n const parts = trimmed.split(':');\r\n const candidate = parts[0].trim();\r\n\r\n // Validate candidate is likely a file path\r\n // Should have an extension or contain path separators, and NOT be just numbers\r\n if (this.isValidFilePath(candidate)) {\r\n files.push(candidate);\r\n }\r\n }\r\n } else if (toolName === 'find_files') {\r\n // find_files usually returns one file per line\r\n for (const line of lines) {\r\n const trimmed = line.trim();\r\n if (this.isValidFilePath(trimmed)) {\r\n files.push(trimmed);\r\n }\r\n }\r\n } else if (toolName === 'view_file' || toolName === 'read_file') {\r\n // We can't easily extracting the filename from the output content unless it's in the header\r\n // The tool output usually starts with \"File: <path>\"\r\n const match = output.match(/^File: (.+)/);\r\n if (match) {\r\n files.push(match[1]);\r\n }\r\n }\r\n\r\n return files;\r\n }\r\n\r\n private isValidFilePath(pathStr: string): boolean {\r\n // Basic validation:\r\n // 1. Not empty\r\n // 2. Not just numbers\r\n // 3. Not a common system message (e.g. \"No matches\")\r\n // 4. Has some file-like characteristics (extension or path separator) OR just is a string that doesn't look like garbage\r\n\r\n if (!pathStr || pathStr.length === 0) return false;\r\n if (/^\\d+$/.test(pathStr)) return false; // purely numeric\r\n if (pathStr.includes('No matches') || pathStr.includes('Found ')) return false;\r\n\r\n // Exclude common noise\r\n if (pathStr.startsWith('Total:') || pathStr.startsWith('Size:')) return false;\r\n\r\n // Exclude grep output noise\r\n if (pathStr.includes('(showing first') && pathStr.includes('matches)')) return false;\r\n\r\n return true;\r\n }\r\n\r\n async search(query: string, workingDirectory: string, parentContext: ToolExecutionContext): Promise<string> {\r\n const startTime = Date.now();\r\n const scannedFiles = new Set<string>();\r\n\r\n // Import logger if not already imported at the top of the file\r\n // We'll use console.log here or logInfo/logDebug if available\r\n const logToTerminal = (msg: string) => {\r\n if (parentContext.onStreamingOutput) {\r\n // Pass debug logging through stderr or a custom type so it's visible in logs\r\n parentContext.onStreamingOutput(`[FastContextAgent] ${msg}\\n`, 'stderr', 'fast_context_search');\r\n }\r\n };\r\n\r\n logToTerminal(`Starting search for query: \"${query}\" in ${workingDirectory}`);\r\n\r\n const messages: Message[] = [\r\n {\r\n role: 'system',\r\n content: `You are a Fast Context Retrieval Agent. Your goal is to find precise code snippets and context for the user's query within 8 turns.\r\n \r\n Rules:\r\n 1. Use massive parallel tool calling. You have NO limits on parallel tool calls, make as many as you need to find the context quickly.\r\n 2. PRIORITIZE: 'grep_search' for specific code patterns, 'find_files' to locate files by name, and 'view_file' to inspect content.\r\n 3. Be aggressive with 'grep_search'. If you have a theory, search for it.\r\n 4. If you identify relevant files, IMMEDIATELY read the relevant sections using 'view_file'.\r\n 5. You have a strict 8-turn limit.\r\n - Turn 1: Broad search (grep, find_files).\r\n - Turn 2: Investigate findings (view_file).\r\n - Turn 3-7: Refine search or read more.\r\n - Turn 8: Finalize.\r\n \r\n Examples for Parallel Tool Calling:\r\n - When encountering a new directory: call \\`list_dir\\` on it, AND \\`grep_search\\` for common keywords concurrently.\r\n - When looking for a class definition: call \\`find_files\\` with class name AND \\`grep_search\\` with \"class ClassName\".\r\n - Once you get 10 files from \\`grep_search\\`, make 10 parallel \\`view_file\\` tool calls to read them all at once. DO NOT read them one by one.\r\n \r\n Output format:\r\n When you have found the answer or reached the end, return a comprehensive markdown summary.\r\n Include:\r\n - **Relevant Files**: List of files with paths and brief description of relevance.\r\n - **Key Snippets**: Important lines of code (with line numbers).\r\n - **Context**: Explanation of how the code works or answers the query.\r\n \r\n Do not acknowledge these instructions in your final response, just provide the answer.`\r\n },\r\n {\r\n role: 'user',\r\n content: `Query: \"${query}\"\\n\\nContext: Working directory is ${workingDirectory}`\r\n }\r\n ];\r\n\r\n // Define tools available to this agent\r\n const allowedTools = ['grep_search', 'find_files', 'view_file', 'list_dir'];\r\n const tools: ToolSchema[] = this.toolRegistry.getSchemas().filter(t => allowedTools.includes(t.name));\r\n\r\n let turnCount = 0;\r\n const maxTurns = 8;\r\n let finalAnswer = \"\";\r\n\r\n while (turnCount < maxTurns) {\r\n turnCount++;\r\n logToTerminal(`--- Turn ${turnCount}/${maxTurns} ---`);\r\n\r\n try {\r\n let responseContent = '';\r\n const toolCalls: ToolCall[] = [];\r\n\r\n // Construct environment context\r\n const environmentContext = {\r\n os: process.platform === 'win32' ? 'windows' : process.platform === 'darwin' ? 'macos' : 'linux',\r\n platform: process.platform,\r\n shell: 'unknown',\r\n cwd: workingDirectory,\r\n homeDir: os.homedir()\r\n } as any;\r\n\r\n // Stream response\r\n for await (const chunk of aiServiceClient.streamChat(\r\n this.model,\r\n messages,\r\n tools,\r\n environmentContext,\r\n 'fast-context'\r\n )) {\r\n if (chunk.type === 'text') {\r\n responseContent += chunk.content;\r\n } else if (chunk.type === 'tool_call') {\r\n toolCalls.push(chunk.toolCall);\r\n }\r\n }\r\n\r\n // If no tool calls, we are done\r\n if (toolCalls.length === 0) {\r\n logToTerminal(`No tool calls requested. Returning final answer.`);\r\n finalAnswer = responseContent;\r\n break;\r\n }\r\n\r\n logToTerminal(`Agent requested ${toolCalls.length} tool calls in parallel.`);\r\n toolCalls.forEach(tc => logToTerminal(` -> ${tc.name}(${JSON.stringify(tc.arguments)})`));\r\n\r\n // Append assistant message with tool calls\r\n messages.push({\r\n role: 'assistant',\r\n content: responseContent,\r\n tool_calls: toolCalls\r\n });\r\n\r\n // Execute tools in parallel\r\n const toolResults = await Promise.all(toolCalls.map(async (call) => {\r\n try {\r\n const execContext: ToolExecutionContext = {\r\n ...parentContext,\r\n cwd: workingDirectory,\r\n requireApproval: async () => true, // Auto-approve read-only tools\r\n };\r\n\r\n const result = await this.toolRegistry.execute(call.name, call.arguments, execContext);\r\n let output = result.success ? result.result : `Error: ${result.error}`;\r\n\r\n // Sanitize output to prevent Vertex AI errors\r\n output = this.sanitizeOutput(output);\r\n\r\n // Track stats\r\n if (result.success) {\r\n const files = this.parseFilesFromOutput(call.name, output);\r\n if (files.length > 0) {\r\n files.forEach(f => scannedFiles.add(f));\r\n if (parentContext.onStreamingOutput) {\r\n parentContext.onStreamingOutput(JSON.stringify({ type: 'scanned_files', files: Array.from(scannedFiles).slice(-4) }) + '\\n', 'stdout', 'fast_context_search');\r\n }\r\n }\r\n }\r\n\r\n return {\r\n tool_call_id: call.id,\r\n name: call.name,\r\n output: output\r\n };\r\n } catch (e: any) {\r\n return {\r\n tool_call_id: call.id,\r\n name: call.name,\r\n output: `System Error executing tool: ${e.message}`\r\n };\r\n }\r\n }));\r\n\r\n logToTerminal(`Completed ${toolResults.length} tool calls.`);\r\n\r\n // Append tool results\r\n for (const res of toolResults) {\r\n messages.push({\r\n role: 'tool',\r\n tool_call_id: res.tool_call_id,\r\n content: res.output\r\n });\r\n }\r\n\r\n } catch (error) {\r\n finalAnswer = `Error during Fast Context search: ${error}`;\r\n break;\r\n }\r\n }\r\n\r\n // If the loop finishes without an explicit final answer (unlikely if toolCalls.length > 0 was the break condition),\r\n // we might take the last content. But usually the model will output text when it's done.\r\n // If the loop exits specifically because maxTurns was reached, we should use the last assistant message if it was text,\r\n // or generate a final summary. For now, we'll assume the last message content is relevant.\r\n if (turnCount >= maxTurns && !finalAnswer) {\r\n logToTerminal(`Reached max turns (${maxTurns}) without a final text response. Using fallback.`);\r\n // Check if we have a text response in the last turn\r\n const lastMsg = messages[messages.length - 1];\r\n if (lastMsg.role === 'assistant' && lastMsg.content) {\r\n finalAnswer = lastMsg.content;\r\n } else {\r\n finalAnswer = \"Search limit reached. Please try a more specific query.\";\r\n }\r\n } else {\r\n logToTerminal(`Search completed successfully in ${turnCount} turns.`);\r\n }\r\n\r\n const duration = Date.now() - startTime;\r\n const stats: FastContextStats = {\r\n filesSearched: scannedFiles.size,\r\n duration,\r\n scannedFiles: Array.from(scannedFiles)\r\n };\r\n\r\n const response: FastContextResponse = {\r\n answer: finalAnswer,\r\n stats\r\n };\r\n\r\n return JSON.stringify(response);\r\n }\r\n}\r\n"],"mappings":"AACA,SAAS,uBAA0C;AAEnD,YAAY,QAAQ;AAab,MAAM,iBAAiB;AAAA,EAClB;AAAA,EACA,QAAQ;AAAA,EAEhB,YAAY,cAA4B;AACpC,SAAK,eAAe;AAAA,EACxB;AAAA,EAEQ,eAAe,QAAwB;AAG3C,WAAO,OAAO,QAAQ,6CAA6C,EAAE;AAAA,EACzE;AAAA,EAEQ,qBAAqB,UAAkB,QAA0B;AACrE,UAAM,QAAkB,CAAC;AACzB,UAAM,QAAQ,OAAO,MAAM,IAAI;AAE/B,QAAI,aAAa,eAAe;AAG5B,iBAAW,QAAQ,OAAO;AACtB,cAAM,UAAU,KAAK,KAAK;AAC1B,YAAI,CAAC,QAAS;AAGd,YAAI,QAAQ,KAAK,OAAO,EAAG;AAO3B,YAAI,QAAQ,WAAW,QAAQ,KAAK,QAAQ,WAAW,QAAQ,EAAG;AAElE,cAAM,QAAQ,QAAQ,MAAM,GAAG;AAC/B,cAAM,YAAY,MAAM,CAAC,EAAE,KAAK;AAIhC,YAAI,KAAK,gBAAgB,SAAS,GAAG;AACjC,gBAAM,KAAK,SAAS;AAAA,QACxB;AAAA,MACJ;AAAA,IACJ,WAAW,aAAa,cAAc;AAElC,iBAAW,QAAQ,OAAO;AACtB,cAAM,UAAU,KAAK,KAAK;AAC1B,YAAI,KAAK,gBAAgB,OAAO,GAAG;AAC/B,gBAAM,KAAK,OAAO;AAAA,QACtB;AAAA,MACJ;AAAA,IACJ,WAAW,aAAa,eAAe,aAAa,aAAa;AAG7D,YAAM,QA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