@travisennis/acai 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +186 -17
- package/bin/acai-wrapper.js +26 -0
- package/dist/agent/index.d.ts +15 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +202 -174
- package/dist/api/exa/index.js +1 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +40 -7
- package/dist/commands/add-directory-command.d.ts +1 -1
- package/dist/commands/add-directory-command.d.ts.map +1 -1
- package/dist/commands/add-directory-command.js +1 -32
- package/dist/commands/application-log-command.d.ts +1 -1
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +2 -38
- package/dist/commands/clear-command.d.ts +1 -1
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +1 -5
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +0 -9
- package/dist/commands/context-command.d.ts +1 -1
- package/dist/commands/context-command.d.ts.map +1 -1
- package/dist/commands/context-command.js +13 -72
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +0 -19
- package/dist/commands/edit-command.d.ts +1 -1
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +3 -49
- package/dist/commands/edit-prompt-command.d.ts +1 -1
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +1 -26
- package/dist/commands/exit-command.d.ts +1 -4
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +2 -18
- package/dist/commands/files-command.d.ts +1 -1
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +1 -54
- package/dist/commands/generate-rules-command.d.ts +1 -1
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +18 -60
- package/dist/commands/handoff-command.d.ts.map +1 -1
- package/dist/commands/handoff-command.js +0 -11
- package/dist/commands/health-command.d.ts +1 -1
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +8 -103
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +6 -14
- package/dist/commands/history-command.d.ts +1 -1
- package/dist/commands/history-command.d.ts.map +1 -1
- package/dist/commands/history-command.js +30 -106
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +4 -23
- package/dist/commands/last-log-command.d.ts +1 -1
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +1 -28
- package/dist/commands/list-directories-command.d.ts +1 -1
- package/dist/commands/list-directories-command.d.ts.map +1 -1
- package/dist/commands/list-directories-command.js +1 -14
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +55 -78
- package/dist/commands/manager.d.ts +1 -8
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +7 -42
- package/dist/commands/model-command.d.ts +0 -22
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +5 -126
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +1 -79
- package/dist/commands/pickup-command.d.ts.map +1 -1
- package/dist/commands/pickup-command.js +3 -55
- package/dist/commands/prompt-command.d.ts +19 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +172 -194
- package/dist/commands/remove-directory-command.d.ts +1 -1
- package/dist/commands/remove-directory-command.d.ts.map +1 -1
- package/dist/commands/remove-directory-command.js +1 -33
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +3 -11
- package/dist/commands/rules-command.d.ts +1 -1
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +1 -63
- package/dist/commands/save-command.d.ts +1 -1
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +1 -8
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +1 -48
- package/dist/commands/types.d.ts +0 -3
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +5 -16
- package/dist/config.d.ts +17 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +86 -53
- package/dist/execution/index.d.ts +17 -2
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +62 -20
- package/dist/formatting.d.ts +19 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +54 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +212 -153
- package/dist/messages.d.ts +3 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +67 -3
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +0 -7
- package/dist/models/deepseek-provider.d.ts.map +1 -1
- package/dist/models/deepseek-provider.js +0 -2
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +0 -3
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +0 -1
- package/dist/models/openai-provider.d.ts.map +1 -1
- package/dist/models/openai-provider.js +0 -4
- package/dist/models/openrouter-provider.d.ts +10 -9
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +82 -88
- package/dist/models/providers.d.ts +4 -14
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +1 -57
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -2
- package/dist/prompts.d.ts +9 -4
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +427 -99
- package/dist/repl/project-status-line.d.ts +1 -0
- package/dist/repl/project-status-line.d.ts.map +1 -1
- package/dist/repl/project-status-line.js +57 -27
- package/dist/repl-new.d.ts +0 -2
- package/dist/repl-new.d.ts.map +1 -1
- package/dist/repl-new.js +34 -54
- package/dist/skills.d.ts +20 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +192 -0
- package/dist/terminal/control.d.ts +55 -0
- package/dist/terminal/control.d.ts.map +1 -0
- package/dist/terminal/control.js +109 -0
- package/dist/terminal/default-theme.d.ts +1 -1
- package/dist/terminal/default-theme.d.ts.map +1 -1
- package/dist/terminal/default-theme.js +24 -28
- package/dist/terminal/formatting.d.ts +23 -25
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +35 -52
- package/dist/terminal/highlight/index.d.ts.map +1 -1
- package/dist/terminal/highlight/index.js +3 -6
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +2 -6
- package/dist/terminal/index.d.ts +2 -101
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +2 -464
- package/dist/terminal/markdown.js +7 -5
- package/dist/terminal/strip-ansi.js +4 -4
- package/dist/terminal/table/cell.d.ts +114 -0
- package/dist/terminal/table/cell.d.ts.map +1 -0
- package/dist/terminal/table/cell.js +407 -0
- package/dist/terminal/table/debug.d.ts +15 -0
- package/dist/terminal/table/debug.d.ts.map +1 -0
- package/dist/terminal/table/debug.js +32 -0
- package/dist/terminal/table/index.d.ts +3 -0
- package/dist/terminal/table/index.d.ts.map +1 -0
- package/dist/terminal/table/index.js +2 -0
- package/dist/terminal/table/layout-manager.d.ts +27 -0
- package/dist/terminal/table/layout-manager.d.ts.map +1 -0
- package/dist/terminal/table/layout-manager.js +257 -0
- package/dist/terminal/table/table.d.ts +9 -0
- package/dist/terminal/table/table.d.ts.map +1 -0
- package/dist/terminal/table/table.js +97 -0
- package/dist/terminal/table/utils.d.ts +63 -0
- package/dist/terminal/table/utils.d.ts.map +1 -0
- package/dist/terminal/table/utils.js +326 -0
- package/dist/tokens/threshold.d.ts +6 -21
- package/dist/tokens/threshold.d.ts.map +1 -1
- package/dist/tokens/threshold.js +13 -31
- package/dist/tools/advanced-edit-file.d.ts.map +1 -1
- package/dist/tools/advanced-edit-file.js +5 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +19 -5
- package/dist/tools/bash.d.ts +3 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +204 -42
- package/dist/tools/batch.d.ts +34 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +174 -0
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +25 -9
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +9 -2
- package/dist/tools/directory-tree.d.ts +0 -6
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +29 -18
- package/dist/tools/dynamic-tool-loader.d.ts +0 -4
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +2 -2
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +16 -3
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +24 -13
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +40 -25
- package/dist/tools/index.d.ts +17 -3
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +43 -1
- package/dist/tools/llm-edit-fixer.d.ts +0 -1
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -1
- package/dist/tools/llm-edit-fixer.js +14 -28
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +8 -1
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +32 -23
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +102 -45
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +20 -2
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +7 -1
- package/dist/tools/types.d.ts +5 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +1 -1
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +24 -9
- package/dist/tui/components/assistant-message.js +1 -1
- package/dist/tui/components/box.d.ts +20 -0
- package/dist/tui/components/box.d.ts.map +1 -0
- package/dist/tui/components/box.js +81 -0
- package/dist/tui/components/editor.d.ts +60 -5
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +577 -115
- package/dist/tui/components/footer.d.ts +0 -12
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +19 -7
- package/dist/tui/components/header.d.ts +21 -0
- package/dist/tui/components/header.d.ts.map +1 -0
- package/dist/tui/components/header.js +63 -0
- package/dist/tui/components/loader.d.ts +5 -1
- package/dist/tui/components/loader.d.ts.map +1 -1
- package/dist/tui/components/loader.js +2 -2
- package/dist/tui/components/markdown.d.ts +26 -23
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +107 -54
- package/dist/tui/components/modal.d.ts +0 -11
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +0 -29
- package/dist/tui/components/progress-bar.d.ts +19 -0
- package/dist/tui/components/progress-bar.d.ts.map +1 -0
- package/dist/tui/components/progress-bar.js +78 -0
- package/dist/tui/components/prompt-status.d.ts +2 -1
- package/dist/tui/components/prompt-status.d.ts.map +1 -1
- package/dist/tui/components/prompt-status.js +7 -2
- package/dist/tui/components/select-list.d.ts +27 -1
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +93 -29
- package/dist/tui/components/spacer.d.ts +1 -1
- package/dist/tui/components/spacer.d.ts.map +1 -1
- package/dist/tui/components/spacer.js +2 -2
- package/dist/tui/components/table.d.ts +27 -0
- package/dist/tui/components/table.d.ts.map +1 -0
- package/dist/tui/components/table.js +125 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -1
- package/dist/tui/components/thinking-block.js +4 -1
- package/dist/tui/components/tool-execution.d.ts +8 -4
- package/dist/tui/components/tool-execution.d.ts.map +1 -1
- package/dist/tui/components/tool-execution.js +88 -80
- package/dist/tui/components/user-message.d.ts.map +1 -1
- package/dist/tui/components/user-message.js +6 -4
- package/dist/tui/index.d.ts +9 -5
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +5 -1
- package/dist/tui/terminal.d.ts +2 -1
- package/dist/tui/terminal.d.ts.map +1 -1
- package/dist/tui/terminal.js +28 -38
- package/dist/tui/tui.d.ts +2 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +53 -33
- package/dist/tui/utils.d.ts +5 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +81 -1
- package/dist/{tools/bash-utils.d.ts → utils/bash.d.ts} +3 -3
- package/dist/utils/bash.d.ts.map +1 -0
- package/dist/{tools/bash-utils.js → utils/bash.js} +22 -11
- package/dist/utils/{filesystem.d.ts → filesystem/operations.d.ts} +1 -1
- package/dist/utils/filesystem/operations.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.d.ts → utils/filesystem/security.d.ts} +3 -2
- package/dist/utils/filesystem/security.d.ts.map +1 -0
- package/dist/{tools/filesystem-utils.js → utils/filesystem/security.js} +62 -4
- package/dist/utils/funcs.d.ts +6 -0
- package/dist/utils/funcs.d.ts.map +1 -0
- package/dist/utils/funcs.js +6 -0
- package/dist/{tools/git-utils.d.ts → utils/git.d.ts} +1 -1
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/{tools/git-utils.js → utils/git.js} +0 -6
- package/dist/utils/glob.js +1 -1
- package/dist/utils/{zod-utils.d.ts → zod.d.ts} +1 -1
- package/dist/utils/zod.d.ts.map +1 -0
- package/package.json +17 -17
- package/dist/agent/manual-loop.d.ts +0 -41
- package/dist/agent/manual-loop.d.ts.map +0 -1
- package/dist/agent/manual-loop.js +0 -278
- package/dist/repl/display-tool-messages.d.ts +0 -4
- package/dist/repl/display-tool-messages.d.ts.map +0 -1
- package/dist/repl/display-tool-messages.js +0 -58
- package/dist/repl/display-tool-use.d.ts +0 -14
- package/dist/repl/display-tool-use.d.ts.map +0 -1
- package/dist/repl/display-tool-use.js +0 -63
- package/dist/repl/get-prompt-header.d.ts +0 -8
- package/dist/repl/get-prompt-header.d.ts.map +0 -1
- package/dist/repl/get-prompt-header.js +0 -9
- package/dist/repl/prompt.d.ts +0 -21
- package/dist/repl/prompt.d.ts.map +0 -1
- package/dist/repl/prompt.js +0 -244
- package/dist/repl.d.ts +0 -29
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -218
- package/dist/terminal/checkbox-prompt.d.ts +0 -36
- package/dist/terminal/checkbox-prompt.d.ts.map +0 -1
- package/dist/terminal/checkbox-prompt.js +0 -368
- package/dist/terminal/editor-prompt.d.ts +0 -10
- package/dist/terminal/editor-prompt.d.ts.map +0 -1
- package/dist/terminal/editor-prompt.js +0 -61
- package/dist/terminal/errors.d.ts +0 -19
- package/dist/terminal/errors.d.ts.map +0 -1
- package/dist/terminal/errors.js +0 -37
- package/dist/terminal/input-prompt.d.ts +0 -17
- package/dist/terminal/input-prompt.d.ts.map +0 -1
- package/dist/terminal/input-prompt.js +0 -181
- package/dist/terminal/search-prompt.d.ts +0 -20
- package/dist/terminal/search-prompt.d.ts.map +0 -1
- package/dist/terminal/search-prompt.js +0 -280
- package/dist/terminal/types.d.ts +0 -35
- package/dist/terminal/types.d.ts.map +0 -1
- package/dist/terminal/types.js +0 -1
- package/dist/tools/bash-utils.d.ts.map +0 -1
- package/dist/tools/filesystem-utils.d.ts.map +0 -1
- package/dist/tools/git-utils.d.ts.map +0 -1
- package/dist/utils/filesystem.d.ts.map +0 -1
- package/dist/utils/zod-utils.d.ts.map +0 -1
- /package/dist/utils/{filesystem.js → filesystem/operations.js} +0 -0
- /package/dist/utils/{zod-utils.js → zod.js} +0 -0
|
@@ -2,44 +2,13 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import style from "../terminal/style.js";
|
|
4
4
|
import { Text } from "../tui/index.js";
|
|
5
|
-
export const addDirectoryCommand = ({
|
|
5
|
+
export const addDirectoryCommand = ({ workspace, }) => {
|
|
6
6
|
return {
|
|
7
7
|
command: "/add-directory",
|
|
8
8
|
description: "Add a directory to the list of allowed working directories",
|
|
9
9
|
getSubCommands: async () => {
|
|
10
10
|
return [];
|
|
11
11
|
},
|
|
12
|
-
execute: async (args) => {
|
|
13
|
-
const directoryPath = args?.[0];
|
|
14
|
-
if (!directoryPath) {
|
|
15
|
-
terminal.error("Usage: /add-directory <path>");
|
|
16
|
-
return "continue";
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
// Resolve and validate the directory
|
|
20
|
-
const resolvedPath = path.resolve(directoryPath);
|
|
21
|
-
const stats = await fs.stat(resolvedPath);
|
|
22
|
-
if (!stats.isDirectory()) {
|
|
23
|
-
terminal.error(`Path is not a directory: ${resolvedPath}`);
|
|
24
|
-
return "continue";
|
|
25
|
-
}
|
|
26
|
-
// Check if directory is already in the list
|
|
27
|
-
if (workspace.allowedDirs.includes(resolvedPath)) {
|
|
28
|
-
terminal.warn(`Directory already in allowed list: ${resolvedPath}`);
|
|
29
|
-
return "continue";
|
|
30
|
-
}
|
|
31
|
-
// Add the directory to the workspace
|
|
32
|
-
workspace.allowedDirs.push(resolvedPath);
|
|
33
|
-
terminal.writeln(`Added directory to allowed list: ${style.blue(resolvedPath)}`);
|
|
34
|
-
terminal.writeln(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`);
|
|
35
|
-
return "continue";
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
39
|
-
terminal.error(`Failed to add directory: ${errorMessage}`);
|
|
40
|
-
return "continue";
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
12
|
async handle(args, { tui, container, editor, }) {
|
|
44
13
|
const directoryPath = args?.[0];
|
|
45
14
|
if (!directoryPath) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const applicationLogCommand: (
|
|
2
|
+
export declare const applicationLogCommand: (_options: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=application-log-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/application-log-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,qBAAqB,GAChC,UAAU,cAAc,KACvB,WAiFF,CAAC"}
|
|
@@ -1,52 +1,16 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { config } from "../config.js";
|
|
3
|
-
import { editor } from "../terminal/editor-prompt.js";
|
|
4
3
|
import style from "../terminal/style.js";
|
|
5
4
|
import { Text } from "../tui/index.js";
|
|
6
|
-
export const applicationLogCommand = (
|
|
5
|
+
export const applicationLogCommand = (_options) => {
|
|
7
6
|
return {
|
|
8
7
|
command: "/application-logs",
|
|
9
8
|
description: "Opens the application log file defined in acai.json in the editor.",
|
|
10
9
|
getSubCommands: () => Promise.resolve([]),
|
|
11
|
-
execute: async () => {
|
|
12
|
-
let logFilePath;
|
|
13
|
-
try {
|
|
14
|
-
const projectConfig = await config.readProjectConfig();
|
|
15
|
-
logFilePath = projectConfig.logs?.path;
|
|
16
|
-
if (!logFilePath) {
|
|
17
|
-
terminal.error("Application log path is not defined in .acai/acai.json under the 'logs.path' key.");
|
|
18
|
-
return "continue";
|
|
19
|
-
}
|
|
20
|
-
const content = await readFile(logFilePath, { encoding: "utf8" });
|
|
21
|
-
// Use the editor prompt to display the content (read-only)
|
|
22
|
-
await editor({
|
|
23
|
-
message: `Viewing ${logFilePath}`,
|
|
24
|
-
// Attempt to infer postfix from file extension, default otherwise
|
|
25
|
-
postfix: logFilePath.includes(".")
|
|
26
|
-
? `.${logFilePath.split(".").pop()}`
|
|
27
|
-
: ".log",
|
|
28
|
-
default: content,
|
|
29
|
-
// By not providing an onSubmit or similar handler to write the file,
|
|
30
|
-
// and not calling writeFileSync after, this effectively becomes read-only.
|
|
31
|
-
skipPrompt: true,
|
|
32
|
-
});
|
|
33
|
-
terminal.info(`Closed log view for: ${logFilePath}`);
|
|
34
|
-
return "continue";
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (logFilePath && error.code === "ENOENT") {
|
|
38
|
-
terminal.error(`Application log file not found at: ${logFilePath}`);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
terminal.error(`Error reading or displaying log file ${logFilePath ?? "specified in config"}: ${error}`);
|
|
42
|
-
}
|
|
43
|
-
return "continue";
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
10
|
async handle(_args, { tui, container, editor, }) {
|
|
47
11
|
let logFilePath;
|
|
48
12
|
try {
|
|
49
|
-
const projectConfig = await config.
|
|
13
|
+
const projectConfig = await config.getConfig();
|
|
50
14
|
logFilePath = projectConfig.logs?.path;
|
|
51
15
|
if (!logFilePath) {
|
|
52
16
|
container.addChild(new Text(style.red("Application log path is not defined in .acai/acai.json under the 'logs.path' key."), 1, 0));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear-command.d.ts","sourceRoot":"","sources":["../../source/commands/clear-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,
|
|
1
|
+
{"version":3,"file":"clear-command.d.ts","sourceRoot":"","sources":["../../source/commands/clear-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,UAAU,cAAc,KAAG,WAqBvD,CAAC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
export const clearCommand = (
|
|
1
|
+
export const clearCommand = (_options) => {
|
|
2
2
|
return {
|
|
3
3
|
command: "/clear",
|
|
4
4
|
description: "Clears the terminal screen.",
|
|
5
5
|
getSubCommands: () => Promise.resolve([]),
|
|
6
|
-
execute: async () => {
|
|
7
|
-
terminal.clear();
|
|
8
|
-
return "continue";
|
|
9
|
-
},
|
|
10
6
|
async handle(_args, { tui, container, editor, }) {
|
|
11
7
|
// In TUI mode, we can't clear the screen like terminal.clear()
|
|
12
8
|
// Instead, we'll just clear the input and show a message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact-command.d.ts","sourceRoot":"","sources":["../../source/commands/compact-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,
|
|
1
|
+
{"version":3,"file":"compact-command.d.ts","sourceRoot":"","sources":["../../source/commands/compact-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WA6BxD,CAAC"}
|
|
@@ -7,15 +7,6 @@ export const compactCommand = (options) => {
|
|
|
7
7
|
command: "/compact",
|
|
8
8
|
description: "Saves, summarizes, and resets the chat history. Optional instructions can be provided for the summary.",
|
|
9
9
|
getSubCommands: () => Promise.resolve([]),
|
|
10
|
-
execute: async (args) => {
|
|
11
|
-
const { messageHistory, terminal } = options;
|
|
12
|
-
if (!messageHistory.isEmpty()) {
|
|
13
|
-
const additionalInstructions = args.join(" ");
|
|
14
|
-
await summarizeAndReset(options, additionalInstructions);
|
|
15
|
-
}
|
|
16
|
-
terminal.info("Message history summarized and reset.");
|
|
17
|
-
return "continue";
|
|
18
|
-
},
|
|
19
10
|
async handle(args, { tui, container, editor, }) {
|
|
20
11
|
const { messageHistory } = options;
|
|
21
12
|
if (!messageHistory.isEmpty()) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare function contextCommand({
|
|
2
|
+
export declare function contextCommand({ config, tokenCounter, modelManager, messageHistory, workspace, }: CommandOptions): ReplCommand;
|
|
3
3
|
//# sourceMappingURL=context-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-command.d.ts","sourceRoot":"","sources":["../../source/commands/context-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4C9D,wBAAgB,cAAc,CAAC,EAC7B,
|
|
1
|
+
{"version":3,"file":"context-command.d.ts","sourceRoot":"","sources":["../../source/commands/context-command.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA4C9D,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,SAAS,GACV,EAAE,cAAc,GAAG,WAAW,CAuH9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { systemPrompt } from "../prompts.js";
|
|
2
2
|
import { initCliTools } from "../tools/index.js";
|
|
3
3
|
import { prepareTools } from "../tools/utils.js";
|
|
4
|
-
import { Container, Modal,
|
|
4
|
+
import { Container, Modal, ModalText, TableComponent } from "../tui/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Count tokens from message history
|
|
7
7
|
*/
|
|
@@ -31,91 +31,30 @@ function pct(n, d) {
|
|
|
31
31
|
return "0.0%";
|
|
32
32
|
return `${((n / d) * 100).toFixed(1)}%`;
|
|
33
33
|
}
|
|
34
|
-
export function contextCommand({
|
|
34
|
+
export function contextCommand({ config, tokenCounter, modelManager, messageHistory, workspace, }) {
|
|
35
35
|
return {
|
|
36
36
|
command: "/context",
|
|
37
37
|
description: "Show context window usage breakdown",
|
|
38
38
|
getSubCommands: () => Promise.resolve(["--details", "--json"]),
|
|
39
|
-
async execute(args) {
|
|
40
|
-
const meta = modelManager.getModelMetadata("repl");
|
|
41
|
-
const window = meta.contextWindow;
|
|
42
|
-
// 1) System prompt
|
|
43
|
-
const sys = await systemPrompt({
|
|
44
|
-
supportsToolCalling: meta.supportsToolCalling,
|
|
45
|
-
includeRules: true,
|
|
46
|
-
});
|
|
47
|
-
const systemPromptTokens = tokenCounter.count(sys);
|
|
48
|
-
// 2) Tools (MVP approximation)
|
|
49
|
-
let toolsTokens = 0;
|
|
50
|
-
try {
|
|
51
|
-
const tools = await initCliTools({ tokenCounter, workspace });
|
|
52
|
-
const toolDefs = tools.toolDefs;
|
|
53
|
-
const toolNames = JSON.stringify(prepareTools(toolDefs));
|
|
54
|
-
toolsTokens = tokenCounter.count(toolNames);
|
|
55
|
-
// v2: replace with exact serialized definitions
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
console.error(error);
|
|
59
|
-
toolsTokens = 0;
|
|
60
|
-
}
|
|
61
|
-
// 3) Messages
|
|
62
|
-
const messagesTokens = countMessageTokens(messageHistory.get(), tokenCounter);
|
|
63
|
-
// 4) Totals
|
|
64
|
-
const used = systemPromptTokens + toolsTokens + messagesTokens;
|
|
65
|
-
const free = Math.max(0, window - used);
|
|
66
|
-
const breakdown = {
|
|
67
|
-
systemPrompt: systemPromptTokens,
|
|
68
|
-
tools: toolsTokens,
|
|
69
|
-
messages: messagesTokens,
|
|
70
|
-
totalUsed: used,
|
|
71
|
-
window,
|
|
72
|
-
free,
|
|
73
|
-
};
|
|
74
|
-
// Output
|
|
75
|
-
terminal.header("Context Usage");
|
|
76
|
-
terminal.table([
|
|
77
|
-
[
|
|
78
|
-
"System prompt",
|
|
79
|
-
formatNum(breakdown.systemPrompt),
|
|
80
|
-
pct(breakdown.systemPrompt, window),
|
|
81
|
-
],
|
|
82
|
-
[
|
|
83
|
-
"System tools",
|
|
84
|
-
formatNum(breakdown.tools),
|
|
85
|
-
pct(breakdown.tools, window),
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
"Messages",
|
|
89
|
-
formatNum(breakdown.messages),
|
|
90
|
-
pct(breakdown.messages, window),
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
"Free space",
|
|
94
|
-
formatNum(breakdown.free),
|
|
95
|
-
pct(breakdown.free, window),
|
|
96
|
-
],
|
|
97
|
-
], { header: ["Section", "Tokens", "Percent"], colWidths: [40, 30, 30] });
|
|
98
|
-
terminal.lineBreak();
|
|
99
|
-
terminal.displayProgressBar(used, window);
|
|
100
|
-
if (args.includes("--json")) {
|
|
101
|
-
terminal.lineBreak();
|
|
102
|
-
terminal.display(JSON.stringify(breakdown, null, 2));
|
|
103
|
-
}
|
|
104
|
-
return "continue";
|
|
105
|
-
},
|
|
106
39
|
async handle(args, { tui, editor }) {
|
|
107
40
|
const meta = modelManager.getModelMetadata("repl");
|
|
108
41
|
const window = meta.contextWindow;
|
|
42
|
+
const projectConfig = await config.getConfig();
|
|
109
43
|
// 1) System prompt
|
|
110
44
|
const sys = await systemPrompt({
|
|
111
|
-
|
|
45
|
+
type: projectConfig.systemPromptType,
|
|
46
|
+
activeTools: projectConfig.tools.activeTools,
|
|
47
|
+
allowedDirs: workspace.allowedDirs,
|
|
112
48
|
includeRules: true,
|
|
113
49
|
});
|
|
114
50
|
const systemPromptTokens = tokenCounter.count(sys);
|
|
115
51
|
// 2) Tools (MVP approximation)
|
|
116
52
|
let toolsTokens = 0;
|
|
117
53
|
try {
|
|
118
|
-
const tools = await initCliTools({
|
|
54
|
+
const tools = await initCliTools({
|
|
55
|
+
tokenCounter,
|
|
56
|
+
workspace,
|
|
57
|
+
});
|
|
119
58
|
const toolDefs = tools.toolDefs;
|
|
120
59
|
const toolNames = JSON.stringify(prepareTools(toolDefs));
|
|
121
60
|
toolsTokens = tokenCounter.count(toolNames);
|
|
@@ -160,7 +99,9 @@ export function contextCommand({ terminal, tokenCounter, modelManager, messageHi
|
|
|
160
99
|
["Free space", formatNum(breakdown.free), pct(breakdown.free, window)],
|
|
161
100
|
];
|
|
162
101
|
modalContent.addChild(new ModalText("Context Usage", 0, 1));
|
|
163
|
-
modalContent.addChild(new
|
|
102
|
+
modalContent.addChild(new TableComponent(tableData, {
|
|
103
|
+
headers: ["Section", "Tokens", "Percent"],
|
|
104
|
+
}));
|
|
164
105
|
// Progress bar
|
|
165
106
|
const progressBar = `[${"#".repeat(Math.floor((used / window) * 20))}${"-".repeat(20 - Math.floor((used / window) * 20))}] ${pct(used, window)}`;
|
|
166
107
|
modalContent.addChild(new ModalText("", 0, 1)); // Spacer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-command.d.ts","sourceRoot":"","sources":["../../source/commands/copy-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyB9D,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"copy-command.d.ts","sourceRoot":"","sources":["../../source/commands/copy-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyB9D,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAmDhE"}
|
|
@@ -31,25 +31,6 @@ export function copyCommand(options) {
|
|
|
31
31
|
async getSubCommands() {
|
|
32
32
|
return [];
|
|
33
33
|
},
|
|
34
|
-
async execute(_args) {
|
|
35
|
-
const { messageHistory, terminal } = options;
|
|
36
|
-
const history = messageHistory.get();
|
|
37
|
-
const lastText = extractLastAssistantText(history);
|
|
38
|
-
if (!lastText) {
|
|
39
|
-
terminal.info("No assistant response to copy.");
|
|
40
|
-
return "continue";
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
await Clipboard.setText(lastText);
|
|
44
|
-
terminal.success("Copied last response to clipboard.");
|
|
45
|
-
return "continue";
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
49
|
-
terminal.error(`Could not copy to clipboard: ${message}`);
|
|
50
|
-
return "continue";
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
34
|
async handle(_args, { tui, container, editor, }) {
|
|
54
35
|
const { messageHistory } = options;
|
|
55
36
|
const history = messageHistory.get();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,UAAU,cAAc,KAAG,WAkEtD,CAAC"}
|
|
@@ -1,58 +1,12 @@
|
|
|
1
|
-
import { existsSync, readFileSync
|
|
2
|
-
import {
|
|
3
|
-
import { editor } from "../terminal/editor-prompt.js";
|
|
4
|
-
import { search } from "../terminal/search-prompt.js";
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
5
3
|
import style from "../terminal/style.js";
|
|
6
4
|
import { Text } from "../tui/index.js";
|
|
7
|
-
|
|
8
|
-
export const editCommand = ({ terminal }) => {
|
|
5
|
+
export const editCommand = (_options) => {
|
|
9
6
|
return {
|
|
10
7
|
command: "/edit",
|
|
11
8
|
description: "Opens file in $EDITOR for editing. Usage: /edit [file-path]",
|
|
12
9
|
getSubCommands: () => Promise.resolve([]),
|
|
13
|
-
execute: async (args) => {
|
|
14
|
-
let fileToEdit;
|
|
15
|
-
if (args.length > 0) {
|
|
16
|
-
// File path provided as argument
|
|
17
|
-
const filePath = args.join(" "); // Handle file paths with spaces
|
|
18
|
-
const resolvedPath = resolve(filePath);
|
|
19
|
-
if (!existsSync(resolvedPath)) {
|
|
20
|
-
terminal.error(`File not found: ${filePath}`);
|
|
21
|
-
return "continue";
|
|
22
|
-
}
|
|
23
|
-
fileToEdit = filePath;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// No file path provided, use search prompt
|
|
27
|
-
fileToEdit = await search({
|
|
28
|
-
message: "Search for file:",
|
|
29
|
-
source: async (input) => {
|
|
30
|
-
if (!input) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
const foundFiles = await glob(`**/*${input}*`, {
|
|
34
|
-
gitignore: true,
|
|
35
|
-
});
|
|
36
|
-
return foundFiles.map((file) => ({
|
|
37
|
-
name: file,
|
|
38
|
-
value: file,
|
|
39
|
-
}));
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
const content = readFileSync(fileToEdit, { encoding: "utf8" });
|
|
44
|
-
const edit = await editor({
|
|
45
|
-
message: `Edit ${fileToEdit}?`,
|
|
46
|
-
postfix: extname(fileToEdit),
|
|
47
|
-
default: content,
|
|
48
|
-
skipPrompt: true,
|
|
49
|
-
});
|
|
50
|
-
writeFileSync(fileToEdit, edit);
|
|
51
|
-
if (content !== edit) {
|
|
52
|
-
terminal.info(`File updated: ${fileToEdit}`);
|
|
53
|
-
}
|
|
54
|
-
return "continue";
|
|
55
|
-
},
|
|
56
10
|
async handle(args, { tui, container, editor, }) {
|
|
57
11
|
let fileToEdit;
|
|
58
12
|
if (args.length > 0) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const editPromptCommand: ({
|
|
2
|
+
export declare const editPromptCommand: ({ promptManager, promptHistory, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=edit-prompt-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-prompt-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit-prompt-command.d.ts","sourceRoot":"","sources":["../../source/commands/edit-prompt-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,iBAAiB,GAAI,mCAG/B,cAAc,KAAG,WAuDnB,CAAC"}
|
|
@@ -1,36 +1,11 @@
|
|
|
1
1
|
import { syncTry } from "@travisennis/stdlib/try";
|
|
2
|
-
import { editor } from "../terminal/editor-prompt.js";
|
|
3
2
|
import style from "../terminal/style.js";
|
|
4
3
|
import { Text } from "../tui/index.js";
|
|
5
|
-
export const editPromptCommand = ({
|
|
4
|
+
export const editPromptCommand = ({ promptManager, promptHistory, }) => {
|
|
6
5
|
return {
|
|
7
6
|
command: "/edit-prompt",
|
|
8
7
|
description: "Edit the prompt. Accepts optional arguments as initial content.",
|
|
9
8
|
getSubCommands: () => Promise.resolve([]),
|
|
10
|
-
execute: async (args = []) => {
|
|
11
|
-
try {
|
|
12
|
-
const prompt = syncTry(() => promptManager.get());
|
|
13
|
-
const initialContent = args.length > 0 ? args.join(" ") : prompt.unwrapOr("");
|
|
14
|
-
const updatedPrompt = await editor({
|
|
15
|
-
message: " Edit prompt?",
|
|
16
|
-
postfix: "md",
|
|
17
|
-
default: initialContent,
|
|
18
|
-
skipPrompt: true,
|
|
19
|
-
});
|
|
20
|
-
if (updatedPrompt.trim().length === 0) {
|
|
21
|
-
throw new Error("Prompt was empty.");
|
|
22
|
-
}
|
|
23
|
-
terminal.writeln(`> ${updatedPrompt}`);
|
|
24
|
-
promptManager.set(updatedPrompt);
|
|
25
|
-
// Add the edited prompt to history
|
|
26
|
-
promptHistory.push(updatedPrompt);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
terminal.error(`Error editing prompt: ${error.message}`);
|
|
30
|
-
return "continue";
|
|
31
|
-
}
|
|
32
|
-
return "use";
|
|
33
|
-
},
|
|
34
9
|
async handle(args, { tui, container, editor, }) {
|
|
35
10
|
try {
|
|
36
11
|
const prompt = syncTry(() => promptManager.get());
|
|
@@ -4,10 +4,7 @@ export interface ExitCommandOptions {
|
|
|
4
4
|
isEmpty: () => boolean;
|
|
5
5
|
save: () => Promise<void>;
|
|
6
6
|
};
|
|
7
|
-
terminal: {
|
|
8
|
-
clear: () => void;
|
|
9
|
-
};
|
|
10
7
|
baseDir?: string | null;
|
|
11
8
|
}
|
|
12
|
-
export declare const exitCommand: ({ messageHistory,
|
|
9
|
+
export declare const exitCommand: ({ messageHistory, baseDir, }: ExitCommandOptions) => ReplCommand;
|
|
13
10
|
//# sourceMappingURL=exit-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE;QACd,OAAO,EAAE,MAAM,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IACF,
|
|
1
|
+
{"version":3,"file":"exit-command.d.ts","sourceRoot":"","sources":["../../source/commands/exit-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE;QACd,OAAO,EAAE,MAAM,OAAO,CAAC;QACvB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,GAAI,8BAGzB,kBAAkB,KAAG,WAiCvB,CAAC"}
|
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { logger } from "../logger.js";
|
|
3
3
|
import { Text } from "../tui/index.js";
|
|
4
|
-
import { clearDirectory } from "../utils/filesystem.js";
|
|
5
|
-
export const exitCommand = ({ messageHistory,
|
|
4
|
+
import { clearDirectory } from "../utils/filesystem/operations.js";
|
|
5
|
+
export const exitCommand = ({ messageHistory, baseDir, }) => {
|
|
6
6
|
return {
|
|
7
7
|
command: "/exit",
|
|
8
8
|
aliases: ["/bye", "/quit"],
|
|
9
9
|
description: "Exits and saves the chat history.",
|
|
10
10
|
getSubCommands: () => Promise.resolve([]),
|
|
11
|
-
execute: async () => {
|
|
12
|
-
terminal.clear();
|
|
13
|
-
if (!messageHistory.isEmpty()) {
|
|
14
|
-
await messageHistory.save();
|
|
15
|
-
}
|
|
16
|
-
// Clear the .tmp directory on exit
|
|
17
|
-
try {
|
|
18
|
-
const tmpDirPath = path.join(baseDir ?? process.cwd(), ".tmp");
|
|
19
|
-
await clearDirectory(tmpDirPath);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
// Log error but don't block exit
|
|
23
|
-
console.error("Failed to clear .tmp directory:", error);
|
|
24
|
-
}
|
|
25
|
-
return "break";
|
|
26
|
-
},
|
|
27
11
|
async handle(_args, { tui, container, editor, }) {
|
|
28
12
|
if (!messageHistory.isEmpty()) {
|
|
29
13
|
await messageHistory.save();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const filesCommand: ({
|
|
2
|
+
export declare const filesCommand: ({ promptManager, modelManager, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=files-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files-command.d.ts","sourceRoot":"","sources":["../../source/commands/files-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,kCAG1B,cAAc,KAAG,WA4GnB,CAAC"}
|
|
@@ -1,67 +1,14 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { formatFile } from "../formatting.js";
|
|
3
|
-
import { checkbox } from "../terminal/checkbox-prompt.js";
|
|
4
3
|
import style from "../terminal/style.js";
|
|
5
4
|
import { TokenCounter } from "../tokens/counter.js";
|
|
6
5
|
import { Text } from "../tui/index.js";
|
|
7
6
|
import { glob } from "../utils/glob.js";
|
|
8
|
-
export const filesCommand = ({
|
|
7
|
+
export const filesCommand = ({ promptManager, modelManager, }) => {
|
|
9
8
|
return {
|
|
10
9
|
command: "/files",
|
|
11
10
|
description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
|
|
12
11
|
getSubCommands: () => Promise.resolve([]),
|
|
13
|
-
execute: async (args) => {
|
|
14
|
-
try {
|
|
15
|
-
let workingFiles = [];
|
|
16
|
-
if (!args || args.length === 0) {
|
|
17
|
-
// Get all files in the current directory
|
|
18
|
-
const foundFiles = await glob("**/*", { gitignore: true });
|
|
19
|
-
const selectedFiles = await checkbox({
|
|
20
|
-
message: "Select files to include:",
|
|
21
|
-
choices: foundFiles,
|
|
22
|
-
pageSize: 15,
|
|
23
|
-
});
|
|
24
|
-
if (selectedFiles.length === 0) {
|
|
25
|
-
terminal.warn("No files selected.");
|
|
26
|
-
return "continue";
|
|
27
|
-
}
|
|
28
|
-
// Process the selected files
|
|
29
|
-
workingFiles = selectedFiles;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
const patternList = args.filter(Boolean);
|
|
33
|
-
const foundFiles = await glob(patternList, { gitignore: true });
|
|
34
|
-
if (foundFiles.length === 0) {
|
|
35
|
-
terminal.warn("No files found matching the pattern(s)");
|
|
36
|
-
return "continue";
|
|
37
|
-
}
|
|
38
|
-
// Process the selected files
|
|
39
|
-
workingFiles = foundFiles;
|
|
40
|
-
}
|
|
41
|
-
// Read the content of the files and format them for the next prompt
|
|
42
|
-
const format = modelManager.getModelMetadata("repl").promptFormat;
|
|
43
|
-
let tokenCount = 0;
|
|
44
|
-
const tokenCounter = new TokenCounter();
|
|
45
|
-
await Promise.all(workingFiles.map(async (filePath) => {
|
|
46
|
-
try {
|
|
47
|
-
const content = await readFile(filePath, "utf-8");
|
|
48
|
-
const formattedFile = formatFile(filePath, content, format);
|
|
49
|
-
tokenCount += tokenCounter.count(formattedFile);
|
|
50
|
-
promptManager.addContext(formattedFile);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
terminal.error(`Error reading file ${filePath}: ${error.message}`);
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
tokenCounter.free();
|
|
57
|
-
terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
|
|
58
|
-
return "continue";
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
terminal.error(`Error processing file patterns: ${error.message}`);
|
|
62
|
-
return "continue";
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
12
|
async handle(args, { tui, container, editor, }) {
|
|
66
13
|
try {
|
|
67
14
|
let workingFiles = [];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const generateRulesCommand: ({
|
|
2
|
+
export declare const generateRulesCommand: ({ messageHistory, modelManager, tokenTracker, config, workspace, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=generate-rules-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/generate-rules-command.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/generate-rules-command.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,oBAAoB,GAAI,oEAMlC,cAAc,KAAG,WAoInB,CAAC"}
|