@travisennis/acai 0.0.6 → 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 (344) hide show
  1. package/README.md +186 -17
  2. package/bin/acai-wrapper.js +26 -0
  3. package/dist/agent/index.d.ts +15 -2
  4. package/dist/agent/index.d.ts.map +1 -1
  5. package/dist/agent/index.js +202 -174
  6. package/dist/api/exa/index.js +1 -1
  7. package/dist/cli.d.ts +2 -1
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +40 -7
  10. package/dist/commands/add-directory-command.d.ts +1 -1
  11. package/dist/commands/add-directory-command.d.ts.map +1 -1
  12. package/dist/commands/add-directory-command.js +1 -32
  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 +2 -38
  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 +1 -5
  19. package/dist/commands/compact-command.d.ts.map +1 -1
  20. package/dist/commands/compact-command.js +0 -9
  21. package/dist/commands/context-command.d.ts +1 -1
  22. package/dist/commands/context-command.d.ts.map +1 -1
  23. package/dist/commands/context-command.js +13 -72
  24. package/dist/commands/copy-command.d.ts.map +1 -1
  25. package/dist/commands/copy-command.js +0 -19
  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 +3 -49
  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 +1 -26
  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 +2 -18
  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 +1 -54
  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 +18 -60
  41. package/dist/commands/handoff-command.d.ts.map +1 -1
  42. package/dist/commands/handoff-command.js +0 -11
  43. package/dist/commands/health-command.d.ts +1 -1
  44. package/dist/commands/health-command.d.ts.map +1 -1
  45. package/dist/commands/health-command.js +8 -103
  46. package/dist/commands/help-command.d.ts +1 -1
  47. package/dist/commands/help-command.d.ts.map +1 -1
  48. package/dist/commands/help-command.js +6 -14
  49. package/dist/commands/history-command.d.ts +1 -1
  50. package/dist/commands/history-command.d.ts.map +1 -1
  51. package/dist/commands/history-command.js +30 -106
  52. package/dist/commands/init-command.d.ts +1 -1
  53. package/dist/commands/init-command.d.ts.map +1 -1
  54. package/dist/commands/init-command.js +4 -23
  55. package/dist/commands/last-log-command.d.ts +1 -1
  56. package/dist/commands/last-log-command.d.ts.map +1 -1
  57. package/dist/commands/last-log-command.js +1 -28
  58. package/dist/commands/list-directories-command.d.ts +1 -1
  59. package/dist/commands/list-directories-command.d.ts.map +1 -1
  60. package/dist/commands/list-directories-command.js +1 -14
  61. package/dist/commands/list-tools-command.d.ts.map +1 -1
  62. package/dist/commands/list-tools-command.js +55 -78
  63. package/dist/commands/manager.d.ts +1 -8
  64. package/dist/commands/manager.d.ts.map +1 -1
  65. package/dist/commands/manager.js +7 -42
  66. package/dist/commands/model-command.d.ts +0 -22
  67. package/dist/commands/model-command.d.ts.map +1 -1
  68. package/dist/commands/model-command.js +5 -126
  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 +1 -79
  72. package/dist/commands/pickup-command.d.ts.map +1 -1
  73. package/dist/commands/pickup-command.js +3 -55
  74. package/dist/commands/prompt-command.d.ts +19 -1
  75. package/dist/commands/prompt-command.d.ts.map +1 -1
  76. package/dist/commands/prompt-command.js +172 -194
  77. package/dist/commands/remove-directory-command.d.ts +1 -1
  78. package/dist/commands/remove-directory-command.d.ts.map +1 -1
  79. package/dist/commands/remove-directory-command.js +1 -33
  80. package/dist/commands/reset-command.d.ts +1 -1
  81. package/dist/commands/reset-command.d.ts.map +1 -1
  82. package/dist/commands/reset-command.js +3 -11
  83. package/dist/commands/rules-command.d.ts +1 -1
  84. package/dist/commands/rules-command.d.ts.map +1 -1
  85. package/dist/commands/rules-command.js +1 -63
  86. package/dist/commands/save-command.d.ts +1 -1
  87. package/dist/commands/save-command.d.ts.map +1 -1
  88. package/dist/commands/save-command.js +1 -8
  89. package/dist/commands/shell-command.d.ts.map +1 -1
  90. package/dist/commands/shell-command.js +1 -48
  91. package/dist/commands/types.d.ts +0 -3
  92. package/dist/commands/types.d.ts.map +1 -1
  93. package/dist/commands/usage-command.d.ts +1 -1
  94. package/dist/commands/usage-command.d.ts.map +1 -1
  95. package/dist/commands/usage-command.js +5 -16
  96. package/dist/config.d.ts +17 -6
  97. package/dist/config.d.ts.map +1 -1
  98. package/dist/config.js +86 -53
  99. package/dist/execution/index.d.ts +17 -2
  100. package/dist/execution/index.d.ts.map +1 -1
  101. package/dist/execution/index.js +62 -20
  102. package/dist/formatting.d.ts +19 -0
  103. package/dist/formatting.d.ts.map +1 -1
  104. package/dist/formatting.js +54 -0
  105. package/dist/index.d.ts +1 -1
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +212 -153
  108. package/dist/messages.d.ts +3 -0
  109. package/dist/messages.d.ts.map +1 -1
  110. package/dist/messages.js +67 -3
  111. package/dist/models/anthropic-provider.d.ts.map +1 -1
  112. package/dist/models/anthropic-provider.js +0 -7
  113. package/dist/models/deepseek-provider.d.ts.map +1 -1
  114. package/dist/models/deepseek-provider.js +0 -2
  115. package/dist/models/google-provider.d.ts.map +1 -1
  116. package/dist/models/google-provider.js +0 -3
  117. package/dist/models/groq-provider.d.ts.map +1 -1
  118. package/dist/models/groq-provider.js +0 -1
  119. package/dist/models/openai-provider.d.ts.map +1 -1
  120. package/dist/models/openai-provider.js +0 -4
  121. package/dist/models/openrouter-provider.d.ts +10 -9
  122. package/dist/models/openrouter-provider.d.ts.map +1 -1
  123. package/dist/models/openrouter-provider.js +82 -88
  124. package/dist/models/providers.d.ts +4 -14
  125. package/dist/models/providers.d.ts.map +1 -1
  126. package/dist/models/providers.js +1 -57
  127. package/dist/models/xai-provider.d.ts.map +1 -1
  128. package/dist/models/xai-provider.js +0 -2
  129. package/dist/prompts.d.ts +9 -4
  130. package/dist/prompts.d.ts.map +1 -1
  131. package/dist/prompts.js +427 -99
  132. package/dist/repl/project-status-line.d.ts +1 -0
  133. package/dist/repl/project-status-line.d.ts.map +1 -1
  134. package/dist/repl/project-status-line.js +57 -27
  135. package/dist/repl-new.d.ts +0 -2
  136. package/dist/repl-new.d.ts.map +1 -1
  137. package/dist/repl-new.js +34 -54
  138. package/dist/skills.d.ts +20 -0
  139. package/dist/skills.d.ts.map +1 -0
  140. package/dist/skills.js +192 -0
  141. package/dist/terminal/control.d.ts +55 -0
  142. package/dist/terminal/control.d.ts.map +1 -0
  143. package/dist/terminal/control.js +109 -0
  144. package/dist/terminal/default-theme.d.ts +1 -1
  145. package/dist/terminal/default-theme.d.ts.map +1 -1
  146. package/dist/terminal/default-theme.js +24 -28
  147. package/dist/terminal/formatting.d.ts +23 -25
  148. package/dist/terminal/formatting.d.ts.map +1 -1
  149. package/dist/terminal/formatting.js +35 -52
  150. package/dist/terminal/highlight/index.d.ts.map +1 -1
  151. package/dist/terminal/highlight/index.js +3 -6
  152. package/dist/terminal/highlight/theme.d.ts.map +1 -1
  153. package/dist/terminal/highlight/theme.js +2 -6
  154. package/dist/terminal/index.d.ts +2 -101
  155. package/dist/terminal/index.d.ts.map +1 -1
  156. package/dist/terminal/index.js +2 -464
  157. package/dist/terminal/markdown.js +7 -5
  158. package/dist/terminal/strip-ansi.js +4 -4
  159. package/dist/terminal/table/cell.d.ts +114 -0
  160. package/dist/terminal/table/cell.d.ts.map +1 -0
  161. package/dist/terminal/table/cell.js +407 -0
  162. package/dist/terminal/table/debug.d.ts +15 -0
  163. package/dist/terminal/table/debug.d.ts.map +1 -0
  164. package/dist/terminal/table/debug.js +32 -0
  165. package/dist/terminal/table/index.d.ts +3 -0
  166. package/dist/terminal/table/index.d.ts.map +1 -0
  167. package/dist/terminal/table/index.js +2 -0
  168. package/dist/terminal/table/layout-manager.d.ts +27 -0
  169. package/dist/terminal/table/layout-manager.d.ts.map +1 -0
  170. package/dist/terminal/table/layout-manager.js +257 -0
  171. package/dist/terminal/table/table.d.ts +9 -0
  172. package/dist/terminal/table/table.d.ts.map +1 -0
  173. package/dist/terminal/table/table.js +97 -0
  174. package/dist/terminal/table/utils.d.ts +63 -0
  175. package/dist/terminal/table/utils.d.ts.map +1 -0
  176. package/dist/terminal/table/utils.js +326 -0
  177. package/dist/tokens/threshold.d.ts +6 -21
  178. package/dist/tokens/threshold.d.ts.map +1 -1
  179. package/dist/tokens/threshold.js +13 -31
  180. package/dist/tools/advanced-edit-file.d.ts.map +1 -1
  181. package/dist/tools/advanced-edit-file.js +5 -1
  182. package/dist/tools/agent.d.ts.map +1 -1
  183. package/dist/tools/agent.js +19 -5
  184. package/dist/tools/bash.d.ts +3 -1
  185. package/dist/tools/bash.d.ts.map +1 -1
  186. package/dist/tools/bash.js +204 -42
  187. package/dist/tools/batch.d.ts +34 -0
  188. package/dist/tools/batch.d.ts.map +1 -0
  189. package/dist/tools/batch.js +174 -0
  190. package/dist/tools/code-interpreter.d.ts.map +1 -1
  191. package/dist/tools/code-interpreter.js +25 -9
  192. package/dist/tools/delete-file.d.ts.map +1 -1
  193. package/dist/tools/delete-file.js +9 -2
  194. package/dist/tools/directory-tree.d.ts +0 -6
  195. package/dist/tools/directory-tree.d.ts.map +1 -1
  196. package/dist/tools/directory-tree.js +29 -18
  197. package/dist/tools/dynamic-tool-loader.d.ts +0 -4
  198. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  199. package/dist/tools/dynamic-tool-loader.js +2 -2
  200. package/dist/tools/edit-file.d.ts.map +1 -1
  201. package/dist/tools/edit-file.js +16 -3
  202. package/dist/tools/glob.d.ts.map +1 -1
  203. package/dist/tools/glob.js +24 -13
  204. package/dist/tools/grep.d.ts.map +1 -1
  205. package/dist/tools/grep.js +40 -25
  206. package/dist/tools/index.d.ts +17 -3
  207. package/dist/tools/index.d.ts.map +1 -1
  208. package/dist/tools/index.js +43 -1
  209. package/dist/tools/llm-edit-fixer.d.ts +0 -1
  210. package/dist/tools/llm-edit-fixer.d.ts.map +1 -1
  211. package/dist/tools/llm-edit-fixer.js +14 -28
  212. package/dist/tools/move-file.d.ts.map +1 -1
  213. package/dist/tools/move-file.js +8 -1
  214. package/dist/tools/read-file.d.ts.map +1 -1
  215. package/dist/tools/read-file.js +32 -23
  216. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  217. package/dist/tools/read-multiple-files.js +102 -45
  218. package/dist/tools/save-file.d.ts +4 -4
  219. package/dist/tools/save-file.d.ts.map +1 -1
  220. package/dist/tools/save-file.js +20 -2
  221. package/dist/tools/think.d.ts.map +1 -1
  222. package/dist/tools/think.js +7 -1
  223. package/dist/tools/types.d.ts +5 -1
  224. package/dist/tools/types.d.ts.map +1 -1
  225. package/dist/tools/web-fetch.js +1 -1
  226. package/dist/tools/web-search.d.ts.map +1 -1
  227. package/dist/tools/web-search.js +24 -9
  228. package/dist/tui/components/assistant-message.js +1 -1
  229. package/dist/tui/components/box.d.ts +20 -0
  230. package/dist/tui/components/box.d.ts.map +1 -0
  231. package/dist/tui/components/box.js +81 -0
  232. package/dist/tui/components/editor.d.ts +60 -5
  233. package/dist/tui/components/editor.d.ts.map +1 -1
  234. package/dist/tui/components/editor.js +577 -115
  235. package/dist/tui/components/footer.d.ts +0 -12
  236. package/dist/tui/components/footer.d.ts.map +1 -1
  237. package/dist/tui/components/footer.js +19 -7
  238. package/dist/tui/components/header.d.ts +21 -0
  239. package/dist/tui/components/header.d.ts.map +1 -0
  240. package/dist/tui/components/header.js +63 -0
  241. package/dist/tui/components/loader.d.ts +5 -1
  242. package/dist/tui/components/loader.d.ts.map +1 -1
  243. package/dist/tui/components/loader.js +2 -2
  244. package/dist/tui/components/markdown.d.ts +26 -23
  245. package/dist/tui/components/markdown.d.ts.map +1 -1
  246. package/dist/tui/components/markdown.js +107 -54
  247. package/dist/tui/components/modal.d.ts +0 -11
  248. package/dist/tui/components/modal.d.ts.map +1 -1
  249. package/dist/tui/components/modal.js +0 -29
  250. package/dist/tui/components/progress-bar.d.ts +19 -0
  251. package/dist/tui/components/progress-bar.d.ts.map +1 -0
  252. package/dist/tui/components/progress-bar.js +78 -0
  253. package/dist/tui/components/prompt-status.d.ts +2 -1
  254. package/dist/tui/components/prompt-status.d.ts.map +1 -1
  255. package/dist/tui/components/prompt-status.js +7 -2
  256. package/dist/tui/components/select-list.d.ts +27 -1
  257. package/dist/tui/components/select-list.d.ts.map +1 -1
  258. package/dist/tui/components/select-list.js +93 -29
  259. package/dist/tui/components/spacer.d.ts +1 -1
  260. package/dist/tui/components/spacer.d.ts.map +1 -1
  261. package/dist/tui/components/spacer.js +2 -2
  262. package/dist/tui/components/table.d.ts +27 -0
  263. package/dist/tui/components/table.d.ts.map +1 -0
  264. package/dist/tui/components/table.js +125 -0
  265. package/dist/tui/components/thinking-block.d.ts.map +1 -1
  266. package/dist/tui/components/thinking-block.js +4 -1
  267. package/dist/tui/components/tool-execution.d.ts +8 -4
  268. package/dist/tui/components/tool-execution.d.ts.map +1 -1
  269. package/dist/tui/components/tool-execution.js +88 -80
  270. package/dist/tui/components/user-message.d.ts.map +1 -1
  271. package/dist/tui/components/user-message.js +6 -4
  272. package/dist/tui/index.d.ts +9 -5
  273. package/dist/tui/index.d.ts.map +1 -1
  274. package/dist/tui/index.js +5 -1
  275. package/dist/tui/terminal.d.ts +2 -1
  276. package/dist/tui/terminal.d.ts.map +1 -1
  277. package/dist/tui/terminal.js +28 -38
  278. package/dist/tui/tui.d.ts +2 -0
  279. package/dist/tui/tui.d.ts.map +1 -1
  280. package/dist/tui/tui.js +53 -33
  281. package/dist/tui/utils.d.ts +5 -0
  282. package/dist/tui/utils.d.ts.map +1 -1
  283. package/dist/tui/utils.js +81 -1
  284. package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
  285. package/dist/utils/bash.d.ts.map +1 -0
  286. package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
  287. package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
  288. package/dist/utils/filesystem/operations.d.ts.map +1 -0
  289. package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
  290. package/dist/utils/filesystem/security.d.ts.map +1 -0
  291. package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
  292. package/dist/utils/funcs.d.ts +6 -0
  293. package/dist/utils/funcs.d.ts.map +1 -0
  294. package/dist/utils/funcs.js +6 -0
  295. package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
  296. package/dist/utils/git.d.ts.map +1 -0
  297. package/dist/{tools/git-utils.js → utils/git.js} +0 -6
  298. package/dist/utils/glob.js +1 -1
  299. package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
  300. package/dist/utils/zod.d.ts.map +1 -0
  301. package/package.json +17 -17
  302. package/dist/agent/manual-loop.d.ts +0 -41
  303. package/dist/agent/manual-loop.d.ts.map +0 -1
  304. package/dist/agent/manual-loop.js +0 -278
  305. package/dist/repl/display-tool-messages.d.ts +0 -4
  306. package/dist/repl/display-tool-messages.d.ts.map +0 -1
  307. package/dist/repl/display-tool-messages.js +0 -58
  308. package/dist/repl/display-tool-use.d.ts +0 -14
  309. package/dist/repl/display-tool-use.d.ts.map +0 -1
  310. package/dist/repl/display-tool-use.js +0 -63
  311. package/dist/repl/get-prompt-header.d.ts +0 -8
  312. package/dist/repl/get-prompt-header.d.ts.map +0 -1
  313. package/dist/repl/get-prompt-header.js +0 -9
  314. package/dist/repl/prompt.d.ts +0 -21
  315. package/dist/repl/prompt.d.ts.map +0 -1
  316. package/dist/repl/prompt.js +0 -244
  317. package/dist/repl.d.ts +0 -29
  318. package/dist/repl.d.ts.map +0 -1
  319. package/dist/repl.js +0 -218
  320. package/dist/terminal/checkbox-prompt.d.ts +0 -36
  321. package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
  322. package/dist/terminal/checkbox-prompt.js +0 -368
  323. package/dist/terminal/editor-prompt.d.ts +0 -10
  324. package/dist/terminal/editor-prompt.d.ts.map +0 -1
  325. package/dist/terminal/editor-prompt.js +0 -61
  326. package/dist/terminal/errors.d.ts +0 -19
  327. package/dist/terminal/errors.d.ts.map +0 -1
  328. package/dist/terminal/errors.js +0 -37
  329. package/dist/terminal/input-prompt.d.ts +0 -17
  330. package/dist/terminal/input-prompt.d.ts.map +0 -1
  331. package/dist/terminal/input-prompt.js +0 -181
  332. package/dist/terminal/search-prompt.d.ts +0 -20
  333. package/dist/terminal/search-prompt.d.ts.map +0 -1
  334. package/dist/terminal/search-prompt.js +0 -280
  335. package/dist/terminal/types.d.ts +0 -35
  336. package/dist/terminal/types.d.ts.map +0 -1
  337. package/dist/terminal/types.js +0 -1
  338. package/dist/tools/bash-utils.d.ts.map +0 -1
  339. package/dist/tools/filesystem-utils.d.ts.map +0 -1
  340. package/dist/tools/git-utils.d.ts.map +0 -1
  341. package/dist/utils/filesystem.d.ts.map +0 -1
  342. package/dist/utils/zod-utils.d.ts.map +0 -1
  343. /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
  344. /package/dist/utils/{zod-utils.js → zod.js} +0 -0
@@ -2,44 +2,13 @@ import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import style from "../terminal/style.js";
4
4
  import { Text } from "../tui/index.js";
5
- export const addDirectoryCommand = ({ terminal, workspace, }) => {
5
+ export const addDirectoryCommand = ({ workspace, }) => {
6
6
  return {
7
7
  command: "/add-directory",
8
8
  description: "Add a directory to the list of allowed working directories",
9
9
  getSubCommands: async () => {
10
10
  return [];
11
11
  },
12
- execute: async (args) => {
13
- const directoryPath = args?.[0];
14
- if (!directoryPath) {
15
- terminal.error("Usage: /add-directory <path>");
16
- return "continue";
17
- }
18
- try {
19
- // Resolve and validate the directory
20
- const resolvedPath = path.resolve(directoryPath);
21
- const stats = await fs.stat(resolvedPath);
22
- if (!stats.isDirectory()) {
23
- terminal.error(`Path is not a directory: ${resolvedPath}`);
24
- return "continue";
25
- }
26
- // Check if directory is already in the list
27
- if (workspace.allowedDirs.includes(resolvedPath)) {
28
- terminal.warn(`Directory already in allowed list: ${resolvedPath}`);
29
- return "continue";
30
- }
31
- // Add the directory to the workspace
32
- workspace.allowedDirs.push(resolvedPath);
33
- terminal.writeln(`Added directory to allowed list: ${style.blue(resolvedPath)}`);
34
- terminal.writeln(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`);
35
- return "continue";
36
- }
37
- catch (error) {
38
- const errorMessage = error instanceof Error ? error.message : String(error);
39
- terminal.error(`Failed to add directory: ${errorMessage}`);
40
- return "continue";
41
- }
42
- },
43
12
  async handle(args, { tui, container, editor, }) {
44
13
  const directoryPath = args?.[0];
45
14
  if (!directoryPath) {
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare const applicationLogCommand: ({ terminal, }: CommandOptions) => ReplCommand;
2
+ export declare const applicationLogCommand: (_options: CommandOptions) => ReplCommand;
3
3
  //# sourceMappingURL=application-log-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,qBAAqB,GAAI,eAEnC,cAAc,KAAG,WAwHnB,CAAC"}
1
+ {"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,qBAAqB,GAChC,UAAU,cAAc,KACvB,WAiFF,CAAC"}
@@ -1,52 +1,16 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { config } from "../config.js";
3
- import { editor } from "../terminal/editor-prompt.js";
4
3
  import style from "../terminal/style.js";
5
4
  import { Text } from "../tui/index.js";
6
- export const applicationLogCommand = ({ terminal, }) => {
5
+ export const applicationLogCommand = (_options) => {
7
6
  return {
8
7
  command: "/application-logs",
9
8
  description: "Opens the application log file defined in acai.json in the editor.",
10
9
  getSubCommands: () => Promise.resolve([]),
11
- execute: async () => {
12
- let logFilePath;
13
- try {
14
- const projectConfig = await config.readProjectConfig();
15
- logFilePath = projectConfig.logs?.path;
16
- if (!logFilePath) {
17
- terminal.error("Application log path is not defined in .acai/acai.json under the 'logs.path' key.");
18
- return "continue";
19
- }
20
- const content = await readFile(logFilePath, { encoding: "utf8" });
21
- // Use the editor prompt to display the content (read-only)
22
- await editor({
23
- message: `Viewing ${logFilePath}`,
24
- // Attempt to infer postfix from file extension, default otherwise
25
- postfix: logFilePath.includes(".")
26
- ? `.${logFilePath.split(".").pop()}`
27
- : ".log",
28
- default: content,
29
- // By not providing an onSubmit or similar handler to write the file,
30
- // and not calling writeFileSync after, this effectively becomes read-only.
31
- skipPrompt: true,
32
- });
33
- terminal.info(`Closed log view for: ${logFilePath}`);
34
- return "continue";
35
- }
36
- catch (error) {
37
- if (logFilePath && error.code === "ENOENT") {
38
- terminal.error(`Application log file not found at: ${logFilePath}`);
39
- }
40
- else {
41
- terminal.error(`Error reading or displaying log file ${logFilePath ?? "specified in config"}: ${error}`);
42
- }
43
- return "continue";
44
- }
45
- },
46
10
  async handle(_args, { tui, container, editor, }) {
47
11
  let logFilePath;
48
12
  try {
49
- const projectConfig = await config.readProjectConfig();
13
+ const projectConfig = await config.getConfig();
50
14
  logFilePath = projectConfig.logs?.path;
51
15
  if (!logFilePath) {
52
16
  container.addChild(new Text(style.red("Application log path is not defined in .acai/acai.json under the 'logs.path' key."), 1, 0));
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare const clearCommand: ({ terminal }: CommandOptions) => ReplCommand;
2
+ export declare const clearCommand: (_options: CommandOptions) => ReplCommand;
3
3
  //# sourceMappingURL=clear-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clear-command.d.ts","sourceRoot":"","sources":["../../source/commands/clear-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,cAAc,cAAc,KAAG,WAyB3D,CAAC"}
1
+ {"version":3,"file":"clear-command.d.ts","sourceRoot":"","sources":["../../source/commands/clear-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,UAAU,cAAc,KAAG,WAqBvD,CAAC"}
@@ -1,12 +1,8 @@
1
- export const clearCommand = ({ terminal }) => {
1
+ export const clearCommand = (_options) => {
2
2
  return {
3
3
  command: "/clear",
4
4
  description: "Clears the terminal screen.",
5
5
  getSubCommands: () => Promise.resolve([]),
6
- execute: async () => {
7
- terminal.clear();
8
- return "continue";
9
- },
10
6
  async handle(_args, { tui, container, editor, }) {
11
7
  // In TUI mode, we can't clear the screen like terminal.clear()
12
8
  // Instead, we'll just clear the input and show a message
@@ -1 +1 @@
1
- {"version":3,"file":"compact-command.d.ts","sourceRoot":"","sources":["../../source/commands/compact-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WAqCxD,CAAC"}
1
+ {"version":3,"file":"compact-command.d.ts","sourceRoot":"","sources":["../../source/commands/compact-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WA6BxD,CAAC"}
@@ -7,15 +7,6 @@ export const compactCommand = (options) => {
7
7
  command: "/compact",
8
8
  description: "Saves, summarizes, and resets the chat history. Optional instructions can be provided for the summary.",
9
9
  getSubCommands: () => Promise.resolve([]),
10
- execute: async (args) => {
11
- const { messageHistory, terminal } = options;
12
- if (!messageHistory.isEmpty()) {
13
- const additionalInstructions = args.join(" ");
14
- await summarizeAndReset(options, additionalInstructions);
15
- }
16
- terminal.info("Message history summarized and reset.");
17
- return "continue";
18
- },
19
10
  async handle(args, { tui, container, editor, }) {
20
11
  const { messageHistory } = options;
21
12
  if (!messageHistory.isEmpty()) {
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare function contextCommand({ terminal, tokenCounter, modelManager, messageHistory, workspace, }: CommandOptions): ReplCommand;
2
+ export declare function contextCommand({ config, tokenCounter, modelManager, messageHistory, workspace, }: CommandOptions): ReplCommand;
3
3
  //# sourceMappingURL=context-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-command.d.ts","sourceRoot":"","sources":["../../source/commands/context-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4C9D,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,GACV,EAAE,cAAc,GAAG,WAAW,CA4L9B"}
1
+ {"version":3,"file":"context-command.d.ts","sourceRoot":"","sources":["../../source/commands/context-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4C9D,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,GACV,EAAE,cAAc,GAAG,WAAW,CAuH9B"}
@@ -1,7 +1,7 @@
1
1
  import { systemPrompt } from "../prompts.js";
2
2
  import { initCliTools } from "../tools/index.js";
3
3
  import { prepareTools } from "../tools/utils.js";
4
- import { Container, Modal, ModalTable, ModalText } from "../tui/index.js";
4
+ import { Container, Modal, ModalText, TableComponent } from "../tui/index.js";
5
5
  /**
6
6
  * Count tokens from message history
7
7
  */
@@ -31,91 +31,30 @@ function pct(n, d) {
31
31
  return "0.0%";
32
32
  return `${((n / d) * 100).toFixed(1)}%`;
33
33
  }
34
- export function contextCommand({ terminal, tokenCounter, modelManager, messageHistory, workspace, }) {
34
+ export function contextCommand({ config, tokenCounter, modelManager, messageHistory, workspace, }) {
35
35
  return {
36
36
  command: "/context",
37
37
  description: "Show context window usage breakdown",
38
38
  getSubCommands: () => Promise.resolve(["--details", "--json"]),
39
- async execute(args) {
40
- const meta = modelManager.getModelMetadata("repl");
41
- const window = meta.contextWindow;
42
- // 1) System prompt
43
- const sys = await systemPrompt({
44
- supportsToolCalling: meta.supportsToolCalling,
45
- includeRules: true,
46
- });
47
- const systemPromptTokens = tokenCounter.count(sys);
48
- // 2) Tools (MVP approximation)
49
- let toolsTokens = 0;
50
- try {
51
- const tools = await initCliTools({ tokenCounter, workspace });
52
- const toolDefs = tools.toolDefs;
53
- const toolNames = JSON.stringify(prepareTools(toolDefs));
54
- toolsTokens = tokenCounter.count(toolNames);
55
- // v2: replace with exact serialized definitions
56
- }
57
- catch (error) {
58
- console.error(error);
59
- toolsTokens = 0;
60
- }
61
- // 3) Messages
62
- const messagesTokens = countMessageTokens(messageHistory.get(), tokenCounter);
63
- // 4) Totals
64
- const used = systemPromptTokens + toolsTokens + messagesTokens;
65
- const free = Math.max(0, window - used);
66
- const breakdown = {
67
- systemPrompt: systemPromptTokens,
68
- tools: toolsTokens,
69
- messages: messagesTokens,
70
- totalUsed: used,
71
- window,
72
- free,
73
- };
74
- // Output
75
- terminal.header("Context Usage");
76
- terminal.table([
77
- [
78
- "System prompt",
79
- formatNum(breakdown.systemPrompt),
80
- pct(breakdown.systemPrompt, window),
81
- ],
82
- [
83
- "System tools",
84
- formatNum(breakdown.tools),
85
- pct(breakdown.tools, window),
86
- ],
87
- [
88
- "Messages",
89
- formatNum(breakdown.messages),
90
- pct(breakdown.messages, window),
91
- ],
92
- [
93
- "Free space",
94
- formatNum(breakdown.free),
95
- pct(breakdown.free, window),
96
- ],
97
- ], { header: ["Section", "Tokens", "Percent"], colWidths: [40, 30, 30] });
98
- terminal.lineBreak();
99
- terminal.displayProgressBar(used, window);
100
- if (args.includes("--json")) {
101
- terminal.lineBreak();
102
- terminal.display(JSON.stringify(breakdown, null, 2));
103
- }
104
- return "continue";
105
- },
106
39
  async handle(args, { tui, editor }) {
107
40
  const meta = modelManager.getModelMetadata("repl");
108
41
  const window = meta.contextWindow;
42
+ const projectConfig = await config.getConfig();
109
43
  // 1) System prompt
110
44
  const sys = await systemPrompt({
111
- supportsToolCalling: meta.supportsToolCalling,
45
+ type: projectConfig.systemPromptType,
46
+ activeTools: projectConfig.tools.activeTools,
47
+ allowedDirs: workspace.allowedDirs,
112
48
  includeRules: true,
113
49
  });
114
50
  const systemPromptTokens = tokenCounter.count(sys);
115
51
  // 2) Tools (MVP approximation)
116
52
  let toolsTokens = 0;
117
53
  try {
118
- const tools = await initCliTools({ tokenCounter, workspace });
54
+ const tools = await initCliTools({
55
+ tokenCounter,
56
+ workspace,
57
+ });
119
58
  const toolDefs = tools.toolDefs;
120
59
  const toolNames = JSON.stringify(prepareTools(toolDefs));
121
60
  toolsTokens = tokenCounter.count(toolNames);
@@ -160,7 +99,9 @@ export function contextCommand({ terminal, tokenCounter, modelManager, messageHi
160
99
  ["Free space", formatNum(breakdown.free), pct(breakdown.free, window)],
161
100
  ];
162
101
  modalContent.addChild(new ModalText("Context Usage", 0, 1));
163
- modalContent.addChild(new ModalTable(tableData, ["Section", "Tokens", "Percent"]));
102
+ modalContent.addChild(new TableComponent(tableData, {
103
+ headers: ["Section", "Tokens", "Percent"],
104
+ }));
164
105
  // Progress bar
165
106
  const progressBar = `[${"#".repeat(Math.floor((used / window) * 20))}${"-".repeat(20 - Math.floor((used / window) * 20))}] ${pct(used, window)}`;
166
107
  modalContent.addChild(new ModalText("", 0, 1)); // Spacer
@@ -1 +1 @@
1
- {"version":3,"file":"copy-command.d.ts","sourceRoot":"","sources":["../../source/commands/copy-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyB9D,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAsEhE"}
1
+ {"version":3,"file":"copy-command.d.ts","sourceRoot":"","sources":["../../source/commands/copy-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyB9D,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAmDhE"}
@@ -31,25 +31,6 @@ export function copyCommand(options) {
31
31
  async getSubCommands() {
32
32
  return [];
33
33
  },
34
- async execute(_args) {
35
- const { messageHistory, terminal } = options;
36
- const history = messageHistory.get();
37
- const lastText = extractLastAssistantText(history);
38
- if (!lastText) {
39
- terminal.info("No assistant response to copy.");
40
- return "continue";
41
- }
42
- try {
43
- await Clipboard.setText(lastText);
44
- terminal.success("Copied last response to clipboard.");
45
- return "continue";
46
- }
47
- catch (err) {
48
- const message = err instanceof Error ? err.message : String(err);
49
- terminal.error(`Could not copy to clipboard: ${message}`);
50
- return "continue";
51
- }
52
- },
53
34
  async handle(_args, { tui, container, editor, }) {
54
35
  const { messageHistory } = options;
55
36
  const history = messageHistory.get();
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare const editCommand: ({ terminal }: CommandOptions) => ReplCommand;
2
+ export declare const editCommand: (_options: CommandOptions) => ReplCommand;
3
3
  //# sourceMappingURL=edit-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edit-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-command.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,cAAc,cAAc,KAAG,WAoH1D,CAAC"}
1
+ {"version":3,"file":"edit-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,UAAU,cAAc,KAAG,WAkEtD,CAAC"}
@@ -1,58 +1,12 @@
1
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { extname, resolve } from "node:path";
3
- import { editor } from "../terminal/editor-prompt.js";
4
- import { search } from "../terminal/search-prompt.js";
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
5
3
  import style from "../terminal/style.js";
6
4
  import { Text } from "../tui/index.js";
7
- import { glob } from "../utils/glob.js";
8
- export const editCommand = ({ terminal }) => {
5
+ export const editCommand = (_options) => {
9
6
  return {
10
7
  command: "/edit",
11
8
  description: "Opens file in $EDITOR for editing. Usage: /edit [file-path]",
12
9
  getSubCommands: () => Promise.resolve([]),
13
- execute: async (args) => {
14
- let fileToEdit;
15
- if (args.length > 0) {
16
- // File path provided as argument
17
- const filePath = args.join(" "); // Handle file paths with spaces
18
- const resolvedPath = resolve(filePath);
19
- if (!existsSync(resolvedPath)) {
20
- terminal.error(`File not found: ${filePath}`);
21
- return "continue";
22
- }
23
- fileToEdit = filePath;
24
- }
25
- else {
26
- // No file path provided, use search prompt
27
- fileToEdit = await search({
28
- message: "Search for file:",
29
- source: async (input) => {
30
- if (!input) {
31
- return [];
32
- }
33
- const foundFiles = await glob(`**/*${input}*`, {
34
- gitignore: true,
35
- });
36
- return foundFiles.map((file) => ({
37
- name: file,
38
- value: file,
39
- }));
40
- },
41
- });
42
- }
43
- const content = readFileSync(fileToEdit, { encoding: "utf8" });
44
- const edit = await editor({
45
- message: `Edit ${fileToEdit}?`,
46
- postfix: extname(fileToEdit),
47
- default: content,
48
- skipPrompt: true,
49
- });
50
- writeFileSync(fileToEdit, edit);
51
- if (content !== edit) {
52
- terminal.info(`File updated: ${fileToEdit}`);
53
- }
54
- return "continue";
55
- },
56
10
  async handle(args, { tui, container, editor, }) {
57
11
  let fileToEdit;
58
12
  if (args.length > 0) {
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare const editPromptCommand: ({ terminal, promptManager, promptHistory, }: CommandOptions) => ReplCommand;
2
+ export declare const editPromptCommand: ({ promptManager, promptHistory, }: CommandOptions) => ReplCommand;
3
3
  //# sourceMappingURL=edit-prompt-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edit-prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-prompt-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,iBAAiB,GAAI,6CAI/B,cAAc,KAAG,WAkFnB,CAAC"}
1
+ {"version":3,"file":"edit-prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-prompt-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,iBAAiB,GAAI,mCAG/B,cAAc,KAAG,WAuDnB,CAAC"}
@@ -1,36 +1,11 @@
1
1
  import { syncTry } from "@travisennis/stdlib/try";
2
- import { editor } from "../terminal/editor-prompt.js";
3
2
  import style from "../terminal/style.js";
4
3
  import { Text } from "../tui/index.js";
5
- export const editPromptCommand = ({ terminal, promptManager, promptHistory, }) => {
4
+ export const editPromptCommand = ({ promptManager, promptHistory, }) => {
6
5
  return {
7
6
  command: "/edit-prompt",
8
7
  description: "Edit the prompt. Accepts optional arguments as initial content.",
9
8
  getSubCommands: () => Promise.resolve([]),
10
- execute: async (args = []) => {
11
- try {
12
- const prompt = syncTry(() => promptManager.get());
13
- const initialContent = args.length > 0 ? args.join(" ") : prompt.unwrapOr("");
14
- const updatedPrompt = await editor({
15
- message: " Edit prompt?",
16
- postfix: "md",
17
- default: initialContent,
18
- skipPrompt: true,
19
- });
20
- if (updatedPrompt.trim().length === 0) {
21
- throw new Error("Prompt was empty.");
22
- }
23
- terminal.writeln(`> ${updatedPrompt}`);
24
- promptManager.set(updatedPrompt);
25
- // Add the edited prompt to history
26
- promptHistory.push(updatedPrompt);
27
- }
28
- catch (error) {
29
- terminal.error(`Error editing prompt: ${error.message}`);
30
- return "continue";
31
- }
32
- return "use";
33
- },
34
9
  async handle(args, { tui, container, editor, }) {
35
10
  try {
36
11
  const prompt = syncTry(() => promptManager.get());
@@ -4,10 +4,7 @@ export interface ExitCommandOptions {
4
4
  isEmpty: () => boolean;
5
5
  save: () => Promise<void>;
6
6
  };
7
- terminal: {
8
- clear: () => void;
9
- };
10
7
  baseDir?: string | null;
11
8
  }
12
- export declare const exitCommand: ({ messageHistory, terminal, baseDir, }: ExitCommandOptions) => ReplCommand;
9
+ export declare const exitCommand: ({ messageHistory, baseDir, }: ExitCommandOptions) => ReplCommand;
13
10
  //# sourceMappingURL=exit-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE;QACd,OAAO,EAAE,MAAM,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IACF,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,GAAI,wCAIzB,kBAAkB,KAAG,WAkDvB,CAAC"}
1
+ {"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,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,WAiCvB,CAAC"}
@@ -1,29 +1,13 @@
1
1
  import path from "node:path";
2
2
  import { logger } from "../logger.js";
3
3
  import { Text } from "../tui/index.js";
4
- import { clearDirectory } from "../utils/filesystem.js";
5
- export const exitCommand = ({ messageHistory, terminal, baseDir, }) => {
4
+ import { clearDirectory } from "../utils/filesystem/operations.js";
5
+ export const exitCommand = ({ messageHistory, baseDir, }) => {
6
6
  return {
7
7
  command: "/exit",
8
8
  aliases: ["/bye", "/quit"],
9
9
  description: "Exits and saves the chat history.",
10
10
  getSubCommands: () => Promise.resolve([]),
11
- execute: async () => {
12
- terminal.clear();
13
- if (!messageHistory.isEmpty()) {
14
- await messageHistory.save();
15
- }
16
- // Clear the .tmp directory on exit
17
- try {
18
- const tmpDirPath = path.join(baseDir ?? process.cwd(), ".tmp");
19
- await clearDirectory(tmpDirPath);
20
- }
21
- catch (error) {
22
- // Log error but don't block exit
23
- console.error("Failed to clear .tmp directory:", error);
24
- }
25
- return "break";
26
- },
27
11
  async handle(_args, { tui, container, editor, }) {
28
12
  if (!messageHistory.isEmpty()) {
29
13
  await messageHistory.save();
@@ -1,3 +1,3 @@
1
1
  import type { CommandOptions, ReplCommand } from "./types.ts";
2
- export declare const filesCommand: ({ terminal, promptManager, modelManager, }: CommandOptions) => ReplCommand;
2
+ export declare const filesCommand: ({ promptManager, modelManager, }: CommandOptions) => ReplCommand;
3
3
  //# sourceMappingURL=files-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,4CAI1B,cAAc,KAAG,WA8KnB,CAAC"}
1
+ {"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,kCAG1B,cAAc,KAAG,WA4GnB,CAAC"}
@@ -1,67 +1,14 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { formatFile } from "../formatting.js";
3
- import { checkbox } from "../terminal/checkbox-prompt.js";
4
3
  import style from "../terminal/style.js";
5
4
  import { TokenCounter } from "../tokens/counter.js";
6
5
  import { Text } from "../tui/index.js";
7
6
  import { glob } from "../utils/glob.js";
8
- export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
7
+ export const filesCommand = ({ promptManager, modelManager, }) => {
9
8
  return {
10
9
  command: "/files",
11
10
  description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
12
11
  getSubCommands: () => Promise.resolve([]),
13
- execute: async (args) => {
14
- try {
15
- let workingFiles = [];
16
- if (!args || args.length === 0) {
17
- // Get all files in the current directory
18
- const foundFiles = await glob("**/*", { gitignore: true });
19
- const selectedFiles = await checkbox({
20
- message: "Select files to include:",
21
- choices: foundFiles,
22
- pageSize: 15,
23
- });
24
- if (selectedFiles.length === 0) {
25
- terminal.warn("No files selected.");
26
- return "continue";
27
- }
28
- // Process the selected files
29
- workingFiles = selectedFiles;
30
- }
31
- else {
32
- const patternList = args.filter(Boolean);
33
- const foundFiles = await glob(patternList, { gitignore: true });
34
- if (foundFiles.length === 0) {
35
- terminal.warn("No files found matching the pattern(s)");
36
- return "continue";
37
- }
38
- // Process the selected files
39
- workingFiles = foundFiles;
40
- }
41
- // Read the content of the files and format them for the next prompt
42
- const format = modelManager.getModelMetadata("repl").promptFormat;
43
- let tokenCount = 0;
44
- const tokenCounter = new TokenCounter();
45
- await Promise.all(workingFiles.map(async (filePath) => {
46
- try {
47
- const content = await readFile(filePath, "utf-8");
48
- const formattedFile = formatFile(filePath, content, format);
49
- tokenCount += tokenCounter.count(formattedFile);
50
- promptManager.addContext(formattedFile);
51
- }
52
- catch (error) {
53
- terminal.error(`Error reading file ${filePath}: ${error.message}`);
54
- }
55
- }));
56
- tokenCounter.free();
57
- terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
58
- return "continue";
59
- }
60
- catch (error) {
61
- terminal.error(`Error processing file patterns: ${error.message}`);
62
- return "continue";
63
- }
64
- },
65
12
  async handle(args, { tui, container, editor, }) {
66
13
  try {
67
14
  let workingFiles = [];
@@ -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":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuC9D,eAAO,MAAM,oBAAoB,GAAI,mEAMlC,cAAc,KAAG,WA6JnB,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"}