@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
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
import { editor } from "@inquirer/prompts";
|
|
2
1
|
import { syncTry } from "@travisennis/stdlib/try";
|
|
3
|
-
|
|
2
|
+
import { editor } from "../terminal/editor-prompt.js";
|
|
3
|
+
export const editPromptCommand = ({ terminal, promptManager, promptHistory, }) => {
|
|
4
4
|
return {
|
|
5
5
|
command: "/edit-prompt",
|
|
6
|
-
description: "Edit the prompt.",
|
|
7
|
-
result: "use",
|
|
6
|
+
description: "Edit the prompt. Accepts optional arguments as initial content.",
|
|
8
7
|
getSubCommands: () => Promise.resolve([]),
|
|
9
|
-
execute: async () => {
|
|
8
|
+
execute: async (args = []) => {
|
|
10
9
|
try {
|
|
11
10
|
const prompt = syncTry(() => promptManager.get());
|
|
11
|
+
const initialContent = args.length > 0 ? args.join(" ") : prompt.unwrapOr("");
|
|
12
12
|
const updatedPrompt = await editor({
|
|
13
13
|
message: " Edit prompt?",
|
|
14
14
|
postfix: "md",
|
|
15
|
-
default:
|
|
15
|
+
default: initialContent,
|
|
16
|
+
skipPrompt: true,
|
|
16
17
|
});
|
|
18
|
+
if (updatedPrompt.trim().length === 0) {
|
|
19
|
+
throw new Error("Prompt was empty.");
|
|
20
|
+
}
|
|
17
21
|
terminal.writeln(`> ${updatedPrompt}`);
|
|
18
22
|
promptManager.set(updatedPrompt);
|
|
23
|
+
// Add the edited prompt to history
|
|
24
|
+
promptHistory.push(updatedPrompt);
|
|
19
25
|
}
|
|
20
26
|
catch (error) {
|
|
21
|
-
terminal.error(`Error
|
|
27
|
+
terminal.error(`Error editing prompt: ${error.message}`);
|
|
28
|
+
return "continue";
|
|
22
29
|
}
|
|
30
|
+
return "use";
|
|
23
31
|
},
|
|
24
32
|
};
|
|
25
33
|
};
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
1
|
+
import type { ReplCommand } from "./types.ts";
|
|
2
|
+
export interface ExitCommandOptions {
|
|
3
|
+
messageHistory: {
|
|
4
|
+
isEmpty: () => boolean;
|
|
5
|
+
save: () => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
terminal: {
|
|
8
|
+
clear: () => void;
|
|
9
|
+
};
|
|
10
|
+
baseDir?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const exitCommand: ({ messageHistory, terminal, baseDir, }: ExitCommandOptions) => ReplCommand;
|
|
13
|
+
//# sourceMappingURL=exit-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"AAEA,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,WAwBvB,CAAC"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { clearDirectory } from "../utils/filesystem.js";
|
|
3
|
+
export const exitCommand = ({ messageHistory, terminal, baseDir, }) => {
|
|
2
4
|
return {
|
|
3
5
|
command: "/exit",
|
|
4
6
|
aliases: ["/bye", "/quit"],
|
|
5
7
|
description: "Exits and saves the chat history.",
|
|
6
|
-
result: "break",
|
|
7
8
|
getSubCommands: () => Promise.resolve([]),
|
|
8
9
|
execute: async () => {
|
|
10
|
+
terminal.clear();
|
|
9
11
|
if (!messageHistory.isEmpty()) {
|
|
10
12
|
await messageHistory.save();
|
|
11
13
|
}
|
|
14
|
+
// Clear the .tmp directory on exit
|
|
15
|
+
try {
|
|
16
|
+
const tmpDirPath = path.join(baseDir ?? process.cwd(), ".tmp");
|
|
17
|
+
await clearDirectory(tmpDirPath);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
// Log error but don't block exit
|
|
21
|
+
console.error("Failed to clear .tmp directory:", error);
|
|
22
|
+
}
|
|
23
|
+
return "break";
|
|
12
24
|
},
|
|
13
25
|
};
|
|
14
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,4CAI1B,cAAc,KAAG,WA0EnB,CAAC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { checkbox } from "@inquirer/prompts";
|
|
3
|
-
import { globby } from "globby";
|
|
4
2
|
import { formatFile } from "../formatting.js";
|
|
5
|
-
import {
|
|
3
|
+
import { checkbox } from "../terminal/checkbox-prompt.js";
|
|
4
|
+
import { TokenCounter } from "../tokens/counter.js";
|
|
5
|
+
import { glob } from "../utils/glob.js";
|
|
6
6
|
export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
7
7
|
return {
|
|
8
8
|
command: "/files",
|
|
9
9
|
description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
|
|
10
|
-
result: "continue",
|
|
11
10
|
getSubCommands: () => Promise.resolve([]),
|
|
12
11
|
execute: async (args) => {
|
|
13
12
|
try {
|
|
14
13
|
let workingFiles = [];
|
|
15
14
|
if (!args || args.length === 0) {
|
|
16
15
|
// Get all files in the current directory
|
|
17
|
-
const foundFiles = await
|
|
16
|
+
const foundFiles = await glob("**/*", { gitignore: true });
|
|
18
17
|
const selectedFiles = await checkbox({
|
|
19
18
|
message: "Select files to include:",
|
|
20
19
|
choices: foundFiles,
|
|
@@ -22,17 +21,17 @@ export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
|
22
21
|
});
|
|
23
22
|
if (selectedFiles.length === 0) {
|
|
24
23
|
terminal.warn("No files selected.");
|
|
25
|
-
return;
|
|
24
|
+
return "continue";
|
|
26
25
|
}
|
|
27
26
|
// Process the selected files
|
|
28
27
|
workingFiles = selectedFiles;
|
|
29
28
|
}
|
|
30
29
|
else {
|
|
31
30
|
const patternList = args.filter(Boolean);
|
|
32
|
-
const foundFiles = await
|
|
31
|
+
const foundFiles = await glob(patternList, { gitignore: true });
|
|
33
32
|
if (foundFiles.length === 0) {
|
|
34
33
|
terminal.warn("No files found matching the pattern(s)");
|
|
35
|
-
return;
|
|
34
|
+
return "continue";
|
|
36
35
|
}
|
|
37
36
|
// Process the selected files
|
|
38
37
|
workingFiles = foundFiles;
|
|
@@ -54,9 +53,11 @@ export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
|
54
53
|
}));
|
|
55
54
|
tokenCounter.free();
|
|
56
55
|
terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
|
|
56
|
+
return "continue";
|
|
57
57
|
}
|
|
58
58
|
catch (error) {
|
|
59
59
|
terminal.error(`Error processing file patterns: ${error.message}`);
|
|
60
|
+
return "continue";
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/generate-rules-command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuC9D,eAAO,MAAM,oBAAoB,GAAI,mEAMlC,cAAc,KAAG,WAmCnB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { checkbox } from "@inquirer/prompts";
|
|
2
1
|
import { analyzeConversation } from "../conversation-analyzer.js";
|
|
3
2
|
import { logger } from "../logger.js"; // Import logger
|
|
3
|
+
import { checkbox } from "../terminal/checkbox-prompt.js";
|
|
4
4
|
async function _processAndSaveRules(newRules, terminal, config) {
|
|
5
5
|
if (!newRules || newRules.length === 0) {
|
|
6
6
|
terminal.warn("No new generalizable rules were identified.");
|
|
@@ -32,12 +32,11 @@ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, t
|
|
|
32
32
|
return {
|
|
33
33
|
command: "/generate-rules",
|
|
34
34
|
description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
|
|
35
|
-
result: "continue",
|
|
36
35
|
getSubCommands: () => Promise.resolve([]),
|
|
37
36
|
execute: async () => {
|
|
38
37
|
if (messageHistory.isEmpty()) {
|
|
39
38
|
terminal.writeln("Cannot generate rules from an empty conversation.");
|
|
40
|
-
return;
|
|
39
|
+
return "continue";
|
|
41
40
|
}
|
|
42
41
|
terminal.lineBreak();
|
|
43
42
|
terminal.info("Analyzing conversation to generate rules...");
|
|
@@ -55,7 +54,9 @@ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, t
|
|
|
55
54
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
56
55
|
terminal.error(`Error generating rules: ${errorMessage}`);
|
|
57
56
|
logger.error(error, "Error during rule generation:");
|
|
57
|
+
return "continue";
|
|
58
58
|
}
|
|
59
|
+
return "continue";
|
|
59
60
|
},
|
|
60
61
|
};
|
|
61
62
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
1
2
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare function healthCommand({ terminal }: CommandOptions): ReplCommand;
|
|
3
|
+
export declare function healthCommand({ terminal }: CommandOptions, execFn?: typeof execSync): ReplCommand;
|
|
4
|
+
//# sourceMappingURL=health-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-command.d.ts","sourceRoot":"","sources":["../../source/commands/health-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,EAAE,QAAQ,EAAE,EAAE,cAAc,EAC5B,MAAM,kBAAW,GAChB,WAAW,CAqHb"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
export function healthCommand({ terminal }, execFn = execSync) {
|
|
2
3
|
return {
|
|
3
4
|
command: "/health",
|
|
4
5
|
description: "Show application health status and environment variables",
|
|
5
|
-
result: "continue",
|
|
6
6
|
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
execute() {
|
|
7
|
+
async execute() {
|
|
8
8
|
// Define the environment variables we care about
|
|
9
9
|
const envVars = [
|
|
10
10
|
// AI Provider API Keys
|
|
@@ -15,6 +15,7 @@ export function healthCommand({ terminal }) {
|
|
|
15
15
|
description: "Google (Gemini models)",
|
|
16
16
|
},
|
|
17
17
|
{ name: "DEEPSEEK_API_KEY", description: "DeepSeek" },
|
|
18
|
+
{ name: "GROQ_API_KEY", description: "Groq (multiple models)" },
|
|
18
19
|
{ name: "X_AI_API_KEY", description: "X.AI (Grok models)" },
|
|
19
20
|
{ name: "XAI_API_KEY", description: "X.AI (Grok models - alt)" },
|
|
20
21
|
{
|
|
@@ -46,14 +47,50 @@ export function healthCommand({ terminal }) {
|
|
|
46
47
|
// Count how many are set (derived from envStatus to avoid re-checking process.env)
|
|
47
48
|
const setCount = envStatus.filter((row) => row[1] === "✓ Set").length;
|
|
48
49
|
const totalCount = envVars.length;
|
|
49
|
-
terminal.info(
|
|
50
|
+
terminal.info(`Summary: ${setCount}/${totalCount} environment variables are set`);
|
|
50
51
|
if (setCount === 0) {
|
|
51
52
|
terminal.warn("⚠️ No AI provider API keys are configured. The app may not function properly.");
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
55
|
terminal.info("✓ At least one AI provider is configured.");
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
// Check for required bash tools
|
|
58
|
+
const tools = [
|
|
59
|
+
{ name: "git", command: "git --version" },
|
|
60
|
+
{ name: "gh", command: "gh --version" },
|
|
61
|
+
{ name: "rg", command: "rg --version" },
|
|
62
|
+
{ name: "fd", command: "fd --version" },
|
|
63
|
+
{ name: "ast-grep", command: "ast-grep --version" },
|
|
64
|
+
{ name: "jq", command: "jq --version" },
|
|
65
|
+
{ name: "yq", command: "yq --version" },
|
|
66
|
+
];
|
|
67
|
+
const toolStatus = tools.map((tool) => {
|
|
68
|
+
let status = "✗ Not installed";
|
|
69
|
+
try {
|
|
70
|
+
execFn(tool.command, { stdio: "ignore", timeout: 5000 });
|
|
71
|
+
status = "✓ Installed";
|
|
72
|
+
}
|
|
73
|
+
catch (_error) {
|
|
74
|
+
// Ignore error, tool is not installed
|
|
75
|
+
}
|
|
76
|
+
return [tool.name, status];
|
|
77
|
+
});
|
|
78
|
+
terminal.lineBreak();
|
|
79
|
+
terminal.info("Bash Tools Status:");
|
|
80
|
+
terminal.table(toolStatus, {
|
|
81
|
+
header: ["Tool", "Status"],
|
|
82
|
+
colWidths: [15, 20],
|
|
83
|
+
});
|
|
84
|
+
const installedCount = toolStatus.filter((row) => row[1] === "✓ Installed").length;
|
|
85
|
+
const totalTools = tools.length;
|
|
86
|
+
terminal.info(`Tool Summary: ${installedCount}/${totalTools} tools are installed.`);
|
|
87
|
+
if (installedCount < totalTools) {
|
|
88
|
+
terminal.warn("⚠️ Some tools are missing. Install them for full functionality.");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
terminal.info("✓ All required tools are installed.");
|
|
92
|
+
}
|
|
93
|
+
return "continue";
|
|
57
94
|
},
|
|
58
95
|
};
|
|
59
96
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-command.d.ts","sourceRoot":"","sources":["../../source/commands/help-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GACtB,cAAc,cAAc,EAC5B,MAAM,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,KAC7B,WAoBF,CAAC"}
|
|
@@ -2,9 +2,8 @@ export const helpCommand = ({ terminal }, cmds) => {
|
|
|
2
2
|
return {
|
|
3
3
|
command: "/help",
|
|
4
4
|
description: "Shows available commands.",
|
|
5
|
-
result: "continue",
|
|
6
5
|
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
execute: () => {
|
|
6
|
+
execute: async () => {
|
|
8
7
|
const commands = cmds;
|
|
9
8
|
const entries = Array.from(commands.entries())
|
|
10
9
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
@@ -13,7 +12,7 @@ export const helpCommand = ({ terminal }, cmds) => {
|
|
|
13
12
|
header: ["Command", "Description"],
|
|
14
13
|
colWidths: [30, 70],
|
|
15
14
|
});
|
|
16
|
-
return
|
|
15
|
+
return "continue";
|
|
17
16
|
},
|
|
18
17
|
};
|
|
19
18
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../source/commands/init-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,uDAKzB,cAAc,KAAG,WAoCnB,CAAC"}
|
|
@@ -6,7 +6,6 @@ export const initCommand = ({ terminal, modelManager, tokenCounter, toolEvents,
|
|
|
6
6
|
return {
|
|
7
7
|
command: "/init",
|
|
8
8
|
description: "Creates the AGENTS.md file.",
|
|
9
|
-
result: "continue",
|
|
10
9
|
getSubCommands: () => Promise.resolve([]),
|
|
11
10
|
execute: async () => {
|
|
12
11
|
const result = streamText({
|
|
@@ -29,12 +28,12 @@ Platform: ${platform()}`,
|
|
|
29
28
|
terminal,
|
|
30
29
|
tokenCounter,
|
|
31
30
|
events: toolEvents,
|
|
32
|
-
autoAcceptAll: true,
|
|
33
31
|
}),
|
|
34
32
|
});
|
|
35
33
|
for await (const text of result.textStream) {
|
|
36
34
|
terminal.write(text);
|
|
37
35
|
}
|
|
36
|
+
return "continue";
|
|
38
37
|
},
|
|
39
38
|
};
|
|
40
39
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/last-log-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyC9D,eAAO,MAAM,cAAc,GAAI,cAAc,cAAc,KAAG,WAqC7D,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { editor } from "@inquirer/prompts";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { globby } from "globby";
|
|
6
3
|
import { config } from "../config.js";
|
|
4
|
+
import { editor } from "../terminal/editor-prompt.js";
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { glob } from "../utils/glob.js";
|
|
7
7
|
const isoDateRegex = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)/;
|
|
8
8
|
// Function to find the most recent log file
|
|
9
9
|
async function findMostRecentLog(logDir) {
|
|
10
10
|
const logPattern = join(logDir, "*-repl-message.json");
|
|
11
|
-
const files = await
|
|
11
|
+
const files = await glob(logPattern);
|
|
12
12
|
if (files.length === 0) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
@@ -21,16 +21,9 @@ async function findMostRecentLog(logDir) {
|
|
|
21
21
|
// Match the ISO date string at the beginning of the filename
|
|
22
22
|
const match = filename.match(isoDateRegex);
|
|
23
23
|
if (match?.[1]) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (!Number.isNaN(date.getTime())) {
|
|
28
|
-
return { file, date };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
// Ignore files with invalid date strings
|
|
33
|
-
console.warn(`Could not parse date from filename: ${filename}`, e);
|
|
24
|
+
const date = new Date(match[1]);
|
|
25
|
+
if (!Number.isNaN(date.getTime())) {
|
|
26
|
+
return { file, date };
|
|
34
27
|
}
|
|
35
28
|
}
|
|
36
29
|
return null; // Exclude files that don't match the pattern or have invalid dates
|
|
@@ -47,29 +40,31 @@ export const lastLogCommand = ({ terminal }) => {
|
|
|
47
40
|
return {
|
|
48
41
|
command: "/last-log",
|
|
49
42
|
description: "Opens the most recent REPL audit log in the editor.",
|
|
50
|
-
result: "continue",
|
|
51
43
|
getSubCommands: () => Promise.resolve([]),
|
|
52
44
|
execute: async () => {
|
|
53
45
|
const logDir = config.app.ensurePathSync("audit");
|
|
54
46
|
const mostRecentLog = await findMostRecentLog(logDir);
|
|
55
47
|
if (!mostRecentLog) {
|
|
56
48
|
terminal.error(`No REPL audit logs found in '${logDir}'.`);
|
|
57
|
-
return;
|
|
49
|
+
return "continue";
|
|
58
50
|
}
|
|
59
51
|
try {
|
|
60
52
|
const content = await readFile(mostRecentLog, { encoding: "utf8" });
|
|
61
53
|
// Use the editor prompt to display the content (read-only)
|
|
62
54
|
await editor({
|
|
63
|
-
message: `Viewing ${
|
|
55
|
+
message: `Viewing ${style.green(mostRecentLog)}`,
|
|
64
56
|
postfix: ".json", // Set postfix for syntax highlighting if editor supports it
|
|
65
57
|
default: content,
|
|
66
58
|
// By not providing an onSubmit or similar handler to write the file,
|
|
67
59
|
// and not calling writeFileSync after, this effectively becomes read-only.
|
|
60
|
+
skipPrompt: true,
|
|
68
61
|
});
|
|
69
62
|
terminal.info("Closed log view");
|
|
63
|
+
return "continue";
|
|
70
64
|
}
|
|
71
65
|
catch (error) {
|
|
72
66
|
terminal.error(`Error reading or displaying log file ${mostRecentLog}: ${error}`);
|
|
67
|
+
return "continue";
|
|
73
68
|
}
|
|
74
69
|
},
|
|
75
70
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-tools-command.d.ts","sourceRoot":"","sources":["../../source/commands/list-tools-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAmErE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { initAgents, initTools } from "../tools/index.js";
|
|
2
|
+
export function listToolsCommand(options) {
|
|
3
|
+
return {
|
|
4
|
+
command: "/list-tools",
|
|
5
|
+
description: "List all available static and dynamic tools.",
|
|
6
|
+
aliases: ["/lt"],
|
|
7
|
+
getSubCommands: async () => [],
|
|
8
|
+
async execute(_args) {
|
|
9
|
+
const { terminal } = options;
|
|
10
|
+
try {
|
|
11
|
+
const tools = await initTools({
|
|
12
|
+
terminal: options.terminal,
|
|
13
|
+
tokenCounter: options.tokenCounter,
|
|
14
|
+
events: new Map(),
|
|
15
|
+
});
|
|
16
|
+
const agentTools = await initAgents({
|
|
17
|
+
terminal: options.terminal,
|
|
18
|
+
modelManager: options.modelManager,
|
|
19
|
+
tokenTracker: options.tokenTracker,
|
|
20
|
+
tokenCounter: options.tokenCounter,
|
|
21
|
+
events: new Map(),
|
|
22
|
+
});
|
|
23
|
+
const toolNames = Object.keys({ ...tools, ...agentTools }).sort();
|
|
24
|
+
terminal.writeln("Available tools:");
|
|
25
|
+
terminal.lineBreak();
|
|
26
|
+
// Separate static and dynamic tools
|
|
27
|
+
const staticTools = [];
|
|
28
|
+
const dynamicTools = [];
|
|
29
|
+
for (const toolName of toolNames) {
|
|
30
|
+
if (toolName.startsWith("dynamic-")) {
|
|
31
|
+
dynamicTools.push(toolName);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
staticTools.push(toolName);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Display static tools
|
|
38
|
+
if (staticTools.length > 0) {
|
|
39
|
+
terminal.writeln(" Static tools:");
|
|
40
|
+
for (const toolName of staticTools) {
|
|
41
|
+
terminal.writeln(` ${toolName}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Display dynamic tools
|
|
45
|
+
if (dynamicTools.length > 0) {
|
|
46
|
+
terminal.writeln(" Dynamic tools:");
|
|
47
|
+
for (const toolName of dynamicTools) {
|
|
48
|
+
terminal.writeln(` ${toolName}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Display summary
|
|
52
|
+
terminal.writeln(`\n Total: ${staticTools.length} static, ${dynamicTools.length} dynamic`);
|
|
53
|
+
return "continue";
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
terminal.error(`Error listing tools: ${error.message}`);
|
|
57
|
+
return "continue";
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -9,8 +9,12 @@ export declare class CommandManager {
|
|
|
9
9
|
private config;
|
|
10
10
|
private tokenCounter;
|
|
11
11
|
private toolEvents;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
private toolExecutor?;
|
|
13
|
+
private promptHistory;
|
|
14
|
+
private initialized;
|
|
15
|
+
constructor({ promptManager, modelManager, terminal, messageHistory, tokenTracker, config, tokenCounter, toolEvents, toolExecutor, promptHistory, }: CommandOptions);
|
|
16
|
+
initializeCommmands(): Promise<void>;
|
|
17
|
+
private ensureInitialized;
|
|
14
18
|
getCommands(): string[];
|
|
15
19
|
getSubCommands(command: string): Promise<string[]>;
|
|
16
20
|
handle({ userInput }: {
|
|
@@ -20,3 +24,4 @@ export declare class CommandManager {
|
|
|
20
24
|
break: boolean;
|
|
21
25
|
}>;
|
|
22
26
|
}
|
|
27
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../source/commands/manager.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,YAAY,CAAC;AAG9D,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,YAAY,CAAC,CAAe;IACpC,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,WAAW,CAAU;gBAEjB,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,GACd,EAAE,cAAc;IAeX,mBAAmB;IA8EzB,OAAO,CAAC,iBAAiB;IAQzB,WAAW;IAKL,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKlD,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE;;;;CA6BlD"}
|
package/dist/commands/manager.js
CHANGED
|
@@ -11,12 +11,14 @@ import { healthCommand } from "./health-command.js";
|
|
|
11
11
|
import { helpCommand } from "./help-command.js";
|
|
12
12
|
import { initCommand } from "./init-command.js";
|
|
13
13
|
import { lastLogCommand } from "./last-log-command.js";
|
|
14
|
+
import { listToolsCommand } from "./list-tools-command.js";
|
|
14
15
|
import { modelCommand } from "./model-command.js";
|
|
15
16
|
import { pasteCommand } from "./paste-command.js";
|
|
16
17
|
import { promptCommand } from "./prompt-command.js";
|
|
17
18
|
import { resetCommand } from "./reset-command.js";
|
|
18
19
|
import { rulesCommand } from "./rules-command.js";
|
|
19
20
|
import { saveCommand } from "./save-command.js";
|
|
21
|
+
import { shellCommand } from "./shell-command.js";
|
|
20
22
|
import { usageCommand } from "./usage-command.js";
|
|
21
23
|
export class CommandManager {
|
|
22
24
|
commands;
|
|
@@ -28,7 +30,10 @@ export class CommandManager {
|
|
|
28
30
|
config;
|
|
29
31
|
tokenCounter;
|
|
30
32
|
toolEvents;
|
|
31
|
-
|
|
33
|
+
toolExecutor;
|
|
34
|
+
promptHistory;
|
|
35
|
+
initialized;
|
|
36
|
+
constructor({ promptManager, modelManager, terminal, messageHistory, tokenTracker, config, tokenCounter, toolEvents, toolExecutor, promptHistory, }) {
|
|
32
37
|
this.commands = new Map();
|
|
33
38
|
this.promptManager = promptManager;
|
|
34
39
|
this.modelManager = modelManager;
|
|
@@ -38,9 +43,14 @@ export class CommandManager {
|
|
|
38
43
|
this.config = config;
|
|
39
44
|
this.tokenCounter = tokenCounter;
|
|
40
45
|
this.toolEvents = toolEvents;
|
|
41
|
-
this.
|
|
46
|
+
this.toolExecutor = toolExecutor;
|
|
47
|
+
this.promptHistory = promptHistory;
|
|
48
|
+
this.initialized = false;
|
|
42
49
|
}
|
|
43
|
-
initializeCommmands() {
|
|
50
|
+
async initializeCommmands() {
|
|
51
|
+
if (this.initialized) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
44
54
|
// Import and register each command
|
|
45
55
|
const options = {
|
|
46
56
|
promptManager: this.promptManager,
|
|
@@ -51,6 +61,8 @@ export class CommandManager {
|
|
|
51
61
|
config: this.config,
|
|
52
62
|
tokenCounter: this.tokenCounter,
|
|
53
63
|
toolEvents: this.toolEvents,
|
|
64
|
+
toolExecutor: this.toolExecutor,
|
|
65
|
+
promptHistory: this.promptHistory,
|
|
54
66
|
};
|
|
55
67
|
// Register all commands
|
|
56
68
|
const cmds = [
|
|
@@ -73,6 +85,8 @@ export class CommandManager {
|
|
|
73
85
|
generateRulesCommand(options),
|
|
74
86
|
applicationLogCommand(options),
|
|
75
87
|
copyCommand(options),
|
|
88
|
+
listToolsCommand(options),
|
|
89
|
+
shellCommand(options),
|
|
76
90
|
];
|
|
77
91
|
// Add help command with access to all commands
|
|
78
92
|
const helpCmd = helpCommand(options, this.commands);
|
|
@@ -88,28 +102,51 @@ export class CommandManager {
|
|
|
88
102
|
this.commands.set(alias, cmd);
|
|
89
103
|
}
|
|
90
104
|
}
|
|
105
|
+
const promptCmd = this.commands.get("/prompt");
|
|
106
|
+
if (promptCmd) {
|
|
107
|
+
const promptSubmCommands = await promptCmd.getSubCommands();
|
|
108
|
+
for (const cmd of promptSubmCommands) {
|
|
109
|
+
this.commands.set(`/${cmd}`, {
|
|
110
|
+
command: `/${cmd}`,
|
|
111
|
+
description: "",
|
|
112
|
+
execute: (args) => {
|
|
113
|
+
return promptCmd.execute([cmd, ...args]);
|
|
114
|
+
},
|
|
115
|
+
getSubCommands: () => Promise.resolve([]),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.initialized = true;
|
|
120
|
+
}
|
|
121
|
+
ensureInitialized() {
|
|
122
|
+
if (!this.initialized) {
|
|
123
|
+
throw new Error("Commands have not been initialized. Call initializeCommmands() first.");
|
|
124
|
+
}
|
|
91
125
|
}
|
|
92
126
|
getCommands() {
|
|
127
|
+
this.ensureInitialized();
|
|
93
128
|
return Array.from(this.commands.keys()).sort();
|
|
94
129
|
}
|
|
95
130
|
async getSubCommands(command) {
|
|
131
|
+
this.ensureInitialized();
|
|
96
132
|
return (await this.commands.get(command)?.getSubCommands()) ?? [];
|
|
97
133
|
}
|
|
98
134
|
async handle({ userInput }) {
|
|
135
|
+
this.ensureInitialized();
|
|
99
136
|
const commandArgs = userInput.split(" ");
|
|
100
137
|
const command = commandArgs.at(0);
|
|
101
138
|
const args = commandArgs.slice(1);
|
|
102
139
|
if (command) {
|
|
103
140
|
const replCommand = this.commands.get(command);
|
|
104
141
|
if (replCommand) {
|
|
105
|
-
await replCommand.execute(args);
|
|
106
|
-
if (
|
|
142
|
+
const result = await replCommand.execute(args);
|
|
143
|
+
if (result === "continue") {
|
|
107
144
|
return {
|
|
108
145
|
continue: true,
|
|
109
146
|
break: false,
|
|
110
147
|
};
|
|
111
148
|
}
|
|
112
|
-
if (
|
|
149
|
+
if (result === "break") {
|
|
113
150
|
return {
|
|
114
151
|
continue: false,
|
|
115
152
|
break: true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-command.d.ts","sourceRoot":"","sources":["../../source/commands/model-command.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CA+GjE"}
|