Elffuss BraidHub

kikocis/continue public

a77b0bec8949 · 877 BRawPermalink
1import { ToolImpl } from ".";
2import { ContextItem } from "../..";
3
4const MAX_AGENT_GLOB_RESULTS = 100;
5export const fileGlobSearchImpl: ToolImpl = async (args, extras) => {
6 const results = await extras.ide.getFileResults(
7 args.pattern,
8 MAX_AGENT_GLOB_RESULTS,
9 );
10 const contextItems: ContextItem[] = [
11 {
12 name: "File results",
13 description: "Results from file glob search",
14 content: results.join("\n"),
15 },
16 ];
17
18 // In case of truncation, add a warning
19 if (results.length === MAX_AGENT_GLOB_RESULTS) {
20 contextItems.push({
21 name: "Truncation warning",
22 description: "Inform the model that results were truncated",
23 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`,
24 });
25 }
26
27 return contextItems;
28};