@travisennis/acai 0.0.5 → 0.0.7

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 (421) hide show
  1. package/README.md +190 -19
  2. package/bin/acai-wrapper.js +26 -0
  3. package/dist/agent/index.d.ts +132 -0
  4. package/dist/agent/index.d.ts.map +1 -0
  5. package/dist/agent/index.js +434 -0
  6. package/dist/api/exa/index.js +1 -1
  7. package/dist/cli.d.ts +4 -1
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +67 -40
  10. package/dist/commands/add-directory-command.d.ts +3 -0
  11. package/dist/commands/add-directory-command.d.ts.map +1 -0
  12. package/dist/commands/add-directory-command.js +54 -0
  13. package/dist/commands/application-log-command.d.ts +1 -1
  14. package/dist/commands/application-log-command.d.ts.map +1 -1
  15. package/dist/commands/application-log-command.js +18 -20
  16. package/dist/commands/clear-command.d.ts +1 -1
  17. package/dist/commands/clear-command.d.ts.map +1 -1
  18. package/dist/commands/clear-command.js +7 -3
  19. package/dist/commands/compact-command.d.ts.map +1 -1
  20. package/dist/commands/compact-command.js +9 -5
  21. package/dist/commands/context-command.d.ts +3 -0
  22. package/dist/commands/context-command.d.ts.map +1 -0
  23. package/dist/commands/context-command.js +124 -0
  24. package/dist/commands/copy-command.d.ts.map +1 -1
  25. package/dist/commands/copy-command.js +14 -5
  26. package/dist/commands/edit-command.d.ts +1 -1
  27. package/dist/commands/edit-command.d.ts.map +1 -1
  28. package/dist/commands/edit-command.js +21 -34
  29. package/dist/commands/edit-prompt-command.d.ts +1 -1
  30. package/dist/commands/edit-prompt-command.d.ts.map +1 -1
  31. package/dist/commands/edit-prompt-command.js +18 -15
  32. package/dist/commands/exit-command.d.ts +1 -4
  33. package/dist/commands/exit-command.d.ts.map +1 -1
  34. package/dist/commands/exit-command.js +9 -5
  35. package/dist/commands/files-command.d.ts +1 -1
  36. package/dist/commands/files-command.d.ts.map +1 -1
  37. package/dist/commands/files-command.js +20 -16
  38. package/dist/commands/generate-rules-command.d.ts +1 -1
  39. package/dist/commands/generate-rules-command.d.ts.map +1 -1
  40. package/dist/commands/generate-rules-command.js +307 -39
  41. package/dist/commands/handoff-command.d.ts +3 -0
  42. package/dist/commands/handoff-command.d.ts.map +1 -0
  43. package/dist/commands/handoff-command.js +191 -0
  44. package/dist/commands/health-command.d.ts +1 -1
  45. package/dist/commands/health-command.d.ts.map +1 -1
  46. package/dist/commands/health-command.js +49 -27
  47. package/dist/commands/help-command.d.ts +1 -1
  48. package/dist/commands/help-command.d.ts.map +1 -1
  49. package/dist/commands/help-command.js +25 -5
  50. package/dist/commands/history-command.d.ts +3 -0
  51. package/dist/commands/history-command.d.ts.map +1 -0
  52. package/dist/commands/history-command.js +458 -0
  53. package/dist/commands/init-command.d.ts +1 -1
  54. package/dist/commands/init-command.d.ts.map +1 -1
  55. package/dist/commands/init-command.js +40 -22
  56. package/dist/commands/last-log-command.d.ts +1 -1
  57. package/dist/commands/last-log-command.d.ts.map +1 -1
  58. package/dist/commands/last-log-command.js +15 -15
  59. package/dist/commands/list-directories-command.d.ts +3 -0
  60. package/dist/commands/list-directories-command.d.ts.map +1 -0
  61. package/dist/commands/list-directories-command.js +35 -0
  62. package/dist/commands/list-tools-command.d.ts.map +1 -1
  63. package/dist/commands/list-tools-command.js +61 -21
  64. package/dist/commands/manager.d.ts +9 -4
  65. package/dist/commands/manager.d.ts.map +1 -1
  66. package/dist/commands/manager.js +64 -39
  67. package/dist/commands/model-command.d.ts.map +1 -1
  68. package/dist/commands/model-command.js +201 -66
  69. package/dist/commands/paste-command.d.ts +1 -1
  70. package/dist/commands/paste-command.d.ts.map +1 -1
  71. package/dist/commands/paste-command.js +23 -9
  72. package/dist/commands/pickup-command.d.ts +3 -0
  73. package/dist/commands/pickup-command.d.ts.map +1 -0
  74. package/dist/commands/pickup-command.js +109 -0
  75. package/dist/commands/prompt-command.d.ts +19 -1
  76. package/dist/commands/prompt-command.d.ts.map +1 -1
  77. package/dist/commands/prompt-command.js +191 -98
  78. package/dist/commands/remove-directory-command.d.ts +3 -0
  79. package/dist/commands/remove-directory-command.d.ts.map +1 -0
  80. package/dist/commands/remove-directory-command.js +55 -0
  81. package/dist/commands/reset-command.d.ts +1 -1
  82. package/dist/commands/reset-command.d.ts.map +1 -1
  83. package/dist/commands/reset-command.js +8 -5
  84. package/dist/commands/rules-command.d.ts +1 -1
  85. package/dist/commands/rules-command.d.ts.map +1 -1
  86. package/dist/commands/rules-command.js +25 -22
  87. package/dist/commands/save-command.d.ts +1 -1
  88. package/dist/commands/save-command.d.ts.map +1 -1
  89. package/dist/commands/save-command.js +8 -3
  90. package/dist/commands/shell-command.d.ts.map +1 -1
  91. package/dist/commands/shell-command.js +45 -24
  92. package/dist/commands/types.d.ts +9 -7
  93. package/dist/commands/types.d.ts.map +1 -1
  94. package/dist/commands/usage-command.d.ts +1 -1
  95. package/dist/commands/usage-command.d.ts.map +1 -1
  96. package/dist/commands/usage-command.js +18 -7
  97. package/dist/config.d.ts +21 -11
  98. package/dist/config.d.ts.map +1 -1
  99. package/dist/config.js +90 -63
  100. package/dist/execution/index.d.ts +17 -2
  101. package/dist/execution/index.d.ts.map +1 -1
  102. package/dist/execution/index.js +62 -20
  103. package/dist/formatting.d.ts +127 -0
  104. package/dist/formatting.d.ts.map +1 -1
  105. package/dist/formatting.js +201 -0
  106. package/dist/index.d.ts +7 -2
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +263 -102
  109. package/dist/logger.d.ts.map +1 -1
  110. package/dist/logger.js +47 -18
  111. package/dist/mentions.d.ts +2 -1
  112. package/dist/mentions.d.ts.map +1 -1
  113. package/dist/mentions.js +16 -1
  114. package/dist/messages.d.ts +11 -0
  115. package/dist/messages.d.ts.map +1 -1
  116. package/dist/messages.js +122 -21
  117. package/dist/middleware/cache.d.ts +3 -0
  118. package/dist/middleware/cache.d.ts.map +1 -0
  119. package/dist/middleware/cache.js +53 -0
  120. package/dist/middleware/index.d.ts +1 -0
  121. package/dist/middleware/index.d.ts.map +1 -1
  122. package/dist/middleware/index.js +1 -0
  123. package/dist/models/ai-config.d.ts +4 -2
  124. package/dist/models/ai-config.d.ts.map +1 -1
  125. package/dist/models/ai-config.js +12 -2
  126. package/dist/models/anthropic-provider.d.ts.map +1 -1
  127. package/dist/models/anthropic-provider.js +3 -67
  128. package/dist/models/deepseek-provider.d.ts.map +1 -1
  129. package/dist/models/deepseek-provider.js +0 -2
  130. package/dist/models/google-provider.d.ts.map +1 -1
  131. package/dist/models/google-provider.js +0 -3
  132. package/dist/models/groq-provider.d.ts.map +1 -1
  133. package/dist/models/groq-provider.js +0 -1
  134. package/dist/models/manager.d.ts +2 -1
  135. package/dist/models/manager.d.ts.map +1 -1
  136. package/dist/models/manager.js +26 -2
  137. package/dist/models/openai-provider.d.ts.map +1 -1
  138. package/dist/models/openai-provider.js +0 -4
  139. package/dist/models/openrouter-provider.d.ts +16 -22
  140. package/dist/models/openrouter-provider.d.ts.map +1 -1
  141. package/dist/models/openrouter-provider.js +175 -236
  142. package/dist/models/providers.d.ts +4 -14
  143. package/dist/models/providers.d.ts.map +1 -1
  144. package/dist/models/providers.js +1 -57
  145. package/dist/models/xai-provider.d.ts.map +1 -1
  146. package/dist/models/xai-provider.js +0 -2
  147. package/dist/prompts.d.ts +10 -4
  148. package/dist/prompts.d.ts.map +1 -1
  149. package/dist/prompts.js +447 -70
  150. package/dist/repl/project-status-line.d.ts +3 -0
  151. package/dist/repl/project-status-line.d.ts.map +1 -0
  152. package/dist/repl/project-status-line.js +61 -0
  153. package/dist/repl/tool-call-repair.d.ts.map +1 -1
  154. package/dist/repl/tool-call-repair.js +8 -4
  155. package/dist/repl-new.d.ts +51 -0
  156. package/dist/repl-new.d.ts.map +1 -0
  157. package/dist/repl-new.js +354 -0
  158. package/dist/skills.d.ts +20 -0
  159. package/dist/skills.d.ts.map +1 -0
  160. package/dist/skills.js +192 -0
  161. package/dist/terminal/control.d.ts +55 -0
  162. package/dist/terminal/control.d.ts.map +1 -0
  163. package/dist/terminal/control.js +109 -0
  164. package/dist/terminal/default-theme.d.ts +1 -1
  165. package/dist/terminal/default-theme.d.ts.map +1 -1
  166. package/dist/terminal/default-theme.js +24 -28
  167. package/dist/terminal/formatting.d.ts +23 -25
  168. package/dist/terminal/formatting.d.ts.map +1 -1
  169. package/dist/terminal/formatting.js +35 -52
  170. package/dist/terminal/highlight/index.d.ts.map +1 -1
  171. package/dist/terminal/highlight/index.js +3 -6
  172. package/dist/terminal/highlight/theme.d.ts.map +1 -1
  173. package/dist/terminal/highlight/theme.js +2 -6
  174. package/dist/terminal/index.d.ts +2 -94
  175. package/dist/terminal/index.d.ts.map +1 -1
  176. package/dist/terminal/index.js +2 -370
  177. package/dist/terminal/markdown.js +10 -5
  178. package/dist/terminal/select-prompt.d.ts +2 -2
  179. package/dist/terminal/select-prompt.d.ts.map +1 -1
  180. package/dist/terminal/select-prompt.js +47 -39
  181. package/dist/terminal/strip-ansi.js +4 -4
  182. package/dist/terminal/table/cell.d.ts +114 -0
  183. package/dist/terminal/table/cell.d.ts.map +1 -0
  184. package/dist/terminal/table/cell.js +407 -0
  185. package/dist/terminal/table/debug.d.ts +15 -0
  186. package/dist/terminal/table/debug.d.ts.map +1 -0
  187. package/dist/terminal/table/debug.js +32 -0
  188. package/dist/terminal/table/index.d.ts +3 -0
  189. package/dist/terminal/table/index.d.ts.map +1 -0
  190. package/dist/terminal/table/index.js +2 -0
  191. package/dist/terminal/table/layout-manager.d.ts +27 -0
  192. package/dist/terminal/table/layout-manager.d.ts.map +1 -0
  193. package/dist/terminal/table/layout-manager.js +257 -0
  194. package/dist/terminal/table/table.d.ts +9 -0
  195. package/dist/terminal/table/table.d.ts.map +1 -0
  196. package/dist/terminal/table/table.js +97 -0
  197. package/dist/terminal/table/utils.d.ts +63 -0
  198. package/dist/terminal/table/utils.d.ts.map +1 -0
  199. package/dist/terminal/table/utils.js +326 -0
  200. package/dist/tokens/threshold.d.ts +20 -0
  201. package/dist/tokens/threshold.d.ts.map +1 -0
  202. package/dist/tokens/threshold.js +67 -0
  203. package/dist/tools/advanced-edit-file.d.ts +69 -0
  204. package/dist/tools/advanced-edit-file.d.ts.map +1 -0
  205. package/dist/tools/advanced-edit-file.js +285 -0
  206. package/dist/tools/agent.d.ts +16 -5
  207. package/dist/tools/agent.d.ts.map +1 -1
  208. package/dist/tools/agent.js +86 -59
  209. package/dist/tools/bash.d.ts +23 -12
  210. package/dist/tools/bash.d.ts.map +1 -1
  211. package/dist/tools/bash.js +243 -128
  212. package/dist/tools/batch.d.ts +34 -0
  213. package/dist/tools/batch.d.ts.map +1 -0
  214. package/dist/tools/batch.js +174 -0
  215. package/dist/tools/code-interpreter.d.ts +21 -9
  216. package/dist/tools/code-interpreter.d.ts.map +1 -1
  217. package/dist/tools/code-interpreter.js +151 -134
  218. package/dist/tools/delete-file.d.ts +17 -10
  219. package/dist/tools/delete-file.d.ts.map +1 -1
  220. package/dist/tools/delete-file.js +60 -97
  221. package/dist/tools/directory-tree.d.ts +17 -12
  222. package/dist/tools/directory-tree.d.ts.map +1 -1
  223. package/dist/tools/directory-tree.js +57 -48
  224. package/dist/tools/dynamic-tool-loader.d.ts +16 -10
  225. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  226. package/dist/tools/dynamic-tool-loader.js +122 -130
  227. package/dist/tools/dynamic-tool-parser.d.ts +1 -0
  228. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
  229. package/dist/tools/dynamic-tool-parser.js +1 -0
  230. package/dist/tools/edit-file.d.ts +35 -15
  231. package/dist/tools/edit-file.d.ts.map +1 -1
  232. package/dist/tools/edit-file.js +127 -114
  233. package/dist/tools/glob.d.ts +36 -0
  234. package/dist/tools/glob.d.ts.map +1 -0
  235. package/dist/tools/glob.js +154 -0
  236. package/dist/tools/grep.d.ts +73 -12
  237. package/dist/tools/grep.d.ts.map +1 -1
  238. package/dist/tools/grep.js +425 -165
  239. package/dist/tools/index.d.ts +220 -126
  240. package/dist/tools/index.d.ts.map +1 -1
  241. package/dist/tools/index.js +284 -135
  242. package/dist/tools/llm-edit-fixer.d.ts +24 -0
  243. package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
  244. package/dist/tools/llm-edit-fixer.js +136 -0
  245. package/dist/tools/move-file.d.ts +19 -7
  246. package/dist/tools/move-file.d.ts.map +1 -1
  247. package/dist/tools/move-file.js +48 -34
  248. package/dist/tools/read-file.d.ts +47 -9
  249. package/dist/tools/read-file.d.ts.map +1 -1
  250. package/dist/tools/read-file.js +84 -70
  251. package/dist/tools/read-multiple-files.d.ts +17 -6
  252. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  253. package/dist/tools/read-multiple-files.js +132 -72
  254. package/dist/tools/save-file.d.ts +45 -12
  255. package/dist/tools/save-file.d.ts.map +1 -1
  256. package/dist/tools/save-file.js +76 -101
  257. package/dist/tools/think.d.ts +15 -7
  258. package/dist/tools/think.d.ts.map +1 -1
  259. package/dist/tools/think.js +34 -20
  260. package/dist/tools/types.d.ts +8 -10
  261. package/dist/tools/types.d.ts.map +1 -1
  262. package/dist/tools/types.js +9 -0
  263. package/dist/tools/utils.d.ts +14 -0
  264. package/dist/tools/utils.d.ts.map +1 -0
  265. package/dist/tools/utils.js +16 -0
  266. package/dist/tools/web-fetch.d.ts +11 -4
  267. package/dist/tools/web-fetch.d.ts.map +1 -1
  268. package/dist/tools/web-fetch.js +39 -38
  269. package/dist/tools/web-search.d.ts +15 -6
  270. package/dist/tools/web-search.d.ts.map +1 -1
  271. package/dist/tools/web-search.js +64 -31
  272. package/dist/tui/autocomplete.d.ts +44 -0
  273. package/dist/tui/autocomplete.d.ts.map +1 -0
  274. package/dist/tui/autocomplete.js +466 -0
  275. package/dist/tui/components/assistant-message.d.ts +18 -0
  276. package/dist/tui/components/assistant-message.d.ts.map +1 -0
  277. package/dist/tui/components/assistant-message.js +29 -0
  278. package/dist/tui/components/box.d.ts +20 -0
  279. package/dist/tui/components/box.d.ts.map +1 -0
  280. package/dist/tui/components/box.js +81 -0
  281. package/dist/tui/components/editor.d.ts +106 -0
  282. package/dist/tui/components/editor.d.ts.map +1 -0
  283. package/dist/tui/components/editor.js +1220 -0
  284. package/dist/tui/components/footer.d.ts +12 -0
  285. package/dist/tui/components/footer.d.ts.map +1 -0
  286. package/dist/tui/components/footer.js +209 -0
  287. package/dist/tui/components/header.d.ts +21 -0
  288. package/dist/tui/components/header.d.ts.map +1 -0
  289. package/dist/tui/components/header.js +63 -0
  290. package/dist/tui/components/input.d.ts +14 -0
  291. package/dist/tui/components/input.d.ts.map +1 -0
  292. package/dist/tui/components/input.js +122 -0
  293. package/dist/tui/components/loader.d.ts +23 -0
  294. package/dist/tui/components/loader.d.ts.map +1 -0
  295. package/dist/tui/components/loader.js +45 -0
  296. package/dist/tui/components/markdown.d.ts +106 -0
  297. package/dist/tui/components/markdown.d.ts.map +1 -0
  298. package/dist/tui/components/markdown.js +586 -0
  299. package/dist/tui/components/modal.d.ts +29 -0
  300. package/dist/tui/components/modal.d.ts.map +1 -0
  301. package/dist/tui/components/modal.js +263 -0
  302. package/dist/tui/components/progress-bar.d.ts +19 -0
  303. package/dist/tui/components/progress-bar.d.ts.map +1 -0
  304. package/dist/tui/components/progress-bar.js +78 -0
  305. package/dist/tui/components/prompt-status.d.ts +17 -0
  306. package/dist/tui/components/prompt-status.d.ts.map +1 -0
  307. package/dist/tui/components/prompt-status.js +26 -0
  308. package/dist/tui/components/select-list.d.ts +48 -0
  309. package/dist/tui/components/select-list.d.ts.map +1 -0
  310. package/dist/tui/components/select-list.js +207 -0
  311. package/dist/tui/components/spacer.d.ts +16 -0
  312. package/dist/tui/components/spacer.d.ts.map +1 -0
  313. package/dist/tui/components/spacer.js +27 -0
  314. package/dist/tui/components/table.d.ts +27 -0
  315. package/dist/tui/components/table.d.ts.map +1 -0
  316. package/dist/tui/components/table.js +125 -0
  317. package/dist/tui/components/text.d.ts +26 -0
  318. package/dist/tui/components/text.d.ts.map +1 -0
  319. package/dist/tui/components/text.js +143 -0
  320. package/dist/tui/components/thinking-block.d.ts +14 -0
  321. package/dist/tui/components/thinking-block.d.ts.map +1 -0
  322. package/dist/tui/components/thinking-block.js +33 -0
  323. package/dist/tui/components/tool-execution.d.ts +21 -0
  324. package/dist/tui/components/tool-execution.d.ts.map +1 -0
  325. package/dist/tui/components/tool-execution.js +161 -0
  326. package/dist/tui/components/user-message.d.ts +9 -0
  327. package/dist/tui/components/user-message.d.ts.map +1 -0
  328. package/dist/tui/components/user-message.js +23 -0
  329. package/dist/tui/components/welcome.d.ts +6 -0
  330. package/dist/tui/components/welcome.d.ts.map +1 -0
  331. package/dist/tui/components/welcome.js +30 -0
  332. package/dist/tui/index.d.ts +18 -0
  333. package/dist/tui/index.d.ts.map +1 -0
  334. package/dist/tui/index.js +22 -0
  335. package/dist/tui/terminal.d.ts +38 -0
  336. package/dist/tui/terminal.d.ts.map +1 -0
  337. package/dist/tui/terminal.js +94 -0
  338. package/dist/tui/tui.d.ts +69 -0
  339. package/dist/tui/tui.d.ts.map +1 -0
  340. package/dist/tui/tui.js +204 -0
  341. package/dist/tui/utils.d.ts +24 -0
  342. package/dist/tui/utils.d.ts.map +1 -0
  343. package/dist/tui/utils.js +111 -0
  344. package/dist/utils/bash.d.ts +7 -0
  345. package/dist/utils/bash.d.ts.map +1 -0
  346. package/dist/{tools/bash-utils.js → utils/bash.js} +31 -12
  347. package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
  348. package/dist/utils/filesystem/operations.d.ts.map +1 -0
  349. package/dist/utils/filesystem/security.d.ts +9 -0
  350. package/dist/utils/filesystem/security.d.ts.map +1 -0
  351. package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +93 -21
  352. package/dist/utils/funcs.d.ts +6 -0
  353. package/dist/utils/funcs.d.ts.map +1 -0
  354. package/dist/utils/funcs.js +6 -0
  355. package/dist/utils/generators.d.ts +3 -0
  356. package/dist/utils/generators.d.ts.map +1 -0
  357. package/dist/utils/generators.js +25 -0
  358. package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
  359. package/dist/utils/git.d.ts.map +1 -0
  360. package/dist/{tools/git-utils.js → utils/git.js} +0 -6
  361. package/dist/utils/glob.js +1 -1
  362. package/dist/utils/iterables.d.ts +2 -0
  363. package/dist/utils/iterables.d.ts.map +1 -0
  364. package/dist/utils/iterables.js +6 -0
  365. package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
  366. package/dist/utils/zod.d.ts.map +1 -0
  367. package/package.json +21 -21
  368. package/dist/conversation-analyzer.d.ts +0 -11
  369. package/dist/conversation-analyzer.d.ts.map +0 -1
  370. package/dist/conversation-analyzer.js +0 -88
  371. package/dist/repl/display-tool-messages.d.ts +0 -4
  372. package/dist/repl/display-tool-messages.d.ts.map +0 -1
  373. package/dist/repl/display-tool-messages.js +0 -55
  374. package/dist/repl/display-tool-use.d.ts +0 -14
  375. package/dist/repl/display-tool-use.d.ts.map +0 -1
  376. package/dist/repl/display-tool-use.js +0 -63
  377. package/dist/repl/get-prompt-header.d.ts +0 -8
  378. package/dist/repl/get-prompt-header.d.ts.map +0 -1
  379. package/dist/repl/get-prompt-header.js +0 -38
  380. package/dist/repl-prompt.d.ts +0 -15
  381. package/dist/repl-prompt.d.ts.map +0 -1
  382. package/dist/repl-prompt.js +0 -147
  383. package/dist/repl.d.ts +0 -31
  384. package/dist/repl.d.ts.map +0 -1
  385. package/dist/repl.js +0 -310
  386. package/dist/terminal/checkbox-prompt.d.ts +0 -36
  387. package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
  388. package/dist/terminal/checkbox-prompt.js +0 -362
  389. package/dist/terminal/editor-prompt.d.ts +0 -10
  390. package/dist/terminal/editor-prompt.d.ts.map +0 -1
  391. package/dist/terminal/editor-prompt.js +0 -61
  392. package/dist/terminal/errors.d.ts +0 -19
  393. package/dist/terminal/errors.d.ts.map +0 -1
  394. package/dist/terminal/errors.js +0 -37
  395. package/dist/terminal/input-prompt.d.ts +0 -16
  396. package/dist/terminal/input-prompt.d.ts.map +0 -1
  397. package/dist/terminal/input-prompt.js +0 -181
  398. package/dist/terminal/search-prompt.d.ts +0 -20
  399. package/dist/terminal/search-prompt.d.ts.map +0 -1
  400. package/dist/terminal/search-prompt.js +0 -279
  401. package/dist/terminal/types.d.ts +0 -35
  402. package/dist/terminal/types.d.ts.map +0 -1
  403. package/dist/terminal/types.js +0 -1
  404. package/dist/tokens/manage-output.d.ts +0 -34
  405. package/dist/tokens/manage-output.d.ts.map +0 -1
  406. package/dist/tokens/manage-output.js +0 -44
  407. package/dist/tool-executor.d.ts +0 -28
  408. package/dist/tool-executor.d.ts.map +0 -1
  409. package/dist/tool-executor.js +0 -74
  410. package/dist/tools/bash-utils.d.ts +0 -7
  411. package/dist/tools/bash-utils.d.ts.map +0 -1
  412. package/dist/tools/file-editing-utils.d.ts +0 -2
  413. package/dist/tools/file-editing-utils.d.ts.map +0 -1
  414. package/dist/tools/file-editing-utils.js +0 -135
  415. package/dist/tools/filesystem-utils.d.ts +0 -7
  416. package/dist/tools/filesystem-utils.d.ts.map +0 -1
  417. package/dist/tools/git-utils.d.ts.map +0 -1
  418. package/dist/utils/filesystem.d.ts.map +0 -1
  419. package/dist/utils/zod-utils.d.ts.map +0 -1
  420. /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
  421. /package/dist/utils/{zod-utils.js → zod.js} +0 -0
@@ -1,36 +1,36 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { formatFile } from "../formatting.js";
3
- import { checkbox } from "../terminal/checkbox-prompt.js";
3
+ import style from "../terminal/style.js";
4
4
  import { TokenCounter } from "../tokens/counter.js";
5
+ import { Text } from "../tui/index.js";
5
6
  import { glob } from "../utils/glob.js";
6
- export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
7
+ export const filesCommand = ({ promptManager, modelManager, }) => {
7
8
  return {
8
9
  command: "/files",
9
10
  description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
10
11
  getSubCommands: () => Promise.resolve([]),
11
- execute: async (args) => {
12
+ async handle(args, { tui, container, editor, }) {
12
13
  try {
13
14
  let workingFiles = [];
14
15
  if (!args || args.length === 0) {
15
16
  // Get all files in the current directory
16
17
  const foundFiles = await glob("**/*", { gitignore: true });
17
- const selectedFiles = await checkbox({
18
- message: "Select files to include:",
19
- choices: foundFiles,
20
- pageSize: 15,
21
- });
22
- if (selectedFiles.length === 0) {
23
- terminal.warn("No files selected.");
18
+ // For TUI mode, we'll just use the first few files
19
+ workingFiles = foundFiles.slice(0, 5);
20
+ if (workingFiles.length === 0) {
21
+ container.addChild(new Text(style.yellow("No files found"), 0, 1));
22
+ tui.requestRender();
23
+ editor.setText("");
24
24
  return "continue";
25
25
  }
26
- // Process the selected files
27
- workingFiles = selectedFiles;
28
26
  }
29
27
  else {
30
28
  const patternList = args.filter(Boolean);
31
29
  const foundFiles = await glob(patternList, { gitignore: true });
32
30
  if (foundFiles.length === 0) {
33
- terminal.warn("No files found matching the pattern(s)");
31
+ container.addChild(new Text(style.yellow("No files found matching the pattern(s)"), 1, 0));
32
+ tui.requestRender();
33
+ editor.setText("");
34
34
  return "continue";
35
35
  }
36
36
  // Process the selected files
@@ -48,15 +48,19 @@ export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
48
48
  promptManager.addContext(formattedFile);
49
49
  }
50
50
  catch (error) {
51
- terminal.error(`Error reading file ${filePath}: ${error.message}`);
51
+ container.addChild(new Text(style.red(`Error reading file ${filePath}: ${error.message}`), 1, 0));
52
52
  }
53
53
  }));
54
54
  tokenCounter.free();
55
- terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
55
+ container.addChild(new Text(style.green(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`), 1, 0));
56
+ tui.requestRender();
57
+ editor.setText("");
56
58
  return "continue";
57
59
  }
58
60
  catch (error) {
59
- terminal.error(`Error processing file patterns: ${error.message}`);
61
+ container.addChild(new Text(style.red(`Error processing file patterns: ${error.message}`), 1, 0));
62
+ tui.requestRender();
63
+ editor.setText("");
60
64
  return "continue";
61
65
  }
62
66
  },
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare const generateRulesCommand: ({ terminal, messageHistory, modelManager, tokenTracker, config, }: CommandOptions) => ReplCommand;
2
+ export declare const generateRulesCommand: ({ messageHistory, modelManager, tokenTracker, config, workspace, }: CommandOptions) => ReplCommand;
3
3
  //# sourceMappingURL=generate-rules-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/generate-rules-command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuC9D,eAAO,MAAM,oBAAoB,GAAI,mEAMlC,cAAc,KAAG,WAmCnB,CAAC"}
1
+ {"version":3,"file":"generate-rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/generate-rules-command.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,oBAAoB,GAAI,oEAMlC,cAAc,KAAG,WAoInB,CAAC"}
@@ -1,62 +1,330 @@
1
- import { analyzeConversation } from "../conversation-analyzer.js";
1
+ import { generateText } from "ai";
2
+ import { config } from "../config.js";
2
3
  import { logger } from "../logger.js"; // Import logger
3
- import { checkbox } from "../terminal/checkbox-prompt.js";
4
- async function _processAndSaveRules(newRules, terminal, config) {
5
- if (!newRules || newRules.length === 0) {
6
- terminal.warn("No new generalizable rules were identified.");
7
- return;
8
- }
9
- terminal.info("Generated potential rules:");
10
- terminal.lineBreak();
11
- const rulesToKeep = await checkbox({
12
- message: "Select the rules you want to keep:",
13
- choices: newRules.map((rule) => ({ name: rule, value: rule })),
14
- });
15
- if (rulesToKeep.length === 0) {
16
- terminal.warn("No rules selected to save.");
17
- return;
18
- }
19
- terminal.info("Saving selected rules...");
20
- const existingRules = await config.readProjectLearnedRulesFile();
21
- const rulesToAdd = rulesToKeep.join("\n");
22
- const updatedProjectRules = existingRules.endsWith("\n") || existingRules.length === 0
23
- ? `${existingRules}${rulesToAdd}`
24
- : `${existingRules}\n${rulesToAdd}`;
25
- await config.writeProjectLearnedRulesFile(updatedProjectRules);
26
- terminal.success("Selected rules saved to project learned rules.");
27
- terminal.lineBreak();
28
- terminal.display(rulesToAdd); // Display only the saved rules
29
- }
30
- export const generateRulesCommand = ({ terminal, messageHistory, modelManager, tokenTracker, config, // This is the config module from CommandOptions
31
- }) => {
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, }) => {
32
11
  return {
33
12
  command: "/generate-rules",
34
13
  description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
35
14
  getSubCommands: () => Promise.resolve([]),
36
- execute: async () => {
15
+ async handle(_args, { tui, container, inputContainer, editor, }) {
37
16
  if (messageHistory.isEmpty()) {
38
- terminal.writeln("Cannot generate rules from an empty conversation.");
17
+ container.addChild(new Text(style.yellow("Cannot generate rules from an empty conversation."), 1, 0));
18
+ tui.requestRender();
19
+ editor.setText("");
39
20
  return "continue";
40
21
  }
41
- terminal.lineBreak();
42
- terminal.info("Analyzing conversation to generate rules...");
22
+ container.addChild(new Text("Analyzing conversation to generate rules...", 0, 1));
23
+ tui.requestRender();
43
24
  try {
44
25
  const newRules = await analyzeConversation({
45
26
  modelManager,
46
27
  messages: messageHistory.get(),
47
28
  tokenTracker,
48
- terminal,
29
+ config,
30
+ workspace,
31
+ });
32
+ if (!newRules || newRules.length === 0) {
33
+ container.addChild(new Text(style.yellow("No new generalizable rules were identified."), 2, 0));
34
+ tui.requestRender();
35
+ editor.setText("");
36
+ return "continue";
37
+ }
38
+ // Create rule selector for TUI mode
39
+ const ruleSelector = new RuleSelectorComponent(newRules, async (selectedRules) => {
40
+ // Handle rule selection
41
+ if (selectedRules.length === 0) {
42
+ container.addChild(new Text(style.yellow("No rules selected to save."), 2, 0));
43
+ }
44
+ else {
45
+ try {
46
+ const existingRules = await config.readProjectLearnedRulesFile();
47
+ const rulesToAdd = selectedRules.join("\n");
48
+ const updatedProjectRules = existingRules.endsWith("\n") || existingRules.length === 0
49
+ ? `${existingRules}${rulesToAdd}`
50
+ : `${existingRules}\n${rulesToAdd}`;
51
+ await config.writeProjectLearnedRulesFile(updatedProjectRules);
52
+ container.addChild(new Text(style.green("Selected rules saved to project learned rules."), 2, 0));
53
+ container.addChild(new Text(style.dim("Saved rules:"), 3, 0));
54
+ selectedRules.forEach((rule, index) => {
55
+ container.addChild(new Text(`- ${rule}`, 4 + index, 0));
56
+ });
57
+ }
58
+ catch (error) {
59
+ container.addChild(new Text(style.red(`Failed to save rules: ${error}`), 2, 0));
60
+ }
61
+ }
62
+ // Hide selector and show editor again
63
+ hideRuleSelector(inputContainer, editor, tui);
64
+ tui.requestRender();
65
+ }, () => {
66
+ // Cancel selection - just hide selector
67
+ hideRuleSelector(inputContainer, editor, tui);
68
+ tui.requestRender();
49
69
  });
50
- // Pass the config object available in CommandOptions scope
51
- await _processAndSaveRules(newRules, terminal, config);
70
+ // Replace editor with rule selector
71
+ inputContainer.clear();
72
+ inputContainer.addChild(ruleSelector);
73
+ tui.setFocus(ruleSelector);
74
+ tui.requestRender();
75
+ return "continue";
52
76
  }
53
77
  catch (error) {
54
78
  const errorMessage = error instanceof Error ? error.message : String(error);
55
- terminal.error(`Error generating rules: ${errorMessage}`);
79
+ container.addChild(new Text(style.red(`Error generating rules: ${errorMessage}`), 0, 1));
56
80
  logger.error(error, "Error during rule generation:");
81
+ tui.requestRender();
82
+ editor.setText("");
57
83
  return "continue";
58
84
  }
59
- return "continue";
60
85
  },
61
86
  };
62
87
  };
88
+ // Modified System Prompt
89
+ const system = async (configManager, workspace) => {
90
+ const projectConfig = await configManager.getConfig();
91
+ const sys = await systemPrompt({
92
+ type: projectConfig.systemPromptType,
93
+ activeTools: projectConfig.tools.activeTools,
94
+ includeRules: true,
95
+ allowedDirs: workspace.allowedDirs,
96
+ });
97
+ 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
+
99
+ **Your Task:**
100
+ 1. Analyze the conversation provided.
101
+ 2. Identify significant corrections or redirections from the engineer. Ignore minor clarifications or task-specific adjustments.
102
+ 3. For each significant correction, infer a *single, concise, broadly applicable, actionable rule* (starting with 'Always' or 'Never') that captures the underlying principle the agent should follow in the future.
103
+ 4. Ensure the rule is general enough to be useful in various scenarios, not just the specific context of this conversation.
104
+ 5. Provide a brief, illustrative quote or example from the conversation in parentheses after the rule.
105
+ 6. List only the inferred rules in Markdown bullet points. Do not include explanations, summaries, or conversational filler.
106
+
107
+ **Crucially, AVOID generating rules that are:**
108
+ - Overly specific to the files, functions, or variables discussed (e.g., "Always check for null in the 'processUserData' function"). Instead, generalize (e.g., "Always validate data from external sources before processing").
109
+ - Merely restatements of the task requirements.
110
+ - Too narrow to be useful outside the immediate context.
111
+ - Related to minor typos or formatting preferences unless they represent a consistent pattern requested by the user.
112
+
113
+ **Good General Rule Examples:**
114
+ <examples>
115
+ - Always ask for clarification if the user's request is ambiguous.
116
+ - Never make assumptions about file paths without confirmation.
117
+ - Always follow the user's explicitly stated formatting preferences.
118
+ - Never provide incomplete code snippets without indicating they are partial.
119
+ - Always check for potential null or undefined values before accessing properties.
120
+ </examples>
121
+
122
+ **Bad Specific Rule Examples (Avoid These):**
123
+ <bad-examples>
124
+ - Always use 'const' instead of 'let' for the 'userId' variable in 'auth.ts'.
125
+ - Never forget to pass the 'config' object to the 'initializeDb' function.
126
+ - Always add a try-catch block around the 'api.fetchData()' call in 'dataService.ts'.
127
+ </bad-examples>
128
+
129
+ This is the original system prompt the agent operated under:
130
+ <systemPrompt>
131
+ ${sys}
132
+ </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
+ }
187
+ /**
188
+ * Component that renders a rule selector with search and multi-selection
189
+ */
190
+ class RuleSelectorComponent extends Container {
191
+ searchInput;
192
+ listContainer;
193
+ allRules = [];
194
+ filteredRules = [];
195
+ selectedIndex = 0;
196
+ selectedRules = new Set();
197
+ onSelectCallback;
198
+ onCancelCallback;
199
+ constructor(rules, onSelect, onCancel) {
200
+ super();
201
+ this.onSelectCallback = onSelect;
202
+ this.onCancelCallback = onCancel;
203
+ // Load all rules
204
+ this.allRules = rules;
205
+ this.filteredRules = rules;
206
+ const { columns } = getTerminalSize();
207
+ // Add top border
208
+ this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
209
+ this.addChild(new Spacer(1));
210
+ // Create search input
211
+ this.searchInput = new Input();
212
+ this.searchInput.onSubmit = () => {
213
+ // Enter on search input toggles selection of current item
214
+ this.toggleSelection(this.selectedIndex);
215
+ };
216
+ this.addChild(this.searchInput);
217
+ this.addChild(new Spacer(1));
218
+ // Create list container
219
+ this.listContainer = new Container();
220
+ this.addChild(this.listContainer);
221
+ this.addChild(new Spacer(1));
222
+ // Add instructions
223
+ this.addChild(new Text(style.dim("Space: toggle selection, Enter: confirm, Escape: cancel"), 0, 0));
224
+ this.addChild(new Spacer(1));
225
+ // Add bottom border
226
+ this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
227
+ // Initial render
228
+ this.updateList();
229
+ }
230
+ filterRules(query) {
231
+ if (!query.trim()) {
232
+ this.filteredRules = this.allRules;
233
+ }
234
+ else {
235
+ const searchTokens = query
236
+ .toLowerCase()
237
+ .split(/\s+/)
238
+ .filter((t) => t);
239
+ this.filteredRules = this.allRules.filter((rule) => {
240
+ const searchText = rule.toLowerCase();
241
+ return searchTokens.every((token) => searchText.includes(token));
242
+ });
243
+ }
244
+ this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredRules.length - 1));
245
+ this.updateList();
246
+ }
247
+ updateList() {
248
+ this.listContainer.clear();
249
+ const maxVisible = 10;
250
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredRules.length - maxVisible));
251
+ const endIndex = Math.min(startIndex + maxVisible, this.filteredRules.length);
252
+ // Show visible slice of filtered rules
253
+ for (let i = startIndex; i < endIndex; i++) {
254
+ const rule = this.filteredRules[i];
255
+ if (!rule)
256
+ continue;
257
+ const isSelected = i === this.selectedIndex;
258
+ const isChecked = this.selectedRules.has(i);
259
+ let line = "";
260
+ if (isSelected) {
261
+ const prefix = style.blue("→ ");
262
+ const checkbox = isChecked ? style.green("[✓] ") : "[ ] ";
263
+ const ruleText = rule;
264
+ line = `${prefix + checkbox + style.blue(ruleText)}`;
265
+ }
266
+ else {
267
+ const checkbox = isChecked ? style.green("[✓] ") : "[ ] ";
268
+ const ruleText = ` ${rule}`;
269
+ line = `${checkbox + ruleText}`;
270
+ }
271
+ this.listContainer.addChild(new Text(line, 0, 0));
272
+ }
273
+ // Add scroll indicator if needed
274
+ if (startIndex > 0 || endIndex < this.filteredRules.length) {
275
+ const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredRules.length})`);
276
+ this.listContainer.addChild(new Text(scrollInfo, 0, 0));
277
+ }
278
+ // Show "no results" if empty
279
+ if (this.filteredRules.length === 0) {
280
+ this.listContainer.addChild(new Text(style.gray(" No matching rules"), 0, 0));
281
+ }
282
+ }
283
+ handleInput(keyData) {
284
+ // Up arrow
285
+ if (keyData === "\x1b[A") {
286
+ this.selectedIndex = Math.max(0, this.selectedIndex - 1);
287
+ this.updateList();
288
+ }
289
+ // Down arrow
290
+ else if (keyData === "\x1b[B") {
291
+ this.selectedIndex = Math.min(this.filteredRules.length - 1, this.selectedIndex + 1);
292
+ this.updateList();
293
+ }
294
+ // Space - toggle selection
295
+ else if (keyData === " ") {
296
+ this.toggleSelection(this.selectedIndex);
297
+ }
298
+ // Enter - confirm selection
299
+ else if (keyData === "\r") {
300
+ this.handleConfirm();
301
+ }
302
+ // Escape
303
+ else if (keyData === "\x1b") {
304
+ this.onCancelCallback();
305
+ }
306
+ // Pass everything else to search input
307
+ else {
308
+ this.searchInput.handleInput(keyData);
309
+ this.filterRules(this.searchInput.getValue());
310
+ }
311
+ }
312
+ toggleSelection(index) {
313
+ if (this.selectedRules.has(index)) {
314
+ this.selectedRules.delete(index);
315
+ }
316
+ else {
317
+ this.selectedRules.add(index);
318
+ }
319
+ this.updateList();
320
+ }
321
+ handleConfirm() {
322
+ const selectedRuleTexts = Array.from(this.selectedRules)
323
+ .map((index) => this.filteredRules[index])
324
+ .filter((rule) => rule !== undefined);
325
+ this.onSelectCallback(selectedRuleTexts);
326
+ }
327
+ getSearchInput() {
328
+ return this.searchInput;
329
+ }
330
+ }
@@ -0,0 +1,3 @@
1
+ import type { CommandOptions, ReplCommand } from "./types.ts";
2
+ export declare const handoffCommand: (options: CommandOptions) => ReplCommand;
3
+ //# sourceMappingURL=handoff-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff-command.d.ts","sourceRoot":"","sources":["../../source/commands/handoff-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WAoDxD,CAAC"}
@@ -0,0 +1,191 @@
1
+ import { generateText } from "ai";
2
+ import style from "../terminal/style.js";
3
+ import { initCliTools } from "../tools/index.js";
4
+ import { Text } from "../tui/index.js";
5
+ export const handoffCommand = (options) => {
6
+ return {
7
+ command: "/handoff",
8
+ description: "Creates a detailed handoff plan of the conversation for continuing the work in a new session. Usage: /handoff <the purpose of the handoff>",
9
+ getSubCommands: () => Promise.resolve([]),
10
+ async handle(args, { tui, container, editor, }) {
11
+ // Validate that purpose is provided
12
+ const purpose = args.join(" ").trim();
13
+ if (!purpose) {
14
+ container.addChild(new Text(style.red("Please provide a purpose for the handoff. Usage: /handoff <the purpose of the handoff>"), 1, 0));
15
+ tui.requestRender();
16
+ editor.setText("");
17
+ return "continue";
18
+ }
19
+ container.addChild(new Text(`Creating handoff document for purpose: ${style.blue(purpose)}`, 1, 0));
20
+ tui.requestRender();
21
+ await createHandoffDocument(options, purpose);
22
+ container.addChild(new Text(style.green("Handoff document created"), 2, 0));
23
+ tui.requestRender();
24
+ editor.setText("");
25
+ return "continue";
26
+ },
27
+ };
28
+ };
29
+ const handoffPrompt = (purpose) => {
30
+ return `Creates a detailed handoff plan of the conversation for continuing the work in a new session.
31
+
32
+ The user specified purpose:
33
+
34
+ <purpose>${purpose}</purpose>
35
+
36
+ You are creating a summary specifically so that it can be continued by another agent. For this to work you MUST have a purpose. If no specified purpose was provided in the \`<purpose>...</purpose>\` tag you must STOP IMMEDIATELY and ask the user what the purpose is.
37
+
38
+ Do not continue before asking for the purpose as you will otherwise not understand the instructions and do not assume a purpose!
39
+
40
+ ## Goal
41
+
42
+ Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit purpose for the next steps.
43
+ This handoff plan should be thorough in capturing technical details, code patterns, and architectural decisions that will be essential for continuing development work without losing context.
44
+
45
+ ## Process
46
+
47
+ Before providing your final plan, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
48
+
49
+ 1. Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
50
+ - The user's explicit requests and intents
51
+ - Your approach to addressing the user's requests
52
+ - Key decisions, technical concepts and code patterns
53
+ - Specific details like file names, full code snippets, function signatures, file edits, etc
54
+ 2. Double-check for technical accuracy and completeness, addressing each required element thoroughly.
55
+
56
+ Your plan should include the following sections:
57
+
58
+ 1. **Primary Request and Intent**: Capture all of the user's explicit requests and intents in detail
59
+ 2. **Key Technical Concepts**: List all important technical concepts, technologies, and frameworks discussed.
60
+ 3. **Files and Code Sections**: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
61
+ 4. **Problem Solving**: Document problems solved and any ongoing troubleshooting efforts.
62
+ 5. **Pending Tasks**: Outline any pending tasks that you have explicitly been asked to work on.
63
+ 6. **Current Work**: Describe in detail precisely what was being worked on immediately before this handoff request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
64
+ 7. **Optional Next Step**: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's explicit requests, and the task you were working on immediately before this handoff request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests without confirming with the user first.
65
+
66
+ Additionally create a "slug" for this handoff. The "slug" is how we will refer to it later in a few places. Examples:
67
+
68
+ * current-user-api-handler
69
+ * implement-auth
70
+ * fix-issue-42
71
+
72
+ Together with the slug create a "Readable Summary". Examples:
73
+
74
+ * Implement Currnet User API Handler
75
+ * Implement Authentication
76
+ * Fix Issue #42
77
+
78
+ ## Output Structure
79
+
80
+ Here's an example of how your output should be structured:
81
+
82
+ \`\`\` markdown
83
+ # Readable Summary
84
+
85
+ <analysis>
86
+ [Your thought process, ensuring all points are covered thoroughly and accurately]
87
+ </analysis>
88
+
89
+ <plan>
90
+ # Session Handoff Plan
91
+
92
+ ## 1. Primary Request and Intent
93
+ [Detailed description of all user requests and intents]
94
+
95
+ ## 2. Key Technical Concepts
96
+ - [Concept 1]
97
+ - [Concept 2]
98
+ - [...]
99
+
100
+ ## 3. Files and Code Sections
101
+ ### [File Name 1]
102
+ - **Why important**: [Summary of why this file is important]
103
+ - **Changes made**: [Summary of the changes made to this file, if any]
104
+ - **Code snippet**:
105
+ \`\`\` language
106
+ [Important Code Snippet]
107
+ \`\`\`
108
+
109
+ ### [File Name 2]
110
+ - **Code snippet**:
111
+ \`\`\` language
112
+ [Important Code Snippet]
113
+ \`\`\`
114
+
115
+ [...]
116
+
117
+ ## 4. Problem Solving
118
+ [Description of solved problems and ongoing troubleshooting]
119
+
120
+ ## 5. Next Step
121
+ [Required next step to take, directly aligned with user's explicit handoff purpose]
122
+ </plan>
123
+ \`\`\`
124
+
125
+ ## Final Step
126
+
127
+ After providing your analysis and summary, write the handoff summary to a markdown file at \`handoff-[timestamp]-[slug].md\` where [timestamp] is the current date in format YYYY-MM-DD and the slug is what we defined before.
128
+
129
+ Then tell the user about this file and that they can use \`/pickup FILENAME\` to continue.`;
130
+ };
131
+ async function createHandoffDocument({ modelManager, tokenTracker, tokenCounter, workspace }, purpose) {
132
+ const app = "handoff-agent";
133
+ const { text, usage } = await generateText({
134
+ model: modelManager.getModel(app),
135
+ 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.",
136
+ prompt: handoffPrompt(purpose),
137
+ tools: (await initCliTools({ tokenCounter, workspace })).toolDefs,
138
+ });
139
+ tokenTracker.trackUsage(app, usage);
140
+ console.info(text);
141
+ // // Parse the response to extract the readable summary and slug
142
+ // const lines = text.split("\n");
143
+ // let readableSummary = "";
144
+ // let slug = "";
145
+ // const planContent = text;
146
+ // // Extract readable summary (first heading after markdown)
147
+ // for (let i = 0; i < lines.length; i++) {
148
+ // const line = lines[i].trim();
149
+ // if (line.startsWith("# ") && !readableSummary) {
150
+ // readableSummary = line.substring(2).trim();
151
+ // break;
152
+ // }
153
+ // }
154
+ // // Create slug from readable summary
155
+ // if (readableSummary) {
156
+ // slug = readableSummary
157
+ // .toLowerCase()
158
+ // .replace(/[^a-z0-9\s-]/g, "")
159
+ // .replace(/\s+/g, "-")
160
+ // .replace(/-+/g, "-")
161
+ // .trim();
162
+ // }
163
+ // // Generate filename with timestamp
164
+ // const now = new Date();
165
+ // const timestamp = now.toISOString().split("T")[0]; // YYYY-MM-DD format
166
+ // const filename = `handoff-${timestamp}-${slug || "session"}.md`;
167
+ // // Create the final handoff document
168
+ // const handoffDocument = `# ${readableSummary || "Session Handoff"}
169
+ // ${planContent}
170
+ // ---
171
+ // *Generated on ${now.toISOString()} for purpose: ${purpose}*
172
+ // *This handoff file can be used to continue the work using the /pickup command*`;
173
+ // // Save the handoff document using the saveFile tool
174
+ // const saveFileTool = await createSaveFileTool({
175
+ // workingDir: workspace.primaryDir,
176
+ // allowedDirs: workspace.allowedDirs,
177
+ // });
178
+ // saveFileTool.execute(
179
+ // {
180
+ // path: `./${filename}`,
181
+ // content: handoffDocument,
182
+ // encoding: "utf-8",
183
+ // },
184
+ // {
185
+ // toolCallId: `handoff-${Date.now()}`,
186
+ // abortSignal: undefined,
187
+ // messages: messageHistory.get(),
188
+ // },
189
+ // );
190
+ // console.info(`Handoff document created: ${filename}`);
191
+ }
@@ -1,4 +1,4 @@
1
1
  import { execSync } from "node:child_process";
2
2
  import type { CommandOptions, ReplCommand } from "./types.ts";
3
- export declare function healthCommand({ terminal }: CommandOptions, execFn?: typeof execSync): ReplCommand;
3
+ export declare function healthCommand(_options: CommandOptions, execFn?: typeof execSync): ReplCommand;
4
4
  //# sourceMappingURL=health-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"health-command.d.ts","sourceRoot":"","sources":["../../source/commands/health-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,EAAE,QAAQ,EAAE,EAAE,cAAc,EAC5B,MAAM,kBAAW,GAChB,WAAW,CAqHb"}
1
+ {"version":3,"file":"health-command.d.ts","sourceRoot":"","sources":["../../source/commands/health-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,cAAc,EACxB,MAAM,kBAAW,GAChB,WAAW,CAiKb"}