Elffuss BraidHub

kikocis/continue public

fc89067dc2f1 · 967 BRawPermalink
1import { ToolImpl } from ".";
2import { ContextItem } from "../..";
3import { getStringArg } from "../parseArgs";
4
5const MAX_AGENT_GLOB_RESULTS = 100;
6
7export const fileGlobSearchImpl: ToolImpl = async (args, extras) => {
8 const pattern = getStringArg(args, "pattern");
9 const results = await extras.ide.getFileResults(
10 pattern,
11 MAX_AGENT_GLOB_RESULTS,
12 );
13 const contextItems: ContextItem[] = [
14 {
15 name: "File results",
16 description: "Results from file glob search",
17 content: results.join("\n"),
18 },
19 ];
20
21 // In case of truncation, add a warning
22 if (results.length === MAX_AGENT_GLOB_RESULTS) {
23 contextItems.push({
24 name: "Truncation warning",
25 description: "Inform the model that results were truncated",
26 content: `Warning: the results above were truncated to the first ${MAX_AGENT_GLOB_RESULTS} files. If the results are not satisfactory, refine your search pattern`,
27 });
28 }
29
30 return contextItems;
31};