@travisennis/acai 0.0.1 → 0.0.3
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 +3 -4
- package/dist/commands/health-command.d.ts +2 -0
- package/dist/commands/health-command.js +59 -0
- package/dist/commands/manager.js +2 -0
- package/dist/commands/paste-command.d.ts +1 -1
- package/dist/commands/paste-command.js +155 -11
- package/dist/commands/reset-command.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/models/openrouter-provider.d.ts +4 -1
- package/dist/models/openrouter-provider.js +46 -4
- package/dist/models/providers.d.ts +1 -1
- package/dist/prompts/manager.d.ts +1 -0
- package/dist/prompts/manager.js +10 -0
- package/dist/prompts.js +8 -6
- package/dist/repl.js +49 -26
- package/dist/terminal/formatting.d.ts +16 -5
- package/dist/terminal/formatting.js +40 -6
- package/dist/terminal/index.d.ts +1 -1
- package/dist/terminal/index.js +54 -14
- package/dist/terminal/markdown.js +0 -1
- package/dist/terminal/supports-color.d.ts +16 -0
- package/dist/terminal/supports-color.js +121 -0
- package/dist/terminal/supports-hyperlinks.d.ts +7 -0
- package/dist/terminal/supports-hyperlinks.js +98 -0
- package/dist/tools/bash.js +95 -117
- package/dist/tools/code-interpreter.js +11 -1
- package/dist/tools/command-validation.d.ts +7 -3
- package/dist/tools/command-validation.js +67 -23
- package/dist/tools/delete-file.d.ts +4 -1
- package/dist/tools/delete-file.js +47 -3
- package/dist/tools/git-utils.d.ts +6 -0
- package/dist/tools/git-utils.js +89 -12
- package/dist/tools/grep.d.ts +20 -0
- package/dist/tools/grep.js +128 -40
- package/dist/tools/index.d.ts +2 -18
- package/dist/tools/index.js +4 -18
- package/package.json +30 -20
- package/.acai/acai.json +0 -9
- package/.acai/prompts/add-openrouter-model.md +0 -13
- package/.acai/prompts/project-status.md +0 -4
- package/.acai/prompts/update-architecture-document.md +0 -9
- package/.acai/rules/learned-rules.md +0 -9
- package/.ai/docs/available-tools.txt +0 -3
- package/.ai/docs/cognitive_complexity_refactoring_progress.md +0 -65
- package/.ai/docs/deleted_tools.md +0 -168
- package/.ai/docs/deleted_tools_88ced9ef.md +0 -56
- package/.ai/docs/image-pasting.md +0 -46
- package/.ai/docs/initialize-app.md +0 -117
- package/.ai/docs/issue-4-plan.md +0 -44
- package/.ai/docs/marked-renderer-debug.md +0 -15
- package/.ai/docs/marked-renderer-refactor-plan.md +0 -64
- package/.ai/docs/memory-use-cases.md +0 -55
- package/.ai/docs/prompt-consistency.md +0 -31
- package/.ai/docs/refactoring-tools.md +0 -98
- package/.ai/docs/system-prompt-update.md +0 -174
- package/.ai/docs/system_prompt.txt +0 -210
- package/.ai/docs/tasks.md +0 -49
- package/.ai/plan.md +0 -131
- package/.ai/prompt.md +0 -1
- package/.ai/scripts/fetch_models.js +0 -27
- package/.ai/scripts/generateSystemPrompt.ts +0 -15
- package/.ai/scripts/list-tools.mjs +0 -4
- package/.ai/scripts/p5_geometric_shapes.js +0 -149
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -3
- package/.husky/pre-push +0 -1
- package/.ignore +0 -4
- package/AGENTS.md +0 -25
- package/ARCHITECTURE.md +0 -304
- package/TODO.md +0 -2
- package/biome.json +0 -61
- package/commitlint.config.js +0 -3
- package/dist/source/cli.d.ts +0 -19
- package/dist/source/cli.js +0 -116
- package/dist/source/commands/application-log-command.d.ts +0 -2
- package/dist/source/commands/application-log-command.js +0 -43
- package/dist/source/commands/clear-command.d.ts +0 -2
- package/dist/source/commands/clear-command.js +0 -12
- package/dist/source/commands/compact-command.d.ts +0 -2
- package/dist/source/commands/compact-command.js +0 -51
- package/dist/source/commands/copy-command.d.ts +0 -2
- package/dist/source/commands/copy-command.js +0 -51
- package/dist/source/commands/edit-command.d.ts +0 -2
- package/dist/source/commands/edit-command.js +0 -53
- package/dist/source/commands/edit-prompt-command.d.ts +0 -2
- package/dist/source/commands/edit-prompt-command.js +0 -25
- package/dist/source/commands/exit-command.d.ts +0 -2
- package/dist/source/commands/exit-command.js +0 -14
- package/dist/source/commands/files-command.d.ts +0 -2
- package/dist/source/commands/files-command.js +0 -63
- package/dist/source/commands/generate-rules-command.d.ts +0 -2
- package/dist/source/commands/generate-rules-command.js +0 -61
- package/dist/source/commands/help-command.d.ts +0 -2
- package/dist/source/commands/help-command.js +0 -19
- package/dist/source/commands/init-command.d.ts +0 -2
- package/dist/source/commands/init-command.js +0 -40
- package/dist/source/commands/last-log-command.d.ts +0 -2
- package/dist/source/commands/last-log-command.js +0 -76
- package/dist/source/commands/manager.d.ts +0 -22
- package/dist/source/commands/manager.js +0 -123
- package/dist/source/commands/model-command.d.ts +0 -2
- package/dist/source/commands/model-command.js +0 -84
- package/dist/source/commands/paste-command.d.ts +0 -2
- package/dist/source/commands/paste-command.js +0 -40
- package/dist/source/commands/prompt-command.d.ts +0 -2
- package/dist/source/commands/prompt-command.js +0 -111
- package/dist/source/commands/reset-command.d.ts +0 -2
- package/dist/source/commands/reset-command.js +0 -16
- package/dist/source/commands/rules-command.d.ts +0 -2
- package/dist/source/commands/rules-command.js +0 -68
- package/dist/source/commands/save-command.d.ts +0 -2
- package/dist/source/commands/save-command.js +0 -14
- package/dist/source/commands/types.d.ts +0 -26
- package/dist/source/commands/types.js +0 -1
- package/dist/source/commands/usage-command.d.ts +0 -2
- package/dist/source/commands/usage-command.js +0 -21
- package/dist/source/config.d.ts +0 -60
- package/dist/source/config.js +0 -193
- package/dist/source/conversation-analyzer.d.ts +0 -10
- package/dist/source/conversation-analyzer.js +0 -88
- package/dist/source/dedent.d.ts +0 -3
- package/dist/source/dedent.js +0 -38
- package/dist/source/formatting.d.ts +0 -17
- package/dist/source/formatting.js +0 -103
- package/dist/source/index.d.ts +0 -18
- package/dist/source/index.js +0 -213
- package/dist/source/logger.d.ts +0 -2
- package/dist/source/logger.js +0 -24
- package/dist/source/mentions.d.ts +0 -9
- package/dist/source/mentions.js +0 -182
- package/dist/source/messages.d.ts +0 -69
- package/dist/source/messages.js +0 -261
- package/dist/source/middleware/audit-message.d.ts +0 -5
- package/dist/source/middleware/audit-message.js +0 -95
- package/dist/source/middleware/index.d.ts +0 -2
- package/dist/source/middleware/index.js +0 -2
- package/dist/source/middleware/rate-limit.d.ts +0 -4
- package/dist/source/middleware/rate-limit.js +0 -17
- package/dist/source/models/ai-config.d.ts +0 -12
- package/dist/source/models/ai-config.js +0 -87
- package/dist/source/models/anthropic-provider.d.ts +0 -25
- package/dist/source/models/anthropic-provider.js +0 -184
- package/dist/source/models/deepseek-provider.d.ts +0 -20
- package/dist/source/models/deepseek-provider.js +0 -42
- package/dist/source/models/google-provider.d.ts +0 -19
- package/dist/source/models/google-provider.js +0 -56
- package/dist/source/models/manager.d.ts +0 -15
- package/dist/source/models/manager.js +0 -48
- package/dist/source/models/openai-provider.d.ts +0 -22
- package/dist/source/models/openai-provider.js +0 -70
- package/dist/source/models/openrouter-provider.d.ts +0 -36
- package/dist/source/models/openrouter-provider.js +0 -276
- package/dist/source/models/providers.d.ts +0 -33
- package/dist/source/models/providers.js +0 -116
- package/dist/source/models/xai-provider.d.ts +0 -20
- package/dist/source/models/xai-provider.js +0 -47
- package/dist/source/parsing.d.ts +0 -2
- package/dist/source/parsing.js +0 -18
- package/dist/source/prompts/manager.d.ts +0 -19
- package/dist/source/prompts/manager.js +0 -71
- package/dist/source/prompts.d.ts +0 -4
- package/dist/source/prompts.js +0 -158
- package/dist/source/repl-prompt.d.ts +0 -14
- package/dist/source/repl-prompt.js +0 -147
- package/dist/source/repl.d.ts +0 -27
- package/dist/source/repl.js +0 -431
- package/dist/source/terminal/formatting.d.ts +0 -37
- package/dist/source/terminal/formatting.js +0 -106
- package/dist/source/terminal/index.d.ts +0 -94
- package/dist/source/terminal/index.js +0 -420
- package/dist/source/terminal/markdown-utils.d.ts +0 -2
- package/dist/source/terminal/markdown-utils.js +0 -81
- package/dist/source/terminal/markdown.d.ts +0 -1
- package/dist/source/terminal/markdown.js +0 -111
- package/dist/source/terminal/types.d.ts +0 -71
- package/dist/source/terminal/types.js +0 -1
- package/dist/source/terminal-output.d.ts +0 -8
- package/dist/source/terminal-output.js +0 -213
- package/dist/source/terminal-output.test.d.ts +0 -8
- package/dist/source/terminal-output.test.js +0 -213
- package/dist/source/token-tracker.d.ts +0 -14
- package/dist/source/token-tracker.js +0 -53
- package/dist/source/token-utils.d.ts +0 -7
- package/dist/source/token-utils.js +0 -13
- package/dist/source/tools/agent.d.ts +0 -17
- package/dist/source/tools/agent.js +0 -87
- package/dist/source/tools/bash.d.ts +0 -19
- package/dist/source/tools/bash.js +0 -294
- package/dist/source/tools/code-interpreter.d.ts +0 -12
- package/dist/source/tools/code-interpreter.js +0 -131
- package/dist/source/tools/command-validation.d.ts +0 -8
- package/dist/source/tools/command-validation.js +0 -69
- package/dist/source/tools/delete-file.d.ts +0 -12
- package/dist/source/tools/delete-file.js +0 -56
- package/dist/source/tools/directory-tree.d.ts +0 -12
- package/dist/source/tools/directory-tree.js +0 -38
- package/dist/source/tools/edit-file.d.ts +0 -19
- package/dist/source/tools/edit-file.js +0 -107
- package/dist/source/tools/filesystem-utils.d.ts +0 -22
- package/dist/source/tools/filesystem-utils.js +0 -191
- package/dist/source/tools/git-utils.d.ts +0 -14
- package/dist/source/tools/git-utils.js +0 -64
- package/dist/source/tools/grep.d.ts +0 -17
- package/dist/source/tools/grep.js +0 -138
- package/dist/source/tools/index.d.ts +0 -161
- package/dist/source/tools/index.js +0 -209
- package/dist/source/tools/memory-read.d.ts +0 -13
- package/dist/source/tools/memory-read.js +0 -135
- package/dist/source/tools/memory-write.d.ts +0 -12
- package/dist/source/tools/memory-write.js +0 -83
- package/dist/source/tools/move-file.d.ts +0 -13
- package/dist/source/tools/move-file.js +0 -44
- package/dist/source/tools/read-file.d.ts +0 -17
- package/dist/source/tools/read-file.js +0 -86
- package/dist/source/tools/read-multiple-files.d.ts +0 -14
- package/dist/source/tools/read-multiple-files.js +0 -55
- package/dist/source/tools/save-file.d.ts +0 -17
- package/dist/source/tools/save-file.js +0 -98
- package/dist/source/tools/think.d.ts +0 -11
- package/dist/source/tools/think.js +0 -45
- package/dist/source/tools/types.d.ts +0 -29
- package/dist/source/tools/types.js +0 -14
- package/dist/source/tools/web-fetch.d.ts +0 -47
- package/dist/source/tools/web-fetch.js +0 -246
- package/dist/source/tools/web-search.d.ts +0 -13
- package/dist/source/tools/web-search.js +0 -80
- package/dist/source/utils/process.d.ts +0 -36
- package/dist/source/utils/process.js +0 -75
- package/dist/source/version.d.ts +0 -1
- package/dist/source/version.js +0 -21
- package/dist/terminal-output.d.ts +0 -8
- package/dist/terminal-output.js +0 -213
- package/dist/tools/memory-read.d.ts +0 -13
- package/dist/tools/memory-read.js +0 -135
- package/dist/tools/memory-write.d.ts +0 -12
- package/dist/tools/memory-write.js +0 -83
- package/knip.json +0 -5
- package/source/cli.ts +0 -172
- package/source/commands/application-log-command.ts +0 -53
- package/source/commands/clear-command.ts +0 -14
- package/source/commands/compact-command.ts +0 -64
- package/source/commands/copy-command.ts +0 -55
- package/source/commands/edit-command.ts +0 -63
- package/source/commands/edit-prompt-command.ts +0 -31
- package/source/commands/exit-command.ts +0 -18
- package/source/commands/files-command.ts +0 -85
- package/source/commands/generate-rules-command.ts +0 -82
- package/source/commands/help-command.ts +0 -27
- package/source/commands/init-command.ts +0 -48
- package/source/commands/last-log-command.ts +0 -88
- package/source/commands/manager.ts +0 -151
- package/source/commands/model-command.ts +0 -123
- package/source/commands/paste-command.ts +0 -62
- package/source/commands/prompt-command.ts +0 -150
- package/source/commands/reset-command.ts +0 -22
- package/source/commands/rules-command.ts +0 -76
- package/source/commands/save-command.ts +0 -20
- package/source/commands/types.ts +0 -28
- package/source/commands/usage-command.ts +0 -26
- package/source/config.ts +0 -223
- package/source/conversation-analyzer.ts +0 -115
- package/source/dedent.ts +0 -53
- package/source/formatting.ts +0 -132
- package/source/index.ts +0 -240
- package/source/logger.ts +0 -29
- package/source/mentions.ts +0 -227
- package/source/messages.ts +0 -360
- package/source/middleware/audit-message.ts +0 -133
- package/source/middleware/index.ts +0 -2
- package/source/middleware/rate-limit.ts +0 -24
- package/source/models/ai-config.ts +0 -109
- package/source/models/anthropic-provider.ts +0 -199
- package/source/models/deepseek-provider.ts +0 -53
- package/source/models/google-provider.ts +0 -68
- package/source/models/manager.ts +0 -84
- package/source/models/openai-provider.ts +0 -81
- package/source/models/openrouter-provider.ts +0 -288
- package/source/models/providers.ts +0 -197
- package/source/models/xai-provider.ts +0 -59
- package/source/parsing.ts +0 -20
- package/source/prompts/manager.ts +0 -90
- package/source/prompts.ts +0 -172
- package/source/repl-prompt.ts +0 -196
- package/source/repl.ts +0 -572
- package/source/terminal/formatting.ts +0 -121
- package/source/terminal/index.ts +0 -518
- package/source/terminal/markdown-utils.ts +0 -89
- package/source/terminal/markdown.ts +0 -155
- package/source/terminal/types.ts +0 -84
- package/source/terminal-output.test.ts +0 -266
- package/source/token-tracker.ts +0 -78
- package/source/token-utils.ts +0 -17
- package/source/tools/agent.ts +0 -107
- package/source/tools/bash.ts +0 -367
- package/source/tools/code-interpreter.ts +0 -172
- package/source/tools/command-validation.ts +0 -81
- package/source/tools/delete-file.ts +0 -71
- package/source/tools/directory-tree.ts +0 -54
- package/source/tools/edit-file.ts +0 -155
- package/source/tools/filesystem-utils.ts +0 -265
- package/source/tools/git-utils.ts +0 -70
- package/source/tools/grep.ts +0 -184
- package/source/tools/index.ts +0 -278
- package/source/tools/memory-read.ts +0 -174
- package/source/tools/memory-write.ts +0 -105
- package/source/tools/move-file.ts +0 -59
- package/source/tools/read-file.ts +0 -129
- package/source/tools/read-multiple-files.ts +0 -80
- package/source/tools/save-file.ts +0 -147
- package/source/tools/think.ts +0 -51
- package/source/tools/types.ts +0 -58
- package/source/tools/web-fetch.ts +0 -327
- package/source/tools/web-search.ts +0 -101
- package/source/utils/process.ts +0 -121
- package/source/version.ts +0 -21
- package/test/commands/copy-command.test.ts +0 -69
- package/test/config.test.ts +0 -200
- package/test/terminal/markdown-utils.test.ts +0 -124
- package/test/tools/bash-tool.test.ts +0 -58
- package/test/tools/code-interpreter.test.ts +0 -91
- package/test/tools/command-validation.test.ts +0 -48
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -30
package/biome.json
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.1.4/schema.json",
|
|
3
|
-
"files": {
|
|
4
|
-
"includes": ["source/**/*.*", "test/**/*.*"],
|
|
5
|
-
"maxSize": 1048576
|
|
6
|
-
},
|
|
7
|
-
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
|
8
|
-
"linter": {
|
|
9
|
-
"enabled": true,
|
|
10
|
-
"rules": {
|
|
11
|
-
"complexity": { "useLiteralKeys": "off" },
|
|
12
|
-
"correctness": { "noNodejsModules": "off" },
|
|
13
|
-
"performance": {},
|
|
14
|
-
"security": {},
|
|
15
|
-
"suspicious": { "noConsole": "off" },
|
|
16
|
-
"style": {
|
|
17
|
-
"noParameterAssign": "error",
|
|
18
|
-
"useAsConstAssertion": "error",
|
|
19
|
-
"useDefaultParameterLast": "error",
|
|
20
|
-
"useEnumInitializers": "error",
|
|
21
|
-
"useSelfClosingElements": "error",
|
|
22
|
-
"useSingleVarDeclarator": "error",
|
|
23
|
-
"noUnusedTemplateLiteral": "error",
|
|
24
|
-
"useNumberNamespace": "error",
|
|
25
|
-
"noInferrableTypes": "error",
|
|
26
|
-
"noUselessElse": "error",
|
|
27
|
-
"useNamingConvention": "error"
|
|
28
|
-
},
|
|
29
|
-
"nursery": { "recommended": true }
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"formatter": {
|
|
33
|
-
"enabled": true,
|
|
34
|
-
"formatWithErrors": false,
|
|
35
|
-
"indentStyle": "space",
|
|
36
|
-
"indentWidth": 2,
|
|
37
|
-
"lineEnding": "lf",
|
|
38
|
-
"lineWidth": 80,
|
|
39
|
-
"attributePosition": "auto"
|
|
40
|
-
},
|
|
41
|
-
"javascript": {
|
|
42
|
-
"formatter": {
|
|
43
|
-
"jsxQuoteStyle": "double",
|
|
44
|
-
"quoteProperties": "asNeeded",
|
|
45
|
-
"trailingCommas": "all",
|
|
46
|
-
"arrowParentheses": "always",
|
|
47
|
-
"bracketSpacing": true,
|
|
48
|
-
"bracketSameLine": false,
|
|
49
|
-
"quoteStyle": "double",
|
|
50
|
-
"attributePosition": "auto"
|
|
51
|
-
},
|
|
52
|
-
"parser": {
|
|
53
|
-
"unsafeParameterDecoratorsEnabled": true
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"html": {
|
|
57
|
-
"formatter": {
|
|
58
|
-
"enabled": true
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
package/commitlint.config.js
DELETED
package/dist/source/cli.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { MessageHistory } from "./messages.ts";
|
|
2
|
-
import type { ModelManager } from "./models/manager.js";
|
|
3
|
-
import type { PromptManager } from "./prompts/manager.ts";
|
|
4
|
-
import type { TokenTracker } from "./token-tracker.ts";
|
|
5
|
-
import type { TokenCounter } from "./token-utils.ts";
|
|
6
|
-
interface CliOptions {
|
|
7
|
-
messageHistory: MessageHistory;
|
|
8
|
-
promptManager: PromptManager;
|
|
9
|
-
modelManager: ModelManager;
|
|
10
|
-
tokenTracker: TokenTracker;
|
|
11
|
-
config: Record<PropertyKey, unknown>;
|
|
12
|
-
tokenCounter: TokenCounter;
|
|
13
|
-
}
|
|
14
|
-
export declare class Cli {
|
|
15
|
-
private options;
|
|
16
|
-
constructor(options: CliOptions);
|
|
17
|
-
run(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
package/dist/source/cli.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { generateObject, generateText, NoSuchToolError, stepCountIs, } from "ai";
|
|
2
|
-
import { logger } from "./logger.js";
|
|
3
|
-
import { AiConfig } from "./models/ai-config.js";
|
|
4
|
-
import { minSystemPrompt } from "./prompts.js";
|
|
5
|
-
import { DeleteFileTool } from "./tools/delete-file.js";
|
|
6
|
-
import { EditFileTool } from "./tools/edit-file.js";
|
|
7
|
-
import { initCliTools } from "./tools/index.js";
|
|
8
|
-
import { MoveFileTool } from "./tools/move-file.js";
|
|
9
|
-
import { SaveFileTool } from "./tools/save-file.js";
|
|
10
|
-
import { ThinkTool } from "./tools/think.js";
|
|
11
|
-
export class Cli {
|
|
12
|
-
options;
|
|
13
|
-
constructor(options) {
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
async run() {
|
|
17
|
-
const { config, promptManager, modelManager, tokenTracker, messageHistory, tokenCounter, } = this.options;
|
|
18
|
-
logger.info(config, "Config:");
|
|
19
|
-
const abortController = new AbortController();
|
|
20
|
-
const { signal } = abortController;
|
|
21
|
-
const cb = () => {
|
|
22
|
-
abortController.abort();
|
|
23
|
-
};
|
|
24
|
-
// Handle Ctrl+C (SIGINT)
|
|
25
|
-
process.on("SIGINT", cb);
|
|
26
|
-
const langModel = modelManager.getModel("cli");
|
|
27
|
-
const modelConfig = modelManager.getModelMetadata("cli");
|
|
28
|
-
const userPrompt = promptManager.get();
|
|
29
|
-
const userMsg = promptManager.getUserMessage();
|
|
30
|
-
messageHistory.appendUserMessage(userMsg);
|
|
31
|
-
const finalSystemPrompt = await minSystemPrompt();
|
|
32
|
-
const aiConfig = new AiConfig({
|
|
33
|
-
modelMetadata: modelConfig,
|
|
34
|
-
prompt: userPrompt,
|
|
35
|
-
});
|
|
36
|
-
const maxTokens = aiConfig.getMaxTokens();
|
|
37
|
-
const tools = modelConfig.supportsToolCalling
|
|
38
|
-
? await initCliTools({ tokenCounter })
|
|
39
|
-
: undefined;
|
|
40
|
-
try {
|
|
41
|
-
const result = await generateText({
|
|
42
|
-
model: langModel,
|
|
43
|
-
maxOutputTokens: maxTokens,
|
|
44
|
-
messages: [
|
|
45
|
-
{
|
|
46
|
-
role: "system",
|
|
47
|
-
content: finalSystemPrompt,
|
|
48
|
-
providerOptions: {
|
|
49
|
-
anthropic: { cacheControl: { type: "ephemeral" } },
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
...messageHistory.get(),
|
|
53
|
-
],
|
|
54
|
-
temperature: modelConfig.defaultTemperature,
|
|
55
|
-
stopWhen: stepCountIs(60),
|
|
56
|
-
maxRetries: 2,
|
|
57
|
-
providerOptions: aiConfig.getProviderOptions(),
|
|
58
|
-
tools,
|
|
59
|
-
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
60
|
-
experimental_activeTools: [
|
|
61
|
-
EditFileTool.name,
|
|
62
|
-
SaveFileTool.name,
|
|
63
|
-
MoveFileTool.name,
|
|
64
|
-
DeleteFileTool.name,
|
|
65
|
-
ThinkTool.name,
|
|
66
|
-
],
|
|
67
|
-
// biome-ignore lint/style/useNamingConvention: third-party controlled
|
|
68
|
-
experimental_repairToolCall: modelConfig.supportsToolCalling
|
|
69
|
-
? toolCallRepair(modelManager)
|
|
70
|
-
: undefined,
|
|
71
|
-
abortSignal: signal,
|
|
72
|
-
});
|
|
73
|
-
if (result.response.messages.length > 0) {
|
|
74
|
-
messageHistory.appendResponseMessages(result.response.messages);
|
|
75
|
-
}
|
|
76
|
-
// this tracks the usage of every step in the call to streamText. it's a cumulative usage.
|
|
77
|
-
tokenTracker.trackUsage("cli", result.usage);
|
|
78
|
-
process.stdout.end(result.text.endsWith("\n") ? result.text : `${result.text}\n`);
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
if (e instanceof Error) {
|
|
82
|
-
logger.error(e);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
logger.error(JSON.stringify(e, null, 2));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const toolCallRepair = (modelManager) => {
|
|
91
|
-
const fn = async ({ toolCall, tools, inputSchema, error, }) => {
|
|
92
|
-
if (NoSuchToolError.isInstance(error)) {
|
|
93
|
-
return null; // do not attempt to fix invalid tool names
|
|
94
|
-
}
|
|
95
|
-
const tool = tools[toolCall.toolName];
|
|
96
|
-
try {
|
|
97
|
-
const { object: repairedArgs } = await generateObject({
|
|
98
|
-
model: modelManager.getModel("tool-repair"),
|
|
99
|
-
schema: tool.inputSchema,
|
|
100
|
-
prompt: [
|
|
101
|
-
`The model tried to call the tool "${toolCall.toolName}" with the following arguments:`,
|
|
102
|
-
JSON.stringify(toolCall.input),
|
|
103
|
-
"The tool accepts the following schema:",
|
|
104
|
-
JSON.stringify(inputSchema(toolCall)),
|
|
105
|
-
"Please fix the arguments.",
|
|
106
|
-
].join("\n"),
|
|
107
|
-
});
|
|
108
|
-
return { ...toolCall, args: JSON.stringify(repairedArgs) };
|
|
109
|
-
}
|
|
110
|
-
catch (err) {
|
|
111
|
-
logger.error(err, `Failed to repair tool call: ${toolCall.toolName}.`);
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
return fn;
|
|
116
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { editor } from "@inquirer/prompts";
|
|
3
|
-
import { config } from "../config.js";
|
|
4
|
-
export const applicationLogCommand = ({ terminal, }) => {
|
|
5
|
-
return {
|
|
6
|
-
command: "/application-logs",
|
|
7
|
-
description: "Opens the application log file defined in acai.json in the editor.",
|
|
8
|
-
result: "continue",
|
|
9
|
-
getSubCommands: () => Promise.resolve([]),
|
|
10
|
-
execute: async () => {
|
|
11
|
-
let logFilePath;
|
|
12
|
-
try {
|
|
13
|
-
const projectConfig = await config.readProjectConfig();
|
|
14
|
-
logFilePath = projectConfig.logs?.path;
|
|
15
|
-
if (!logFilePath) {
|
|
16
|
-
terminal.error("Application log path is not defined in .acai/acai.json under the 'logs.path' key.");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const content = await readFile(logFilePath, { encoding: "utf8" });
|
|
20
|
-
// Use the editor prompt to display the content (read-only)
|
|
21
|
-
await editor({
|
|
22
|
-
message: `Viewing ${logFilePath}`,
|
|
23
|
-
// Attempt to infer postfix from file extension, default otherwise
|
|
24
|
-
postfix: logFilePath.includes(".")
|
|
25
|
-
? `.${logFilePath.split(".").pop()}`
|
|
26
|
-
: ".log",
|
|
27
|
-
default: content,
|
|
28
|
-
// By not providing an onSubmit or similar handler to write the file,
|
|
29
|
-
// and not calling writeFileSync after, this effectively becomes read-only.
|
|
30
|
-
});
|
|
31
|
-
terminal.info(`Closed log view for: ${logFilePath}`);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (logFilePath && error.code === "ENOENT") {
|
|
35
|
-
terminal.error(`Application log file not found at: ${logFilePath}`);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
terminal.error(`Error reading or displaying log file ${logFilePath ?? "specified in config"}: ${error}`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const clearCommand = ({ terminal }) => {
|
|
2
|
-
return {
|
|
3
|
-
command: "/clear",
|
|
4
|
-
description: "Clears the terminal screen.",
|
|
5
|
-
result: "continue", // Keep the REPL running
|
|
6
|
-
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
execute: () => {
|
|
8
|
-
terminal.clear();
|
|
9
|
-
return Promise.resolve();
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { generateText } from "ai";
|
|
2
|
-
import { createUserMessage } from "../messages.js";
|
|
3
|
-
export const compactCommand = (options) => {
|
|
4
|
-
return {
|
|
5
|
-
command: "/compact",
|
|
6
|
-
description: "Saves, summarizes, and resets the chat history. Optional instructions can be provided for the summary.",
|
|
7
|
-
result: "continue",
|
|
8
|
-
getSubCommands: () => Promise.resolve([]),
|
|
9
|
-
execute: async (args) => {
|
|
10
|
-
const { messageHistory, terminal } = options;
|
|
11
|
-
if (!messageHistory.isEmpty()) {
|
|
12
|
-
const additionalInstructions = args.join(" ");
|
|
13
|
-
await summarizeAndReset(options, additionalInstructions);
|
|
14
|
-
}
|
|
15
|
-
terminal.info("Message history summarized and reset.");
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
async function summarizeAndReset({ messageHistory, modelManager, tokenTracker }, additionalInstructions) {
|
|
20
|
-
const app = "conversation-summarizer";
|
|
21
|
-
// save existing message history
|
|
22
|
-
await messageHistory.save();
|
|
23
|
-
// summarize message history
|
|
24
|
-
let userPrompt = `Your tasks is to provide a detailed summary of our conversation so far. Focus on information that would be helpful for continuing the conversation and the task, including what was the orginal task requested by the user, what we have done so far and why, which files we're working on, and what we're going to do next. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently. You need to provide enough information that another coding agent can you use your summary to pick up where you have left off.
|
|
25
|
-
|
|
26
|
-
Your summary should include the following sections:
|
|
27
|
-
1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
|
|
28
|
-
2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
|
|
29
|
-
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
|
|
30
|
-
4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
|
|
31
|
-
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
|
|
32
|
-
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
|
|
33
|
-
7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
|
|
34
|
-
8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
|
35
|
-
9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests without confirming with the user first.
|
|
36
|
-
|
|
37
|
-
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.`;
|
|
38
|
-
if (additionalInstructions && additionalInstructions.trim().length > 0) {
|
|
39
|
-
userPrompt += `\n\nAdditional instructions provided by the user: ${additionalInstructions}`;
|
|
40
|
-
}
|
|
41
|
-
messageHistory.appendUserMessage(createUserMessage([], userPrompt));
|
|
42
|
-
const { text, usage } = await generateText({
|
|
43
|
-
model: modelManager.getModel(app),
|
|
44
|
-
system: "You are a helpful AI assistant tasked with summarizing conversations so that a coding agent such as yourself can understand what actions have been taken on a code base and what future work still needs to be done.",
|
|
45
|
-
messages: messageHistory.get(),
|
|
46
|
-
});
|
|
47
|
-
tokenTracker.trackUsage(app, usage);
|
|
48
|
-
//clear messages
|
|
49
|
-
messageHistory.clear();
|
|
50
|
-
messageHistory.appendUserMessage(createUserMessage([text]));
|
|
51
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import Clipboard from "@crosscopy/clipboard";
|
|
2
|
-
function extractLastAssistantText(messages) {
|
|
3
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
4
|
-
const msg = messages[i];
|
|
5
|
-
if (!msg)
|
|
6
|
-
continue;
|
|
7
|
-
if (msg.role !== "assistant")
|
|
8
|
-
continue;
|
|
9
|
-
if (!("content" in msg) || !Array.isArray(msg.content))
|
|
10
|
-
continue;
|
|
11
|
-
// Find last text part
|
|
12
|
-
for (let j = msg.content.length - 1; j >= 0; j--) {
|
|
13
|
-
const part = msg.content[j];
|
|
14
|
-
if (part &&
|
|
15
|
-
part.type === "text" &&
|
|
16
|
-
typeof part.text === "string") {
|
|
17
|
-
const text = part.text;
|
|
18
|
-
if (text.trim().length > 0)
|
|
19
|
-
return text;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
export function copyCommand(options) {
|
|
26
|
-
return {
|
|
27
|
-
command: "/copy",
|
|
28
|
-
description: "Copy the last assistant response to the clipboard",
|
|
29
|
-
result: "continue",
|
|
30
|
-
async getSubCommands() {
|
|
31
|
-
return [];
|
|
32
|
-
},
|
|
33
|
-
async execute(_args) {
|
|
34
|
-
const { messageHistory, terminal } = options;
|
|
35
|
-
const history = messageHistory.get();
|
|
36
|
-
const lastText = extractLastAssistantText(history);
|
|
37
|
-
if (!lastText) {
|
|
38
|
-
terminal.info("No assistant response to copy.");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
await Clipboard.setText(lastText);
|
|
43
|
-
terminal.success("Copied last response to clipboard.");
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
47
|
-
terminal.error(`Could not copy to clipboard: ${message}`);
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { extname, resolve } from "node:path";
|
|
3
|
-
import { editor, search } from "@inquirer/prompts";
|
|
4
|
-
import { globby } from "globby";
|
|
5
|
-
export const editCommand = ({ terminal }) => {
|
|
6
|
-
return {
|
|
7
|
-
command: "/edit",
|
|
8
|
-
description: "Opens file in $EDITOR for editing. Usage: /edit [file-path]",
|
|
9
|
-
result: "continue",
|
|
10
|
-
getSubCommands: () => Promise.resolve([]),
|
|
11
|
-
execute: async (args) => {
|
|
12
|
-
let fileToEdit;
|
|
13
|
-
if (args.length > 0) {
|
|
14
|
-
// File path provided as argument
|
|
15
|
-
const filePath = args.join(" "); // Handle file paths with spaces
|
|
16
|
-
const resolvedPath = resolve(filePath);
|
|
17
|
-
if (!existsSync(resolvedPath)) {
|
|
18
|
-
terminal.error(`File not found: ${filePath}`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
fileToEdit = filePath;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
// No file path provided, use search prompt
|
|
25
|
-
fileToEdit = await search({
|
|
26
|
-
message: "Search for file:",
|
|
27
|
-
source: async (input) => {
|
|
28
|
-
if (!input) {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
const foundFiles = await globby(`**/*${input}*`, {
|
|
32
|
-
gitignore: true,
|
|
33
|
-
});
|
|
34
|
-
return foundFiles.map((file) => ({
|
|
35
|
-
name: file,
|
|
36
|
-
value: file,
|
|
37
|
-
}));
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
const content = readFileSync(fileToEdit, { encoding: "utf8" });
|
|
42
|
-
const edit = await editor({
|
|
43
|
-
message: `Edit ${fileToEdit}?`,
|
|
44
|
-
postfix: extname(fileToEdit),
|
|
45
|
-
default: content,
|
|
46
|
-
});
|
|
47
|
-
writeFileSync(fileToEdit, edit);
|
|
48
|
-
if (content !== edit) {
|
|
49
|
-
terminal.info(`File updated: ${fileToEdit}`);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { editor } from "@inquirer/prompts";
|
|
2
|
-
import { syncTry } from "@travisennis/stdlib/try";
|
|
3
|
-
export const editPromptCommand = ({ terminal, promptManager, }) => {
|
|
4
|
-
return {
|
|
5
|
-
command: "/edit-prompt",
|
|
6
|
-
description: "Edit the prompt.",
|
|
7
|
-
result: "use",
|
|
8
|
-
getSubCommands: () => Promise.resolve([]),
|
|
9
|
-
execute: async () => {
|
|
10
|
-
try {
|
|
11
|
-
const prompt = syncTry(() => promptManager.get());
|
|
12
|
-
const updatedPrompt = await editor({
|
|
13
|
-
message: " Edit prompt?",
|
|
14
|
-
postfix: "md",
|
|
15
|
-
default: prompt.unwrapOr(""),
|
|
16
|
-
});
|
|
17
|
-
terminal.writeln(`> ${updatedPrompt}`);
|
|
18
|
-
promptManager.set(updatedPrompt);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
terminal.error(`Error updating prompt: ${error.message}`);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const exitCommand = ({ messageHistory, }) => {
|
|
2
|
-
return {
|
|
3
|
-
command: "/exit",
|
|
4
|
-
aliases: ["/bye", "/quit"],
|
|
5
|
-
description: "Exits and saves the chat history.",
|
|
6
|
-
result: "break",
|
|
7
|
-
getSubCommands: () => Promise.resolve([]),
|
|
8
|
-
execute: async () => {
|
|
9
|
-
if (!messageHistory.isEmpty()) {
|
|
10
|
-
await messageHistory.save();
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { checkbox } from "@inquirer/prompts";
|
|
3
|
-
import { globby } from "globby";
|
|
4
|
-
import { formatFile } from "../formatting.js";
|
|
5
|
-
import { TokenCounter } from "../token-utils.js";
|
|
6
|
-
export const filesCommand = ({ terminal, promptManager, modelManager, }) => {
|
|
7
|
-
return {
|
|
8
|
-
command: "/files",
|
|
9
|
-
description: "Finds files matching the given patterns and adds their content to the next prompt. Usage: /files or /files src/**/*.ts",
|
|
10
|
-
result: "continue",
|
|
11
|
-
getSubCommands: () => Promise.resolve([]),
|
|
12
|
-
execute: async (args) => {
|
|
13
|
-
try {
|
|
14
|
-
let workingFiles = [];
|
|
15
|
-
if (!args || args.length === 0) {
|
|
16
|
-
// Get all files in the current directory
|
|
17
|
-
const foundFiles = await globby("**/*", { gitignore: true });
|
|
18
|
-
const selectedFiles = await checkbox({
|
|
19
|
-
message: "Select files to include:",
|
|
20
|
-
choices: foundFiles,
|
|
21
|
-
pageSize: 15,
|
|
22
|
-
});
|
|
23
|
-
if (selectedFiles.length === 0) {
|
|
24
|
-
terminal.warn("No files selected.");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
// Process the selected files
|
|
28
|
-
workingFiles = selectedFiles;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const patternList = args.filter(Boolean);
|
|
32
|
-
const foundFiles = await globby(patternList, { gitignore: true });
|
|
33
|
-
if (foundFiles.length === 0) {
|
|
34
|
-
terminal.warn("No files found matching the pattern(s)");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// Process the selected files
|
|
38
|
-
workingFiles = foundFiles;
|
|
39
|
-
}
|
|
40
|
-
// Read the content of the files and format them for the next prompt
|
|
41
|
-
const format = modelManager.getModelMetadata("repl").promptFormat;
|
|
42
|
-
let tokenCount = 0;
|
|
43
|
-
const tokenCounter = new TokenCounter();
|
|
44
|
-
await Promise.all(workingFiles.map(async (filePath) => {
|
|
45
|
-
try {
|
|
46
|
-
const content = await readFile(filePath, "utf-8");
|
|
47
|
-
const formattedFile = formatFile(filePath, content, format);
|
|
48
|
-
tokenCount += tokenCounter.count(formattedFile);
|
|
49
|
-
promptManager.addContext(formattedFile);
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
terminal.error(`Error reading file ${filePath}: ${error.message}`);
|
|
53
|
-
}
|
|
54
|
-
}));
|
|
55
|
-
tokenCounter.free();
|
|
56
|
-
terminal.success(`File contents will be added to your next prompt (${workingFiles.length} files, ${tokenCount} tokens)`);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
terminal.error(`Error processing file patterns: ${error.message}`);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { checkbox } from "@inquirer/prompts";
|
|
2
|
-
import { analyzeConversation } from "../conversation-analyzer.js";
|
|
3
|
-
import { logger } from "../logger.js"; // Import logger
|
|
4
|
-
async function _processAndSaveRules(newRules, terminal, config) {
|
|
5
|
-
if (!newRules || newRules.length === 0) {
|
|
6
|
-
terminal.warn("No new generalizable rules were identified.");
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
terminal.info("Generated potential rules:");
|
|
10
|
-
terminal.lineBreak();
|
|
11
|
-
const rulesToKeep = await checkbox({
|
|
12
|
-
message: "Select the rules you want to keep:",
|
|
13
|
-
choices: newRules.map((rule) => ({ name: rule, value: rule })),
|
|
14
|
-
});
|
|
15
|
-
if (rulesToKeep.length === 0) {
|
|
16
|
-
terminal.warn("No rules selected to save.");
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
terminal.info("Saving selected rules...");
|
|
20
|
-
const existingRules = await config.readProjectLearnedRulesFile();
|
|
21
|
-
const rulesToAdd = rulesToKeep.join("\n");
|
|
22
|
-
const updatedProjectRules = existingRules.endsWith("\n") || existingRules.length === 0
|
|
23
|
-
? `${existingRules}${rulesToAdd}`
|
|
24
|
-
: `${existingRules}\n${rulesToAdd}`;
|
|
25
|
-
await config.writeProjectLearnedRulesFile(updatedProjectRules);
|
|
26
|
-
terminal.success("Selected rules saved to project learned rules.");
|
|
27
|
-
terminal.lineBreak();
|
|
28
|
-
terminal.display(rulesToAdd); // Display only the saved rules
|
|
29
|
-
}
|
|
30
|
-
export const generateRulesCommand = ({ terminal, messageHistory, modelManager, tokenTracker, config, // This is the config module from CommandOptions
|
|
31
|
-
}) => {
|
|
32
|
-
return {
|
|
33
|
-
command: "/generate-rules",
|
|
34
|
-
description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
|
|
35
|
-
result: "continue",
|
|
36
|
-
getSubCommands: () => Promise.resolve([]),
|
|
37
|
-
execute: async () => {
|
|
38
|
-
if (messageHistory.isEmpty()) {
|
|
39
|
-
terminal.writeln("Cannot generate rules from an empty conversation.");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
terminal.lineBreak();
|
|
43
|
-
terminal.info("Analyzing conversation to generate rules...");
|
|
44
|
-
try {
|
|
45
|
-
const newRules = await analyzeConversation({
|
|
46
|
-
modelManager,
|
|
47
|
-
messages: messageHistory.get(),
|
|
48
|
-
tokenTracker,
|
|
49
|
-
terminal,
|
|
50
|
-
});
|
|
51
|
-
// Pass the config object available in CommandOptions scope
|
|
52
|
-
await _processAndSaveRules(newRules, terminal, config);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
56
|
-
terminal.error(`Error generating rules: ${errorMessage}`);
|
|
57
|
-
logger.error(error, "Error during rule generation:");
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const helpCommand = ({ terminal }, cmds) => {
|
|
2
|
-
return {
|
|
3
|
-
command: "/help",
|
|
4
|
-
description: "Shows available commands.",
|
|
5
|
-
result: "continue",
|
|
6
|
-
getSubCommands: () => Promise.resolve([]),
|
|
7
|
-
execute: () => {
|
|
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 Promise.resolve();
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
};
|