@travisennis/acai 0.0.5 → 0.0.6
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 +4 -2
- package/dist/agent/index.d.ts +119 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +406 -0
- package/dist/agent/manual-loop.d.ts +41 -0
- package/dist/agent/manual-loop.d.ts.map +1 -0
- package/dist/agent/manual-loop.js +278 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -33
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +85 -0
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +34 -0
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +8 -0
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +15 -2
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +183 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +28 -0
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +33 -0
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +28 -0
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +20 -0
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +57 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +311 -1
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +202 -0
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +119 -2
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +28 -0
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +534 -0
- 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 +55 -18
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +27 -0
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +48 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +66 -3
- package/dist/commands/manager.d.ts +15 -3
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +86 -26
- package/dist/commands/model-command.d.ts +22 -0
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +256 -0
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +92 -0
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +161 -0
- package/dist/commands/prompt-command.d.ts +1 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +117 -2
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +87 -0
- 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 +13 -2
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +65 -0
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +12 -0
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +68 -0
- package/dist/commands/types.d.ts +9 -4
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +22 -0
- package/dist/config.d.ts +6 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -29
- package/dist/formatting.d.ts +108 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +147 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +140 -38
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +8 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +56 -19
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -60
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openrouter-provider.d.ts +7 -14
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +114 -169
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/prompts.d.ts +1 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +53 -4
- package/dist/repl/display-tool-messages.d.ts +1 -1
- package/dist/repl/display-tool-messages.d.ts.map +1 -1
- package/dist/repl/display-tool-messages.js +47 -44
- package/dist/repl/get-prompt-header.d.ts.map +1 -1
- package/dist/repl/get-prompt-header.js +1 -30
- package/dist/repl/project-status-line.d.ts +2 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +31 -0
- package/dist/repl/prompt.d.ts +21 -0
- package/dist/repl/prompt.d.ts.map +1 -0
- package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +53 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +374 -0
- package/dist/repl.d.ts +3 -5
- package/dist/repl.d.ts.map +1 -1
- package/dist/repl.js +74 -166
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -1
- package/dist/terminal/checkbox-prompt.js +10 -4
- package/dist/terminal/index.d.ts +7 -0
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +94 -0
- package/dist/terminal/input-prompt.d.ts +2 -1
- package/dist/terminal/input-prompt.d.ts.map +1 -1
- package/dist/terminal/markdown.js +3 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -1
- package/dist/terminal/search-prompt.js +11 -10
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/tokens/threshold.d.ts +35 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +85 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +281 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +71 -58
- package/dist/tools/bash-utils.d.ts +1 -1
- package/dist/tools/bash-utils.d.ts.map +1 -1
- package/dist/tools/bash-utils.js +14 -6
- package/dist/tools/bash.d.ts +21 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +88 -135
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +138 -137
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +51 -95
- package/dist/tools/directory-tree.d.ts +17 -6
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +47 -49
- package/dist/tools/dynamic-tool-loader.d.ts +18 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +121 -129
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +112 -112
- package/dist/tools/filesystem-utils.d.ts +2 -1
- package/dist/tools/filesystem-utils.d.ts.map +1 -1
- package/dist/tools/filesystem-utils.js +31 -17
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +143 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +413 -168
- package/dist/tools/index.d.ts +204 -124
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +242 -135
- package/dist/tools/llm-edit-fixer.d.ts +25 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +150 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +40 -33
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +74 -69
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +76 -73
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +58 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +30 -22
- package/dist/tools/types.d.ts +4 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +50 -32
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/editor.d.ts +51 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +758 -0
- package/dist/tui/components/footer.d.ts +24 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +197 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +19 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +103 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +533 -0
- package/dist/tui/components/modal.d.ts +40 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +292 -0
- package/dist/tui/components/prompt-status.d.ts +16 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +21 -0
- package/dist/tui/components/select-list.d.ts +22 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +143 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +30 -0
- package/dist/tui/components/tool-execution.d.ts +17 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +153 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +21 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +14 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +18 -0
- package/dist/tui/terminal.d.ts +37 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +104 -0
- package/dist/tui/tui.d.ts +67 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +184 -0
- package/dist/tui/utils.d.ts +19 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +31 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/package.json +16 -16
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { readdir, readFile } from "node:fs/promises";
|
|
2
2
|
import path, { basename } from "node:path";
|
|
3
3
|
import { processPrompt } from "../mentions.js";
|
|
4
|
-
|
|
4
|
+
import style from "../terminal/style.js";
|
|
5
|
+
import { Text } from "../tui/index.js";
|
|
6
|
+
export const promptCommand = ({ terminal, modelManager, promptManager, config, promptHistory, workspace, }) => {
|
|
5
7
|
return {
|
|
6
8
|
command: "/prompt",
|
|
7
9
|
description: "Loads and executes prompts. Project prompts override user prompts with the same name.",
|
|
@@ -76,7 +78,7 @@ export const promptCommand = ({ terminal, modelManager, promptManager, config, p
|
|
|
76
78
|
terminal.info(`Input: "${inputString}"`);
|
|
77
79
|
}
|
|
78
80
|
const processedPrompt = await processPrompt(promptContent, {
|
|
79
|
-
baseDir:
|
|
81
|
+
baseDir: workspace.primaryDir,
|
|
80
82
|
model: modelManager.getModelMetadata("repl"),
|
|
81
83
|
});
|
|
82
84
|
for (const context of processedPrompt.context) {
|
|
@@ -96,6 +98,75 @@ export const promptCommand = ({ terminal, modelManager, promptManager, config, p
|
|
|
96
98
|
return "continue";
|
|
97
99
|
}
|
|
98
100
|
},
|
|
101
|
+
async handle(args, { tui, container, editor, }) {
|
|
102
|
+
const promptName = args?.[0];
|
|
103
|
+
// Handle no subcommand or 'list' subcommand
|
|
104
|
+
if (!promptName || promptName === "list") {
|
|
105
|
+
await listAllPromptsTui(container, config);
|
|
106
|
+
tui.requestRender();
|
|
107
|
+
editor.setText("");
|
|
108
|
+
return "continue";
|
|
109
|
+
}
|
|
110
|
+
// Check for old format and provide helpful error
|
|
111
|
+
if (promptName.includes(":")) {
|
|
112
|
+
container.addChild(new Text(style.yellow("The old format (user:name or project:name) is no longer supported. Use: /prompt <prompt-name> [input...]"), 1, 0));
|
|
113
|
+
tui.requestRender();
|
|
114
|
+
editor.setText("");
|
|
115
|
+
return "continue";
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const promptResult = await findPrompt(promptName, config);
|
|
119
|
+
if (!promptResult) {
|
|
120
|
+
container.addChild(new Text(style.red(`Prompt not found: ${promptName}. Available prompts can be seen with tab completion.`), 1, 0));
|
|
121
|
+
tui.requestRender();
|
|
122
|
+
editor.setText("");
|
|
123
|
+
return "continue";
|
|
124
|
+
}
|
|
125
|
+
let promptContent;
|
|
126
|
+
try {
|
|
127
|
+
promptContent = await readFile(promptResult.path, "utf8");
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (error.code === "ENOENT") {
|
|
131
|
+
container.addChild(new Text(style.red(`Prompt file not found: ${promptName} at ${promptResult.path}`), 1, 0));
|
|
132
|
+
tui.requestRender();
|
|
133
|
+
editor.setText("");
|
|
134
|
+
return "continue";
|
|
135
|
+
}
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
// Combine remaining arguments into a single string for input
|
|
139
|
+
const inputArgs = args.slice(1);
|
|
140
|
+
const inputString = inputArgs.join(" ");
|
|
141
|
+
// Replace {{INPUT}} placeholder with the input string
|
|
142
|
+
if (promptContent.includes("{{INPUT}}")) {
|
|
143
|
+
promptContent = promptContent.replace(/{{INPUT}}/g, inputString);
|
|
144
|
+
}
|
|
145
|
+
container.addChild(new Text(`Loaded ${promptResult.type} prompt: ${style.blue(promptName)}`, 1, 0));
|
|
146
|
+
if (inputArgs.length > 0) {
|
|
147
|
+
container.addChild(new Text(`Input: "${inputString}"`, 2, 0));
|
|
148
|
+
}
|
|
149
|
+
const processedPrompt = await processPrompt(promptContent, {
|
|
150
|
+
baseDir: workspace.primaryDir,
|
|
151
|
+
model: modelManager.getModelMetadata("repl"),
|
|
152
|
+
});
|
|
153
|
+
for (const context of processedPrompt.context) {
|
|
154
|
+
promptManager.addContext(context);
|
|
155
|
+
}
|
|
156
|
+
promptManager.set(processedPrompt.message);
|
|
157
|
+
// Add the loaded prompt to history
|
|
158
|
+
promptHistory.push(processedPrompt.message);
|
|
159
|
+
tui.requestRender();
|
|
160
|
+
editor.setText("");
|
|
161
|
+
return "use";
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
container.addChild(new Text(style.red(`Error loading prompt: ${error.message}`), 1, 0));
|
|
165
|
+
tui.requestRender();
|
|
166
|
+
editor.setText("");
|
|
167
|
+
return "continue";
|
|
168
|
+
}
|
|
169
|
+
},
|
|
99
170
|
};
|
|
100
171
|
};
|
|
101
172
|
async function findPrompt(promptName, config) {
|
|
@@ -163,3 +234,47 @@ async function listAllPrompts(terminal, config) {
|
|
|
163
234
|
terminal.info("\nUsage: /prompt <prompt-name> [input...]");
|
|
164
235
|
terminal.info("Example: /prompt project-status");
|
|
165
236
|
}
|
|
237
|
+
async function listAllPromptsTui(container, config) {
|
|
238
|
+
const getPromptNamesFromDir = async (dirPath) => {
|
|
239
|
+
try {
|
|
240
|
+
const dirents = await readdir(dirPath, { withFileTypes: true });
|
|
241
|
+
return dirents
|
|
242
|
+
.filter((dirent) => dirent.isFile() && dirent.name.endsWith(".md"))
|
|
243
|
+
.map((dirent) => basename(dirent.name, ".md"));
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
if (error.code === "ENOENT") {
|
|
247
|
+
return []; // Directory doesn't exist, return empty array
|
|
248
|
+
}
|
|
249
|
+
return []; // Return empty on other errors
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
const userPromptDir = config.app.ensurePathSync("prompts");
|
|
253
|
+
const projectPromptDir = config.project.ensurePathSync("prompts");
|
|
254
|
+
const userPrompts = await getPromptNamesFromDir(userPromptDir);
|
|
255
|
+
const projectPrompts = await getPromptNamesFromDir(projectPromptDir);
|
|
256
|
+
if (userPrompts.length === 0 && projectPrompts.length === 0) {
|
|
257
|
+
container.addChild(new Text(style.yellow("No prompts found. Create prompts in ~/.acai/prompts/ or ./.acai/prompts/"), 1, 0));
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
container.addChild(new Text("Available prompts:", 0, 1));
|
|
261
|
+
let lineIndex = 2;
|
|
262
|
+
if (projectPrompts.length > 0) {
|
|
263
|
+
container.addChild(new Text(" Project prompts (./.acai/prompts/):", lineIndex, 0));
|
|
264
|
+
lineIndex++;
|
|
265
|
+
projectPrompts.sort().forEach((prompt) => {
|
|
266
|
+
container.addChild(new Text(` • ${prompt}`, lineIndex, 0));
|
|
267
|
+
lineIndex++;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
if (userPrompts.length > 0) {
|
|
271
|
+
container.addChild(new Text(" User prompts (~/.acai/prompts/):", lineIndex, 0));
|
|
272
|
+
lineIndex++;
|
|
273
|
+
userPrompts.sort().forEach((prompt) => {
|
|
274
|
+
container.addChild(new Text(` • ${prompt}`, lineIndex, 0));
|
|
275
|
+
lineIndex++;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
container.addChild(new Text("\nUsage: /prompt <prompt-name> [input...]", lineIndex, 0));
|
|
279
|
+
container.addChild(new Text("Example: /prompt project-status", lineIndex + 1, 1));
|
|
280
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-directory-command.d.ts","sourceRoot":"","sources":["../../source/commands/remove-directory-command.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,sBAAsB,GAAI,0BAGpC,cAAc,KAAG,WA6InB,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import style from "../terminal/style.js";
|
|
3
|
+
import { Text } from "../tui/index.js";
|
|
4
|
+
export const removeDirectoryCommand = ({ terminal, workspace, }) => {
|
|
5
|
+
return {
|
|
6
|
+
command: "/remove-directory",
|
|
7
|
+
description: "Remove a directory from the list of allowed working directories",
|
|
8
|
+
getSubCommands: async () => {
|
|
9
|
+
// Return only non-primary directories for tab completion
|
|
10
|
+
return workspace.allowedDirs.filter((dir) => dir !== workspace.primaryDir);
|
|
11
|
+
},
|
|
12
|
+
execute: async (args) => {
|
|
13
|
+
const directoryPath = args?.[0];
|
|
14
|
+
if (!directoryPath) {
|
|
15
|
+
terminal.error("Usage: /remove-directory <path>");
|
|
16
|
+
return "continue";
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
// Resolve the directory path
|
|
20
|
+
const resolvedPath = path.resolve(directoryPath);
|
|
21
|
+
// Check if it's the primary directory
|
|
22
|
+
if (resolvedPath === workspace.primaryDir) {
|
|
23
|
+
terminal.error("Cannot remove the primary working directory");
|
|
24
|
+
return "continue";
|
|
25
|
+
}
|
|
26
|
+
// Find the directory in the list
|
|
27
|
+
const index = workspace.allowedDirs.indexOf(resolvedPath);
|
|
28
|
+
if (index === -1) {
|
|
29
|
+
terminal.error(`Directory not found in allowed list: ${resolvedPath}`);
|
|
30
|
+
return "continue";
|
|
31
|
+
}
|
|
32
|
+
// Remove the directory
|
|
33
|
+
workspace.allowedDirs.splice(index, 1);
|
|
34
|
+
terminal.writeln(`Removed directory from allowed list: ${style.blue(resolvedPath)}`);
|
|
35
|
+
terminal.writeln(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`);
|
|
36
|
+
return "continue";
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
40
|
+
terminal.error(`Failed to remove directory: ${errorMessage}`);
|
|
41
|
+
return "continue";
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
async handle(args, { tui, container, editor, }) {
|
|
45
|
+
const directoryPath = args?.[0];
|
|
46
|
+
if (!directoryPath) {
|
|
47
|
+
container.addChild(new Text(style.red("Usage: /remove-directory <path>"), 0, 1));
|
|
48
|
+
tui.requestRender();
|
|
49
|
+
editor.setText("");
|
|
50
|
+
return "continue";
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// Resolve the directory path
|
|
54
|
+
const resolvedPath = path.resolve(directoryPath);
|
|
55
|
+
// Check if it's the primary directory
|
|
56
|
+
if (resolvedPath === workspace.primaryDir) {
|
|
57
|
+
container.addChild(new Text(style.red("Cannot remove the primary working directory"), 1, 0));
|
|
58
|
+
tui.requestRender();
|
|
59
|
+
editor.setText("");
|
|
60
|
+
return "continue";
|
|
61
|
+
}
|
|
62
|
+
// Find the directory in the list
|
|
63
|
+
const index = workspace.allowedDirs.indexOf(resolvedPath);
|
|
64
|
+
if (index === -1) {
|
|
65
|
+
container.addChild(new Text(style.red(`Directory not found in allowed list: ${resolvedPath}`), 1, 0));
|
|
66
|
+
tui.requestRender();
|
|
67
|
+
editor.setText("");
|
|
68
|
+
return "continue";
|
|
69
|
+
}
|
|
70
|
+
// Remove the directory
|
|
71
|
+
workspace.allowedDirs.splice(index, 1);
|
|
72
|
+
container.addChild(new Text(`Removed directory from allowed list: ${style.blue(resolvedPath)}`, 1, 0));
|
|
73
|
+
container.addChild(new Text(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`, 2, 0));
|
|
74
|
+
tui.requestRender();
|
|
75
|
+
editor.setText("");
|
|
76
|
+
return "continue";
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
80
|
+
container.addChild(new Text(style.red(`Failed to remove directory: ${errorMessage}`), 1, 0));
|
|
81
|
+
tui.requestRender();
|
|
82
|
+
editor.setText("");
|
|
83
|
+
return "continue";
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const resetCommand: ({ terminal, messageHistory, }: CommandOptions) => ReplCommand;
|
|
2
|
+
export declare const resetCommand: ({ modelManager, terminal, messageHistory, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=reset-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset-command.d.ts","sourceRoot":"","sources":["../../source/commands/reset-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reset-command.d.ts","sourceRoot":"","sources":["../../source/commands/reset-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,6CAI1B,cAAc,KAAG,WAqCnB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const resetCommand = ({ terminal, messageHistory, }) => {
|
|
1
|
+
export const resetCommand = ({ modelManager, terminal, messageHistory, }) => {
|
|
2
2
|
return {
|
|
3
3
|
command: "/reset",
|
|
4
4
|
aliases: ["/new"],
|
|
@@ -7,11 +7,22 @@ export const resetCommand = ({ terminal, messageHistory, }) => {
|
|
|
7
7
|
execute: async () => {
|
|
8
8
|
if (!messageHistory.isEmpty()) {
|
|
9
9
|
await messageHistory.save();
|
|
10
|
-
messageHistory.
|
|
10
|
+
messageHistory.create(modelManager.getModel("repl").modelId);
|
|
11
11
|
}
|
|
12
12
|
terminal.setTitle(`acai: ${process.cwd()}`);
|
|
13
13
|
terminal.clear();
|
|
14
14
|
return "continue";
|
|
15
15
|
},
|
|
16
|
+
async handle(_args, { tui, container, editor, }) {
|
|
17
|
+
if (!messageHistory.isEmpty()) {
|
|
18
|
+
await messageHistory.save();
|
|
19
|
+
messageHistory.create(modelManager.getModel("repl").modelId);
|
|
20
|
+
}
|
|
21
|
+
terminal.setTitle(`acai: ${process.cwd()}`);
|
|
22
|
+
container.clear();
|
|
23
|
+
editor.setText("");
|
|
24
|
+
tui.requestRender();
|
|
25
|
+
return "continue";
|
|
26
|
+
},
|
|
16
27
|
};
|
|
17
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/rules-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rules-command.d.ts","sourceRoot":"","sources":["../../source/commands/rules-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,cAAc,cAAc,KAAG,WA4L3D,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { config } from "../config.js";
|
|
2
2
|
import { editor } from "../terminal/editor-prompt.js";
|
|
3
|
+
import style from "../terminal/style.js";
|
|
4
|
+
import { Text } from "../tui/index.js";
|
|
3
5
|
export const rulesCommand = ({ terminal }) => {
|
|
4
6
|
return {
|
|
5
7
|
command: "/rules",
|
|
@@ -66,5 +68,68 @@ export const rulesCommand = ({ terminal }) => {
|
|
|
66
68
|
return "continue";
|
|
67
69
|
}
|
|
68
70
|
},
|
|
71
|
+
async handle(args, { tui, container, editor, }) {
|
|
72
|
+
const subCommand = args[0] ?? "view"; // Default to 'view'
|
|
73
|
+
const commandArgs = args.slice(1).join(" ");
|
|
74
|
+
try {
|
|
75
|
+
switch (subCommand) {
|
|
76
|
+
case "view": {
|
|
77
|
+
const currentContent = await config.readAgentsFile();
|
|
78
|
+
if (currentContent) {
|
|
79
|
+
container.addChild(new Text("--- Current Rules ---", 0, 1));
|
|
80
|
+
container.addChild(new Text(currentContent, 2, 0));
|
|
81
|
+
container.addChild(new Text("---------------------", 3, 0));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
container.addChild(new Text(style.yellow("No rules defined yet. Use '/rules add' or '/rules edit'."), 1, 0));
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "add": {
|
|
89
|
+
const newMemory = commandArgs.trim();
|
|
90
|
+
if (!newMemory) {
|
|
91
|
+
container.addChild(new Text(style.red("Error: Memory text cannot be empty for 'add'."), 1, 0));
|
|
92
|
+
container.addChild(new Text("Usage: /memory add <new memory text>", 2, 0));
|
|
93
|
+
tui.requestRender();
|
|
94
|
+
editor.setText("");
|
|
95
|
+
return "continue";
|
|
96
|
+
}
|
|
97
|
+
const currentContent = await config.readAgentsFile();
|
|
98
|
+
const updatedContent = currentContent
|
|
99
|
+
? `${currentContent.trim()}\n- ${newMemory}` // Ensure space after dash
|
|
100
|
+
: `- ${newMemory}`; // Start with dash if new file
|
|
101
|
+
await config.writeAgentsFile(updatedContent);
|
|
102
|
+
container.addChild(new Text(style.green("Rule added successfully"), 0, 1));
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "edit": {
|
|
106
|
+
const currentContent = await config.readAgentsFile();
|
|
107
|
+
// For TUI mode, we can't use the editor prompt, so we'll just show current content
|
|
108
|
+
if (currentContent) {
|
|
109
|
+
container.addChild(new Text("Current rules:", 0, 1));
|
|
110
|
+
container.addChild(new Text(currentContent, 2, 0));
|
|
111
|
+
container.addChild(new Text(style.dim("Note: Rule editing not available in TUI mode"), 3, 0));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
container.addChild(new Text(style.yellow("No rules defined yet. Use '/rules add' or '/rules edit'."), 1, 0));
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
default:
|
|
119
|
+
container.addChild(new Text(style.red("Invalid subcommand. Usage: /rules [view|add <text>|edit]"), 1, 0));
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
tui.requestRender();
|
|
123
|
+
editor.setText("");
|
|
124
|
+
return "continue";
|
|
125
|
+
}
|
|
126
|
+
catch (_error) {
|
|
127
|
+
// Errors from read/write helpers are already logged
|
|
128
|
+
container.addChild(new Text(style.red("Failed to execute memory command."), 0, 1));
|
|
129
|
+
tui.requestRender();
|
|
130
|
+
editor.setText("");
|
|
131
|
+
return "continue";
|
|
132
|
+
}
|
|
133
|
+
},
|
|
69
134
|
};
|
|
70
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-command.d.ts","sourceRoot":"","sources":["../../source/commands/save-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"save-command.d.ts","sourceRoot":"","sources":["../../source/commands/save-command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GAAI,+BAGzB,cAAc,KAAG,WAgCnB,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import style from "../terminal/style.js";
|
|
2
|
+
import { Spacer, Text } from "../tui/index.js";
|
|
1
3
|
export const saveCommand = ({ messageHistory, terminal, }) => {
|
|
2
4
|
return {
|
|
3
5
|
command: "/save",
|
|
@@ -10,5 +12,15 @@ export const saveCommand = ({ messageHistory, terminal, }) => {
|
|
|
10
12
|
terminal.info("Message history saved.");
|
|
11
13
|
return "continue";
|
|
12
14
|
},
|
|
15
|
+
async handle(_args, { tui, container, editor, }) {
|
|
16
|
+
if (!messageHistory.isEmpty()) {
|
|
17
|
+
await messageHistory.save();
|
|
18
|
+
}
|
|
19
|
+
container.addChild(new Spacer(1));
|
|
20
|
+
container.addChild(new Text(style.green("Message history saved."), 0, 1));
|
|
21
|
+
tui.requestRender();
|
|
22
|
+
editor.setText("");
|
|
23
|
+
return "continue";
|
|
24
|
+
},
|
|
13
25
|
};
|
|
14
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-command.d.ts","sourceRoot":"","sources":["../../source/commands/shell-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell-command.d.ts","sourceRoot":"","sources":["../../source/commands/shell-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9D,eAAO,MAAM,YAAY,GAAI,SAAS,cAAc,KAAG,WAgLtD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { initExecutionEnvironment } from "../execution/index.js";
|
|
2
2
|
import { input } from "../terminal/input-prompt.js";
|
|
3
3
|
import style from "../terminal/style.js";
|
|
4
|
+
import { SelectList, Text } from "../tui/index.js";
|
|
4
5
|
// Command execution timeout in milliseconds
|
|
5
6
|
const DEFAULT_TIMEOUT = 1.5 * 60 * 1000; // 1.5 minutes
|
|
6
7
|
export const shellCommand = (options) => {
|
|
@@ -56,5 +57,72 @@ export const shellCommand = (options) => {
|
|
|
56
57
|
}
|
|
57
58
|
return "continue";
|
|
58
59
|
},
|
|
60
|
+
async handle(args, { tui, container, editor, }) {
|
|
61
|
+
const commandStr = args.join(" ");
|
|
62
|
+
if (!commandStr.trim()) {
|
|
63
|
+
container.addChild(new Text(style.red("Provide a non-empty command."), 0, 1));
|
|
64
|
+
tui.requestRender();
|
|
65
|
+
editor.setText("");
|
|
66
|
+
return "continue";
|
|
67
|
+
}
|
|
68
|
+
const execEnv = await initExecutionEnvironment();
|
|
69
|
+
const colorEnv = {
|
|
70
|
+
["FORCE_COLOR"]: "1",
|
|
71
|
+
["CLICOLOR"]: "1",
|
|
72
|
+
["CLICOLOR_FORCE"]: "1",
|
|
73
|
+
["TERM"]: process.env["TERM"] ?? "xterm-256color",
|
|
74
|
+
["COLORTERM"]: process.env["COLORTERM"] ?? "truecolor",
|
|
75
|
+
["npm_config_color"]: "true",
|
|
76
|
+
};
|
|
77
|
+
const { output, exitCode, duration } = await execEnv.executeCommand(commandStr, {
|
|
78
|
+
cwd: process.cwd(),
|
|
79
|
+
timeout: DEFAULT_TIMEOUT,
|
|
80
|
+
preserveOutputOnError: true,
|
|
81
|
+
captureStderr: true,
|
|
82
|
+
throwOnError: false,
|
|
83
|
+
env: colorEnv,
|
|
84
|
+
});
|
|
85
|
+
container.addChild(new Text(style.gray(`Exit code: ${exitCode}, Duration: ${duration}ms`), 1, 0));
|
|
86
|
+
container.addChild(new Text(output, 2, 0));
|
|
87
|
+
// Create context selection component
|
|
88
|
+
const contextSelector = new SelectList([
|
|
89
|
+
{
|
|
90
|
+
value: "yes",
|
|
91
|
+
label: "Yes",
|
|
92
|
+
description: "Add output to prompt context",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
value: "no",
|
|
96
|
+
label: "No",
|
|
97
|
+
description: "Do not add output to context",
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
contextSelector.onSelect = (item) => {
|
|
101
|
+
if (item.value === "yes") {
|
|
102
|
+
const tokenCount = tokenCounter.count(output);
|
|
103
|
+
promptManager.addContext(output);
|
|
104
|
+
container.addChild(new Text(style.green(`Output added to prompt context. (${tokenCount} tokens)`), 3, 0));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
container.addChild(new Text(style.gray("Output not added to context."), 3, 0));
|
|
108
|
+
}
|
|
109
|
+
// Remove the selector and show final result
|
|
110
|
+
container.removeChild(contextSelector);
|
|
111
|
+
tui.requestRender();
|
|
112
|
+
editor.setText("");
|
|
113
|
+
};
|
|
114
|
+
contextSelector.onCancel = () => {
|
|
115
|
+
// User cancelled - default to not adding to context
|
|
116
|
+
container.addChild(new Text(style.gray("Output not added to context."), 3, 0));
|
|
117
|
+
container.removeChild(contextSelector);
|
|
118
|
+
tui.requestRender();
|
|
119
|
+
editor.setText("");
|
|
120
|
+
};
|
|
121
|
+
// Add the selector to the container
|
|
122
|
+
container.addChild(contextSelector);
|
|
123
|
+
tui.setFocus(contextSelector);
|
|
124
|
+
tui.requestRender();
|
|
125
|
+
return "continue";
|
|
126
|
+
},
|
|
59
127
|
};
|
|
60
128
|
};
|
package/dist/commands/types.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import type { ConfigManager } from "../config.ts";
|
|
2
|
+
import type { WorkspaceContext } from "../index.ts";
|
|
2
3
|
import type { MessageHistory } from "../messages.ts";
|
|
3
4
|
import type { ModelManager } from "../models/manager.ts";
|
|
4
5
|
import type { PromptManagerApi } from "../prompts/manager.ts";
|
|
5
6
|
import type { Terminal } from "../terminal/index.ts";
|
|
6
7
|
import type { TokenCounter } from "../tokens/counter.ts";
|
|
7
8
|
import type { TokenTracker } from "../tokens/tracker.ts";
|
|
8
|
-
import type {
|
|
9
|
-
import type { Message } from "../tools/types.ts";
|
|
9
|
+
import type { Container, Editor, TUI } from "../tui/index.ts";
|
|
10
10
|
export interface ReplCommand {
|
|
11
11
|
command: string;
|
|
12
12
|
aliases?: string[];
|
|
13
13
|
description: string;
|
|
14
14
|
getSubCommands: () => Promise<string[]>;
|
|
15
15
|
execute: (args: string[]) => Promise<"break" | "continue" | "use">;
|
|
16
|
+
handle: (args: string[], options: {
|
|
17
|
+
tui: TUI;
|
|
18
|
+
container: Container;
|
|
19
|
+
inputContainer: Container;
|
|
20
|
+
editor: Editor;
|
|
21
|
+
}) => Promise<"break" | "continue" | "use">;
|
|
16
22
|
}
|
|
17
23
|
export interface CommandOptions {
|
|
18
24
|
promptManager: PromptManagerApi;
|
|
@@ -22,8 +28,7 @@ export interface CommandOptions {
|
|
|
22
28
|
tokenTracker: TokenTracker;
|
|
23
29
|
config: ConfigManager;
|
|
24
30
|
tokenCounter: TokenCounter;
|
|
25
|
-
toolEvents: Map<string, Message[]>;
|
|
26
|
-
toolExecutor?: ToolExecutor;
|
|
27
31
|
promptHistory: string[];
|
|
32
|
+
workspace: WorkspaceContext;
|
|
28
33
|
}
|
|
29
34
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../source/commands/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../source/commands/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC,CAAC;IACnE,MAAM,EAAE,CACN,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;QACP,GAAG,EAAE,GAAG,CAAC;QACT,SAAS,EAAE,SAAS,CAAC;QACrB,cAAc,EAAE,SAAS,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;KAChB,KACE,OAAO,CAAC,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,gBAAgB,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-command.d.ts","sourceRoot":"","sources":["../../source/commands/usage-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usage-command.d.ts","sourceRoot":"","sources":["../../source/commands/usage-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,YAAY,GACb,EAAE,cAAc,GAAG,WAAW,CA+C9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Modal, Container as ModalContainer, ModalTable, ModalText, } from "../tui/index.js";
|
|
1
2
|
export function usageCommand({ terminal, tokenTracker, }) {
|
|
2
3
|
return {
|
|
3
4
|
command: "/usage",
|
|
@@ -16,5 +17,26 @@ export function usageCommand({ terminal, tokenTracker, }) {
|
|
|
16
17
|
}
|
|
17
18
|
return "continue";
|
|
18
19
|
},
|
|
20
|
+
async handle(_args, { tui, editor }) {
|
|
21
|
+
const entries = Object.entries(tokenTracker.getUsageBreakdown());
|
|
22
|
+
// Build modal content
|
|
23
|
+
const modalContent = new ModalContainer();
|
|
24
|
+
if (entries.length === 0) {
|
|
25
|
+
modalContent.addChild(new ModalText("No usage yet.", 0, 1));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// Convert entries to table format
|
|
29
|
+
const tableData = entries.map(([app, tokens]) => [app, String(tokens)]);
|
|
30
|
+
modalContent.addChild(new ModalTable(tableData, ["App", "Tokens"]));
|
|
31
|
+
}
|
|
32
|
+
// Create and show modal
|
|
33
|
+
const modal = new Modal("Token Usage", modalContent, true, () => {
|
|
34
|
+
// Modal closed callback
|
|
35
|
+
editor.setText("");
|
|
36
|
+
tui.requestRender();
|
|
37
|
+
});
|
|
38
|
+
tui.showModal(modal);
|
|
39
|
+
return "continue";
|
|
40
|
+
},
|
|
19
41
|
};
|
|
20
42
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -3,15 +3,14 @@ declare const ProjectConfigSchema: z.ZodObject<{
|
|
|
3
3
|
logs: z.ZodOptional<z.ZodObject<{
|
|
4
4
|
path: z.ZodString;
|
|
5
5
|
}, z.core.$strip>>;
|
|
6
|
+
loop: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
7
|
+
maxIterations: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
parallelTools: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
maxDurationMs: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
}, z.core.$strip>>>;
|
|
6
11
|
tools: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
7
12
|
maxTokens: z.ZodDefault<z.ZodNumber>;
|
|
8
|
-
|
|
9
|
-
allowPipes: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
-
allowChaining: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
-
allowRedirection: z.ZodDefault<z.ZodBoolean>;
|
|
12
|
-
maxSegments: z.ZodDefault<z.ZodNumber>;
|
|
13
|
-
maxOutputBytes: z.ZodDefault<z.ZodNumber>;
|
|
14
|
-
}, z.core.$strip>>>;
|
|
13
|
+
maxResults: z.ZodDefault<z.ZodNumber>;
|
|
15
14
|
dynamicTools: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
16
15
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
17
16
|
maxTools: z.ZodDefault<z.ZodNumber>;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../source/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../source/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;iBA2CvB,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEzD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM;IAI3B,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAK1B,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOlD,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;CAKxC;AAED,qBAAa,aAAa;IACxB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;;YAOlB,WAAW;IAenB,iBAAiB,IAAI,OAAO,CAAC,aAAa,CAAC;IAe3C,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAYjC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY7C,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC;IAe9C,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc1D,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC;IAY7C,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAczD,aAAa,CACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAalC,eAAe,CACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAmClC,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;CAKjB;AAGD,eAAO,MAAM,MAAM,eAAsB,CAAC"}
|