@travisennis/acai 0.0.3 → 0.0.5

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 (316) hide show
  1. package/README.md +225 -6
  2. package/dist/api/exa/index.d.ts +177 -0
  3. package/dist/api/exa/index.d.ts.map +1 -0
  4. package/dist/api/exa/index.js +439 -0
  5. package/dist/cli.d.ts +3 -2
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/commands/application-log-command.d.ts +1 -0
  8. package/dist/commands/application-log-command.d.ts.map +1 -0
  9. package/dist/commands/application-log-command.js +5 -3
  10. package/dist/commands/clear-command.d.ts +1 -0
  11. package/dist/commands/clear-command.d.ts.map +1 -0
  12. package/dist/commands/clear-command.js +2 -3
  13. package/dist/commands/compact-command.d.ts +1 -0
  14. package/dist/commands/compact-command.d.ts.map +1 -0
  15. package/dist/commands/compact-command.js +1 -1
  16. package/dist/commands/copy-command.d.ts +1 -0
  17. package/dist/commands/copy-command.d.ts.map +1 -0
  18. package/dist/commands/copy-command.js +3 -2
  19. package/dist/commands/edit-command.d.ts +1 -0
  20. package/dist/commands/edit-command.d.ts.map +1 -0
  21. package/dist/commands/edit-command.js +7 -5
  22. package/dist/commands/edit-prompt-command.d.ts +2 -1
  23. package/dist/commands/edit-prompt-command.d.ts.map +1 -0
  24. package/dist/commands/edit-prompt-command.js +15 -7
  25. package/dist/commands/exit-command.d.ts +13 -2
  26. package/dist/commands/exit-command.d.ts.map +1 -0
  27. package/dist/commands/exit-command.js +14 -2
  28. package/dist/commands/files-command.d.ts +1 -0
  29. package/dist/commands/files-command.d.ts.map +1 -0
  30. package/dist/commands/files-command.js +9 -8
  31. package/dist/commands/generate-rules-command.d.ts +1 -0
  32. package/dist/commands/generate-rules-command.d.ts.map +1 -0
  33. package/dist/commands/generate-rules-command.js +4 -3
  34. package/dist/commands/health-command.d.ts +3 -1
  35. package/dist/commands/health-command.d.ts.map +1 -0
  36. package/dist/commands/health-command.js +42 -5
  37. package/dist/commands/help-command.d.ts +1 -0
  38. package/dist/commands/help-command.d.ts.map +1 -0
  39. package/dist/commands/help-command.js +2 -3
  40. package/dist/commands/init-command.d.ts +1 -0
  41. package/dist/commands/init-command.d.ts.map +1 -0
  42. package/dist/commands/init-command.js +1 -2
  43. package/dist/commands/last-log-command.d.ts +1 -0
  44. package/dist/commands/last-log-command.d.ts.map +1 -0
  45. package/dist/commands/last-log-command.js +12 -17
  46. package/dist/commands/list-tools-command.d.ts +3 -0
  47. package/dist/commands/list-tools-command.d.ts.map +1 -0
  48. package/dist/commands/list-tools-command.js +61 -0
  49. package/dist/commands/manager.d.ts +7 -2
  50. package/dist/commands/manager.d.ts.map +1 -0
  51. package/dist/commands/manager.js +43 -6
  52. package/dist/commands/model-command.d.ts +1 -0
  53. package/dist/commands/model-command.d.ts.map +1 -0
  54. package/dist/commands/model-command.js +5 -5
  55. package/dist/commands/paste-command.d.ts +1 -0
  56. package/dist/commands/paste-command.d.ts.map +1 -0
  57. package/dist/commands/paste-command.js +6 -5
  58. package/dist/commands/prompt-command.d.ts +2 -1
  59. package/dist/commands/prompt-command.d.ts.map +1 -0
  60. package/dist/commands/prompt-command.js +62 -8
  61. package/dist/commands/reset-command.d.ts +1 -0
  62. package/dist/commands/reset-command.d.ts.map +1 -0
  63. package/dist/commands/reset-command.js +1 -1
  64. package/dist/commands/rules-command.d.ts +1 -0
  65. package/dist/commands/rules-command.d.ts.map +1 -0
  66. package/dist/commands/rules-command.js +5 -3
  67. package/dist/commands/save-command.d.ts +1 -0
  68. package/dist/commands/save-command.d.ts.map +1 -0
  69. package/dist/commands/save-command.js +1 -1
  70. package/dist/commands/shell-command.d.ts +3 -0
  71. package/dist/commands/shell-command.d.ts.map +1 -0
  72. package/dist/commands/shell-command.js +60 -0
  73. package/dist/commands/types.d.ts +9 -6
  74. package/dist/commands/types.d.ts.map +1 -0
  75. package/dist/commands/usage-command.d.ts +1 -0
  76. package/dist/commands/usage-command.d.ts.map +1 -0
  77. package/dist/commands/usage-command.js +2 -3
  78. package/dist/config.d.ts +22 -34
  79. package/dist/config.d.ts.map +1 -0
  80. package/dist/config.js +61 -15
  81. package/dist/conversation-analyzer.d.ts +2 -1
  82. package/dist/conversation-analyzer.d.ts.map +1 -0
  83. package/dist/dedent.d.ts +1 -0
  84. package/dist/dedent.d.ts.map +1 -0
  85. package/dist/execution/index.d.ts +112 -0
  86. package/dist/execution/index.d.ts.map +1 -0
  87. package/dist/execution/index.js +432 -0
  88. package/dist/formatting.d.ts +2 -13
  89. package/dist/formatting.d.ts.map +1 -0
  90. package/dist/formatting.js +5 -64
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +14 -4
  94. package/dist/logger.d.ts +1 -0
  95. package/dist/logger.d.ts.map +1 -0
  96. package/dist/mentions.d.ts +4 -0
  97. package/dist/mentions.d.ts.map +1 -0
  98. package/dist/mentions.js +42 -10
  99. package/dist/messages.d.ts +8 -20
  100. package/dist/messages.d.ts.map +1 -0
  101. package/dist/messages.js +33 -53
  102. package/dist/middleware/audit-message.d.ts +1 -0
  103. package/dist/middleware/audit-message.d.ts.map +1 -0
  104. package/dist/middleware/index.d.ts +1 -0
  105. package/dist/middleware/index.d.ts.map +1 -0
  106. package/dist/middleware/rate-limit.d.ts +1 -0
  107. package/dist/middleware/rate-limit.d.ts.map +1 -0
  108. package/dist/models/ai-config.d.ts +1 -0
  109. package/dist/models/ai-config.d.ts.map +1 -0
  110. package/dist/models/anthropic-provider.d.ts +1 -0
  111. package/dist/models/anthropic-provider.d.ts.map +1 -0
  112. package/dist/models/deepseek-provider.d.ts +1 -0
  113. package/dist/models/deepseek-provider.d.ts.map +1 -0
  114. package/dist/models/google-provider.d.ts +1 -0
  115. package/dist/models/google-provider.d.ts.map +1 -0
  116. package/dist/models/groq-provider.d.ts +20 -0
  117. package/dist/models/groq-provider.d.ts.map +1 -0
  118. package/dist/models/groq-provider.js +31 -0
  119. package/dist/models/manager.d.ts +1 -0
  120. package/dist/models/manager.d.ts.map +1 -0
  121. package/dist/models/openai-provider.d.ts +2 -1
  122. package/dist/models/openai-provider.d.ts.map +1 -0
  123. package/dist/models/openrouter-provider.d.ts +31 -22
  124. package/dist/models/openrouter-provider.d.ts.map +1 -0
  125. package/dist/models/openrouter-provider.js +115 -1
  126. package/dist/models/providers.d.ts +4 -5
  127. package/dist/models/providers.d.ts.map +1 -0
  128. package/dist/models/providers.js +7 -3
  129. package/dist/models/xai-provider.d.ts +1 -0
  130. package/dist/models/xai-provider.d.ts.map +1 -0
  131. package/dist/parsing.d.ts +2 -1
  132. package/dist/parsing.d.ts.map +1 -0
  133. package/dist/prompts/manager.d.ts +14 -2
  134. package/dist/prompts/manager.d.ts.map +1 -0
  135. package/dist/prompts.d.ts +1 -0
  136. package/dist/prompts.d.ts.map +1 -0
  137. package/dist/prompts.js +17 -11
  138. package/dist/repl/display-tool-messages.d.ts +4 -0
  139. package/dist/repl/display-tool-messages.d.ts.map +1 -0
  140. package/dist/repl/display-tool-messages.js +55 -0
  141. package/dist/repl/display-tool-use.d.ts +14 -0
  142. package/dist/repl/display-tool-use.d.ts.map +1 -0
  143. package/dist/repl/display-tool-use.js +63 -0
  144. package/dist/repl/get-prompt-header.d.ts +8 -0
  145. package/dist/repl/get-prompt-header.d.ts.map +1 -0
  146. package/dist/repl/get-prompt-header.js +38 -0
  147. package/dist/repl/tool-call-repair.d.ts +4 -0
  148. package/dist/repl/tool-call-repair.d.ts.map +1 -0
  149. package/dist/repl/tool-call-repair.js +50 -0
  150. package/dist/repl-prompt.d.ts +1 -0
  151. package/dist/repl-prompt.d.ts.map +1 -0
  152. package/dist/repl.d.ts +8 -4
  153. package/dist/repl.d.ts.map +1 -0
  154. package/dist/repl.js +108 -252
  155. package/dist/terminal/ansi-styles.d.ts +77 -0
  156. package/dist/terminal/ansi-styles.d.ts.map +1 -0
  157. package/dist/terminal/ansi-styles.js +215 -0
  158. package/dist/terminal/checkbox-prompt.d.ts +36 -0
  159. package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
  160. package/dist/terminal/checkbox-prompt.js +362 -0
  161. package/dist/terminal/default-theme.d.ts +6 -0
  162. package/dist/terminal/default-theme.d.ts.map +1 -0
  163. package/dist/terminal/default-theme.js +182 -0
  164. package/dist/terminal/east-asian-width.d.ts +8 -0
  165. package/dist/terminal/east-asian-width.d.ts.map +1 -0
  166. package/dist/terminal/east-asian-width.js +409 -0
  167. package/dist/terminal/editor-prompt.d.ts +10 -0
  168. package/dist/terminal/editor-prompt.d.ts.map +1 -0
  169. package/dist/terminal/editor-prompt.js +61 -0
  170. package/dist/terminal/errors.d.ts +19 -0
  171. package/dist/terminal/errors.d.ts.map +1 -0
  172. package/dist/terminal/errors.js +37 -0
  173. package/dist/terminal/formatting.d.ts +1 -11
  174. package/dist/terminal/formatting.d.ts.map +1 -0
  175. package/dist/terminal/formatting.js +4 -20
  176. package/dist/terminal/highlight/index.d.ts +53 -0
  177. package/dist/terminal/highlight/index.d.ts.map +1 -0
  178. package/dist/terminal/highlight/index.js +90 -0
  179. package/dist/terminal/highlight/theme.d.ts +233 -0
  180. package/dist/terminal/highlight/theme.d.ts.map +1 -0
  181. package/dist/terminal/highlight/theme.js +83 -0
  182. package/dist/terminal/index.d.ts +16 -9
  183. package/dist/terminal/index.d.ts.map +1 -0
  184. package/dist/terminal/index.js +42 -126
  185. package/dist/terminal/input-prompt.d.ts +16 -0
  186. package/dist/terminal/input-prompt.d.ts.map +1 -0
  187. package/dist/terminal/input-prompt.js +181 -0
  188. package/dist/terminal/markdown-utils.d.ts +1 -0
  189. package/dist/terminal/markdown-utils.d.ts.map +1 -0
  190. package/dist/terminal/markdown.d.ts +1 -0
  191. package/dist/terminal/markdown.d.ts.map +1 -0
  192. package/dist/terminal/markdown.js +17 -12
  193. package/dist/terminal/search-prompt.d.ts +20 -0
  194. package/dist/terminal/search-prompt.d.ts.map +1 -0
  195. package/dist/terminal/search-prompt.js +279 -0
  196. package/dist/terminal/select-prompt.d.ts +26 -0
  197. package/dist/terminal/select-prompt.d.ts.map +1 -0
  198. package/dist/terminal/select-prompt.js +298 -0
  199. package/dist/terminal/string-width.d.ts +7 -0
  200. package/dist/terminal/string-width.d.ts.map +1 -0
  201. package/dist/terminal/string-width.js +61 -0
  202. package/dist/terminal/strip-ansi.d.ts +2 -0
  203. package/dist/terminal/strip-ansi.d.ts.map +1 -0
  204. package/dist/terminal/strip-ansi.js +20 -0
  205. package/dist/terminal/style.d.ts +191 -0
  206. package/dist/terminal/style.d.ts.map +1 -0
  207. package/dist/terminal/style.js +259 -0
  208. package/dist/terminal/supports-color.d.ts +1 -0
  209. package/dist/terminal/supports-color.d.ts.map +1 -0
  210. package/dist/terminal/supports-hyperlinks.d.ts +1 -3
  211. package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
  212. package/dist/terminal/supports-hyperlinks.js +1 -1
  213. package/dist/terminal/types.d.ts +1 -37
  214. package/dist/terminal/types.d.ts.map +1 -0
  215. package/dist/terminal/wrap-ansi.d.ts +8 -0
  216. package/dist/terminal/wrap-ansi.d.ts.map +1 -0
  217. package/dist/terminal/wrap-ansi.js +190 -0
  218. package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
  219. package/dist/tokens/counter.d.ts.map +1 -0
  220. package/dist/{token-utils.js → tokens/counter.js} +1 -1
  221. package/dist/tokens/manage-output.d.ts +34 -0
  222. package/dist/tokens/manage-output.d.ts.map +1 -0
  223. package/dist/tokens/manage-output.js +44 -0
  224. package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
  225. package/dist/tokens/tracker.d.ts.map +1 -0
  226. package/dist/tool-executor.d.ts +28 -0
  227. package/dist/tool-executor.d.ts.map +1 -0
  228. package/dist/tool-executor.js +74 -0
  229. package/dist/tools/agent.d.ts +3 -2
  230. package/dist/tools/agent.d.ts.map +1 -0
  231. package/dist/tools/agent.js +7 -4
  232. package/dist/tools/bash-utils.d.ts +7 -0
  233. package/dist/tools/bash-utils.d.ts.map +1 -0
  234. package/dist/tools/bash-utils.js +212 -0
  235. package/dist/tools/bash.d.ts +9 -7
  236. package/dist/tools/bash.d.ts.map +1 -0
  237. package/dist/tools/bash.js +95 -212
  238. package/dist/tools/code-interpreter.d.ts +1 -0
  239. package/dist/tools/code-interpreter.d.ts.map +1 -0
  240. package/dist/tools/code-interpreter.js +33 -8
  241. package/dist/tools/delete-file.d.ts +5 -3
  242. package/dist/tools/delete-file.d.ts.map +1 -0
  243. package/dist/tools/delete-file.js +47 -33
  244. package/dist/tools/directory-tree.d.ts +10 -1
  245. package/dist/tools/directory-tree.d.ts.map +1 -0
  246. package/dist/tools/directory-tree.js +91 -8
  247. package/dist/tools/dynamic-tool-loader.d.ts +12 -0
  248. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
  249. package/dist/tools/dynamic-tool-loader.js +280 -0
  250. package/dist/tools/dynamic-tool-parser.d.ts +20 -0
  251. package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
  252. package/dist/tools/dynamic-tool-parser.js +21 -0
  253. package/dist/tools/edit-file.d.ts +10 -2
  254. package/dist/tools/edit-file.d.ts.map +1 -0
  255. package/dist/tools/edit-file.js +117 -40
  256. package/dist/tools/file-editing-utils.d.ts +2 -0
  257. package/dist/tools/file-editing-utils.d.ts.map +1 -0
  258. package/dist/tools/file-editing-utils.js +135 -0
  259. package/dist/tools/filesystem-utils.d.ts +6 -21
  260. package/dist/tools/filesystem-utils.d.ts.map +1 -0
  261. package/dist/tools/filesystem-utils.js +96 -148
  262. package/dist/tools/git-utils.d.ts +1 -0
  263. package/dist/tools/git-utils.d.ts.map +1 -0
  264. package/dist/tools/grep.d.ts +5 -3
  265. package/dist/tools/grep.d.ts.map +1 -0
  266. package/dist/tools/grep.js +67 -27
  267. package/dist/tools/index.d.ts +10 -14
  268. package/dist/tools/index.d.ts.map +1 -0
  269. package/dist/tools/index.js +33 -22
  270. package/dist/tools/move-file.d.ts +1 -0
  271. package/dist/tools/move-file.d.ts.map +1 -0
  272. package/dist/tools/move-file.js +12 -5
  273. package/dist/tools/read-file.d.ts +2 -1
  274. package/dist/tools/read-file.d.ts.map +1 -0
  275. package/dist/tools/read-file.js +13 -6
  276. package/dist/tools/read-multiple-files.d.ts +2 -1
  277. package/dist/tools/read-multiple-files.d.ts.map +1 -0
  278. package/dist/tools/read-multiple-files.js +90 -9
  279. package/dist/tools/save-file.d.ts +5 -3
  280. package/dist/tools/save-file.d.ts.map +1 -0
  281. package/dist/tools/save-file.js +64 -36
  282. package/dist/tools/think.d.ts +1 -0
  283. package/dist/tools/think.d.ts.map +1 -0
  284. package/dist/tools/think.js +5 -1
  285. package/dist/tools/types.d.ts +14 -1
  286. package/dist/tools/types.d.ts.map +1 -0
  287. package/dist/tools/web-fetch.d.ts +4 -2
  288. package/dist/tools/web-fetch.d.ts.map +1 -0
  289. package/dist/tools/web-fetch.js +2 -2
  290. package/dist/tools/web-search.d.ts +2 -1
  291. package/dist/tools/web-search.d.ts.map +1 -0
  292. package/dist/tools/web-search.js +46 -11
  293. package/dist/utils/filesystem.d.ts +23 -0
  294. package/dist/utils/filesystem.d.ts.map +1 -0
  295. package/dist/utils/filesystem.js +140 -0
  296. package/dist/utils/filetype-detection.d.ts +3 -0
  297. package/dist/utils/filetype-detection.d.ts.map +1 -0
  298. package/dist/utils/filetype-detection.js +112 -0
  299. package/dist/utils/glob.d.ts +52 -0
  300. package/dist/utils/glob.d.ts.map +1 -0
  301. package/dist/utils/glob.js +376 -0
  302. package/dist/utils/ignore.d.ts +104 -0
  303. package/dist/utils/ignore.d.ts.map +1 -0
  304. package/dist/utils/ignore.js +649 -0
  305. package/dist/utils/process.d.ts +10 -1
  306. package/dist/utils/process.d.ts.map +1 -0
  307. package/dist/utils/process.js +104 -5
  308. package/dist/utils/zod-utils.d.ts +4 -0
  309. package/dist/utils/zod-utils.d.ts.map +1 -0
  310. package/dist/utils/zod-utils.js +7 -0
  311. package/dist/version.d.ts +1 -0
  312. package/dist/version.d.ts.map +1 -0
  313. package/package.json +32 -30
  314. package/dist/tools/command-validation.d.ts +0 -12
  315. package/dist/tools/command-validation.js +0 -113
  316. /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
@@ -3,6 +3,81 @@ import { isUndefined } from "@travisennis/stdlib/typeguards";
3
3
  const MS_IN_SECOND = 1000;
4
4
  const SECONDS_IN_MINUTE = 60;
5
5
  const DEFAULT_TIMEOUT = 2 * SECONDS_IN_MINUTE * MS_IN_SECOND;
6
+ // Quote/escape-aware argv tokenizer that forbids command substitution
7
+ export function parseArgv(input) {
8
+ const argv = [];
9
+ let buf = "";
10
+ let i = 0;
11
+ const n = input.length;
12
+ let inSingle = false;
13
+ let inDouble = false;
14
+ while (i < n) {
15
+ const ch = input[i] ?? "";
16
+ // Reject shell-only constructs early
17
+ if (ch === "`")
18
+ return { ok: false, error: "Backticks are not allowed" };
19
+ if (ch === "$" && i + 1 < n && input[i + 1] === "(") {
20
+ return { ok: false, error: "Command substitution $() is not allowed" };
21
+ }
22
+ if (!inSingle && !inDouble && /\s/.test(ch)) {
23
+ if (buf.length > 0) {
24
+ argv.push(buf);
25
+ buf = "";
26
+ }
27
+ i += 1;
28
+ continue;
29
+ }
30
+ if (!inDouble && ch === "'" && !inSingle) {
31
+ inSingle = true;
32
+ i += 1;
33
+ continue;
34
+ }
35
+ if (inSingle && ch === "'") {
36
+ inSingle = false;
37
+ i += 1;
38
+ continue;
39
+ }
40
+ if (!inSingle && ch === '"' && !inDouble) {
41
+ inDouble = true;
42
+ i += 1;
43
+ continue;
44
+ }
45
+ if (inDouble && ch === '"') {
46
+ inDouble = false;
47
+ i += 1;
48
+ continue;
49
+ }
50
+ if (!inSingle && ch === "\\") {
51
+ i += 1;
52
+ if (i >= n)
53
+ return { ok: false, error: "Dangling escape" };
54
+ const next = input[i] ?? "";
55
+ // Inside double quotes, only escape " and \\ reliably
56
+ if (inDouble && next !== '"' && next !== "\\") {
57
+ // Keep backslash literally for safety
58
+ buf += `\\${next}`;
59
+ }
60
+ else {
61
+ buf += next;
62
+ }
63
+ i += 1;
64
+ continue;
65
+ }
66
+ buf += ch;
67
+ i += 1;
68
+ }
69
+ if (inSingle || inDouble)
70
+ return { ok: false, error: "Unterminated quote" };
71
+ if (buf.length > 0)
72
+ argv.push(buf);
73
+ if (argv.length === 0)
74
+ return { ok: false, error: "Empty command" };
75
+ const first = argv[0];
76
+ if (typeof first !== "string" || first.trim() === "") {
77
+ return { ok: false, error: "Missing command" };
78
+ }
79
+ return { ok: true, argv: argv };
80
+ }
6
81
  /**
7
82
  * Executes a command and returns the result, providing unified error handling
8
83
  *
@@ -19,9 +94,18 @@ export function executeCommand(command, options) {
19
94
  [cmd, ...args] = command;
20
95
  }
21
96
  else {
22
- const parts = command.split(" ");
23
- cmd = parts[0] ?? "";
24
- args = parts.slice(1);
97
+ const parsed = parseArgv(command);
98
+ if (!parsed.ok) {
99
+ const result = {
100
+ stdout: "",
101
+ stderr: parsed.error,
102
+ code: 1,
103
+ };
104
+ return throwOnError
105
+ ? Promise.reject(new Error(parsed.error))
106
+ : Promise.resolve(result);
107
+ }
108
+ [cmd, ...args] = parsed.argv;
25
109
  }
26
110
  if (isUndefined(cmd) || cmd.trim() === "") {
27
111
  const result = {
@@ -33,6 +117,16 @@ export function executeCommand(command, options) {
33
117
  ? Promise.reject(new Error("Missing command"))
34
118
  : Promise.resolve(result);
35
119
  }
120
+ if (abortSignal?.aborted) {
121
+ const result = {
122
+ stdout: "",
123
+ stderr: "Command execution aborted",
124
+ code: 130,
125
+ };
126
+ return throwOnError
127
+ ? Promise.reject(new Error("Command execution aborted"))
128
+ : Promise.resolve(result);
129
+ }
36
130
  return new Promise((resolve, reject) => {
37
131
  try {
38
132
  execFile(cmd, args, {
@@ -43,12 +137,17 @@ export function executeCommand(command, options) {
43
137
  maxBuffer,
44
138
  }, (error, stdout, stderr) => {
45
139
  if (error) {
46
- const errorCode = typeof error.code === "number" ? error.code : 1;
140
+ let errorCode = typeof error.code === "number" ? error.code : 1;
141
+ let errorSignal = error.signal ?? undefined;
142
+ if (error.name === "AbortError") {
143
+ errorCode = 130;
144
+ errorSignal = "SIGINT";
145
+ }
47
146
  const result = {
48
147
  stdout: preserveOutputOnError ? stdout : "",
49
148
  stderr: preserveOutputOnError ? stderr : "",
50
149
  code: errorCode,
51
- signal: error.signal ?? undefined,
150
+ signal: errorSignal,
52
151
  };
53
152
  if (throwOnError) {
54
153
  reject(Object.assign(error, { result }));
@@ -0,0 +1,4 @@
1
+ import { ZodType } from "zod";
2
+ export declare function isZodSchema(obj: unknown): obj is ZodType<unknown>;
3
+ export declare function zodToJsonSchema(schema: ZodType<unknown>): Record<string, unknown>;
4
+ //# sourceMappingURL=zod-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-utils.d.ts","sourceRoot":"","sources":["../../source/utils/zod-utils.ts"],"names":[],"mappings":"AAAA,OAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEjC,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAEjE;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GACvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
@@ -0,0 +1,7 @@
1
+ import z, { ZodType } from "zod";
2
+ export function isZodSchema(obj) {
3
+ return obj instanceof ZodType;
4
+ }
5
+ export function zodToJsonSchema(schema) {
6
+ return z.toJSONSchema(schema);
7
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export declare function getPackageVersion(fallback?: string): string;
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../source/version.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,QAAQ,SAAgB,GAAG,MAAM,CAiBlE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travisennis/acai",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "An AI assistant for developing software.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "license": "MIT",
26
26
  "scripts": {
27
27
  "build": "tsc --pretty -p tsconfig.build.json",
28
- "clean": "rm -rf ./dist/ ./tsconfig.build.tsbuildinfo",
28
+ "clean": "rm -rf ./dist/ ./coverage/ ./tsconfig.build.tsbuildinfo",
29
29
  "compile": "tsc --pretty -p tsconfig.json",
30
30
  "lint": "biome lint",
31
31
  "lint:fix": "biome lint --unsafe --write",
@@ -33,56 +33,58 @@
33
33
  "format:staged": "biome check --staged --formatter-enabled=true --linter-enabled=false --no-errors-on-unmatched",
34
34
  "prepack": "npm run clean && npm run build",
35
35
  "prepare": "husky",
36
- "test": "c8 node --no-warnings --test test/**/*.test.ts",
37
- "pretest": "npm run compile",
36
+ "test": "node --no-warnings --test test/**/*.test.ts",
37
+ "test:minimal": "node --no-warnings --test --test-reporter=dot test/**/*.test.ts",
38
+ "test:coverage": "c8 node --no-warnings --test test/**/*.test.ts",
39
+ "test:full-coverage": "c8 --all node --no-warnings --test test/**/*.test.ts",
40
+ "pretest": "npm run typecheck",
38
41
  "format": "biome check --formatter-enabled=true --linter-enabled=false --write ./ && biome format --write",
39
42
  "dev": "node --no-warnings --env-file=.env ./source/index.ts",
40
43
  "oxlint": "npx oxlint@latest --ignore-path .gitignore --deny correctness --deny suspicous --deny pedantic --deny style --node-plugin",
41
44
  "knip": "npx knip",
42
45
  "check": "npx npm-check-updates --interactive --format group",
43
46
  "cpd": "npx jscpd ./source",
44
- "typecheck:staged": "tsc --noEmit --pretty -p tsconfig.json"
47
+ "typecheck": "tsc --noEmit --pretty -p tsconfig.json",
48
+ "typecheck:staged": "npm run typecheck"
45
49
  },
46
50
  "dependencies": {
47
- "@ai-sdk/anthropic": "^2.0.6",
48
- "@ai-sdk/deepseek": "^1.0.11",
49
- "@ai-sdk/google": "^2.0.8",
50
- "@ai-sdk/openai": "^2.0.20",
51
- "@ai-sdk/openai-compatible": "^1.0.11",
51
+ "@ai-sdk/anthropic": "^2.0.25",
52
+ "@ai-sdk/deepseek": "^1.0.21",
53
+ "@ai-sdk/google": "^2.0.18",
54
+ "@ai-sdk/groq": "^2.0.23",
55
+ "@ai-sdk/openai": "^2.0.46",
56
+ "@ai-sdk/openai-compatible": "^1.0.20",
52
57
  "@crosscopy/clipboard": "^0.2.8",
53
- "@inquirer/prompts": "^7.8.4",
58
+ "@openrouter/ai-sdk-provider": "^1.2.0",
54
59
  "@travisennis/stdlib": "^0.0.14",
55
- "ai": "^5.0.23",
56
- "chalk": "^5.6.0",
60
+ "ai": "^5.0.64",
57
61
  "cheerio": "^1.1.2",
58
- "cli-highlight": "^2.1.11",
59
62
  "cli-table3": "^0.6.5",
60
63
  "diff": "^8.0.2",
61
64
  "duck-duck-scrape": "^2.2.7",
62
- "exa-js": "^1.9.2",
63
- "globby": "^14.1.0",
64
- "ignore": "^7.0.5",
65
- "log-update": "^6.1.0",
66
- "marked": "16.2.0",
67
- "ora": "^8.2.0",
65
+ "fast-glob": "^3.3.3",
66
+ "highlight.js": "^11.11.1",
67
+ "jsonrepair": "^3.13.1",
68
+ "marked": "16.4.0",
68
69
  "p-throttle": "^8.0.0",
69
- "pino": "^9.9.0",
70
+ "parse5": "^8.0.0",
71
+ "parse5-htmlparser2-tree-adapter": "^8.0.0",
72
+ "pino": "^10.0.0",
70
73
  "pino-pretty": "^13.1.1",
71
- "pino-roll": "^3.1.0",
74
+ "pino-roll": "^4.0.0",
72
75
  "tiktoken": "^1.0.22",
73
- "wrap-ansi": "^9.0.0",
74
- "zod": "^3.25.75"
76
+ "zod": "^4.1.12"
75
77
  },
76
78
  "devDependencies": {
77
79
  "@ai-sdk/provider": "^2.0.0",
78
- "@biomejs/biome": "2.2.2",
79
- "@commitlint/config-conventional": "^19.8.1",
80
- "@types/node": "^24.3.0",
81
- "@types/node-notifier": "^8.0.5",
80
+ "@biomejs/biome": "2.2.5",
81
+ "@commitlint/config-conventional": "^20.0.0",
82
+ "@types/node": "^24.7.1",
82
83
  "c8": "^10.1.3",
83
- "commitlint": "^19.8.1",
84
+ "commitlint": "^20.1.0",
85
+ "domhandler": "^5.0.3",
84
86
  "husky": "^9.1.7",
85
- "typescript": "^5.9.2"
87
+ "typescript": "^5.9.3"
86
88
  },
87
89
  "engines": {
88
90
  "node": ">=20"
@@ -1,12 +0,0 @@
1
- export declare class CommandValidation {
2
- private readonly allowedCommands;
3
- private readonly dangerousPatterns;
4
- constructor(allowedCommands: string[]);
5
- private isCommandAllowed;
6
- private hasDangerousPatterns;
7
- isValid(command: string): {
8
- isValid: boolean;
9
- error?: string;
10
- };
11
- private splitOnPipes;
12
- }
@@ -1,113 +0,0 @@
1
- export class CommandValidation {
2
- allowedCommands;
3
- dangerousPatterns;
4
- constructor(allowedCommands) {
5
- this.allowedCommands = allowedCommands;
6
- // Only block truly dangerous patterns, not useful shell operations
7
- this.dangerousPatterns = [
8
- /`/, // backticks (command substitution)
9
- /\$\(/, // $() command substitution
10
- /&&\s*rm\s+-rf/, // dangerous rm chains
11
- /;\s*rm\s+-rf/, // dangerous rm chains
12
- ];
13
- }
14
- isCommandAllowed(command) {
15
- const baseCommand = command.split(" ")[0] || "";
16
- return this.allowedCommands.includes(baseCommand);
17
- }
18
- hasDangerousPatterns(command) {
19
- // Remove all quoted segments first
20
- const stripped = command
21
- .replace(/'([^'\\]|\\.)*'/g, "")
22
- .replace(/"([^"\\]|\\.)*"/g, "");
23
- // Check for dangerous patterns only in unquoted portions
24
- return this.dangerousPatterns.some((re) => re.test(stripped));
25
- }
26
- isValid(command) {
27
- if (!command.trim()) {
28
- return { isValid: false, error: "Command cannot be empty" };
29
- }
30
- // First check for dangerous patterns
31
- if (this.hasDangerousPatterns(command)) {
32
- return {
33
- isValid: false,
34
- error: "Command contains dangerous patterns (command substitution or unsafe rm chains)",
35
- };
36
- }
37
- // Process command while preserving quoted strings to extract sub-commands
38
- const subCommands = [];
39
- let currentSegment = "";
40
- let inSingleQuote = false;
41
- let inDoubleQuote = false;
42
- for (let i = 0; i < command.length; i++) {
43
- const char = command[i];
44
- // Handle quote states
45
- if (char === "'" && !inDoubleQuote)
46
- inSingleQuote = !inSingleQuote;
47
- if (char === '"' && !inSingleQuote)
48
- inDoubleQuote = !inDoubleQuote;
49
- // Split on command separators only when not in quotes
50
- // Note: We allow pipes (|) and redirects (>, <) but split on command separators
51
- if (!inSingleQuote && !inDoubleQuote && (char === "&" || char === ";")) {
52
- if (currentSegment.trim()) {
53
- subCommands.push(currentSegment.trim());
54
- currentSegment = "";
55
- }
56
- // Skip the operator and any subsequent same operators (like &&)
57
- while (i + 1 < command.length &&
58
- ["&", ";"].includes(command[i + 1] ?? "")) {
59
- i++;
60
- }
61
- }
62
- else {
63
- currentSegment += char;
64
- }
65
- }
66
- // Add the last segment
67
- if (currentSegment.trim()) {
68
- subCommands.push(currentSegment.trim());
69
- }
70
- // Validate all sub-commands (but be smart about pipes)
71
- for (const subCmd of subCommands) {
72
- // For piped commands, validate each part of the pipe
73
- const pipeParts = this.splitOnPipes(subCmd);
74
- for (const part of pipeParts) {
75
- const trimmedPart = part.trim();
76
- if (trimmedPart && !this.isCommandAllowed(trimmedPart)) {
77
- const baseCmd = trimmedPart.split(" ")[0] || "";
78
- return {
79
- isValid: false,
80
- error: `Command '${baseCmd}' is not allowed. Allowed commands: ${this.allowedCommands.join(", ")}`,
81
- };
82
- }
83
- }
84
- }
85
- return { isValid: true };
86
- }
87
- splitOnPipes(command) {
88
- const parts = [];
89
- let current = "";
90
- let inSingleQuote = false;
91
- let inDoubleQuote = false;
92
- for (let i = 0; i < command.length; i++) {
93
- const char = command[i];
94
- if (char === "'" && !inDoubleQuote)
95
- inSingleQuote = !inSingleQuote;
96
- if (char === '"' && !inSingleQuote)
97
- inDoubleQuote = !inDoubleQuote;
98
- if (char === "|" && !inSingleQuote && !inDoubleQuote) {
99
- if (current.trim()) {
100
- parts.push(current.trim());
101
- current = "";
102
- }
103
- }
104
- else {
105
- current += char;
106
- }
107
- }
108
- if (current.trim()) {
109
- parts.push(current.trim());
110
- }
111
- return parts;
112
- }
113
- }
File without changes