refactor: remove read-many-files tool from agent (#12796)

This commit is contained in:
Abhi
2025-11-12 21:56:37 -05:00
committed by GitHub
parent a05e0ea3a4
commit 5d27a62bec
9 changed files with 5 additions and 194 deletions
+1 -5
View File
@@ -10,7 +10,6 @@ import {
CommandKind,
} from './types.js';
import { MessageType, type HistoryItemToolsList } from '../types.js';
import { READ_MANY_FILES_TOOL_NAME } from '@google/gemini-cli-core';
export const toolsCommand: SlashCommand = {
name: 'tools',
@@ -45,10 +44,7 @@ export const toolsCommand: SlashCommand = {
type: MessageType.TOOLS_LIST,
tools: geminiTools.map((tool) => ({
name: tool.name,
displayName:
tool.name === READ_MANY_FILES_TOOL_NAME
? `${tool.displayName} (Deprecated)`
: tool.displayName,
displayName: tool.displayName,
description: tool.description,
})),
showDescriptions: useShowDescriptions,
@@ -13,6 +13,7 @@ import {
getErrorMessage,
isNodeError,
unescapePath,
ReadManyFilesTool,
} from '@google/gemini-cli-core';
import type { HistoryItem, IndividualToolCallDisplay } from '../types.js';
import { ToolCallStatus } from '../types.js';
@@ -153,7 +154,7 @@ export async function handleAtCommand({
};
const toolRegistry = config.getToolRegistry();
const readManyFilesTool = toolRegistry.getTool('read_many_files');
const readManyFilesTool = new ReadManyFilesTool(config);
const globTool = toolRegistry.getTool('glob');
if (!readManyFilesTool) {
-35
View File
@@ -34,7 +34,6 @@ import { logRipgrepFallback } from '../telemetry/loggers.js';
import { RipgrepFallbackEvent } from '../telemetry/types.js';
import { ToolRegistry } from '../tools/tool-registry.js';
import { DEFAULT_MODEL_CONFIGS } from './defaultModelConfigs.js';
import { READ_MANY_FILES_TOOL_NAME } from '../tools/tool-names.js';
vi.mock('fs', async (importOriginal) => {
const actual = await importOriginal<typeof import('fs')>();
@@ -1041,40 +1040,6 @@ describe('Server Config (config.ts)', () => {
expect(mockCoreEvents.emitFeedback).not.toHaveBeenCalled();
});
});
describe('checkDeprecatedTools', () => {
it('should emit a warning when a deprecated tool is in coreTools', async () => {
const params: ConfigParameters = {
...baseParams,
coreTools: [READ_MANY_FILES_TOOL_NAME],
};
const config = new Config(params);
await config.initialize();
expect(mockCoreEvents.emitFeedback).toHaveBeenCalledWith(
'warning',
expect.stringContaining(
`The tool '${READ_MANY_FILES_TOOL_NAME}' (or 'ReadManyFilesTool') specified in 'tools.core' is deprecated`,
),
);
});
it('should emit a warning when a deprecated tool is in allowedTools', async () => {
const params: ConfigParameters = {
...baseParams,
allowedTools: ['ReadManyFilesTool'],
};
const config = new Config(params);
await config.initialize();
expect(mockCoreEvents.emitFeedback).toHaveBeenCalledWith(
'warning',
expect.stringContaining(
`The tool '${READ_MANY_FILES_TOOL_NAME}' (or 'ReadManyFilesTool') specified in 'tools.allowed' is deprecated`,
),
);
});
});
});
describe('setApprovalMode with folder trust', () => {
-29
View File
@@ -28,7 +28,6 @@ import { SmartEditTool } from '../tools/smart-edit.js';
import { ShellTool } from '../tools/shell.js';
import { WriteFileTool } from '../tools/write-file.js';
import { WebFetchTool } from '../tools/web-fetch.js';
import { ReadManyFilesTool } from '../tools/read-many-files.js';
import { MemoryTool, setGeminiMdFilename } from '../tools/memoryTool.js';
import { WebSearchTool } from '../tools/web-search.js';
import { GeminiClient } from '../core/client.js';
@@ -164,7 +163,6 @@ import {
SimpleExtensionLoader,
} from '../utils/extensionLoader.js';
import { McpClientManager } from '../tools/mcp-client-manager.js';
import { READ_MANY_FILES_TOOL_NAME } from '../tools/tool-names.js';
export type { FileFilteringOptions };
export {
@@ -632,32 +630,6 @@ export class Config {
]);
await this.geminiClient.initialize();
this.checkDeprecatedTools();
}
private checkDeprecatedTools(): void {
const deprecatedTools = [
{
name: READ_MANY_FILES_TOOL_NAME,
alternateName: 'ReadManyFilesTool',
},
];
const checkList = (list: string[] | undefined, listName: string) => {
if (!list) return;
for (const tool of deprecatedTools) {
if (list.includes(tool.name) || list.includes(tool.alternateName)) {
coreEvents.emitFeedback(
'warning',
`The tool '${tool.name}' (or '${tool.alternateName}') specified in '${listName}' is deprecated and will be removed in v0.16.0.`,
);
}
}
};
checkList(this.coreTools, 'tools.core');
checkList(this.allowedTools, 'tools.allowed');
}
getContentGenerator(): ContentGenerator {
@@ -1396,7 +1368,6 @@ export class Config {
}
registerCoreTool(WriteFileTool, this);
registerCoreTool(WebFetchTool, this);
registerCoreTool(ReadManyFilesTool, this);
registerCoreTool(ShellTool, this);
registerCoreTool(MemoryTool);
registerCoreTool(WebSearchTool, this);