mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-01 19:03:42 +00:00
refactor(tools): Move all tool names into tool-names.ts (#11493)
This commit is contained in:
@@ -409,7 +409,7 @@ class EditToolInvocation implements ToolInvocation<EditToolParams, ToolResult> {
|
||||
logFileOperation(
|
||||
this.config,
|
||||
new FileOperationEvent(
|
||||
EditTool.Name,
|
||||
EDIT_TOOL_NAME,
|
||||
operation,
|
||||
editData.newContent.split('\n').length,
|
||||
mimetype,
|
||||
@@ -464,10 +464,9 @@ export class EditTool
|
||||
extends BaseDeclarativeTool<EditToolParams, ToolResult>
|
||||
implements ModifiableDeclarativeTool<EditToolParams>
|
||||
{
|
||||
static readonly Name = EDIT_TOOL_NAME;
|
||||
constructor(private readonly config: Config) {
|
||||
super(
|
||||
EditTool.Name,
|
||||
EDIT_TOOL_NAME,
|
||||
'Edit',
|
||||
`Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
|
||||
|
||||
|
||||
@@ -260,11 +260,9 @@ class GlobToolInvocation extends BaseToolInvocation<
|
||||
* Implementation of the Glob tool logic
|
||||
*/
|
||||
export class GlobTool extends BaseDeclarativeTool<GlobToolParams, ToolResult> {
|
||||
static readonly Name = GLOB_TOOL_NAME;
|
||||
|
||||
constructor(private config: Config) {
|
||||
super(
|
||||
GlobTool.Name,
|
||||
GLOB_TOOL_NAME,
|
||||
'FindFiles',
|
||||
'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.',
|
||||
Kind.Search,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { makeRelative, shortenPath } from '../utils/paths.js';
|
||||
import type { Config } from '../config/config.js';
|
||||
import { DEFAULT_FILE_FILTERING_OPTIONS } from '../config/constants.js';
|
||||
import { ToolErrorType } from './tool-error.js';
|
||||
import { LS_TOOL_NAME } from './tool-names.js';
|
||||
|
||||
/**
|
||||
* Parameters for the LS tool
|
||||
@@ -252,11 +253,9 @@ class LSToolInvocation extends BaseToolInvocation<LSToolParams, ToolResult> {
|
||||
* Implementation of the LS tool logic
|
||||
*/
|
||||
export class LSTool extends BaseDeclarativeTool<LSToolParams, ToolResult> {
|
||||
static readonly Name = 'list_directory';
|
||||
|
||||
constructor(private config: Config) {
|
||||
super(
|
||||
LSTool.Name,
|
||||
LS_TOOL_NAME,
|
||||
'ReadFolder',
|
||||
'Lists the names of files and subdirectories directly within a specified directory path. Can optionally ignore entries matching provided glob patterns.',
|
||||
Kind.Search,
|
||||
|
||||
@@ -23,9 +23,10 @@ import type {
|
||||
ModifyContext,
|
||||
} from './modifiable-tool.js';
|
||||
import { ToolErrorType } from './tool-error.js';
|
||||
import { MEMORY_TOOL_NAME } from './tool-names.js';
|
||||
|
||||
const memoryToolSchemaData: FunctionDeclaration = {
|
||||
name: 'save_memory',
|
||||
name: MEMORY_TOOL_NAME,
|
||||
description:
|
||||
'Saves a specific piece of information or fact to your long-term memory. Use this when the user explicitly asks you to remember something, or when they state a clear, concise fact that seems important to retain for future interactions.',
|
||||
parametersJsonSchema: {
|
||||
@@ -288,10 +289,9 @@ export class MemoryTool
|
||||
extends BaseDeclarativeTool<SaveMemoryParams, ToolResult>
|
||||
implements ModifiableDeclarativeTool<SaveMemoryParams>
|
||||
{
|
||||
static readonly Name: string = memoryToolSchemaData.name!;
|
||||
constructor() {
|
||||
super(
|
||||
MemoryTool.Name,
|
||||
MEMORY_TOOL_NAME,
|
||||
'Save Memory',
|
||||
memoryToolDescription,
|
||||
Kind.Think,
|
||||
|
||||
@@ -815,11 +815,9 @@ export class SmartEditTool
|
||||
extends BaseDeclarativeTool<EditToolParams, ToolResult>
|
||||
implements ModifiableDeclarativeTool<EditToolParams>
|
||||
{
|
||||
static readonly Name = EDIT_TOOL_NAME;
|
||||
|
||||
constructor(private readonly config: Config) {
|
||||
super(
|
||||
SmartEditTool.Name,
|
||||
EDIT_TOOL_NAME,
|
||||
'Edit',
|
||||
`Replaces text within a file. Replaces a single occurrence. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement.
|
||||
|
||||
|
||||
@@ -18,7 +18,5 @@ export const SHELL_TOOL_NAME = 'run_shell_command';
|
||||
export const GREP_TOOL_NAME = 'search_file_content';
|
||||
export const READ_MANY_FILES_TOOL_NAME = 'read_many_files';
|
||||
export const READ_FILE_TOOL_NAME = 'read_file';
|
||||
|
||||
// TODO: Migrate other tool names here to follow this pattern and prevent future circular dependencies.
|
||||
// Candidates for migration:
|
||||
// - LSTool ('list_directory')
|
||||
export const LS_TOOL_NAME = 'list_directory';
|
||||
export const MEMORY_TOOL_NAME = 'save_memory';
|
||||
|
||||
@@ -395,14 +395,12 @@ export class WebFetchTool extends BaseDeclarativeTool<
|
||||
WebFetchToolParams,
|
||||
ToolResult
|
||||
> {
|
||||
static readonly Name: string = WEB_FETCH_TOOL_NAME;
|
||||
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
messageBus?: MessageBus,
|
||||
) {
|
||||
super(
|
||||
WebFetchTool.Name,
|
||||
WEB_FETCH_TOOL_NAME,
|
||||
'WebFetch',
|
||||
"Processes content from URL(s), including local and private network addresses (e.g., localhost), embedded in a prompt. Include up to 20 URLs and instructions (e.g., summarize, extract specific data) directly in the 'prompt' parameter.",
|
||||
Kind.Fetch,
|
||||
|
||||
@@ -185,11 +185,9 @@ export class WebSearchTool extends BaseDeclarativeTool<
|
||||
WebSearchToolParams,
|
||||
WebSearchToolResult
|
||||
> {
|
||||
static readonly Name: string = WEB_SEARCH_TOOL_NAME;
|
||||
|
||||
constructor(private readonly config: Config) {
|
||||
super(
|
||||
WebSearchTool.Name,
|
||||
WEB_SEARCH_TOOL_NAME,
|
||||
'GoogleSearch',
|
||||
'Performs a web search using Google Search (via the Gemini API) and returns the results. This tool is useful for finding information on the internet based on a query.',
|
||||
Kind.Search,
|
||||
|
||||
@@ -319,7 +319,7 @@ class WriteFileToolInvocation extends BaseToolInvocation<
|
||||
logFileOperation(
|
||||
this.config,
|
||||
new FileOperationEvent(
|
||||
WriteFileTool.Name,
|
||||
WRITE_FILE_TOOL_NAME,
|
||||
operation,
|
||||
fileContent.split('\n').length,
|
||||
mimetype,
|
||||
@@ -390,11 +390,9 @@ export class WriteFileTool
|
||||
extends BaseDeclarativeTool<WriteFileToolParams, ToolResult>
|
||||
implements ModifiableDeclarativeTool<WriteFileToolParams>
|
||||
{
|
||||
static readonly Name: string = WRITE_FILE_TOOL_NAME;
|
||||
|
||||
constructor(private readonly config: Config) {
|
||||
super(
|
||||
WriteFileTool.Name,
|
||||
WRITE_FILE_TOOL_NAME,
|
||||
'WriteFile',
|
||||
`Writes content to a specified file in the local filesystem.
|
||||
|
||||
|
||||
@@ -126,11 +126,9 @@ export class WriteTodosTool extends BaseDeclarativeTool<
|
||||
WriteTodosToolParams,
|
||||
ToolResult
|
||||
> {
|
||||
static readonly Name: string = WRITE_TODOS_TOOL_NAME;
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
WriteTodosTool.Name,
|
||||
WRITE_TODOS_TOOL_NAME,
|
||||
'Write Todos',
|
||||
WRITE_TODOS_DESCRIPTION,
|
||||
Kind.Other,
|
||||
|
||||
Reference in New Issue
Block a user