@travisennis/acai 0.0.1

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 (439) hide show
  1. package/.acai/acai.json +9 -0
  2. package/.acai/prompts/add-openrouter-model.md +13 -0
  3. package/.acai/prompts/project-status.md +4 -0
  4. package/.acai/prompts/update-architecture-document.md +9 -0
  5. package/.acai/rules/learned-rules.md +9 -0
  6. package/.ai/docs/available-tools.txt +3 -0
  7. package/.ai/docs/cognitive_complexity_refactoring_progress.md +65 -0
  8. package/.ai/docs/deleted_tools.md +168 -0
  9. package/.ai/docs/deleted_tools_88ced9ef.md +56 -0
  10. package/.ai/docs/image-pasting.md +46 -0
  11. package/.ai/docs/initialize-app.md +117 -0
  12. package/.ai/docs/issue-4-plan.md +44 -0
  13. package/.ai/docs/marked-renderer-debug.md +15 -0
  14. package/.ai/docs/marked-renderer-refactor-plan.md +64 -0
  15. package/.ai/docs/memory-use-cases.md +55 -0
  16. package/.ai/docs/prompt-consistency.md +31 -0
  17. package/.ai/docs/refactoring-tools.md +98 -0
  18. package/.ai/docs/system-prompt-update.md +174 -0
  19. package/.ai/docs/system_prompt.txt +210 -0
  20. package/.ai/docs/tasks.md +49 -0
  21. package/.ai/plan.md +131 -0
  22. package/.ai/prompt.md +1 -0
  23. package/.ai/scripts/fetch_models.js +27 -0
  24. package/.ai/scripts/generateSystemPrompt.ts +15 -0
  25. package/.ai/scripts/list-tools.mjs +4 -0
  26. package/.ai/scripts/p5_geometric_shapes.js +149 -0
  27. package/.husky/commit-msg +1 -0
  28. package/.husky/pre-commit +3 -0
  29. package/.husky/pre-push +1 -0
  30. package/.ignore +4 -0
  31. package/AGENTS.md +25 -0
  32. package/ARCHITECTURE.md +304 -0
  33. package/LICENSE +21 -0
  34. package/README.md +392 -0
  35. package/TODO.md +2 -0
  36. package/biome.json +61 -0
  37. package/commitlint.config.js +3 -0
  38. package/dist/cli.d.ts +19 -0
  39. package/dist/cli.js +116 -0
  40. package/dist/commands/application-log-command.d.ts +2 -0
  41. package/dist/commands/application-log-command.js +43 -0
  42. package/dist/commands/clear-command.d.ts +2 -0
  43. package/dist/commands/clear-command.js +12 -0
  44. package/dist/commands/compact-command.d.ts +2 -0
  45. package/dist/commands/compact-command.js +51 -0
  46. package/dist/commands/copy-command.d.ts +2 -0
  47. package/dist/commands/copy-command.js +51 -0
  48. package/dist/commands/edit-command.d.ts +2 -0
  49. package/dist/commands/edit-command.js +53 -0
  50. package/dist/commands/edit-prompt-command.d.ts +2 -0
  51. package/dist/commands/edit-prompt-command.js +25 -0
  52. package/dist/commands/exit-command.d.ts +2 -0
  53. package/dist/commands/exit-command.js +14 -0
  54. package/dist/commands/files-command.d.ts +2 -0
  55. package/dist/commands/files-command.js +63 -0
  56. package/dist/commands/generate-rules-command.d.ts +2 -0
  57. package/dist/commands/generate-rules-command.js +61 -0
  58. package/dist/commands/help-command.d.ts +2 -0
  59. package/dist/commands/help-command.js +19 -0
  60. package/dist/commands/init-command.d.ts +2 -0
  61. package/dist/commands/init-command.js +40 -0
  62. package/dist/commands/last-log-command.d.ts +2 -0
  63. package/dist/commands/last-log-command.js +76 -0
  64. package/dist/commands/manager.d.ts +22 -0
  65. package/dist/commands/manager.js +123 -0
  66. package/dist/commands/model-command.d.ts +2 -0
  67. package/dist/commands/model-command.js +84 -0
  68. package/dist/commands/paste-command.d.ts +2 -0
  69. package/dist/commands/paste-command.js +40 -0
  70. package/dist/commands/prompt-command.d.ts +2 -0
  71. package/dist/commands/prompt-command.js +111 -0
  72. package/dist/commands/reset-command.d.ts +2 -0
  73. package/dist/commands/reset-command.js +16 -0
  74. package/dist/commands/rules-command.d.ts +2 -0
  75. package/dist/commands/rules-command.js +68 -0
  76. package/dist/commands/save-command.d.ts +2 -0
  77. package/dist/commands/save-command.js +14 -0
  78. package/dist/commands/types.d.ts +26 -0
  79. package/dist/commands/types.js +1 -0
  80. package/dist/commands/usage-command.d.ts +2 -0
  81. package/dist/commands/usage-command.js +21 -0
  82. package/dist/config.d.ts +60 -0
  83. package/dist/config.js +193 -0
  84. package/dist/conversation-analyzer.d.ts +10 -0
  85. package/dist/conversation-analyzer.js +88 -0
  86. package/dist/dedent.d.ts +3 -0
  87. package/dist/dedent.js +38 -0
  88. package/dist/formatting.d.ts +17 -0
  89. package/dist/formatting.js +103 -0
  90. package/dist/index.d.ts +18 -0
  91. package/dist/index.js +213 -0
  92. package/dist/logger.d.ts +2 -0
  93. package/dist/logger.js +24 -0
  94. package/dist/mentions.d.ts +9 -0
  95. package/dist/mentions.js +182 -0
  96. package/dist/messages.d.ts +69 -0
  97. package/dist/messages.js +261 -0
  98. package/dist/middleware/audit-message.d.ts +5 -0
  99. package/dist/middleware/audit-message.js +95 -0
  100. package/dist/middleware/index.d.ts +2 -0
  101. package/dist/middleware/index.js +2 -0
  102. package/dist/middleware/rate-limit.d.ts +4 -0
  103. package/dist/middleware/rate-limit.js +17 -0
  104. package/dist/models/ai-config.d.ts +12 -0
  105. package/dist/models/ai-config.js +87 -0
  106. package/dist/models/anthropic-provider.d.ts +25 -0
  107. package/dist/models/anthropic-provider.js +184 -0
  108. package/dist/models/deepseek-provider.d.ts +20 -0
  109. package/dist/models/deepseek-provider.js +42 -0
  110. package/dist/models/google-provider.d.ts +19 -0
  111. package/dist/models/google-provider.js +56 -0
  112. package/dist/models/manager.d.ts +15 -0
  113. package/dist/models/manager.js +48 -0
  114. package/dist/models/openai-provider.d.ts +22 -0
  115. package/dist/models/openai-provider.js +70 -0
  116. package/dist/models/openrouter-provider.d.ts +36 -0
  117. package/dist/models/openrouter-provider.js +276 -0
  118. package/dist/models/providers.d.ts +33 -0
  119. package/dist/models/providers.js +116 -0
  120. package/dist/models/xai-provider.d.ts +20 -0
  121. package/dist/models/xai-provider.js +47 -0
  122. package/dist/parsing.d.ts +2 -0
  123. package/dist/parsing.js +18 -0
  124. package/dist/prompts/manager.d.ts +19 -0
  125. package/dist/prompts/manager.js +71 -0
  126. package/dist/prompts.d.ts +4 -0
  127. package/dist/prompts.js +158 -0
  128. package/dist/repl-prompt.d.ts +14 -0
  129. package/dist/repl-prompt.js +147 -0
  130. package/dist/repl.d.ts +27 -0
  131. package/dist/repl.js +431 -0
  132. package/dist/source/cli.d.ts +19 -0
  133. package/dist/source/cli.js +116 -0
  134. package/dist/source/commands/application-log-command.d.ts +2 -0
  135. package/dist/source/commands/application-log-command.js +43 -0
  136. package/dist/source/commands/clear-command.d.ts +2 -0
  137. package/dist/source/commands/clear-command.js +12 -0
  138. package/dist/source/commands/compact-command.d.ts +2 -0
  139. package/dist/source/commands/compact-command.js +51 -0
  140. package/dist/source/commands/copy-command.d.ts +2 -0
  141. package/dist/source/commands/copy-command.js +51 -0
  142. package/dist/source/commands/edit-command.d.ts +2 -0
  143. package/dist/source/commands/edit-command.js +53 -0
  144. package/dist/source/commands/edit-prompt-command.d.ts +2 -0
  145. package/dist/source/commands/edit-prompt-command.js +25 -0
  146. package/dist/source/commands/exit-command.d.ts +2 -0
  147. package/dist/source/commands/exit-command.js +14 -0
  148. package/dist/source/commands/files-command.d.ts +2 -0
  149. package/dist/source/commands/files-command.js +63 -0
  150. package/dist/source/commands/generate-rules-command.d.ts +2 -0
  151. package/dist/source/commands/generate-rules-command.js +61 -0
  152. package/dist/source/commands/help-command.d.ts +2 -0
  153. package/dist/source/commands/help-command.js +19 -0
  154. package/dist/source/commands/init-command.d.ts +2 -0
  155. package/dist/source/commands/init-command.js +40 -0
  156. package/dist/source/commands/last-log-command.d.ts +2 -0
  157. package/dist/source/commands/last-log-command.js +76 -0
  158. package/dist/source/commands/manager.d.ts +22 -0
  159. package/dist/source/commands/manager.js +123 -0
  160. package/dist/source/commands/model-command.d.ts +2 -0
  161. package/dist/source/commands/model-command.js +84 -0
  162. package/dist/source/commands/paste-command.d.ts +2 -0
  163. package/dist/source/commands/paste-command.js +40 -0
  164. package/dist/source/commands/prompt-command.d.ts +2 -0
  165. package/dist/source/commands/prompt-command.js +111 -0
  166. package/dist/source/commands/reset-command.d.ts +2 -0
  167. package/dist/source/commands/reset-command.js +16 -0
  168. package/dist/source/commands/rules-command.d.ts +2 -0
  169. package/dist/source/commands/rules-command.js +68 -0
  170. package/dist/source/commands/save-command.d.ts +2 -0
  171. package/dist/source/commands/save-command.js +14 -0
  172. package/dist/source/commands/types.d.ts +26 -0
  173. package/dist/source/commands/types.js +1 -0
  174. package/dist/source/commands/usage-command.d.ts +2 -0
  175. package/dist/source/commands/usage-command.js +21 -0
  176. package/dist/source/config.d.ts +60 -0
  177. package/dist/source/config.js +193 -0
  178. package/dist/source/conversation-analyzer.d.ts +10 -0
  179. package/dist/source/conversation-analyzer.js +88 -0
  180. package/dist/source/dedent.d.ts +3 -0
  181. package/dist/source/dedent.js +38 -0
  182. package/dist/source/formatting.d.ts +17 -0
  183. package/dist/source/formatting.js +103 -0
  184. package/dist/source/index.d.ts +18 -0
  185. package/dist/source/index.js +213 -0
  186. package/dist/source/logger.d.ts +2 -0
  187. package/dist/source/logger.js +24 -0
  188. package/dist/source/mentions.d.ts +9 -0
  189. package/dist/source/mentions.js +182 -0
  190. package/dist/source/messages.d.ts +69 -0
  191. package/dist/source/messages.js +261 -0
  192. package/dist/source/middleware/audit-message.d.ts +5 -0
  193. package/dist/source/middleware/audit-message.js +95 -0
  194. package/dist/source/middleware/index.d.ts +2 -0
  195. package/dist/source/middleware/index.js +2 -0
  196. package/dist/source/middleware/rate-limit.d.ts +4 -0
  197. package/dist/source/middleware/rate-limit.js +17 -0
  198. package/dist/source/models/ai-config.d.ts +12 -0
  199. package/dist/source/models/ai-config.js +87 -0
  200. package/dist/source/models/anthropic-provider.d.ts +25 -0
  201. package/dist/source/models/anthropic-provider.js +184 -0
  202. package/dist/source/models/deepseek-provider.d.ts +20 -0
  203. package/dist/source/models/deepseek-provider.js +42 -0
  204. package/dist/source/models/google-provider.d.ts +19 -0
  205. package/dist/source/models/google-provider.js +56 -0
  206. package/dist/source/models/manager.d.ts +15 -0
  207. package/dist/source/models/manager.js +48 -0
  208. package/dist/source/models/openai-provider.d.ts +22 -0
  209. package/dist/source/models/openai-provider.js +70 -0
  210. package/dist/source/models/openrouter-provider.d.ts +36 -0
  211. package/dist/source/models/openrouter-provider.js +276 -0
  212. package/dist/source/models/providers.d.ts +33 -0
  213. package/dist/source/models/providers.js +116 -0
  214. package/dist/source/models/xai-provider.d.ts +20 -0
  215. package/dist/source/models/xai-provider.js +47 -0
  216. package/dist/source/parsing.d.ts +2 -0
  217. package/dist/source/parsing.js +18 -0
  218. package/dist/source/prompts/manager.d.ts +19 -0
  219. package/dist/source/prompts/manager.js +71 -0
  220. package/dist/source/prompts.d.ts +4 -0
  221. package/dist/source/prompts.js +158 -0
  222. package/dist/source/repl-prompt.d.ts +14 -0
  223. package/dist/source/repl-prompt.js +147 -0
  224. package/dist/source/repl.d.ts +27 -0
  225. package/dist/source/repl.js +431 -0
  226. package/dist/source/terminal/formatting.d.ts +37 -0
  227. package/dist/source/terminal/formatting.js +106 -0
  228. package/dist/source/terminal/index.d.ts +94 -0
  229. package/dist/source/terminal/index.js +420 -0
  230. package/dist/source/terminal/markdown-utils.d.ts +2 -0
  231. package/dist/source/terminal/markdown-utils.js +81 -0
  232. package/dist/source/terminal/markdown.d.ts +1 -0
  233. package/dist/source/terminal/markdown.js +111 -0
  234. package/dist/source/terminal/types.d.ts +71 -0
  235. package/dist/source/terminal/types.js +1 -0
  236. package/dist/source/terminal-output.d.ts +8 -0
  237. package/dist/source/terminal-output.js +213 -0
  238. package/dist/source/terminal-output.test.d.ts +8 -0
  239. package/dist/source/terminal-output.test.js +213 -0
  240. package/dist/source/token-tracker.d.ts +14 -0
  241. package/dist/source/token-tracker.js +53 -0
  242. package/dist/source/token-utils.d.ts +7 -0
  243. package/dist/source/token-utils.js +13 -0
  244. package/dist/source/tools/agent.d.ts +17 -0
  245. package/dist/source/tools/agent.js +87 -0
  246. package/dist/source/tools/bash.d.ts +19 -0
  247. package/dist/source/tools/bash.js +294 -0
  248. package/dist/source/tools/code-interpreter.d.ts +12 -0
  249. package/dist/source/tools/code-interpreter.js +131 -0
  250. package/dist/source/tools/command-validation.d.ts +8 -0
  251. package/dist/source/tools/command-validation.js +69 -0
  252. package/dist/source/tools/delete-file.d.ts +12 -0
  253. package/dist/source/tools/delete-file.js +56 -0
  254. package/dist/source/tools/directory-tree.d.ts +12 -0
  255. package/dist/source/tools/directory-tree.js +38 -0
  256. package/dist/source/tools/edit-file.d.ts +19 -0
  257. package/dist/source/tools/edit-file.js +107 -0
  258. package/dist/source/tools/filesystem-utils.d.ts +22 -0
  259. package/dist/source/tools/filesystem-utils.js +191 -0
  260. package/dist/source/tools/git-utils.d.ts +14 -0
  261. package/dist/source/tools/git-utils.js +64 -0
  262. package/dist/source/tools/grep.d.ts +17 -0
  263. package/dist/source/tools/grep.js +138 -0
  264. package/dist/source/tools/index.d.ts +161 -0
  265. package/dist/source/tools/index.js +209 -0
  266. package/dist/source/tools/memory-read.d.ts +13 -0
  267. package/dist/source/tools/memory-read.js +135 -0
  268. package/dist/source/tools/memory-write.d.ts +12 -0
  269. package/dist/source/tools/memory-write.js +83 -0
  270. package/dist/source/tools/move-file.d.ts +13 -0
  271. package/dist/source/tools/move-file.js +44 -0
  272. package/dist/source/tools/read-file.d.ts +17 -0
  273. package/dist/source/tools/read-file.js +86 -0
  274. package/dist/source/tools/read-multiple-files.d.ts +14 -0
  275. package/dist/source/tools/read-multiple-files.js +55 -0
  276. package/dist/source/tools/save-file.d.ts +17 -0
  277. package/dist/source/tools/save-file.js +98 -0
  278. package/dist/source/tools/think.d.ts +11 -0
  279. package/dist/source/tools/think.js +45 -0
  280. package/dist/source/tools/types.d.ts +29 -0
  281. package/dist/source/tools/types.js +14 -0
  282. package/dist/source/tools/web-fetch.d.ts +47 -0
  283. package/dist/source/tools/web-fetch.js +246 -0
  284. package/dist/source/tools/web-search.d.ts +13 -0
  285. package/dist/source/tools/web-search.js +80 -0
  286. package/dist/source/utils/process.d.ts +36 -0
  287. package/dist/source/utils/process.js +75 -0
  288. package/dist/source/version.d.ts +1 -0
  289. package/dist/source/version.js +21 -0
  290. package/dist/terminal/formatting.d.ts +37 -0
  291. package/dist/terminal/formatting.js +106 -0
  292. package/dist/terminal/index.d.ts +94 -0
  293. package/dist/terminal/index.js +420 -0
  294. package/dist/terminal/markdown-utils.d.ts +2 -0
  295. package/dist/terminal/markdown-utils.js +81 -0
  296. package/dist/terminal/markdown.d.ts +1 -0
  297. package/dist/terminal/markdown.js +111 -0
  298. package/dist/terminal/types.d.ts +71 -0
  299. package/dist/terminal/types.js +1 -0
  300. package/dist/terminal-output.d.ts +8 -0
  301. package/dist/terminal-output.js +213 -0
  302. package/dist/token-tracker.d.ts +14 -0
  303. package/dist/token-tracker.js +53 -0
  304. package/dist/token-utils.d.ts +7 -0
  305. package/dist/token-utils.js +13 -0
  306. package/dist/tools/agent.d.ts +17 -0
  307. package/dist/tools/agent.js +87 -0
  308. package/dist/tools/bash.d.ts +19 -0
  309. package/dist/tools/bash.js +294 -0
  310. package/dist/tools/code-interpreter.d.ts +12 -0
  311. package/dist/tools/code-interpreter.js +131 -0
  312. package/dist/tools/command-validation.d.ts +8 -0
  313. package/dist/tools/command-validation.js +69 -0
  314. package/dist/tools/delete-file.d.ts +12 -0
  315. package/dist/tools/delete-file.js +56 -0
  316. package/dist/tools/directory-tree.d.ts +12 -0
  317. package/dist/tools/directory-tree.js +38 -0
  318. package/dist/tools/edit-file.d.ts +19 -0
  319. package/dist/tools/edit-file.js +107 -0
  320. package/dist/tools/filesystem-utils.d.ts +22 -0
  321. package/dist/tools/filesystem-utils.js +191 -0
  322. package/dist/tools/git-utils.d.ts +14 -0
  323. package/dist/tools/git-utils.js +64 -0
  324. package/dist/tools/grep.d.ts +17 -0
  325. package/dist/tools/grep.js +138 -0
  326. package/dist/tools/index.d.ts +161 -0
  327. package/dist/tools/index.js +209 -0
  328. package/dist/tools/memory-read.d.ts +13 -0
  329. package/dist/tools/memory-read.js +135 -0
  330. package/dist/tools/memory-write.d.ts +12 -0
  331. package/dist/tools/memory-write.js +83 -0
  332. package/dist/tools/move-file.d.ts +13 -0
  333. package/dist/tools/move-file.js +44 -0
  334. package/dist/tools/read-file.d.ts +17 -0
  335. package/dist/tools/read-file.js +86 -0
  336. package/dist/tools/read-multiple-files.d.ts +14 -0
  337. package/dist/tools/read-multiple-files.js +55 -0
  338. package/dist/tools/save-file.d.ts +17 -0
  339. package/dist/tools/save-file.js +98 -0
  340. package/dist/tools/think.d.ts +11 -0
  341. package/dist/tools/think.js +45 -0
  342. package/dist/tools/types.d.ts +29 -0
  343. package/dist/tools/types.js +14 -0
  344. package/dist/tools/web-fetch.d.ts +47 -0
  345. package/dist/tools/web-fetch.js +246 -0
  346. package/dist/tools/web-search.d.ts +13 -0
  347. package/dist/tools/web-search.js +80 -0
  348. package/dist/utils/process.d.ts +36 -0
  349. package/dist/utils/process.js +75 -0
  350. package/dist/version.d.ts +1 -0
  351. package/dist/version.js +21 -0
  352. package/knip.json +5 -0
  353. package/package.json +83 -0
  354. package/source/cli.ts +172 -0
  355. package/source/commands/application-log-command.ts +53 -0
  356. package/source/commands/clear-command.ts +14 -0
  357. package/source/commands/compact-command.ts +64 -0
  358. package/source/commands/copy-command.ts +55 -0
  359. package/source/commands/edit-command.ts +63 -0
  360. package/source/commands/edit-prompt-command.ts +31 -0
  361. package/source/commands/exit-command.ts +18 -0
  362. package/source/commands/files-command.ts +85 -0
  363. package/source/commands/generate-rules-command.ts +82 -0
  364. package/source/commands/help-command.ts +27 -0
  365. package/source/commands/init-command.ts +48 -0
  366. package/source/commands/last-log-command.ts +88 -0
  367. package/source/commands/manager.ts +151 -0
  368. package/source/commands/model-command.ts +123 -0
  369. package/source/commands/paste-command.ts +62 -0
  370. package/source/commands/prompt-command.ts +150 -0
  371. package/source/commands/reset-command.ts +22 -0
  372. package/source/commands/rules-command.ts +76 -0
  373. package/source/commands/save-command.ts +20 -0
  374. package/source/commands/types.ts +28 -0
  375. package/source/commands/usage-command.ts +26 -0
  376. package/source/config.ts +223 -0
  377. package/source/conversation-analyzer.ts +115 -0
  378. package/source/dedent.ts +53 -0
  379. package/source/formatting.ts +132 -0
  380. package/source/index.ts +240 -0
  381. package/source/logger.ts +29 -0
  382. package/source/mentions.ts +227 -0
  383. package/source/messages.ts +360 -0
  384. package/source/middleware/audit-message.ts +133 -0
  385. package/source/middleware/index.ts +2 -0
  386. package/source/middleware/rate-limit.ts +24 -0
  387. package/source/models/ai-config.ts +109 -0
  388. package/source/models/anthropic-provider.ts +199 -0
  389. package/source/models/deepseek-provider.ts +53 -0
  390. package/source/models/google-provider.ts +68 -0
  391. package/source/models/manager.ts +84 -0
  392. package/source/models/openai-provider.ts +81 -0
  393. package/source/models/openrouter-provider.ts +288 -0
  394. package/source/models/providers.ts +197 -0
  395. package/source/models/xai-provider.ts +59 -0
  396. package/source/parsing.ts +20 -0
  397. package/source/prompts/manager.ts +90 -0
  398. package/source/prompts.ts +172 -0
  399. package/source/repl-prompt.ts +196 -0
  400. package/source/repl.ts +572 -0
  401. package/source/terminal/formatting.ts +121 -0
  402. package/source/terminal/index.ts +518 -0
  403. package/source/terminal/markdown-utils.ts +89 -0
  404. package/source/terminal/markdown.ts +155 -0
  405. package/source/terminal/types.ts +84 -0
  406. package/source/terminal-output.test.ts +266 -0
  407. package/source/token-tracker.ts +78 -0
  408. package/source/token-utils.ts +17 -0
  409. package/source/tools/agent.ts +107 -0
  410. package/source/tools/bash.ts +367 -0
  411. package/source/tools/code-interpreter.ts +172 -0
  412. package/source/tools/command-validation.ts +81 -0
  413. package/source/tools/delete-file.ts +71 -0
  414. package/source/tools/directory-tree.ts +54 -0
  415. package/source/tools/edit-file.ts +155 -0
  416. package/source/tools/filesystem-utils.ts +265 -0
  417. package/source/tools/git-utils.ts +70 -0
  418. package/source/tools/grep.ts +184 -0
  419. package/source/tools/index.ts +278 -0
  420. package/source/tools/memory-read.ts +174 -0
  421. package/source/tools/memory-write.ts +105 -0
  422. package/source/tools/move-file.ts +59 -0
  423. package/source/tools/read-file.ts +129 -0
  424. package/source/tools/read-multiple-files.ts +80 -0
  425. package/source/tools/save-file.ts +147 -0
  426. package/source/tools/think.ts +51 -0
  427. package/source/tools/types.ts +58 -0
  428. package/source/tools/web-fetch.ts +327 -0
  429. package/source/tools/web-search.ts +101 -0
  430. package/source/utils/process.ts +121 -0
  431. package/source/version.ts +21 -0
  432. package/test/commands/copy-command.test.ts +69 -0
  433. package/test/config.test.ts +200 -0
  434. package/test/terminal/markdown-utils.test.ts +124 -0
  435. package/test/tools/bash-tool.test.ts +58 -0
  436. package/test/tools/code-interpreter.test.ts +91 -0
  437. package/test/tools/command-validation.test.ts +48 -0
  438. package/tsconfig.build.json +9 -0
  439. package/tsconfig.json +30 -0
@@ -0,0 +1,155 @@
1
+ import { EOL } from "node:os";
2
+ import chalk from "chalk";
3
+ import { highlight, supportsLanguage } from "cli-highlight";
4
+ import Table from "cli-table3";
5
+ import { marked, type Token } from "marked";
6
+ import { logger } from "../logger.ts";
7
+ import { link as terminalLink } from "./formatting.ts";
8
+ import { getListNumber } from "./markdown-utils.ts";
9
+
10
+ function logError(msg: string) {
11
+ logger.error(msg);
12
+ }
13
+
14
+ export function applyMarkdown(content: string): string {
15
+ return marked
16
+ .lexer(content)
17
+ .map((token) => format(token))
18
+ .join("")
19
+ .trim();
20
+ }
21
+
22
+ function format(
23
+ token: Token,
24
+ listDepth = 0,
25
+ orderedListNumber: number | null = null,
26
+ parent: Token | null = null,
27
+ ): string {
28
+ switch (token.type) {
29
+ case "blockquote":
30
+ return chalk.dim.italic(
31
+ (token.tokens ?? [])
32
+ .map((_) => format(_))
33
+ .map((l) => ` ${l}`)
34
+ .join(""),
35
+ );
36
+ case "code": {
37
+ if (token.lang && supportsLanguage(token.lang)) {
38
+ return highlight(token.text, { language: token.lang }) + EOL;
39
+ }
40
+ logError(
41
+ `Language not supported while highlighting code, falling back to markdown: ${token.lang}`,
42
+ );
43
+ return highlight(token.text, { language: "markdown" }) + EOL;
44
+ }
45
+ case "codespan":
46
+ // inline code
47
+ return chalk.blue(token.text);
48
+ case "em":
49
+ return chalk.italic((token.tokens ?? []).map((_) => format(_)).join(""));
50
+ case "strong":
51
+ return chalk.bold((token.tokens ?? []).map((_) => format(_)).join(""));
52
+ case "heading":
53
+ switch (token.depth) {
54
+ case 1: // h1
55
+ return (
56
+ chalk.bold.italic.underline(
57
+ (token.tokens ?? []).map((_) => format(_)).join(""),
58
+ ) +
59
+ EOL +
60
+ EOL
61
+ );
62
+ case 2: // h2
63
+ return (
64
+ chalk.bold((token.tokens ?? []).map((_) => format(_)).join("")) +
65
+ EOL +
66
+ EOL
67
+ );
68
+ default: // h3+
69
+ return (
70
+ chalk.bold.dim(
71
+ (token.tokens ?? []).map((_) => format(_)).join(""),
72
+ ) +
73
+ EOL +
74
+ EOL
75
+ );
76
+ }
77
+ case "hr":
78
+ return "---";
79
+ case "image": {
80
+ const alt = (token.title ?? token.text ?? "").toString().trim();
81
+ if (alt.length > 0) {
82
+ return `[Image: ${alt} (${token.href})]`;
83
+ }
84
+ return `[Image: ${token.href}]`;
85
+ }
86
+ case "link":
87
+ return terminalLink(token.text, token.href);
88
+ case "list": {
89
+ return token.items
90
+ .map((_: Token, index: number) =>
91
+ format(
92
+ _,
93
+ listDepth,
94
+ token.ordered ? token.start + index : null,
95
+ token,
96
+ ),
97
+ )
98
+ .join("");
99
+ }
100
+ case "list_item":
101
+ return (token.tokens ?? [])
102
+ .map(
103
+ (_) =>
104
+ `${" ".repeat(listDepth)}${format(_, listDepth + 1, orderedListNumber, token)}`,
105
+ )
106
+ .join("");
107
+ case "paragraph":
108
+ return (token.tokens ?? []).map((_) => format(_)).join("") + EOL;
109
+ case "space":
110
+ return EOL;
111
+ case "text": {
112
+ if (parent?.type === "list_item") {
113
+ return `${orderedListNumber === null ? "-" : `${getListNumber(listDepth, orderedListNumber)}.`} ${token.tokens ? token.tokens.map((_) => format(_, listDepth, orderedListNumber, token)).join("") : token.text}${EOL}`;
114
+ }
115
+ return token.text;
116
+ }
117
+ case "table": {
118
+ const header = Array.isArray(token.header)
119
+ ? token.header
120
+ : [token.header];
121
+ const rows = Array.isArray(token.rows) ? token.rows : [token.rows];
122
+
123
+ // Calculate column widths based on terminal width
124
+ const padding = 5; // Account for table borders and padding
125
+ const availableWidth = Math.max(
126
+ 10,
127
+ (process.stdout.columns || 80) - padding,
128
+ );
129
+ const colCount = header?.length ?? 1;
130
+ const width = Math.max(
131
+ 10,
132
+ Math.floor(availableWidth / Math.max(1, colCount)),
133
+ );
134
+ const computedColWidths: number[] = new Array(colCount).fill(width);
135
+
136
+ const table = new Table({
137
+ head: header.map((h) => h.text),
138
+ colWidths: computedColWidths,
139
+ wordWrap: true, // Enable word wrapping for the description column
140
+ });
141
+
142
+ table.push(
143
+ ...rows.map((row) => row.map((c: { text: string }) => c.text)),
144
+ );
145
+
146
+ return `${table.toString()}\n`;
147
+ }
148
+ case "del": {
149
+ return chalk.strikethrough(token.text);
150
+ }
151
+ default:
152
+ console.log(token.type);
153
+ return "";
154
+ }
155
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Terminal theme options
3
+ */
4
+ type TerminalTheme = "dark" | "light" | "system";
5
+
6
+ /**
7
+ * Terminal configuration
8
+ */
9
+ export interface TerminalConfig {
10
+ /**
11
+ * Terminal color theme
12
+ */
13
+ theme: TerminalTheme;
14
+
15
+ /**
16
+ * Whether to use colors in output
17
+ */
18
+ useColors: boolean;
19
+
20
+ /**
21
+ * Whether to show progress indicators
22
+ */
23
+ showProgressIndicators: boolean;
24
+
25
+ /**
26
+ * Whether to enable syntax highlighting for code
27
+ */
28
+ codeHighlighting: boolean;
29
+
30
+ /**
31
+ * Maximum terminal height (rows)
32
+ */
33
+ maxHeight?: number | undefined;
34
+
35
+ /**
36
+ * Maximum terminal width (columns)
37
+ */
38
+ maxWidth?: number | undefined;
39
+ }
40
+
41
+ /**
42
+ * Spinner instance for progress indicators
43
+ */
44
+ export interface SpinnerInstance {
45
+ /**
46
+ * Spinner identifier
47
+ */
48
+ id: string;
49
+
50
+ /**
51
+ * Update spinner text
52
+ */
53
+ update(text: string): SpinnerInstance;
54
+
55
+ /**
56
+ * Mark spinner as successful and stop
57
+ */
58
+ succeed(text?: string): SpinnerInstance;
59
+
60
+ /**
61
+ * Mark spinner as failed and stop
62
+ */
63
+ fail(text?: string): SpinnerInstance;
64
+
65
+ /**
66
+ * Mark spinner with warning and stop
67
+ */
68
+ warn(text?: string): SpinnerInstance;
69
+
70
+ /**
71
+ * Mark spinner with info and stop
72
+ */
73
+ info(text?: string): SpinnerInstance;
74
+
75
+ /**
76
+ * Clear spinner without any indicator
77
+ */
78
+ clear(): SpinnerInstance;
79
+
80
+ /**
81
+ * Stop spinner without any indicator
82
+ */
83
+ stop(): SpinnerInstance;
84
+ }
@@ -0,0 +1,266 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+
3
+ /**
4
+ * Terminal Output Test Module
5
+ *
6
+ * Exercises all methods and features of the Terminal class for testing purposes.
7
+ * Demonstrates various markdown rendering capabilities.
8
+ */
9
+
10
+ import { initTerminal } from "./terminal/index.ts";
11
+
12
+ // Initialize terminal
13
+ const terminal = initTerminal({
14
+ useColors: true,
15
+ showProgressIndicators: true,
16
+ });
17
+
18
+ // Test all terminal methods and features
19
+ function testTerminalOutput(): void {
20
+ // Clear screen and show welcome
21
+ terminal.clear();
22
+ terminal.displayWelcome();
23
+
24
+ // Test basic output methods
25
+ terminal.header("Basic Output Methods");
26
+ terminal.writeln("This is a basic write line");
27
+ terminal.write("This is a basic write without newline");
28
+ terminal.lineBreak();
29
+ terminal.emphasize("This is emphasized text");
30
+ terminal.info("This is an info message");
31
+ terminal.success("This is a success message");
32
+ terminal.warn("This is a warning message");
33
+ terminal.error("This is an error message");
34
+ terminal.lineBreak();
35
+
36
+ // Test markdown display
37
+ terminal.header("Markdown Display Features");
38
+
39
+ // Headers
40
+ terminal.display("# This is an H1 Header");
41
+ terminal.display("## This is an H2 Header");
42
+ terminal.display("### This is an H3 Header");
43
+ terminal.display("#### This is an H4 Header");
44
+ terminal.display("##### This is an H5 Header");
45
+ terminal.display("###### This is an H6 Header");
46
+
47
+ // Text formatting
48
+ terminal.display("**This is bold text**");
49
+ terminal.display("*This is italic text*");
50
+ terminal.display("***This is bold and italic text***");
51
+ terminal.display("This is `inline code` text");
52
+ terminal.display("~~This is strikethrough text~~");
53
+
54
+ // Links
55
+ terminal.display("This is a [link](https://example.com)");
56
+
57
+ // Images
58
+ terminal.display("This is an ![image](https://example.com/image.jpg)");
59
+
60
+ // Blockquotes
61
+ terminal.display("> This is a blockquote");
62
+ terminal.display("> This is a\n> multi-line blockquote");
63
+
64
+ // Horizontal rule
65
+ terminal.display("---");
66
+
67
+ // Lists
68
+ terminal.display("- This is an unordered list item");
69
+ terminal.display("- This is another unordered list item");
70
+ terminal.display(" - This is a nested list item");
71
+ terminal.display(" - This is a double nested list item");
72
+
73
+ terminal.display("1. This is an ordered list item");
74
+ terminal.display("2. This is another ordered list item");
75
+ terminal.display(" 1. This is a nested ordered list item");
76
+ terminal.display(" 2. This is another nested ordered list item");
77
+
78
+ // Code blocks
79
+ terminal.display(
80
+ "```javascript\nconst greeting = 'Hello World';\nconsole.log(greeting);\n```",
81
+ );
82
+ terminal.display("```python\ndef hello():\n print('Hello World')\n```");
83
+ terminal.display("```\nThis is a plain code block\n```");
84
+
85
+ // Tables
86
+ terminal.display(
87
+ "| Header 1 | Header 2 | Header 3 |\n|----------|----------|----------|\n| Cell 1 | Cell 2 | Cell 3 |\n| Cell 4 | Cell 5 | Cell 6 |",
88
+ );
89
+
90
+ // Paragraphs
91
+ terminal.display(
92
+ "This is a paragraph with some **bold** and *italic* text. " +
93
+ "It also contains `inline code` and a [link](https://example.com). " +
94
+ "Here's an ![image](image.jpg) for good measure.",
95
+ );
96
+
97
+ terminal.display(
98
+ "This is another paragraph that demonstrates how line breaks work " +
99
+ "in markdown with the terminal display. It should wrap appropriately based " +
100
+ "on the terminal width.",
101
+ );
102
+
103
+ // Complex markdown example
104
+ const complexMarkdown = `
105
+ # Complex Markdown Example
106
+
107
+ This is a complex example showing various **markdown** features in *one* document.
108
+
109
+ ## Features Demonstrated
110
+
111
+ 1. **Headers** of different levels
112
+ 2. *Text formatting* options
113
+ 3. \`Code elements\` of various types
114
+ 4. [External links](https://example.com)
115
+ 5. ![Images](image.jpg)
116
+ 6. Blockquotes
117
+
118
+ > Blockquotes
119
+
120
+ 7. Horizontal rules
121
+ 8. Lists (ordered and unordered)
122
+ 9. Tables
123
+ 10. Code blocks
124
+
125
+ ## Code Example
126
+
127
+ Here's some JavaScript code:
128
+
129
+ \`\`\`javascript
130
+ function fibonacci(n) {
131
+ if (n <= 1) return n;
132
+ return fibonacci(n - 1) + fibonacci(n - 2);
133
+ }
134
+
135
+ console.log(fibonacci(10)); // 55
136
+ \`\`\`
137
+
138
+ ## Table Example
139
+
140
+ | Name | Age | City |
141
+ |------|-----|------|
142
+ | John | 30 | New York |
143
+ | Jane | 25 | Boston |
144
+ | Bob | 35 | Chicago |
145
+
146
+ ## Blockquote Example
147
+
148
+ > This is a blockquote.
149
+ >
150
+ > It can span multiple lines.
151
+ >
152
+ > > It can also contain nested blockquotes.
153
+
154
+ ---
155
+
156
+ ## List Examples
157
+
158
+ ### Unordered List
159
+
160
+ - Item 1
161
+ - Item 2
162
+ - Nested item 2.1
163
+ - Nested item 2.2
164
+ - Double nested item 2.2.1
165
+ - Item 3
166
+
167
+ ### Ordered List
168
+
169
+ 1. First item
170
+ 2. Second item
171
+ 1. Nested item 2.1
172
+ 2. Nested item 2.2
173
+ 1. Double nested item 2.2.1
174
+ 3. Third item
175
+
176
+ ## Inline Elements
177
+
178
+ This paragraph contains **bold text**, *italic text*, \`inline code\`,
179
+ ~~strikethrough text~~, [a link](https://example.com), and ![an image](image.jpg).
180
+
181
+ The end of this complex example.
182
+ `;
183
+
184
+ terminal.header("Complex Markdown Example");
185
+ terminal.display(complexMarkdown);
186
+
187
+ // Test other terminal features
188
+ terminal.header("Other Terminal Features");
189
+
190
+ // Box display
191
+ terminal.box("Info Box", "This is content inside a box with a header");
192
+ terminal.box(
193
+ "Code",
194
+ `
195
+ \`\`\`javascript
196
+ function fibonacci(n) {
197
+ if (n <= 1) return n;
198
+ return fibonacci(n - 1) + fibonacci(n - 2);
199
+ }
200
+
201
+ console.log(fibonacci(10)); // 55
202
+ \`\`\`
203
+ `,
204
+ );
205
+
206
+ terminal.box(
207
+ "Markdown Block",
208
+ `
209
+ This paragraph contains **bold text**, *italic text*, \`inline code\`,
210
+ ~~strikethrough text~~, [a link](https://example.com), and ![an image](image.jpg).
211
+ `,
212
+ );
213
+
214
+ // Horizontal rule
215
+ terminal.hr();
216
+
217
+ // Table
218
+ terminal.table(
219
+ [
220
+ ["Headers", "Working"],
221
+ ["Text Formatting", "Working"],
222
+ ["Lists", "Working"],
223
+ ["Code Blocks", "Working"],
224
+ ["Tables", "Working"],
225
+ ["Links", "Working"],
226
+ ["Images", "Working"],
227
+ ["Blockquotes", "Working"],
228
+ ],
229
+ { header: ["Feature", "Status"] },
230
+ );
231
+
232
+ // Progress bar
233
+ terminal.header("Progress Bar Example");
234
+ for (let i = 0; i <= 100; i += 10) {
235
+ terminal.displayProgressBar(i, 100);
236
+ }
237
+
238
+ // Spinner (demonstration)
239
+ // terminal.header("Spinner Example");
240
+ // const spinner = terminal.spinner("Loading...");
241
+ // setTimeout(() => {
242
+ // spinner.succeed("Loading complete!");
243
+ // }, 2000);
244
+
245
+ // Terminal info
246
+ terminal.header("Terminal Information");
247
+ terminal.writeln(
248
+ `Terminal size: ${terminal["terminalWidth"]}x${terminal["terminalHeight"]}`,
249
+ );
250
+ terminal.writeln(`Is interactive: ${terminal["isInteractive"]}`);
251
+
252
+ // Link example
253
+ terminal.header("Link Example");
254
+ terminal.writeln(
255
+ `Visit ${terminal.link("Google", "https://google.com")} for search`,
256
+ );
257
+
258
+ // Alert
259
+ terminal.alert();
260
+
261
+ // Final message
262
+ terminal.success("All terminal features tested successfully!");
263
+ }
264
+
265
+ // Run the test
266
+ testTerminalOutput();
@@ -0,0 +1,78 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { isNumber } from "@travisennis/stdlib/typeguards";
3
+ import type { LanguageModelUsage } from "ai";
4
+
5
+ interface TokenUsage {
6
+ tool: string;
7
+ usage: Partial<LanguageModelUsage>;
8
+ }
9
+
10
+ interface TokenTrackerEvents {
11
+ usage: [LanguageModelUsage];
12
+ }
13
+
14
+ export class TokenTracker extends EventEmitter<TokenTrackerEvents> {
15
+ private usages: TokenUsage[] = [];
16
+
17
+ trackUsage(tool: string, usage: LanguageModelUsage | undefined) {
18
+ if (usage) {
19
+ const u = { tool, usage };
20
+ this.usages.push(u);
21
+ this.emit("usage", usage);
22
+ }
23
+ }
24
+
25
+ getTotalUsage(): LanguageModelUsage {
26
+ return this.usages.reduce(
27
+ (acc, { usage }) => {
28
+ acc.inputTokens += isNumber(usage.inputTokens) ? usage.inputTokens : 0;
29
+ acc.outputTokens += isNumber(usage.outputTokens)
30
+ ? usage.outputTokens
31
+ : 0;
32
+ acc.totalTokens += isNumber(usage.totalTokens) ? usage.totalTokens : 0;
33
+ return acc;
34
+ },
35
+ { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
36
+ );
37
+ }
38
+
39
+ getUsageByApp(app: string): LanguageModelUsage {
40
+ return this.usages
41
+ .filter(({ tool }) => tool === app)
42
+ .reduce(
43
+ (acc, { usage }) => {
44
+ acc.inputTokens += isNumber(usage.inputTokens)
45
+ ? usage.inputTokens
46
+ : 0;
47
+ acc.outputTokens += isNumber(usage.outputTokens)
48
+ ? usage.outputTokens
49
+ : 0;
50
+ acc.totalTokens += isNumber(usage.totalTokens)
51
+ ? usage.totalTokens
52
+ : 0;
53
+ return acc;
54
+ },
55
+ { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
56
+ );
57
+ }
58
+
59
+ getUsageBreakdown(): Record<string, number> {
60
+ return this.usages.reduce(
61
+ (acc, { tool, usage }) => {
62
+ acc[tool] =
63
+ (acc[tool] || 0) +
64
+ (isNumber(usage.totalTokens) ? usage.totalTokens : 0);
65
+ return acc;
66
+ },
67
+ {} as Record<string, number>,
68
+ );
69
+ }
70
+
71
+ printSummary() {
72
+ const breakdown = this.getUsageBreakdown();
73
+ console.info("Token Usage Summary:", {
74
+ total: this.getTotalUsage(),
75
+ breakdown,
76
+ });
77
+ }
78
+ }
@@ -0,0 +1,17 @@
1
+ import { encoding_for_model, type TiktokenModel } from "tiktoken";
2
+
3
+ export class TokenCounter {
4
+ private tiktokenEncoding: ReturnType<typeof encoding_for_model>;
5
+
6
+ constructor(model: TiktokenModel = "chatgpt-4o-latest") {
7
+ this.tiktokenEncoding = encoding_for_model(model);
8
+ }
9
+
10
+ count(input: string): number {
11
+ return this.tiktokenEncoding.encode(input).length;
12
+ }
13
+
14
+ free() {
15
+ this.tiktokenEncoding.free();
16
+ }
17
+ }
@@ -0,0 +1,107 @@
1
+ import { generateText, stepCountIs, tool } from "ai";
2
+ import chalk from "chalk";
3
+ import { z } from "zod";
4
+ import { AiConfig } from "../models/ai-config.ts";
5
+ import type { ModelManager } from "../models/manager.ts";
6
+ import type { TokenTracker } from "../token-tracker.ts";
7
+ import type { TokenCounter } from "../token-utils.ts";
8
+ import { BashTool } from "./bash.ts";
9
+ import { DirectoryTreeTool } from "./directory-tree.ts";
10
+ import { GrepTool } from "./grep.ts";
11
+ import { initCliTools } from "./index.ts";
12
+ import { ReadFileTool } from "./read-file.ts";
13
+ import { ReadMultipleFilesTool } from "./read-multiple-files.ts";
14
+ import type { SendData } from "./types.ts";
15
+
16
+ export const AgentTool = {
17
+ name: "agent" as const,
18
+ };
19
+
20
+ const TOOLS = [
21
+ GrepTool.name,
22
+ BashTool.name,
23
+ ReadFileTool.name,
24
+ ReadMultipleFilesTool.name,
25
+ DirectoryTreeTool.name,
26
+ ] as const;
27
+
28
+ type ToolName = (typeof TOOLS)[number];
29
+
30
+ function getToolDescription(): string {
31
+ const toolNames = TOOLS.join(", ");
32
+ return `Launch a new agent that has access to the following tools: ${toolNames}. When you are searching for a keyword or file and are not confident that you will find the right match on the first try, use the ${AgentTool.name} tool to perform the search for you. For example:
33
+
34
+ - If you are searching for a keyword like "config" or "logger", the ${AgentTool.name} tool is appropriate
35
+ - If you want to read a specific file path, use the ${ReadFileTool.name} or appropriate command via the ${BashTool.name} tool instead of this tool, to find the match more quickly
36
+ - If you are searching for a specific class definition like "class Foo", use the ${GrepTool.name} tool instead, to find the match more quickly
37
+
38
+ Usage notes:
39
+ 1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
40
+ 2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
41
+ 3. Each agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
42
+ 4. The agent's outputs should generally be trusted.`;
43
+ }
44
+
45
+ const inputSchema = z.object({
46
+ prompt: z.string().describe("The task for the agent to perform"),
47
+ });
48
+
49
+ export const createAgentTools = (options: {
50
+ modelManager: ModelManager;
51
+ tokenTracker: TokenTracker;
52
+ tokenCounter: TokenCounter;
53
+ sendData?: SendData | undefined;
54
+ }) => {
55
+ const { modelManager, tokenTracker, tokenCounter, sendData } = options;
56
+ return {
57
+ [AgentTool.name]: tool({
58
+ description: getToolDescription(),
59
+ inputSchema: inputSchema,
60
+ execute: async ({ prompt }, { abortSignal, toolCallId }) => {
61
+ sendData?.({
62
+ event: "tool-init",
63
+ id: toolCallId,
64
+ data: `Initializing agent with prompt: ${chalk.cyan(prompt)}`,
65
+ });
66
+ try {
67
+ const modelConfig = modelManager.getModelMetadata("task-agent");
68
+ const aiConfig = new AiConfig({
69
+ modelMetadata: modelConfig,
70
+ prompt: prompt,
71
+ });
72
+
73
+ const { text, usage } = await generateText({
74
+ model: modelManager.getModel("task-agent"),
75
+ maxOutputTokens: aiConfig.getMaxTokens(),
76
+ system:
77
+ "You are a code search assistant that will be given a task that will require you to search a code base to find relevant code and files.",
78
+ prompt: prompt,
79
+ stopWhen: stepCountIs(30),
80
+ providerOptions: aiConfig.getProviderOptions(),
81
+ tools: await initCliTools({ tokenCounter }),
82
+ abortSignal: abortSignal,
83
+ // biome-ignore lint/style/useNamingConvention: third-party code
84
+ experimental_activeTools: [...TOOLS] as ToolName[],
85
+ });
86
+
87
+ tokenTracker.trackUsage("task-agent", usage);
88
+
89
+ sendData?.({
90
+ event: "tool-completion",
91
+ id: toolCallId,
92
+ data: "Finished running the agent tool.",
93
+ });
94
+
95
+ return text;
96
+ } catch (error) {
97
+ sendData?.({
98
+ event: "tool-error",
99
+ id: toolCallId,
100
+ data: "Error running agent tool.",
101
+ });
102
+ return Promise.resolve((error as Error).message);
103
+ }
104
+ },
105
+ }),
106
+ };
107
+ };