Zed integration schema upgrade (#5536)

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Ben Brandt <benjamin@zed.dev>
This commit is contained in:
Agus Zubiaga
2025-08-13 12:58:26 -03:00
committed by GitHub
parent 150103e5dd
commit d3fda9dafb
24 changed files with 1293 additions and 754 deletions

View File

@@ -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: {

View File

@@ -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<GlobToolParams, ToolResult> {
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: {

View File

@@ -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<GrepToolParams, ToolResult> {
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: {

View File

@@ -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<LSToolParams, ToolResult> {
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: {

View File

@@ -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<ToolParams, ToolResult> {
nameOverride ?? generateValidName(serverToolName),
`${serverToolName} (${serverName} MCP Server)`,
description,
Icon.Hammer,
Kind.Other,
parameterSchema,
true, // isOutputMarkdown
false, // canUpdateOutput

View File

@@ -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<string, unknown>,
);
}

View File

@@ -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: {

View File

@@ -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,
);
}

View File

@@ -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<ShellToolParams, ToolResult> {
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: {

View File

@@ -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

View File

@@ -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 {

View File

@@ -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<WebFetchToolParams, ToolResult> {
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: {

View File

@@ -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: {

View File

@@ -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,