53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { ConfigDependentToolParams, Tool } from "..";
|
|
import * as toolDefinitions from "./definitions";
|
|
|
|
// 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.
|
|
export const getBaseToolDefinitions = () => [
|
|
toolDefinitions.readFileTool,
|
|
toolDefinitions.createNewFileTool,
|
|
toolDefinitions.runTerminalCommandTool,
|
|
toolDefinitions.globSearchTool,
|
|
toolDefinitions.viewDiffTool,
|
|
toolDefinitions.readCurrentlyOpenFileTool,
|
|
toolDefinitions.lsTool,
|
|
toolDefinitions.createRuleBlock,
|
|
toolDefinitions.fetchUrlContentTool,
|
|
toolDefinitions.singleFindAndReplaceTool,
|
|
];
|
|
|
|
export const getConfigDependentToolDefinitions = (
|
|
params: ConfigDependentToolParams,
|
|
): Tool[] => {
|
|
const { modelName, isSignedIn, enableExperimentalTools, isRemote } = params;
|
|
const tools: Tool[] = [];
|
|
|
|
tools.push(toolDefinitions.requestRuleTool(params));
|
|
|
|
if (isSignedIn) {
|
|
// Web search is only available for signed-in users
|
|
tools.push(toolDefinitions.searchWebTool);
|
|
}
|
|
|
|
if (enableExperimentalTools) {
|
|
tools.push(
|
|
toolDefinitions.viewRepoMapTool,
|
|
toolDefinitions.viewSubdirectoryTool,
|
|
toolDefinitions.codebaseTool,
|
|
);
|
|
}
|
|
|
|
// OLD SEARCH AND REPLACE IS CURRENTLY NOT USED
|
|
// toolDefinitions.searchAndReplaceInFileTool
|
|
if (modelName?.includes("claude") || modelName?.includes("gpt-5")) {
|
|
tools.push(toolDefinitions.multiEditTool);
|
|
} else {
|
|
tools.push(toolDefinitions.editFileTool);
|
|
}
|
|
|
|
// missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269
|
|
if (!isRemote) {
|
|
tools.push(toolDefinitions.grepSearchTool);
|
|
}
|
|
|
|
return tools;
|
|
};
|