| 1 | import { ConfigDependentToolParams, IDE, Tool } from ".."; |
| 2 | import { codebaseTool } from "./definitions/codebaseTool"; |
| 3 | import { createNewFileTool } from "./definitions/createNewFile"; |
| 4 | import { createRuleBlock } from "./definitions/createRuleBlock"; |
| 5 | import { editFileTool } from "./definitions/editFile"; |
| 6 | import { fetchUrlContentTool } from "./definitions/fetchUrlContent"; |
| 7 | import { globSearchTool } from "./definitions/globSearch"; |
| 8 | import { grepSearchTool } from "./definitions/grepSearch"; |
| 9 | import { lsTool } from "./definitions/ls"; |
| 10 | import { readCurrentlyOpenFileTool } from "./definitions/readCurrentlyOpenFile"; |
| 11 | import { readFileTool } from "./definitions/readFile"; |
| 12 | import { requestRuleTool } from "./definitions/requestRule"; |
| 13 | import { runTerminalCommandTool } from "./definitions/runTerminalCommand"; |
| 14 | import { searchAndReplaceInFileTool } from "./definitions/searchAndReplaceInFile"; |
| 15 | import { searchWebTool } from "./definitions/searchWeb"; |
| 16 | import { viewDiffTool } from "./definitions/viewDiff"; |
| 17 | import { viewRepoMapTool } from "./definitions/viewRepoMap"; |
| 18 | import { viewSubdirectoryTool } from "./definitions/viewSubdirectory"; |
| 19 | |
| 20 | // 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. |
| 21 | |
| 22 | // missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269 |
| 23 | const getLocalOnlyToolDefinitions = () => [grepSearchTool]; |
| 24 | |
| 25 | const getBaseToolDefinitions = () => [ |
| 26 | readFileTool, |
| 27 | createNewFileTool, |
| 28 | runTerminalCommandTool, |
| 29 | globSearchTool, |
| 30 | searchWebTool, |
| 31 | viewDiffTool, |
| 32 | readCurrentlyOpenFileTool, |
| 33 | lsTool, |
| 34 | createRuleBlock, |
| 35 | fetchUrlContentTool, |
| 36 | ]; |
| 37 | |
| 38 | export const getConfigDependentToolDefinitions = ( |
| 39 | params: ConfigDependentToolParams, |
| 40 | ): Tool[] => [ |
| 41 | requestRuleTool(params), |
| 42 | // Search and replace is now generally available |
| 43 | searchAndReplaceInFileTool, |
| 44 | // Keep edit file tool available for models that need it |
| 45 | editFileTool, |
| 46 | ...(params.enableExperimentalTools |
| 47 | ? [viewRepoMapTool, viewSubdirectoryTool, codebaseTool] |
| 48 | : []), |
| 49 | ]; |
| 50 | |
| 51 | export const getToolsForIde = async (ide: IDE): Promise<Tool[]> => |
| 52 | (await ide.isWorkspaceRemote()) |
| 53 | ? getBaseToolDefinitions() |
| 54 | : [...getBaseToolDefinitions(), ...getLocalOnlyToolDefinitions()]; |