@travisennis/acai 0.0.4 → 0.0.6

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 (433) hide show
  1. package/README.md +229 -8
  2. package/dist/agent/index.d.ts +119 -0
  3. package/dist/agent/index.d.ts.map +1 -0
  4. package/dist/agent/index.js +406 -0
  5. package/dist/agent/manual-loop.d.ts +41 -0
  6. package/dist/agent/manual-loop.d.ts.map +1 -0
  7. package/dist/agent/manual-loop.js +278 -0
  8. package/dist/api/exa/index.d.ts +177 -0
  9. package/dist/api/exa/index.d.ts.map +1 -0
  10. package/dist/api/exa/index.js +439 -0
  11. package/dist/cli.d.ts +5 -2
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +27 -33
  14. package/dist/commands/add-directory-command.d.ts +3 -0
  15. package/dist/commands/add-directory-command.d.ts.map +1 -0
  16. package/dist/commands/add-directory-command.js +85 -0
  17. package/dist/commands/application-log-command.d.ts +1 -0
  18. package/dist/commands/application-log-command.d.ts.map +1 -0
  19. package/dist/commands/application-log-command.js +39 -3
  20. package/dist/commands/clear-command.d.ts +1 -0
  21. package/dist/commands/clear-command.d.ts.map +1 -0
  22. package/dist/commands/clear-command.js +10 -3
  23. package/dist/commands/compact-command.d.ts +1 -0
  24. package/dist/commands/compact-command.d.ts.map +1 -0
  25. package/dist/commands/compact-command.js +16 -3
  26. package/dist/commands/context-command.d.ts +3 -0
  27. package/dist/commands/context-command.d.ts.map +1 -0
  28. package/dist/commands/context-command.js +183 -0
  29. package/dist/commands/copy-command.d.ts +1 -0
  30. package/dist/commands/copy-command.d.ts.map +1 -0
  31. package/dist/commands/copy-command.js +31 -2
  32. package/dist/commands/edit-command.d.ts +1 -0
  33. package/dist/commands/edit-command.d.ts.map +1 -0
  34. package/dist/commands/edit-command.js +40 -5
  35. package/dist/commands/edit-prompt-command.d.ts +2 -1
  36. package/dist/commands/edit-prompt-command.d.ts.map +1 -0
  37. package/dist/commands/edit-prompt-command.js +43 -7
  38. package/dist/commands/exit-command.d.ts +13 -2
  39. package/dist/commands/exit-command.d.ts.map +1 -0
  40. package/dist/commands/exit-command.js +34 -2
  41. package/dist/commands/files-command.d.ts +1 -0
  42. package/dist/commands/files-command.d.ts.map +1 -0
  43. package/dist/commands/files-command.js +66 -8
  44. package/dist/commands/generate-rules-command.d.ts +1 -0
  45. package/dist/commands/generate-rules-command.d.ts.map +1 -0
  46. package/dist/commands/generate-rules-command.js +315 -4
  47. package/dist/commands/handoff-command.d.ts +3 -0
  48. package/dist/commands/handoff-command.d.ts.map +1 -0
  49. package/dist/commands/handoff-command.js +202 -0
  50. package/dist/commands/health-command.d.ts +3 -1
  51. package/dist/commands/health-command.d.ts.map +1 -0
  52. package/dist/commands/health-command.js +160 -6
  53. package/dist/commands/help-command.d.ts +1 -0
  54. package/dist/commands/help-command.d.ts.map +1 -0
  55. package/dist/commands/help-command.js +30 -3
  56. package/dist/commands/history-command.d.ts +3 -0
  57. package/dist/commands/history-command.d.ts.map +1 -0
  58. package/dist/commands/history-command.js +534 -0
  59. package/dist/commands/init-command.d.ts +2 -1
  60. package/dist/commands/init-command.d.ts.map +1 -0
  61. package/dist/commands/init-command.js +56 -20
  62. package/dist/commands/last-log-command.d.ts +1 -0
  63. package/dist/commands/last-log-command.d.ts.map +1 -0
  64. package/dist/commands/last-log-command.js +39 -17
  65. package/dist/commands/list-directories-command.d.ts +3 -0
  66. package/dist/commands/list-directories-command.d.ts.map +1 -0
  67. package/dist/commands/list-directories-command.js +48 -0
  68. package/dist/commands/list-tools-command.d.ts +3 -0
  69. package/dist/commands/list-tools-command.d.ts.map +1 -0
  70. package/dist/commands/list-tools-command.js +124 -0
  71. package/dist/commands/manager.d.ts +20 -3
  72. package/dist/commands/manager.d.ts.map +1 -0
  73. package/dist/commands/manager.js +123 -26
  74. package/dist/commands/model-command.d.ts +23 -0
  75. package/dist/commands/model-command.d.ts.map +1 -0
  76. package/dist/commands/model-command.js +261 -5
  77. package/dist/commands/paste-command.d.ts +1 -0
  78. package/dist/commands/paste-command.d.ts.map +1 -0
  79. package/dist/commands/paste-command.js +98 -5
  80. package/dist/commands/pickup-command.d.ts +3 -0
  81. package/dist/commands/pickup-command.d.ts.map +1 -0
  82. package/dist/commands/pickup-command.js +161 -0
  83. package/dist/commands/prompt-command.d.ts +2 -1
  84. package/dist/commands/prompt-command.d.ts.map +1 -0
  85. package/dist/commands/prompt-command.js +178 -9
  86. package/dist/commands/remove-directory-command.d.ts +3 -0
  87. package/dist/commands/remove-directory-command.d.ts.map +1 -0
  88. package/dist/commands/remove-directory-command.js +87 -0
  89. package/dist/commands/reset-command.d.ts +2 -1
  90. package/dist/commands/reset-command.d.ts.map +1 -0
  91. package/dist/commands/reset-command.js +14 -3
  92. package/dist/commands/rules-command.d.ts +1 -0
  93. package/dist/commands/rules-command.d.ts.map +1 -0
  94. package/dist/commands/rules-command.js +70 -3
  95. package/dist/commands/save-command.d.ts +1 -0
  96. package/dist/commands/save-command.d.ts.map +1 -0
  97. package/dist/commands/save-command.js +13 -1
  98. package/dist/commands/shell-command.d.ts +3 -0
  99. package/dist/commands/shell-command.d.ts.map +1 -0
  100. package/dist/commands/shell-command.js +128 -0
  101. package/dist/commands/types.d.ts +16 -8
  102. package/dist/commands/types.d.ts.map +1 -0
  103. package/dist/commands/usage-command.d.ts +1 -0
  104. package/dist/commands/usage-command.d.ts.map +1 -0
  105. package/dist/commands/usage-command.js +24 -3
  106. package/dist/config.d.ts +21 -34
  107. package/dist/config.d.ts.map +1 -0
  108. package/dist/config.js +55 -15
  109. package/dist/dedent.d.ts +1 -0
  110. package/dist/dedent.d.ts.map +1 -0
  111. package/dist/execution/index.d.ts +112 -0
  112. package/dist/execution/index.d.ts.map +1 -0
  113. package/dist/execution/index.js +432 -0
  114. package/dist/formatting.d.ts +107 -10
  115. package/dist/formatting.d.ts.map +1 -0
  116. package/dist/formatting.js +150 -62
  117. package/dist/index.d.ts +8 -2
  118. package/dist/index.d.ts.map +1 -0
  119. package/dist/index.js +150 -38
  120. package/dist/logger.d.ts +1 -0
  121. package/dist/logger.d.ts.map +1 -0
  122. package/dist/logger.js +47 -18
  123. package/dist/mentions.d.ts +6 -1
  124. package/dist/mentions.d.ts.map +1 -0
  125. package/dist/mentions.js +58 -11
  126. package/dist/messages.d.ts +16 -20
  127. package/dist/messages.d.ts.map +1 -0
  128. package/dist/messages.js +89 -72
  129. package/dist/middleware/audit-message.d.ts +1 -0
  130. package/dist/middleware/audit-message.d.ts.map +1 -0
  131. package/dist/middleware/cache.d.ts +3 -0
  132. package/dist/middleware/cache.d.ts.map +1 -0
  133. package/dist/middleware/cache.js +53 -0
  134. package/dist/middleware/index.d.ts +2 -0
  135. package/dist/middleware/index.d.ts.map +1 -0
  136. package/dist/middleware/index.js +1 -0
  137. package/dist/middleware/rate-limit.d.ts +1 -0
  138. package/dist/middleware/rate-limit.d.ts.map +1 -0
  139. package/dist/models/ai-config.d.ts +5 -2
  140. package/dist/models/ai-config.d.ts.map +1 -0
  141. package/dist/models/ai-config.js +12 -2
  142. package/dist/models/anthropic-provider.d.ts +1 -0
  143. package/dist/models/anthropic-provider.d.ts.map +1 -0
  144. package/dist/models/anthropic-provider.js +3 -60
  145. package/dist/models/deepseek-provider.d.ts +1 -0
  146. package/dist/models/deepseek-provider.d.ts.map +1 -0
  147. package/dist/models/google-provider.d.ts +1 -0
  148. package/dist/models/google-provider.d.ts.map +1 -0
  149. package/dist/models/groq-provider.d.ts +20 -0
  150. package/dist/models/groq-provider.d.ts.map +1 -0
  151. package/dist/models/groq-provider.js +31 -0
  152. package/dist/models/manager.d.ts +3 -1
  153. package/dist/models/manager.d.ts.map +1 -0
  154. package/dist/models/manager.js +26 -2
  155. package/dist/models/openai-provider.d.ts +2 -1
  156. package/dist/models/openai-provider.d.ts.map +1 -0
  157. package/dist/models/openrouter-provider.d.ts +25 -23
  158. package/dist/models/openrouter-provider.d.ts.map +1 -0
  159. package/dist/models/openrouter-provider.js +181 -122
  160. package/dist/models/providers.d.ts +4 -5
  161. package/dist/models/providers.d.ts.map +1 -0
  162. package/dist/models/providers.js +7 -3
  163. package/dist/models/xai-provider.d.ts +1 -0
  164. package/dist/models/xai-provider.d.ts.map +1 -0
  165. package/dist/parsing.d.ts +2 -1
  166. package/dist/parsing.d.ts.map +1 -0
  167. package/dist/prompts/manager.d.ts +14 -2
  168. package/dist/prompts/manager.d.ts.map +1 -0
  169. package/dist/prompts.d.ts +2 -0
  170. package/dist/prompts.d.ts.map +1 -0
  171. package/dist/prompts.js +65 -12
  172. package/dist/repl/display-tool-messages.d.ts +4 -0
  173. package/dist/repl/display-tool-messages.d.ts.map +1 -0
  174. package/dist/repl/display-tool-messages.js +58 -0
  175. package/dist/repl/display-tool-use.d.ts +14 -0
  176. package/dist/repl/display-tool-use.d.ts.map +1 -0
  177. package/dist/repl/display-tool-use.js +63 -0
  178. package/dist/repl/get-prompt-header.d.ts +8 -0
  179. package/dist/repl/get-prompt-header.d.ts.map +1 -0
  180. package/dist/repl/get-prompt-header.js +9 -0
  181. package/dist/repl/project-status-line.d.ts +2 -0
  182. package/dist/repl/project-status-line.d.ts.map +1 -0
  183. package/dist/repl/project-status-line.js +31 -0
  184. package/dist/repl/prompt.d.ts +21 -0
  185. package/dist/repl/prompt.d.ts.map +1 -0
  186. package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
  187. package/dist/repl/tool-call-repair.d.ts +4 -0
  188. package/dist/repl/tool-call-repair.d.ts.map +1 -0
  189. package/dist/repl/tool-call-repair.js +54 -0
  190. package/dist/repl-new.d.ts +53 -0
  191. package/dist/repl-new.d.ts.map +1 -0
  192. package/dist/repl-new.js +374 -0
  193. package/dist/repl.d.ts +9 -7
  194. package/dist/repl.d.ts.map +1 -0
  195. package/dist/repl.js +142 -378
  196. package/dist/terminal/ansi-styles.d.ts +77 -0
  197. package/dist/terminal/ansi-styles.d.ts.map +1 -0
  198. package/dist/terminal/ansi-styles.js +215 -0
  199. package/dist/terminal/checkbox-prompt.d.ts +36 -0
  200. package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
  201. package/dist/terminal/checkbox-prompt.js +368 -0
  202. package/dist/terminal/default-theme.d.ts +6 -0
  203. package/dist/terminal/default-theme.d.ts.map +1 -0
  204. package/dist/terminal/default-theme.js +182 -0
  205. package/dist/terminal/east-asian-width.d.ts +8 -0
  206. package/dist/terminal/east-asian-width.d.ts.map +1 -0
  207. package/dist/terminal/east-asian-width.js +409 -0
  208. package/dist/terminal/editor-prompt.d.ts +10 -0
  209. package/dist/terminal/editor-prompt.d.ts.map +1 -0
  210. package/dist/terminal/editor-prompt.js +61 -0
  211. package/dist/terminal/errors.d.ts +19 -0
  212. package/dist/terminal/errors.d.ts.map +1 -0
  213. package/dist/terminal/errors.js +37 -0
  214. package/dist/terminal/formatting.d.ts +1 -11
  215. package/dist/terminal/formatting.d.ts.map +1 -0
  216. package/dist/terminal/formatting.js +4 -20
  217. package/dist/terminal/highlight/index.d.ts +53 -0
  218. package/dist/terminal/highlight/index.d.ts.map +1 -0
  219. package/dist/terminal/highlight/index.js +90 -0
  220. package/dist/terminal/highlight/theme.d.ts +233 -0
  221. package/dist/terminal/highlight/theme.d.ts.map +1 -0
  222. package/dist/terminal/highlight/theme.js +83 -0
  223. package/dist/terminal/index.d.ts +23 -9
  224. package/dist/terminal/index.d.ts.map +1 -0
  225. package/dist/terminal/index.js +136 -126
  226. package/dist/terminal/input-prompt.d.ts +17 -0
  227. package/dist/terminal/input-prompt.d.ts.map +1 -0
  228. package/dist/terminal/input-prompt.js +181 -0
  229. package/dist/terminal/markdown-utils.d.ts +1 -0
  230. package/dist/terminal/markdown-utils.d.ts.map +1 -0
  231. package/dist/terminal/markdown.d.ts +1 -0
  232. package/dist/terminal/markdown.d.ts.map +1 -0
  233. package/dist/terminal/markdown.js +20 -12
  234. package/dist/terminal/search-prompt.d.ts +20 -0
  235. package/dist/terminal/search-prompt.d.ts.map +1 -0
  236. package/dist/terminal/search-prompt.js +280 -0
  237. package/dist/terminal/select-prompt.d.ts +26 -0
  238. package/dist/terminal/select-prompt.d.ts.map +1 -0
  239. package/dist/terminal/select-prompt.js +306 -0
  240. package/dist/terminal/string-width.d.ts +7 -0
  241. package/dist/terminal/string-width.d.ts.map +1 -0
  242. package/dist/terminal/string-width.js +61 -0
  243. package/dist/terminal/strip-ansi.d.ts +2 -0
  244. package/dist/terminal/strip-ansi.d.ts.map +1 -0
  245. package/dist/terminal/strip-ansi.js +20 -0
  246. package/dist/terminal/style.d.ts +191 -0
  247. package/dist/terminal/style.d.ts.map +1 -0
  248. package/dist/terminal/style.js +259 -0
  249. package/dist/terminal/supports-color.d.ts +1 -0
  250. package/dist/terminal/supports-color.d.ts.map +1 -0
  251. package/dist/terminal/supports-hyperlinks.d.ts +1 -3
  252. package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
  253. package/dist/terminal/supports-hyperlinks.js +1 -1
  254. package/dist/terminal/types.d.ts +1 -37
  255. package/dist/terminal/types.d.ts.map +1 -0
  256. package/dist/terminal/wrap-ansi.d.ts +8 -0
  257. package/dist/terminal/wrap-ansi.d.ts.map +1 -0
  258. package/dist/terminal/wrap-ansi.js +190 -0
  259. package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
  260. package/dist/tokens/counter.d.ts.map +1 -0
  261. package/dist/{token-utils.js → tokens/counter.js} +1 -1
  262. package/dist/tokens/threshold.d.ts +35 -0
  263. package/dist/tokens/threshold.d.ts.map +1 -0
  264. package/dist/tokens/threshold.js +85 -0
  265. package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
  266. package/dist/tokens/tracker.d.ts.map +1 -0
  267. package/dist/tools/advanced-edit-file.d.ts +69 -0
  268. package/dist/tools/advanced-edit-file.d.ts.map +1 -0
  269. package/dist/tools/advanced-edit-file.js +281 -0
  270. package/dist/tools/agent.d.ts +19 -7
  271. package/dist/tools/agent.d.ts.map +1 -0
  272. package/dist/tools/agent.js +70 -54
  273. package/dist/tools/bash-utils.d.ts +7 -0
  274. package/dist/tools/bash-utils.d.ts.map +1 -0
  275. package/dist/tools/bash-utils.js +220 -0
  276. package/dist/tools/bash.d.ts +25 -14
  277. package/dist/tools/bash.d.ts.map +1 -0
  278. package/dist/tools/bash.js +87 -251
  279. package/dist/tools/code-interpreter.d.ts +22 -10
  280. package/dist/tools/code-interpreter.d.ts.map +1 -0
  281. package/dist/tools/code-interpreter.js +146 -210
  282. package/dist/tools/delete-file.d.ts +18 -9
  283. package/dist/tools/delete-file.d.ts.map +1 -0
  284. package/dist/tools/delete-file.js +55 -85
  285. package/dist/tools/directory-tree.d.ts +26 -6
  286. package/dist/tools/directory-tree.d.ts.map +1 -0
  287. package/dist/tools/directory-tree.js +109 -28
  288. package/dist/tools/dynamic-tool-loader.d.ts +22 -0
  289. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
  290. package/dist/tools/dynamic-tool-loader.js +272 -0
  291. package/dist/tools/dynamic-tool-parser.d.ts +21 -0
  292. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
  293. package/dist/tools/dynamic-tool-parser.js +22 -0
  294. package/dist/tools/edit-file.d.ts +41 -13
  295. package/dist/tools/edit-file.d.ts.map +1 -0
  296. package/dist/tools/edit-file.js +173 -96
  297. package/dist/tools/filesystem-utils.d.ts +7 -21
  298. package/dist/tools/filesystem-utils.d.ts.map +1 -0
  299. package/dist/tools/filesystem-utils.js +111 -149
  300. package/dist/tools/git-utils.d.ts +1 -0
  301. package/dist/tools/git-utils.d.ts.map +1 -0
  302. package/dist/tools/glob.d.ts +36 -0
  303. package/dist/tools/glob.d.ts.map +1 -0
  304. package/dist/tools/glob.js +143 -0
  305. package/dist/tools/grep.d.ts +76 -13
  306. package/dist/tools/grep.d.ts.map +1 -0
  307. package/dist/tools/grep.js +420 -135
  308. package/dist/tools/index.d.ts +207 -133
  309. package/dist/tools/index.d.ts.map +1 -0
  310. package/dist/tools/index.js +245 -127
  311. package/dist/tools/llm-edit-fixer.d.ts +25 -0
  312. package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
  313. package/dist/tools/llm-edit-fixer.js +150 -0
  314. package/dist/tools/move-file.d.ts +20 -7
  315. package/dist/tools/move-file.d.ts.map +1 -0
  316. package/dist/tools/move-file.js +43 -29
  317. package/dist/tools/read-file.d.ts +49 -10
  318. package/dist/tools/read-file.d.ts.map +1 -0
  319. package/dist/tools/read-file.js +79 -67
  320. package/dist/tools/read-multiple-files.d.ts +19 -7
  321. package/dist/tools/read-multiple-files.d.ts.map +1 -0
  322. package/dist/tools/read-multiple-files.js +117 -33
  323. package/dist/tools/save-file.d.ts +46 -11
  324. package/dist/tools/save-file.d.ts.map +1 -0
  325. package/dist/tools/save-file.js +63 -78
  326. package/dist/tools/think.d.ts +16 -7
  327. package/dist/tools/think.d.ts.map +1 -0
  328. package/dist/tools/think.js +34 -22
  329. package/dist/tools/types.d.ts +18 -11
  330. package/dist/tools/types.d.ts.map +1 -0
  331. package/dist/tools/types.js +9 -0
  332. package/dist/tools/utils.d.ts +14 -0
  333. package/dist/tools/utils.d.ts.map +1 -0
  334. package/dist/tools/utils.js +16 -0
  335. package/dist/tools/web-fetch.d.ts +15 -6
  336. package/dist/tools/web-fetch.d.ts.map +1 -0
  337. package/dist/tools/web-fetch.js +40 -39
  338. package/dist/tools/web-search.d.ts +17 -7
  339. package/dist/tools/web-search.d.ts.map +1 -0
  340. package/dist/tools/web-search.js +86 -33
  341. package/dist/tui/autocomplete.d.ts +44 -0
  342. package/dist/tui/autocomplete.d.ts.map +1 -0
  343. package/dist/tui/autocomplete.js +466 -0
  344. package/dist/tui/components/assistant-message.d.ts +18 -0
  345. package/dist/tui/components/assistant-message.d.ts.map +1 -0
  346. package/dist/tui/components/assistant-message.js +29 -0
  347. package/dist/tui/components/editor.d.ts +51 -0
  348. package/dist/tui/components/editor.d.ts.map +1 -0
  349. package/dist/tui/components/editor.js +758 -0
  350. package/dist/tui/components/footer.d.ts +24 -0
  351. package/dist/tui/components/footer.d.ts.map +1 -0
  352. package/dist/tui/components/footer.js +197 -0
  353. package/dist/tui/components/input.d.ts +14 -0
  354. package/dist/tui/components/input.d.ts.map +1 -0
  355. package/dist/tui/components/input.js +122 -0
  356. package/dist/tui/components/loader.d.ts +19 -0
  357. package/dist/tui/components/loader.d.ts.map +1 -0
  358. package/dist/tui/components/loader.js +45 -0
  359. package/dist/tui/components/markdown.d.ts +103 -0
  360. package/dist/tui/components/markdown.d.ts.map +1 -0
  361. package/dist/tui/components/markdown.js +533 -0
  362. package/dist/tui/components/modal.d.ts +40 -0
  363. package/dist/tui/components/modal.d.ts.map +1 -0
  364. package/dist/tui/components/modal.js +292 -0
  365. package/dist/tui/components/prompt-status.d.ts +16 -0
  366. package/dist/tui/components/prompt-status.d.ts.map +1 -0
  367. package/dist/tui/components/prompt-status.js +21 -0
  368. package/dist/tui/components/select-list.d.ts +22 -0
  369. package/dist/tui/components/select-list.d.ts.map +1 -0
  370. package/dist/tui/components/select-list.js +143 -0
  371. package/dist/tui/components/spacer.d.ts +16 -0
  372. package/dist/tui/components/spacer.d.ts.map +1 -0
  373. package/dist/tui/components/spacer.js +27 -0
  374. package/dist/tui/components/text.d.ts +26 -0
  375. package/dist/tui/components/text.d.ts.map +1 -0
  376. package/dist/tui/components/text.js +143 -0
  377. package/dist/tui/components/thinking-block.d.ts +14 -0
  378. package/dist/tui/components/thinking-block.d.ts.map +1 -0
  379. package/dist/tui/components/thinking-block.js +30 -0
  380. package/dist/tui/components/tool-execution.d.ts +17 -0
  381. package/dist/tui/components/tool-execution.d.ts.map +1 -0
  382. package/dist/tui/components/tool-execution.js +153 -0
  383. package/dist/tui/components/user-message.d.ts +9 -0
  384. package/dist/tui/components/user-message.d.ts.map +1 -0
  385. package/dist/tui/components/user-message.js +21 -0
  386. package/dist/tui/components/welcome.d.ts +6 -0
  387. package/dist/tui/components/welcome.d.ts.map +1 -0
  388. package/dist/tui/components/welcome.js +30 -0
  389. package/dist/tui/index.d.ts +14 -0
  390. package/dist/tui/index.d.ts.map +1 -0
  391. package/dist/tui/index.js +18 -0
  392. package/dist/tui/terminal.d.ts +37 -0
  393. package/dist/tui/terminal.d.ts.map +1 -0
  394. package/dist/tui/terminal.js +104 -0
  395. package/dist/tui/tui.d.ts +67 -0
  396. package/dist/tui/tui.d.ts.map +1 -0
  397. package/dist/tui/tui.js +184 -0
  398. package/dist/tui/utils.d.ts +19 -0
  399. package/dist/tui/utils.d.ts.map +1 -0
  400. package/dist/tui/utils.js +31 -0
  401. package/dist/utils/filesystem.d.ts +23 -0
  402. package/dist/utils/filesystem.d.ts.map +1 -0
  403. package/dist/utils/filesystem.js +140 -0
  404. package/dist/utils/filetype-detection.d.ts +3 -0
  405. package/dist/utils/filetype-detection.d.ts.map +1 -0
  406. package/dist/utils/filetype-detection.js +112 -0
  407. package/dist/utils/generators.d.ts +3 -0
  408. package/dist/utils/generators.d.ts.map +1 -0
  409. package/dist/utils/generators.js +25 -0
  410. package/dist/utils/glob.d.ts +52 -0
  411. package/dist/utils/glob.d.ts.map +1 -0
  412. package/dist/utils/glob.js +376 -0
  413. package/dist/utils/ignore.d.ts +104 -0
  414. package/dist/utils/ignore.d.ts.map +1 -0
  415. package/dist/utils/ignore.js +649 -0
  416. package/dist/utils/iterables.d.ts +2 -0
  417. package/dist/utils/iterables.d.ts.map +1 -0
  418. package/dist/utils/iterables.js +6 -0
  419. package/dist/utils/process.d.ts +3 -2
  420. package/dist/utils/process.d.ts.map +1 -0
  421. package/dist/utils/process.js +17 -2
  422. package/dist/utils/zod-utils.d.ts +4 -0
  423. package/dist/utils/zod-utils.d.ts.map +1 -0
  424. package/dist/utils/zod-utils.js +7 -0
  425. package/dist/version.d.ts +1 -0
  426. package/dist/version.d.ts.map +1 -0
  427. package/package.json +34 -32
  428. package/dist/conversation-analyzer.d.ts +0 -10
  429. package/dist/conversation-analyzer.js +0 -88
  430. package/dist/repl-prompt.d.ts +0 -14
  431. package/dist/tools/command-validation.d.ts +0 -11
  432. package/dist/tools/command-validation.js +0 -45
  433. /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
@@ -1,119 +1,172 @@
1
1
  import { execSync } from "node:child_process";
2
2
  import { inspect } from "node:util";
3
- import { tool } from "ai";
4
- import chalk from "chalk";
5
3
  import { z } from "zod";
4
+ import { config } from "../config.js";
5
+ import style from "../terminal/style.js";
6
+ import { manageTokenLimit } from "../tokens/threshold.js";
6
7
  export const GrepTool = {
7
8
  name: "grepFiles",
8
9
  };
9
- export const createGrepTool = (options = {}) => {
10
- const { sendData } = options;
10
+ const inputSchema = z.object({
11
+ pattern: z
12
+ .string()
13
+ .describe("The search pattern (regex by default, or fixed-string if literal=true or auto-detected as unbalanced)"),
14
+ path: z.string().describe("The path to search in"),
15
+ recursive: z.coerce
16
+ .boolean()
17
+ .nullable()
18
+ .describe("Search recursively. (default: true))"),
19
+ ignoreCase: z.coerce
20
+ .boolean()
21
+ .nullable()
22
+ .describe("Use case-sensitive search. (default: false)"),
23
+ filePattern: z.coerce
24
+ .string()
25
+ .nullable()
26
+ .describe("Glob pattern to filter files (e.g., '*.ts', '**/*.test.js'). (Default: no filtering)"),
27
+ contextLines: z.coerce
28
+ .number()
29
+ .nullable()
30
+ .describe("The number of context lines needed in search results. (Default: 0)"),
31
+ searchIgnored: z.coerce
32
+ .boolean()
33
+ .nullable()
34
+ .describe("Search ignored files. (Default: false)"),
35
+ literal: z.coerce
36
+ .boolean()
37
+ .nullable()
38
+ .describe("Pass true for fixed-string search (-F), false for regex, (Default: auto-detects unbalanced patterns like mismatched parentheses/brackets.)"),
39
+ maxResults: z.coerce
40
+ .number()
41
+ .nullable()
42
+ .describe("Maximum number of matches to return. Set to 0 for no limit. (Default: configured value)"),
43
+ });
44
+ export const createGrepTool = (options) => {
45
+ const { tokenCounter } = options;
11
46
  return {
12
- [GrepTool.name]: tool({
13
- description: "Search files for patterns using ripgrep",
14
- inputSchema: z.object({
15
- pattern: z.string().describe("The regex pattern to search for"),
16
- path: z.string().describe("The path to search in"),
17
- recursive: z
18
- .boolean()
19
- .nullable()
20
- .describe("Pass null to use the default (true, search recursively)."),
21
- ignoreCase: z
22
- .boolean()
23
- .nullable()
24
- .describe("Pass null to use the default (false, case-sensitive search)."),
25
- filePattern: z
26
- .string()
27
- .nullable()
28
- .describe("Pass null if no file pattern filter is needed."),
29
- contextLines: z
30
- .number()
31
- .nullable()
32
- .describe("Pass null if no context lines are needed."),
33
- searchIgnored: z
34
- .boolean()
35
- .nullable()
36
- .describe("Pass null to use the default (false, don't search ignored files)."),
37
- literal: z
38
- .boolean()
39
- .nullable()
40
- .describe("Pass true to search as a fixed string (no regex). Pass null to auto-detect."),
41
- }),
42
- execute: ({ pattern, path, recursive, ignoreCase, filePattern, contextLines, searchIgnored, literal, }, { toolCallId }) => {
43
- try {
44
- sendData?.({
45
- event: "tool-init",
46
- id: toolCallId,
47
- data: `Searching codebase for "${chalk.cyan(inspect(pattern))}" in ${chalk.cyan(path)}`,
48
- });
49
- // Normalize literal option: if null => auto-detect using heuristic
50
- let effectiveLiteral = null;
51
- if (literal === true) {
52
- effectiveLiteral = true;
53
- }
54
- else if (literal === false) {
55
- effectiveLiteral = false;
56
- }
57
- else {
58
- // auto-detect
59
- try {
60
- if (likelyUnbalancedRegex(pattern)) {
61
- effectiveLiteral = true;
62
- sendData?.({
63
- event: "tool-update",
64
- id: toolCallId,
65
- data: {
66
- primary: "Pattern appears to contain unbalanced regex metacharacters; using fixed-string mode (-F).",
67
- },
68
- });
69
- }
70
- else {
71
- effectiveLiteral = false;
72
- }
47
+ toolDef: {
48
+ description: `Search files for patterns using ripgrep (rg). Uses glob patterns for file filtering (e.g., "*.ts", "**/*.test.ts"). Auto-detects unbalanced regex patterns and falls back to fixed-string search for safety. Results are limited to prevent overwhelming output; configure via maxResults parameter.`,
49
+ inputSchema,
50
+ },
51
+ async *execute({ pattern, path, recursive, ignoreCase, filePattern, contextLines, searchIgnored, literal, maxResults, }, { toolCallId, abortSignal }) {
52
+ // Check if execution has been aborted
53
+ if (abortSignal?.aborted) {
54
+ throw new Error("Grep search aborted");
55
+ }
56
+ try {
57
+ // grok doesn't follow my instructions
58
+ const safeFilePattern = filePattern === "null" || filePattern === "undefined"
59
+ ? null
60
+ : filePattern;
61
+ // Enhanced tool-init with detailed search parameters
62
+ let initMessage = `${style.cyan(inspect(pattern))} in ${style.cyan(path)}`;
63
+ if (safeFilePattern) {
64
+ initMessage += ` ${style.dim(`(filter: ${safeFilePattern})`)}`;
65
+ }
66
+ if (recursive === false) {
67
+ initMessage += ` ${style.dim("(non-recursive)")}`;
68
+ }
69
+ if (ignoreCase) {
70
+ initMessage += ` ${style.dim("(case-insensitive)")}`;
71
+ }
72
+ if (contextLines && contextLines > 0) {
73
+ initMessage += ` ${style.dim(`(with ${contextLines} context line${contextLines === 1 ? "" : "s"})`)}`;
74
+ }
75
+ yield {
76
+ name: GrepTool.name,
77
+ event: "tool-init",
78
+ id: toolCallId,
79
+ data: initMessage,
80
+ };
81
+ // Normalize literal option: if null => auto-detect using heuristic
82
+ let effectiveLiteral = null;
83
+ if (literal === true) {
84
+ effectiveLiteral = true;
85
+ }
86
+ else if (literal === false) {
87
+ effectiveLiteral = false;
88
+ }
89
+ else {
90
+ // auto-detect
91
+ try {
92
+ if (likelyUnbalancedRegex(pattern)) {
93
+ effectiveLiteral = true;
73
94
  }
74
- catch (_err) {
95
+ else {
75
96
  effectiveLiteral = false;
76
97
  }
77
98
  }
78
- const result = grepFiles(pattern, path, {
79
- recursive,
80
- ignoreCase,
81
- filePattern,
82
- contextLines,
83
- searchIgnored,
84
- literal: effectiveLiteral,
85
- });
86
- const matchCount = result === "No matches found."
87
- ? 0
88
- : result
89
- .trim()
90
- .split("\n")
91
- .filter((line) => {
92
- if (line === "--") {
93
- return false;
94
- }
95
- return /^(.+?):(\d+):(.*)$/.test(line);
96
- }).length;
97
- sendData?.({
98
- event: "tool-completion",
99
- id: toolCallId,
100
- data: `Found ${chalk.cyan(matchCount)} matches.`,
101
- });
102
- return Promise.resolve(result);
103
- }
104
- catch (error) {
105
- sendData?.({
106
- event: "tool-error",
107
- id: toolCallId,
108
- data: `Error searching for "${pattern}" in ${path}`,
109
- });
110
- return Promise.resolve(error.message);
111
- }
112
- },
113
- }),
99
+ catch (_err) {
100
+ effectiveLiteral = false;
101
+ }
102
+ }
103
+ const projectConfig = await config.readProjectConfig();
104
+ const configMaxResults = projectConfig.tools.maxResults;
105
+ const effectiveMaxResults = maxResults ?? configMaxResults;
106
+ const grepResult = grepFilesStructured(pattern, path, {
107
+ recursive,
108
+ ignoreCase,
109
+ filePattern: safeFilePattern,
110
+ contextLines,
111
+ searchIgnored,
112
+ literal: effectiveLiteral,
113
+ maxResults: effectiveMaxResults,
114
+ });
115
+ const result = await manageTokenLimit(grepResult.rawOutput, tokenCounter, "Grep", "Use maxResults parameter, more specific patterns, or contextLines=0 to reduce output");
116
+ const matchCount = grepResult.matchCount;
117
+ // Build completion message with preview information
118
+ let completionMessage = `Found ${style.cyan(matchCount)} match${matchCount === 1 ? "" : "es"}`;
119
+ if (matchCount === 0) {
120
+ completionMessage = "Search completed - no matches found";
121
+ }
122
+ // Calculate unique files with matches
123
+ const filesWithMatches = new Set(grepResult.parsedMatches
124
+ .filter((match) => match.isMatch && !match.isContext && match.file)
125
+ .map((match) => match.file)).size;
126
+ if (filesWithMatches > 0) {
127
+ completionMessage += ` across ${style.cyan(filesWithMatches)} file${filesWithMatches === 1 ? "" : "s"}`;
128
+ }
129
+ if (grepResult.contextCount > 0) {
130
+ completionMessage += ` with ${style.cyan(grepResult.contextCount)} context line${grepResult.contextCount === 1 ? "" : "s"}`;
131
+ }
132
+ completionMessage += ` (${result.tokenCount} tokens)`;
133
+ yield {
134
+ name: GrepTool.name,
135
+ event: "tool-completion",
136
+ id: toolCallId,
137
+ data: completionMessage,
138
+ };
139
+ yield result.content;
140
+ }
141
+ catch (error) {
142
+ const errorMessage = error.message;
143
+ let userFriendlyError = `Error searching for "${pattern}" in ${path}: ${errorMessage}`;
144
+ // Provide more helpful error messages for common cases
145
+ if (errorMessage.includes("No such file or directory")) {
146
+ userFriendlyError = `Path not found: "${path}"`;
147
+ if (filePattern) {
148
+ userFriendlyError += ` with file pattern "${filePattern}"`;
149
+ }
150
+ userFriendlyError += " - check if the path exists and is accessible";
151
+ }
152
+ else if (errorMessage.includes("permission denied")) {
153
+ userFriendlyError = `Permission denied accessing "${path}"`;
154
+ }
155
+ else if (errorMessage.includes("Regex parse error")) {
156
+ userFriendlyError = `Invalid search pattern "${pattern}" - try using literal=true for fixed-string search`;
157
+ }
158
+ yield {
159
+ name: GrepTool.name,
160
+ event: "tool-error",
161
+ id: toolCallId,
162
+ data: userFriendlyError,
163
+ };
164
+ yield errorMessage;
165
+ }
166
+ },
114
167
  };
115
168
  };
116
- function likelyUnbalancedRegex(pattern) {
169
+ export function likelyUnbalancedRegex(pattern) {
117
170
  const counts = {
118
171
  openParen: 0,
119
172
  closeParen: 0,
@@ -123,6 +176,7 @@ function likelyUnbalancedRegex(pattern) {
123
176
  closeBrace: 0,
124
177
  };
125
178
  let escaped = false;
179
+ let inCharacterClass = false;
126
180
  for (let i = 0; i < pattern.length; i++) {
127
181
  const ch = pattern[i];
128
182
  if (escaped) {
@@ -133,32 +187,105 @@ function likelyUnbalancedRegex(pattern) {
133
187
  escaped = true;
134
188
  continue;
135
189
  }
136
- switch (ch) {
137
- case "(":
138
- counts.openParen++;
139
- break;
140
- case ")":
141
- counts.closeParen++;
142
- break;
143
- case "[":
144
- counts.openBracket++;
145
- break;
146
- case "]":
147
- counts.closeBracket++;
148
- break;
149
- case "{":
150
- counts.openBrace++;
151
- break;
152
- case "}":
153
- counts.closeBrace++;
154
- break;
155
- default:
156
- break;
190
+ // Track character class boundaries
191
+ if (ch === "[" && !inCharacterClass) {
192
+ inCharacterClass = true;
193
+ counts.openBracket++;
194
+ continue;
195
+ }
196
+ if (ch === "]" && inCharacterClass) {
197
+ inCharacterClass = false;
198
+ counts.closeBracket++;
199
+ continue;
200
+ }
201
+ // Only count brackets/parens/braces outside of character classes
202
+ if (!inCharacterClass) {
203
+ switch (ch) {
204
+ case "(":
205
+ counts.openParen++;
206
+ break;
207
+ case ")":
208
+ counts.closeParen++;
209
+ break;
210
+ case "{":
211
+ counts.openBrace++;
212
+ break;
213
+ case "}":
214
+ counts.closeBrace++;
215
+ break;
216
+ default:
217
+ break;
218
+ }
219
+ }
220
+ }
221
+ // Check for unbalanced brackets, parentheses, and braces
222
+ const hasUnbalancedBrackets = counts.openBracket !== counts.closeBracket;
223
+ const hasUnbalancedParens = counts.openParen !== counts.closeParen;
224
+ const hasUnbalancedBraces = counts.openBrace !== counts.closeBrace;
225
+ // Also check for invalid repetition operators (e.g., {n}, {n,}, {n,m}) outside of character classes
226
+ let hasInvalidRepetition = false;
227
+ {
228
+ let escaped2 = false;
229
+ let inClass2 = false;
230
+ for (let i = 0; i < pattern.length; i++) {
231
+ const ch = pattern[i];
232
+ if (escaped2) {
233
+ escaped2 = false;
234
+ continue;
235
+ }
236
+ if (ch === "\\") {
237
+ escaped2 = true;
238
+ continue;
239
+ }
240
+ if (ch === "[" && !inClass2) {
241
+ inClass2 = true;
242
+ continue;
243
+ }
244
+ if (ch === "]" && inClass2) {
245
+ inClass2 = false;
246
+ continue;
247
+ }
248
+ if (inClass2) {
249
+ continue;
250
+ }
251
+ if (ch === "{") {
252
+ let j = i + 1;
253
+ let hasDigits = false;
254
+ let hasComma = false;
255
+ while (j < pattern.length && pattern[j] !== "}") {
256
+ const c = pattern[j];
257
+ if (c >= "0" && c <= "9") {
258
+ hasDigits = true;
259
+ }
260
+ else if (c === "," && !hasComma) {
261
+ hasComma = true;
262
+ }
263
+ else {
264
+ break;
265
+ }
266
+ j++;
267
+ }
268
+ if (j >= pattern.length || pattern[j] !== "}") {
269
+ hasInvalidRepetition = true;
270
+ break;
271
+ }
272
+ // At this point we have a closing brace at j
273
+ if (!hasDigits) {
274
+ // Heuristic: treat empty {} as non-quantifier when it doesn't follow a likely atom
275
+ const prev = i > 0 ? pattern[i - 1] : undefined;
276
+ if (prev !== undefined && /\S/.test(prev)) {
277
+ hasInvalidRepetition = true;
278
+ break;
279
+ }
280
+ // else ignore as literal braces
281
+ }
282
+ }
157
283
  }
158
284
  }
159
- return (counts.openParen !== counts.closeParen ||
160
- counts.openBracket !== counts.closeBracket ||
161
- counts.openBrace !== counts.closeBrace);
285
+ return (hasUnbalancedBrackets ||
286
+ hasUnbalancedParens ||
287
+ hasUnbalancedBraces ||
288
+ hasInvalidRepetition);
162
289
  }
163
290
  /**
164
291
  * Search files for patterns using ripgrep
@@ -206,21 +333,179 @@ export function buildGrepCommand(pattern, path, options = {}) {
206
333
  command += " -F";
207
334
  }
208
335
  command += ` ${JSON.stringify(pattern)}`;
209
- command += ` ${path}`;
336
+ command += ` ${JSON.stringify(path)}`;
210
337
  return command;
211
338
  }
339
+ /**
340
+ * Parse ripgrep output and extract structured match information
341
+ */
342
+ export function parseRipgrepOutput(content) {
343
+ if (content === "No matches found.") {
344
+ return [];
345
+ }
346
+ const lines = content.trim().split("\n");
347
+ const parsed = [];
348
+ for (const line of lines) {
349
+ if (line === "--") {
350
+ // Separator between file groups - skip
351
+ continue;
352
+ }
353
+ if (line.trim() === "") {
354
+ // Empty line - skip
355
+ continue;
356
+ }
357
+ // Try multi-file format: file:line:content
358
+ const multiFileMatch = line.match(/^([^:]+):(\d+):(.+)$/);
359
+ if (multiFileMatch) {
360
+ parsed.push({
361
+ file: multiFileMatch[1],
362
+ line: Number.parseInt(multiFileMatch[2], 10),
363
+ content: multiFileMatch[3],
364
+ isMatch: true,
365
+ });
366
+ continue;
367
+ }
368
+ // Try single-file format: line:content
369
+ const singleFileMatch = line.match(/^(\d+):(.+)$/);
370
+ if (singleFileMatch) {
371
+ parsed.push({
372
+ line: Number.parseInt(singleFileMatch[1], 10),
373
+ content: singleFileMatch[2],
374
+ isMatch: true,
375
+ });
376
+ continue;
377
+ }
378
+ // Try context line format: file-line-context
379
+ const contextMatch = line.match(/^([^:]+)-(\d+)-(.+)$/);
380
+ if (contextMatch) {
381
+ parsed.push({
382
+ file: contextMatch[1],
383
+ line: Number.parseInt(contextMatch[2], 10),
384
+ content: contextMatch[3],
385
+ isMatch: false,
386
+ isContext: true,
387
+ });
388
+ continue;
389
+ }
390
+ // Try context line format without file: line-context
391
+ const contextNoFileMatch = line.match(/^(\d+)-(.+)$/);
392
+ if (contextNoFileMatch) {
393
+ parsed.push({
394
+ line: Number.parseInt(contextNoFileMatch[1], 10),
395
+ content: contextNoFileMatch[2],
396
+ isMatch: false,
397
+ isContext: true,
398
+ });
399
+ continue;
400
+ }
401
+ // If we get here, it's an unrecognized format - treat as match for backwards compatibility
402
+ parsed.push({
403
+ content: line,
404
+ line: 0,
405
+ isMatch: true,
406
+ });
407
+ }
408
+ return parsed;
409
+ }
410
+ /**
411
+ * Count actual matches (excluding context lines)
412
+ */
413
+ export function countActualMatches(parsed) {
414
+ return parsed.filter((match) => match.isMatch && !match.isContext).length;
415
+ }
416
+ /**
417
+ * Count context lines
418
+ */
419
+ export function countContextLines(parsed) {
420
+ return parsed.filter((match) => match.isContext).length;
421
+ }
422
+ /**
423
+ * Truncate matches to a maximum number of results
424
+ */
425
+ export function truncateMatches(matches, maxResults) {
426
+ if (!maxResults || maxResults <= 0) {
427
+ return { truncated: matches, isTruncated: false };
428
+ }
429
+ const actualMatches = matches.filter((m) => m.isMatch && !m.isContext);
430
+ if (actualMatches.length <= maxResults) {
431
+ return { truncated: matches, isTruncated: false };
432
+ }
433
+ const truncated = [];
434
+ let matchesKept = 0;
435
+ for (const match of matches) {
436
+ if (match.isMatch && !match.isContext) {
437
+ if (matchesKept < maxResults) {
438
+ truncated.push(match);
439
+ matchesKept++;
440
+ }
441
+ else {
442
+ break;
443
+ }
444
+ }
445
+ }
446
+ return {
447
+ truncated,
448
+ isTruncated: true,
449
+ };
450
+ }
451
+ /**
452
+ * Extract matches from content (backwards compatibility wrapper)
453
+ */
454
+ export function extractMatches(content) {
455
+ const parsed = parseRipgrepOutput(content);
456
+ const matches = parsed.filter((match) => match.isMatch && !match.isContext);
457
+ // Convert back to original string format for backwards compatibility
458
+ return matches.map((match) => {
459
+ if (match.file) {
460
+ return `${match.file}:${match.line}:${match.content}`;
461
+ }
462
+ return `${match.line}:${match.content}`;
463
+ });
464
+ }
212
465
  export function grepFiles(pattern, path, options = {}) {
466
+ const result = grepFilesStructured(pattern, path, options);
467
+ return result.rawOutput;
468
+ }
469
+ export function grepFilesStructured(pattern, path, options = {}) {
213
470
  try {
214
471
  const command = buildGrepCommand(pattern, path, options);
215
- const result = execSync(command, { encoding: "utf-8" });
216
- return result;
472
+ const rawOutput = execSync(command, {
473
+ encoding: "utf-8",
474
+ stdio: ["pipe", "pipe", "pipe"],
475
+ });
476
+ const parsedMatches = parseRipgrepOutput(rawOutput);
477
+ const matchCount = countActualMatches(parsedMatches);
478
+ const { truncated, isTruncated } = truncateMatches(parsedMatches, options.maxResults);
479
+ const displayedCount = countActualMatches(truncated);
480
+ const displayedContextCount = countContextLines(truncated);
481
+ return {
482
+ rawOutput,
483
+ parsedMatches: truncated,
484
+ matchCount,
485
+ displayedCount,
486
+ contextCount: displayedContextCount,
487
+ hasMatches: matchCount > 0,
488
+ isTruncated,
489
+ };
217
490
  }
218
491
  catch (error) {
219
- if (error instanceof Error &&
220
- "status" in error &&
221
- error.status === 1) {
222
- return "No matches found.";
492
+ const execError = error;
493
+ const exitCode = execError?.status;
494
+ if (exitCode === 1) {
495
+ return {
496
+ rawOutput: "No matches found.",
497
+ parsedMatches: [],
498
+ matchCount: 0,
499
+ contextCount: 0,
500
+ hasMatches: false,
501
+ };
502
+ }
503
+ if (exitCode === 2) {
504
+ const stderrStr = typeof execError.stderr === "string"
505
+ ? execError.stderr
506
+ : (execError.stderr?.toString("utf-8") ?? execError.message);
507
+ throw new Error(`Regex parse error in pattern "${pattern}": ${stderrStr}`);
223
508
  }
224
- throw new Error(`Error executing ripgrep: ${error.message}`);
509
+ throw new Error(`Error executing ripgrep: ${execError.message}`);
225
510
  }
226
511
  }