@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.
- package/README.md +225 -6
- package/dist/api/exa/index.d.ts +177 -0
- package/dist/api/exa/index.d.ts.map +1 -0
- package/dist/api/exa/index.js +439 -0
- package/dist/cli.d.ts +3 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/commands/application-log-command.d.ts +1 -0
- package/dist/commands/application-log-command.d.ts.map +1 -0
- package/dist/commands/application-log-command.js +5 -3
- package/dist/commands/clear-command.d.ts +1 -0
- package/dist/commands/clear-command.d.ts.map +1 -0
- package/dist/commands/clear-command.js +2 -3
- package/dist/commands/compact-command.d.ts +1 -0
- package/dist/commands/compact-command.d.ts.map +1 -0
- package/dist/commands/compact-command.js +1 -1
- package/dist/commands/copy-command.d.ts +1 -0
- package/dist/commands/copy-command.d.ts.map +1 -0
- package/dist/commands/copy-command.js +3 -2
- package/dist/commands/edit-command.d.ts +1 -0
- package/dist/commands/edit-command.d.ts.map +1 -0
- package/dist/commands/edit-command.js +7 -5
- package/dist/commands/edit-prompt-command.d.ts +2 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -0
- package/dist/commands/edit-prompt-command.js +15 -7
- package/dist/commands/exit-command.d.ts +13 -2
- package/dist/commands/exit-command.d.ts.map +1 -0
- package/dist/commands/exit-command.js +14 -2
- package/dist/commands/files-command.d.ts +1 -0
- package/dist/commands/files-command.d.ts.map +1 -0
- package/dist/commands/files-command.js +9 -8
- package/dist/commands/generate-rules-command.d.ts +1 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -0
- package/dist/commands/generate-rules-command.js +4 -3
- package/dist/commands/health-command.d.ts +3 -1
- package/dist/commands/health-command.d.ts.map +1 -0
- package/dist/commands/health-command.js +42 -5
- package/dist/commands/help-command.d.ts +1 -0
- package/dist/commands/help-command.d.ts.map +1 -0
- package/dist/commands/help-command.js +2 -3
- package/dist/commands/init-command.d.ts +1 -0
- package/dist/commands/init-command.d.ts.map +1 -0
- package/dist/commands/init-command.js +1 -2
- package/dist/commands/last-log-command.d.ts +1 -0
- package/dist/commands/last-log-command.d.ts.map +1 -0
- package/dist/commands/last-log-command.js +12 -17
- package/dist/commands/list-tools-command.d.ts +3 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -0
- package/dist/commands/list-tools-command.js +61 -0
- package/dist/commands/manager.d.ts +7 -2
- package/dist/commands/manager.d.ts.map +1 -0
- package/dist/commands/manager.js +43 -6
- package/dist/commands/model-command.d.ts +1 -0
- package/dist/commands/model-command.d.ts.map +1 -0
- package/dist/commands/model-command.js +5 -5
- package/dist/commands/paste-command.d.ts +1 -0
- package/dist/commands/paste-command.d.ts.map +1 -0
- package/dist/commands/paste-command.js +6 -5
- package/dist/commands/prompt-command.d.ts +2 -1
- package/dist/commands/prompt-command.d.ts.map +1 -0
- package/dist/commands/prompt-command.js +62 -8
- package/dist/commands/reset-command.d.ts +1 -0
- package/dist/commands/reset-command.d.ts.map +1 -0
- package/dist/commands/reset-command.js +1 -1
- package/dist/commands/rules-command.d.ts +1 -0
- package/dist/commands/rules-command.d.ts.map +1 -0
- package/dist/commands/rules-command.js +5 -3
- package/dist/commands/save-command.d.ts +1 -0
- package/dist/commands/save-command.d.ts.map +1 -0
- package/dist/commands/save-command.js +1 -1
- package/dist/commands/shell-command.d.ts +3 -0
- package/dist/commands/shell-command.d.ts.map +1 -0
- package/dist/commands/shell-command.js +60 -0
- package/dist/commands/types.d.ts +9 -6
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/usage-command.d.ts +1 -0
- package/dist/commands/usage-command.d.ts.map +1 -0
- package/dist/commands/usage-command.js +2 -3
- package/dist/config.d.ts +22 -34
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +61 -15
- package/dist/conversation-analyzer.d.ts +2 -1
- package/dist/conversation-analyzer.d.ts.map +1 -0
- package/dist/dedent.d.ts +1 -0
- package/dist/dedent.d.ts.map +1 -0
- package/dist/execution/index.d.ts +112 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +432 -0
- package/dist/formatting.d.ts +2 -13
- package/dist/formatting.d.ts.map +1 -0
- package/dist/formatting.js +5 -64
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -4
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/mentions.d.ts +4 -0
- package/dist/mentions.d.ts.map +1 -0
- package/dist/mentions.js +42 -10
- package/dist/messages.d.ts +8 -20
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +33 -53
- package/dist/middleware/audit-message.d.ts +1 -0
- package/dist/middleware/audit-message.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/rate-limit.d.ts +1 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/models/ai-config.d.ts +1 -0
- package/dist/models/ai-config.d.ts.map +1 -0
- package/dist/models/anthropic-provider.d.ts +1 -0
- package/dist/models/anthropic-provider.d.ts.map +1 -0
- package/dist/models/deepseek-provider.d.ts +1 -0
- package/dist/models/deepseek-provider.d.ts.map +1 -0
- package/dist/models/google-provider.d.ts +1 -0
- package/dist/models/google-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.d.ts +20 -0
- package/dist/models/groq-provider.d.ts.map +1 -0
- package/dist/models/groq-provider.js +31 -0
- package/dist/models/manager.d.ts +1 -0
- package/dist/models/manager.d.ts.map +1 -0
- package/dist/models/openai-provider.d.ts +2 -1
- package/dist/models/openai-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.d.ts +31 -22
- package/dist/models/openrouter-provider.d.ts.map +1 -0
- package/dist/models/openrouter-provider.js +115 -1
- package/dist/models/providers.d.ts +4 -5
- package/dist/models/providers.d.ts.map +1 -0
- package/dist/models/providers.js +7 -3
- package/dist/models/xai-provider.d.ts +1 -0
- package/dist/models/xai-provider.d.ts.map +1 -0
- package/dist/parsing.d.ts +2 -1
- package/dist/parsing.d.ts.map +1 -0
- package/dist/prompts/manager.d.ts +14 -2
- package/dist/prompts/manager.d.ts.map +1 -0
- package/dist/prompts.d.ts +1 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +17 -11
- package/dist/repl/display-tool-messages.d.ts +4 -0
- package/dist/repl/display-tool-messages.d.ts.map +1 -0
- package/dist/repl/display-tool-messages.js +55 -0
- package/dist/repl/display-tool-use.d.ts +14 -0
- package/dist/repl/display-tool-use.d.ts.map +1 -0
- package/dist/repl/display-tool-use.js +63 -0
- package/dist/repl/get-prompt-header.d.ts +8 -0
- package/dist/repl/get-prompt-header.d.ts.map +1 -0
- package/dist/repl/get-prompt-header.js +38 -0
- package/dist/repl/tool-call-repair.d.ts +4 -0
- package/dist/repl/tool-call-repair.d.ts.map +1 -0
- package/dist/repl/tool-call-repair.js +50 -0
- package/dist/repl-prompt.d.ts +1 -0
- package/dist/repl-prompt.d.ts.map +1 -0
- package/dist/repl.d.ts +8 -4
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +108 -252
- package/dist/terminal/ansi-styles.d.ts +77 -0
- package/dist/terminal/ansi-styles.d.ts.map +1 -0
- package/dist/terminal/ansi-styles.js +215 -0
- package/dist/terminal/checkbox-prompt.d.ts +36 -0
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -0
- package/dist/terminal/checkbox-prompt.js +362 -0
- package/dist/terminal/default-theme.d.ts +6 -0
- package/dist/terminal/default-theme.d.ts.map +1 -0
- package/dist/terminal/default-theme.js +182 -0
- package/dist/terminal/east-asian-width.d.ts +8 -0
- package/dist/terminal/east-asian-width.d.ts.map +1 -0
- package/dist/terminal/east-asian-width.js +409 -0
- package/dist/terminal/editor-prompt.d.ts +10 -0
- package/dist/terminal/editor-prompt.d.ts.map +1 -0
- package/dist/terminal/editor-prompt.js +61 -0
- package/dist/terminal/errors.d.ts +19 -0
- package/dist/terminal/errors.d.ts.map +1 -0
- package/dist/terminal/errors.js +37 -0
- package/dist/terminal/formatting.d.ts +1 -11
- package/dist/terminal/formatting.d.ts.map +1 -0
- package/dist/terminal/formatting.js +4 -20
- package/dist/terminal/highlight/index.d.ts +53 -0
- package/dist/terminal/highlight/index.d.ts.map +1 -0
- package/dist/terminal/highlight/index.js +90 -0
- package/dist/terminal/highlight/theme.d.ts +233 -0
- package/dist/terminal/highlight/theme.d.ts.map +1 -0
- package/dist/terminal/highlight/theme.js +83 -0
- package/dist/terminal/index.d.ts +16 -9
- package/dist/terminal/index.d.ts.map +1 -0
- package/dist/terminal/index.js +42 -126
- package/dist/terminal/input-prompt.d.ts +16 -0
- package/dist/terminal/input-prompt.d.ts.map +1 -0
- package/dist/terminal/input-prompt.js +181 -0
- package/dist/terminal/markdown-utils.d.ts +1 -0
- package/dist/terminal/markdown-utils.d.ts.map +1 -0
- package/dist/terminal/markdown.d.ts +1 -0
- package/dist/terminal/markdown.d.ts.map +1 -0
- package/dist/terminal/markdown.js +17 -12
- package/dist/terminal/search-prompt.d.ts +20 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -0
- package/dist/terminal/search-prompt.js +279 -0
- package/dist/terminal/select-prompt.d.ts +26 -0
- package/dist/terminal/select-prompt.d.ts.map +1 -0
- package/dist/terminal/select-prompt.js +298 -0
- package/dist/terminal/string-width.d.ts +7 -0
- package/dist/terminal/string-width.d.ts.map +1 -0
- package/dist/terminal/string-width.js +61 -0
- package/dist/terminal/strip-ansi.d.ts +2 -0
- package/dist/terminal/strip-ansi.d.ts.map +1 -0
- package/dist/terminal/strip-ansi.js +20 -0
- package/dist/terminal/style.d.ts +191 -0
- package/dist/terminal/style.d.ts.map +1 -0
- package/dist/terminal/style.js +259 -0
- package/dist/terminal/supports-color.d.ts +1 -0
- package/dist/terminal/supports-color.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.d.ts +1 -3
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -0
- package/dist/terminal/supports-hyperlinks.js +1 -1
- package/dist/terminal/types.d.ts +1 -37
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.d.ts +8 -0
- package/dist/terminal/wrap-ansi.d.ts.map +1 -0
- package/dist/terminal/wrap-ansi.js +190 -0
- package/dist/{token-utils.d.ts → tokens/counter.d.ts} +1 -0
- package/dist/tokens/counter.d.ts.map +1 -0
- package/dist/{token-utils.js → tokens/counter.js} +1 -1
- package/dist/tokens/manage-output.d.ts +34 -0
- package/dist/tokens/manage-output.d.ts.map +1 -0
- package/dist/tokens/manage-output.js +44 -0
- package/dist/{token-tracker.d.ts → tokens/tracker.d.ts} +1 -0
- package/dist/tokens/tracker.d.ts.map +1 -0
- package/dist/tool-executor.d.ts +28 -0
- package/dist/tool-executor.d.ts.map +1 -0
- package/dist/tool-executor.js +74 -0
- package/dist/tools/agent.d.ts +3 -2
- package/dist/tools/agent.d.ts.map +1 -0
- package/dist/tools/agent.js +7 -4
- package/dist/tools/bash-utils.d.ts +7 -0
- package/dist/tools/bash-utils.d.ts.map +1 -0
- package/dist/tools/bash-utils.js +212 -0
- package/dist/tools/bash.d.ts +9 -7
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +95 -212
- package/dist/tools/code-interpreter.d.ts +1 -0
- package/dist/tools/code-interpreter.d.ts.map +1 -0
- package/dist/tools/code-interpreter.js +33 -8
- package/dist/tools/delete-file.d.ts +5 -3
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +47 -33
- package/dist/tools/directory-tree.d.ts +10 -1
- package/dist/tools/directory-tree.d.ts.map +1 -0
- package/dist/tools/directory-tree.js +91 -8
- package/dist/tools/dynamic-tool-loader.d.ts +12 -0
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-loader.js +280 -0
- package/dist/tools/dynamic-tool-parser.d.ts +20 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -0
- package/dist/tools/dynamic-tool-parser.js +21 -0
- package/dist/tools/edit-file.d.ts +10 -2
- package/dist/tools/edit-file.d.ts.map +1 -0
- package/dist/tools/edit-file.js +117 -40
- package/dist/tools/file-editing-utils.d.ts +2 -0
- package/dist/tools/file-editing-utils.d.ts.map +1 -0
- package/dist/tools/file-editing-utils.js +135 -0
- package/dist/tools/filesystem-utils.d.ts +6 -21
- package/dist/tools/filesystem-utils.d.ts.map +1 -0
- package/dist/tools/filesystem-utils.js +96 -148
- package/dist/tools/git-utils.d.ts +1 -0
- package/dist/tools/git-utils.d.ts.map +1 -0
- package/dist/tools/grep.d.ts +5 -3
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +67 -27
- package/dist/tools/index.d.ts +10 -14
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +33 -22
- package/dist/tools/move-file.d.ts +1 -0
- package/dist/tools/move-file.d.ts.map +1 -0
- package/dist/tools/move-file.js +12 -5
- package/dist/tools/read-file.d.ts +2 -1
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +13 -6
- package/dist/tools/read-multiple-files.d.ts +2 -1
- package/dist/tools/read-multiple-files.d.ts.map +1 -0
- package/dist/tools/read-multiple-files.js +90 -9
- package/dist/tools/save-file.d.ts +5 -3
- package/dist/tools/save-file.d.ts.map +1 -0
- package/dist/tools/save-file.js +64 -36
- package/dist/tools/think.d.ts +1 -0
- package/dist/tools/think.d.ts.map +1 -0
- package/dist/tools/think.js +5 -1
- package/dist/tools/types.d.ts +14 -1
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/web-fetch.d.ts +4 -2
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +2 -2
- package/dist/tools/web-search.d.ts +2 -1
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +46 -11
- package/dist/utils/filesystem.d.ts +23 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +140 -0
- package/dist/utils/filetype-detection.d.ts +3 -0
- package/dist/utils/filetype-detection.d.ts.map +1 -0
- package/dist/utils/filetype-detection.js +112 -0
- package/dist/utils/glob.d.ts +52 -0
- package/dist/utils/glob.d.ts.map +1 -0
- package/dist/utils/glob.js +376 -0
- package/dist/utils/ignore.d.ts +104 -0
- package/dist/utils/ignore.d.ts.map +1 -0
- package/dist/utils/ignore.js +649 -0
- package/dist/utils/process.d.ts +10 -1
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +104 -5
- package/dist/utils/zod-utils.d.ts +4 -0
- package/dist/utils/zod-utils.d.ts.map +1 -0
- package/dist/utils/zod-utils.js +7 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +32 -30
- package/dist/tools/command-validation.d.ts +0 -12
- package/dist/tools/command-validation.js +0 -113
- /package/dist/{token-tracker.js → tokens/tracker.js} +0 -0
package/dist/utils/process.js
CHANGED
|
@@ -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
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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:
|
|
150
|
+
signal: errorSignal,
|
|
52
151
|
};
|
|
53
152
|
if (throwOnError) {
|
|
54
153
|
reject(Object.assign(error, { result }));
|
|
@@ -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"}
|
package/dist/version.d.ts
CHANGED
|
@@ -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
|
+
"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": "
|
|
37
|
-
"
|
|
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
|
|
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.
|
|
48
|
-
"@ai-sdk/deepseek": "^1.0.
|
|
49
|
-
"@ai-sdk/google": "^2.0.
|
|
50
|
-
"@ai-sdk/
|
|
51
|
-
"@ai-sdk/openai
|
|
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
|
-
"@
|
|
58
|
+
"@openrouter/ai-sdk-provider": "^1.2.0",
|
|
54
59
|
"@travisennis/stdlib": "^0.0.14",
|
|
55
|
-
"ai": "^5.0.
|
|
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
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
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
|
-
"
|
|
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": "^
|
|
74
|
+
"pino-roll": "^4.0.0",
|
|
72
75
|
"tiktoken": "^1.0.22",
|
|
73
|
-
"
|
|
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.
|
|
79
|
-
"@commitlint/config-conventional": "^
|
|
80
|
-
"@types/node": "^24.
|
|
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": "^
|
|
84
|
+
"commitlint": "^20.1.0",
|
|
85
|
+
"domhandler": "^5.0.3",
|
|
84
86
|
"husky": "^9.1.7",
|
|
85
|
-
"typescript": "^5.9.
|
|
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
|