| 1 | import { ConfigDependentToolParams, IDE, Tool } from ".."; |
| 2 | import * as toolDefinitions from "./definitions"; |
| 3 | |
| 4 | // I'm writing these as functions because we've messed up 3 TIMES by pushing to const, causing duplicate tool definitions on subsequent config loads. |
| 5 | |
| 6 | // missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269 |
| 7 | const getLocalOnlyToolDefinitions = () => [toolDefinitions.grepSearchTool]; |
| 8 | |
| 9 | const getBaseToolDefinitions = () => [ |
| 10 | toolDefinitions.readFileTool, |
| 11 | toolDefinitions.createNewFileTool, |
| 12 | toolDefinitions.runTerminalCommandTool, |
| 13 | toolDefinitions.globSearchTool, |
| 14 | toolDefinitions.searchWebTool, |
| 15 | toolDefinitions.viewDiffTool, |
| 16 | toolDefinitions.readCurrentlyOpenFileTool, |
| 17 | toolDefinitions.lsTool, |
| 18 | toolDefinitions.createRuleBlock, |
| 19 | toolDefinitions.fetchUrlContentTool, |
| 20 | ]; |
| 21 | |
| 22 | export const getConfigDependentToolDefinitions = ( |
| 23 | params: ConfigDependentToolParams, |
| 24 | ): Tool[] => [ |
| 25 | toolDefinitions.requestRuleTool(params), |
| 26 | // Search and replace is now generally available |
| 27 | toolDefinitions.searchAndReplaceInFileTool, |
| 28 | // Keep edit file tool available for models that need it |
| 29 | toolDefinitions.editFileTool, |
| 30 | ...(params.enableExperimentalTools |
| 31 | ? [ |
| 32 | toolDefinitions.viewRepoMapTool, |
| 33 | toolDefinitions.viewSubdirectoryTool, |
| 34 | toolDefinitions.codebaseTool, |
| 35 | ] |
| 36 | : []), |
| 37 | ]; |
| 38 | |
| 39 | export const getToolsForIde = async (ide: IDE): Promise<Tool[]> => |
| 40 | (await ide.isWorkspaceRemote()) |
| 41 | ? getBaseToolDefinitions() |
| 42 | : [...getBaseToolDefinitions(), ...getLocalOnlyToolDefinitions()]; |