From d3fda9dafb3921c9edd5cf4fc166dedecd91d84f Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Wed, 13 Aug 2025 12:58:26 -0300 Subject: Zed integration schema upgrade (#5536) Co-authored-by: Conrad Irwin Co-authored-by: Ben Brandt --- packages/core/src/config/config.ts | 11 +++++---- packages/core/src/core/coreToolScheduler.test.ts | 4 ++-- packages/core/src/test-utils/tools.ts | 4 ++-- packages/core/src/tools/edit.ts | 4 ++-- packages/core/src/tools/glob.ts | 4 ++-- packages/core/src/tools/grep.ts | 4 ++-- packages/core/src/tools/ls.ts | 4 ++-- packages/core/src/tools/mcp-tool.ts | 4 ++-- packages/core/src/tools/memoryTool.ts | 4 ++-- packages/core/src/tools/read-file.ts | 4 ++-- packages/core/src/tools/read-many-files.ts | 4 ++-- packages/core/src/tools/shell.ts | 4 ++-- packages/core/src/tools/tool-registry.ts | 4 ++-- packages/core/src/tools/tools.ts | 29 ++++++++++++------------ packages/core/src/tools/web-fetch.ts | 4 ++-- packages/core/src/tools/web-search.ts | 4 ++-- packages/core/src/tools/write-file.ts | 9 ++++++-- 17 files changed, 56 insertions(+), 49 deletions(-) (limited to 'packages/core/src') diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 9231f427..069a486d 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -185,7 +185,7 @@ export interface ConfigParameters { model: string; extensionContextFilePaths?: string[]; maxSessionTurns?: number; - experimentalAcp?: boolean; + experimentalZedIntegration?: boolean; listExtensions?: boolean; extensions?: GeminiCLIExtension[]; blockedMcpServers?: Array<{ name: string; extensionName: string }>; @@ -256,7 +256,7 @@ export class Config { private readonly summarizeToolOutput: | Record | undefined; - private readonly experimentalAcp: boolean = false; + private readonly experimentalZedIntegration: boolean = false; private readonly loadMemoryFromIncludeDirectories: boolean = false; private readonly chatCompression: ChatCompressionSettings | undefined; private readonly interactive: boolean; @@ -309,7 +309,8 @@ export class Config { this.model = params.model; this.extensionContextFilePaths = params.extensionContextFilePaths ?? []; this.maxSessionTurns = params.maxSessionTurns ?? -1; - this.experimentalAcp = params.experimentalAcp ?? false; + this.experimentalZedIntegration = + params.experimentalZedIntegration ?? false; this.listExtensions = params.listExtensions ?? false; this._extensions = params.extensions ?? []; this._blockedMcpServers = params.blockedMcpServers ?? []; @@ -621,8 +622,8 @@ export class Config { return this.extensionContextFilePaths; } - getExperimentalAcp(): boolean { - return this.experimentalAcp; + getExperimentalZedIntegration(): boolean { + return this.experimentalZedIntegration; } getListExtensions(): boolean { diff --git a/packages/core/src/core/coreToolScheduler.test.ts b/packages/core/src/core/coreToolScheduler.test.ts index a3a25707..df39c1dc 100644 --- a/packages/core/src/core/coreToolScheduler.test.ts +++ b/packages/core/src/core/coreToolScheduler.test.ts @@ -19,7 +19,7 @@ import { ToolConfirmationPayload, ToolResult, Config, - Icon, + Kind, ApprovalMode, } from '../index.js'; import { Part, PartListUnion } from '@google/genai'; @@ -389,7 +389,7 @@ describe('CoreToolScheduler edit cancellation', () => { 'mockEditTool', 'mockEditTool', 'A mock edit tool', - Icon.Pencil, + Kind.Edit, {}, ); } diff --git a/packages/core/src/test-utils/tools.ts b/packages/core/src/test-utils/tools.ts index b168db9c..7d917b6c 100644 --- a/packages/core/src/test-utils/tools.ts +++ b/packages/core/src/test-utils/tools.ts @@ -7,9 +7,9 @@ import { vi } from 'vitest'; import { BaseTool, - Icon, ToolCallConfirmationDetails, ToolResult, + Kind, } from '../tools/tools.js'; import { Schema, Type } from '@google/genai'; @@ -29,7 +29,7 @@ export class MockTool extends BaseTool<{ [key: string]: unknown }, ToolResult> { properties: { param: { type: Type.STRING } }, }, ) { - super(name, displayName ?? name, description, Icon.Hammer, params); + super(name, displayName ?? name, description, Kind.Other, params); } async execute( diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index e2b517cf..733c1bf8 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -9,7 +9,7 @@ import * as path from 'path'; import * as Diff from 'diff'; import { BaseDeclarativeTool, - Icon, + Kind, ToolCallConfirmationDetails, ToolConfirmationOutcome, ToolEditConfirmationDetails, @@ -435,7 +435,7 @@ Expectation for required parameters: 4. NEVER escape \`old_string\` or \`new_string\`, that would break the exact literal text requirement. **Important:** If ANY of the above are not satisfied, the tool will fail. CRITICAL for \`old_string\`: Must uniquely identify the single instance to change. Include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. If this string matches multiple locations, or does not match exactly, the tool will fail. **Multiple replacements:** Set \`expected_replacements\` to the number of occurrences you want to replace. The tool will replace ALL occurrences that match \`old_string\` exactly. Ensure the number of replacements matches your expectation.`, - Icon.Pencil, + Kind.Edit, { properties: { file_path: { diff --git a/packages/core/src/tools/glob.ts b/packages/core/src/tools/glob.ts index eaedc20f..77a7241f 100644 --- a/packages/core/src/tools/glob.ts +++ b/packages/core/src/tools/glob.ts @@ -11,7 +11,7 @@ import { SchemaValidator } from '../utils/schemaValidator.js'; import { BaseDeclarativeTool, BaseToolInvocation, - Icon, + Kind, ToolInvocation, ToolResult, } from './tools.js'; @@ -248,7 +248,7 @@ export class GlobTool extends BaseDeclarativeTool { GlobTool.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.', - Icon.FileSearch, + Kind.Search, { properties: { pattern: { diff --git a/packages/core/src/tools/grep.ts b/packages/core/src/tools/grep.ts index f8ecdc9c..9d3d638a 100644 --- a/packages/core/src/tools/grep.ts +++ b/packages/core/src/tools/grep.ts @@ -13,7 +13,7 @@ import { globStream } from 'glob'; import { BaseDeclarativeTool, BaseToolInvocation, - Icon, + Kind, ToolInvocation, ToolResult, } from './tools.js'; @@ -543,7 +543,7 @@ export class GrepTool extends BaseDeclarativeTool { 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.', - Icon.Regex, + Kind.Search, { properties: { pattern: { diff --git a/packages/core/src/tools/ls.ts b/packages/core/src/tools/ls.ts index 79820246..7a4445a5 100644 --- a/packages/core/src/tools/ls.ts +++ b/packages/core/src/tools/ls.ts @@ -6,7 +6,7 @@ import fs from 'fs'; import path from 'path'; -import { BaseTool, Icon, ToolResult } from './tools.js'; +import { BaseTool, Kind, ToolResult } from './tools.js'; import { SchemaValidator } from '../utils/schemaValidator.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import { Config, DEFAULT_FILE_FILTERING_OPTIONS } from '../config/config.js'; @@ -75,7 +75,7 @@ export class LSTool extends BaseTool { LSTool.Name, 'ReadFolder', 'Lists the names of files and subdirectories directly within a specified directory path. Can optionally ignore entries matching provided glob patterns.', - Icon.Folder, + Kind.Search, { properties: { path: { diff --git a/packages/core/src/tools/mcp-tool.ts b/packages/core/src/tools/mcp-tool.ts index 4b9a9818..59f83db3 100644 --- a/packages/core/src/tools/mcp-tool.ts +++ b/packages/core/src/tools/mcp-tool.ts @@ -10,7 +10,7 @@ import { ToolCallConfirmationDetails, ToolConfirmationOutcome, ToolMcpConfirmationDetails, - Icon, + Kind, } from './tools.js'; import { CallableTool, Part, FunctionCall } from '@google/genai'; @@ -67,7 +67,7 @@ export class DiscoveredMCPTool extends BaseTool { nameOverride ?? generateValidName(serverToolName), `${serverToolName} (${serverName} MCP Server)`, description, - Icon.Hammer, + Kind.Other, parameterSchema, true, // isOutputMarkdown false, // canUpdateOutput diff --git a/packages/core/src/tools/memoryTool.ts b/packages/core/src/tools/memoryTool.ts index f0c95b6a..c8e88c97 100644 --- a/packages/core/src/tools/memoryTool.ts +++ b/packages/core/src/tools/memoryTool.ts @@ -6,10 +6,10 @@ import { BaseTool, + Kind, ToolResult, ToolEditConfirmationDetails, ToolConfirmationOutcome, - Icon, } from './tools.js'; import { FunctionDeclaration } from '@google/genai'; import * as fs from 'fs/promises'; @@ -122,7 +122,7 @@ export class MemoryTool MemoryTool.Name, 'Save Memory', memoryToolDescription, - Icon.LightBulb, + Kind.Think, memoryToolSchemaData.parametersJsonSchema as Record, ); } diff --git a/packages/core/src/tools/read-file.ts b/packages/core/src/tools/read-file.ts index 0c040b66..d10c73d1 100644 --- a/packages/core/src/tools/read-file.ts +++ b/packages/core/src/tools/read-file.ts @@ -10,7 +10,7 @@ import { makeRelative, shortenPath } from '../utils/paths.js'; import { BaseDeclarativeTool, BaseToolInvocation, - Icon, + Kind, ToolInvocation, ToolLocation, ToolResult, @@ -173,7 +173,7 @@ export class ReadFileTool extends BaseDeclarativeTool< ReadFileTool.Name, 'ReadFile', `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges.`, - Icon.FileSearch, + Kind.Read, { properties: { absolute_path: { diff --git a/packages/core/src/tools/read-many-files.ts b/packages/core/src/tools/read-many-files.ts index 1c92b4f3..5a0799bb 100644 --- a/packages/core/src/tools/read-many-files.ts +++ b/packages/core/src/tools/read-many-files.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { BaseTool, Icon, ToolResult } from './tools.js'; +import { BaseTool, Kind, ToolResult } from './tools.js'; import { SchemaValidator } from '../utils/schemaValidator.js'; import { getErrorMessage } from '../utils/errors.js'; import * as path from 'path'; @@ -229,7 +229,7 @@ This tool is useful when you need to understand or analyze a collection of files - When the user asks to "read all files in X directory" or "show me the content of all Y files". Use this tool when the user's query implies needing the content of several files simultaneously for context, analysis, or summarization. For text files, it uses default UTF-8 encoding and a '--- {filePath} ---' separator between file contents. Ensure paths are relative to the target directory. Glob patterns like 'src/**/*.js' are supported. Avoid using for single files if a more specific single-file reading tool is available, unless the user specifically requests to process a list containing just one file via this tool. Other binary files (not explicitly requested as image/PDF) are generally skipped. Default excludes apply to common non-text files (except for explicitly requested images/PDFs) and large dependency directories unless 'useDefaultExcludes' is false.`, - Icon.FileSearch, + Kind.Read, parameterSchema, ); } diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts index de9b7c2f..4fa08297 100644 --- a/packages/core/src/tools/shell.ts +++ b/packages/core/src/tools/shell.ts @@ -15,7 +15,7 @@ import { ToolCallConfirmationDetails, ToolExecuteConfirmationDetails, ToolConfirmationOutcome, - Icon, + Kind, } from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { SchemaValidator } from '../utils/schemaValidator.js'; @@ -61,7 +61,7 @@ export class ShellTool extends BaseTool { Signal: Signal number or \`(none)\` if no signal was received. Background PIDs: List of background processes started or \`(none)\`. Process Group PGID: Process group started or \`(none)\``, - Icon.Terminal, + Kind.Execute, { type: 'object', properties: { diff --git a/packages/core/src/tools/tool-registry.ts b/packages/core/src/tools/tool-registry.ts index 17d324b3..02f77727 100644 --- a/packages/core/src/tools/tool-registry.ts +++ b/packages/core/src/tools/tool-registry.ts @@ -5,7 +5,7 @@ */ import { FunctionDeclaration } from '@google/genai'; -import { AnyDeclarativeTool, Icon, ToolResult, BaseTool } from './tools.js'; +import { AnyDeclarativeTool, Kind, ToolResult, BaseTool } from './tools.js'; import { Config } from '../config/config.js'; import { spawn } from 'node:child_process'; import { StringDecoder } from 'node:string_decoder'; @@ -44,7 +44,7 @@ Signal: Signal number or \`(none)\` if no signal was received. name, name, description, - Icon.Hammer, + Kind.Other, parameterSchema, false, // isOutputMarkdown false, // canUpdateOutput diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts index 4b13174c..3e7d0647 100644 --- a/packages/core/src/tools/tools.ts +++ b/packages/core/src/tools/tools.ts @@ -145,9 +145,9 @@ export interface ToolBuilder< description: string; /** - * The icon to display when interacting via ACP. + * The kind of tool for categorization and permissions */ - icon: Icon; + kind: Kind; /** * Function declaration schema from @google/genai. @@ -185,7 +185,7 @@ export abstract class DeclarativeTool< readonly name: string, readonly displayName: string, readonly description: string, - readonly icon: Icon, + readonly kind: Kind, readonly parameterSchema: unknown, readonly isOutputMarkdown: boolean = true, readonly canUpdateOutput: boolean = false, @@ -287,7 +287,7 @@ export abstract class BaseTool< readonly name: string, readonly displayName: string, readonly description: string, - readonly icon: Icon, + readonly kind: Kind, readonly parameterSchema: unknown, readonly isOutputMarkdown: boolean = true, readonly canUpdateOutput: boolean = false, @@ -296,7 +296,7 @@ export abstract class BaseTool< name, displayName, description, - icon, + kind, parameterSchema, isOutputMarkdown, canUpdateOutput, @@ -570,15 +570,16 @@ export enum ToolConfirmationOutcome { Cancel = 'cancel', } -export enum Icon { - FileSearch = 'fileSearch', - Folder = 'folder', - Globe = 'globe', - Hammer = 'hammer', - LightBulb = 'lightBulb', - Pencil = 'pencil', - Regex = 'regex', - Terminal = 'terminal', +export enum Kind { + Read = 'read', + Edit = 'edit', + Delete = 'delete', + Move = 'move', + Search = 'search', + Execute = 'execute', + Think = 'think', + Fetch = 'fetch', + Other = 'other', } export interface ToolLocation { diff --git a/packages/core/src/tools/web-fetch.ts b/packages/core/src/tools/web-fetch.ts index 6733c38d..bf8d1968 100644 --- a/packages/core/src/tools/web-fetch.ts +++ b/packages/core/src/tools/web-fetch.ts @@ -10,7 +10,7 @@ import { ToolResult, ToolCallConfirmationDetails, ToolConfirmationOutcome, - Icon, + Kind, } from './tools.js'; import { getErrorMessage } from '../utils/errors.js'; import { Config, ApprovalMode } from '../config/config.js'; @@ -70,7 +70,7 @@ export class WebFetchTool extends BaseTool { WebFetchTool.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.", - Icon.Globe, + Kind.Fetch, { properties: { prompt: { diff --git a/packages/core/src/tools/web-search.ts b/packages/core/src/tools/web-search.ts index 8fe29967..54679452 100644 --- a/packages/core/src/tools/web-search.ts +++ b/packages/core/src/tools/web-search.ts @@ -5,7 +5,7 @@ */ import { GroundingMetadata } from '@google/genai'; -import { BaseTool, Icon, ToolResult } from './tools.js'; +import { BaseTool, Kind, ToolResult } from './tools.js'; import { Type } from '@google/genai'; import { SchemaValidator } from '../utils/schemaValidator.js'; @@ -69,7 +69,7 @@ export class WebSearchTool extends BaseTool< WebSearchTool.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.', - Icon.Globe, + Kind.Search, { type: Type.OBJECT, properties: { diff --git a/packages/core/src/tools/write-file.ts b/packages/core/src/tools/write-file.ts index 72aeba6d..fa1e1301 100644 --- a/packages/core/src/tools/write-file.ts +++ b/packages/core/src/tools/write-file.ts @@ -15,7 +15,8 @@ import { ToolEditConfirmationDetails, ToolConfirmationOutcome, ToolCallConfirmationDetails, - Icon, + Kind, + ToolLocation, } from './tools.js'; import { ToolErrorType } from './tool-error.js'; import { SchemaValidator } from '../utils/schemaValidator.js'; @@ -82,7 +83,7 @@ export class WriteFileTool `Writes content to a specified file in the local filesystem. The user has the ability to modify \`content\`. If modified, this will be stated in the response.`, - Icon.Pencil, + Kind.Edit, { properties: { file_path: { @@ -101,6 +102,10 @@ export class WriteFileTool ); } + toolLocations(params: WriteFileToolParams): ToolLocation[] { + return [{ path: params.file_path }]; + } + validateToolParams(params: WriteFileToolParams): string | null { const errors = SchemaValidator.validate( this.schema.parametersJsonSchema, -- cgit v1.2.3