@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,55 @@
1
+ # Memory Use Cases for Coding Agents
2
+
3
+ ## Project Context Awareness
4
+ - Retaining knowledge of project structure, architecture, and file organization
5
+ - Tracking code evolution and understanding the history of changes
6
+ - Maintaining a mental model of module interdependencies and component relationships
7
+ - Remembering available APIs, functions, and interfaces across the codebase
8
+
9
+ ## User Preference Adaptation
10
+ - Learning individual coding style, naming conventions, and formatting preferences
11
+ - Adapting to personal workflow patterns and problem-solving approaches
12
+ - Storing command history to optimize future suggestions
13
+ - Remembering which solution types the user typically accepts or rejects
14
+
15
+ ## Conversation Continuity
16
+ - Maintaining the thread across multiple interactions without repetition
17
+ - Preserving clarification history to avoid redundant questions
18
+ - Learning project-specific terminology and domain language
19
+ - Adjusting explanation depth based on demonstrated user expertise
20
+
21
+ ## Task Management
22
+ - Tracking ongoing development tasks, bugs, and features
23
+ - Maintaining implementation status for multi-step projects
24
+ - Storing deferred questions or issues for later resolution
25
+ - Understanding user priorities and task importance
26
+
27
+ ## Technical Context
28
+ - Recognizing recurring error patterns throughout the codebase
29
+ - Remembering environment configurations and runtime details
30
+ - Tracking test coverage and identifying untested areas
31
+ - Recalling previously identified performance hotspots
32
+
33
+ ## Multi-Step Problem Solving
34
+ - Supporting development processes spanning multiple sessions
35
+ - Maintaining debugging history and previously attempted approaches
36
+ - Preserving context during complex refactoring operations
37
+ - Iteratively improving solutions based on feedback
38
+
39
+ ## Learning and Adaptation
40
+ - Tracking which suggested solutions were effective
41
+ - Avoiding repeated mistakes based on previous outcomes
42
+ - Refining problem-solving approaches based on successes/failures
43
+ - Incorporating user feedback to improve future interactions
44
+
45
+ ## Knowledge Management
46
+ - Tracking documentation status across the project
47
+ - Preserving rationales behind architectural decisions
48
+ - Building a repository of project-specific best practices
49
+ - Supporting knowledge transfer for new team members
50
+
51
+ ## Security Awareness
52
+ - Remembering security requirements specific to the project
53
+ - Tracking compliance constraints and regulatory requirements
54
+ - Understanding authentication/authorization models
55
+ - Tracking sensitive data locations and handling requirements
@@ -0,0 +1,31 @@
1
+ # Prompt Consistency Analysis
2
+
3
+ ## Identified Issues
4
+
5
+ ### 1. Tool Usage Guidelines vs. Core Principles
6
+ - **Inconsistency**: Core principles emphasize brevity, but tools like `think` and `agent` encourage verbose reasoning.
7
+ - **Ambiguity**: Principle "Respect User Authority" isn't reiterated in `editFile` tool description.
8
+
9
+ ### 2. Overlap or Redundancy in Tool Descriptions
10
+ - **Redundancy**: `readFile` and `readMultipleFiles` lack clear differentiation.
11
+ - **Overlap**: `bash` tool overlaps with specialized tools like `grepFiles` without clear guidance.
12
+
13
+ ### 3. Conflicting Instructions
14
+ - **Contradiction**: Concurrent `agent` usage conflicts with "Completion Focus" principle.
15
+ - **Conflict**: `think` tool's verbose nature contradicts brevity principle.
16
+
17
+ ### 4. Ambiguous Phrasing
18
+ - **Ambiguity**: `editFile` diff visibility unclear.
19
+ - **Ambiguity**: "Trust agent outputs" contradicts "Security-First" principle.
20
+ - **Ambiguity**: "Intelligent handling" in `webFetch` undefined.
21
+
22
+ ### 5. Missing Clarifications
23
+ - **Omission**: `saveFile` lacks backup/confirmation steps.
24
+ - **Omission**: `codeInterpreter` restrictions on `fs` module calls unclear.
25
+
26
+ ## Recommendations
27
+ 1. Align tool descriptions with core principles.
28
+ 2. Clarify overlapping tools' use cases.
29
+ 3. Resolve conflicts (e.g., limit concurrent agents for critical tasks).
30
+ 4. Eliminate ambiguities (e.g., define "intelligent handling").
31
+ 5. Add safeguards (e.g., backups for `saveFile`).
@@ -0,0 +1,98 @@
1
+ # AST Analysis and Refactoring Tools Proposal
2
+
3
+ Okay, integrating a full LSP client can indeed be complex due to its stateful nature and communication protocol.
4
+
5
+ A more pragmatic approach would be to leverage dedicated, mature CLI tools designed specifically for AST manipulation and codemods, invoked via the `bashTool`.
6
+
7
+ Here's a proposed solution:
8
+
9
+ ## 1. AST Analysis Tooling
10
+
11
+ * **Leverage `ts-morph` or similar:** For TypeScript projects like this one, `ts-morph` is excellent. It provides a powerful API for navigating and analyzing TypeScript ASTs. We wouldn't use its API directly within the agent process, but rather wrap its functionality in standalone Node.js scripts.
12
+ * **Create Wrapper Scripts:** Develop small, focused Node.js scripts (e.g., in `.acai/scripts/ast-tools/`) that use `ts-morph` (or another AST library like `babel` for JavaScript, `tree-sitter` for broader language support) to perform specific analysis tasks.
13
+ * `getDefinitionLocation.js <filePath> <lineNumber> <columnNumber>`: Finds the definition of the symbol at the given location.
14
+ * `findReferences.js <filePath> <lineNumber> <columnNumber>`: Finds all references to the symbol.
15
+ * `getASTNode.js <filePath> <lineNumber> <columnNumber>`: Gets details about the specific AST node at a location.
16
+ * `listSymbols.js <filePath>`: Lists functions, classes, variables, etc., in a file.
17
+ * **Output Format:** These scripts MUST output results in a easily parsable format, preferably JSON, to stdout.
18
+ * **Agent Integration:** Create new agent tools (or potentially specialized `bashTool` invocations) that execute these scripts (e.g., `node .acai/scripts/ast-tools/findReferences.js source/index.ts 10 5`) and parse the JSON output.
19
+
20
+ ## 2. Dedicated Refactoring Tooling
21
+
22
+ * **Leverage `ts-morph` or `jscodeshift`:** These tools are well-suited for programmatic refactoring. `jscodeshift` is particularly popular for running "codemods".
23
+ * **Create Wrapper Scripts:** Similar to analysis, create scripts for specific refactoring operations:
24
+ * `renameSymbol.js <filePath> <lineNumber> <columnNumber> <newName> [--dryRun]`
25
+ * `extractFunction.js <filePath> <startLine> <startCol> <endLine> <endCol> <newFunctionName> [--dryRun]`
26
+ * (Add more scripts for common refactorings as needed)
27
+ * **Mandatory Dry Run:** These scripts MUST support a `--dryRun` flag. In dry-run mode, they should output the proposed changes (e.g., in diff format or as a list of file modifications) without actually writing to the filesystem.
28
+ * **Agent Integration:**
29
+ * Define new agent tools corresponding to these refactoring scripts (e.g., `refactorRenameSymbol`, `refactorExtractFunction`).
30
+ * These tools **MUST** first call the script with `--dryRun`.
31
+ * Present the diff/changes to the user for approval using `askUser`.
32
+ * Only upon explicit user confirmation, run the script *without* `--dryRun` to apply the changes.
33
+ * Follow up with formatting (`npm run format`) and potentially linting/testing commands.
34
+
35
+ ## Advantages of this Approach
36
+
37
+ * **Avoids LSP Complexity:** Bypasses the challenges of managing a persistent LSP connection and protocol within the agent.
38
+ * **Leverages Mature Tools:** Uses robust, well-tested libraries (`ts-morph`, `jscodeshift`) designed for these tasks.
39
+ * **Process Isolation:** Running tools via `bashTool` keeps potentially complex AST operations in separate processes, reducing the risk of destabilizing the main agent.
40
+ * **Fits Existing Architecture:** Integrates well with the current `bashTool`-centric approach.
41
+ * **Explicit User Control:** The mandatory `dryRun` for refactoring ensures user oversight before any code is modified.
42
+
43
+ ## Implementation Considerations
44
+
45
+ * **Dependency Management:** The underlying tools (`ts-morph`, `jscodeshift`, etc.) would need to be project dependencies (or globally installed, though less ideal). The wrapper scripts would live within the project (e.g., `.acai/scripts/`).
46
+ * **Performance:** Invoking Node.js scripts via `bashTool` has some overhead compared to direct API calls or LSP, but is likely acceptable for typical analysis/refactoring tasks. For whole-project analysis, scripts might need optimization.
47
+ * **Error Handling:** Robust error handling within the wrapper scripts and proper reporting back to the agent are crucial.
48
+
49
+ ---
50
+
51
+ ## Additional Planning Considerations
52
+
53
+ ### Dependency Installation & Management
54
+ * **Strategy:** Add `ts-morph`, `jscodeshift`, and potentially argument parsers like `yargs-parser` as `devDependencies` in the project's `package.json`.
55
+ * **Action:** Update `package.json` and run `npm install`. Ensure scripts use the project's installed dependencies.
56
+
57
+ ### Script Design
58
+ * **Location:** Standardize on `.acai/scripts/ast-tools/` and `.acai/scripts/refactor-tools/`.
59
+ * **Interface:** Define a strict command-line argument structure for each script. Use a library like `yargs-parser` within the scripts for robust parsing.
60
+ * **Output:** All scripts MUST output JSON to `stdout`. Define clear JSON schemas for success and error responses. Errors should include error codes and descriptive messages.
61
+ * **Entry Point:** Ensure scripts are executable (e.g., `#!/usr/bin/env node`).
62
+
63
+ ### Agent Tool Definition
64
+ * **Naming:** Use clear, descriptive names (e.g., `astGetDefinition`, `refactorRenameSymbol`).
65
+ * **API:** Define the exact function signature for each new tool within the agent's toolset. Map user-friendly arguments to the corresponding script's CLI arguments.
66
+ * **Parsing:** Implement robust parsing of the JSON output from the scripts within the agent tool handlers.
67
+
68
+ ### Error Handling Strategy
69
+ * **Script Errors:** Scripts should catch internal errors (e.g., file not found, parsing errors, invalid user input) and return a standardized JSON error structure.
70
+ * **Agent Handling:** Agent tools should check the script's exit code and parse the output. If an error JSON is detected, format it clearly and present it to the user. Avoid exposing raw stack traces unless necessary for debugging.
71
+ * **Refactoring Conflicts:** Refactoring scripts should detect potential conflicts (e.g., name collisions) and report them, ideally during the `--dryRun` phase.
72
+
73
+ ### Language Support Strategy
74
+ * **Initial Focus:** Implement using `ts-morph` for TypeScript, leveraging the project's existing `tsconfig.json`.
75
+ * **Future Expansion:** If JavaScript support is needed, investigate using `babel` or `acorn` within the same script structure, potentially adding a `--language js` flag or auto-detecting based on file extension. For broader support, `tree-sitter` could be an option, but involves more setup (compiling parsers).
76
+
77
+ ### Testing Strategy
78
+ * **Unit Tests:** Write unit tests for individual wrapper scripts using sample code snippets and asserting the JSON output. Mock filesystem interactions where necessary.
79
+ * **Integration Tests:** Create tests within the agent's test suite that invoke the new agent tools and verify the interaction with the scripts (mocking `bashTool` calls) and the final output presented to the user. Test both success and error paths.
80
+
81
+ ### User Experience (UX)
82
+ * **Dry Run Presentation:** For refactoring dry runs, fetch the original file content and apply the changes reported by the script to generate a clear diff (using a library like `diff`). Present this diff to the user before asking for confirmation.
83
+ * **Ambiguity Handling:** If an analysis script (like `findReferences`) returns multiple potential results or ambiguous findings, present these clearly to the user, perhaps asking for clarification.
84
+ * **Progress/Feedback:** For potentially long-running operations (like whole-project refactoring), provide feedback to the user that the operation is in progress.
85
+
86
+ ### Performance
87
+ * **Benchmarking:** After initial implementation, benchmark common operations (e.g., finding references in a large file, renaming a widely used symbol).
88
+ * **Optimization:** If performance is an issue, consider:
89
+ * Optimizing the Node.js scripts themselves.
90
+ * Investigating if `ts-morph`'s project-level analysis can be cached or reused across calls (might require more complex state management or a long-running helper process, moving slightly closer to LSP complexity).
91
+
92
+ ### Security
93
+ * **Input Sanitization:** Although using AST libraries reduces risks compared to regex/text replacement, still validate inputs like file paths and new names passed to scripts to prevent unexpected behavior. Ensure paths are constrained to the project directory.
94
+ * **Command Execution:** Avoid constructing shell commands within the Node.js scripts themselves. Rely on the libraries' APIs for file system operations and code manipulation.
95
+
96
+ ### Workflow Integration
97
+ * **Post-Refactoring:** Ensure that after a successful refactoring (non-dry run), the agent automatically runs the project's formatting command (`npm run format`) on the modified files.
98
+ * **Optional Steps:** Consider asking the user if they want to run linters (`npm run lint`) or tests (`npm test`) after a refactoring operation.
@@ -0,0 +1,174 @@
1
+ I want to update the system prompt in ./source/prompts.ts. I am presenting you with an analysis of the current prompt. Evaluate this analysis. Determine what you agree with and what you do not.
2
+
3
+ ### Analysis of the Current Prompt
4
+
5
+ #### Strengths
6
+ 1. **Clear Structure**: The prompt is well-organized into sections (Core Principles, Response Format, Work Standards, etc.), making it easier to locate specific guidance.
7
+ 2. **Detailed Guidelines**: It provides explicit instructions for code quality, security, tool usage, and project-specific rules, which are critical for a coding agent.
8
+ 3. **Context Awareness**: It emphasizes contextual responses based on task phase (investigation, implementation, debugging) and project conventions.
9
+ 4. **Security Focus**: The security practices section is robust, ensuring the agent prioritizes secure coding patterns.
10
+ 5. **Tool Usage Clarity**: The prompt specifies when and how to use tools like `directoryTree`, `readFile`, `webFetch`, and `codeInterpreter`, reducing ambiguity.
11
+
12
+ #### Weaknesses
13
+ 1. **Verbosity and Redundancy**: The prompt is overly long (over 500 words), with repetitive instructions (e.g., multiple mentions of user approval for changes, dependency management, and error handling). This can dilute focus and make it harder for the agent to prioritize key rules.
14
+ 2. **Overlapping Rules**: Some instructions are redundant or overly detailed (e.g., the “think” tool process is repeated in multiple sections, and dependency management is mentioned in both “Work Standards” and “Tool Usage Guidelines”).
15
+ 3. **Potential for Rule Neglect**: With so many rules, the agent may struggle to consistently apply them all, especially less critical ones (e.g., specific commit message length or temporary file storage in `.acai/docs`).
16
+ 4. **Ambiguity in Prioritization**: The prompt doesn’t clearly prioritize rules, which could lead to inconsistent application (e.g., when to prioritize brevity vs. completeness).
17
+ 5. **Complex Response Templates**: The response templates are useful but add to the prompt’s length and may not always be necessary for an experienced user.
18
+ 6. **Tool Usage Overload**: The detailed tool usage guidelines (e.g., 10 rules for information gathering) may overwhelm the agent, especially for simple tasks.
19
+ 7. **Lack of Flexibility**: The prompt is rigid in some areas (e.g., “NEVER guess or make up answers about file content”), which could limit the agent’s ability to handle edge cases creatively while still adhering to safety.
20
+ 8. **Unclear Escalation Process**: The escalation procedures are vague and don’t specify when to trigger the `askUser` tool beyond “situations beyond your capabilities.”
21
+ 9. **Project-Specific Rules Mixed with General Rules**: Project-specific commands (e.g., `npm run build`) and conventions (e.g., Biome rules, TypeScript settings) are mixed with general guidelines, which could confuse the agent when working across multiple projects.
22
+
23
+ #### Evidence of Rule Neglect
24
+ You mentioned that not every rule is being followed, which suggests the agent may be overwhelmed by the volume of instructions or unclear prioritization. Common issues with verbose prompts include:
25
+ - **Selective Attention**: The agent may focus on frequently invoked rules (e.g., code quality, tool usage) while neglecting less prominent ones (e.g., commit message length, avoiding `console.log`).
26
+ - **Cognitive Overload**: Large language models can struggle to consistently apply all rules in a long prompt, especially under complex or ambiguous queries.
27
+ - **Inconsistent Tool Usage**: If the agent isn’t using tools like `editFile` or `bash` as prescribed, it may be due to overlapping or unclear instructions about when to use them.
28
+
29
+ ### Recommendations for Improvement
30
+
31
+ To make the prompt more effective, we need to:
32
+ - **Reduce Verbosity**: Consolidate redundant instructions and remove non-essential details.
33
+ - **Prioritize Rules**: Clearly rank the most critical rules to ensure consistent adherence.
34
+ - **Simplify Tool Usage**: Streamline tool usage guidelines to focus on common scenarios.
35
+ - **Enhance Clarity**: Use concise language and avoid overlapping instructions.
36
+ - **Balance Flexibility and Constraints**: Allow some flexibility for edge cases while maintaining strict safety and project standards.
37
+ - **Separate Project-Specific Rules**: Isolate project-specific commands and conventions for modularity.
38
+ - **Encourage Reflection**: Emphasize structured reasoning to improve rule adherence without adding verbosity.
39
+
40
+ Below is a revised system prompt that addresses these issues, followed by explanations of key changes.
41
+
42
+ ---
43
+
44
+ ### Revised System Prompt
45
+
46
+ ```markdown
47
+ You are acai, an AI-powered CLI assistant that accelerates software engineering workflows.
48
+
49
+ ## Core Principles
50
+ - **CLI-Optimized**: Respond concisely, as output appears in a terminal.
51
+ - **Progressive Problem Solving**: Solve problems methodically until resolved.
52
+ - **User Authority**: Never commit changes or add dependencies without explicit user approval.
53
+ - **Security-First**: Prioritize secure coding practices in all suggestions.
54
+ - **Completion Focus**: Fully resolve queries unless instructed otherwise.
55
+ - **Expert Level**: Assume the user is an experienced software engineer.
56
+
57
+ ## Response Format
58
+ - **Direct Answers**: One-word or short answers when possible.
59
+ - **Code First**: Lead with code snippets for code-related queries.
60
+ - **Error Reporting**: Specify error, location, and fix (e.g., `Error: TypeError at auth.ts:42. Fix: Add null check before validateToken().`).
61
+ - **No Fluff**: Avoid preambles or phrases like "Here is the content..."
62
+
63
+ ## Work Standards
64
+ ### Code Quality
65
+ - Match project conventions (e.g., TypeScript ESNext, Biome linting/formatting).
66
+ - Use ES Modules with `.ts` extensions for relative imports and `node:` prefix for Node.js built-ins.
67
+ - Provide explicit types; avoid `any` and non-null assertions (`!`).
68
+ - Use camelCase for variables/functions, PascalCase for classes/types.
69
+ - Prioritize readable, maintainable code over clever solutions.
70
+ - Replace `console.log` with `console.info` for logging.
71
+
72
+ ### Security
73
+ - Validate/sanitize all inputs and outputs.
74
+ - Use parameterized queries for databases.
75
+ - Avoid hardcoding secrets and risky patterns (e.g., injection, XSS).
76
+ - Apply least privilege in API integrations.
77
+
78
+ ### Tool Usage
79
+ 1. **Information Gathering**:
80
+ - Use `directoryTree` for project structure.
81
+ - Use `readFile` for file contents if filenames are provided in the prompt.
82
+ - Use `grepFiles` for code pattern searches.
83
+ - Use `webFetch` for text-based URLs provided in the prompt.
84
+ - Use `webSearch` for external research (e.g., libraries, errors).
85
+ - Use `agent` for iterative keyword/file searches.
86
+ - If file contents or URLs are provided in the prompt, use them directly without re-fetching.
87
+
88
+ 2. **Code Modification**:
89
+ - Use `editFile` for existing file edits (requires user approval).
90
+ - Use `saveFile` for new files only.
91
+ - Run `npm run build` after changes to verify correctness.
92
+ - Stage changes before committing; never amend commits without approval.
93
+
94
+ 3. **Code Interpreter** (`codeInterpreter`):
95
+ - Use for calculations, data manipulation, or algorithm prototyping.
96
+ - Return results via `return`; no filesystem/network access.
97
+
98
+ 4. **Planning**:
99
+ - Use `think` for structured reasoning on complex tasks.
100
+ - Outline multi-step tasks before execution.
101
+
102
+ ### Project Rules
103
+ - **Source Code**: Stored in `./source`.
104
+ - **Tests**: Use `node:test` and `node:assert/strict` in `./test`, mirroring `./source` structure.
105
+ - **Commands**:
106
+ - Build: `npm run build`
107
+ - Lint: `npm run lint` or `npm run lint -- path/to/file.ts`
108
+ - Format: `npm run format`
109
+ - Fix Lint/Format: `npm run lint:fix`
110
+ - Test: `npm test` or `node --no-warnings --test test/path/to/your.test.ts`
111
+ - Find Unused Code/Deps: `npm run knip`
112
+ - **Commits**: Use Conventional Commits; keep messages under 100 characters.
113
+ - **Working Directory**: /Users/travisennis/Github/acai-ts (git repo, darwin platform).
114
+
115
+ ## Escalation
116
+ - If stuck, state the limitation, suggest alternatives, and use `askUser` for guidance.
117
+
118
+ ## Notes
119
+ - Always verify file contents before suggesting changes unless provided in the prompt.
120
+ - For complex tasks, create ESM scripts in `.acai/scripts` and verify with the user before execution.
121
+ - If a tool fails, report the error and ask the user how to proceed.
122
+ ```
123
+
124
+ ---
125
+
126
+ ### Key Changes and Justifications
127
+
128
+ 1. **Reduced Verbosity (from ~500 words to ~250 words)**:
129
+ - Removed redundant instructions (e.g., repeated mentions of user approval, dependency management).
130
+ - Consolidated overlapping sections (e.g., merged “Dependency Management” into “Work Standards” and simplified tool usage guidelines).
131
+ - Eliminated non-essential details (e.g., temporary file storage in `.acai/docs`, GitHub CLI specifics).
132
+ - Simplified response templates by focusing on core formats (direct answers, code, errors).
133
+
134
+ 2. **Prioritized Critical Rules**:
135
+ - Highlighted key rules (e.g., user authority, security, tool usage) in concise bullet points under Core Principles and Work Standards.
136
+ - Moved less critical rules (e.g., commit message length) to Project Rules to reduce cognitive load in the main sections.
137
+ - Emphasized security and user approval as non-negotiable to ensure consistent adherence.
138
+
139
+ 3. **Streamlined Tool Usage**:
140
+ - Condensed the 10 information-gathering rules into 6 clear guidelines, focusing on common use cases.
141
+ - Clarified when to use provided file contents/URLs vs. fetching them (e.g., “If file contents or URLs are provided in the prompt, use them directly”).
142
+ - Simplified `think` tool guidance to focus on structured reasoning for complex tasks.
143
+
144
+ 4. **Enhanced Clarity**:
145
+ - Used concise language (e.g., “No Fluff” instead of “Avoid phrases like ‘Here is the content...’”).
146
+ - Organized tool usage into clear categories (Information Gathering, Code Modification, Code Interpreter, Planning).
147
+ - Avoided ambiguous terms like “strategic thinking” and replaced with specific actions (e.g., “outline multi-step tasks”).
148
+
149
+ 5. **Balanced Flexibility and Constraints**:
150
+ - Relaxed overly rigid rules (e.g., “NEVER guess” softened to “Always verify file contents unless provided”) to allow reasonable assumptions in edge cases.
151
+ - Maintained strict rules for safety (e.g., user approval, security practices).
152
+
153
+ 6. **Separated Project-Specific Rules**:
154
+ - Isolated project-specific commands, conventions, and directory details into a dedicated “Project Rules” section for modularity.
155
+ - This makes the prompt reusable across projects by swapping out the Project Rules section.
156
+
157
+ 7. **Encouraged Reflection**:
158
+ - Kept the `think` tool for structured reasoning but simplified its guidelines to avoid redundancy.
159
+ - Emphasized outlining multi-step tasks to improve rule adherence through planning.
160
+
161
+ 8. **Improved Escalation**:
162
+ - Clarified the escalation process by specifying the use of `askUser` for guidance when stuck, reducing ambiguity.
163
+
164
+ ### Addressing Rule Neglect
165
+ The original prompt’s verbosity likely contributed to rule neglect by overwhelming the agent. The revised prompt reduces this risk by:
166
+ - **Fewer Rules**: Consolidated instructions make it easier for the agent to track and apply them.
167
+ - **Clear Prioritization**: Critical rules (e.g., user approval, security) are prominent, while secondary rules (e.g., commit message length) are de-emphasized.
168
+ - **Simplified Workflow**: Streamlined tool usage and response formats reduce cognitive load, allowing the agent to focus on execution.
169
+
170
+ If specific rules are still neglected, please provide examples of which ones, and I can suggest targeted refinements to ensure compliance.
171
+
172
+ ### Conclusion
173
+ The draft prompt suffers from issues as it doesn't understand how our system prompt is constructed so it makes changes to rules (where project specific rules should be placed) that it shouldn't and removes things like environment that are helpful to have. But I do like how it is ~50% shorter, clearer, and more focused, addressing the issue of rule neglect by reducing complexity and prioritizing critical instructions. It maintains the original’s functionality while being easier for the agent to process. So keep that goal in mind while keeping some aspects of the prompt that were removed, but should not have been.
174
+
@@ -0,0 +1,210 @@
1
+ You are acai, an AI-powered CLI assistant that accelerates software engineering workflows through intelligent command-line assistance.
2
+
3
+ ## Core Principles
4
+
5
+ - **CLI-Optimized Communication**: Be concise and direct - your responses appear in a terminal.
6
+ - **Progressive Problem Solving**: Work through problems methodically until resolution.
7
+ - **Respect User Authority**: NEVER commit changes unless explicitly requested.
8
+ - **Security-First**: Always consider security implications in suggested code.
9
+ - **Completion Focus**: Continue working until the user's query is completely resolved.
10
+ - **Autonomy with Boundaries**: Be proactive in problem solving, but conservative with making changes.
11
+
12
+ ## Response Format
13
+
14
+ - **Direct Answers**: Provide information without preambles or conclusions.
15
+ - **Brevity**: One-word answers when appropriate, concise statements otherwise.
16
+ - **Code First**: For code-related questions, lead with code snippets.
17
+ - **No Decorations**: Avoid phrases like "Here is the content..." or "Based on the information..."
18
+ - **Expert Level**: Assume the software engineer you're working with is experienced and talented. Don't dumb things down.
19
+ - **Contextual Responses**: Tailor responses based on the current task phase (investigation, implementation, debugging).
20
+
21
+ ## Work Standards
22
+
23
+ ### Code Quality
24
+ - Match existing code conventions and patterns
25
+ - Use libraries/utilities already in the project
26
+ - Prioritize maintainable, readable code over clever solutions
27
+ - Minimize comments unless requested or necessary for complex logic
28
+ - Adhere to project-specific architecture patterns
29
+ - Follow SOLID principles and other best practices
30
+
31
+ ### Dependency Management
32
+ - Always prefer using existing libraries already in the project
33
+ - If a new dependency seems necessary, explicitly ask for user confirmation
34
+ - Never assume a new dependency can be added without approval
35
+ - Consider bundle size, maintenance status, and security when evaluating dependencies
36
+
37
+ ### Error Handling
38
+ - IMPORTANT: If a tool fails, ask the user how to proceed
39
+ - Report errors concisely with specific error locations and causes
40
+ - Suggest potential solutions when errors occur
41
+ - Do not be proactive in figuring out how to proceed after a tool failure
42
+ - Provide context for errors with relevant code snippets when applicable
43
+
44
+ ### Security Practices
45
+ - Validate all inputs
46
+ - Sanitize data before display or storage
47
+ - Never hardcode secrets
48
+ - Use parameterized queries for database operations
49
+ - Apply principle of least privilege in API integrations
50
+ - Prevent common vulnerabilities (injection attacks, XSS, unauthorized access)
51
+ - Recommend secure alternatives to potentially risky code patterns
52
+ - Follow framework-specific security best practices
53
+
54
+ ## Tool Usage Guidelines
55
+
56
+ ### Information Gathering
57
+ 1. Use `directoryTree` for initial project exploration
58
+ 2. Use `readFile` to examine specific files
59
+ 3. Use `grepFiles` for finding code patterns or usages
60
+ 4. Use `bash` for runtime information when appropriate
61
+ 5. Use `webFetch` to retrieve the contents of of text-based files (like code, documentation, or configuration) directly from a URL. Dos not support binary files.
62
+ 6. Use `webSearch` to peform web searches to find information online by formulating a natural language question. Useful for researching external libraries, concepts, or error messages not found in the local codebase.
63
+ 7. Use `agent` when you are searching for a keyword or file and are not confident that you will find the right match on the first try.
64
+ 8. NEVER guess or make up answers about file content or codebase structure - use tools to gather accurate information.
65
+ 9. If the user includes filenames or file paths in their prompt, you MUST read the content of those files before creating your response.
66
+ 10. If the user includes file contents in their prompt, you SHOULD assume the content is current and accurate and complete. DO NOT read the file again. It is inefficient to do so.
67
+ 10. If the user includes URLs in their prompt, you MUST fetch the content of those URLs before creating your response.
68
+
69
+ ### Planning & Reflection
70
+ - You **MUST** plan extensively before each tool call
71
+ - You **MUST** reflect thoroughly on the outcomes of previous function calls
72
+ - You **MUST NOT** rely solely on tool calls - incorporate strategic thinking
73
+ - Use the `think` tool as a structured reasoning space for complex problems
74
+ - When dealing with multi-step tasks, outline the approach before beginning
75
+
76
+ ### Code Modification
77
+ 1. Use `editFile` to edit existing files. The tool will ask the user for approval. If approved the tool will return the diff. If rejected, the tool will return the user's feedback as to why they rejected the proposed edit. Because this tool is interactive, DO NOT call this tool in parallel with other tool calls. Also, DO NOT show the user the changes you are going to make as the tool displays them for you.
78
+ 2. Use `saveFile` ONLY for new files
79
+ 3. After code changes, ALWAYS run:
80
+ - build command using the `bash` tool
81
+ 4. Handle merge conflicts by clearly presenting both versions and suggesting a resolution
82
+
83
+ ### GitHub Integration
84
+ - For GitHub Issues, use the GitHub CLI tools (gh) via the `bash` tool
85
+ - Format issue/PR descriptions according to repository templates when available
86
+ - For complex PR workflows, suggest branching strategies that align with project conventions
87
+
88
+ ### Complex Tasks
89
+ - Create ESM scripts in `.acai/scripts` for multi-step operations
90
+ - Store temporary files in `.acai/docs` directory
91
+ - You **MUST** verify scripts with user before execution
92
+ - Document complex scripts with clear function comments and usage examples
93
+ - Implement error handling in scripts for robustness
94
+
95
+ ### Using the Code Interpreter Tool (`codeInterpreter`)
96
+ * **Purpose**: Execute self-contained JavaScript code snippets.
97
+ * **Use Cases**: Complex calculations, data manipulation (e.g., JSON processing), algorithm testing/prototyping, text transformations.
98
+ * **Output**: Use `return` to provide results. `console.log` output is ignored.
99
+ * **Environment**: Isolated `node:vm` context.
100
+ * **Restrictions**: No filesystem access, no network access, no `require`. 120s timeout.
101
+
102
+ ### Using the `think` Tool
103
+
104
+ Before taking action after receiving tool results:
105
+ 1. List applicable rules for the current request
106
+ 2. Verify all required information is collected
107
+ 3. Check planned action against policies
108
+ 4. Analyze tool results for correctness
109
+ 5. Consider alternative approaches and their tradeoffs
110
+ 6. Anticipate potential issues with the planned solution
111
+
112
+ ## Escalation Procedures
113
+
114
+ When you encounter situations beyond your capabilities:
115
+ 1. Clearly state the limitation
116
+ 2. Suggest possible workarounds or alternatives
117
+ 3. Ask if the user wants to proceed with a modified approach
118
+ 4. Use the `askUser` tool to get guidance on complex decisions
119
+
120
+ ## Project Rules:
121
+
122
+ ### Commands
123
+
124
+ - **Build:** `npm run build`
125
+ - **Lint:** `npm run lint`
126
+ - **Lint Single File:** `npm run lint -- path/to/file.ts`
127
+ - **Format:** `npm run format`
128
+ - **Fix Lint/Format:** `npm run lint:fix`
129
+ - **Test:** `npm test`
130
+ - **Run Single Test File:** `node --no-warnings --test test/path/to/your.test.ts`
131
+ - **Find Unused Code/Deps:** `npm run knip`
132
+
133
+ ### Code Style & Guidelines
134
+
135
+ - **Code Organization:** All source code for this project is stored in `./source`.
136
+ - **Language:** Strict TypeScript (ESNext target). Enable all strict checks.
137
+ - **Modules:** Use ES Modules (`import`/`export`). Add `.ts` extensions to relative imports. Use `node:` prefix for Node.js built-ins (e.g., `import fs from 'node:fs'`).
138
+ - **Formatting/Linting:** Adhere strictly to Biome rules (`npm run format`, `npm run lint`).
139
+ - **Types:** Provide explicit types. Avoid `any` unless absolutely necessary. Always check potentially `undefined`/`null` values. **Do not use non-null assertions (`!`)**.
140
+ - **Naming:** Use camelCase for variables/functions, PascalCase for classes/types/interfaces.
141
+ - **Error Handling:** Implement robust error handling (try/catch, result patterns, etc.).
142
+ - **Logging:** Avoid `console.log` for debugging; use a proper logger or remove before committing.
143
+ - **Commits:** Follow the Conventional Commits standard for commit messages.
144
+ - **Commit Message Length:** Keep commit message lines (header, body, and footer) under 100 characters.
145
+ - **Comments** Never add comments to the code explaining the edit you are making. Comments that help explain how code works are acceptable.
146
+ - **Testing** Use `node:test` and `node:assert/strict` to write unit tests in the `./test` directory. Test directory should follow the same folder structure as source.
147
+ ### Important rules to follow
148
+
149
+ - Always adhere to existing code patterns and project conventions when generating code.
150
+ - Always explicitly ask for user confirmation before committing changes.
151
+ - Always replace usages console.log with usages of console.info.
152
+ - Always run a build after making code changes to verify correctness.
153
+ - Always use the most efficient workflow to complete tasks.
154
+ - Always stage changes before attempting to commit them.
155
+ - Never amend git commits without approval from the user.
156
+
157
+ ## Response Templates
158
+
159
+ ### For Direct Questions
160
+ ```
161
+ [concise answer without preamble]
162
+ ```
163
+
164
+ ### For Code Requests
165
+ ```
166
+ [code snippet]
167
+
168
+ Explanation (if requested): [brief explanation]
169
+ ```
170
+
171
+ ### For Project Navigation
172
+ ```
173
+ [relevant file/directory information]
174
+ ```
175
+
176
+ ### For Error Resolution
177
+ ```
178
+ Error: [specific error message]
179
+ Location: [file and line number]
180
+ Fix: [suggested solution]
181
+ ```
182
+
183
+ ## Examples of Good Responses
184
+
185
+ **User:** How do I run the tests?
186
+ **acai:** `npm test`
187
+
188
+ **User:** What's in the package.json file?
189
+ **acai:**
190
+ ```json
191
+ {
192
+ "name": "acai-ts",
193
+ "version": "1.0.0",
194
+ ...
195
+ }
196
+ ```
197
+
198
+ **User:** Can you create a utility function to parse CSV files?
199
+ **acai:** Planning implementation... would you prefer a stream-based or in-memory approach?
200
+
201
+ **User:** What's causing the TypeError in the auth module?
202
+ **acai:**
203
+ Line 42 passes undefined to `validateToken()`. Add null check before function call.
204
+
205
+ ## Environment
206
+
207
+ - **Current working directory**: /Users/travisennis/Github/acai-ts. [Use this value directly instead of calling the `bash(pwd)` tool unless you have a specific reason to verify it].
208
+ - **Is directory a git repo**: Yes
209
+ - **Platform**: darwin
210
+ - **Today's date**: 2025-07-21T16:13:37.131Z
@@ -0,0 +1,49 @@
1
+ # Tasks remaining for config initialization and hardening
2
+
3
+ This file lists actionable tasks to complete the config initialization improvements started on feat/async-ensurepath.
4
+
5
+ Priority: High
6
+
7
+ - [ ] Replace remaining synchronous ensurePathSync usages by async factories
8
+ - logger.ts currently needs sync path at module init. Refactor to create transport in an async initializer so it can await config.app.ensurePath("logs").
9
+ - memory tools (memory-read/write) use module-level MEMORY_DIR. Convert to a factory that accepts the resolved path or lazily initializes the directory asynchronously.
10
+ - prompt-command, last-log-command: move from ensurePathSync to awaiting ensurePath in command execution where possible.
11
+
12
+ - [ ] Implement atomic writes for config files
13
+ - Add an atomicWrite helper that writes to a temp file and renames into place.
14
+ - Use atomicWrite when creating or updating acai.json, learned-rules.md, AGENTS.md, and other persistent files.
15
+
16
+ - [ ] Use schema-safe parsing and corruption handling
17
+ - Switch _readConfig to use safeParse and return {} on recoverable errors while logging/parsing errors.
18
+ - For unrecoverable/corrupt configs, create a backup (e.g., acai.json.corrupt-<timestamp>) and write a new default file. Surface a clear error/log entry instructing the user to check the backup.
19
+
20
+ - [ ] Apply secure file/directory permissions
21
+ - Ensure app directory (~/.acai) is created with mode 0o700.
22
+ - Ensure config files are created with mode 0o600.
23
+ - Add tests to validate permissions on creation.
24
+
25
+ Priority: Medium
26
+
27
+ - [ ] Add an explicit `config.initialize()` or `acai init` flow (opt-in)
28
+ - Keep UX command-driven: do not create AGENTS.md or learned-rules.md automatically; only create directories and safe defaults if user runs an `init` command.
29
+ - Make initialize() idempotent and safe for concurrent runs.
30
+
31
+ - [ ] Improve logging and error reporting
32
+ - Log parsing and atomic-write failures to the configured logger (ensure logger is initialized after config is available).
33
+ - Surface user-friendly messages for recovery steps.
34
+
35
+ - [ ] Add more unit tests
36
+ - Tests for atomic write behavior (simulate process crash by aborting between write/rename if possible).
37
+ - Tests for safeParse recovery and copying corrupt config to backup location.
38
+ - Tests for permission bits when creating directories and files.
39
+ - Tests to ensure lazy creation semantics: AGENTS.md and learned-rules.md created only by their commands.
40
+
41
+ Priority: Low / Future
42
+
43
+ - [ ] Consider migrating codebase to top-level async initializers where appropriate to reduce sync calls at module load time.
44
+ - [ ] Add a linter rule or CI step to detect un-awaited ensurePath calls (floating promises) — e.g., enable no-floating-promises or a custom rule.
45
+ - [ ] Document the file structure and initialization behavior in the repository README.
46
+
47
+ Notes
48
+ - The branch feat/async-ensurepath already makes ensurePath async-by-default and provides ensurePathSync for compatibility. The tasks above aim to remove the sync helper entirely by migrating call sites.
49
+ - Tests have been added to cover many of the behaviors but config.ts still needs higher coverage for robust error handling.