@travisennis/acai 0.0.10 → 0.0.12
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 +7 -4
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +29 -27
- package/dist/cli/stdin.d.ts +2 -1
- package/dist/cli/stdin.d.ts.map +1 -1
- package/dist/commands/generate-rules/service.d.ts +3 -2
- package/dist/commands/generate-rules/service.d.ts.map +1 -1
- package/dist/commands/health/utils.d.ts +3 -2
- package/dist/commands/health/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.d.ts +2 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +0 -11
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +6 -1
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +4 -1
- package/dist/commands/review/utils.d.ts +6 -1
- package/dist/commands/review/utils.d.ts.map +1 -1
- package/dist/commands/session/index.d.ts.map +1 -1
- package/dist/commands/session/index.js +6 -0
- package/dist/commands/session/types.d.ts +1 -0
- package/dist/commands/session/types.d.ts.map +1 -1
- package/dist/commands/tools/index.d.ts +3 -0
- package/dist/commands/tools/index.d.ts.map +1 -0
- package/dist/commands/tools/index.js +190 -0
- package/dist/commands/tools/templates.d.ts +6 -0
- package/dist/commands/tools/templates.d.ts.map +1 -0
- package/dist/commands/tools/templates.js +97 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +41 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/dist/models/anthropic-provider.d.ts +1 -1
- package/dist/models/deepseek-provider.d.ts +3 -3
- package/dist/models/deepseek-provider.js +17 -17
- package/dist/models/google-provider.d.ts +2 -4
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +2 -17
- package/dist/models/groq-provider.d.ts +2 -4
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +3 -21
- package/dist/models/opencode-go-provider.d.ts +35 -0
- package/dist/models/opencode-go-provider.d.ts.map +1 -0
- package/dist/models/opencode-go-provider.js +214 -0
- package/dist/models/opencode-zen-provider.d.ts +5 -5
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +41 -47
- package/dist/models/openrouter-provider.d.ts +5 -13
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +34 -138
- package/dist/models/providers.d.ts +3 -3
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/providers.js +6 -0
- package/dist/models/xai-provider.d.ts +1 -2
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -13
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +5 -1
- package/dist/prompts/mentions.d.ts.map +1 -1
- package/dist/prompts/mentions.js +35 -6
- package/dist/prompts/system-prompt.d.ts +1 -0
- package/dist/prompts/system-prompt.d.ts.map +1 -1
- package/dist/prompts/system-prompt.js +20 -5
- package/dist/repl/index.d.ts +1 -2
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +14 -53
- package/dist/sessions/manager.d.ts +3 -3
- package/dist/sessions/manager.d.ts.map +1 -1
- package/dist/sessions/manager.js +1 -1
- package/dist/skills/activated-tracker.d.ts +11 -0
- package/dist/skills/activated-tracker.d.ts.map +1 -0
- package/dist/skills/activated-tracker.js +16 -0
- package/dist/skills/index.d.ts +3 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +7 -1
- package/dist/subagents/index.d.ts +2 -1
- package/dist/subagents/index.d.ts.map +1 -1
- package/dist/terminal/table/utils.d.ts +1 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/wrap-ansi.js +2 -2
- package/dist/tools/agent.js +1 -1
- package/dist/tools/apply-patch.d.ts +62 -0
- package/dist/tools/apply-patch.d.ts.map +1 -0
- package/dist/tools/apply-patch.js +377 -0
- package/dist/tools/bash.d.ts +4 -4
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +40 -8
- package/dist/tools/directory-tree.d.ts +4 -4
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +3 -1
- package/dist/tools/dynamic-tool-loader.d.ts +12 -3
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +299 -39
- package/dist/tools/edit-file.d.ts +2 -2
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +188 -79
- package/dist/tools/glob.d.ts +16 -16
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +30 -15
- package/dist/tools/grep.d.ts +14 -14
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +50 -29
- package/dist/tools/index.d.ts +57 -84
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +20 -5
- package/dist/tools/ls.d.ts +2 -2
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +2 -1
- package/dist/tools/read-file.d.ts +9 -11
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +21 -16
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +26 -21
- package/dist/tools/skill.d.ts +2 -1
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +55 -12
- package/dist/tools/types.d.ts +8 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/web-fetch.d.ts +6 -18
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +45 -9
- package/dist/tools/web-search.d.ts +4 -22
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +1 -1
- package/dist/tui/autocomplete/file-search-provider.js +1 -1
- package/dist/tui/autocomplete/utils.d.ts +2 -1
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +25 -23
- package/dist/tui/components/editor.d.ts +2 -1
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +1 -1
- package/dist/tui/components/footer.d.ts +0 -2
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +1 -17
- package/dist/tui/components/markdown.d.ts +2 -2
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/welcome.d.ts +2 -1
- package/dist/tui/components/welcome.d.ts.map +1 -1
- package/dist/tui/editor-launcher.d.ts +3 -2
- package/dist/tui/editor-launcher.d.ts.map +1 -1
- package/dist/tui/index.d.ts +0 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/tui.d.ts +1 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +9 -0
- package/dist/tui/utils.d.ts +1 -5
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +271 -44
- package/dist/utils/binary-output.d.ts +32 -0
- package/dist/utils/binary-output.d.ts.map +1 -0
- package/dist/utils/binary-output.js +127 -0
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +92 -9
- package/dist/utils/parsing.d.ts +1 -1
- package/dist/utils/parsing.d.ts.map +1 -1
- package/package.json +28 -26
- package/dist/commands/add-directory/types.d.ts +0 -6
- package/dist/commands/add-directory/types.d.ts.map +0 -1
- package/dist/commands/add-directory/types.js +0 -1
- package/dist/commands/copy/types.d.ts +0 -3
- package/dist/commands/copy/types.d.ts.map +0 -1
- package/dist/commands/copy/types.js +0 -1
- package/dist/commands/review/types.d.ts +0 -12
- package/dist/commands/review/types.d.ts.map +0 -1
- package/dist/commands/review/types.js +0 -1
- package/dist/modes/manager.d.ts +0 -23
- package/dist/modes/manager.d.ts.map +0 -1
- package/dist/modes/manager.js +0 -77
- package/dist/modes/prompts.d.ts +0 -2
- package/dist/modes/prompts.d.ts.map +0 -1
- package/dist/modes/prompts.js +0 -143
- package/dist/tools/code-search.d.ts +0 -41
- package/dist/tools/code-search.d.ts.map +0 -1
- package/dist/tools/code-search.js +0 -195
- package/dist/utils/iterables.d.ts +0 -2
- package/dist/utils/iterables.d.ts.map +0 -1
- package/dist/utils/iterables.js +0 -6
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AsyncReturnType } from "@travisennis/stdlib/types";
|
|
2
2
|
import type { Tool } from "ai";
|
|
3
3
|
import type { WorkspaceContext } from "../index.ts";
|
|
4
|
+
import { ActivatedSkillsTracker } from "../skills/activated-tracker.ts";
|
|
4
5
|
export type CompleteToolSet = {
|
|
5
6
|
-readonly [K in keyof AsyncReturnType<typeof initTools>]: AsyncReturnType<typeof initTools>[K];
|
|
6
7
|
};
|
|
@@ -8,15 +9,34 @@ export type CompleteTools = {
|
|
|
8
9
|
-readonly [K in keyof AsyncReturnType<typeof initTools>]: Tool<unknown, string>;
|
|
9
10
|
};
|
|
10
11
|
export type CompleteToolNames = keyof CompleteToolSet;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the activated skills tracker instance.
|
|
14
|
+
* Used to reset the tracker when a new session starts.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getActivatedSkillsTracker(): ActivatedSkillsTracker;
|
|
11
17
|
export declare function initTools({ workspace, }: {
|
|
12
18
|
workspace: WorkspaceContext;
|
|
13
19
|
}): Promise<{
|
|
20
|
+
readonly ApplyPatch: {
|
|
21
|
+
toolDef: {
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: import("zod").ZodObject<{
|
|
24
|
+
patchText: import("zod").ZodString;
|
|
25
|
+
}, import("zod/v4/core").$strip>;
|
|
26
|
+
};
|
|
27
|
+
display({ patchText }: {
|
|
28
|
+
patchText: string;
|
|
29
|
+
}): string;
|
|
30
|
+
execute({ patchText }: {
|
|
31
|
+
patchText: string;
|
|
32
|
+
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
33
|
+
};
|
|
14
34
|
readonly Edit: {
|
|
15
35
|
toolDef: {
|
|
16
36
|
description: string;
|
|
17
37
|
inputSchema: import("zod").ZodObject<{
|
|
18
38
|
path: import("zod").ZodString;
|
|
19
|
-
edits: import("zod").
|
|
39
|
+
edits: import("zod").ZodPreprocess<import("zod").ZodArray<import("zod").ZodObject<{
|
|
20
40
|
oldText: import("zod").ZodString;
|
|
21
41
|
newText: import("zod").ZodString;
|
|
22
42
|
}, import("zod/v4/core").$strip>>>;
|
|
@@ -42,8 +62,8 @@ export declare function initTools({ workspace, }: {
|
|
|
42
62
|
description: string;
|
|
43
63
|
inputSchema: import("zod").ZodObject<{
|
|
44
64
|
command: import("zod").ZodString;
|
|
45
|
-
cwd: import("zod").
|
|
46
|
-
timeout: import("zod").
|
|
65
|
+
cwd: import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
66
|
+
timeout: import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
47
67
|
background: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
48
68
|
}, import("zod/v4/core").$strip>;
|
|
49
69
|
};
|
|
@@ -67,14 +87,14 @@ export declare function initTools({ workspace, }: {
|
|
|
67
87
|
path: import("zod").ZodString;
|
|
68
88
|
content: import("zod").ZodString;
|
|
69
89
|
encoding: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
90
|
+
base64: "base64";
|
|
91
|
+
base64url: "base64url";
|
|
70
92
|
utf8: "utf8";
|
|
71
93
|
ascii: "ascii";
|
|
72
94
|
"utf-8": "utf-8";
|
|
73
95
|
utf16le: "utf16le";
|
|
74
96
|
ucs2: "ucs2";
|
|
75
97
|
"ucs-2": "ucs-2";
|
|
76
|
-
base64: "base64";
|
|
77
|
-
base64url: "base64url";
|
|
78
98
|
latin1: "latin1";
|
|
79
99
|
binary: "binary";
|
|
80
100
|
hex: "hex";
|
|
@@ -84,12 +104,12 @@ export declare function initTools({ workspace, }: {
|
|
|
84
104
|
display({ path }: {
|
|
85
105
|
path: string;
|
|
86
106
|
content: string;
|
|
87
|
-
encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "
|
|
107
|
+
encoding: "base64" | "base64url" | "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "latin1" | "binary" | "hex";
|
|
88
108
|
}): string;
|
|
89
109
|
execute({ path: userPath, content, encoding }: {
|
|
90
110
|
path: string;
|
|
91
111
|
content: string;
|
|
92
|
-
encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "
|
|
112
|
+
encoding: "base64" | "base64url" | "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "latin1" | "binary" | "hex";
|
|
93
113
|
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
94
114
|
};
|
|
95
115
|
readonly Read: {
|
|
@@ -98,50 +118,47 @@ export declare function initTools({ workspace, }: {
|
|
|
98
118
|
inputSchema: import("zod").ZodObject<{
|
|
99
119
|
path: import("zod").ZodString;
|
|
100
120
|
encoding: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodEnum<{
|
|
121
|
+
base64: "base64";
|
|
122
|
+
base64url: "base64url";
|
|
101
123
|
utf8: "utf8";
|
|
102
124
|
ascii: "ascii";
|
|
103
125
|
"utf-8": "utf-8";
|
|
104
126
|
utf16le: "utf16le";
|
|
105
127
|
ucs2: "ucs2";
|
|
106
128
|
"ucs-2": "ucs-2";
|
|
107
|
-
base64: "base64";
|
|
108
|
-
base64url: "base64url";
|
|
109
129
|
latin1: "latin1";
|
|
110
130
|
binary: "binary";
|
|
111
131
|
hex: "hex";
|
|
112
132
|
}>>>;
|
|
113
|
-
startLine: import("zod").
|
|
114
|
-
lineCount: import("zod").
|
|
115
|
-
maxBytes: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
133
|
+
startLine: import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
134
|
+
lineCount: import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
116
135
|
}, import("zod/v4/core").$strip>;
|
|
117
136
|
};
|
|
118
137
|
display({ path: providedPath, startLine, lineCount }: {
|
|
119
138
|
path: string;
|
|
120
|
-
encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "
|
|
139
|
+
encoding: "base64" | "base64url" | "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "latin1" | "binary" | "hex" | null;
|
|
121
140
|
startLine: number | null;
|
|
122
141
|
lineCount: number | null;
|
|
123
|
-
maxBytes: number | null;
|
|
124
142
|
}): string;
|
|
125
|
-
execute({ path: providedPath, encoding, startLine, lineCount,
|
|
143
|
+
execute({ path: providedPath, encoding, startLine, lineCount, }: {
|
|
126
144
|
path: string;
|
|
127
|
-
encoding: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "
|
|
145
|
+
encoding: "base64" | "base64url" | "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "latin1" | "binary" | "hex" | null;
|
|
128
146
|
startLine: number | null;
|
|
129
147
|
lineCount: number | null;
|
|
130
|
-
maxBytes: number | null;
|
|
131
148
|
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
132
149
|
};
|
|
133
150
|
readonly Glob: {
|
|
134
151
|
toolDef: {
|
|
135
152
|
description: string;
|
|
136
153
|
inputSchema: import("zod").ZodObject<{
|
|
137
|
-
patterns: import("zod").
|
|
138
|
-
path: import("zod").
|
|
139
|
-
gitignore: import("zod").
|
|
140
|
-
recursive: import("zod").
|
|
141
|
-
expandDirectories: import("zod").
|
|
142
|
-
ignoreFiles: import("zod").
|
|
143
|
-
cwd: import("zod").
|
|
144
|
-
maxResults: import("zod").
|
|
154
|
+
patterns: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>>;
|
|
155
|
+
path: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodString>>;
|
|
156
|
+
gitignore: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
157
|
+
recursive: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
158
|
+
expandDirectories: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
159
|
+
ignoreFiles: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>>>;
|
|
160
|
+
cwd: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedString<unknown>>>>;
|
|
161
|
+
maxResults: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
145
162
|
}, import("zod/v4/core").$strip>;
|
|
146
163
|
};
|
|
147
164
|
display({ patterns, path }: {
|
|
@@ -171,13 +188,13 @@ export declare function initTools({ workspace, }: {
|
|
|
171
188
|
inputSchema: import("zod").ZodObject<{
|
|
172
189
|
pattern: import("zod").ZodString;
|
|
173
190
|
path: import("zod").ZodString;
|
|
174
|
-
recursive: import("zod").
|
|
175
|
-
ignoreCase: import("zod").
|
|
176
|
-
filePattern: import("zod").
|
|
177
|
-
contextLines: import("zod").
|
|
178
|
-
searchIgnored: import("zod").
|
|
179
|
-
literal: import("zod").
|
|
180
|
-
maxResults: import("zod").
|
|
191
|
+
recursive: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
192
|
+
ignoreCase: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
193
|
+
filePattern: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedString<unknown>>>>;
|
|
194
|
+
contextLines: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
195
|
+
searchIgnored: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
196
|
+
literal: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
197
|
+
maxResults: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
181
198
|
}, import("zod/v4/core").$strip>;
|
|
182
199
|
};
|
|
183
200
|
display({ pattern, path, filePattern, recursive, ignoreCase, contextLines, }: {
|
|
@@ -203,57 +220,13 @@ export declare function initTools({ workspace, }: {
|
|
|
203
220
|
maxResults: number | null;
|
|
204
221
|
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
205
222
|
};
|
|
206
|
-
readonly CodeSearch: {
|
|
207
|
-
toolDef: {
|
|
208
|
-
description: string;
|
|
209
|
-
inputSchema: import("zod").ZodObject<{
|
|
210
|
-
query: import("zod").ZodString;
|
|
211
|
-
path: import("zod").ZodDefault<import("zod").ZodString>;
|
|
212
|
-
regexPattern: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodString>>;
|
|
213
|
-
filePattern: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodString>>;
|
|
214
|
-
excludePattern: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodString>>;
|
|
215
|
-
excludeDir: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodString>>;
|
|
216
|
-
maxResults: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
217
|
-
contextLines: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>;
|
|
218
|
-
filesOnly: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
|
|
219
|
-
showContent: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
|
|
220
|
-
codeOnly: import("zod").ZodPipe<import("zod").ZodTransform<unknown, unknown>, import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>;
|
|
221
|
-
}, import("zod/v4/core").$strip>;
|
|
222
|
-
};
|
|
223
|
-
display({ query, path, regexPattern, filePattern, excludePattern, excludeDir, maxResults, contextLines, filesOnly, showContent, codeOnly, }: {
|
|
224
|
-
query: string;
|
|
225
|
-
path: string;
|
|
226
|
-
regexPattern: string | null;
|
|
227
|
-
filePattern: string | null;
|
|
228
|
-
excludePattern: string | null;
|
|
229
|
-
excludeDir: string | null;
|
|
230
|
-
maxResults: number | null;
|
|
231
|
-
contextLines: number | null;
|
|
232
|
-
filesOnly: boolean | null;
|
|
233
|
-
showContent: boolean | null;
|
|
234
|
-
codeOnly: boolean | null;
|
|
235
|
-
}): string;
|
|
236
|
-
execute({ query, path, regexPattern, filePattern, excludePattern, excludeDir, maxResults, contextLines, filesOnly, showContent, codeOnly, }: {
|
|
237
|
-
query: string;
|
|
238
|
-
path: string;
|
|
239
|
-
regexPattern: string | null;
|
|
240
|
-
filePattern: string | null;
|
|
241
|
-
excludePattern: string | null;
|
|
242
|
-
excludeDir: string | null;
|
|
243
|
-
maxResults: number | null;
|
|
244
|
-
contextLines: number | null;
|
|
245
|
-
filesOnly: boolean | null;
|
|
246
|
-
showContent: boolean | null;
|
|
247
|
-
codeOnly: boolean | null;
|
|
248
|
-
}, { abortSignal }: import("./types.ts").ToolExecutionOptions): Promise<string>;
|
|
249
|
-
};
|
|
250
223
|
readonly DirectoryTree: {
|
|
251
224
|
toolDef: {
|
|
252
225
|
description: string;
|
|
253
226
|
inputSchema: import("zod").ZodObject<{
|
|
254
227
|
path: import("zod").ZodString;
|
|
255
|
-
maxResults: import("zod").
|
|
256
|
-
maxDepth: import("zod").
|
|
228
|
+
maxResults: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
229
|
+
maxDepth: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
257
230
|
}, import("zod/v4/core").$strip>;
|
|
258
231
|
};
|
|
259
232
|
display({ path, maxDepth, maxResults }: {
|
|
@@ -284,7 +257,7 @@ export declare function initTools({ workspace, }: {
|
|
|
284
257
|
description: string;
|
|
285
258
|
inputSchema: import("zod").ZodObject<{
|
|
286
259
|
path: import("zod").ZodOptional<import("zod").ZodString>;
|
|
287
|
-
limit: import("zod").
|
|
260
|
+
limit: import("zod").ZodDefault<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
288
261
|
}, import("zod/v4/core").$strip>;
|
|
289
262
|
};
|
|
290
263
|
display({ path: providedPath, limit }: {
|
|
@@ -338,8 +311,8 @@ export declare function initTools({ workspace, }: {
|
|
|
338
311
|
description: string;
|
|
339
312
|
inputSchema: import("zod").ZodObject<{
|
|
340
313
|
query: import("zod").ZodString;
|
|
341
|
-
numResults: import("zod").ZodOptional<import("zod").
|
|
342
|
-
timeout: import("zod").ZodOptional<import("zod").
|
|
314
|
+
numResults: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
315
|
+
timeout: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
343
316
|
provider: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
344
317
|
exa: "exa";
|
|
345
318
|
duckduckgo: "duckduckgo";
|
|
@@ -370,9 +343,9 @@ export declare function initTools({ workspace, }: {
|
|
|
370
343
|
html: "html";
|
|
371
344
|
json: "json";
|
|
372
345
|
}>>;
|
|
373
|
-
jina: import("zod").ZodOptional<import("zod").
|
|
374
|
-
timeout: import("zod").ZodOptional<import("zod").
|
|
375
|
-
headers: import("zod").ZodOptional<import("zod").
|
|
346
|
+
jina: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
347
|
+
timeout: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedNumber<unknown>>>>;
|
|
348
|
+
headers: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodNullable<import("zod").ZodCoercedBoolean<unknown>>>>;
|
|
376
349
|
}, import("zod/v4/core").$strip>;
|
|
377
350
|
};
|
|
378
351
|
display({ url }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAoBxE,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,eAAe,CACvE,OAAO,SAAS,CACjB,CAAC,CAAC,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,UAAU,CAAC,IAAI,MAAM,eAAe,CAAC,OAAO,SAAS,CAAC,GAAG,IAAI,CAC5D,OAAO,EACP,MAAM,CACP;CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC;AAKtD;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,sBAAsB,CAElE;AAED,wBAAsB,SAAS,CAAC,EAC9B,SAAS,GACV,EAAE;IACD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EA"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { config } from "../config/index.js";
|
|
2
|
+
import { ActivatedSkillsTracker } from "../skills/activated-tracker.js";
|
|
2
3
|
import { AgentTool, createAgentTools } from "./agent.js";
|
|
4
|
+
import { ApplyPatchTool, createApplyPatchTool } from "./apply-patch.js";
|
|
3
5
|
import { BashTool, createBashTool } from "./bash.js";
|
|
4
|
-
import { CodeSearchTool, createCodeSearchTool } from "./code-search.js";
|
|
5
6
|
import { createDirectoryTreeTool, DirectoryTreeTool, } from "./directory-tree.js";
|
|
6
7
|
import { loadDynamicTools } from "./dynamic-tool-loader.js";
|
|
7
8
|
import { createEditFileTool, EditFileTool } from "./edit-file.js";
|
|
@@ -14,6 +15,15 @@ import { createSkillTool, SkillTool } from "./skill.js";
|
|
|
14
15
|
import { createThinkTool, ThinkTool } from "./think.js";
|
|
15
16
|
import { createWebFetchTool, WebFetchTool } from "./web-fetch.js";
|
|
16
17
|
import { createWebSearchTool, WebSearchTool } from "./web-search.js";
|
|
18
|
+
// Singleton tracker for activated skills, reset when a new session starts
|
|
19
|
+
const activatedSkillsTracker = new ActivatedSkillsTracker();
|
|
20
|
+
/**
|
|
21
|
+
* Returns the activated skills tracker instance.
|
|
22
|
+
* Used to reset the tracker when a new session starts.
|
|
23
|
+
*/
|
|
24
|
+
export function getActivatedSkillsTracker() {
|
|
25
|
+
return activatedSkillsTracker;
|
|
26
|
+
}
|
|
17
27
|
export async function initTools({ workspace, }) {
|
|
18
28
|
const readFileTool = await createReadFileTool({ workspace });
|
|
19
29
|
const editFileTool = await createEditFileTool({ workspace });
|
|
@@ -21,25 +31,25 @@ export async function initTools({ workspace, }) {
|
|
|
21
31
|
const directoryTreeTool = await createDirectoryTreeTool({ workspace });
|
|
22
32
|
const globTool = createGlobTool();
|
|
23
33
|
const grepTool = createGrepTool();
|
|
24
|
-
const codeSearchTool = createCodeSearchTool();
|
|
25
34
|
const thinkTool = createThinkTool();
|
|
26
35
|
const lsTool = await createLsTool({ workspace });
|
|
27
36
|
const projectConfig = await config.getConfig();
|
|
28
37
|
const bashTool = await createBashTool({ workspace, env: projectConfig.env });
|
|
29
|
-
const skillTool = await createSkillTool();
|
|
38
|
+
const skillTool = await createSkillTool(activatedSkillsTracker);
|
|
30
39
|
const agentTool = await createAgentTools({ workspace });
|
|
31
40
|
const webSearchTool = await createWebSearchTool();
|
|
32
41
|
const webFetchTool = await createWebFetchTool();
|
|
42
|
+
const applyPatchTool = await createApplyPatchTool({ workspace });
|
|
33
43
|
const dynamicTools = await loadDynamicTools({
|
|
34
44
|
baseDir: workspace.primaryDir,
|
|
35
45
|
existingToolNames: [
|
|
46
|
+
ApplyPatchTool.name,
|
|
36
47
|
EditFileTool.name,
|
|
37
48
|
BashTool.name,
|
|
38
49
|
SaveFileTool.name,
|
|
39
50
|
ReadFileTool.name,
|
|
40
51
|
GlobTool.name,
|
|
41
52
|
GrepTool.name,
|
|
42
|
-
CodeSearchTool.name,
|
|
43
53
|
DirectoryTreeTool.name,
|
|
44
54
|
ThinkTool.name,
|
|
45
55
|
LsTool.name,
|
|
@@ -48,16 +58,21 @@ export async function initTools({ workspace, }) {
|
|
|
48
58
|
WebSearchTool.name,
|
|
49
59
|
WebFetchTool.name,
|
|
50
60
|
],
|
|
61
|
+
sessionContext: {
|
|
62
|
+
sessionId: "",
|
|
63
|
+
projectDir: workspace.primaryDir,
|
|
64
|
+
agentName: "repl",
|
|
65
|
+
},
|
|
51
66
|
});
|
|
52
67
|
// Build tools object for AI SDK
|
|
53
68
|
const tools = {
|
|
69
|
+
[ApplyPatchTool.name]: applyPatchTool,
|
|
54
70
|
[EditFileTool.name]: editFileTool,
|
|
55
71
|
[BashTool.name]: bashTool,
|
|
56
72
|
[SaveFileTool.name]: saveFileTool,
|
|
57
73
|
[ReadFileTool.name]: readFileTool,
|
|
58
74
|
[GlobTool.name]: globTool,
|
|
59
75
|
[GrepTool.name]: grepTool,
|
|
60
|
-
[CodeSearchTool.name]: codeSearchTool,
|
|
61
76
|
[DirectoryTreeTool.name]: directoryTreeTool,
|
|
62
77
|
[ThinkTool.name]: thinkTool,
|
|
63
78
|
[LsTool.name]: lsTool,
|
package/dist/tools/ls.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const LsTool: {
|
|
|
6
6
|
};
|
|
7
7
|
declare const inputSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodOptional<z.ZodString>;
|
|
9
|
-
limit: z.
|
|
9
|
+
limit: z.ZodDefault<z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
11
|
type LsInputSchema = z.infer<typeof inputSchema>;
|
|
12
12
|
export declare const createLsTool: (options: {
|
|
@@ -16,7 +16,7 @@ export declare const createLsTool: (options: {
|
|
|
16
16
|
description: string;
|
|
17
17
|
inputSchema: z.ZodObject<{
|
|
18
18
|
path: z.ZodOptional<z.ZodString>;
|
|
19
|
-
limit: z.
|
|
19
|
+
limit: z.ZodDefault<z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>>;
|
|
20
20
|
}, z.core.$strip>;
|
|
21
21
|
};
|
|
22
22
|
display({ path: providedPath, limit }: LsInputSchema): string;
|
package/dist/tools/ls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.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;AAEvD,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,QAAA,MAAM,WAAW;;;
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../source/tools/ls.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;AAEvD,eAAO,MAAM,MAAM;;CAElB,CAAC;AAEF,QAAA,MAAM,WAAW;;;iBASf,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAIjD,eAAO,MAAM,YAAY,GAAU,SAAS;IAC1C,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;2CAU0C,aAAa;2CAOnB,aAAa,mBAC3B,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA6DrB,CAAC"}
|
package/dist/tools/ls.js
CHANGED
|
@@ -16,6 +16,7 @@ const inputSchema = z.object({
|
|
|
16
16
|
.describe("Directory to list (default: current directory)"),
|
|
17
17
|
limit: z
|
|
18
18
|
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
19
|
+
.default(null)
|
|
19
20
|
.describe("Maximum number of entries to return (default: 500)"),
|
|
20
21
|
});
|
|
21
22
|
const DEFAULT_ENTRY_LIMIT = 500;
|
|
@@ -24,7 +25,7 @@ export const createLsTool = async (options) => {
|
|
|
24
25
|
const allowedDirectory = allowedDirs ?? [primaryDir];
|
|
25
26
|
return {
|
|
26
27
|
toolDef: {
|
|
27
|
-
description: "List files in a directory.",
|
|
28
|
+
description: "List files in a single directory. Fast and simple - use this when you need a quick flat list of files in one directory. For recursive tree views, use DirectoryTree instead.",
|
|
28
29
|
inputSchema,
|
|
29
30
|
},
|
|
30
31
|
display({ path: providedPath, limit }) {
|
|
@@ -7,21 +7,20 @@ export declare const ReadFileTool: {
|
|
|
7
7
|
declare const inputSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
|
9
9
|
encoding: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
10
|
+
base64: "base64";
|
|
11
|
+
base64url: "base64url";
|
|
10
12
|
utf8: "utf8";
|
|
11
13
|
ascii: "ascii";
|
|
12
14
|
"utf-8": "utf-8";
|
|
13
15
|
utf16le: "utf16le";
|
|
14
16
|
ucs2: "ucs2";
|
|
15
17
|
"ucs-2": "ucs-2";
|
|
16
|
-
base64: "base64";
|
|
17
|
-
base64url: "base64url";
|
|
18
18
|
latin1: "latin1";
|
|
19
19
|
binary: "binary";
|
|
20
20
|
hex: "hex";
|
|
21
21
|
}>>>;
|
|
22
|
-
startLine: z.
|
|
23
|
-
lineCount: z.
|
|
24
|
-
maxBytes: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
22
|
+
startLine: z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
23
|
+
lineCount: z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
25
24
|
}, z.core.$strip>;
|
|
26
25
|
type ReadFileInputSchema = z.infer<typeof inputSchema>;
|
|
27
26
|
export declare const createReadFileTool: (options: {
|
|
@@ -32,25 +31,24 @@ export declare const createReadFileTool: (options: {
|
|
|
32
31
|
inputSchema: z.ZodObject<{
|
|
33
32
|
path: z.ZodString;
|
|
34
33
|
encoding: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
34
|
+
base64: "base64";
|
|
35
|
+
base64url: "base64url";
|
|
35
36
|
utf8: "utf8";
|
|
36
37
|
ascii: "ascii";
|
|
37
38
|
"utf-8": "utf-8";
|
|
38
39
|
utf16le: "utf16le";
|
|
39
40
|
ucs2: "ucs2";
|
|
40
41
|
"ucs-2": "ucs-2";
|
|
41
|
-
base64: "base64";
|
|
42
|
-
base64url: "base64url";
|
|
43
42
|
latin1: "latin1";
|
|
44
43
|
binary: "binary";
|
|
45
44
|
hex: "hex";
|
|
46
45
|
}>>>;
|
|
47
|
-
startLine: z.
|
|
48
|
-
lineCount: z.
|
|
49
|
-
maxBytes: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
46
|
+
startLine: z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
47
|
+
lineCount: z.ZodPreprocess<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
|
|
50
48
|
}, z.core.$strip>;
|
|
51
49
|
};
|
|
52
50
|
display({ path: providedPath, startLine, lineCount }: ReadFileInputSchema): string;
|
|
53
|
-
execute({ path: providedPath, encoding, startLine, lineCount,
|
|
51
|
+
execute({ path: providedPath, encoding, startLine, lineCount, }: ReadFileInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
|
|
54
52
|
}>;
|
|
55
53
|
export {};
|
|
56
54
|
//# sourceMappingURL=read-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-file.d.ts","sourceRoot":"","sources":["../../source/tools/read-file.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAsBvD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;iBAkBf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEvD,eAAO,MAAM,kBAAkB,GAAU,SAAS;IAChD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;;0DAOyD,mBAAmB;qEAUpE,mBAAmB,mBACL,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EAsBrB,CAAC"}
|
package/dist/tools/read-file.js
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import { createInterface } from "node:readline/promises";
|
|
3
5
|
import { isNumber } from "@travisennis/stdlib/typeguards";
|
|
4
6
|
import { z } from "zod";
|
|
5
7
|
import style from "../terminal/style.js";
|
|
6
8
|
import { toDisplayPath } from "../utils/filesystem/path-display.js";
|
|
7
|
-
import { joinWorkingDir, validatePath } from "../utils/filesystem/security.js";
|
|
8
9
|
import { convertNullString } from "../utils/zod.js";
|
|
9
10
|
import { fileEncodingSchema } from "./types.js";
|
|
10
|
-
//
|
|
11
|
-
const
|
|
11
|
+
// hardcoded limit in bytes (50KB) - not configurable by the agent
|
|
12
|
+
const BYTE_LIMIT = 50 * 1024;
|
|
13
|
+
// Resolve a path for reading, expanding ~ and handling relative paths
|
|
14
|
+
function resolveReadPath(providedPath, workingDir) {
|
|
15
|
+
// Expand ~ to home directory
|
|
16
|
+
let resolved = providedPath;
|
|
17
|
+
if (resolved.startsWith("~/") || resolved === "~") {
|
|
18
|
+
resolved = path.join(os.homedir(), resolved.slice(1));
|
|
19
|
+
}
|
|
20
|
+
// If not absolute, join with working directory
|
|
21
|
+
if (!path.isAbsolute(resolved)) {
|
|
22
|
+
resolved = path.join(workingDir, resolved);
|
|
23
|
+
}
|
|
24
|
+
return path.normalize(resolved);
|
|
25
|
+
}
|
|
12
26
|
export const ReadFileTool = {
|
|
13
27
|
name: "Read",
|
|
14
28
|
};
|
|
@@ -24,13 +38,9 @@ const inputSchema = z.object({
|
|
|
24
38
|
lineCount: z
|
|
25
39
|
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
26
40
|
.describe("Maximum number of lines to read. Required but nullable. Pass null to get all lines."),
|
|
27
|
-
maxBytes: z
|
|
28
|
-
.preprocess((val) => convertNullString(val), z.coerce.number().nullable())
|
|
29
|
-
.describe("Maximum number of bytes to read. Set to 0 for no limit. (Default: 20KB)"),
|
|
30
41
|
});
|
|
31
42
|
export const createReadFileTool = async (options) => {
|
|
32
|
-
const { primaryDir
|
|
33
|
-
const allowedDirectory = allowedDirs ?? [primaryDir];
|
|
43
|
+
const { primaryDir } = options.workspace;
|
|
34
44
|
return {
|
|
35
45
|
toolDef: {
|
|
36
46
|
description: "Read the contents of a file.",
|
|
@@ -40,15 +50,14 @@ export const createReadFileTool = async (options) => {
|
|
|
40
50
|
const displayPath = toDisplayPath(providedPath);
|
|
41
51
|
return `${style.cyan(displayPath)}${startLine ? style.cyan(`:${startLine}`) : ""}${lineCount ? style.cyan(`:${lineCount}`) : ""}`;
|
|
42
52
|
},
|
|
43
|
-
async execute({ path: providedPath, encoding, startLine, lineCount,
|
|
53
|
+
async execute({ path: providedPath, encoding, startLine, lineCount, }, { abortSignal }) {
|
|
44
54
|
if (abortSignal?.aborted) {
|
|
45
55
|
throw new Error("File reading aborted");
|
|
46
56
|
}
|
|
47
|
-
const filePath =
|
|
57
|
+
const filePath = resolveReadPath(providedPath, primaryDir);
|
|
48
58
|
const effectiveEncoding = encoding ?? "utf-8";
|
|
49
|
-
const effectiveMaxBytes = maxBytes ?? DEFAULT_BYTE_LIMIT;
|
|
50
59
|
const file = await readFileContent(filePath, effectiveEncoding, startLine, lineCount, abortSignal);
|
|
51
|
-
validateByteLimit(file, effectiveEncoding,
|
|
60
|
+
validateByteLimit(file, effectiveEncoding, BYTE_LIMIT);
|
|
52
61
|
return file;
|
|
53
62
|
},
|
|
54
63
|
};
|
|
@@ -98,15 +107,11 @@ async function readFileLines(filePath, startLine, lineCount, abortSignal) {
|
|
|
98
107
|
}
|
|
99
108
|
// Validate that file content doesn't exceed byte limit
|
|
100
109
|
function validateByteLimit(file, encoding, maxBytes) {
|
|
101
|
-
if (maxBytes <= 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
110
|
const byteLength = Buffer.byteLength(file, encoding);
|
|
105
111
|
if (byteLength > maxBytes) {
|
|
106
112
|
const fileSizeKb = (byteLength / 1024).toFixed(1);
|
|
107
113
|
const limitKb = (maxBytes / 1024).toFixed(0);
|
|
108
114
|
throw new Error(`File (${fileSizeKb}KB) exceeds the ${limitKb}KB read limit. To read this file, use one of these options:\n` +
|
|
109
|
-
"• Set maxBytes: 0 to read the entire file\n" +
|
|
110
115
|
"• Use startLine and lineCount to read specific portions (e.g., startLine: 1, lineCount: 100)\n" +
|
|
111
116
|
"• Use the Grep tool to search for specific content\n" +
|
|
112
117
|
`• Use the Bash tool with 'tail' or 'head' commands`);
|
|
@@ -8,14 +8,14 @@ declare const inputSchema: z.ZodObject<{
|
|
|
8
8
|
path: z.ZodString;
|
|
9
9
|
content: z.ZodString;
|
|
10
10
|
encoding: z.ZodDefault<z.ZodEnum<{
|
|
11
|
+
base64: "base64";
|
|
12
|
+
base64url: "base64url";
|
|
11
13
|
utf8: "utf8";
|
|
12
14
|
ascii: "ascii";
|
|
13
15
|
"utf-8": "utf-8";
|
|
14
16
|
utf16le: "utf16le";
|
|
15
17
|
ucs2: "ucs2";
|
|
16
18
|
"ucs-2": "ucs-2";
|
|
17
|
-
base64: "base64";
|
|
18
|
-
base64url: "base64url";
|
|
19
19
|
latin1: "latin1";
|
|
20
20
|
binary: "binary";
|
|
21
21
|
hex: "hex";
|
|
@@ -31,14 +31,14 @@ export declare const createSaveFileTool: (options: {
|
|
|
31
31
|
path: z.ZodString;
|
|
32
32
|
content: z.ZodString;
|
|
33
33
|
encoding: z.ZodDefault<z.ZodEnum<{
|
|
34
|
+
base64: "base64";
|
|
35
|
+
base64url: "base64url";
|
|
34
36
|
utf8: "utf8";
|
|
35
37
|
ascii: "ascii";
|
|
36
38
|
"utf-8": "utf-8";
|
|
37
39
|
utf16le: "utf16le";
|
|
38
40
|
ucs2: "ucs2";
|
|
39
41
|
"ucs-2": "ucs-2";
|
|
40
|
-
base64: "base64";
|
|
41
|
-
base64url: "base64url";
|
|
42
42
|
latin1: "latin1";
|
|
43
43
|
binary: "binary";
|
|
44
44
|
hex: "hex";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save-file.d.ts","sourceRoot":"","sources":["../../source/tools/save-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"save-file.d.ts","sourceRoot":"","sources":["../../source/tools/save-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AA8BvD,eAAO,MAAM,kBAAkB,GAAU,SAAS;IAChD,SAAS,EAAE,gBAAgB,CAAC;CAC7B;;;;;;;;;;;;;;;;;;;;;sBAUqB,mBAAmB;mDAKI,mBAAmB,mBACzC,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;EA8BrB,CAAC"}
|