@travisennis/acai 0.0.8 → 0.0.10

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 (386) hide show
  1. package/README.md +48 -729
  2. package/bin/acai +52 -0
  3. package/dist/agent/index.d.ts +12 -2
  4. package/dist/agent/index.d.ts.map +1 -1
  5. package/dist/agent/index.js +378 -168
  6. package/dist/agent/sub-agent.d.ts +23 -0
  7. package/dist/agent/sub-agent.d.ts.map +1 -0
  8. package/dist/agent/sub-agent.js +109 -0
  9. package/dist/cli/index.d.ts +26 -0
  10. package/dist/cli/index.d.ts.map +1 -0
  11. package/dist/{cli.js → cli/index.js} +84 -76
  12. package/dist/cli/stdin.d.ts +9 -0
  13. package/dist/cli/stdin.d.ts.map +1 -0
  14. package/dist/cli/stdin.js +37 -0
  15. package/dist/commands/copy/index.js +2 -2
  16. package/dist/commands/copy/utils.d.ts.map +1 -1
  17. package/dist/commands/copy/utils.js +15 -13
  18. package/dist/commands/generate-rules/index.d.ts +1 -1
  19. package/dist/commands/generate-rules/index.d.ts.map +1 -1
  20. package/dist/commands/generate-rules/index.js +16 -100
  21. package/dist/commands/generate-rules/service.d.ts +21 -0
  22. package/dist/commands/generate-rules/service.d.ts.map +1 -0
  23. package/dist/commands/generate-rules/service.js +103 -0
  24. package/dist/commands/handoff/index.js +2 -2
  25. package/dist/commands/health/index.js +1 -1
  26. package/dist/commands/health/utils.d.ts.map +1 -1
  27. package/dist/commands/health/utils.js +6 -0
  28. package/dist/commands/history/index.d.ts +1 -1
  29. package/dist/commands/history/index.d.ts.map +1 -1
  30. package/dist/commands/history/index.js +17 -18
  31. package/dist/commands/history/types.d.ts +38 -0
  32. package/dist/commands/history/types.d.ts.map +1 -1
  33. package/dist/commands/history/utils.d.ts.map +1 -1
  34. package/dist/commands/history/utils.js +63 -58
  35. package/dist/commands/init/index.d.ts.map +1 -1
  36. package/dist/commands/init/index.js +3 -8
  37. package/dist/commands/init-project/index.d.ts.map +1 -1
  38. package/dist/commands/init-project/index.js +3 -3
  39. package/dist/commands/init-project/utils.d.ts.map +1 -1
  40. package/dist/commands/init-project/utils.js +10 -2
  41. package/dist/commands/list-tools/index.d.ts.map +1 -1
  42. package/dist/commands/list-tools/index.js +7 -31
  43. package/dist/commands/manager.d.ts +2 -2
  44. package/dist/commands/manager.d.ts.map +1 -1
  45. package/dist/commands/manager.js +57 -33
  46. package/dist/commands/model/index.d.ts.map +1 -1
  47. package/dist/commands/model/index.js +20 -151
  48. package/dist/commands/model/model-panel.d.ts +4 -0
  49. package/dist/commands/model/model-panel.d.ts.map +1 -0
  50. package/dist/commands/model/model-panel.js +144 -0
  51. package/dist/commands/paste/index.d.ts.map +1 -1
  52. package/dist/commands/paste/index.js +59 -62
  53. package/dist/commands/paste/utils.d.ts.map +1 -1
  54. package/dist/commands/paste/utils.js +88 -58
  55. package/dist/commands/pickup/index.d.ts.map +1 -1
  56. package/dist/commands/pickup/index.js +6 -3
  57. package/dist/commands/pickup/utils.js +3 -3
  58. package/dist/commands/resources/index.d.ts.map +1 -1
  59. package/dist/commands/resources/index.js +33 -50
  60. package/dist/commands/review/index.d.ts.map +1 -1
  61. package/dist/commands/review/index.js +3 -117
  62. package/dist/commands/review/review-panel.d.ts +3 -0
  63. package/dist/commands/review/review-panel.d.ts.map +1 -0
  64. package/dist/commands/review/review-panel.js +186 -0
  65. package/dist/commands/review/utils.d.ts +9 -0
  66. package/dist/commands/review/utils.d.ts.map +1 -1
  67. package/dist/commands/review/utils.js +127 -68
  68. package/dist/commands/session/index.d.ts +1 -1
  69. package/dist/commands/session/index.d.ts.map +1 -1
  70. package/dist/commands/session/index.js +134 -112
  71. package/dist/commands/session/types.d.ts +7 -0
  72. package/dist/commands/session/types.d.ts.map +1 -1
  73. package/dist/commands/share/html-renderer.d.ts +25 -0
  74. package/dist/commands/share/html-renderer.d.ts.map +1 -0
  75. package/dist/commands/share/html-renderer.js +384 -0
  76. package/dist/commands/share/index.d.ts +3 -0
  77. package/dist/commands/share/index.d.ts.map +1 -0
  78. package/dist/commands/share/index.js +122 -0
  79. package/dist/commands/shell/index.d.ts.map +1 -1
  80. package/dist/commands/shell/index.js +16 -1
  81. package/dist/commands/types.d.ts +2 -2
  82. package/dist/commands/types.d.ts.map +1 -1
  83. package/dist/{config.d.ts → config/index.d.ts} +20 -9
  84. package/dist/config/index.d.ts.map +1 -0
  85. package/dist/{config.js → config/index.js} +43 -42
  86. package/dist/execution/index.d.ts.map +1 -1
  87. package/dist/execution/index.js +75 -55
  88. package/dist/index.d.ts +1 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +170 -127
  91. package/dist/middleware/cache.d.ts.map +1 -1
  92. package/dist/middleware/cache.js +18 -36
  93. package/dist/models/ai-config.d.ts +1 -0
  94. package/dist/models/ai-config.d.ts.map +1 -1
  95. package/dist/models/ai-config.js +4 -3
  96. package/dist/models/anthropic-provider.d.ts +2 -5
  97. package/dist/models/anthropic-provider.d.ts.map +1 -1
  98. package/dist/models/anthropic-provider.js +3 -70
  99. package/dist/models/deepseek-provider.d.ts +1 -0
  100. package/dist/models/deepseek-provider.d.ts.map +1 -1
  101. package/dist/models/google-provider.d.ts +2 -3
  102. package/dist/models/google-provider.d.ts.map +1 -1
  103. package/dist/models/google-provider.js +0 -26
  104. package/dist/models/groq-provider.d.ts +1 -0
  105. package/dist/models/groq-provider.d.ts.map +1 -1
  106. package/dist/models/manager.d.ts +13 -2
  107. package/dist/models/manager.d.ts.map +1 -1
  108. package/dist/models/manager.js +20 -8
  109. package/dist/models/openai-provider.d.ts +5 -5
  110. package/dist/models/openai-provider.d.ts.map +1 -1
  111. package/dist/models/openai-provider.js +27 -40
  112. package/dist/models/opencode-zen-provider.d.ts +8 -3
  113. package/dist/models/opencode-zen-provider.d.ts.map +1 -1
  114. package/dist/models/opencode-zen-provider.js +68 -11
  115. package/dist/models/openrouter-provider.d.ts +24 -30
  116. package/dist/models/openrouter-provider.d.ts.map +1 -1
  117. package/dist/models/openrouter-provider.js +92 -177
  118. package/dist/models/providers.d.ts +1 -1
  119. package/dist/models/providers.d.ts.map +1 -1
  120. package/dist/models/xai-provider.d.ts +4 -3
  121. package/dist/models/xai-provider.d.ts.map +1 -1
  122. package/dist/models/xai-provider.js +18 -18
  123. package/dist/modes/manager.d.ts +23 -0
  124. package/dist/modes/manager.d.ts.map +1 -0
  125. package/dist/modes/manager.js +77 -0
  126. package/dist/modes/prompts.d.ts +2 -0
  127. package/dist/modes/prompts.d.ts.map +1 -0
  128. package/dist/modes/prompts.js +143 -0
  129. package/dist/prompts/mentions.d.ts +11 -0
  130. package/dist/prompts/mentions.d.ts.map +1 -0
  131. package/dist/{mentions.js → prompts/mentions.js} +21 -80
  132. package/dist/prompts/system-prompt.d.ts +26 -0
  133. package/dist/prompts/system-prompt.d.ts.map +1 -0
  134. package/dist/{prompts.js → prompts/system-prompt.js} +50 -22
  135. package/dist/repl/index.d.ts +174 -0
  136. package/dist/repl/index.d.ts.map +1 -0
  137. package/dist/{repl-new.js → repl/index.js} +399 -76
  138. package/dist/repl/project-status.d.ts +1 -0
  139. package/dist/repl/project-status.d.ts.map +1 -1
  140. package/dist/repl/project-status.js +4 -1
  141. package/dist/sessions/manager.d.ts +93 -1
  142. package/dist/sessions/manager.d.ts.map +1 -1
  143. package/dist/sessions/manager.js +264 -9
  144. package/dist/sessions/summary.d.ts +4 -0
  145. package/dist/sessions/summary.d.ts.map +1 -0
  146. package/dist/sessions/summary.js +30 -0
  147. package/dist/{skills.d.ts → skills/index.d.ts} +14 -2
  148. package/dist/skills/index.d.ts.map +1 -0
  149. package/dist/skills/index.js +294 -0
  150. package/dist/subagents/index.d.ts +15 -0
  151. package/dist/subagents/index.d.ts.map +1 -0
  152. package/dist/subagents/index.js +231 -0
  153. package/dist/terminal/control.d.ts +1 -1
  154. package/dist/terminal/control.d.ts.map +1 -1
  155. package/dist/terminal/control.js +30 -9
  156. package/dist/terminal/east-asian-width.d.ts.map +1 -1
  157. package/dist/terminal/east-asian-width.js +404 -351
  158. package/dist/terminal/keys.d.ts +17 -0
  159. package/dist/terminal/keys.d.ts.map +1 -1
  160. package/dist/terminal/keys.js +37 -0
  161. package/dist/terminal/select-prompt.d.ts.map +1 -1
  162. package/dist/terminal/select-prompt.js +24 -12
  163. package/dist/terminal/string-width.d.ts.map +1 -1
  164. package/dist/terminal/string-width.js +25 -27
  165. package/dist/terminal/style.d.ts.map +1 -1
  166. package/dist/terminal/style.js +4 -7
  167. package/dist/terminal/supports-color.d.ts.map +1 -1
  168. package/dist/terminal/supports-color.js +41 -27
  169. package/dist/terminal/table/cell.d.ts +12 -0
  170. package/dist/terminal/table/cell.d.ts.map +1 -1
  171. package/dist/terminal/table/cell.js +40 -25
  172. package/dist/terminal/table/layout-manager.d.ts.map +1 -1
  173. package/dist/terminal/table/layout-manager.js +100 -68
  174. package/dist/terminal/table/utils.d.ts.map +1 -1
  175. package/dist/terminal/table/utils.js +17 -10
  176. package/dist/terminal/wrap-ansi.d.ts.map +1 -1
  177. package/dist/terminal/wrap-ansi.js +172 -103
  178. package/dist/tokens/tracker.d.ts +1 -0
  179. package/dist/tokens/tracker.d.ts.map +1 -1
  180. package/dist/tokens/tracker.js +3 -0
  181. package/dist/tools/agent.d.ts +27 -0
  182. package/dist/tools/agent.d.ts.map +1 -0
  183. package/dist/tools/agent.js +81 -0
  184. package/dist/tools/bash.d.ts +4 -3
  185. package/dist/tools/bash.d.ts.map +1 -1
  186. package/dist/tools/bash.js +343 -121
  187. package/dist/tools/code-search.d.ts +41 -0
  188. package/dist/tools/code-search.d.ts.map +1 -0
  189. package/dist/tools/code-search.js +195 -0
  190. package/dist/tools/directory-tree.d.ts +3 -3
  191. package/dist/tools/directory-tree.d.ts.map +1 -1
  192. package/dist/tools/directory-tree.js +8 -5
  193. package/dist/tools/dynamic-tool-loader.d.ts +2 -5
  194. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  195. package/dist/tools/dynamic-tool-loader.js +20 -4
  196. package/dist/tools/edit-file.d.ts +7 -7
  197. package/dist/tools/edit-file.d.ts.map +1 -1
  198. package/dist/tools/edit-file.js +164 -66
  199. package/dist/tools/glob.d.ts +6 -6
  200. package/dist/tools/glob.d.ts.map +1 -1
  201. package/dist/tools/glob.js +95 -55
  202. package/dist/tools/grep.d.ts +15 -12
  203. package/dist/tools/grep.d.ts.map +1 -1
  204. package/dist/tools/grep.js +300 -192
  205. package/dist/tools/index.d.ts +143 -5
  206. package/dist/tools/index.d.ts.map +1 -1
  207. package/dist/tools/index.js +39 -24
  208. package/dist/tools/ls.d.ts +2 -2
  209. package/dist/tools/ls.d.ts.map +1 -1
  210. package/dist/tools/ls.js +7 -5
  211. package/dist/tools/read-file.d.ts +3 -3
  212. package/dist/tools/read-file.d.ts.map +1 -1
  213. package/dist/tools/read-file.js +74 -34
  214. package/dist/tools/save-file.d.ts +3 -3
  215. package/dist/tools/save-file.d.ts.map +1 -1
  216. package/dist/tools/save-file.js +11 -11
  217. package/dist/tools/skill.d.ts +23 -0
  218. package/dist/tools/skill.d.ts.map +1 -0
  219. package/dist/tools/skill.js +65 -0
  220. package/dist/tools/think.d.ts.map +1 -1
  221. package/dist/tools/think.js +2 -9
  222. package/dist/tools/utils.d.ts +2 -0
  223. package/dist/tools/utils.d.ts.map +1 -1
  224. package/dist/tools/utils.js +12 -0
  225. package/dist/tools/web-fetch.d.ts +62 -0
  226. package/dist/tools/web-fetch.d.ts.map +1 -0
  227. package/dist/tools/web-fetch.js +429 -0
  228. package/dist/tools/web-search.d.ts +62 -0
  229. package/dist/tools/web-search.d.ts.map +1 -0
  230. package/dist/tools/web-search.js +226 -0
  231. package/dist/tui/autocomplete/attachment-provider.d.ts +3 -6
  232. package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -1
  233. package/dist/tui/autocomplete/attachment-provider.js +25 -78
  234. package/dist/tui/autocomplete/base-provider.d.ts +1 -0
  235. package/dist/tui/autocomplete/base-provider.d.ts.map +1 -1
  236. package/dist/tui/autocomplete/combined-provider.d.ts +1 -4
  237. package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -1
  238. package/dist/tui/autocomplete/combined-provider.js +3 -17
  239. package/dist/tui/autocomplete/command-provider.d.ts +1 -0
  240. package/dist/tui/autocomplete/command-provider.d.ts.map +1 -1
  241. package/dist/tui/autocomplete/command-provider.js +3 -0
  242. package/dist/tui/autocomplete/file-search-provider.d.ts +2 -1
  243. package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -1
  244. package/dist/tui/autocomplete/file-search-provider.js +36 -16
  245. package/dist/tui/autocomplete/skill-provider.d.ts +17 -0
  246. package/dist/tui/autocomplete/skill-provider.d.ts.map +1 -0
  247. package/dist/tui/autocomplete/skill-provider.js +49 -0
  248. package/dist/tui/autocomplete.d.ts +2 -2
  249. package/dist/tui/autocomplete.d.ts.map +1 -1
  250. package/dist/tui/autocomplete.js +3 -5
  251. package/dist/tui/components/assistant-message.d.ts.map +1 -1
  252. package/dist/tui/components/assistant-message.js +0 -4
  253. package/dist/tui/components/editor.d.ts +21 -2
  254. package/dist/tui/components/editor.d.ts.map +1 -1
  255. package/dist/tui/components/editor.js +228 -236
  256. package/dist/tui/components/footer.d.ts +6 -4
  257. package/dist/tui/components/footer.d.ts.map +1 -1
  258. package/dist/tui/components/footer.js +49 -25
  259. package/dist/tui/components/markdown.d.ts +8 -5
  260. package/dist/tui/components/markdown.d.ts.map +1 -1
  261. package/dist/tui/components/markdown.js +57 -39
  262. package/dist/tui/components/modal.d.ts.map +1 -1
  263. package/dist/tui/components/modal.js +35 -33
  264. package/dist/tui/components/notification.d.ts +13 -2
  265. package/dist/tui/components/notification.d.ts.map +1 -1
  266. package/dist/tui/components/notification.js +37 -2
  267. package/dist/tui/components/progress-bar.js +1 -1
  268. package/dist/tui/components/select-list.d.ts +1 -0
  269. package/dist/tui/components/select-list.d.ts.map +1 -1
  270. package/dist/tui/components/select-list.js +14 -11
  271. package/dist/tui/components/text.d.ts +16 -0
  272. package/dist/tui/components/text.d.ts.map +1 -1
  273. package/dist/tui/components/text.js +72 -57
  274. package/dist/tui/components/thinking-block.d.ts +9 -0
  275. package/dist/tui/components/thinking-block.d.ts.map +1 -1
  276. package/dist/tui/components/thinking-block.js +43 -11
  277. package/dist/tui/components/tool-execution.d.ts +5 -1
  278. package/dist/tui/components/tool-execution.d.ts.map +1 -1
  279. package/dist/tui/components/tool-execution.js +19 -10
  280. package/dist/tui/components/user-message.d.ts.map +1 -1
  281. package/dist/tui/components/user-message.js +0 -3
  282. package/dist/tui/components/welcome.js +2 -2
  283. package/dist/tui/editor-launcher.d.ts +13 -0
  284. package/dist/tui/editor-launcher.d.ts.map +1 -0
  285. package/dist/tui/editor-launcher.js +39 -0
  286. package/dist/tui/index.d.ts +3 -1
  287. package/dist/tui/index.d.ts.map +1 -1
  288. package/dist/tui/index.js +1 -0
  289. package/dist/tui/terminal.d.ts +27 -0
  290. package/dist/tui/terminal.d.ts.map +1 -1
  291. package/dist/tui/terminal.js +144 -15
  292. package/dist/tui/tui.d.ts +43 -0
  293. package/dist/tui/tui.d.ts.map +1 -1
  294. package/dist/tui/tui.js +172 -41
  295. package/dist/utils/bash/parse.d.ts +19 -0
  296. package/dist/utils/bash/parse.d.ts.map +1 -0
  297. package/dist/utils/bash/parse.js +223 -0
  298. package/dist/utils/bash/quote.d.ts +6 -0
  299. package/dist/utils/bash/quote.d.ts.map +1 -0
  300. package/dist/utils/bash/quote.js +23 -0
  301. package/dist/utils/bash.d.ts.map +1 -1
  302. package/dist/utils/bash.js +211 -126
  303. package/dist/utils/command-protection.d.ts +28 -0
  304. package/dist/utils/command-protection.d.ts.map +1 -0
  305. package/dist/utils/command-protection.js +324 -0
  306. package/dist/utils/dedent.d.ts.map +1 -0
  307. package/dist/utils/env-expand.d.ts +2 -0
  308. package/dist/utils/env-expand.d.ts.map +1 -0
  309. package/dist/utils/env-expand.js +8 -0
  310. package/dist/utils/filesystem/path-display.d.ts +11 -0
  311. package/dist/utils/filesystem/path-display.d.ts.map +1 -0
  312. package/dist/utils/filesystem/path-display.js +32 -0
  313. package/dist/utils/filesystem/security.d.ts +2 -2
  314. package/dist/utils/filesystem/security.d.ts.map +1 -1
  315. package/dist/utils/filesystem/security.js +32 -31
  316. package/dist/utils/formatting.d.ts.map +1 -0
  317. package/dist/{formatting.js → utils/formatting.js} +1 -1
  318. package/dist/utils/git.d.ts +4 -0
  319. package/dist/utils/git.d.ts.map +1 -1
  320. package/dist/utils/git.js +30 -0
  321. package/dist/utils/glob.d.ts +1 -1
  322. package/dist/utils/glob.d.ts.map +1 -1
  323. package/dist/utils/logger.d.ts.map +1 -0
  324. package/dist/{logger.js → utils/logger.js} +1 -1
  325. package/dist/utils/parsing.d.ts.map +1 -0
  326. package/dist/utils/process.d.ts.map +1 -1
  327. package/dist/utils/process.js +90 -37
  328. package/dist/utils/templates.d.ts +2 -0
  329. package/dist/utils/templates.d.ts.map +1 -0
  330. package/dist/utils/templates.js +24 -0
  331. package/dist/utils/version.d.ts.map +1 -0
  332. package/dist/{version.js → utils/version.js} +1 -1
  333. package/package.json +34 -25
  334. package/dist/cli.d.ts +0 -23
  335. package/dist/cli.d.ts.map +0 -1
  336. package/dist/commands/exit/index.d.ts +0 -10
  337. package/dist/commands/exit/index.d.ts.map +0 -1
  338. package/dist/commands/exit/index.js +0 -21
  339. package/dist/commands/exit/types.d.ts +0 -8
  340. package/dist/commands/exit/types.d.ts.map +0 -1
  341. package/dist/commands/exit/types.js +0 -1
  342. package/dist/commands/exit/utils.d.ts +0 -2
  343. package/dist/commands/exit/utils.d.ts.map +0 -1
  344. package/dist/commands/exit/utils.js +0 -13
  345. package/dist/commands/prompt/index.d.ts +0 -5
  346. package/dist/commands/prompt/index.d.ts.map +0 -1
  347. package/dist/commands/prompt/index.js +0 -126
  348. package/dist/commands/prompt/types.d.ts +0 -15
  349. package/dist/commands/prompt/types.d.ts.map +0 -1
  350. package/dist/commands/prompt/types.js +0 -1
  351. package/dist/commands/prompt/utils.d.ts +0 -12
  352. package/dist/commands/prompt/utils.d.ts.map +0 -1
  353. package/dist/commands/prompt/utils.js +0 -107
  354. package/dist/commands/reset/index.d.ts +0 -3
  355. package/dist/commands/reset/index.d.ts.map +0 -1
  356. package/dist/commands/reset/index.js +0 -25
  357. package/dist/commands/reset/types.d.ts +0 -1
  358. package/dist/commands/reset/types.d.ts.map +0 -1
  359. package/dist/commands/reset/types.js +0 -3
  360. package/dist/commands/save/index.d.ts +0 -3
  361. package/dist/commands/save/index.d.ts.map +0 -1
  362. package/dist/commands/save/index.js +0 -19
  363. package/dist/config.d.ts.map +0 -1
  364. package/dist/dedent.d.ts.map +0 -1
  365. package/dist/formatting.d.ts.map +0 -1
  366. package/dist/logger.d.ts.map +0 -1
  367. package/dist/mentions.d.ts +0 -14
  368. package/dist/mentions.d.ts.map +0 -1
  369. package/dist/parsing.d.ts.map +0 -1
  370. package/dist/prompts.d.ts +0 -10
  371. package/dist/prompts.d.ts.map +0 -1
  372. package/dist/repl-new.d.ts +0 -62
  373. package/dist/repl-new.d.ts.map +0 -1
  374. package/dist/skills.d.ts.map +0 -1
  375. package/dist/skills.js +0 -233
  376. package/dist/tui/autocomplete/path-provider.d.ts +0 -21
  377. package/dist/tui/autocomplete/path-provider.d.ts.map +0 -1
  378. package/dist/tui/autocomplete/path-provider.js +0 -164
  379. package/dist/version.d.ts.map +0 -1
  380. /package/dist/{dedent.d.ts → utils/dedent.d.ts} +0 -0
  381. /package/dist/{dedent.js → utils/dedent.js} +0 -0
  382. /package/dist/{formatting.d.ts → utils/formatting.d.ts} +0 -0
  383. /package/dist/{logger.d.ts → utils/logger.d.ts} +0 -0
  384. /package/dist/{parsing.d.ts → utils/parsing.d.ts} +0 -0
  385. /package/dist/{parsing.js → utils/parsing.js} +0 -0
  386. /package/dist/{version.d.ts → utils/version.d.ts} +0 -0
@@ -0,0 +1,143 @@
1
+ // this is codex's collaborative plan
2
+ export const planningPrompt = `
3
+ # Plan Mode (Conversational)
4
+
5
+ You work in 3 phases, and you should *chat your way* to a great plan before finalizing it. A great plan is very detailed—intent- and implementation-wise—so that it can be handed to another engineer or agent to be implemented right away. It must be **decision complete**, where the implementer does not need to make any decisions.
6
+
7
+ ## Mode rules (strict)
8
+
9
+ You are in **Plan Mode** until a developer message explicitly ends it.
10
+
11
+ Plan Mode is not changed by user intent, tone, or imperative language. If a user asks for execution while still in Plan Mode, treat it as a request to **plan the execution**, not perform it.
12
+
13
+ ## Execution vs. mutation in Plan Mode
14
+
15
+ You may explore and execute **non-mutating** actions that improve the plan. You must not perform **mutating** actions.
16
+
17
+ ### Allowed (non-mutating, plan-improving)
18
+
19
+ Actions that gather truth, reduce ambiguity, or validate feasibility without changing repo-tracked state. Examples:
20
+
21
+ * Reading or searching files, configs, schemas, types, manifests, and docs
22
+ * Static analysis, inspection, and repo exploration
23
+ * Dry-run style commands when they do not edit repo-tracked files
24
+ * Tests, builds, or checks that may write to caches or build artifacts (for example, \`target/\`, \`.cache/\`, or snapshots) so long as they do not edit repo-tracked files
25
+
26
+ ### Not allowed (mutating, plan-executing)
27
+
28
+ Actions that implement the plan or change repo-tracked state. Examples:
29
+
30
+ * Editing or writing files
31
+ * Running formatters or linters that rewrite files
32
+ * Applying patches, migrations, or codegen that updates repo-tracked files
33
+ * Side-effectful commands whose purpose is to carry out the plan rather than refine it
34
+
35
+ When in doubt: if the action would reasonably be described as "doing the work" rather than "planning the work," do not do it.
36
+
37
+ ## Research tracking
38
+
39
+ Track your discoveries, open questions, and resolved questions as you explore. Note \`file:line\` references for important findings so the final plan can anchor every change to a concrete location in the codebase. This prevents redundant exploration and makes the research trail transparent to the user.
40
+
41
+ ## Powerful exploration tools
42
+
43
+ You have access to powerful tools for codebase exploration—use them liberally:
44
+
45
+ * **CodeSearch**: Use this for semantic code search. It understands natural language queries like "function that handles user authentication" and finds relevant code even when keywords don't match exactly. This is often more effective than grep for understanding code patterns and relationships.
46
+ * **codebase-researcher subagent**: When you need thorough investigation of a feature, system, or component, launch the codebase-researcher subagent to perform deep exploration. Provide it with a detailed brief and it will comprehensively investigate the codebase, returning findings that you can synthesize into your plan.
47
+
48
+ For complex tasks, consider: (1) launching the codebase-researcher in parallel while you explore other areas, (2) using CodeSearch to find related patterns across the codebase, then (3) synthesizing findings into your plan.
49
+
50
+ ## PHASE 1 — Ground in the environment (explore first, ask second)
51
+
52
+ Begin by grounding yourself in the actual environment. Eliminate unknowns in the prompt by discovering facts, not by asking the user. Resolve all questions that can be answered through exploration or inspection. Identify missing or ambiguous details only if they cannot be derived from the environment. Silent exploration between turns is allowed and encouraged.
53
+
54
+ Before asking the user any question, perform at least one targeted non-mutating exploration pass (for example: search relevant files, inspect likely entrypoints/configs, confirm current implementation shape), unless no local environment/repo is available.
55
+
56
+ Exception: you may ask clarifying questions about the user's prompt before exploring, ONLY if there are obvious ambiguities or contradictions in the prompt itself. However, if ambiguity might be resolved by exploring, always prefer exploring first.
57
+
58
+ Do not ask questions that can be answered from the repo or system (for example, "where is this struct?" or "which UI component should we use?" when exploration can make it clear). Only ask once you have exhausted reasonable non-mutating exploration.
59
+
60
+ ## PHASE 2 — Intent chat (what they actually want)
61
+
62
+ * Keep asking until you can clearly state: goal + success criteria, audience, in/out of scope, constraints, current state, and the key preferences/tradeoffs.
63
+ * Require an explicit **"Out of Scope"** statement — what we are NOT doing. This prevents scope creep and sets clear expectations.
64
+ * Be skeptical: actively challenge vague requirements, identify issues early, and verify assumptions against code rather than accepting them at face value.
65
+ * Bias toward questions over guessing: if any high-impact ambiguity remains, do NOT plan yet—ask.
66
+
67
+ ## PHASE 3 — Implementation chat (what/how we’ll build)
68
+
69
+ * Once intent is stable, keep asking until the spec is decision complete: approach, interfaces (APIs/schemas/I/O), data flow, edge cases/failure modes, testing + acceptance criteria, rollout/monitoring, and any migrations/compat constraints.
70
+ * **Propose a plan outline first**: before writing the full detailed plan, present a high-level outline of implementation phases — each with a name and what it accomplishes. Get user feedback on structure before filling in details.
71
+ * **Migration, rollback, and backwards compatibility**: when applicable, give these dedicated attention. They are often the hardest parts of implementation and must not be an afterthought.
72
+ * **Common implementation sequencing** — use these as reference when ordering phases:
73
+ * Database changes: schema/migration → store methods → business logic → API → clients
74
+ * New features: research existing patterns → data model → backend logic → API endpoints → UI
75
+ * Refactoring: document current behavior → plan incremental changes → maintain backwards compatibility → migration strategy
76
+
77
+ ## Asking questions
78
+
79
+ Critical rules:
80
+
81
+ * Offer meaningful multiple‑choice options when possible; don’t include filler choices that are obviously wrong or irrelevant.
82
+
83
+ You SHOULD ask many questions, but each question must:
84
+
85
+ * materially change the spec/plan, OR
86
+ * confirm/lock an assumption, OR
87
+ * choose between meaningful tradeoffs.
88
+ * not be answerable by non-mutating commands.
89
+
90
+ ## Two kinds of unknowns (treat differently)
91
+
92
+ 1. **Discoverable facts** (repo/system truth): explore first.
93
+
94
+ * Before asking, run targeted searches and check likely sources of truth (configs/manifests/entrypoints/schemas/types/constants).
95
+ * Ask only if: multiple plausible candidates; nothing found but you need a missing identifier/context; or ambiguity is actually product intent.
96
+ * If asking, present concrete candidates (paths/service names) + recommend one.
97
+ * Never ask questions you can answer from your environment (e.g., “where is this struct”).
98
+
99
+ 2. **Preferences/tradeoffs** (not discoverable): ask early.
100
+
101
+ * These are intent or implementation preferences that cannot be derived from exploration.
102
+ * Provide 2–4 mutually exclusive options + a recommended default.
103
+ * If unanswered, proceed with the recommended option and record it as an assumption in the final plan.
104
+
105
+ ## Finalization rule
106
+
107
+ Only output the final plan when it is decision complete and leaves no decisions to the implementer.
108
+
109
+ When you present the official plan, wrap it in a \`<proposed_plan>\` block so the client can render it specially:
110
+
111
+ 1) The opening tag must be on its own line.
112
+ 2) Start the plan content on the next line (no text on the same line as the tag).
113
+ 3) The closing tag must be on its own line.
114
+ 4) Use Markdown inside the block.
115
+ 5) Keep the tags exactly as \`<proposed_plan>\` and \`</proposed_plan>\` (do not translate or rename them), even if the plan content is in another language.
116
+
117
+ Example:
118
+
119
+ <proposed_plan>
120
+ plan content
121
+ </proposed_plan>
122
+
123
+ plan content should be human and agent digestible. The final plan must be plan-only and include:
124
+
125
+ * A clear title
126
+ * A brief summary section
127
+ * Important changes or additions to public APIs/interfaces/types
128
+ * Specific \`file:line\` references for all code locations the plan touches
129
+ * An explicit **"Out of Scope"** section
130
+ * **Success criteria** separated into two categories:
131
+ * **Automated verification** — commands that can be run (test, lint, typecheck, build) and specific files/code that should exist or compile
132
+ * **Manual verification** — UI/UX functionality, performance under real conditions, hard-to-automate edge cases, user acceptance criteria
133
+ * Migration/rollback strategy when applicable
134
+ * Explicit assumptions and defaults chosen where needed
135
+
136
+ Do not ask "should I proceed?" in the final output. The user can easily switch out of Plan mode and request implementation if you have included a \`<proposed_plan>\` block in your response. Alternatively, they can decide to stay in Plan mode and continue refining the plan.
137
+
138
+ Only produce at most one \`<proposed_plan>\` block per turn, and only when you are presenting a complete spec.
139
+
140
+ ## Plan acceptance
141
+
142
+ After presenting a \`<proposed_plan>\` block, explicitly ask the user if they accept the plan. If they accept (e.g., they say "yes", "accept", "go ahead", or similar confirmation), write the plan content to \`plan.md\` in the current working directory using the Write tool. After writing, acknowledge the plan has been saved and ask if they'd like to proceed with implementation or continue refining.
143
+ `;
@@ -0,0 +1,11 @@
1
+ import type { ModelMetadata } from "../models/providers.ts";
2
+ import type { ContextItem } from "./manager.ts";
3
+ export declare function processPrompt(message: string, { baseDir, model, pasteStore, }: {
4
+ baseDir: string;
5
+ model: ModelMetadata;
6
+ pasteStore?: Map<number, string>;
7
+ }): Promise<{
8
+ message: string;
9
+ context: ContextItem[];
10
+ }>;
11
+ //# sourceMappingURL=mentions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentions.d.ts","sourceRoot":"","sources":["../../source/prompts/mentions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwGhD,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,EACE,OAAO,EACP,KAAK,EACL,UAAU,GACX,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,GACA,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,CAwDtD"}
@@ -1,48 +1,31 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { initExecutionEnvironment } from "./execution/index.js";
4
- import { formatFile } from "./formatting.js";
5
- class ShellCommandError extends Error {
6
- command;
7
- exitCode;
8
- output;
9
- constructor(message, command, exitCode, output) {
10
- super(message);
11
- this.name = "ShellCommandError";
12
- this.command = command;
13
- this.exitCode = exitCode;
14
- this.output = output;
3
+ import { formatFile } from "../utils/formatting.js";
4
+ async function readFileEntry(fullPath, relativeFilePath, format) {
5
+ try {
6
+ const fileContents = await fs.readFile(fullPath, "utf8");
7
+ return formatFile(relativeFilePath, fileContents, format);
8
+ }
9
+ catch (error) {
10
+ return `Error reading file ${relativeFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`;
15
11
  }
16
12
  }
17
- export class PromptError extends Error {
18
- constructor(message, cause) {
19
- super(message, { cause });
20
- this.name = "PromptError";
13
+ async function collectFiles(currentPath, format, allContents, relativePath = "") {
14
+ const entries = await fs.readdir(currentPath, { withFileTypes: true });
15
+ for (const entry of entries) {
16
+ const fullPath = path.join(currentPath, entry.name);
17
+ const relativeFilePath = path.join(relativePath, entry.name);
18
+ if (entry.isDirectory()) {
19
+ await collectFiles(fullPath, format, allContents, relativeFilePath);
20
+ }
21
+ else if (entry.isFile()) {
22
+ allContents.push(await readFileEntry(fullPath, relativeFilePath, format));
23
+ }
21
24
  }
22
25
  }
23
- // Helper function to recursively read all files in a directory
24
26
  async function readDirectoryRecursive(dirPath, format) {
25
27
  const allContents = [];
26
- async function readDir(currentPath, relativePath = "") {
27
- const entries = await fs.readdir(currentPath, { withFileTypes: true });
28
- for (const entry of entries) {
29
- const fullPath = path.join(currentPath, entry.name);
30
- const relativeFilePath = path.join(relativePath, entry.name);
31
- if (entry.isDirectory()) {
32
- await readDir(fullPath, relativeFilePath);
33
- }
34
- else if (entry.isFile()) {
35
- try {
36
- const fileContents = await fs.readFile(fullPath, "utf8");
37
- allContents.push(formatFile(relativeFilePath, fileContents, format));
38
- }
39
- catch (error) {
40
- allContents.push(`Error reading file ${relativeFilePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
41
- }
42
- }
43
- }
44
- }
45
- await readDir(dirPath);
28
+ await collectFiles(dirPath, format, allContents);
46
29
  if (allContents.length === 0) {
47
30
  return `Directory ${path.basename(dirPath)} is empty or contains no readable files.`;
48
31
  }
@@ -91,34 +74,10 @@ async function processFileCommand(context) {
91
74
  return `Error accessing ${filePath}: An unknown error occurred.`;
92
75
  }
93
76
  }
94
- async function processShellCommand(command) {
95
- try {
96
- const execEnv = await initExecutionEnvironment();
97
- const { output, exitCode } = await execEnv.executeCommand(command, {
98
- throwOnError: true,
99
- });
100
- if (exitCode === 0) {
101
- return output;
102
- }
103
- throw new ShellCommandError(`Command failed with exit code ${exitCode}`, command, exitCode, output);
104
- }
105
- catch (error) {
106
- if (error instanceof ShellCommandError) {
107
- throw error;
108
- }
109
- if (error instanceof Error) {
110
- throw new ShellCommandError(`Command execution failed: ${error.message}`, command, undefined, undefined);
111
- }
112
- throw new ShellCommandError("Command execution failed with unknown error", command, undefined, undefined);
113
- }
114
- }
115
- // Returns the formatted string or an error message string
116
77
  export async function processPrompt(message, { baseDir, model, pasteStore, }) {
117
- const fileRegex = /@([^\s@]+(?:\.[\w\d]+))/g;
118
- const shellRegex = /!`([^`]+)`/g;
78
+ const fileRegex = /(?<![a-zA-Z0-9_-])#([a-zA-Z_][^\s#]*?(?:\.[a-zA-Z0-9]+)?)(?![^\s#]*#[\d.]+)/g;
119
79
  // Collect all matches for files
120
80
  const fileMatches = Array.from(message.matchAll(fileRegex));
121
- const shellMatches = Array.from(message.matchAll(shellRegex));
122
81
  const mentionProcessingPromises = [];
123
82
  // Process file references - collect promises
124
83
  for (const match of fileMatches) {
@@ -148,24 +107,6 @@ export async function processPrompt(message, { baseDir, model, pasteStore, }) {
148
107
  match = pasteRegex.exec(processedMessage);
149
108
  }
150
109
  }
151
- // Process shell commands
152
- for (const match of shellMatches) {
153
- const command = match[1];
154
- if (command) {
155
- try {
156
- const output = await processShellCommand(command);
157
- processedMessage = processedMessage.replace(match[0], output);
158
- }
159
- catch (error) {
160
- if (error instanceof ShellCommandError) {
161
- // Wrap shell command errors in PromptError
162
- throw new PromptError(`Shell command failed: ${error.message}`, error);
163
- }
164
- // For other errors, wrap them in PromptError
165
- throw new PromptError(`Unexpected error executing command: ${error instanceof Error ? error.message : "Unknown error"}`, error instanceof Error ? error : undefined);
166
- }
167
- }
168
- }
169
110
  // Wait for all mentions to be processed
170
111
  const mentionResults = await Promise.all(mentionProcessingPromises);
171
112
  const context = [];
@@ -0,0 +1,26 @@
1
+ import type { CompleteToolNames } from "../tools/index.ts";
2
+ type SystemPromptComponents = {
3
+ core: string;
4
+ userAgentsMd: string;
5
+ cwdAgentsMd: string;
6
+ learnedRules: string;
7
+ skills: string;
8
+ subagents: string;
9
+ };
10
+ export declare function environmentInfo(currentWorkingDir: string, allowedDirs: string[], logsPath?: string): Promise<string>;
11
+ type SystemPromptOptions = {
12
+ currentWorkingDir?: string;
13
+ allowedDirs?: string[];
14
+ logsPath?: string;
15
+ activeTools?: CompleteToolNames[];
16
+ includeRules?: boolean;
17
+ skillsEnabled?: boolean;
18
+ minimalPrompt?: boolean;
19
+ };
20
+ type SystemPromptResult = {
21
+ prompt: string;
22
+ components: SystemPromptComponents;
23
+ };
24
+ export declare function systemPrompt(options?: SystemPromptOptions): Promise<SystemPromptResult>;
25
+ export {};
26
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../source/prompts/system-prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAsCF,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,EAAE,EACrB,QAAQ,CAAC,EAAE,MAAM,mBA+BlB;AAED,KAAK,mBAAmB,GAAG;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,sBAAsB,CAAC;CACpC,CAAC;AAKF,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAyK7B"}
@@ -1,16 +1,17 @@
1
1
  import { platform } from "node:os";
2
- import { config } from "./config.js";
3
- import { dedent } from "./dedent.js";
4
- import { formatSkillsForPrompt, loadSkills } from "./skills.js";
5
- import { getShell } from "./terminal/index.js";
6
- import { getCurrentBranch, inGitDirectory } from "./utils/git.js";
2
+ import { config } from "../config/index.js";
3
+ import { formatSkillsForPrompt, loadSkills } from "../skills/index.js";
4
+ import { formatSubagentsForPrompt, loadSubagents } from "../subagents/index.js";
5
+ import { getShell } from "../terminal/index.js";
6
+ import { dedent } from "../utils/dedent.js";
7
+ import { getCurrentBranch, inGitDirectory } from "../utils/git.js";
7
8
  async function getProjectContext() {
8
9
  const agentsFiles = await config.readAgentsFiles();
9
10
  const userAgentsFile = agentsFiles.find((f) => f.path === "~/.acai/AGENTS.md");
10
11
  const cwdAgentsFile = agentsFiles.find((f) => f.path === "./AGENTS.md");
11
12
  const userRules = (userAgentsFile?.content ?? "").trim();
12
13
  const cwdRules = (cwdAgentsFile?.content ?? "").trim();
13
- const learnedRules = (await config.readProjectLearnedRulesFile()).trim();
14
+ const learnedRules = (await config.readLearnedRulesFile()).trim();
14
15
  let result = "";
15
16
  if (userRules || cwdRules) {
16
17
  result += "## Project Context:\n\n";
@@ -27,19 +28,33 @@ async function getProjectContext() {
27
28
  }
28
29
  result += `### Important rules to follow\n\n${learnedRules}`;
29
30
  }
30
- return result.trim();
31
+ return {
32
+ text: result.trim(),
33
+ userAgentsMd: userRules,
34
+ cwdAgentsMd: cwdRules,
35
+ learnedRules: learnedRules,
36
+ };
31
37
  }
32
- async function environmentInfo(allowedDirs) {
38
+ export async function environmentInfo(currentWorkingDir, allowedDirs, logsPath) {
33
39
  const gitDirectory = await inGitDirectory();
34
40
  let gitSection = `- **Is directory a git repo**: ${gitDirectory ? "Yes" : "No"}`;
35
41
  if (gitDirectory) {
36
42
  gitSection += `\n- **Current git branch**: ${await getCurrentBranch()}`;
37
43
  }
44
+ let logsSection = "";
45
+ if (logsPath) {
46
+ logsSection = `
47
+ ### Project logs:
48
+
49
+ - ${logsPath}`;
50
+ }
38
51
  return `## Environment
52
+ ### Current working directory:
53
+ ${currentWorkingDir}
39
54
 
40
55
  ### Allowed directories:
41
56
 
42
- ${allowedDirs.map((dir) => `- ${dir}`).join("\n")}
57
+ ${allowedDirs.map((dir) => `- ${dir}`).join("\n")}${logsSection}
43
58
 
44
59
  ### Information:
45
60
 
@@ -47,20 +62,27 @@ ${gitSection}
47
62
  - **Platform**: ${platform()}
48
63
  - **Shell**: ${getShell()}
49
64
  - **Today's date**: ${new Date().toISOString().split("T")[0]}
50
-
51
- - Note: The .tmp directory in the current working directory is deleted each time the agent shuts down.`;
65
+ `;
52
66
  }
53
- const DEFAULT_ALLOWED_DIRS = [process.cwd()];
67
+ const DEFAULT_WORKING_DIRS = process.cwd();
68
+ const DEFAULT_ALLOWED_DIR = [process.cwd()];
54
69
  export async function systemPrompt(options) {
55
- const { allowedDirs = DEFAULT_ALLOWED_DIRS, includeRules = true, skillsEnabled = true, } = options ?? {};
56
- const projectContextText = includeRules ? await getProjectContext() : "";
57
- const environmentInfoText = await environmentInfo(allowedDirs);
70
+ const { currentWorkingDir = DEFAULT_WORKING_DIRS, allowedDirs = DEFAULT_ALLOWED_DIR, logsPath, includeRules = true, skillsEnabled = true, minimalPrompt = true, } = options ?? {};
71
+ const projectContextResult = includeRules
72
+ ? await getProjectContext()
73
+ : { text: "", userAgentsMd: "", cwdAgentsMd: "", learnedRules: "" };
74
+ const projectContextText = projectContextResult.text;
75
+ const environmentInfoText = await environmentInfo(currentWorkingDir, allowedDirs, logsPath);
58
76
  let skillsText = "";
59
77
  if (skillsEnabled) {
60
78
  const skills = await loadSkills();
61
- skillsText = formatSkillsForPrompt(skills);
79
+ skillsText = formatSkillsForPrompt(skills.getModelInvocable());
62
80
  }
63
- const prompt = dedent `
81
+ const subagents = await loadSubagents();
82
+ const subagentsText = formatSubagentsForPrompt(subagents);
83
+ const corePrompt = minimalPrompt
84
+ ? "You are acai. You are running as a coding agent in a CLI on the user's computer."
85
+ : dedent `
64
86
  You are acai. You are running as a coding agent in a CLI on the user's computer.
65
87
 
66
88
  ## Core Principles
@@ -184,10 +206,16 @@ DEFAULT TO PARALLEL: Unless you have a specific reason why operations MUST be se
184
206
  - Apply principle of least privilege in API integrations
185
207
  - If a tool fails, ask the user how to proceed
186
208
  - Report errors with specific locations and suggested fixes
187
-
188
- ${projectContextText}
189
-
190
- ${environmentInfoText}${skillsText}
191
209
  `;
192
- return prompt;
210
+ const components = {
211
+ core: `${corePrompt}\n\n${environmentInfoText}`,
212
+ userAgentsMd: projectContextResult.userAgentsMd,
213
+ cwdAgentsMd: projectContextResult.cwdAgentsMd,
214
+ learnedRules: projectContextResult.learnedRules,
215
+ skills: skillsText,
216
+ subagents: subagentsText,
217
+ };
218
+ const assembledPrompt = `${corePrompt}\n${projectContextText}\n\n${environmentInfoText}${skillsText}\n\n${subagentsText}`;
219
+ const result = { prompt: assembledPrompt, components };
220
+ return result;
193
221
  }
@@ -0,0 +1,174 @@
1
+ import type { Agent, AgentEvent, AgentState } from "../agent/index.ts";
2
+ import type { CommandManager } from "../commands/manager.ts";
3
+ import type { ConfigManager } from "../config/index.ts";
4
+ import type { WorkspaceContext } from "../index.ts";
5
+ import type { ModelManager } from "../models/manager.ts";
6
+ import type { PromptManager } from "../prompts/manager.ts";
7
+ import { type SessionManager } from "../sessions/manager.ts";
8
+ import type { TokenCounter } from "../tokens/counter.ts";
9
+ import type { TokenTracker } from "../tokens/tracker.ts";
10
+ import type { CompleteToolSet } from "../tools/index.ts";
11
+ import type { ProcessTerminalOptions } from "../tui/terminal.ts";
12
+ /** Configuration options for the REPL instance. */
13
+ interface ReplOptions {
14
+ /** The AI agent that processes user prompts and generates responses. */
15
+ agent: Agent;
16
+ /** Manages session persistence, message history, and metadata. */
17
+ sessionManager: SessionManager;
18
+ /** Manages prompt construction including context injection. */
19
+ promptManager: PromptManager;
20
+ /** Manages model selection and metadata retrieval. */
21
+ modelManager: ModelManager;
22
+ /** Tracks token usage across the session. */
23
+ tokenTracker: TokenTracker;
24
+ /** Handles slash command parsing and execution. */
25
+ commands: CommandManager;
26
+ /** Application configuration manager for rule generation, etc. */
27
+ configManager: ConfigManager;
28
+ /** Counts tokens for prompt budgeting. */
29
+ tokenCounter: TokenCounter;
30
+ /** History of previously submitted prompts for recall. */
31
+ promptHistory: string[];
32
+ /** Workspace context including allowed directories. */
33
+ workspace: WorkspaceContext;
34
+ /** Optional complete set of tools available to the agent. */
35
+ tools?: CompleteToolSet;
36
+ /** Optional terminal configuration for the process terminal. */
37
+ terminalOptions?: ProcessTerminalOptions;
38
+ /** If true, don't save session to disk. */
39
+ noSession?: boolean;
40
+ }
41
+ /**
42
+ * Interactive Read-Eval-Print Loop that provides the primary user interface
43
+ * for the AI assistant CLI. Manages the TUI layout, handles keyboard shortcuts,
44
+ * processes agent events for streaming responses, and coordinates session lifecycle.
45
+ */
46
+ export declare class Repl {
47
+ private options;
48
+ private terminal;
49
+ private tui;
50
+ private welcome;
51
+ private editor;
52
+ private chatContainer;
53
+ private statusContainer;
54
+ private footer;
55
+ private editorContainer;
56
+ private notification;
57
+ private isInitialized;
58
+ private onInputCallback?;
59
+ private loadingAnimation;
60
+ private onInterruptCallback?;
61
+ private onExitCallback?;
62
+ private lastSigintTime;
63
+ private exitNotificationTimer?;
64
+ private pendingTools;
65
+ private tools?;
66
+ private streamingComponent;
67
+ private thinkingBlockComponent;
68
+ private allThinkingBlocks;
69
+ private allToolExecutions;
70
+ private verboseMode;
71
+ private modeManager;
72
+ private config;
73
+ /** Creates a new Repl instance, initializing the TUI layout and components. */
74
+ constructor(options: ReplOptions);
75
+ /**
76
+ * Initializes the REPL by setting up autocomplete,
77
+ * keyboard handlers, and the TUI component tree.
78
+ */
79
+ init(): Promise<void>;
80
+ /**
81
+ * Handles an agent event by updating the TUI accordingly.
82
+ * Processes events such as streaming messages, tool calls, thinking blocks,
83
+ * and agent lifecycle transitions (start, stop, error).
84
+ */
85
+ handle(event: AgentEvent, state: AgentState): Promise<void>;
86
+ /** Adds a user message component to the chat container. */
87
+ private addMessageToChat;
88
+ /**
89
+ * Adds a component to the chat container with spacing.
90
+ * Adds a Spacer(1) before every component (including the first).
91
+ */
92
+ private addComponentWithSpacing;
93
+ /** Returns a promise that resolves with the user's next input submission. */
94
+ getUserInput(): Promise<string>;
95
+ /** Clears the editor input and triggers a re-render. */
96
+ clearEditor(): void;
97
+ /**
98
+ * Sets the callback invoked when the user presses
99
+ * Escape to interrupt the agent.
100
+ */
101
+ setInterruptCallback(callback: () => void): void;
102
+ /** Sets the callback invoked on exit, receiving the current session ID. */
103
+ setExitCallback(callback: (sessionId: string) => void | Promise<void>): void;
104
+ /**
105
+ * Re-renders the entire session by restoring mode state,
106
+ * replaying token usage, and reconstructing the chat
107
+ * display.
108
+ */
109
+ rerender(): Promise<void>;
110
+ /**
111
+ * Rebuilds the chat container from the full session
112
+ * message history, including user messages, assistant
113
+ * responses, and tool executions.
114
+ */
115
+ private reconstructSession;
116
+ /**
117
+ * Extracts the text content from a user message,
118
+ * handling both string and array content formats.
119
+ */
120
+ private extractUserMessageText;
121
+ /**
122
+ * Renders an assistant message into the chat container,
123
+ * including reasoning/thinking blocks and text content.
124
+ */
125
+ private renderAssistantMessage;
126
+ /**
127
+ * Extracts tool call content parts from an assistant
128
+ * message, matching them with their corresponding
129
+ * tool results.
130
+ */
131
+ private extractToolCallsFromAssistant;
132
+ /**
133
+ * Creates start and end/error ToolEvent pairs from a
134
+ * resolved tool call, using the tool's display function
135
+ * when available.
136
+ */
137
+ private createToolEvents;
138
+ /**
139
+ * Toggles verbose mode on/off, updating all thinking
140
+ * block and tool execution components.
141
+ */
142
+ private handleCtrlO;
143
+ /**
144
+ * Starts a new session by saving the current one,
145
+ * resetting mode/tokens/UI, and clearing the chat.
146
+ */
147
+ private handleCtrlN;
148
+ private handleCtrlM;
149
+ /** Handles Ctrl+D to exit the REPL when the editor is empty. */
150
+ private handleCtrlD;
151
+ /**
152
+ * Handles Ctrl+C with double-press-to-exit logic.
153
+ * First press clears the editor; second press within
154
+ * 1 second exits.
155
+ */
156
+ private handleCtrlC;
157
+ /**
158
+ * Stops the REPL, cleaning up timers, animations,
159
+ * and the TUI. Optionally triggers the exit callback.
160
+ */
161
+ stop(showExitMessage?: boolean): void;
162
+ /**
163
+ * Generates rules automatically if autoGenerateRules is enabled
164
+ * and the session has messages.
165
+ */
166
+ private maybeGenerateRules;
167
+ /**
168
+ * Triggers rule generation for use before exit.
169
+ * Returns a promise that resolves when rules are generated.
170
+ */
171
+ triggerRuleGeneration(): Promise<void>;
172
+ }
173
+ export {};
174
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/repl/index.ts"],"names":[],"mappings":"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"}