(args, extras)
| 5 | const MAX_AGENT_GLOB_RESULTS = 100; |
| 6 | |
| 7 | export 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 | |
| 14 | if (results.length === 0) { |
| 15 | return [ |
| 16 | { |
| 17 | name: "File results", |
| 18 | description: "glob search", |
| 19 | content: "The glob search returned no results.", |
| 20 | }, |
| 21 | ]; |
| 22 | } |
| 23 | const contextItems: ContextItem[] = [ |
| 24 | { |
| 25 | name: "File results", |
| 26 | description: "glob search", |
| 27 | content: results.join("\n"), |
| 28 | }, |
| 29 | ]; |
| 30 | |
| 31 | // In case of truncation, add a warning |
| 32 | if (results.length === MAX_AGENT_GLOB_RESULTS) { |
| 33 | contextItems.push({ |
| 34 | name: "Truncation warning", |
| 35 | description: "", |
| 36 | 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`, |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | return contextItems; |
| 41 | }; |
no test coverage detected