@travisennis/acai 0.0.7 → 0.0.9

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 (486) hide show
  1. package/README.md +76 -27
  2. package/dist/agent/index.d.ts +21 -25
  3. package/dist/agent/index.d.ts.map +1 -1
  4. package/dist/agent/index.js +145 -103
  5. package/dist/cli.d.ts +2 -2
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +23 -17
  8. package/dist/commands/add-directory/index.d.ts +3 -0
  9. package/dist/commands/add-directory/index.d.ts.map +1 -0
  10. package/dist/commands/{add-directory-command.js → add-directory/index.js} +6 -10
  11. package/dist/commands/add-directory/types.d.ts +6 -0
  12. package/dist/commands/add-directory/types.d.ts.map +1 -0
  13. package/dist/commands/add-directory/types.js +1 -0
  14. package/dist/commands/add-directory/utils.d.ts +3 -0
  15. package/dist/commands/add-directory/utils.d.ts.map +1 -0
  16. package/dist/commands/add-directory/utils.js +15 -0
  17. package/dist/commands/clear/index.d.ts +3 -0
  18. package/dist/commands/clear/index.d.ts.map +1 -0
  19. package/dist/commands/{clear-command.js → clear/index.js} +0 -2
  20. package/dist/commands/copy/index.d.ts +3 -0
  21. package/dist/commands/copy/index.d.ts.map +1 -0
  22. package/dist/commands/{copy-command.js → copy/index.js} +4 -26
  23. package/dist/commands/copy/types.d.ts +3 -0
  24. package/dist/commands/copy/types.d.ts.map +1 -0
  25. package/dist/commands/copy/types.js +1 -0
  26. package/dist/commands/copy/utils.d.ts +3 -0
  27. package/dist/commands/copy/utils.d.ts.map +1 -0
  28. package/dist/commands/copy/utils.js +22 -0
  29. package/dist/commands/{exit-command.d.ts → exit/index.d.ts} +4 -4
  30. package/dist/commands/exit/index.d.ts.map +1 -0
  31. package/dist/commands/exit/index.js +21 -0
  32. package/dist/commands/exit/types.d.ts +8 -0
  33. package/dist/commands/exit/types.d.ts.map +1 -0
  34. package/dist/commands/exit/types.js +1 -0
  35. package/dist/commands/exit/utils.d.ts +2 -0
  36. package/dist/commands/exit/utils.d.ts.map +1 -0
  37. package/dist/commands/exit/utils.js +13 -0
  38. package/dist/commands/generate-rules/index.d.ts +3 -0
  39. package/dist/commands/generate-rules/index.d.ts.map +1 -0
  40. package/dist/commands/{generate-rules-command.js → generate-rules/index.js} +57 -96
  41. package/dist/commands/generate-rules/utils.d.ts +5 -0
  42. package/dist/commands/generate-rules/utils.d.ts.map +1 -0
  43. package/dist/commands/generate-rules/utils.js +25 -0
  44. package/dist/commands/handoff/index.d.ts +3 -0
  45. package/dist/commands/handoff/index.d.ts.map +1 -0
  46. package/dist/commands/handoff/index.js +97 -0
  47. package/dist/commands/handoff/utils.d.ts +4 -0
  48. package/dist/commands/handoff/utils.d.ts.map +1 -0
  49. package/dist/commands/{handoff-command.js → handoff/utils.js} +24 -92
  50. package/dist/commands/health/index.d.ts +3 -0
  51. package/dist/commands/health/index.d.ts.map +1 -0
  52. package/dist/commands/health/index.js +56 -0
  53. package/dist/commands/health/utils.d.ts +15 -0
  54. package/dist/commands/health/utils.d.ts.map +1 -0
  55. package/dist/commands/health/utils.js +52 -0
  56. package/dist/commands/{help-command.d.ts → help/index.d.ts} +2 -2
  57. package/dist/commands/help/index.d.ts.map +1 -0
  58. package/dist/commands/{help-command.js → help/index.js} +1 -1
  59. package/dist/commands/history/index.d.ts +3 -0
  60. package/dist/commands/history/index.d.ts.map +1 -0
  61. package/dist/commands/{history-command.js → history/index.js} +16 -100
  62. package/dist/commands/history/types.d.ts +11 -0
  63. package/dist/commands/history/types.d.ts.map +1 -0
  64. package/dist/commands/history/types.js +1 -0
  65. package/dist/commands/history/utils.d.ts +4 -0
  66. package/dist/commands/history/utils.d.ts.map +1 -0
  67. package/dist/commands/history/utils.js +86 -0
  68. package/dist/commands/init/index.d.ts +3 -0
  69. package/dist/commands/init/index.d.ts.map +1 -0
  70. package/dist/commands/{init-command.js → init/index.js} +16 -7
  71. package/dist/commands/init-project/index.d.ts +3 -0
  72. package/dist/commands/init-project/index.d.ts.map +1 -0
  73. package/dist/commands/init-project/index.js +51 -0
  74. package/dist/commands/init-project/utils.d.ts +9 -0
  75. package/dist/commands/init-project/utils.d.ts.map +1 -0
  76. package/dist/commands/init-project/utils.js +43 -0
  77. package/dist/commands/list-directories/index.d.ts +3 -0
  78. package/dist/commands/list-directories/index.d.ts.map +1 -0
  79. package/dist/commands/{list-directories-command.js → list-directories/index.js} +1 -1
  80. package/dist/commands/list-tools/index.d.ts +3 -0
  81. package/dist/commands/list-tools/index.d.ts.map +1 -0
  82. package/dist/commands/{list-tools-command.js → list-tools/index.js} +4 -16
  83. package/dist/commands/manager.d.ts +2 -2
  84. package/dist/commands/manager.d.ts.map +1 -1
  85. package/dist/commands/manager.js +35 -43
  86. package/dist/commands/model/index.d.ts +3 -0
  87. package/dist/commands/model/index.d.ts.map +1 -0
  88. package/dist/commands/{model-command.js → model/index.js} +15 -52
  89. package/dist/commands/model/utils.d.ts +3 -0
  90. package/dist/commands/model/utils.d.ts.map +1 -0
  91. package/dist/commands/model/utils.js +5 -0
  92. package/dist/commands/{paste-command.d.ts → paste/index.d.ts} +2 -2
  93. package/dist/commands/paste/index.d.ts.map +1 -0
  94. package/dist/commands/{paste-command.js → paste/index.js} +6 -111
  95. package/dist/commands/paste/utils.d.ts +5 -0
  96. package/dist/commands/paste/utils.d.ts.map +1 -0
  97. package/dist/commands/paste/utils.js +86 -0
  98. package/dist/commands/pickup/index.d.ts +3 -0
  99. package/dist/commands/pickup/index.d.ts.map +1 -0
  100. package/dist/commands/pickup/index.js +138 -0
  101. package/dist/commands/pickup/types.d.ts +6 -0
  102. package/dist/commands/pickup/types.d.ts.map +1 -0
  103. package/dist/commands/pickup/types.js +1 -0
  104. package/dist/commands/pickup/utils.d.ts +7 -0
  105. package/dist/commands/pickup/utils.d.ts.map +1 -0
  106. package/dist/commands/pickup/utils.js +56 -0
  107. package/dist/commands/prompt/index.d.ts +5 -0
  108. package/dist/commands/prompt/index.d.ts.map +1 -0
  109. package/dist/commands/prompt/index.js +122 -0
  110. package/dist/commands/prompt/types.d.ts +15 -0
  111. package/dist/commands/prompt/types.d.ts.map +1 -0
  112. package/dist/commands/prompt/types.js +1 -0
  113. package/dist/commands/prompt/utils.d.ts +12 -0
  114. package/dist/commands/prompt/utils.d.ts.map +1 -0
  115. package/dist/commands/prompt/utils.js +107 -0
  116. package/dist/commands/remove-directory/index.d.ts +3 -0
  117. package/dist/commands/remove-directory/index.d.ts.map +1 -0
  118. package/dist/commands/{remove-directory-command.js → remove-directory/index.js} +2 -2
  119. package/dist/commands/reset/index.d.ts +3 -0
  120. package/dist/commands/reset/index.d.ts.map +1 -0
  121. package/dist/commands/{reset-command.js → reset/index.js} +7 -2
  122. package/dist/commands/reset/types.d.ts +1 -0
  123. package/dist/commands/reset/types.d.ts.map +1 -0
  124. package/dist/commands/reset/types.js +3 -0
  125. package/dist/commands/resources/index.d.ts +3 -0
  126. package/dist/commands/resources/index.d.ts.map +1 -0
  127. package/dist/commands/resources/index.js +84 -0
  128. package/dist/commands/review/index.d.ts +3 -0
  129. package/dist/commands/review/index.d.ts.map +1 -0
  130. package/dist/commands/review/index.js +126 -0
  131. package/dist/commands/review/types.d.ts +12 -0
  132. package/dist/commands/review/types.d.ts.map +1 -0
  133. package/dist/commands/review/types.js +1 -0
  134. package/dist/commands/review/utils.d.ts +4 -0
  135. package/dist/commands/review/utils.d.ts.map +1 -0
  136. package/dist/commands/review/utils.js +87 -0
  137. package/dist/commands/save/index.d.ts +3 -0
  138. package/dist/commands/save/index.d.ts.map +1 -0
  139. package/dist/commands/{save-command.js → save/index.js} +3 -3
  140. package/dist/commands/session/index.d.ts +3 -0
  141. package/dist/commands/session/index.d.ts.map +1 -0
  142. package/dist/commands/session/index.js +230 -0
  143. package/dist/commands/session/types.d.ts +20 -0
  144. package/dist/commands/session/types.d.ts.map +1 -0
  145. package/dist/commands/session/types.js +7 -0
  146. package/dist/commands/share/html-renderer.d.ts +25 -0
  147. package/dist/commands/share/html-renderer.d.ts.map +1 -0
  148. package/dist/commands/share/html-renderer.js +384 -0
  149. package/dist/commands/share/index.d.ts +3 -0
  150. package/dist/commands/share/index.d.ts.map +1 -0
  151. package/dist/commands/share/index.js +122 -0
  152. package/dist/commands/shell/index.d.ts +3 -0
  153. package/dist/commands/shell/index.d.ts.map +1 -0
  154. package/dist/commands/{shell-command.js → shell/index.js} +3 -3
  155. package/dist/commands/types.d.ts +2 -2
  156. package/dist/commands/types.d.ts.map +1 -1
  157. package/dist/config.d.ts +25 -7
  158. package/dist/config.d.ts.map +1 -1
  159. package/dist/config.js +45 -20
  160. package/dist/dedent.d.ts.map +1 -1
  161. package/dist/dedent.js +7 -7
  162. package/dist/execution/index.d.ts +1 -0
  163. package/dist/execution/index.d.ts.map +1 -1
  164. package/dist/execution/index.js +60 -64
  165. package/dist/formatting.d.ts +27 -0
  166. package/dist/formatting.d.ts.map +1 -1
  167. package/dist/formatting.js +40 -0
  168. package/dist/index.d.ts.map +1 -1
  169. package/dist/index.js +194 -95
  170. package/dist/logger.d.ts.map +1 -1
  171. package/dist/logger.js +4 -11
  172. package/dist/mentions.d.ts.map +1 -1
  173. package/dist/mentions.js +3 -53
  174. package/dist/middleware/audit-message.d.ts +2 -2
  175. package/dist/middleware/audit-message.d.ts.map +1 -1
  176. package/dist/middleware/audit-message.js +40 -2
  177. package/dist/middleware/cache.d.ts +2 -2
  178. package/dist/middleware/cache.d.ts.map +1 -1
  179. package/dist/middleware/cache.js +111 -27
  180. package/dist/middleware/rate-limit.d.ts +2 -2
  181. package/dist/middleware/rate-limit.d.ts.map +1 -1
  182. package/dist/middleware/rate-limit.js +1 -0
  183. package/dist/models/ai-config.d.ts.map +1 -1
  184. package/dist/models/ai-config.js +46 -29
  185. package/dist/models/anthropic-provider.d.ts +14 -13
  186. package/dist/models/anthropic-provider.d.ts.map +1 -1
  187. package/dist/models/deepseek-provider.d.ts +9 -8
  188. package/dist/models/deepseek-provider.d.ts.map +1 -1
  189. package/dist/models/google-provider.d.ts +10 -9
  190. package/dist/models/google-provider.d.ts.map +1 -1
  191. package/dist/models/groq-provider.d.ts +8 -7
  192. package/dist/models/groq-provider.d.ts.map +1 -1
  193. package/dist/models/manager.d.ts +7 -4
  194. package/dist/models/manager.d.ts.map +1 -1
  195. package/dist/models/manager.js +5 -25
  196. package/dist/models/openai-provider.d.ts +14 -10
  197. package/dist/models/openai-provider.d.ts.map +1 -1
  198. package/dist/models/openai-provider.js +39 -0
  199. package/dist/models/opencode-zen-provider.d.ts +24 -0
  200. package/dist/models/opencode-zen-provider.d.ts.map +1 -0
  201. package/dist/models/opencode-zen-provider.js +94 -0
  202. package/dist/models/openrouter-provider.d.ts +35 -29
  203. package/dist/models/openrouter-provider.d.ts.map +1 -1
  204. package/dist/models/openrouter-provider.js +108 -80
  205. package/dist/models/providers.d.ts +4 -4
  206. package/dist/models/providers.d.ts.map +1 -1
  207. package/dist/models/providers.js +7 -1
  208. package/dist/models/xai-provider.d.ts +9 -8
  209. package/dist/models/xai-provider.d.ts.map +1 -1
  210. package/dist/prompts/manager.d.ts +1 -1
  211. package/dist/prompts/manager.d.ts.map +1 -1
  212. package/dist/prompts/manager.js +1 -1
  213. package/dist/prompts.d.ts +12 -2
  214. package/dist/prompts.d.ts.map +1 -1
  215. package/dist/prompts.js +74 -411
  216. package/dist/repl/project-status.d.ts +19 -0
  217. package/dist/repl/project-status.d.ts.map +1 -0
  218. package/dist/repl/project-status.js +78 -0
  219. package/dist/repl-new.d.ts +18 -4
  220. package/dist/repl-new.d.ts.map +1 -1
  221. package/dist/repl-new.js +256 -43
  222. package/dist/{messages.d.ts → sessions/manager.d.ts} +10 -4
  223. package/dist/sessions/manager.d.ts.map +1 -0
  224. package/dist/{messages.js → sessions/manager.js} +62 -14
  225. package/dist/skills.d.ts +0 -4
  226. package/dist/skills.d.ts.map +1 -1
  227. package/dist/skills.js +100 -59
  228. package/dist/stdin.d.ts +9 -0
  229. package/dist/stdin.d.ts.map +1 -0
  230. package/dist/stdin.js +26 -0
  231. package/dist/terminal/control.d.ts +1 -0
  232. package/dist/terminal/control.d.ts.map +1 -1
  233. package/dist/terminal/control.js +29 -6
  234. package/dist/terminal/formatting.d.ts +1 -2
  235. package/dist/terminal/formatting.d.ts.map +1 -1
  236. package/dist/terminal/formatting.js +1 -2
  237. package/dist/terminal/keys.d.ts +211 -0
  238. package/dist/terminal/keys.d.ts.map +1 -0
  239. package/dist/terminal/keys.js +546 -0
  240. package/dist/terminal/segmenter.d.ts +6 -0
  241. package/dist/terminal/segmenter.d.ts.map +1 -0
  242. package/dist/terminal/segmenter.js +11 -0
  243. package/dist/terminal/select-prompt.d.ts.map +1 -1
  244. package/dist/terminal/select-prompt.js +9 -21
  245. package/dist/terminal/string-width.d.ts.map +1 -1
  246. package/dist/terminal/string-width.js +40 -21
  247. package/dist/terminal/strip-ansi.d.ts.map +1 -1
  248. package/dist/terminal/strip-ansi.js +9 -15
  249. package/dist/tokens/tracker.d.ts.map +1 -1
  250. package/dist/tokens/tracker.js +58 -16
  251. package/dist/tools/bash.d.ts +9 -11
  252. package/dist/tools/bash.d.ts.map +1 -1
  253. package/dist/tools/bash.js +104 -123
  254. package/dist/tools/directory-tree.d.ts +9 -7
  255. package/dist/tools/directory-tree.d.ts.map +1 -1
  256. package/dist/tools/directory-tree.js +89 -70
  257. package/dist/tools/dynamic-tool-loader.d.ts +22 -4
  258. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  259. package/dist/tools/dynamic-tool-loader.js +39 -44
  260. package/dist/tools/edit-file.d.ts +6 -16
  261. package/dist/tools/edit-file.d.ts.map +1 -1
  262. package/dist/tools/edit-file.js +19 -76
  263. package/dist/tools/glob.d.ts +15 -16
  264. package/dist/tools/glob.d.ts.map +1 -1
  265. package/dist/tools/glob.js +77 -119
  266. package/dist/tools/grep.d.ts +19 -22
  267. package/dist/tools/grep.d.ts.map +1 -1
  268. package/dist/tools/grep.js +61 -108
  269. package/dist/tools/index.d.ts +200 -179
  270. package/dist/tools/index.d.ts.map +1 -1
  271. package/dist/tools/index.js +17 -315
  272. package/dist/tools/ls.d.ts +26 -0
  273. package/dist/tools/ls.d.ts.map +1 -0
  274. package/dist/tools/ls.js +80 -0
  275. package/dist/tools/read-file.d.ts +15 -15
  276. package/dist/tools/read-file.d.ts.map +1 -1
  277. package/dist/tools/read-file.js +49 -82
  278. package/dist/tools/save-file.d.ts +4 -4
  279. package/dist/tools/save-file.d.ts.map +1 -1
  280. package/dist/tools/save-file.js +37 -66
  281. package/dist/tools/think.d.ts +4 -4
  282. package/dist/tools/think.d.ts.map +1 -1
  283. package/dist/tools/think.js +9 -38
  284. package/dist/tools/types.d.ts +5 -25
  285. package/dist/tools/types.d.ts.map +1 -1
  286. package/dist/tools/types.js +0 -9
  287. package/dist/tui/autocomplete/attachment-provider.d.ts +18 -0
  288. package/dist/tui/autocomplete/attachment-provider.d.ts.map +1 -0
  289. package/dist/tui/autocomplete/attachment-provider.js +159 -0
  290. package/dist/tui/autocomplete/base-provider.d.ts +17 -0
  291. package/dist/tui/autocomplete/base-provider.d.ts.map +1 -0
  292. package/dist/tui/autocomplete/base-provider.js +1 -0
  293. package/dist/tui/autocomplete/combined-provider.d.ts +20 -0
  294. package/dist/tui/autocomplete/combined-provider.d.ts.map +1 -0
  295. package/dist/tui/autocomplete/combined-provider.js +61 -0
  296. package/dist/tui/autocomplete/command-provider.d.ts +20 -0
  297. package/dist/tui/autocomplete/command-provider.d.ts.map +1 -0
  298. package/dist/tui/autocomplete/command-provider.js +90 -0
  299. package/dist/tui/autocomplete/file-search-provider.d.ts +16 -0
  300. package/dist/tui/autocomplete/file-search-provider.d.ts.map +1 -0
  301. package/dist/tui/autocomplete/file-search-provider.js +123 -0
  302. package/dist/tui/autocomplete/path-provider.d.ts +21 -0
  303. package/dist/tui/autocomplete/path-provider.d.ts.map +1 -0
  304. package/dist/tui/autocomplete/path-provider.js +164 -0
  305. package/dist/tui/autocomplete/utils.d.ts +16 -0
  306. package/dist/tui/autocomplete/utils.d.ts.map +1 -0
  307. package/dist/tui/autocomplete/utils.js +137 -0
  308. package/dist/tui/autocomplete.d.ts +12 -43
  309. package/dist/tui/autocomplete.d.ts.map +1 -1
  310. package/dist/tui/autocomplete.js +20 -465
  311. package/dist/tui/components/box.d.ts.map +1 -1
  312. package/dist/tui/components/box.js +16 -10
  313. package/dist/tui/components/editor.d.ts +6 -2
  314. package/dist/tui/components/editor.d.ts.map +1 -1
  315. package/dist/tui/components/editor.js +166 -107
  316. package/dist/tui/components/footer.d.ts +20 -7
  317. package/dist/tui/components/footer.d.ts.map +1 -1
  318. package/dist/tui/components/footer.js +89 -196
  319. package/dist/tui/components/input.d.ts.map +1 -1
  320. package/dist/tui/components/input.js +8 -7
  321. package/dist/tui/components/loader.d.ts +2 -1
  322. package/dist/tui/components/loader.d.ts.map +1 -1
  323. package/dist/tui/components/loader.js +7 -2
  324. package/dist/tui/components/markdown.d.ts +5 -4
  325. package/dist/tui/components/markdown.d.ts.map +1 -1
  326. package/dist/tui/components/markdown.js +51 -40
  327. package/dist/tui/components/modal.d.ts.map +1 -1
  328. package/dist/tui/components/modal.js +9 -8
  329. package/dist/tui/components/notification.d.ts +28 -0
  330. package/dist/tui/components/notification.d.ts.map +1 -0
  331. package/dist/tui/components/notification.js +64 -0
  332. package/dist/tui/components/progress-bar.d.ts.map +1 -1
  333. package/dist/tui/components/progress-bar.js +3 -15
  334. package/dist/tui/components/select-list.d.ts +0 -15
  335. package/dist/tui/components/select-list.d.ts.map +1 -1
  336. package/dist/tui/components/select-list.js +5 -28
  337. package/dist/tui/components/tool-execution.d.ts +3 -6
  338. package/dist/tui/components/tool-execution.d.ts.map +1 -1
  339. package/dist/tui/components/tool-execution.js +26 -38
  340. package/dist/tui/components/welcome.d.ts +8 -1
  341. package/dist/tui/components/welcome.d.ts.map +1 -1
  342. package/dist/tui/components/welcome.js +45 -6
  343. package/dist/tui/editor-launcher.d.ts +13 -0
  344. package/dist/tui/editor-launcher.d.ts.map +1 -0
  345. package/dist/tui/editor-launcher.js +39 -0
  346. package/dist/tui/index.d.ts +7 -3
  347. package/dist/tui/index.d.ts.map +1 -1
  348. package/dist/tui/index.js +3 -2
  349. package/dist/tui/terminal.d.ts +29 -2
  350. package/dist/tui/terminal.d.ts.map +1 -1
  351. package/dist/tui/terminal.js +153 -28
  352. package/dist/tui/tui.d.ts +2 -0
  353. package/dist/tui/tui.d.ts.map +1 -1
  354. package/dist/tui/tui.js +39 -29
  355. package/dist/tui/utils.d.ts.map +1 -1
  356. package/dist/tui/utils.js +2 -3
  357. package/dist/utils/filesystem/security.d.ts.map +1 -1
  358. package/dist/utils/filesystem/security.js +4 -1
  359. package/dist/utils/yaml.d.ts +11 -0
  360. package/dist/utils/yaml.d.ts.map +1 -0
  361. package/dist/utils/yaml.js +207 -0
  362. package/dist/utils/zod.d.ts +1 -0
  363. package/dist/utils/zod.d.ts.map +1 -1
  364. package/dist/utils/zod.js +17 -0
  365. package/package.json +31 -29
  366. package/bin/acai-wrapper.js +0 -26
  367. package/dist/api/exa/index.d.ts +0 -177
  368. package/dist/api/exa/index.d.ts.map +0 -1
  369. package/dist/api/exa/index.js +0 -439
  370. package/dist/commands/add-directory-command.d.ts +0 -3
  371. package/dist/commands/add-directory-command.d.ts.map +0 -1
  372. package/dist/commands/application-log-command.d.ts +0 -3
  373. package/dist/commands/application-log-command.d.ts.map +0 -1
  374. package/dist/commands/application-log-command.js +0 -43
  375. package/dist/commands/clear-command.d.ts +0 -3
  376. package/dist/commands/clear-command.d.ts.map +0 -1
  377. package/dist/commands/compact-command.d.ts +0 -3
  378. package/dist/commands/compact-command.d.ts.map +0 -1
  379. package/dist/commands/compact-command.js +0 -55
  380. package/dist/commands/context-command.d.ts +0 -3
  381. package/dist/commands/context-command.d.ts.map +0 -1
  382. package/dist/commands/context-command.js +0 -124
  383. package/dist/commands/copy-command.d.ts +0 -3
  384. package/dist/commands/copy-command.d.ts.map +0 -1
  385. package/dist/commands/edit-command.d.ts +0 -3
  386. package/dist/commands/edit-command.d.ts.map +0 -1
  387. package/dist/commands/edit-command.js +0 -42
  388. package/dist/commands/edit-prompt-command.d.ts +0 -3
  389. package/dist/commands/edit-prompt-command.d.ts.map +0 -1
  390. package/dist/commands/edit-prompt-command.js +0 -36
  391. package/dist/commands/exit-command.d.ts.map +0 -1
  392. package/dist/commands/exit-command.js +0 -30
  393. package/dist/commands/files-command.d.ts +0 -3
  394. package/dist/commands/files-command.d.ts.map +0 -1
  395. package/dist/commands/files-command.js +0 -68
  396. package/dist/commands/generate-rules-command.d.ts +0 -3
  397. package/dist/commands/generate-rules-command.d.ts.map +0 -1
  398. package/dist/commands/handoff-command.d.ts +0 -3
  399. package/dist/commands/handoff-command.d.ts.map +0 -1
  400. package/dist/commands/health-command.d.ts +0 -4
  401. package/dist/commands/health-command.d.ts.map +0 -1
  402. package/dist/commands/health-command.js +0 -118
  403. package/dist/commands/help-command.d.ts.map +0 -1
  404. package/dist/commands/history-command.d.ts +0 -3
  405. package/dist/commands/history-command.d.ts.map +0 -1
  406. package/dist/commands/init-command.d.ts +0 -3
  407. package/dist/commands/init-command.d.ts.map +0 -1
  408. package/dist/commands/last-log-command.d.ts +0 -3
  409. package/dist/commands/last-log-command.d.ts.map +0 -1
  410. package/dist/commands/last-log-command.js +0 -71
  411. package/dist/commands/list-directories-command.d.ts +0 -3
  412. package/dist/commands/list-directories-command.d.ts.map +0 -1
  413. package/dist/commands/list-tools-command.d.ts +0 -3
  414. package/dist/commands/list-tools-command.d.ts.map +0 -1
  415. package/dist/commands/model-command.d.ts +0 -3
  416. package/dist/commands/model-command.d.ts.map +0 -1
  417. package/dist/commands/paste-command.d.ts.map +0 -1
  418. package/dist/commands/pickup-command.d.ts +0 -3
  419. package/dist/commands/pickup-command.d.ts.map +0 -1
  420. package/dist/commands/pickup-command.js +0 -109
  421. package/dist/commands/prompt-command.d.ts +0 -21
  422. package/dist/commands/prompt-command.d.ts.map +0 -1
  423. package/dist/commands/prompt-command.js +0 -258
  424. package/dist/commands/remove-directory-command.d.ts +0 -3
  425. package/dist/commands/remove-directory-command.d.ts.map +0 -1
  426. package/dist/commands/reset-command.d.ts +0 -3
  427. package/dist/commands/reset-command.d.ts.map +0 -1
  428. package/dist/commands/rules-command.d.ts +0 -3
  429. package/dist/commands/rules-command.d.ts.map +0 -1
  430. package/dist/commands/rules-command.js +0 -73
  431. package/dist/commands/save-command.d.ts +0 -3
  432. package/dist/commands/save-command.d.ts.map +0 -1
  433. package/dist/commands/shell-command.d.ts +0 -3
  434. package/dist/commands/shell-command.d.ts.map +0 -1
  435. package/dist/commands/usage-command.d.ts +0 -3
  436. package/dist/commands/usage-command.d.ts.map +0 -1
  437. package/dist/commands/usage-command.js +0 -31
  438. package/dist/messages.d.ts.map +0 -1
  439. package/dist/repl/project-status-line.d.ts +0 -3
  440. package/dist/repl/project-status-line.d.ts.map +0 -1
  441. package/dist/repl/project-status-line.js +0 -61
  442. package/dist/repl/tool-call-repair.d.ts +0 -4
  443. package/dist/repl/tool-call-repair.d.ts.map +0 -1
  444. package/dist/repl/tool-call-repair.js +0 -54
  445. package/dist/terminal/markdown.d.ts +0 -2
  446. package/dist/terminal/markdown.d.ts.map +0 -1
  447. package/dist/terminal/markdown.js +0 -120
  448. package/dist/tokens/threshold.d.ts +0 -20
  449. package/dist/tokens/threshold.d.ts.map +0 -1
  450. package/dist/tokens/threshold.js +0 -67
  451. package/dist/tools/advanced-edit-file.d.ts +0 -69
  452. package/dist/tools/advanced-edit-file.d.ts.map +0 -1
  453. package/dist/tools/advanced-edit-file.js +0 -285
  454. package/dist/tools/agent.d.ts +0 -29
  455. package/dist/tools/agent.d.ts.map +0 -1
  456. package/dist/tools/agent.js +0 -117
  457. package/dist/tools/batch.d.ts +0 -34
  458. package/dist/tools/batch.d.ts.map +0 -1
  459. package/dist/tools/batch.js +0 -174
  460. package/dist/tools/code-interpreter.d.ts +0 -25
  461. package/dist/tools/code-interpreter.d.ts.map +0 -1
  462. package/dist/tools/code-interpreter.js +0 -183
  463. package/dist/tools/delete-file.d.ts +0 -24
  464. package/dist/tools/delete-file.d.ts.map +0 -1
  465. package/dist/tools/delete-file.js +0 -77
  466. package/dist/tools/dynamic-tool-parser.d.ts +0 -21
  467. package/dist/tools/dynamic-tool-parser.d.ts.map +0 -1
  468. package/dist/tools/dynamic-tool-parser.js +0 -22
  469. package/dist/tools/llm-edit-fixer.d.ts +0 -24
  470. package/dist/tools/llm-edit-fixer.d.ts.map +0 -1
  471. package/dist/tools/llm-edit-fixer.js +0 -136
  472. package/dist/tools/move-file.d.ts +0 -26
  473. package/dist/tools/move-file.d.ts.map +0 -1
  474. package/dist/tools/move-file.js +0 -65
  475. package/dist/tools/read-multiple-files.d.ts +0 -26
  476. package/dist/tools/read-multiple-files.d.ts.map +0 -1
  477. package/dist/tools/read-multiple-files.js +0 -196
  478. package/dist/tools/web-fetch.d.ts +0 -56
  479. package/dist/tools/web-fetch.d.ts.map +0 -1
  480. package/dist/tools/web-fetch.js +0 -247
  481. package/dist/tools/web-search.d.ts +0 -23
  482. package/dist/tools/web-search.d.ts.map +0 -1
  483. package/dist/tools/web-search.js +0 -148
  484. package/dist/tui/components/prompt-status.d.ts +0 -17
  485. package/dist/tui/components/prompt-status.d.ts.map +0 -1
  486. package/dist/tui/components/prompt-status.js +0 -26
@@ -1,29 +1,7 @@
1
1
  import Clipboard from "@crosscopy/clipboard";
2
- import style from "../terminal/style.js";
3
- import { Spacer, Text } from "../tui/index.js";
4
- function extractLastAssistantText(messages) {
5
- for (let i = messages.length - 1; i >= 0; i--) {
6
- const msg = messages[i];
7
- if (!msg)
8
- continue;
9
- if (msg.role !== "assistant")
10
- continue;
11
- if (!("content" in msg) || !Array.isArray(msg.content))
12
- continue;
13
- // Find last text part
14
- for (let j = msg.content.length - 1; j >= 0; j--) {
15
- const part = msg.content[j];
16
- if (part &&
17
- part.type === "text" &&
18
- typeof part.text === "string") {
19
- const text = part.text;
20
- if (text.trim().length > 0)
21
- return text;
22
- }
23
- }
24
- }
25
- return null;
26
- }
2
+ import style from "../../terminal/style.js";
3
+ import { Spacer, Text } from "../../tui/index.js";
4
+ import { extractLastAssistantText } from "./utils.js";
27
5
  export function copyCommand(options) {
28
6
  return {
29
7
  command: "/copy",
@@ -32,7 +10,7 @@ export function copyCommand(options) {
32
10
  return [];
33
11
  },
34
12
  async handle(_args, { tui, container, editor, }) {
35
- const { messageHistory } = options;
13
+ const { sessionManager: messageHistory } = options;
36
14
  const history = messageHistory.get();
37
15
  container.addChild(new Spacer(1));
38
16
  const lastText = extractLastAssistantText(history);
@@ -0,0 +1,3 @@
1
+ import type { ModelMessage, TextPart } from "ai";
2
+ export type { ModelMessage, TextPart };
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/copy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEjD,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { ModelMessage } from "ai";
2
+ export declare function extractLastAssistantText(messages: ModelMessage[]): string | null;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/copy/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,IAAI,CAAC;AAEjD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,YAAY,EAAE,GACvB,MAAM,GAAG,IAAI,CAoBf"}
@@ -0,0 +1,22 @@
1
+ export function extractLastAssistantText(messages) {
2
+ for (let i = messages.length - 1; i >= 0; i--) {
3
+ const msg = messages[i];
4
+ if (!msg)
5
+ continue;
6
+ if (msg.role !== "assistant")
7
+ continue;
8
+ if (!("content" in msg) || !Array.isArray(msg.content))
9
+ continue;
10
+ for (let j = msg.content.length - 1; j >= 0; j--) {
11
+ const part = msg.content[j];
12
+ if (part != null &&
13
+ part.type === "text" &&
14
+ typeof part.text === "string") {
15
+ const text = part.text;
16
+ if (text.trim().length > 0)
17
+ return text;
18
+ }
19
+ }
20
+ }
21
+ return null;
22
+ }
@@ -1,10 +1,10 @@
1
- import type { ReplCommand } from "./types.ts";
1
+ import type { ReplCommand } from "../types.ts";
2
2
  export interface ExitCommandOptions {
3
- messageHistory: {
3
+ sessionManager: {
4
4
  isEmpty: () => boolean;
5
5
  save: () => Promise<void>;
6
6
  };
7
7
  baseDir?: string | null;
8
8
  }
9
- export declare const exitCommand: ({ messageHistory, baseDir, }: ExitCommandOptions) => ReplCommand;
10
- //# sourceMappingURL=exit-command.d.ts.map
9
+ export declare const exitCommand: ({ sessionManager, baseDir, }: ExitCommandOptions) => ReplCommand;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/exit/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE;QACd,OAAO,EAAE,MAAM,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,GAAI,8BAGzB,kBAAkB,KAAG,WA2BvB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Text } from "../../tui/index.js";
2
+ import { clearTmpDirectory } from "./utils.js";
3
+ export const exitCommand = ({ sessionManager, baseDir, }) => {
4
+ return {
5
+ command: "/exit",
6
+ aliases: ["/bye", "/quit"],
7
+ description: "Exits and saves the chat history.",
8
+ getSubCommands: () => Promise.resolve([]),
9
+ async handle(_args, { tui, container, editor, }) {
10
+ if (!sessionManager.isEmpty()) {
11
+ await sessionManager.save();
12
+ }
13
+ // Clear the .tmp directory on exit
14
+ await clearTmpDirectory(baseDir);
15
+ container.addChild(new Text("Exiting...", 0, 1));
16
+ tui.requestRender();
17
+ editor.setText("");
18
+ return "break";
19
+ },
20
+ };
21
+ };
@@ -0,0 +1,8 @@
1
+ export interface ExitCommandOptions {
2
+ sessionManager: {
3
+ isEmpty: () => boolean;
4
+ save: () => Promise<void>;
5
+ };
6
+ baseDir?: string | null;
7
+ }
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/exit/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE;QACd,OAAO,EAAE,MAAM,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function clearTmpDirectory(baseDir?: string | null): Promise<void>;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/exit/utils.ts"],"names":[],"mappings":"AAIA,wBAAsB,iBAAiB,CACrC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,IAAI,CAAC,CAQf"}
@@ -0,0 +1,13 @@
1
+ import path from "node:path";
2
+ import { logger } from "../../logger.js";
3
+ import { clearDirectory } from "../../utils/filesystem/operations.js";
4
+ export async function clearTmpDirectory(baseDir) {
5
+ try {
6
+ const tmpDirPath = path.join(baseDir ?? process.cwd(), ".tmp");
7
+ await clearDirectory(tmpDirPath);
8
+ }
9
+ catch (error) {
10
+ // Log error but don't block exit
11
+ logger.error(error, "Failed to clear .tmp directory:");
12
+ }
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { CommandOptions, ReplCommand } from "../types.ts";
2
+ export declare const generateRulesCommand: ({ sessionManager: messageHistory, modelManager, tokenTracker, config, workspace, }: CommandOptions) => ReplCommand;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/generate-rules/index.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,eAAO,MAAM,oBAAoB,GAAI,oFAMlC,cAAc,KAAG,WA+HnB,CAAC"}
@@ -1,13 +1,12 @@
1
1
  import { generateText } from "ai";
2
- import { config } from "../config.js";
3
- import { logger } from "../logger.js"; // Import logger
4
- import { createUserMessage } from "../messages.js";
5
- import { systemPrompt } from "../prompts.js";
6
- import { getTerminalSize } from "../terminal/formatting.js";
7
- import style from "../terminal/style.js";
8
- import { Container, Input, Spacer, Text, } from "../tui/index.js";
9
- export const generateRulesCommand = ({ messageHistory, modelManager, tokenTracker, config, // This is the config module from CommandOptions
10
- workspace, }) => {
2
+ import { logger } from "../../logger.js";
3
+ import { systemPrompt } from "../../prompts.js";
4
+ import { createUserMessage } from "../../sessions/manager.js";
5
+ import { getTerminalSize, isArrowDown, isArrowUp, isEnter, isEscape, } from "../../terminal/control.js";
6
+ import style from "../../terminal/style.js";
7
+ import { Container, Input, Spacer, Text, } from "../../tui/index.js";
8
+ import { hideRuleSelector } from "./utils.js";
9
+ export const generateRulesCommand = ({ sessionManager: messageHistory, modelManager, tokenTracker, config, workspace, }) => {
11
10
  return {
12
11
  command: "/generate-rules",
13
12
  description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
@@ -29,15 +28,13 @@ workspace, }) => {
29
28
  config,
30
29
  workspace,
31
30
  });
32
- if (!newRules || newRules.length === 0) {
31
+ if (newRules == null || newRules.length === 0) {
33
32
  container.addChild(new Text(style.yellow("No new generalizable rules were identified."), 2, 0));
34
33
  tui.requestRender();
35
34
  editor.setText("");
36
35
  return "continue";
37
36
  }
38
- // Create rule selector for TUI mode
39
37
  const ruleSelector = new RuleSelectorComponent(newRules, async (selectedRules) => {
40
- // Handle rule selection
41
38
  if (selectedRules.length === 0) {
42
39
  container.addChild(new Text(style.yellow("No rules selected to save."), 2, 0));
43
40
  }
@@ -59,15 +56,12 @@ workspace, }) => {
59
56
  container.addChild(new Text(style.red(`Failed to save rules: ${error}`), 2, 0));
60
57
  }
61
58
  }
62
- // Hide selector and show editor again
63
59
  hideRuleSelector(inputContainer, editor, tui);
64
60
  tui.requestRender();
65
61
  }, () => {
66
- // Cancel selection - just hide selector
67
62
  hideRuleSelector(inputContainer, editor, tui);
68
63
  tui.requestRender();
69
64
  });
70
- // Replace editor with rule selector
71
65
  inputContainer.clear();
72
66
  inputContainer.addChild(ruleSelector);
73
67
  tui.setFocus(ruleSelector);
@@ -85,15 +79,55 @@ workspace, }) => {
85
79
  },
86
80
  };
87
81
  };
88
- // Modified System Prompt
89
- const system = async (configManager, workspace) => {
82
+ async function analyzeConversation({ modelManager, messages, tokenTracker, config: configManager, workspace, }) {
83
+ const learnedRules = await configManager.readCachedLearnedRulesFile();
84
+ messages.push(createUserMessage([
85
+ `Analyze this conversation based on the system instructions. Identify points where the user made significant corrections revealing general principles for agent improvement. Infer concise, broadly applicable rules (Always/Never) based *only* on these corrections.
86
+
87
+ **Key Requirements:**
88
+ - Focus on *generalizable* rules applicable to future, different tasks.
89
+ - Avoid rules tied to the specifics of *this* conversation.
90
+ - Ensure rules don't already exist in <existing-rules>.
91
+ - If no *new, general* rules can be inferred, return an empty list or response.
92
+ - Return *only* the Markdown list of rules, with no preamble or explanation.
93
+
94
+ <existing-rules>
95
+ ${learnedRules}
96
+ </existing-rules>`,
97
+ ]));
98
+ const systemPromptText = await createSystemPrompt(configManager, workspace);
99
+ const { text, usage } = await generateText({
100
+ model: modelManager.getModel("conversation-analyzer"),
101
+ maxOutputTokens: 8192,
102
+ system: systemPromptText,
103
+ messages: messages,
104
+ });
105
+ tokenTracker.trackUsage("conversation-analyzer", usage);
106
+ const potentialRulesText = text.trim();
107
+ if (!potentialRulesText || potentialRulesText.length === 0) {
108
+ return [];
109
+ }
110
+ const potentialRulesList = potentialRulesText
111
+ .split("\n")
112
+ .map((rule) => rule.trim())
113
+ .filter((rule) => rule.length > 0);
114
+ if (potentialRulesList.length === 0) {
115
+ return [];
116
+ }
117
+ const updatedRules = learnedRules.endsWith("\n") || learnedRules.length === 0
118
+ ? `${learnedRules}${potentialRulesList.join("\n")}`
119
+ : `${learnedRules}\n${potentialRulesList.join("\n")}`;
120
+ await configManager.writeCachedLearnedRulesFile(updatedRules);
121
+ return potentialRulesList;
122
+ }
123
+ async function createSystemPrompt(configManager, workspace) {
90
124
  const projectConfig = await configManager.getConfig();
91
- const sys = await systemPrompt({
92
- type: projectConfig.systemPromptType,
125
+ const sysResult = await systemPrompt({
93
126
  activeTools: projectConfig.tools.activeTools,
94
127
  includeRules: true,
95
128
  allowedDirs: workspace.allowedDirs,
96
129
  });
130
+ const sys = sysResult.prompt;
97
131
  return `You are an expert analyst reviewing conversations between a coding agent and a software engineer. Your goal is to identify instances where the engineer corrected the agent's approach or understanding in a way that reveals a *generalizable principle* for improving the agent's future behavior across *different* tasks.
98
132
 
99
133
  **Your Task:**
@@ -130,63 +164,7 @@ This is the original system prompt the agent operated under:
130
164
  <systemPrompt>
131
165
  ${sys}
132
166
  </systemPrompt>`;
133
- };
134
- async function analyzeConversation({ modelManager, messages, tokenTracker, config: configManager, workspace, }) {
135
- const learnedRules = await configManager.readCachedLearnedRulesFile();
136
- // Modified User Message within analyzeConversation
137
- messages.push(createUserMessage([
138
- `Analyze this conversation based on the system instructions. Identify points where the user made significant corrections revealing general principles for agent improvement. Infer concise, broadly applicable rules (Always/Never) based *only* on these corrections.
139
-
140
- **Key Requirements:**
141
- - Focus on *generalizable* rules applicable to future, different tasks.
142
- - Avoid rules tied to the specifics of *this* conversation.
143
- - Ensure rules don't already exist in <existing-rules>.
144
- - If no *new, general* rules can be inferred, return an empty list or response.
145
- - Return *only* the Markdown list of rules, with no preamble or explanation.
146
-
147
- <existing-rules>
148
- ${learnedRules}
149
- </existing-rules>`,
150
- ]));
151
- const { text, usage } = await generateText({
152
- model: modelManager.getModel("conversation-analyzer"),
153
- maxOutputTokens: 8192,
154
- system: await system(configManager, workspace),
155
- messages: messages,
156
- });
157
- tokenTracker.trackUsage("conversation-analyzer", usage);
158
- // Trim whitespace and check if the response is effectively empty or just whitespace
159
- const potentialRulesText = text.trim();
160
- // Basic check to prevent adding empty lines or just formatting
161
- if (!potentialRulesText || potentialRulesText.length === 0) {
162
- return []; // Return empty array if no valid rules generated
163
- }
164
- // Split into individual rules, filter out empty lines
165
- const potentialRulesList = potentialRulesText
166
- .split("\n")
167
- .map((rule) => rule.trim())
168
- .filter((rule) => rule.length > 0);
169
- if (potentialRulesList.length === 0) {
170
- return []; // Return empty array if splitting results in no rules
171
- }
172
- // Further validation could be added here (e.g., check if it starts with '- ', etc.)
173
- // before writing to the file.
174
- // Append only if there are non-empty potential rules
175
- const updatedRules = learnedRules.endsWith("\n") || learnedRules.length === 0
176
- ? `${learnedRules}${potentialRulesList.join("\n")}`
177
- : `${learnedRules}\n${potentialRulesList.join("\n")}`;
178
- await config.writeCachedLearnedRulesFile(updatedRules);
179
- return potentialRulesList; // Return the list of rules that were added
180
- }
181
- function hideRuleSelector(editorContainer, editor, tui) {
182
- // Replace selector with editor in the container
183
- editorContainer.clear();
184
- editorContainer.addChild(editor);
185
- tui.setFocus(editor);
186
167
  }
187
- /**
188
- * Component that renders a rule selector with search and multi-selection
189
- */
190
168
  class RuleSelectorComponent extends Container {
191
169
  searchInput;
192
170
  listContainer;
@@ -200,31 +178,23 @@ class RuleSelectorComponent extends Container {
200
178
  super();
201
179
  this.onSelectCallback = onSelect;
202
180
  this.onCancelCallback = onCancel;
203
- // Load all rules
204
181
  this.allRules = rules;
205
182
  this.filteredRules = rules;
206
183
  const { columns } = getTerminalSize();
207
- // Add top border
208
184
  this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
209
185
  this.addChild(new Spacer(1));
210
- // Create search input
211
186
  this.searchInput = new Input();
212
187
  this.searchInput.onSubmit = () => {
213
- // Enter on search input toggles selection of current item
214
188
  this.toggleSelection(this.selectedIndex);
215
189
  };
216
190
  this.addChild(this.searchInput);
217
191
  this.addChild(new Spacer(1));
218
- // Create list container
219
192
  this.listContainer = new Container();
220
193
  this.addChild(this.listContainer);
221
194
  this.addChild(new Spacer(1));
222
- // Add instructions
223
195
  this.addChild(new Text(style.dim("Space: toggle selection, Enter: confirm, Escape: cancel"), 0, 0));
224
196
  this.addChild(new Spacer(1));
225
- // Add bottom border
226
197
  this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
227
- // Initial render
228
198
  this.updateList();
229
199
  }
230
200
  filterRules(query) {
@@ -249,7 +219,6 @@ class RuleSelectorComponent extends Container {
249
219
  const maxVisible = 10;
250
220
  const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredRules.length - maxVisible));
251
221
  const endIndex = Math.min(startIndex + maxVisible, this.filteredRules.length);
252
- // Show visible slice of filtered rules
253
222
  for (let i = startIndex; i < endIndex; i++) {
254
223
  const rule = this.filteredRules[i];
255
224
  if (!rule)
@@ -270,40 +239,32 @@ class RuleSelectorComponent extends Container {
270
239
  }
271
240
  this.listContainer.addChild(new Text(line, 0, 0));
272
241
  }
273
- // Add scroll indicator if needed
274
242
  if (startIndex > 0 || endIndex < this.filteredRules.length) {
275
243
  const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredRules.length})`);
276
244
  this.listContainer.addChild(new Text(scrollInfo, 0, 0));
277
245
  }
278
- // Show "no results" if empty
279
246
  if (this.filteredRules.length === 0) {
280
247
  this.listContainer.addChild(new Text(style.gray(" No matching rules"), 0, 0));
281
248
  }
282
249
  }
283
250
  handleInput(keyData) {
284
- // Up arrow
285
- if (keyData === "\x1b[A") {
251
+ if (isArrowUp(keyData)) {
286
252
  this.selectedIndex = Math.max(0, this.selectedIndex - 1);
287
253
  this.updateList();
288
254
  }
289
- // Down arrow
290
- else if (keyData === "\x1b[B") {
255
+ else if (isArrowDown(keyData)) {
291
256
  this.selectedIndex = Math.min(this.filteredRules.length - 1, this.selectedIndex + 1);
292
257
  this.updateList();
293
258
  }
294
- // Space - toggle selection
295
259
  else if (keyData === " ") {
296
260
  this.toggleSelection(this.selectedIndex);
297
261
  }
298
- // Enter - confirm selection
299
- else if (keyData === "\r") {
262
+ else if (isEnter(keyData)) {
300
263
  this.handleConfirm();
301
264
  }
302
- // Escape
303
- else if (keyData === "\x1b") {
265
+ else if (isEscape(keyData)) {
304
266
  this.onCancelCallback();
305
267
  }
306
- // Pass everything else to search input
307
268
  else {
308
269
  this.searchInput.handleInput(keyData);
309
270
  this.filterRules(this.searchInput.getValue());
@@ -0,0 +1,5 @@
1
+ import type { Container, Editor, TUI } from "../../tui/index.ts";
2
+ export declare function hideRuleSelector(editorContainer: Container, editor: Editor, tui: TUI): void;
3
+ export declare function parseRulesText(text: string): string[];
4
+ export declare function formatRulesForStorage(existingRules: string, newRules: string[]): string;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/generate-rules/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAgB,gBAAgB,CAC9B,eAAe,EAAE,SAAS,EAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,GACP,IAAI,CAIN;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUrD;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAUR"}
@@ -0,0 +1,25 @@
1
+ export function hideRuleSelector(editorContainer, editor, tui) {
2
+ editorContainer.clear();
3
+ editorContainer.addChild(editor);
4
+ tui.setFocus(editor);
5
+ }
6
+ export function parseRulesText(text) {
7
+ const trimmed = text.trim();
8
+ if (!trimmed || trimmed.length === 0) {
9
+ return [];
10
+ }
11
+ return trimmed
12
+ .split("\n")
13
+ .map((rule) => rule.trim())
14
+ .filter((rule) => rule.length > 0);
15
+ }
16
+ export function formatRulesForStorage(existingRules, newRules) {
17
+ if (newRules.length === 0) {
18
+ return existingRules;
19
+ }
20
+ const rulesToAdd = newRules.join("\n");
21
+ if (existingRules.endsWith("\n") || existingRules.length === 0) {
22
+ return `${existingRules}${rulesToAdd}`;
23
+ }
24
+ return `${existingRules}\n${rulesToAdd}`;
25
+ }
@@ -0,0 +1,3 @@
1
+ import type { CommandOptions, ReplCommand } from "../types.ts";
2
+ export declare const handoffCommand: (options: CommandOptions) => ReplCommand;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/handoff/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WA2DxD,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import { generateText } from "ai";
3
+ import { AiConfig } from "../../models/ai-config.js";
4
+ import style from "../../terminal/style.js";
5
+ import { Spacer, Text } from "../../tui/index.js";
6
+ import { generateHandoffFilename, generateHandoffSlug, handoffPrompt, } from "./utils.js";
7
+ export const handoffCommand = (options) => {
8
+ return {
9
+ command: "/handoff",
10
+ description: "Creates a detailed handoff plan of the conversation for continuing the work in a new session. Usage: /handoff <the purpose of the handoff>",
11
+ getSubCommands: () => Promise.resolve([]),
12
+ async handle(args, { tui, container, editor, }) {
13
+ const purpose = args.join(" ").trim();
14
+ if (!purpose) {
15
+ container.addChild(new Text(style.red("Please provide a purpose for the handoff. Usage: /handoff <the purpose of the handoff>"), 1, 0));
16
+ tui.requestRender();
17
+ editor.setText("");
18
+ return "continue";
19
+ }
20
+ container.addChild(new Spacer(1));
21
+ container.addChild(new Text(`Creating handoff document for purpose: ${style.blue(purpose)}`, 1, 0));
22
+ tui.requestRender();
23
+ const filename = await createHandoffDocument(options, purpose);
24
+ container.addChild(new Text(style.green(`Handoff document created: ${filename}`), 2, 0));
25
+ container.addChild(new Text(`Use /pickup ${filename.replace(".md", "")} to continue this work.`, 3, 0));
26
+ tui.requestRender();
27
+ editor.setText("");
28
+ return "continue";
29
+ },
30
+ };
31
+ };
32
+ async function createHandoffDocument({ modelManager, tokenTracker, sessionManager: messageHistory, }, purpose) {
33
+ const app = "handoff-agent";
34
+ const model = modelManager.getModel(app);
35
+ const modelConfig = modelManager.getModelMetadata(app);
36
+ const messages = messageHistory.get();
37
+ const conversationText = messages
38
+ .map((msg) => {
39
+ let content = "";
40
+ if (Array.isArray(msg.content)) {
41
+ content = msg.content
42
+ .filter((part) => part.type === "text")
43
+ .map((part) => part.text)
44
+ .join("\n");
45
+ }
46
+ else if (typeof msg.content === "string") {
47
+ content = msg.content;
48
+ }
49
+ return `${msg.role}: ${content}`;
50
+ })
51
+ .filter((text) => text?.trim())
52
+ .join("\n\n");
53
+ const fullPrompt = `${handoffPrompt(purpose)}\n\n## Conversation History\n\n${conversationText}`;
54
+ const aiConfig = new AiConfig({
55
+ modelMetadata: modelConfig,
56
+ prompt: fullPrompt,
57
+ });
58
+ let result;
59
+ try {
60
+ result = await generateText({
61
+ model,
62
+ maxOutputTokens: aiConfig.maxOutputTokens(),
63
+ system: "You are a helpful AI assistant tasked with creating detailed handoff summaries for coding agents. Focus on technical accuracy and completeness so that another agent can seamlessly continue the work.",
64
+ prompt: fullPrompt,
65
+ temperature: aiConfig.temperature(),
66
+ topP: aiConfig.topP(),
67
+ providerOptions: aiConfig.providerOptions(),
68
+ });
69
+ }
70
+ catch (error) {
71
+ console.error(`Error generating handoff text: ${error}`);
72
+ throw new Error(`Failed to generate handoff summary: ${error.message}`);
73
+ }
74
+ const { text, usage } = result;
75
+ tokenTracker.trackUsage(app, usage);
76
+ if (!text || text.trim().length === 0) {
77
+ throw new Error("AI returned empty response");
78
+ }
79
+ const slug = generateHandoffSlug(purpose);
80
+ const filename = generateHandoffFilename(slug);
81
+ const handoffsDir = ".acai/handoffs";
82
+ const filepath = `${handoffsDir}/${filename}`;
83
+ const handoffDocument = `${text}
84
+
85
+ ---
86
+ *Generated on ${new Date().toISOString()} for purpose: ${purpose}*
87
+ *This handoff file can be used to continue the work using the /pickup command*`;
88
+ try {
89
+ await mkdir(handoffsDir, { recursive: true });
90
+ await writeFile(filepath, handoffDocument, "utf-8");
91
+ return filename;
92
+ }
93
+ catch (error) {
94
+ console.error(`Failed to save handoff file: ${error}`);
95
+ throw new Error(`Failed to save handoff file: ${error.message}`);
96
+ }
97
+ }
@@ -0,0 +1,4 @@
1
+ export declare const handoffPrompt: (purpose: string) => string;
2
+ export declare const generateHandoffSlug: (purpose: string, maxLength?: number) => string;
3
+ export declare const generateHandoffFilename: (slug: string) => string;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/handoff/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,MAqG/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,kBAAc,KACb,MAmBF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,MAItD,CAAC"}