@travisennis/acai 0.0.12 → 0.0.14
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 +5 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +91 -5
- package/dist/commands/history/types.d.ts +3 -2
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/init-project/utils.d.ts +0 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +1 -1
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +0 -18
- package/dist/commands/share/html-renderer.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.js +54 -48
- package/dist/commands/tools/index.js +39 -38
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -7
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -76
- package/dist/models/manager.d.ts +1 -10
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +2 -2
- package/dist/models/opencode-go-provider.d.ts +6 -4
- package/dist/models/opencode-go-provider.d.ts.map +1 -1
- package/dist/models/opencode-go-provider.js +55 -35
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/prompts/system-prompt.d.ts +0 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -1
- package/dist/prompts/system-prompt.js +6 -10
- package/dist/repl/index.d.ts +27 -11
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +238 -254
- package/dist/sessions/manager.d.ts +41 -0
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +53 -0
- package/dist/sessions/summary.d.ts.map +1 -1
- package/dist/sessions/summary.js +18 -0
- package/dist/skills/index.d.ts +12 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +123 -73
- package/dist/terminal/control.d.ts +1 -21
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +1 -32
- package/dist/terminal/formatting.d.ts +0 -33
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +0 -91
- package/dist/terminal/highlight/theme.d.ts +0 -37
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +1 -79
- package/dist/terminal/keys.d.ts +0 -97
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +0 -194
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +65 -51
- package/dist/terminal/style.d.ts +1 -1
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +38 -20
- package/dist/terminal/supports-hyperlinks.d.ts +3 -0
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -1
- package/dist/terminal/supports-hyperlinks.js +72 -31
- package/dist/terminal/table/layout-manager.d.ts +0 -20
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +68 -44
- package/dist/terminal/table/utils.d.ts +0 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +2 -4
- package/dist/tools/apply-patch.d.ts +5 -3
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +154 -123
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +11 -8
- package/dist/tools/dynamic-tool-loader.d.ts +6 -1
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +154 -135
- package/dist/tools/index.d.ts +3 -133
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -20
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +32 -13
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +20 -13
- package/dist/tools/web-fetch.d.ts +2 -6
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +59 -36
- package/dist/tools/web-search.d.ts +0 -4
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +40 -32
- package/dist/tui/autocomplete/utils.d.ts +0 -15
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +0 -85
- package/dist/tui/autocomplete.d.ts +1 -1
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +1 -1
- package/dist/tui/components/editor.d.ts +12 -0
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +181 -195
- package/dist/tui/components/input.d.ts +4 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +33 -31
- package/dist/tui/components/markdown.d.ts +30 -0
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +274 -242
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +11 -11
- package/dist/tui/components/select-list.d.ts +5 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +69 -98
- package/dist/tui/components/table.d.ts +6 -0
- package/dist/tui/components/table.d.ts.map +1 -1
- package/dist/tui/components/table.js +61 -52
- package/dist/tui/index.d.ts +1 -8
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +0 -8
- package/dist/tui/tui.d.ts +9 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +78 -48
- package/dist/tui/utils.d.ts +7 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +117 -53
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +156 -104
- package/dist/utils/command-protection.d.ts +3 -6
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +213 -100
- package/dist/utils/filesystem/operations.d.ts +0 -15
- package/dist/utils/filesystem/operations.d.ts.map +1 -1
- package/dist/utils/filesystem/operations.js +1 -38
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +22 -15
- package/dist/utils/filetype-detection.d.ts +0 -1
- package/dist/utils/filetype-detection.d.ts.map +1 -1
- package/dist/utils/filetype-detection.js +0 -12
- package/dist/utils/formatting.d.ts +0 -30
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +0 -44
- package/dist/utils/git.d.ts +4 -6
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +36 -46
- package/dist/utils/ignore.d.ts +1 -1
- package/dist/utils/ignore.d.ts.map +1 -1
- package/dist/utils/ignore.js +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +77 -79
- package/dist/utils/yaml.d.ts +0 -1
- package/dist/utils/yaml.d.ts.map +1 -1
- package/dist/utils/yaml.js +80 -89
- package/dist/utils/zod.d.ts +0 -3
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +0 -7
- package/package.json +25 -24
- package/dist/agent/sub-agent.d.ts +0 -23
- package/dist/agent/sub-agent.d.ts.map +0 -1
- package/dist/agent/sub-agent.js +0 -109
- package/dist/commands/add-directory/index.d.ts +0 -3
- package/dist/commands/add-directory/index.d.ts.map +0 -1
- package/dist/commands/add-directory/index.js +0 -50
- package/dist/commands/add-directory/utils.d.ts +0 -3
- package/dist/commands/add-directory/utils.d.ts.map +0 -1
- package/dist/commands/add-directory/utils.js +0 -15
- package/dist/commands/clear/index.d.ts +0 -3
- package/dist/commands/clear/index.d.ts.map +0 -1
- package/dist/commands/clear/index.js +0 -13
- package/dist/commands/generate-rules/index.d.ts +0 -3
- package/dist/commands/generate-rules/index.d.ts.map +0 -1
- package/dist/commands/generate-rules/index.js +0 -206
- package/dist/commands/generate-rules/service.d.ts +0 -22
- package/dist/commands/generate-rules/service.d.ts.map +0 -1
- package/dist/commands/generate-rules/service.js +0 -103
- package/dist/commands/generate-rules/utils.d.ts +0 -5
- package/dist/commands/generate-rules/utils.d.ts.map +0 -1
- package/dist/commands/generate-rules/utils.js +0 -25
- package/dist/commands/handoff/index.d.ts +0 -3
- package/dist/commands/handoff/index.d.ts.map +0 -1
- package/dist/commands/handoff/index.js +0 -97
- package/dist/commands/handoff/utils.d.ts +0 -4
- package/dist/commands/handoff/utils.d.ts.map +0 -1
- package/dist/commands/handoff/utils.js +0 -123
- package/dist/commands/list-directories/index.d.ts +0 -3
- package/dist/commands/list-directories/index.d.ts.map +0 -1
- package/dist/commands/list-directories/index.js +0 -35
- package/dist/commands/pickup/index.d.ts +0 -3
- package/dist/commands/pickup/index.d.ts.map +0 -1
- package/dist/commands/pickup/index.js +0 -141
- package/dist/commands/pickup/types.d.ts +0 -6
- package/dist/commands/pickup/types.d.ts.map +0 -1
- package/dist/commands/pickup/types.js +0 -1
- package/dist/commands/pickup/utils.d.ts +0 -7
- package/dist/commands/pickup/utils.d.ts.map +0 -1
- package/dist/commands/pickup/utils.js +0 -56
- package/dist/commands/remove-directory/index.d.ts +0 -3
- package/dist/commands/remove-directory/index.d.ts.map +0 -1
- package/dist/commands/remove-directory/index.js +0 -55
- package/dist/commands/review/index.d.ts +0 -3
- package/dist/commands/review/index.d.ts.map +0 -1
- package/dist/commands/review/index.js +0 -12
- package/dist/commands/review/review-panel.d.ts +0 -3
- package/dist/commands/review/review-panel.d.ts.map +0 -1
- package/dist/commands/review/review-panel.js +0 -186
- package/dist/commands/review/utils.d.ts +0 -18
- package/dist/commands/review/utils.d.ts.map +0 -1
- package/dist/commands/review/utils.js +0 -146
- package/dist/commands/shell/index.d.ts +0 -3
- package/dist/commands/shell/index.d.ts.map +0 -1
- package/dist/commands/shell/index.js +0 -96
- package/dist/subagents/index.d.ts +0 -16
- package/dist/subagents/index.d.ts.map +0 -1
- package/dist/subagents/index.js +0 -231
- package/dist/terminal/index.d.ts +0 -9
- package/dist/terminal/index.d.ts.map +0 -1
- package/dist/terminal/index.js +0 -8
- package/dist/tools/agent.d.ts +0 -27
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -81
- package/dist/tools/directory-tree.d.ts +0 -28
- package/dist/tools/directory-tree.d.ts.map +0 -1
- package/dist/tools/directory-tree.js +0 -154
- package/dist/tools/glob.d.ts +0 -35
- package/dist/tools/glob.d.ts.map +0 -1
- package/dist/tools/glob.js +0 -167
- package/dist/tools/grep.d.ts +0 -100
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -608
- package/dist/tools/ls.d.ts +0 -26
- package/dist/tools/ls.d.ts.map +0 -1
- package/dist/tools/ls.js +0 -83
- package/dist/tui/components/header.d.ts +0 -21
- package/dist/tui/components/header.d.ts.map +0 -1
- package/dist/tui/components/header.js +0 -63
- package/dist/utils/bash/parse.d.ts +0 -19
- package/dist/utils/bash/parse.d.ts.map +0 -1
- package/dist/utils/bash/parse.js +0 -223
- package/dist/utils/bash/quote.d.ts +0 -6
- package/dist/utils/bash/quote.d.ts.map +0 -1
- package/dist/utils/bash/quote.js +0 -23
- package/dist/utils/generators.d.ts +0 -3
- package/dist/utils/generators.d.ts.map +0 -1
- package/dist/utils/generators.js +0 -25
- package/dist/utils/glob.d.ts +0 -52
- package/dist/utils/glob.d.ts.map +0 -1
- package/dist/utils/glob.js +0 -376
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Acai is an AI-driven command-line tool that assists software developers with cod
|
|
|
19
19
|
|
|
20
20
|
## Prerequisites
|
|
21
21
|
|
|
22
|
-
- Node.js
|
|
22
|
+
- Node.js 24 or higher
|
|
23
23
|
- Git
|
|
24
24
|
- [Ripgrep](https://github.com/BurntSushi/ripgrep) (`rg`) - Fast file content searching
|
|
25
25
|
- [GitHub CLI](https://cli.github.com/) (`gh`) - Git operations and repository management
|
|
@@ -75,13 +75,14 @@ Reference files directly with `@filename`, directories with `@dirname`, or run s
|
|
|
75
75
|
- **Pino** for structured logging
|
|
76
76
|
- **Zod** for schema validation
|
|
77
77
|
- **Biome** for formatting and linting
|
|
78
|
+
- **Fallow** for dead code, duplication, and complexity analysis
|
|
78
79
|
|
|
79
80
|
## Project Structure
|
|
80
81
|
|
|
81
82
|
```
|
|
82
83
|
.
|
|
83
84
|
├── source/ # Main application source code
|
|
84
|
-
│ ├── agent/ # Agent loop
|
|
85
|
+
│ ├── agent/ # Agent loop
|
|
85
86
|
│ ├── cli.ts # CLI entry point
|
|
86
87
|
│ ├── commands/ # REPL command implementations
|
|
87
88
|
│ ├── execution/ # Command execution utilities
|
|
@@ -110,6 +111,8 @@ Reference files directly with `@filename`, directories with `@dirname`, or run s
|
|
|
110
111
|
- [Dynamic Tools](docs/dynamic-tools.md) - Creating custom tools to extend acai (supports bash, python, and other languages; Amp-compatible text schema format; `/tools make` scaffolding command)
|
|
111
112
|
- [Architecture](ARCHITECTURE.md) - Internal architecture and flow diagrams
|
|
112
113
|
- [Contributing](CONTRIBUTING.md) - Development setup, scripts, and code style
|
|
114
|
+
- [Agent Instructions](AGENTS.md) - Routing guide for AI agents working in this repo
|
|
115
|
+
- [Agent Guardrails](docs/guardrails/) - Focused compatibility, security, testing, and documentation rules
|
|
113
116
|
|
|
114
117
|
## Acknowledgments
|
|
115
118
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/agent/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;
|
|
1
|
+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AC,gBAAgB;YA0BV,sBAAsB;IA4EpC,OAAO,CAAC,kBAAkB;YAuCZ,iBAAiB;IAoG/B,OAAO,CAAC,iBAAiB;CA6B1B"}
|
package/dist/agent/index.js
CHANGED
|
@@ -2,6 +2,42 @@ import { generateText, InvalidToolInputError, NoOutputGeneratedError, NoSuchTool
|
|
|
2
2
|
import { AiConfig } from "../models/ai-config.js";
|
|
3
3
|
import { toAiSdkTools } from "../tools/utils.js";
|
|
4
4
|
import { logger } from "../utils/logger.js";
|
|
5
|
+
/**
|
|
6
|
+
* Whether a stream chunk carries model output (used to mark time-to-first-token).
|
|
7
|
+
*/
|
|
8
|
+
function isContentChunk(chunk) {
|
|
9
|
+
return (chunk.type === "text-delta" ||
|
|
10
|
+
chunk.type === "reasoning-delta" ||
|
|
11
|
+
chunk.type === "tool-call");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Rough input-token estimate for the request.start event. Real input token
|
|
15
|
+
* counts are reported on request.end from provider usage.
|
|
16
|
+
*/
|
|
17
|
+
function estimateInputTokens(messages, systemPrompt) {
|
|
18
|
+
const chars = systemPrompt.length + JSON.stringify(messages).length;
|
|
19
|
+
return Math.ceil(chars / 4);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Selects provider response headers worth keeping for telemetry: request id,
|
|
23
|
+
* rate-limit headers, and retry hints. Header names vary per provider.
|
|
24
|
+
*/
|
|
25
|
+
function extractProviderHeaders(headers) {
|
|
26
|
+
if (!headers) {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
const out = {};
|
|
30
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
31
|
+
const lower = key.toLowerCase();
|
|
32
|
+
if (lower === "x-request-id" ||
|
|
33
|
+
lower === "retry-after" ||
|
|
34
|
+
lower.includes("ratelimit") ||
|
|
35
|
+
lower.includes("rate-limit")) {
|
|
36
|
+
out[lower] = value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
5
41
|
export class Agent {
|
|
6
42
|
opts;
|
|
7
43
|
config;
|
|
@@ -30,7 +66,7 @@ export class Agent {
|
|
|
30
66
|
const { systemPrompt, input, tools, activeTools, abortSignal } = args;
|
|
31
67
|
this.resetState();
|
|
32
68
|
this._state.timestamps.start = performance.now();
|
|
33
|
-
const { modelManager, sessionManager
|
|
69
|
+
const { modelManager, sessionManager } = this.opts;
|
|
34
70
|
const maxIterations = args.maxIterations ?? this.config.loop.maxIterations ?? 200;
|
|
35
71
|
const maxRetries = args.maxRetries ?? 2;
|
|
36
72
|
const langModel = modelManager.getModel("repl");
|
|
@@ -55,6 +91,9 @@ export class Agent {
|
|
|
55
91
|
type: "step-start",
|
|
56
92
|
};
|
|
57
93
|
const toolsCalled = new Map();
|
|
94
|
+
const requestId = `${sessionManager.getSessionId()}:${iter}`;
|
|
95
|
+
const requestStart = performance.now();
|
|
96
|
+
let firstTokenAt = null;
|
|
58
97
|
try {
|
|
59
98
|
// Check abort signal again before starting streamText
|
|
60
99
|
if (abortSignal?.aborted) {
|
|
@@ -62,6 +101,15 @@ export class Agent {
|
|
|
62
101
|
}
|
|
63
102
|
const messages = sessionManager.get();
|
|
64
103
|
const aiSdkTools = toAiSdkTools(tools, false);
|
|
104
|
+
logger.info({
|
|
105
|
+
event: "model.request.start",
|
|
106
|
+
requestId,
|
|
107
|
+
sessionId: sessionManager.getSessionId(),
|
|
108
|
+
model: modelConfig.id,
|
|
109
|
+
provider: modelConfig.provider,
|
|
110
|
+
iteration: iter,
|
|
111
|
+
inputTokenEstimate: estimateInputTokens(messages, systemPrompt),
|
|
112
|
+
}, "model.request.start");
|
|
65
113
|
const result = streamText({
|
|
66
114
|
model: langModel,
|
|
67
115
|
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
@@ -103,6 +151,14 @@ export class Agent {
|
|
|
103
151
|
});
|
|
104
152
|
const pendingToolCalls = [];
|
|
105
153
|
for await (const chunk of result.fullStream) {
|
|
154
|
+
if (firstTokenAt === null && isContentChunk(chunk)) {
|
|
155
|
+
firstTokenAt = performance.now();
|
|
156
|
+
logger.info({
|
|
157
|
+
event: "model.first_token",
|
|
158
|
+
requestId,
|
|
159
|
+
ttftMs: Math.round(firstTokenAt - requestStart),
|
|
160
|
+
}, "model.first_token");
|
|
161
|
+
}
|
|
106
162
|
const event = this.handleStreamChunk(chunk, {
|
|
107
163
|
accumulatedText,
|
|
108
164
|
accumulatedReasoning,
|
|
@@ -116,9 +172,11 @@ export class Agent {
|
|
|
116
172
|
yield event.agentEvent;
|
|
117
173
|
}
|
|
118
174
|
}
|
|
175
|
+
const modelStreamEnd = performance.now();
|
|
119
176
|
// ============================================================
|
|
120
177
|
// PARALLEL TOOL EXECUTION
|
|
121
178
|
// ============================================================
|
|
179
|
+
const toolStart = performance.now();
|
|
122
180
|
const { collectedEvents, parallelToolMessages } = await this.executeToolsInParallel({
|
|
123
181
|
pendingToolCalls,
|
|
124
182
|
abortSignal,
|
|
@@ -126,6 +184,7 @@ export class Agent {
|
|
|
126
184
|
stepToolCalls: thisStepToolCalls,
|
|
127
185
|
stepToolResults: thisStepToolResults,
|
|
128
186
|
});
|
|
187
|
+
const toolEnd = performance.now();
|
|
129
188
|
// Yield all collected events in order
|
|
130
189
|
for (const event of collectedEvents) {
|
|
131
190
|
yield event;
|
|
@@ -143,9 +202,36 @@ export class Agent {
|
|
|
143
202
|
this.updateUsageStats(stepUsage, sessionManager);
|
|
144
203
|
// If finishReason is not tool-calls, break
|
|
145
204
|
const finishReason = await result.finishReason;
|
|
205
|
+
const modelResponseMs = modelStreamEnd - requestStart;
|
|
206
|
+
const toolMs = toolEnd - toolStart;
|
|
207
|
+
const wallClockMs = performance.now() - requestStart;
|
|
208
|
+
const outputTokens = stepUsage.outputTokens ?? 0;
|
|
209
|
+
logger.info({
|
|
210
|
+
event: "model.request.end",
|
|
211
|
+
requestId,
|
|
212
|
+
model: modelConfig.id,
|
|
213
|
+
provider: modelConfig.provider,
|
|
214
|
+
modelResponseMs: Math.round(modelResponseMs),
|
|
215
|
+
ttftMs: firstTokenAt === null
|
|
216
|
+
? null
|
|
217
|
+
: Math.round(firstTokenAt - requestStart),
|
|
218
|
+
inputTokens: stepUsage.inputTokens ?? 0,
|
|
219
|
+
outputTokens,
|
|
220
|
+
outputTokensPerSecond: modelResponseMs > 0
|
|
221
|
+
? Number((outputTokens / (modelResponseMs / 1000)).toFixed(2))
|
|
222
|
+
: 0,
|
|
223
|
+
reasoningTokens: stepUsage.outputTokenDetails.reasoningTokens ?? 0,
|
|
224
|
+
finishReason,
|
|
225
|
+
retryCount: consecutiveErrors,
|
|
226
|
+
providerRequestId: response.id ?? null,
|
|
227
|
+
providerHeaders: extractProviderHeaders(response.headers),
|
|
228
|
+
}, "model.request.end");
|
|
229
|
+
sessionManager.recordTurnTiming({
|
|
230
|
+
wallClockMs,
|
|
231
|
+
modelMs: modelResponseMs,
|
|
232
|
+
toolMs,
|
|
233
|
+
});
|
|
146
234
|
if (finishReason !== "tool-calls") {
|
|
147
|
-
// Track aggregate usage before yielding agent-stop so footer can display it
|
|
148
|
-
tokenTracker.trackUsage("repl", this._state.totalUsage);
|
|
149
235
|
yield {
|
|
150
236
|
type: "agent-stop",
|
|
151
237
|
};
|
|
@@ -159,6 +245,7 @@ export class Agent {
|
|
|
159
245
|
type: "step-stop",
|
|
160
246
|
};
|
|
161
247
|
// continue iterations
|
|
248
|
+
consecutiveErrors = 0;
|
|
162
249
|
iter += 1;
|
|
163
250
|
}
|
|
164
251
|
catch (error) {
|
|
@@ -225,8 +312,6 @@ export class Agent {
|
|
|
225
312
|
}
|
|
226
313
|
// Emit agent-stop if loop ended without emitting a terminal event (maxIterations reached)
|
|
227
314
|
if (!hasEmittedTerminalEvent) {
|
|
228
|
-
// Track aggregate usage before yielding agent-stop so footer can display it
|
|
229
|
-
tokenTracker.trackUsage("repl", this._state.totalUsage);
|
|
230
315
|
yield {
|
|
231
316
|
type: "agent-stop",
|
|
232
317
|
};
|
|
@@ -385,6 +470,7 @@ export class Agent {
|
|
|
385
470
|
this._state.totalUsage.cachedInputTokens += cacheReadTokens;
|
|
386
471
|
this._state.totalUsage.inputTokenDetails.cacheReadTokens += cacheReadTokens;
|
|
387
472
|
this._state.totalUsage.reasoningTokens += reasoningTokens;
|
|
473
|
+
this.opts.tokenTracker.trackUsage("repl", stepUsage);
|
|
388
474
|
sessionManager.recordTurnUsage({
|
|
389
475
|
inputTokens,
|
|
390
476
|
outputTokens,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelMessage } from "ai";
|
|
2
|
-
|
|
2
|
+
interface SessionTokenUsage {
|
|
3
3
|
total: {
|
|
4
4
|
inputTokens: number;
|
|
5
5
|
outputTokens: number;
|
|
@@ -17,7 +17,7 @@ export interface SessionTokenUsage {
|
|
|
17
17
|
estimatedCost: number;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
interface TokenUsageTurn {
|
|
21
21
|
stepIndex: number;
|
|
22
22
|
inputTokens: number;
|
|
23
23
|
outputTokens: number;
|
|
@@ -46,4 +46,5 @@ export interface ConversationHistory {
|
|
|
46
46
|
project: string;
|
|
47
47
|
tokenUsage?: SessionTokenUsage | TokenUsageTurn[];
|
|
48
48
|
}
|
|
49
|
+
export {};
|
|
49
50
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/history/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGvC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../source/commands/history/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGvC,UAAU,iBAAiB;IACzB,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACr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ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/init-project/utils.ts"],"names":[],"mappings":"AAMA,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,GACjB,oBAAoB,CAwBtB;AAED,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,CAazE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { defaultConfig } from "../../config/index.js";
|
|
4
|
-
|
|
4
|
+
const DEVELOPMENT_DIRECTORY = "/Users/travisennis/Github/acai-ts";
|
|
5
5
|
export function ensureProjectDirectory(projectDir) {
|
|
6
6
|
const created = [];
|
|
7
7
|
const existing = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../source/commands/manager.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAEV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,GAAG,EACJ,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../source/commands/manager.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAEV,SAAS,EACT,MAAM,EACN,YAAY,EACZ,GAAG,EACJ,MAAM,iBAAiB,CAAC;AAsBzB,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,YAAY,CAAC;AAE9D,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,WAAW,CAAU;gBAEjB,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,SAAS,GACV,EAAE,cAAc;IAaX,mBAAmB;YAkDX,qBAAqB;IA4EnC,OAAO,CAAC,iBAAiB;IAQnB,cAAc,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAuB/C,WAAW;IAKL,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKlD,MAAM,CACV,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,EACpC,OAAO,EAAE;QACP,GAAG,EAAE,GAAG,CAAC;QACT,SAAS,EAAE,SAAS,CAAC;QACrB,cAAc,EAAE,SAAS,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;KAChB;;;CAsBJ"}
|
package/dist/commands/manager.js
CHANGED
|
@@ -7,27 +7,18 @@ import { Spacer, Text } from "../tui/index.js";
|
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
import { replaceArgumentPlaceholders } from "../utils/templates.js";
|
|
9
9
|
import { parseFrontMatter } from "../utils/yaml.js";
|
|
10
|
-
import { addDirectoryCommand } from "./add-directory/index.js";
|
|
11
|
-
import { clearCommand } from "./clear/index.js";
|
|
12
10
|
import { copyCommand } from "./copy/index.js";
|
|
13
|
-
import { generateRulesCommand } from "./generate-rules/index.js";
|
|
14
|
-
import { handoffCommand } from "./handoff/index.js";
|
|
15
11
|
import { healthCommand } from "./health/index.js";
|
|
16
12
|
import { helpCommand } from "./help/index.js";
|
|
17
13
|
import { historyCommand } from "./history/index.js";
|
|
18
14
|
import { initCommand } from "./init/index.js";
|
|
19
15
|
import { initProjectCommand } from "./init-project/index.js";
|
|
20
|
-
import { listDirectoriesCommand } from "./list-directories/index.js";
|
|
21
16
|
import { listToolsCommand } from "./list-tools/index.js";
|
|
22
17
|
import { modelCommand } from "./model/index.js";
|
|
23
18
|
import { pasteCommand } from "./paste/index.js";
|
|
24
|
-
import { pickupCommand } from "./pickup/index.js";
|
|
25
|
-
import { removeDirectoryCommand } from "./remove-directory/index.js";
|
|
26
19
|
import { resourcesCommand } from "./resources/index.js";
|
|
27
|
-
import { reviewCommand } from "./review/index.js";
|
|
28
20
|
import { sessionCommand } from "./session/index.js";
|
|
29
21
|
import { shareCommand } from "./share/index.js";
|
|
30
|
-
import { shellCommand } from "./shell/index.js";
|
|
31
22
|
import { toolsCommand } from "./tools/index.js";
|
|
32
23
|
export class CommandManager {
|
|
33
24
|
commands;
|
|
@@ -69,26 +60,17 @@ export class CommandManager {
|
|
|
69
60
|
};
|
|
70
61
|
// Register all commands
|
|
71
62
|
const cmds = [
|
|
72
|
-
addDirectoryCommand(options),
|
|
73
|
-
clearCommand(options),
|
|
74
63
|
healthCommand(options),
|
|
75
64
|
historyCommand(options),
|
|
76
65
|
initCommand(options),
|
|
77
66
|
initProjectCommand(options),
|
|
78
|
-
listDirectoriesCommand(options),
|
|
79
67
|
pasteCommand(options),
|
|
80
|
-
pickupCommand(options),
|
|
81
|
-
removeDirectoryCommand(options),
|
|
82
|
-
reviewCommand(options),
|
|
83
68
|
modelCommand(options),
|
|
84
69
|
sessionCommand(options),
|
|
85
|
-
generateRulesCommand(options),
|
|
86
|
-
handoffCommand(options),
|
|
87
70
|
copyCommand(options),
|
|
88
71
|
listToolsCommand(options),
|
|
89
72
|
resourcesCommand(options),
|
|
90
73
|
shareCommand(options),
|
|
91
|
-
shellCommand(options),
|
|
92
74
|
toolsCommand(options),
|
|
93
75
|
];
|
|
94
76
|
// Add help command with access to all commands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-renderer.d.ts","sourceRoot":"","sources":["../../../source/commands/share/html-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAA0C,MAAM,IAAI,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;
|
|
1
|
+
{"version":3,"file":"html-renderer.d.ts","sourceRoot":"","sources":["../../../source/commands/share/html-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAA0C,MAAM,IAAI,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AA8ID,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAwO9D;AAED,wBAAgB,cAAc,CAC5B,cAAc,EAAE;IACd,GAAG,EAAE,MAAM,YAAY,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,EACD,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,CAUb;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAMA"}
|
|
@@ -69,68 +69,74 @@ function renderToolResult(toolResult) {
|
|
|
69
69
|
</div>
|
|
70
70
|
</div>`;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
function extractTextContent(content) {
|
|
73
|
+
if (typeof content === "string") {
|
|
74
|
+
return escapeHtml(content);
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(content)) {
|
|
77
|
+
return content
|
|
78
|
+
.filter((p) => typeof p !== "string" && p.type === "text")
|
|
79
|
+
.map((p) => escapeHtml(p.text))
|
|
80
|
+
.join("\n");
|
|
81
|
+
}
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
function renderSystemMessage(content) {
|
|
85
|
+
const textContent = extractTextContent(content);
|
|
86
|
+
return `
|
|
82
87
|
<div class="message system">
|
|
83
88
|
<div class="role">system</div>
|
|
84
|
-
<div class="content">${
|
|
89
|
+
<div class="content">${textContent}</div>
|
|
85
90
|
</div>`;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (typeof content === "string") {
|
|
91
|
-
textContent = escapeHtml(content);
|
|
92
|
-
}
|
|
93
|
-
else if (Array.isArray(content)) {
|
|
94
|
-
textContent = content
|
|
95
|
-
.filter((p) => typeof p !== "string" && p.type === "text")
|
|
96
|
-
.map((p) => escapeHtml(p.text))
|
|
97
|
-
.join("\n");
|
|
98
|
-
}
|
|
99
|
-
return `
|
|
91
|
+
}
|
|
92
|
+
function renderUserMessage(content) {
|
|
93
|
+
const textContent = extractTextContent(content);
|
|
94
|
+
return `
|
|
100
95
|
<div class="message user">
|
|
101
96
|
<div class="role">user</div>
|
|
102
97
|
<div class="content">${textContent}</div>
|
|
103
98
|
</div>`;
|
|
99
|
+
}
|
|
100
|
+
function renderAssistantContent(content) {
|
|
101
|
+
if (typeof content === "string") {
|
|
102
|
+
return `<div class="content">${escapeHtml(content)}</div>`;
|
|
104
103
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (part.type === "text" && part.text.trim()) {
|
|
114
|
-
html += `<div class="content">${escapeHtml(part.text)}</div>`;
|
|
115
|
-
}
|
|
116
|
-
else if (part.type === "tool-call") {
|
|
117
|
-
html += renderToolCall(part);
|
|
118
|
-
}
|
|
104
|
+
if (Array.isArray(content)) {
|
|
105
|
+
let html = "";
|
|
106
|
+
for (const part of content) {
|
|
107
|
+
if (part.type === "text" && part.text.trim()) {
|
|
108
|
+
html += `<div class="content">${escapeHtml(part.text)}</div>`;
|
|
109
|
+
}
|
|
110
|
+
else if (part.type === "tool-call") {
|
|
111
|
+
html += renderToolCall(part);
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
|
-
html += "</div>";
|
|
122
114
|
return html;
|
|
123
115
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
116
|
+
return "";
|
|
117
|
+
}
|
|
118
|
+
function renderAssistantMessage(content) {
|
|
119
|
+
return `<div class="message assistant"><div class="role">assistant</div>${renderAssistantContent(content)}</div>`;
|
|
120
|
+
}
|
|
121
|
+
function renderToolMessage(parts) {
|
|
122
|
+
let html = "";
|
|
123
|
+
for (const part of parts) {
|
|
124
|
+
if (part.type === "tool-result") {
|
|
125
|
+
html += renderToolResult(part);
|
|
131
126
|
}
|
|
132
|
-
return html;
|
|
133
127
|
}
|
|
128
|
+
return html;
|
|
129
|
+
}
|
|
130
|
+
function renderMessage(message) {
|
|
131
|
+
const role = message.role;
|
|
132
|
+
if (role === "system")
|
|
133
|
+
return renderSystemMessage(message.content);
|
|
134
|
+
if (role === "user")
|
|
135
|
+
return renderUserMessage(message.content);
|
|
136
|
+
if (role === "assistant")
|
|
137
|
+
return renderAssistantMessage(message.content);
|
|
138
|
+
if (role === "tool")
|
|
139
|
+
return renderToolMessage(message.content);
|
|
134
140
|
return "";
|
|
135
141
|
}
|
|
136
142
|
export function renderSessionHtml(session) {
|
|
@@ -72,25 +72,22 @@ function createToolFiles(toolName, description, toolType, outputDir) {
|
|
|
72
72
|
files.push(...writeToolFile(filePath, config.template(), config.executable));
|
|
73
73
|
return files;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
const TYPE_FLAGS = {
|
|
76
|
+
"--bash": "bash",
|
|
77
|
+
"--zsh": "zsh",
|
|
78
|
+
"--node": "node",
|
|
79
|
+
"--text": "text",
|
|
80
|
+
};
|
|
81
|
+
function parseToolArgs(args) {
|
|
77
82
|
let toolName = "";
|
|
78
83
|
let toolType = "bash";
|
|
79
84
|
let description = "";
|
|
80
85
|
let customDir = "";
|
|
81
86
|
for (let i = 0; i < args.length; i++) {
|
|
82
87
|
const arg = args[i];
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
else if (arg === "--zsh") {
|
|
87
|
-
toolType = "zsh";
|
|
88
|
-
}
|
|
89
|
-
else if (arg === "--node") {
|
|
90
|
-
toolType = "node";
|
|
91
|
-
}
|
|
92
|
-
else if (arg === "--text") {
|
|
93
|
-
toolType = "text";
|
|
88
|
+
const typeFlag = TYPE_FLAGS[arg];
|
|
89
|
+
if (typeFlag) {
|
|
90
|
+
toolType = typeFlag;
|
|
94
91
|
}
|
|
95
92
|
else if (arg === "--description" || arg === "-d") {
|
|
96
93
|
description = args[++i] || "";
|
|
@@ -102,49 +99,53 @@ function handleToolMake(args, options, container, editor, tui) {
|
|
|
102
99
|
toolName = arg;
|
|
103
100
|
}
|
|
104
101
|
}
|
|
102
|
+
return { toolName, toolType, description, customDir };
|
|
103
|
+
}
|
|
104
|
+
function showToolError(container, editor, tui, message, usage) {
|
|
105
|
+
container.addChild(new Text(style.red(message), 0, 1));
|
|
106
|
+
if (usage) {
|
|
107
|
+
container.addChild(new Text(style.dim(usage), 0, 1));
|
|
108
|
+
}
|
|
109
|
+
tui.requestRender();
|
|
110
|
+
editor.setText("");
|
|
111
|
+
return "continue";
|
|
112
|
+
}
|
|
113
|
+
function showToolSuccess(container, editor, tui, toolName, filePaths) {
|
|
114
|
+
container.addChild(new Text(style.green(`Created tool: ${toolName}`), 0, 1));
|
|
115
|
+
for (const filePath of filePaths) {
|
|
116
|
+
container.addChild(new Text(style.dim(` ${filePath}`), 0, 1));
|
|
117
|
+
}
|
|
118
|
+
container.addChild(new Text(style.dim("Restart acai or reload tools to use the new tool."), 0, 1));
|
|
119
|
+
tui.requestRender();
|
|
120
|
+
editor.setText("");
|
|
121
|
+
return "continue";
|
|
122
|
+
}
|
|
123
|
+
function handleToolMake(args, options, container, editor, tui) {
|
|
124
|
+
const parsed = parseToolArgs(args);
|
|
125
|
+
let { toolName, toolType, description, customDir } = parsed;
|
|
105
126
|
if (!toolName) {
|
|
106
|
-
container
|
|
107
|
-
container.addChild(new Text(style.dim("Usage: /tools make <name> [--bash|--zsh|--node|--text] [--description <desc>] [--dir <path>]"), 0, 1));
|
|
108
|
-
tui.requestRender();
|
|
109
|
-
editor.setText("");
|
|
110
|
-
return "continue";
|
|
127
|
+
return showToolError(container, editor, tui, "Error: Tool name is required", "Usage: /tools make <name> [--bash|--zsh|--node|--text] [--description <desc>] [--dir <path>]");
|
|
111
128
|
}
|
|
112
129
|
if (!TOOL_NAME_REGEX.test(toolName)) {
|
|
113
|
-
container
|
|
114
|
-
tui.requestRender();
|
|
115
|
-
editor.setText("");
|
|
116
|
-
return "continue";
|
|
130
|
+
return showToolError(container, editor, tui, `Error: Tool name must match ${TOOL_NAME_REGEX.source}`);
|
|
117
131
|
}
|
|
118
132
|
if (!description) {
|
|
119
133
|
description = `Dynamic tool: ${toolName}`;
|
|
120
134
|
}
|
|
121
|
-
// Determine output directory
|
|
122
135
|
const outputDir = customDir || path.join(options.workspace.primaryDir, ".acai", "tools");
|
|
123
|
-
// Create directory if it doesn't exist
|
|
124
136
|
if (!fs.existsSync(outputDir)) {
|
|
125
137
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
126
138
|
}
|
|
127
139
|
try {
|
|
128
140
|
const result = createToolFiles(toolName, description, toolType, outputDir);
|
|
129
141
|
if (typeof result === "string") {
|
|
130
|
-
|
|
131
|
-
container.addChild(new Text(style.red(`Error: File already exists: ${result}`), 0, 1));
|
|
132
|
-
tui.requestRender();
|
|
133
|
-
editor.setText("");
|
|
134
|
-
return "continue";
|
|
135
|
-
}
|
|
136
|
-
container.addChild(new Text(style.green(`Created tool: ${toolName}`), 0, 1));
|
|
137
|
-
for (const filePath of result) {
|
|
138
|
-
container.addChild(new Text(style.dim(` ${filePath}`), 0, 1));
|
|
142
|
+
return showToolError(container, editor, tui, `Error: File already exists: ${result}`);
|
|
139
143
|
}
|
|
140
|
-
|
|
144
|
+
return showToolSuccess(container, editor, tui, toolName, result);
|
|
141
145
|
}
|
|
142
146
|
catch (e) {
|
|
143
|
-
container
|
|
147
|
+
return showToolError(container, editor, tui, `Error creating tool: ${e.message}`);
|
|
144
148
|
}
|
|
145
|
-
tui.requestRender();
|
|
146
|
-
editor.setText("");
|
|
147
|
-
return "continue";
|
|
148
149
|
}
|
|
149
150
|
async function handleToolList(options, container, editor, tui) {
|
|
150
151
|
const projectDir = path.join(options.workspace.primaryDir, ".acai", "tools");
|
package/dist/config/index.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export declare const defaultConfig: {
|
|
|
22
22
|
readonly devtools: {
|
|
23
23
|
readonly enabled: false;
|
|
24
24
|
};
|
|
25
|
-
readonly autoGenerateRules: false;
|
|
26
25
|
readonly allowedDirs: string[];
|
|
27
26
|
readonly env: Record<string, string>;
|
|
28
27
|
};
|
|
@@ -48,7 +47,6 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
48
47
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
49
48
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
50
49
|
}, z.core.$strip>>>;
|
|
51
|
-
autoGenerateRules: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
52
50
|
allowedDirs: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
53
51
|
devtools: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
54
52
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/config/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAa5D;AAED,eAAO,MAAM,aAAa;;;;;8BAKI,MAAM,EAAE,GAAG,SAAS;;;;;;;;;4BAS3B,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/config/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAa5D;AAED,eAAO,MAAM,aAAa;;;;;8BAKI,MAAM,EAAE,GAAG,SAAS;;;;;;;;;4BAS3B,MAAM,EAAE;;;;;;;;0BAQV,MAAM,EAAE;kBAChB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAGX,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsDhB,CAAC;AAEH,MA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c,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"}
|
package/dist/config/index.js
CHANGED
|
@@ -42,7 +42,6 @@ export const defaultConfig = {
|
|
|
42
42
|
devtools: {
|
|
43
43
|
enabled: false,
|
|
44
44
|
},
|
|
45
|
-
autoGenerateRules: false,
|
|
46
45
|
allowedDirs: [],
|
|
47
46
|
env: {},
|
|
48
47
|
};
|
|
@@ -90,10 +89,6 @@ const ConfigSchema = z.object({
|
|
|
90
89
|
})
|
|
91
90
|
.optional()
|
|
92
91
|
.default(defaultConfig.skills),
|
|
93
|
-
autoGenerateRules: z
|
|
94
|
-
.boolean()
|
|
95
|
-
.optional()
|
|
96
|
-
.default(defaultConfig.autoGenerateRules),
|
|
97
92
|
allowedDirs: z
|
|
98
93
|
.array(z.string())
|
|
99
94
|
.optional()
|
|
@@ -156,10 +151,11 @@ export class ConfigManager {
|
|
|
156
151
|
async _readConfig(configPath) {
|
|
157
152
|
try {
|
|
158
153
|
const data = await fs.readFile(configPath, "utf8");
|
|
159
|
-
return
|
|
154
|
+
return JSON.parse(data);
|
|
160
155
|
}
|
|
161
156
|
catch (error) {
|
|
162
|
-
|
|
157
|
+
const code = error.code;
|
|
158
|
+
if (code === "ENOENT" || code === "EPERM" || code === "EACCES") {
|
|
163
159
|
return {};
|
|
164
160
|
}
|
|
165
161
|
throw error;
|