@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
|
@@ -3,67 +3,15 @@ import { config } from "../config.js";
|
|
|
3
3
|
import { logger } from "../logger.js"; // Import logger
|
|
4
4
|
import { createUserMessage } from "../messages.js";
|
|
5
5
|
import { systemPrompt } from "../prompts.js";
|
|
6
|
-
import { checkbox } from "../terminal/checkbox-prompt.js";
|
|
7
6
|
import { getTerminalSize } from "../terminal/formatting.js";
|
|
8
7
|
import style from "../terminal/style.js";
|
|
9
8
|
import { Container, Input, Spacer, Text, } from "../tui/index.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
terminal.warn("No new generalizable rules were identified.");
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
terminal.info("Generated potential rules:");
|
|
16
|
-
terminal.lineBreak();
|
|
17
|
-
const rulesToKeep = await checkbox({
|
|
18
|
-
message: "Select the rules you want to keep:",
|
|
19
|
-
choices: newRules.map((rule) => ({ name: rule, value: rule })),
|
|
20
|
-
});
|
|
21
|
-
if (rulesToKeep.length === 0) {
|
|
22
|
-
terminal.warn("No rules selected to save.");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
terminal.info("Saving selected rules...");
|
|
26
|
-
const existingRules = await config.readProjectLearnedRulesFile();
|
|
27
|
-
const rulesToAdd = rulesToKeep.join("\n");
|
|
28
|
-
const updatedProjectRules = existingRules.endsWith("\n") || existingRules.length === 0
|
|
29
|
-
? `${existingRules}${rulesToAdd}`
|
|
30
|
-
: `${existingRules}\n${rulesToAdd}`;
|
|
31
|
-
await config.writeProjectLearnedRulesFile(updatedProjectRules);
|
|
32
|
-
terminal.success("Selected rules saved to project learned rules.");
|
|
33
|
-
terminal.lineBreak();
|
|
34
|
-
terminal.display(rulesToAdd); // Display only the saved rules
|
|
35
|
-
}
|
|
36
|
-
export const generateRulesCommand = ({ terminal, messageHistory, modelManager, tokenTracker, config, // This is the config module from CommandOptions
|
|
37
|
-
}) => {
|
|
9
|
+
export const generateRulesCommand = ({ messageHistory, modelManager, tokenTracker, config, // This is the config module from CommandOptions
|
|
10
|
+
workspace, }) => {
|
|
38
11
|
return {
|
|
39
12
|
command: "/generate-rules",
|
|
40
13
|
description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
|
|
41
14
|
getSubCommands: () => Promise.resolve([]),
|
|
42
|
-
execute: async () => {
|
|
43
|
-
if (messageHistory.isEmpty()) {
|
|
44
|
-
terminal.writeln("Cannot generate rules from an empty conversation.");
|
|
45
|
-
return "continue";
|
|
46
|
-
}
|
|
47
|
-
terminal.lineBreak();
|
|
48
|
-
terminal.info("Analyzing conversation to generate rules...");
|
|
49
|
-
try {
|
|
50
|
-
const newRules = await analyzeConversation({
|
|
51
|
-
modelManager,
|
|
52
|
-
messages: messageHistory.get(),
|
|
53
|
-
tokenTracker,
|
|
54
|
-
terminal,
|
|
55
|
-
});
|
|
56
|
-
// Pass the config object available in CommandOptions scope
|
|
57
|
-
await _processAndSaveRules(newRules, terminal, config);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
61
|
-
terminal.error(`Error generating rules: ${errorMessage}`);
|
|
62
|
-
logger.error(error, "Error during rule generation:");
|
|
63
|
-
return "continue";
|
|
64
|
-
}
|
|
65
|
-
return "continue";
|
|
66
|
-
},
|
|
67
15
|
async handle(_args, { tui, container, inputContainer, editor, }) {
|
|
68
16
|
if (messageHistory.isEmpty()) {
|
|
69
17
|
container.addChild(new Text(style.yellow("Cannot generate rules from an empty conversation."), 1, 0));
|
|
@@ -78,7 +26,8 @@ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, t
|
|
|
78
26
|
modelManager,
|
|
79
27
|
messages: messageHistory.get(),
|
|
80
28
|
tokenTracker,
|
|
81
|
-
|
|
29
|
+
config,
|
|
30
|
+
workspace,
|
|
82
31
|
});
|
|
83
32
|
if (!newRules || newRules.length === 0) {
|
|
84
33
|
container.addChild(new Text(style.yellow("No new generalizable rules were identified."), 2, 0));
|
|
@@ -137,7 +86,15 @@ export const generateRulesCommand = ({ terminal, messageHistory, modelManager, t
|
|
|
137
86
|
};
|
|
138
87
|
};
|
|
139
88
|
// Modified System Prompt
|
|
140
|
-
const system = async () =>
|
|
89
|
+
const system = async (configManager, workspace) => {
|
|
90
|
+
const projectConfig = await configManager.getConfig();
|
|
91
|
+
const sys = await systemPrompt({
|
|
92
|
+
type: projectConfig.systemPromptType,
|
|
93
|
+
activeTools: projectConfig.tools.activeTools,
|
|
94
|
+
includeRules: true,
|
|
95
|
+
allowedDirs: workspace.allowedDirs,
|
|
96
|
+
});
|
|
97
|
+
return `You are an expert analyst reviewing conversations between a coding agent and a software engineer. Your goal is to identify instances where the engineer corrected the agent's approach or understanding in a way that reveals a *generalizable principle* for improving the agent's future behavior across *different* tasks.
|
|
141
98
|
|
|
142
99
|
**Your Task:**
|
|
143
100
|
1. Analyze the conversation provided.
|
|
@@ -171,10 +128,11 @@ const system = async () => `You are an expert analyst reviewing conversations be
|
|
|
171
128
|
|
|
172
129
|
This is the original system prompt the agent operated under:
|
|
173
130
|
<systemPrompt>
|
|
174
|
-
${
|
|
131
|
+
${sys}
|
|
175
132
|
</systemPrompt>`;
|
|
176
|
-
|
|
177
|
-
|
|
133
|
+
};
|
|
134
|
+
async function analyzeConversation({ modelManager, messages, tokenTracker, config: configManager, workspace, }) {
|
|
135
|
+
const learnedRules = await configManager.readCachedLearnedRulesFile();
|
|
178
136
|
// Modified User Message within analyzeConversation
|
|
179
137
|
messages.push(createUserMessage([
|
|
180
138
|
`Analyze this conversation based on the system instructions. Identify points where the user made significant corrections revealing general principles for agent improvement. Infer concise, broadly applicable rules (Always/Never) based *only* on these corrections.
|
|
@@ -193,7 +151,7 @@ ${learnedRules}
|
|
|
193
151
|
const { text, usage } = await generateText({
|
|
194
152
|
model: modelManager.getModel("conversation-analyzer"),
|
|
195
153
|
maxOutputTokens: 8192,
|
|
196
|
-
system: await system(),
|
|
154
|
+
system: await system(configManager, workspace),
|
|
197
155
|
messages: messages,
|
|
198
156
|
});
|
|
199
157
|
tokenTracker.trackUsage("conversation-analyzer", usage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoff-command.d.ts","sourceRoot":"","sources":["../../source/commands/handoff-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":"handoff-command.d.ts","sourceRoot":"","sources":["../../source/commands/handoff-command.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WAoDxD,CAAC"}
|
|
@@ -7,17 +7,6 @@ export const handoffCommand = (options) => {
|
|
|
7
7
|
command: "/handoff",
|
|
8
8
|
description: "Creates a detailed handoff plan of the conversation for continuing the work in a new session. Usage: /handoff <the purpose of the handoff>",
|
|
9
9
|
getSubCommands: () => Promise.resolve([]),
|
|
10
|
-
execute: async (args) => {
|
|
11
|
-
const { terminal } = options;
|
|
12
|
-
// Validate that purpose is provided
|
|
13
|
-
const purpose = args.join(" ").trim();
|
|
14
|
-
if (!purpose) {
|
|
15
|
-
terminal.error("Please provide a purpose for the handoff. Usage: /handoff <the purpose of the handoff>");
|
|
16
|
-
return "continue";
|
|
17
|
-
}
|
|
18
|
-
await createHandoffDocument(options, purpose);
|
|
19
|
-
return "continue";
|
|
20
|
-
},
|
|
21
10
|
async handle(args, { tui, container, editor, }) {
|
|
22
11
|
// Validate that purpose is provided
|
|
23
12
|
const purpose = args.join(" ").trim();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
2
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
3
|
-
export declare function healthCommand(
|
|
3
|
+
export declare function healthCommand(_options: CommandOptions, execFn?: typeof execSync): ReplCommand;
|
|
4
4
|
//# sourceMappingURL=health-command.d.ts.map
|
|
@@ -1 +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;AAI9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,
|
|
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;AAI9C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,cAAc,EACxB,MAAM,kBAAW,GAChB,WAAW,CAiKb"}
|
|
@@ -1,110 +1,11 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
2
|
import { formatMemoryUsage } from "../formatting.js";
|
|
3
|
-
import { Container, Modal,
|
|
4
|
-
export function healthCommand(
|
|
3
|
+
import { Container, Modal, ModalText, TableComponent } from "../tui/index.js";
|
|
4
|
+
export function healthCommand(_options, execFn = execSync) {
|
|
5
5
|
return {
|
|
6
6
|
command: "/health",
|
|
7
7
|
description: "Show application health status and environment variables",
|
|
8
8
|
getSubCommands: () => Promise.resolve([]),
|
|
9
|
-
async execute() {
|
|
10
|
-
// Define the environment variables we care about
|
|
11
|
-
const envVars = [
|
|
12
|
-
// AI Provider API Keys
|
|
13
|
-
{ name: "OPENAI_API_KEY", description: "OpenAI (GPT models)" },
|
|
14
|
-
{ name: "ANTHROPIC_API_KEY", description: "Anthropic (Claude models)" },
|
|
15
|
-
{
|
|
16
|
-
name: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
17
|
-
description: "Google (Gemini models)",
|
|
18
|
-
},
|
|
19
|
-
{ name: "DEEPSEEK_API_KEY", description: "DeepSeek" },
|
|
20
|
-
{ name: "GROQ_API_KEY", description: "Groq (multiple models)" },
|
|
21
|
-
{ name: "X_AI_API_KEY", description: "X.AI (Grok models)" },
|
|
22
|
-
{ name: "XAI_API_KEY", description: "X.AI (Grok models - alt)" },
|
|
23
|
-
{
|
|
24
|
-
name: "OPENROUTER_API_KEY",
|
|
25
|
-
description: "OpenRouter (multiple models)",
|
|
26
|
-
},
|
|
27
|
-
// Web Service API Keys
|
|
28
|
-
{ name: "EXA_API_KEY", description: "Exa (enhanced web search)" },
|
|
29
|
-
{
|
|
30
|
-
name: "JINA_READER_API_KEY",
|
|
31
|
-
description: "Jina Reader (web content extraction)",
|
|
32
|
-
},
|
|
33
|
-
// Application Configuration
|
|
34
|
-
{ name: "LOG_LEVEL", description: "Logging level" },
|
|
35
|
-
];
|
|
36
|
-
// Check each environment variable
|
|
37
|
-
const envStatus = envVars.map((envVar) => {
|
|
38
|
-
const value = process.env[envVar.name];
|
|
39
|
-
const hasValue = value !== undefined && value !== null && value.trim() !== "";
|
|
40
|
-
const status = hasValue ? "✓ Set" : "✗ Not set";
|
|
41
|
-
return [envVar.name, status, envVar.description];
|
|
42
|
-
});
|
|
43
|
-
// Display the table
|
|
44
|
-
terminal.writeln("Environment Variables Status:");
|
|
45
|
-
terminal.table(envStatus, {
|
|
46
|
-
header: ["Variable", "Status", "Description"],
|
|
47
|
-
colWidths: [30, 15, 55],
|
|
48
|
-
});
|
|
49
|
-
// Count how many are set (derived from envStatus to avoid re-checking process.env)
|
|
50
|
-
const setCount = envStatus.filter((row) => row[1] === "✓ Set").length;
|
|
51
|
-
const totalCount = envVars.length;
|
|
52
|
-
terminal.info(`Summary: ${setCount}/${totalCount} environment variables are set`);
|
|
53
|
-
if (setCount === 0) {
|
|
54
|
-
terminal.warn("⚠️ No AI provider API keys are configured. The app may not function properly.");
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
terminal.info("✓ At least one AI provider is configured.");
|
|
58
|
-
}
|
|
59
|
-
// Check for required bash tools
|
|
60
|
-
const tools = [
|
|
61
|
-
{ name: "git", command: "git --version" },
|
|
62
|
-
{ name: "gh", command: "gh --version" },
|
|
63
|
-
{ name: "rg", command: "rg --version" },
|
|
64
|
-
{ name: "fd", command: "fd --version" },
|
|
65
|
-
{ name: "ast-grep", command: "ast-grep --version" },
|
|
66
|
-
{ name: "jq", command: "jq --version" },
|
|
67
|
-
{ name: "yq", command: "yq --version" },
|
|
68
|
-
];
|
|
69
|
-
const toolStatus = tools.map((tool) => {
|
|
70
|
-
let status = "✗ Not installed";
|
|
71
|
-
try {
|
|
72
|
-
execFn(tool.command, { stdio: "ignore", timeout: 5000 });
|
|
73
|
-
status = "✓ Installed";
|
|
74
|
-
}
|
|
75
|
-
catch (_error) {
|
|
76
|
-
// Ignore error, tool is not installed
|
|
77
|
-
}
|
|
78
|
-
return [tool.name, status];
|
|
79
|
-
});
|
|
80
|
-
terminal.lineBreak();
|
|
81
|
-
terminal.writeln("Bash Tools Status:");
|
|
82
|
-
terminal.table(toolStatus, {
|
|
83
|
-
header: ["Tool", "Status"],
|
|
84
|
-
colWidths: [15, 20],
|
|
85
|
-
});
|
|
86
|
-
const installedCount = toolStatus.filter((row) => row[1] === "✓ Installed").length;
|
|
87
|
-
const totalTools = tools.length;
|
|
88
|
-
terminal.info(`Tool Summary: ${installedCount}/${totalTools} tools are installed.`);
|
|
89
|
-
if (installedCount < totalTools) {
|
|
90
|
-
terminal.warn("⚠️ Some tools are missing. Install them for full functionality.");
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
terminal.info("✓ All required tools are installed.");
|
|
94
|
-
}
|
|
95
|
-
terminal.lineBreak();
|
|
96
|
-
terminal.writeln("Current Process:");
|
|
97
|
-
// Display memory usage
|
|
98
|
-
const usage = process.memoryUsage().rss;
|
|
99
|
-
const formattedUsage = formatMemoryUsage(usage);
|
|
100
|
-
if (usage >= 2 * 1024 * 1024 * 1024) {
|
|
101
|
-
terminal.error(`Memory Usage: ${formattedUsage}`);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
terminal.info(`Memory Usage: ${formattedUsage}`);
|
|
105
|
-
}
|
|
106
|
-
return "continue";
|
|
107
|
-
},
|
|
108
9
|
async handle(_args, { tui, editor }) {
|
|
109
10
|
// Define the environment variables we care about
|
|
110
11
|
const envVars = [
|
|
@@ -172,7 +73,9 @@ export function healthCommand({ terminal }, execFn = execSync) {
|
|
|
172
73
|
const modalContent = new Container();
|
|
173
74
|
// Environment variables section
|
|
174
75
|
modalContent.addChild(new ModalText("Environment Variables Status:", 0, 1));
|
|
175
|
-
modalContent.addChild(new
|
|
76
|
+
modalContent.addChild(new TableComponent(envStatus, {
|
|
77
|
+
headers: ["Variable", "Status", "Description"],
|
|
78
|
+
}));
|
|
176
79
|
const envSummary = `Summary: ${setCount}/${totalCount} environment variables are set`;
|
|
177
80
|
modalContent.addChild(new ModalText(envSummary, 0, 1));
|
|
178
81
|
if (setCount === 0) {
|
|
@@ -184,7 +87,9 @@ export function healthCommand({ terminal }, execFn = execSync) {
|
|
|
184
87
|
// Tools section
|
|
185
88
|
modalContent.addChild(new ModalText("", 0, 1)); // Spacer
|
|
186
89
|
modalContent.addChild(new ModalText("Bash Tools Status:", 0, 1));
|
|
187
|
-
modalContent.addChild(new
|
|
90
|
+
modalContent.addChild(new TableComponent(toolStatus, {
|
|
91
|
+
headers: ["Tool", "Status"],
|
|
92
|
+
}));
|
|
188
93
|
const toolSummary = `Tool Summary: ${installedCount}/${totalTools} tools are installed.`;
|
|
189
94
|
modalContent.addChild(new ModalText(toolSummary, 0, 1));
|
|
190
95
|
if (installedCount < totalTools) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const helpCommand: (
|
|
2
|
+
export declare const helpCommand: (_options: CommandOptions, cmds: Map<string, ReplCommand>) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=help-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-command.d.ts","sourceRoot":"","sources":["../../source/commands/help-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GACtB,
|
|
1
|
+
{"version":3,"file":"help-command.d.ts","sourceRoot":"","sources":["../../source/commands/help-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D,eAAO,MAAM,WAAW,GACtB,UAAU,cAAc,EACxB,MAAM,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,KAC7B,WA6CF,CAAC"}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { Modal, Container as ModalContainer,
|
|
2
|
-
export const helpCommand = (
|
|
1
|
+
import { Modal, Container as ModalContainer, ModalText, TableComponent, } from "../tui/index.js";
|
|
2
|
+
export const helpCommand = (_options, cmds) => {
|
|
3
3
|
return {
|
|
4
4
|
command: "/help",
|
|
5
5
|
description: "Shows available commands.",
|
|
6
6
|
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
execute: async () => {
|
|
8
|
-
const commands = cmds;
|
|
9
|
-
const entries = Array.from(commands.entries())
|
|
10
|
-
.sort(([a], [b]) => a.localeCompare(b))
|
|
11
|
-
.map(([key, cmd]) => [key, cmd.description]);
|
|
12
|
-
terminal.table(entries, {
|
|
13
|
-
header: ["Command", "Description"],
|
|
14
|
-
colWidths: [30, 70],
|
|
15
|
-
});
|
|
16
|
-
return "continue";
|
|
17
|
-
},
|
|
18
7
|
async handle(_args, { tui, editor }) {
|
|
19
8
|
const commands = cmds;
|
|
20
9
|
const entries = Array.from(commands.entries())
|
|
@@ -31,7 +20,10 @@ export const helpCommand = ({ terminal }, cmds) => {
|
|
|
31
20
|
command,
|
|
32
21
|
description,
|
|
33
22
|
]);
|
|
34
|
-
modalContent.addChild(new
|
|
23
|
+
modalContent.addChild(new TableComponent(tableData, {
|
|
24
|
+
headers: ["Command", "Description"],
|
|
25
|
+
colWidths: [30, 70],
|
|
26
|
+
}));
|
|
35
27
|
}
|
|
36
28
|
// Create and show modal
|
|
37
29
|
const modal = new Modal("Available Commands", modalContent, true, () => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const historyCommand: ({ messageHistory,
|
|
2
|
+
export declare const historyCommand: ({ messageHistory, config, modelManager, tokenTracker, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=history-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-command.d.ts","sourceRoot":"","sources":["../../source/commands/history-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"history-command.d.ts","sourceRoot":"","sources":["../../source/commands/history-command.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA2K9D,eAAO,MAAM,cAAc,GAAI,yDAK5B,cAAc,KAAG,WAkJnB,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { writeFile } from "node:fs/promises";
|
|
2
2
|
import { generateText } from "ai";
|
|
3
3
|
import { MessageHistory } from "../messages.js";
|
|
4
|
-
import { getTerminalSize } from "../terminal/formatting.js";
|
|
5
|
-
import { select } from "../terminal/select-prompt.js";
|
|
4
|
+
import { getTerminalSize, setTerminalTitle } from "../terminal/formatting.js";
|
|
6
5
|
import style from "../terminal/style.js";
|
|
7
|
-
import { Container, Input, Spacer, Text } from "../tui/index.js";
|
|
8
|
-
async function exportConversation(history
|
|
6
|
+
import { Container, Input, Markdown, Spacer, Text } from "../tui/index.js";
|
|
7
|
+
async function exportConversation(history) {
|
|
9
8
|
const sanitizedTitle = history.title
|
|
10
9
|
.replace(/[^a-zA-Z0-9\s-_]/g, "")
|
|
11
10
|
.replace(/\s+/g, "-")
|
|
@@ -13,14 +12,8 @@ async function exportConversation(history, terminal) {
|
|
|
13
12
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, -5);
|
|
14
13
|
const filename = `${sanitizedTitle}_${timestamp}.md`;
|
|
15
14
|
const markdownContent = generateMarkdown(history);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
terminal.info(`Conversation exported to: ${filename}`);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
terminal.error(`Failed to export conversation: ${error}`);
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
15
|
+
await writeFile(filename, markdownContent);
|
|
16
|
+
return filename;
|
|
24
17
|
}
|
|
25
18
|
function generateMarkdown(history) {
|
|
26
19
|
const lines = [];
|
|
@@ -96,7 +89,7 @@ function generateMarkdown(history) {
|
|
|
96
89
|
});
|
|
97
90
|
return lines.join("\n");
|
|
98
91
|
}
|
|
99
|
-
async function summarizeConversation(history,
|
|
92
|
+
async function summarizeConversation(history, modelManager, tokenTracker) {
|
|
100
93
|
const systemPrompt = `You are an expert at summarizing conversations between a coding assistant and a user. Your task is to provide a clear, concise summary of the conversation that captures:
|
|
101
94
|
|
|
102
95
|
1. The main topic and objectives
|
|
@@ -122,99 +115,24 @@ Keep the summary focused and informative, around 3-5 paragraphs. Use plain text
|
|
|
122
115
|
})
|
|
123
116
|
.filter((text) => text?.trim())
|
|
124
117
|
.join("\n\n");
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
catch (error) {
|
|
138
|
-
terminal.error(`Failed to generate summary: ${error}`);
|
|
139
|
-
throw error;
|
|
140
|
-
}
|
|
118
|
+
const { text, usage } = await generateText({
|
|
119
|
+
model: modelManager.getModel("conversation-summarizer"),
|
|
120
|
+
system: systemPrompt,
|
|
121
|
+
prompt: `Please summarize this conversation:\n\n${conversationText}`,
|
|
122
|
+
});
|
|
123
|
+
tokenTracker.trackUsage("conversation-summarizer", usage);
|
|
124
|
+
const results = [];
|
|
125
|
+
results.push(`# Summary of "${history.title}":`);
|
|
126
|
+
results.push("");
|
|
127
|
+
results.push(text);
|
|
128
|
+
results.push("");
|
|
129
|
+
return results.join("\n");
|
|
141
130
|
}
|
|
142
|
-
export const historyCommand = ({ messageHistory,
|
|
131
|
+
export const historyCommand = ({ messageHistory, config, modelManager, tokenTracker, }) => {
|
|
143
132
|
return {
|
|
144
133
|
command: "/history",
|
|
145
134
|
description: "Browse and manage previous conversations.",
|
|
146
135
|
getSubCommands: () => Promise.resolve([]),
|
|
147
|
-
execute: async () => {
|
|
148
|
-
const appDir = config.app;
|
|
149
|
-
const messageHistoryDir = await appDir.ensurePath("message-history");
|
|
150
|
-
// Load all histories (use a large number to get all)
|
|
151
|
-
const histories = await MessageHistory.load(messageHistoryDir, 1000);
|
|
152
|
-
if (histories.length === 0) {
|
|
153
|
-
terminal.info("No previous conversations found.");
|
|
154
|
-
return "continue";
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
// Step 1: Select conversation
|
|
158
|
-
const conversationChoice = await select({
|
|
159
|
-
message: "Select a conversation:",
|
|
160
|
-
choices: histories.map((h, index) => ({
|
|
161
|
-
name: `${index + 1}: ${h.title} (${h.updatedAt.toLocaleString()})`,
|
|
162
|
-
value: index,
|
|
163
|
-
description: `${h.messages.length} messages`,
|
|
164
|
-
})),
|
|
165
|
-
pageSize: 15,
|
|
166
|
-
});
|
|
167
|
-
const selectedHistory = histories.at(conversationChoice);
|
|
168
|
-
if (!selectedHistory) {
|
|
169
|
-
terminal.error("Selected history index out of bounds.");
|
|
170
|
-
return "continue";
|
|
171
|
-
}
|
|
172
|
-
// Step 2: Select action
|
|
173
|
-
const actionChoice = await select({
|
|
174
|
-
message: `What would you like to do with "${selectedHistory.title}"?`,
|
|
175
|
-
choices: [
|
|
176
|
-
{
|
|
177
|
-
name: "Resume - Continue this conversation",
|
|
178
|
-
value: "resume",
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
name: "Export - Save as markdown file",
|
|
182
|
-
value: "export",
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: "Summarize - Generate AI summary of conversation",
|
|
186
|
-
value: "summarize",
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
pageSize: 5,
|
|
190
|
-
});
|
|
191
|
-
switch (actionChoice) {
|
|
192
|
-
case "resume":
|
|
193
|
-
messageHistory.restore(selectedHistory);
|
|
194
|
-
terminal.info(`Resuming conversation: ${selectedHistory.title}`);
|
|
195
|
-
terminal.setTitle(selectedHistory.title || `acai: ${process.cwd()}`);
|
|
196
|
-
break;
|
|
197
|
-
case "export":
|
|
198
|
-
await exportConversation(selectedHistory, terminal);
|
|
199
|
-
break;
|
|
200
|
-
case "summarize":
|
|
201
|
-
await summarizeConversation(selectedHistory, terminal, modelManager, tokenTracker);
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
// Handle Ctrl-C cancellation
|
|
207
|
-
if (error instanceof Error &&
|
|
208
|
-
"isCanceled" in error &&
|
|
209
|
-
error.isCanceled === true) {
|
|
210
|
-
terminal.info("Operation cancelled.");
|
|
211
|
-
return "continue";
|
|
212
|
-
}
|
|
213
|
-
// Re-throw other errors
|
|
214
|
-
throw error;
|
|
215
|
-
}
|
|
216
|
-
return "continue";
|
|
217
|
-
},
|
|
218
136
|
async handle(_args, { tui, container, inputContainer, editor, }) {
|
|
219
137
|
const appDir = config.app;
|
|
220
138
|
const messageHistoryDir = await appDir.ensurePath("message-history");
|
|
@@ -235,12 +153,12 @@ export const historyCommand = ({ messageHistory, terminal, config, modelManager,
|
|
|
235
153
|
case "resume":
|
|
236
154
|
messageHistory.restore(conversation);
|
|
237
155
|
container.addChild(new Text(style.green(`Resuming conversation: ${conversation.title}`), 0, 1));
|
|
238
|
-
|
|
156
|
+
setTerminalTitle(conversation.title || `acai: ${process.cwd()}`);
|
|
239
157
|
break;
|
|
240
158
|
case "export":
|
|
241
159
|
try {
|
|
242
|
-
await exportConversation(conversation
|
|
243
|
-
container.addChild(new Text(style.green(
|
|
160
|
+
const destFile = await exportConversation(conversation);
|
|
161
|
+
container.addChild(new Text(style.green(`Conversation exported successfully: ${destFile}`), 1, 0));
|
|
244
162
|
}
|
|
245
163
|
catch (error) {
|
|
246
164
|
container.addChild(new Text(style.red(`Failed to export conversation: ${error}`), 1, 0));
|
|
@@ -248,8 +166,14 @@ export const historyCommand = ({ messageHistory, terminal, config, modelManager,
|
|
|
248
166
|
break;
|
|
249
167
|
case "summarize":
|
|
250
168
|
try {
|
|
251
|
-
await summarizeConversation(conversation,
|
|
252
|
-
container.addChild(new
|
|
169
|
+
const result = await summarizeConversation(conversation, modelManager, tokenTracker);
|
|
170
|
+
container.addChild(new Markdown(result, {
|
|
171
|
+
customBgRgb: {
|
|
172
|
+
r: 52,
|
|
173
|
+
g: 53,
|
|
174
|
+
b: 65,
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
253
177
|
}
|
|
254
178
|
catch (error) {
|
|
255
179
|
container.addChild(new Text(style.red(`Failed to summarize conversation: ${error}`), 1, 0));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const initCommand: ({
|
|
2
|
+
export declare const initCommand: ({ modelManager, tokenCounter, workspace, }: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=init-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../source/commands/init-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9D,eAAO,MAAM,WAAW,GAAI,
|
|
1
|
+
{"version":3,"file":"init-command.d.ts","sourceRoot":"","sources":["../../source/commands/init-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9D,eAAO,MAAM,WAAW,GAAI,4CAIzB,cAAc,KAAG,WAkDnB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { platform } from "node:os";
|
|
2
2
|
import { stepCountIs, streamText } from "ai";
|
|
3
3
|
import style from "../terminal/style.js";
|
|
4
|
-
import { inGitDirectory } from "../tools/git-utils.js";
|
|
5
4
|
import { initCliTools } from "../tools/index.js";
|
|
6
5
|
import { Markdown, Spacer, Text } from "../tui/index.js";
|
|
6
|
+
import { inGitDirectory } from "../utils/git.js";
|
|
7
7
|
const initPrompt = `Please analyze this codebase and create a AGENTS.md file containing:
|
|
8
8
|
1. An overview of the project including how the project is structured and the tech stack used.
|
|
9
9
|
2. Build/lint/test commands - especially for running a single test
|
|
@@ -22,27 +22,11 @@ If there are Cursor rules (in .cursor/rules/ or .cursorrules), Copilot rules (in
|
|
|
22
22
|
Your current working directory is ${process.cwd()}
|
|
23
23
|
Is directory a git repo: ${(await inGitDirectory()) ? "Yes" : "No"}
|
|
24
24
|
Platform: ${platform()}`;
|
|
25
|
-
export const initCommand = ({
|
|
25
|
+
export const initCommand = ({ modelManager, tokenCounter, workspace, }) => {
|
|
26
26
|
return {
|
|
27
27
|
command: "/init",
|
|
28
28
|
description: "Creates the AGENTS.md file.",
|
|
29
29
|
getSubCommands: () => Promise.resolve([]),
|
|
30
|
-
execute: async () => {
|
|
31
|
-
const result = streamText({
|
|
32
|
-
model: modelManager.getModel("init-project"),
|
|
33
|
-
temperature: 0.5,
|
|
34
|
-
prompt: initPrompt,
|
|
35
|
-
stopWhen: stepCountIs(40),
|
|
36
|
-
tools: (await initCliTools({
|
|
37
|
-
tokenCounter,
|
|
38
|
-
workspace,
|
|
39
|
-
})).toolDefs,
|
|
40
|
-
});
|
|
41
|
-
for await (const text of result.textStream) {
|
|
42
|
-
terminal.write(text);
|
|
43
|
-
}
|
|
44
|
-
return "continue";
|
|
45
|
-
},
|
|
46
30
|
async handle(_args, { tui, container, editor, }) {
|
|
47
31
|
container.addChild(new Text("Initializing project and creating AGENTS.md...", 1, 1));
|
|
48
32
|
tui.requestRender();
|
|
@@ -51,14 +35,11 @@ export const initCommand = ({ terminal, modelManager, tokenCounter, workspace, }
|
|
|
51
35
|
temperature: 0.5,
|
|
52
36
|
prompt: initPrompt,
|
|
53
37
|
stopWhen: stepCountIs(40),
|
|
54
|
-
tools: (await initCliTools({
|
|
55
|
-
tokenCounter,
|
|
56
|
-
workspace,
|
|
57
|
-
})).toolDefs,
|
|
38
|
+
tools: (await initCliTools({ tokenCounter, workspace })).toolDefs,
|
|
58
39
|
});
|
|
59
40
|
container.addChild(new Spacer(1));
|
|
60
41
|
let output = "";
|
|
61
|
-
const t = new Markdown(output,
|
|
42
|
+
const t = new Markdown(output, { paddingX: 1, paddingY: 0 });
|
|
62
43
|
container.addChild(t);
|
|
63
44
|
for await (const text of result.textStream) {
|
|
64
45
|
output += text;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CommandOptions, ReplCommand } from "./types.ts";
|
|
2
|
-
export declare const lastLogCommand: (
|
|
2
|
+
export declare const lastLogCommand: (_options: CommandOptions) => ReplCommand;
|
|
3
3
|
//# sourceMappingURL=last-log-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/last-log-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"last-log-command.d.ts","sourceRoot":"","sources":["../../source/commands/last-log-command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAyC9D,eAAO,MAAM,cAAc,GAAI,UAAU,cAAc,KAAG,WAiEzD,CAAC"}
|