@travisennis/acai 0.0.12 → 0.0.13
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 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -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 +2 -6
- 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 +4 -4
- package/dist/models/opencode-go-provider.d.ts.map +1 -1
- package/dist/models/opencode-go-provider.js +29 -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/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 +121 -104
- package/dist/utils/command-protection.d.ts +3 -2
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +42 -33
- 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
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
function isDiffContentLine(line) {
|
|
5
|
-
return ((line.startsWith("+") && !line.startsWith("+++")) ||
|
|
6
|
-
(line.startsWith("-") && !line.startsWith("---")) ||
|
|
7
|
-
line.startsWith(" ") ||
|
|
8
|
-
line.startsWith("index") ||
|
|
9
|
-
line.startsWith("old mode") ||
|
|
10
|
-
line.startsWith("new mode") ||
|
|
11
|
-
line.startsWith("deleted file") ||
|
|
12
|
-
line.startsWith("new file"));
|
|
13
|
-
}
|
|
14
|
-
function parseHunkStats(line, isNewFile) {
|
|
15
|
-
const statsMatch = line.match(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);
|
|
16
|
-
if (!statsMatch) {
|
|
17
|
-
return "Additions: 1, Deletions: 0";
|
|
18
|
-
}
|
|
19
|
-
const deletions = isNewFile ? 0 : Number.parseInt(statsMatch[2], 10);
|
|
20
|
-
const additions = Number.parseInt(statsMatch[4], 10);
|
|
21
|
-
return `Additions: ${additions}, Deletions: ${deletions}`;
|
|
22
|
-
}
|
|
23
|
-
function startNewFile(state, line) {
|
|
24
|
-
if (state.currentFile) {
|
|
25
|
-
state.fileChanges.push(state.currentFile);
|
|
26
|
-
}
|
|
27
|
-
const fileMatch = line.match(/diff --git a\/(.*) b\/(.*)/);
|
|
28
|
-
if (!fileMatch)
|
|
29
|
-
return;
|
|
30
|
-
state.currentFile = { fileName: fileMatch[1], diff: "", stats: "" };
|
|
31
|
-
state.inDiff = true;
|
|
32
|
-
state.isNewFile =
|
|
33
|
-
fileMatch[1] === "/dev/null" || fileMatch[2] === "/dev/null";
|
|
34
|
-
}
|
|
35
|
-
export function parseGitDiffFiles(diffOutput) {
|
|
36
|
-
const lines = diffOutput.split("\n");
|
|
37
|
-
const state = {
|
|
38
|
-
fileChanges: [],
|
|
39
|
-
currentFile: null,
|
|
40
|
-
inDiff: false,
|
|
41
|
-
isNewFile: false,
|
|
42
|
-
};
|
|
43
|
-
for (const line of lines) {
|
|
44
|
-
if (line.startsWith("diff --git")) {
|
|
45
|
-
startNewFile(state, line);
|
|
46
|
-
}
|
|
47
|
-
else if (line.startsWith("@@") && state.currentFile) {
|
|
48
|
-
state.currentFile.stats = parseHunkStats(line, state.isNewFile);
|
|
49
|
-
}
|
|
50
|
-
else if (state.inDiff && state.currentFile && isDiffContentLine(line)) {
|
|
51
|
-
state.currentFile.diff += `${line}\n`;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (state.currentFile) {
|
|
55
|
-
state.fileChanges.push(state.currentFile);
|
|
56
|
-
}
|
|
57
|
-
return state.fileChanges;
|
|
58
|
-
}
|
|
59
|
-
function formatDiffLine(line) {
|
|
60
|
-
if (line.trim() === "")
|
|
61
|
-
return null;
|
|
62
|
-
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
63
|
-
return `+${line.substring(1)}`;
|
|
64
|
-
}
|
|
65
|
-
if (line.startsWith("-") && !line.startsWith("---")) {
|
|
66
|
-
return `-${line.substring(1)}`;
|
|
67
|
-
}
|
|
68
|
-
if (line.startsWith(" ")) {
|
|
69
|
-
return ` ${line.substring(1)}`;
|
|
70
|
-
}
|
|
71
|
-
return line;
|
|
72
|
-
}
|
|
73
|
-
export function formatFileDiffForDisplay(fileName, diff) {
|
|
74
|
-
const lines = diff.split("\n");
|
|
75
|
-
const formattedLines = [`### ${fileName}`, "", "```diff"];
|
|
76
|
-
for (const line of lines) {
|
|
77
|
-
const formatted = formatDiffLine(line);
|
|
78
|
-
if (formatted !== null) {
|
|
79
|
-
formattedLines.push(formatted);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
formattedLines.push("```");
|
|
83
|
-
return formattedLines.join("\n");
|
|
84
|
-
}
|
|
85
|
-
export async function getUntrackedFiles(untrackedOutput, cwd) {
|
|
86
|
-
const fileChanges = [];
|
|
87
|
-
const untrackedFiles = untrackedOutput
|
|
88
|
-
.trim()
|
|
89
|
-
.split("\n")
|
|
90
|
-
.filter((file) => file.length > 0);
|
|
91
|
-
for (const fileName of untrackedFiles) {
|
|
92
|
-
try {
|
|
93
|
-
const filePath = join(cwd, fileName);
|
|
94
|
-
const fileContent = await fs.promises.readFile(filePath, "utf-8");
|
|
95
|
-
const lines = fileContent.split("\n").length;
|
|
96
|
-
// Create a diff-like representation for the untracked file
|
|
97
|
-
const diff = `diff --git a/${fileName} b/${fileName}
|
|
98
|
-
new file mode 100644
|
|
99
|
-
index 0000000..0000000
|
|
100
|
-
--- /dev/null
|
|
101
|
-
+++ b/${fileName}
|
|
102
|
-
@@ -0,0 +1,${lines} @@
|
|
103
|
-
${fileContent
|
|
104
|
-
.split("\n")
|
|
105
|
-
.map((line) => `+${line}`)
|
|
106
|
-
.join("\n")}
|
|
107
|
-
`;
|
|
108
|
-
fileChanges.push({
|
|
109
|
-
fileName,
|
|
110
|
-
diff,
|
|
111
|
-
stats: `Additions: ${lines}, Deletions: 0`,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
// Skip files that can't be read (e.g., directories, binary files)
|
|
116
|
-
console.error(`Failed to read untracked file: ${fileName}`, error);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return fileChanges;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Open a file in the user's preferred editor ($EDITOR or $VISUAL)
|
|
123
|
-
*/
|
|
124
|
-
export function openFileInEditor(filePath, terminal) {
|
|
125
|
-
const editor = process.env["EDITOR"] || process.env["VISUAL"] || "vi";
|
|
126
|
-
terminal.enterExternalMode();
|
|
127
|
-
try {
|
|
128
|
-
const result = spawnSync(editor, [filePath], {
|
|
129
|
-
stdio: "inherit",
|
|
130
|
-
});
|
|
131
|
-
if (result.error) {
|
|
132
|
-
return { success: false, error: result.error.message };
|
|
133
|
-
}
|
|
134
|
-
// Note: Editors often exit with non-zero codes (e.g., :cq in vim, or when
|
|
135
|
-
// quitting without saving). We only treat spawn errors as failures, not
|
|
136
|
-
// exit codes, since the user may intentionally exit with an error code.
|
|
137
|
-
return { success: true };
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
141
|
-
return { success: false, error: errorMessage };
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
terminal.exitExternalMode();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/shell/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/D,eAAO,MAAM,YAAY,GAAI,SAAS,cAAc,KAAG,WAuItD,CAAC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { initExecutionEnvironment } from "../../execution/index.js";
|
|
2
|
-
import style from "../../terminal/style.js";
|
|
3
|
-
import { Loader, SelectList, Spacer, Text } from "../../tui/index.js";
|
|
4
|
-
// Command execution timeout in milliseconds
|
|
5
|
-
const DEFAULT_TIMEOUT = 1.5 * 60 * 1000; // 1.5 minutes
|
|
6
|
-
export const shellCommand = (options) => {
|
|
7
|
-
const { promptManager, tokenCounter } = options;
|
|
8
|
-
return {
|
|
9
|
-
command: "/shell",
|
|
10
|
-
aliases: ["/sh"],
|
|
11
|
-
description: "Run a non-interactive shell command on the local machine.",
|
|
12
|
-
getSubCommands: () => Promise.resolve([]),
|
|
13
|
-
async handle(args, { tui, container, editor, }) {
|
|
14
|
-
const commandStr = args.join(" ");
|
|
15
|
-
if (!commandStr.trim()) {
|
|
16
|
-
container.addChild(new Text(style.red("Provide a non-empty command."), 0, 1));
|
|
17
|
-
tui.requestRender();
|
|
18
|
-
editor.setText("");
|
|
19
|
-
return "continue";
|
|
20
|
-
}
|
|
21
|
-
const execEnv = await initExecutionEnvironment();
|
|
22
|
-
const colorEnv = {
|
|
23
|
-
["FORCE_COLOR"]: "1",
|
|
24
|
-
["CLICOLOR"]: "1",
|
|
25
|
-
["CLICOLOR_FORCE"]: "1",
|
|
26
|
-
["TERM"]: process.env["TERM"] ?? "xterm-256color",
|
|
27
|
-
["COLORTERM"]: process.env["COLORTERM"] ?? "truecolor",
|
|
28
|
-
["npm_config_color"]: "true",
|
|
29
|
-
};
|
|
30
|
-
// Show loader before execution
|
|
31
|
-
const truncatedCommand = commandStr.length > 50
|
|
32
|
-
? `${commandStr.substring(0, 50)}...`
|
|
33
|
-
: commandStr;
|
|
34
|
-
const loader = new Loader(tui, `Running: ${truncatedCommand}`);
|
|
35
|
-
container.addChild(loader);
|
|
36
|
-
tui.requestRender();
|
|
37
|
-
const { output, exitCode, duration } = await execEnv.executeCommand(commandStr, {
|
|
38
|
-
cwd: process.cwd(),
|
|
39
|
-
timeout: DEFAULT_TIMEOUT,
|
|
40
|
-
preserveOutputOnError: true,
|
|
41
|
-
captureStderr: true,
|
|
42
|
-
throwOnError: false,
|
|
43
|
-
env: colorEnv,
|
|
44
|
-
});
|
|
45
|
-
// Cleanup loader
|
|
46
|
-
loader.stop();
|
|
47
|
-
container.removeChild(loader);
|
|
48
|
-
// Display results with spacing
|
|
49
|
-
container.addChild(new Spacer(1));
|
|
50
|
-
container.addChild(new Text(style.gray(`Exit code: ${exitCode}, Duration: ${duration}ms`), 1, 0));
|
|
51
|
-
container.addChild(new Spacer(1));
|
|
52
|
-
container.addChild(new Text(output, 2, 0));
|
|
53
|
-
// Create context selection component
|
|
54
|
-
const contextSelector = new SelectList([
|
|
55
|
-
{
|
|
56
|
-
value: "yes",
|
|
57
|
-
label: "Yes",
|
|
58
|
-
description: "Add output to prompt context",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
value: "no",
|
|
62
|
-
label: "No",
|
|
63
|
-
description: "Do not add output to context",
|
|
64
|
-
},
|
|
65
|
-
]);
|
|
66
|
-
contextSelector.onSelect = (item) => {
|
|
67
|
-
if (item.value === "yes") {
|
|
68
|
-
const tokenCount = tokenCounter.count(output);
|
|
69
|
-
promptManager.addContext(output);
|
|
70
|
-
container.addChild(new Text(style.green(`Output added to prompt context. (${tokenCount} tokens)`), 3, 0));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
container.addChild(new Text(style.gray("Output not added to context."), 3, 0));
|
|
74
|
-
}
|
|
75
|
-
// Remove the selector and show final result
|
|
76
|
-
container.removeChild(contextSelector);
|
|
77
|
-
tui.setFocus(editor);
|
|
78
|
-
tui.requestRender();
|
|
79
|
-
editor.setText("");
|
|
80
|
-
};
|
|
81
|
-
contextSelector.onCancel = () => {
|
|
82
|
-
// User cancelled - default to not adding to context
|
|
83
|
-
container.addChild(new Text(style.gray("Output not added to context."), 3, 0));
|
|
84
|
-
container.removeChild(contextSelector);
|
|
85
|
-
tui.setFocus(editor);
|
|
86
|
-
tui.requestRender();
|
|
87
|
-
editor.setText("");
|
|
88
|
-
};
|
|
89
|
-
// Add the selector to the container
|
|
90
|
-
container.addChild(contextSelector);
|
|
91
|
-
tui.setFocus(contextSelector);
|
|
92
|
-
tui.requestRender();
|
|
93
|
-
return "continue";
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface Subagent {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
model?: string;
|
|
5
|
-
tools?: string[];
|
|
6
|
-
timeout: number;
|
|
7
|
-
systemPrompt: string;
|
|
8
|
-
filePath: string;
|
|
9
|
-
source: string;
|
|
10
|
-
}
|
|
11
|
-
export declare function loadSubagents(): Promise<Subagent[]>;
|
|
12
|
-
export declare function getSubagent(name: string): Promise<Subagent | undefined>;
|
|
13
|
-
export declare function formatSubagentsForDescription(subagents: Subagent[]): string;
|
|
14
|
-
export declare function formatSubagentsForPrompt(subagents: Subagent[]): string;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/subagents/index.ts"],"names":[],"mappings":"AAeA,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAkND,wBAAsB,aAAa,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAgBzD;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAG7E;AAED,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAa3E;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CA6CtE"}
|
package/dist/subagents/index.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
|
-
import { logger } from "../utils/logger.js";
|
|
5
|
-
import { parseFrontMatter } from "../utils/yaml.js";
|
|
6
|
-
const CONFIG_DIR_NAME = ".acai";
|
|
7
|
-
const DEFAULT_TIMEOUT = 900;
|
|
8
|
-
// Validation functions
|
|
9
|
-
function validateSubagentName(name, fileName) {
|
|
10
|
-
// Check required field
|
|
11
|
-
if (!name) {
|
|
12
|
-
return { valid: false, error: "Name field is required" };
|
|
13
|
-
}
|
|
14
|
-
// Check length (1-64 characters)
|
|
15
|
-
if (name.length < 1 || name.length > 64) {
|
|
16
|
-
return { valid: false, error: "Name must be 1-64 characters long" };
|
|
17
|
-
}
|
|
18
|
-
// Check allowed characters (lowercase letters, numbers, hyphens)
|
|
19
|
-
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
20
|
-
return {
|
|
21
|
-
valid: false,
|
|
22
|
-
error: "Name can only contain lowercase letters, numbers, and hyphens",
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
// Check no leading or trailing hyphens
|
|
26
|
-
if (name.startsWith("-") || name.endsWith("-")) {
|
|
27
|
-
return { valid: false, error: "Name cannot start or end with a hyphen" };
|
|
28
|
-
}
|
|
29
|
-
// Check no consecutive hyphens
|
|
30
|
-
if (name.includes("--")) {
|
|
31
|
-
return { valid: false, error: "Name cannot contain consecutive hyphens" };
|
|
32
|
-
}
|
|
33
|
-
// Check matches filename (without .md)
|
|
34
|
-
const expectedName = fileName.replace(/\.md$/, "");
|
|
35
|
-
if (name !== expectedName) {
|
|
36
|
-
return {
|
|
37
|
-
valid: false,
|
|
38
|
-
error: `Name "${name}" must match filename "${fileName}" (without .md)`,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return { valid: true };
|
|
42
|
-
}
|
|
43
|
-
function validateSubagentDescription(description) {
|
|
44
|
-
// Check required field
|
|
45
|
-
if (!description) {
|
|
46
|
-
return { valid: false, error: "Description field is required" };
|
|
47
|
-
}
|
|
48
|
-
// Check length (1-1024 characters)
|
|
49
|
-
if (description.length < 1 || description.length > 1024) {
|
|
50
|
-
return {
|
|
51
|
-
valid: false,
|
|
52
|
-
error: "Description must be 1-1024 characters long",
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return { valid: true };
|
|
56
|
-
}
|
|
57
|
-
function validateSubagentTimeout(timeout) {
|
|
58
|
-
if (timeout === undefined) {
|
|
59
|
-
return { valid: true };
|
|
60
|
-
}
|
|
61
|
-
if (typeof timeout !== "number" || timeout < 1 || timeout > 3600) {
|
|
62
|
-
return {
|
|
63
|
-
valid: false,
|
|
64
|
-
error: "Timeout must be a number between 1 and 3600 seconds",
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return { valid: true };
|
|
68
|
-
}
|
|
69
|
-
function parseFrontmatter(content) {
|
|
70
|
-
const { data, content: body } = parseFrontMatter(content);
|
|
71
|
-
// Type cast and validate required fields
|
|
72
|
-
const name = data["name"];
|
|
73
|
-
const description = data["description"];
|
|
74
|
-
// Set default empty values for optional fields
|
|
75
|
-
const frontmatter = {
|
|
76
|
-
name: name || "",
|
|
77
|
-
description: description || "",
|
|
78
|
-
model: data["model"] || undefined,
|
|
79
|
-
tools: data["tools"] || undefined,
|
|
80
|
-
timeout: data["timeout"] || undefined,
|
|
81
|
-
};
|
|
82
|
-
return { frontmatter, body };
|
|
83
|
-
}
|
|
84
|
-
async function loadSubagentsFromDir(dir, source) {
|
|
85
|
-
const subagents = [];
|
|
86
|
-
try {
|
|
87
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
88
|
-
for (const entry of entries) {
|
|
89
|
-
// Skip hidden files and directories
|
|
90
|
-
if (entry.name.startsWith(".")) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
// Only process .md files
|
|
94
|
-
if (!entry.isFile() || !entry.name.endsWith(".md")) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
const entryPath = join(dir, entry.name);
|
|
98
|
-
// Skip symbolic links to avoid infinite recursion
|
|
99
|
-
try {
|
|
100
|
-
const stats = await stat(entryPath);
|
|
101
|
-
if (stats.isSymbolicLink()) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
// If we can't stat, skip it
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const content = await readFile(entryPath, "utf8");
|
|
111
|
-
const { frontmatter, body } = parseFrontmatter(content);
|
|
112
|
-
// Validate required fields
|
|
113
|
-
const nameValidation = validateSubagentName(frontmatter.name, entry.name);
|
|
114
|
-
if (!nameValidation.valid) {
|
|
115
|
-
logger.warn(`Invalid subagent name in ${entryPath}: ${nameValidation.error}`);
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const descriptionValidation = validateSubagentDescription(frontmatter.description);
|
|
119
|
-
if (!descriptionValidation.valid) {
|
|
120
|
-
logger.warn(`Invalid subagent description in ${entryPath}: ${descriptionValidation.error}`);
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
const timeoutValidation = validateSubagentTimeout(frontmatter.timeout);
|
|
124
|
-
if (!timeoutValidation.valid) {
|
|
125
|
-
logger.warn(`Invalid subagent timeout in ${entryPath}: ${timeoutValidation.error}`);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
// Parse tools if provided
|
|
129
|
-
let tools;
|
|
130
|
-
if (frontmatter.tools) {
|
|
131
|
-
tools = frontmatter.tools
|
|
132
|
-
.split(",")
|
|
133
|
-
.map((t) => t.trim())
|
|
134
|
-
.filter((t) => t.length > 0);
|
|
135
|
-
}
|
|
136
|
-
subagents.push({
|
|
137
|
-
name: frontmatter.name,
|
|
138
|
-
description: frontmatter.description,
|
|
139
|
-
model: frontmatter.model,
|
|
140
|
-
tools,
|
|
141
|
-
timeout: frontmatter.timeout ?? DEFAULT_TIMEOUT,
|
|
142
|
-
systemPrompt: body,
|
|
143
|
-
filePath: entryPath,
|
|
144
|
-
source,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
logger.warn(error, `Failed to load subagent from ${entryPath}:`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
// Directory doesn't exist or can't be read
|
|
154
|
-
if (error.code !== "ENOENT") {
|
|
155
|
-
logger.error(error, `Error reading subagents directory ${dir}:`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return subagents;
|
|
159
|
-
}
|
|
160
|
-
export async function loadSubagents() {
|
|
161
|
-
const subagentMap = new Map();
|
|
162
|
-
// Load from user directory (~/.acai/subagents)
|
|
163
|
-
const userDir = join(homedir(), CONFIG_DIR_NAME, "subagents");
|
|
164
|
-
for (const subagent of await loadSubagentsFromDir(userDir, "user")) {
|
|
165
|
-
subagentMap.set(subagent.name, subagent);
|
|
166
|
-
}
|
|
167
|
-
// Load from project directory (.acai/subagents) - overrides user
|
|
168
|
-
const projectDir = resolve(process.cwd(), CONFIG_DIR_NAME, "subagents");
|
|
169
|
-
for (const subagent of await loadSubagentsFromDir(projectDir, "project")) {
|
|
170
|
-
subagentMap.set(subagent.name, subagent);
|
|
171
|
-
}
|
|
172
|
-
return Array.from(subagentMap.values());
|
|
173
|
-
}
|
|
174
|
-
export async function getSubagent(name) {
|
|
175
|
-
const subagents = await loadSubagents();
|
|
176
|
-
return subagents.find((s) => s.name === name);
|
|
177
|
-
}
|
|
178
|
-
export function formatSubagentsForDescription(subagents) {
|
|
179
|
-
if (subagents.length === 0) {
|
|
180
|
-
return " No subagents available";
|
|
181
|
-
}
|
|
182
|
-
const lines = subagents.map((subagent) => {
|
|
183
|
-
const toolsStr = subagent.tools
|
|
184
|
-
? ` (tools: ${subagent.tools.join(", ")})`
|
|
185
|
-
: "";
|
|
186
|
-
return ` - ${subagent.name}: ${subagent.description}${toolsStr}`;
|
|
187
|
-
});
|
|
188
|
-
return lines.join("\n");
|
|
189
|
-
}
|
|
190
|
-
export function formatSubagentsForPrompt(subagents) {
|
|
191
|
-
if (subagents.length === 0) {
|
|
192
|
-
return "";
|
|
193
|
-
}
|
|
194
|
-
const lines = [
|
|
195
|
-
"## Subagents (Agent Tool)",
|
|
196
|
-
"",
|
|
197
|
-
"Use the Agent tool to delegate complex, multi-step tasks to specialized subagents. Subagents operate autonomously and return a single result.",
|
|
198
|
-
"",
|
|
199
|
-
"**When to use subagents:**",
|
|
200
|
-
"- Deep codebase research or architecture exploration",
|
|
201
|
-
"- Complex multi-file refactoring or implementation tasks",
|
|
202
|
-
"- Writing comprehensive tests across multiple files",
|
|
203
|
-
"- Creating detailed implementation plans",
|
|
204
|
-
"- Tasks requiring investigation across many files",
|
|
205
|
-
"",
|
|
206
|
-
"<available_subagents>",
|
|
207
|
-
];
|
|
208
|
-
for (const subagent of subagents) {
|
|
209
|
-
lines.push("<subagent>");
|
|
210
|
-
lines.push("<name>");
|
|
211
|
-
lines.push(subagent.name);
|
|
212
|
-
lines.push("</name>");
|
|
213
|
-
lines.push("<description>");
|
|
214
|
-
lines.push(subagent.description);
|
|
215
|
-
lines.push("</description>");
|
|
216
|
-
if (subagent.tools && subagent.tools.length > 0) {
|
|
217
|
-
lines.push("<tools>");
|
|
218
|
-
lines.push(subagent.tools.join(", "));
|
|
219
|
-
lines.push("</tools>");
|
|
220
|
-
}
|
|
221
|
-
lines.push("</subagent>");
|
|
222
|
-
}
|
|
223
|
-
lines.push("</available_subagents>");
|
|
224
|
-
lines.push("");
|
|
225
|
-
lines.push("**Usage notes:**");
|
|
226
|
-
lines.push("- Subagents are stateless - provide all context in your prompt");
|
|
227
|
-
lines.push("- Be specific about what information you need returned");
|
|
228
|
-
lines.push("- Use longer timeouts for complex tasks (1800-3600 seconds)");
|
|
229
|
-
lines.push("- Launch multiple subagents concurrently for independent tasks");
|
|
230
|
-
return lines.join("\n");
|
|
231
|
-
}
|
package/dist/terminal/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal Interface Module
|
|
3
|
-
*
|
|
4
|
-
* Provides a user interface for interacting with Claude Code in the terminal.
|
|
5
|
-
* Handles input/output, formatting, and display.
|
|
6
|
-
*/
|
|
7
|
-
export { alert, getShell, isInteractive } from "./control.ts";
|
|
8
|
-
export { emphasize, error, hr, info, success, warn } from "./formatting.ts";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/terminal/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/terminal/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal Interface Module
|
|
3
|
-
*
|
|
4
|
-
* Provides a user interface for interacting with Claude Code in the terminal.
|
|
5
|
-
* Handles input/output, formatting, and display.
|
|
6
|
-
*/
|
|
7
|
-
export { alert, getShell, isInteractive } from "./control.js";
|
|
8
|
-
export { emphasize, error, hr, info, success, warn } from "./formatting.js";
|
package/dist/tools/agent.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { WorkspaceContext } from "../index.ts";
|
|
3
|
-
import type { ToolExecutionOptions } from "./types.ts";
|
|
4
|
-
export declare const AgentTool: {
|
|
5
|
-
name: "Agent";
|
|
6
|
-
};
|
|
7
|
-
declare const inputSchema: z.ZodObject<{
|
|
8
|
-
prompt: z.ZodString;
|
|
9
|
-
type: z.ZodString;
|
|
10
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
export declare const createAgentTools: (options: {
|
|
13
|
-
workspace: WorkspaceContext;
|
|
14
|
-
}) => Promise<{
|
|
15
|
-
toolDef: {
|
|
16
|
-
description: string;
|
|
17
|
-
inputSchema: z.ZodObject<{
|
|
18
|
-
prompt: z.ZodString;
|
|
19
|
-
type: z.ZodString;
|
|
20
|
-
timeout: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
};
|
|
23
|
-
display: ({ prompt, type }: z.infer<typeof inputSchema>) => string;
|
|
24
|
-
execute: ({ prompt, type, timeout }: z.infer<typeof inputSchema>, { abortSignal }: ToolExecutionOptions) => Promise<string>;
|
|
25
|
-
}>;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../source/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,SAAS;;CAErB,CAAC;AAMF,QAAA,MAAM,WAAW;;;;iBAOf,CAAC;AAsBH,eAAO,MAAM,gBAAgB,GAAU,SAAS;IAC9C,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;gCAQoC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC;yCAIjC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,mBACrC,oBAAoB,KACpC,OAAO,CAAC,MAAM,CAAC;EAkDnB,CAAC"}
|
package/dist/tools/agent.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { SubAgent } from "../agent/sub-agent.js";
|
|
3
|
-
import { isSupportedModel } from "../models/providers.js";
|
|
4
|
-
import { environmentInfo } from "../prompts/system-prompt.js";
|
|
5
|
-
import { getSubagent, loadSubagents } from "../subagents/index.js";
|
|
6
|
-
import style from "../terminal/style.js";
|
|
7
|
-
export const AgentTool = {
|
|
8
|
-
name: "Agent",
|
|
9
|
-
};
|
|
10
|
-
async function getToolDescription() {
|
|
11
|
-
return "Delegate a task to a specialized subagent.";
|
|
12
|
-
}
|
|
13
|
-
const inputSchema = z.object({
|
|
14
|
-
prompt: z.string().describe("The task for the agent to perform"),
|
|
15
|
-
type: z.string().describe("The subagent type to use (matches subagent name)"),
|
|
16
|
-
timeout: z
|
|
17
|
-
.number()
|
|
18
|
-
.optional()
|
|
19
|
-
.describe("Override default timeout in seconds"),
|
|
20
|
-
});
|
|
21
|
-
async function loadSubAgentDefinition(type) {
|
|
22
|
-
const subagent = await getSubagent(type);
|
|
23
|
-
if (!subagent) {
|
|
24
|
-
const available = await loadSubagents();
|
|
25
|
-
const names = available.map((s) => s.name).join(", ");
|
|
26
|
-
throw new Error(`Unknown subagent type: "${type}". Available: ${names}`);
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
model: subagent.model ?? "",
|
|
30
|
-
system: subagent.systemPrompt,
|
|
31
|
-
tools: subagent.tools,
|
|
32
|
-
timeout: subagent.timeout,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export const createAgentTools = async (options) => {
|
|
36
|
-
const description = await getToolDescription();
|
|
37
|
-
const toolDef = {
|
|
38
|
-
description,
|
|
39
|
-
inputSchema,
|
|
40
|
-
};
|
|
41
|
-
function display({ prompt, type }) {
|
|
42
|
-
return `${style.cyan(type)} - ${style.dim(prompt.substring(0, 25))}`;
|
|
43
|
-
}
|
|
44
|
-
async function execute({ prompt, type, timeout }, { abortSignal }) {
|
|
45
|
-
if (abortSignal?.aborted) {
|
|
46
|
-
throw new Error("Agent execution aborted");
|
|
47
|
-
}
|
|
48
|
-
const { model, system, tools, timeout: defaultTimeout, } = await loadSubAgentDefinition(type);
|
|
49
|
-
const systemPrompt = `${system}
|
|
50
|
-
|
|
51
|
-
${await environmentInfo(options.workspace.primaryDir, options.workspace.allowedDirs)}`;
|
|
52
|
-
const subagent = new SubAgent({ workspace: options.workspace });
|
|
53
|
-
const effectiveTimeout = timeout ?? defaultTimeout;
|
|
54
|
-
try {
|
|
55
|
-
const result = await subagent.execute({
|
|
56
|
-
model: isSupportedModel(model) ? model : "opencode:minimax-m2.5",
|
|
57
|
-
system: systemPrompt,
|
|
58
|
-
prompt,
|
|
59
|
-
abortSignal,
|
|
60
|
-
allowedTools: tools,
|
|
61
|
-
timeout: effectiveTimeout,
|
|
62
|
-
});
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
const err = error;
|
|
67
|
-
const message = err.message || "Unknown error";
|
|
68
|
-
if (message.includes("timed out") ||
|
|
69
|
-
err.name === "AbortError" ||
|
|
70
|
-
err.name === "TimeoutError") {
|
|
71
|
-
return `Agent failed: ${message}. The timeout was ${effectiveTimeout} seconds. Consider increasing the timeout or breaking the task into smaller subtasks.`;
|
|
72
|
-
}
|
|
73
|
-
return `Agent failed: ${message}`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
toolDef,
|
|
78
|
-
display,
|
|
79
|
-
execute,
|
|
80
|
-
};
|
|
81
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { WorkspaceContext } from "../index.ts";
|
|
3
|
-
import type { ToolExecutionOptions } from "./types.ts";
|
|
4
|
-
export declare const DirectoryTreeTool: {
|
|
5
|
-
name: "DirectoryTree";
|
|
6
|
-
};
|
|
7
|
-
declare const inputSchema: z.ZodObject<{
|
|
8
|
-
path: z.ZodString;
|
|
9
|
-
maxResults: z.ZodDefault<z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>>;
|
|
10
|
-
maxDepth: z.ZodDefault<z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
type DirectoryTreeInputSchema = z.infer<typeof inputSchema>;
|
|
13
|
-
export declare const createDirectoryTreeTool: (options: {
|
|
14
|
-
workspace: WorkspaceContext;
|
|
15
|
-
}) => Promise<{
|
|
16
|
-
toolDef: {
|
|
17
|
-
description: string;
|
|
18
|
-
inputSchema: z.ZodObject<{
|
|
19
|
-
path: z.ZodString;
|
|
20
|
-
maxResults: z.ZodDefault<z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>>;
|
|
21
|
-
maxDepth: z.ZodDefault<z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>>;
|
|
22
|
-
}, z.core.$strip>;
|
|
23
|
-
};
|
|
24
|
-
display({ path, maxDepth, maxResults }: DirectoryTreeInputSchema): string;
|
|
25
|
-
execute({ path, maxResults, maxDepth }: DirectoryTreeInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
26
|
-
}>;
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=directory-tree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directory-tree.d.ts","sourceRoot":"","sources":["../../source/tools/directory-tree.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW;;;;iBAcf,CAAC;AAEH,KAAK,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAU,SAAS;IACrD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;4CAS2C,wBAAwB;4CAY9B,wBAAwB,mBACvC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAyBrB,CAAC"}
|