mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-02 16:04:38 -07:00
feat(core): rename search_file_content tool to grep_search and add legacy alias (#18003)
This commit is contained in:
@@ -3,5 +3,5 @@
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
export const DEFAULT_TOTAL_MAX_MATCHES = 20000;
|
||||
export const DEFAULT_TOTAL_MAX_MATCHES = 100;
|
||||
export const DEFAULT_SEARCH_TIMEOUT_MS = 30000;
|
||||
|
||||
@@ -263,7 +263,13 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
const matchCount = allMatches.length;
|
||||
const matchTerm = matchCount === 1 ? 'match' : 'matches';
|
||||
|
||||
let llmContent = `Found ${matchCount} ${matchTerm} for pattern "${this.params.pattern}" ${searchLocationDescription}${this.params.include ? ` (filter: "${this.params.include}")` : ''}${wasTruncated ? ` (results limited to ${totalMaxMatches} matches for performance)` : ''}:\n---\n`;
|
||||
let llmContent = `Found ${matchCount} ${matchTerm} for pattern "${this.params.pattern}" ${searchLocationDescription}${this.params.include ? ` (filter: "${this.params.include}")` : ''}`;
|
||||
|
||||
if (wasTruncated) {
|
||||
llmContent += ` (results limited to ${totalMaxMatches} matches for performance)`;
|
||||
}
|
||||
|
||||
llmContent += `:\n---\n`;
|
||||
|
||||
for (const filePath in matchesByFile) {
|
||||
llmContent += `File: ${filePath}
|
||||
@@ -570,7 +576,7 @@ export class GrepTool extends BaseDeclarativeTool<GrepToolParams, ToolResult> {
|
||||
super(
|
||||
GrepTool.Name,
|
||||
'SearchText',
|
||||
'Searches for a regular expression pattern within the content of files in a specified directory (or current working directory). Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers.',
|
||||
'Searches for a regular expression pattern within file contents. Max 100 matches.',
|
||||
Kind.Search,
|
||||
{
|
||||
properties: {
|
||||
|
||||
@@ -495,7 +495,7 @@ export class RipGrepTool extends BaseDeclarativeTool<
|
||||
super(
|
||||
RipGrepTool.Name,
|
||||
'SearchText',
|
||||
'FAST, optimized search powered by `ripgrep`. PREFERRED over standard `run_shell_command("grep ...")` due to better performance and automatic output limiting (max 20k matches).',
|
||||
'Searches for a regular expression pattern within file contents. Max 100 matches.',
|
||||
Kind.Search,
|
||||
{
|
||||
properties: {
|
||||
|
||||
@@ -15,7 +15,7 @@ export const WEB_SEARCH_TOOL_NAME = 'google_web_search';
|
||||
export const WEB_FETCH_TOOL_NAME = 'web_fetch';
|
||||
export const EDIT_TOOL_NAME = 'replace';
|
||||
export const SHELL_TOOL_NAME = 'run_shell_command';
|
||||
export const GREP_TOOL_NAME = 'search_file_content';
|
||||
export const GREP_TOOL_NAME = 'grep_search';
|
||||
export const READ_MANY_FILES_TOOL_NAME = 'read_many_files';
|
||||
export const READ_FILE_TOOL_NAME = 'read_file';
|
||||
export const LS_TOOL_NAME = 'list_directory';
|
||||
@@ -33,7 +33,7 @@ export const EXIT_PLAN_MODE_TOOL_NAME = 'exit_plan_mode';
|
||||
*/
|
||||
export const TOOL_LEGACY_ALIASES: Record<string, string> = {
|
||||
// Add future renames here, e.g.:
|
||||
// 'search_file_content': GREP_TOOL_NAME,
|
||||
search_file_content: GREP_TOOL_NAME,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user