@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,51 @@
1
+ import { generateText } from "ai";
2
+ import { createUserMessage } from "../messages.js";
3
+ export const compactCommand = (options) => {
4
+ return {
5
+ command: "/compact",
6
+ description: "Saves, summarizes, and resets the chat history. Optional instructions can be provided for the summary.",
7
+ result: "continue",
8
+ getSubCommands: () => Promise.resolve([]),
9
+ execute: async (args) => {
10
+ const { messageHistory, terminal } = options;
11
+ if (!messageHistory.isEmpty()) {
12
+ const additionalInstructions = args.join(" ");
13
+ await summarizeAndReset(options, additionalInstructions);
14
+ }
15
+ terminal.info("Message history summarized and reset.");
16
+ },
17
+ };
18
+ };
19
+ async function summarizeAndReset({ messageHistory, modelManager, tokenTracker }, additionalInstructions) {
20
+ const app = "conversation-summarizer";
21
+ // save existing message history
22
+ await messageHistory.save();
23
+ // summarize message history
24
+ let userPrompt = `Your tasks is to provide a detailed summary of our conversation so far. Focus on information that would be helpful for continuing the conversation and the task, including what was the orginal task requested by the user, what we have done so far and why, which files we're working on, and what we're going to do next. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently. You need to provide enough information that another coding agent can you use your summary to pick up where you have left off.
25
+
26
+ Your summary should include the following sections:
27
+ 1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
28
+ 2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
29
+ 3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
30
+ 4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
31
+ 5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
32
+ 6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
33
+ 7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
34
+ 8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
35
+ 9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests without confirming with the user first.
36
+
37
+ If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.`;
38
+ if (additionalInstructions && additionalInstructions.trim().length > 0) {
39
+ userPrompt += `\n\nAdditional instructions provided by the user: ${additionalInstructions}`;
40
+ }
41
+ messageHistory.appendUserMessage(createUserMessage([], userPrompt));
42
+ const { text, usage } = await generateText({
43
+ model: modelManager.getModel(app),
44
+ system: "You are a helpful AI assistant tasked with summarizing conversations so that a coding agent such as yourself can understand what actions have been taken on a code base and what future work still needs to be done.",
45
+ messages: messageHistory.get(),
46
+ });
47
+ tokenTracker.trackUsage(app, usage);
48
+ //clear messages
49
+ messageHistory.clear();
50
+ messageHistory.appendUserMessage(createUserMessage([text]));
51
+ }
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare function copyCommand(options: CommandOptions): ReplCommand;
@@ -0,0 +1,51 @@
1
+ import Clipboard from "@crosscopy/clipboard";
2
+ function extractLastAssistantText(messages) {
3
+ for (let i = messages.length - 1; i >= 0; i--) {
4
+ const msg = messages[i];
5
+ if (!msg)
6
+ continue;
7
+ if (msg.role !== "assistant")
8
+ continue;
9
+ if (!("content" in msg) || !Array.isArray(msg.content))
10
+ continue;
11
+ // Find last text part
12
+ for (let j = msg.content.length - 1; j >= 0; j--) {
13
+ const part = msg.content[j];
14
+ if (part &&
15
+ part.type === "text" &&
16
+ typeof part.text === "string") {
17
+ const text = part.text;
18
+ if (text.trim().length > 0)
19
+ return text;
20
+ }
21
+ }
22
+ }
23
+ return null;
24
+ }
25
+ export function copyCommand(options) {
26
+ return {
27
+ command: "/copy",
28
+ description: "Copy the last assistant response to the clipboard",
29
+ result: "continue",
30
+ async getSubCommands() {
31
+ return [];
32
+ },
33
+ async execute(_args) {
34
+ const { messageHistory, terminal } = options;
35
+ const history = messageHistory.get();
36
+ const lastText = extractLastAssistantText(history);
37
+ if (!lastText) {
38
+ terminal.info("No assistant response to copy.");
39
+ return;
40
+ }
41
+ try {
42
+ await Clipboard.setText(lastText);
43
+ terminal.success("Copied last response to clipboard.");
44
+ }
45
+ catch (err) {
46
+ const message = err instanceof Error ? err.message : String(err);
47
+ terminal.error(`Could not copy to clipboard: ${message}`);
48
+ }
49
+ },
50
+ };
51
+ }
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const editCommand: ({ terminal }: CommandOptions) => ReplCommand;
@@ -0,0 +1,53 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { extname, resolve } from "node:path";
3
+ import { editor, search } from "@inquirer/prompts";
4
+ import { globby } from "globby";
5
+ export const editCommand = ({ terminal }) => {
6
+ return {
7
+ command: "/edit",
8
+ description: "Opens file in $EDITOR for editing. Usage: /edit [file-path]",
9
+ result: "continue",
10
+ getSubCommands: () => Promise.resolve([]),
11
+ execute: async (args) => {
12
+ let fileToEdit;
13
+ if (args.length > 0) {
14
+ // File path provided as argument
15
+ const filePath = args.join(" "); // Handle file paths with spaces
16
+ const resolvedPath = resolve(filePath);
17
+ if (!existsSync(resolvedPath)) {
18
+ terminal.error(`File not found: ${filePath}`);
19
+ return;
20
+ }
21
+ fileToEdit = filePath;
22
+ }
23
+ else {
24
+ // No file path provided, use search prompt
25
+ fileToEdit = await search({
26
+ message: "Search for file:",
27
+ source: async (input) => {
28
+ if (!input) {
29
+ return [];
30
+ }
31
+ const foundFiles = await globby(`**/*${input}*`, {
32
+ gitignore: true,
33
+ });
34
+ return foundFiles.map((file) => ({
35
+ name: file,
36
+ value: file,
37
+ }));
38
+ },
39
+ });
40
+ }
41
+ const content = readFileSync(fileToEdit, { encoding: "utf8" });
42
+ const edit = await editor({
43
+ message: `Edit ${fileToEdit}?`,
44
+ postfix: extname(fileToEdit),
45
+ default: content,
46
+ });
47
+ writeFileSync(fileToEdit, edit);
48
+ if (content !== edit) {
49
+ terminal.info(`File updated: ${fileToEdit}`);
50
+ }
51
+ },
52
+ };
53
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const editPromptCommand: ({ terminal, promptManager, }: CommandOptions) => ReplCommand;
@@ -0,0 +1,25 @@
1
+ import { editor } from "@inquirer/prompts";
2
+ import { syncTry } from "@travisennis/stdlib/try";
3
+ export const editPromptCommand = ({ terminal, promptManager, }) => {
4
+ return {
5
+ command: "/edit-prompt",
6
+ description: "Edit the prompt.",
7
+ result: "use",
8
+ getSubCommands: () => Promise.resolve([]),
9
+ execute: async () => {
10
+ try {
11
+ const prompt = syncTry(() => promptManager.get());
12
+ const updatedPrompt = await editor({
13
+ message: " Edit prompt?",
14
+ postfix: "md",
15
+ default: prompt.unwrapOr(""),
16
+ });
17
+ terminal.writeln(`> ${updatedPrompt}`);
18
+ promptManager.set(updatedPrompt);
19
+ }
20
+ catch (error) {
21
+ terminal.error(`Error updating prompt: ${error.message}`);
22
+ }
23
+ },
24
+ };
25
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const exitCommand: ({ messageHistory, }: CommandOptions) => ReplCommand;
@@ -0,0 +1,14 @@
1
+ export const exitCommand = ({ messageHistory, }) => {
2
+ return {
3
+ command: "/exit",
4
+ aliases: ["/bye", "/quit"],
5
+ description: "Exits and saves the chat history.",
6
+ result: "break",
7
+ getSubCommands: () => Promise.resolve([]),
8
+ execute: async () => {
9
+ if (!messageHistory.isEmpty()) {
10
+ await messageHistory.save();
11
+ }
12
+ },
13
+ };
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const filesCommand: ({ terminal, promptManager, modelManager, }: CommandOptions) => ReplCommand;
@@ -0,0 +1,63 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { checkbox } from "@inquirer/prompts";
3
+ import { globby } from "globby";
4
+ import { formatFile } from "../formatting.js";
5
+ import { TokenCounter } from "../token-utils.js";
6
+ export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
7
+ return {
8
+ command: "/files",
9
+ description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
10
+ result: "continue",
11
+ getSubCommands: () => Promise.resolve([]),
12
+ execute: async (args) => {
13
+ try {
14
+ let workingFiles = [];
15
+ if (!args || args.length === 0) {
16
+ // Get all files in the current directory
17
+ const foundFiles = await globby("**/*", { gitignore: true });
18
+ const selectedFiles = await checkbox({
19
+ message: "Select files to include:",
20
+ choices: foundFiles,
21
+ pageSize: 15,
22
+ });
23
+ if (selectedFiles.length === 0) {
24
+ terminal.warn("No files selected.");
25
+ return;
26
+ }
27
+ // Process the selected files
28
+ workingFiles = selectedFiles;
29
+ }
30
+ else {
31
+ const patternList = args.filter(Boolean);
32
+ const foundFiles = await globby(patternList, { gitignore: true });
33
+ if (foundFiles.length === 0) {
34
+ terminal.warn("No files found matching the pattern(s)");
35
+ return;
36
+ }
37
+ // Process the selected files
38
+ workingFiles = foundFiles;
39
+ }
40
+ // Read the content of the files and format them for the next prompt
41
+ const format = modelManager.getModelMetadata("repl").promptFormat;
42
+ let tokenCount = 0;
43
+ const tokenCounter = new TokenCounter();
44
+ await Promise.all(workingFiles.map(async (filePath) => {
45
+ try {
46
+ const content = await readFile(filePath, "utf-8");
47
+ const formattedFile = formatFile(filePath, content, format);
48
+ tokenCount += tokenCounter.count(formattedFile);
49
+ promptManager.addContext(formattedFile);
50
+ }
51
+ catch (error) {
52
+ terminal.error(`Error reading file ${filePath}: ${error.message}`);
53
+ }
54
+ }));
55
+ tokenCounter.free();
56
+ terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
57
+ }
58
+ catch (error) {
59
+ terminal.error(`Error processing file patterns: ${error.message}`);
60
+ }
61
+ },
62
+ };
63
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const generateRulesCommand: ({ terminal, messageHistory, modelManager, tokenTracker, config, }: CommandOptions) => ReplCommand;
@@ -0,0 +1,61 @@
1
+ import { checkbox } from "@inquirer/prompts";
2
+ import { analyzeConversation } from "../conversation-analyzer.js";
3
+ import { logger } from "../logger.js"; // Import logger
4
+ async function _processAndSaveRules(newRules, terminal, config) {
5
+ if (!newRules || newRules.length === 0) {
6
+ terminal.warn("No new generalizable rules were identified.");
7
+ return;
8
+ }
9
+ terminal.info("Generated potential rules:");
10
+ terminal.lineBreak();
11
+ const rulesToKeep = await checkbox({
12
+ message: "Select the rules you want to keep:",
13
+ choices: newRules.map((rule) => ({ name: rule, value: rule })),
14
+ });
15
+ if (rulesToKeep.length === 0) {
16
+ terminal.warn("No rules selected to save.");
17
+ return;
18
+ }
19
+ terminal.info("Saving selected rules...");
20
+ const existingRules = await config.readProjectLearnedRulesFile();
21
+ const rulesToAdd = rulesToKeep.join("\n");
22
+ const updatedProjectRules = existingRules.endsWith("\n") || existingRules.length === 0
23
+ ? `${existingRules}${rulesToAdd}`
24
+ : `${existingRules}\n${rulesToAdd}`;
25
+ await config.writeProjectLearnedRulesFile(updatedProjectRules);
26
+ terminal.success("Selected rules saved to project learned rules.");
27
+ terminal.lineBreak();
28
+ terminal.display(rulesToAdd); // Display only the saved rules
29
+ }
30
+ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, tokenTracker, config, // This is the config module from CommandOptions
31
+ }) => {
32
+ return {
33
+ command: "/generate-rules",
34
+ description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
35
+ result: "continue",
36
+ getSubCommands: () => Promise.resolve([]),
37
+ execute: async () => {
38
+ if (messageHistory.isEmpty()) {
39
+ terminal.writeln("Cannot generate rules from an empty conversation.");
40
+ return;
41
+ }
42
+ terminal.lineBreak();
43
+ terminal.info("Analyzing conversation to generate rules...");
44
+ try {
45
+ const newRules = await analyzeConversation({
46
+ modelManager,
47
+ messages: messageHistory.get(),
48
+ tokenTracker,
49
+ terminal,
50
+ });
51
+ // Pass the config object available in CommandOptions scope
52
+ await _processAndSaveRules(newRules, terminal, config);
53
+ }
54
+ catch (error) {
55
+ const errorMessage = error instanceof Error ? error.message : String(error);
56
+ terminal.error(`Error generating rules: ${errorMessage}`);
57
+ logger.error(error, "Error during rule generation:");
58
+ }
59
+ },
60
+ };
61
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const helpCommand: ({ terminal }: CommandOptions, cmds: Map<string, ReplCommand>) => ReplCommand;
@@ -0,0 +1,19 @@
1
+ export const helpCommand = ({ terminal }, cmds) => {
2
+ return {
3
+ command: "/help",
4
+ description: "Shows available commands.",
5
+ result: "continue",
6
+ getSubCommands: () => Promise.resolve([]),
7
+ execute: () => {
8
+ const commands = cmds;
9
+ const entries = Array.from(commands.entries())
10
+ .sort(([a], [b]) => a.localeCompare(b))
11
+ .map(([key, cmd]) => [key, cmd.description]);
12
+ terminal.table(entries, {
13
+ header: ["Command", "Description"],
14
+ colWidths: [30, 70],
15
+ });
16
+ return Promise.resolve();
17
+ },
18
+ };
19
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const initCommand: ({ terminal, modelManager, tokenCounter, toolEvents, }: CommandOptions) => ReplCommand;
@@ -0,0 +1,40 @@
1
+ import { platform } from "node:os";
2
+ import { stepCountIs, streamText } from "ai";
3
+ import { inGitDirectory } from "../tools/git-utils.js";
4
+ import { initTools } from "../tools/index.js";
5
+ export const initCommand = ({ terminal, modelManager, tokenCounter, toolEvents, }) => {
6
+ return {
7
+ command: "/init",
8
+ description: "Creates the AGENTS.md file.",
9
+ result: "continue",
10
+ getSubCommands: () => Promise.resolve([]),
11
+ execute: async () => {
12
+ const result = streamText({
13
+ model: modelManager.getModel("init-project"),
14
+ temperature: 0.5,
15
+ prompt: `Please analyze this codebase and create a AGENTS.md file containing:
16
+ 1. Build/lint/test commands - especially for running a single test
17
+ 2. Code style guidelines including imports, formatting, types, naming conventions, error handling, etc.
18
+
19
+ The file you create will be given to agentic coding agents (such as yourself) that operate in this repository. Make it about 20 lines long.
20
+
21
+ If there's already a AGENTS.md, improve it.
22
+ If there are Cursor rules (in .cursor/rules/ or .cursorrules), Copilot rules (in .github/copilot-instructions.md), or Windsurf rules (in .windsurf/rules), make sure to include them.
23
+
24
+ Your current working directory is ${process.cwd()}
25
+ Is directory a git repo: ${(await inGitDirectory()) ? "Yes" : "No"}
26
+ Platform: ${platform()}`,
27
+ stopWhen: stepCountIs(40),
28
+ tools: await initTools({
29
+ terminal,
30
+ tokenCounter,
31
+ events: toolEvents,
32
+ autoAcceptAll: true,
33
+ }),
34
+ });
35
+ for await (const text of result.textStream) {
36
+ terminal.write(text);
37
+ }
38
+ },
39
+ };
40
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const lastLogCommand: ({ terminal }: CommandOptions) => ReplCommand;
@@ -0,0 +1,76 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { editor } from "@inquirer/prompts";
4
+ import chalk from "chalk";
5
+ import { globby } from "globby";
6
+ import { config } from "../config.js";
7
+ const isoDateRegex = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)/;
8
+ // Function to find the most recent log file
9
+ async function findMostRecentLog(logDir) {
10
+ const logPattern = join(logDir, "*-repl-message.json");
11
+ const files = await globby(logPattern);
12
+ if (files.length === 0) {
13
+ return null;
14
+ }
15
+ const datedFiles = files
16
+ .map((file) => {
17
+ const filename = file.split("/").pop();
18
+ if (!filename) {
19
+ return null; // Skip if filename is somehow undefined
20
+ }
21
+ // Match the ISO date string at the beginning of the filename
22
+ const match = filename.match(isoDateRegex);
23
+ if (match?.[1]) {
24
+ try {
25
+ const date = new Date(match[1]);
26
+ // Check if the date is valid
27
+ if (!Number.isNaN(date.getTime())) {
28
+ return { file, date };
29
+ }
30
+ }
31
+ catch (e) {
32
+ // Ignore files with invalid date strings
33
+ console.warn(`Could not parse date from filename: ${filename}`, e);
34
+ }
35
+ }
36
+ return null; // Exclude files that don't match the pattern or have invalid dates
37
+ })
38
+ .filter((item) => item !== null);
39
+ if (datedFiles.length === 0) {
40
+ return null; // No valid log files found
41
+ }
42
+ // Sort files by date (descending)
43
+ datedFiles.sort((a, b) => b.date.getTime() - a.date.getTime());
44
+ return datedFiles[0]?.file ?? null; // The first file is the most recent
45
+ }
46
+ export const lastLogCommand = ({ terminal }) => {
47
+ return {
48
+ command: "/last-log",
49
+ description: "Opens the most recent REPL audit log in the editor.",
50
+ result: "continue",
51
+ getSubCommands: () => Promise.resolve([]),
52
+ execute: async () => {
53
+ const logDir = config.app.ensurePathSync("audit");
54
+ const mostRecentLog = await findMostRecentLog(logDir);
55
+ if (!mostRecentLog) {
56
+ terminal.error(`No REPL audit logs found in '${logDir}'.`);
57
+ return;
58
+ }
59
+ try {
60
+ const content = await readFile(mostRecentLog, { encoding: "utf8" });
61
+ // Use the editor prompt to display the content (read-only)
62
+ await editor({
63
+ message: `Viewing ${chalk.green(mostRecentLog)}`,
64
+ postfix: ".json", // Set postfix for syntax highlighting if editor supports it
65
+ default: content,
66
+ // By not providing an onSubmit or similar handler to write the file,
67
+ // and not calling writeFileSync after, this effectively becomes read-only.
68
+ });
69
+ terminal.info("Closed log view");
70
+ }
71
+ catch (error) {
72
+ terminal.error(`Error reading or displaying log file ${mostRecentLog}: ${error}`);
73
+ }
74
+ },
75
+ };
76
+ };
@@ -0,0 +1,22 @@
1
+ import type { CommandOptions } from "./types.ts";
2
+ export declare class CommandManager {
3
+ private commands;
4
+ private promptManager;
5
+ private modelManager;
6
+ private messageHistory;
7
+ private tokenTracker;
8
+ private terminal;
9
+ private config;
10
+ private tokenCounter;
11
+ private toolEvents;
12
+ constructor({ promptManager, modelManager, terminal, messageHistory, tokenTracker, config, tokenCounter, toolEvents, }: CommandOptions);
13
+ initializeCommmands(): void;
14
+ getCommands(): string[];
15
+ getSubCommands(command: string): Promise<string[]>;
16
+ handle({ userInput }: {
17
+ userInput: string;
18
+ }): Promise<{
19
+ continue: boolean;
20
+ break: boolean;
21
+ }>;
22
+ }
@@ -0,0 +1,123 @@
1
+ import { applicationLogCommand } from "./application-log-command.js";
2
+ import { clearCommand } from "./clear-command.js";
3
+ import { compactCommand } from "./compact-command.js";
4
+ import { copyCommand } from "./copy-command.js";
5
+ import { editCommand } from "./edit-command.js";
6
+ import { editPromptCommand } from "./edit-prompt-command.js";
7
+ import { exitCommand } from "./exit-command.js";
8
+ import { filesCommand } from "./files-command.js";
9
+ import { generateRulesCommand } from "./generate-rules-command.js";
10
+ import { helpCommand } from "./help-command.js";
11
+ import { initCommand } from "./init-command.js";
12
+ import { lastLogCommand } from "./last-log-command.js";
13
+ import { modelCommand } from "./model-command.js";
14
+ import { pasteCommand } from "./paste-command.js";
15
+ import { promptCommand } from "./prompt-command.js";
16
+ import { resetCommand } from "./reset-command.js";
17
+ import { rulesCommand } from "./rules-command.js";
18
+ import { saveCommand } from "./save-command.js";
19
+ import { usageCommand } from "./usage-command.js";
20
+ export class CommandManager {
21
+ commands;
22
+ promptManager;
23
+ modelManager;
24
+ messageHistory;
25
+ tokenTracker;
26
+ terminal;
27
+ config;
28
+ tokenCounter;
29
+ toolEvents;
30
+ constructor({ promptManager, modelManager, terminal, messageHistory, tokenTracker, config, tokenCounter, toolEvents, }) {
31
+ this.commands = new Map();
32
+ this.promptManager = promptManager;
33
+ this.modelManager = modelManager;
34
+ this.terminal = terminal;
35
+ this.messageHistory = messageHistory;
36
+ this.tokenTracker = tokenTracker;
37
+ this.config = config;
38
+ this.tokenCounter = tokenCounter;
39
+ this.toolEvents = toolEvents;
40
+ this.initializeCommmands();
41
+ }
42
+ initializeCommmands() {
43
+ // Import and register each command
44
+ const options = {
45
+ promptManager: this.promptManager,
46
+ modelManager: this.modelManager,
47
+ terminal: this.terminal,
48
+ messageHistory: this.messageHistory,
49
+ tokenTracker: this.tokenTracker,
50
+ config: this.config,
51
+ tokenCounter: this.tokenCounter,
52
+ toolEvents: this.toolEvents,
53
+ };
54
+ // Register all commands
55
+ const cmds = [
56
+ clearCommand(options),
57
+ compactCommand(options),
58
+ editCommand(options),
59
+ editPromptCommand(options),
60
+ exitCommand(options),
61
+ filesCommand(options),
62
+ initCommand(options),
63
+ pasteCommand(options),
64
+ promptCommand(options),
65
+ resetCommand(options),
66
+ saveCommand(options),
67
+ rulesCommand(options),
68
+ modelCommand(options),
69
+ usageCommand(options),
70
+ lastLogCommand(options),
71
+ generateRulesCommand(options),
72
+ applicationLogCommand(options),
73
+ copyCommand(options),
74
+ ];
75
+ // Add help command with access to all commands
76
+ const helpCmd = helpCommand(options, this.commands);
77
+ cmds.push({
78
+ ...helpCmd,
79
+ execute: () => helpCmd.execute([]),
80
+ });
81
+ // Register all commands
82
+ for (const cmd of cmds) {
83
+ this.commands.set(cmd.command, cmd);
84
+ const aliases = cmd.aliases ?? [];
85
+ for (const alias of aliases) {
86
+ this.commands.set(alias, cmd);
87
+ }
88
+ }
89
+ }
90
+ getCommands() {
91
+ return Array.from(this.commands.keys()).sort();
92
+ }
93
+ async getSubCommands(command) {
94
+ return (await this.commands.get(command)?.getSubCommands()) ?? [];
95
+ }
96
+ async handle({ userInput }) {
97
+ const commandArgs = userInput.split(" ");
98
+ const command = commandArgs.at(0);
99
+ const args = commandArgs.slice(1);
100
+ if (command) {
101
+ const replCommand = this.commands.get(command);
102
+ if (replCommand) {
103
+ await replCommand.execute(args);
104
+ if (replCommand.result === "continue") {
105
+ return {
106
+ continue: true,
107
+ break: false,
108
+ };
109
+ }
110
+ if (replCommand.result === "break") {
111
+ return {
112
+ continue: false,
113
+ break: true,
114
+ };
115
+ }
116
+ }
117
+ }
118
+ return {
119
+ continue: false,
120
+ break: false,
121
+ };
122
+ }
123
+ }
@@ -0,0 +1,2 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare function modelCommand(options: CommandOptions): ReplCommand;