refactor(core): Centralize tool names to avoid circular dependencies - Edit, Grep, Read (#11434)

This commit is contained in:
Abhi
2025-10-19 19:21:47 -04:00
committed by GitHub
parent 98eef9ba0c
commit 23e52f0ff3
14 changed files with 76 additions and 73 deletions
+10 -7
View File
@@ -8,10 +8,13 @@ import type { Content, GenerateContentConfig } from '@google/genai';
import type { GeminiClient } from '../core/client.js';
import type { BaseLlmClient } from '../core/baseLlmClient.js';
import type { EditToolParams } from '../tools/edit.js';
import { EDIT_TOOL_NAME, WRITE_FILE_TOOL_NAME } from '../tools/tool-names.js';
import { ReadFileTool } from '../tools/read-file.js';
import { ReadManyFilesTool } from '../tools/read-many-files.js';
import { GrepTool } from '../tools/grep.js';
import {
EDIT_TOOL_NAME,
GREP_TOOL_NAME,
READ_FILE_TOOL_NAME,
READ_MANY_FILES_TOOL_NAME,
WRITE_FILE_TOOL_NAME,
} from '../tools/tool-names.js';
import { LruCache } from './LruCache.js';
import { DEFAULT_GEMINI_FLASH_LITE_MODEL } from '../config/models.js';
import {
@@ -101,11 +104,11 @@ async function findLastEditTimestamp(
const toolsInResp = new Set([
WRITE_FILE_TOOL_NAME,
EDIT_TOOL_NAME,
ReadManyFilesTool.Name,
GrepTool.Name,
READ_MANY_FILES_TOOL_NAME,
GREP_TOOL_NAME,
]);
// Tools that may reference the file path in their FunctionCall `args`.
const toolsInCall = new Set([...toolsInResp, ReadFileTool.Name]);
const toolsInCall = new Set([...toolsInResp, READ_FILE_TOOL_NAME]);
// Iterate backwards to find the most recent relevant action.
for (const entry of history.slice().reverse()) {