diff options
Diffstat (limited to 'packages/core/src/tools/edit.ts')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index f388b9f5..45e74e93 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -15,6 +15,7 @@ import { ToolResult, ToolResultDisplay, } from './tools.js'; +import { Type } from '@google/genai'; import { SchemaValidator } from '../utils/schemaValidator.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import { isNodeError } from '../utils/errors.js'; @@ -97,27 +98,27 @@ Expectation for required parameters: file_path: { description: "The absolute path to the file to modify. Must start with '/'.", - type: 'string', + type: Type.STRING, }, old_string: { description: 'The exact literal text to replace, preferably unescaped. For single replacements (default), include at least 3 lines of context BEFORE and AFTER the target text, matching whitespace and indentation precisely. For multiple replacements, specify expected_replacements parameter. If this string is not the exact literal text (i.e. you escaped it) or does not match exactly, the tool will fail.', - type: 'string', + type: Type.STRING, }, new_string: { description: 'The exact literal text to replace `old_string` with, preferably unescaped. Provide the EXACT text. Ensure the resulting code is correct and idiomatic.', - type: 'string', + type: Type.STRING, }, expected_replacements: { - type: 'number', + type: Type.NUMBER, description: 'Number of replacements expected. Defaults to 1 if not specified. Use when you want to replace multiple occurrences.', minimum: 1, }, }, required: ['file_path', 'old_string', 'new_string'], - type: 'object', + type: Type.OBJECT, }, ); this.rootDirectory = path.resolve(this.config.getTargetDir()); @@ -146,14 +147,9 @@ Expectation for required parameters: * @returns Error message string or null if valid */ validateToolParams(params: EditToolParams): string | null { - if ( - this.schema.parameters && - !SchemaValidator.validate( - this.schema.parameters as Record<string, unknown>, - params, - ) - ) { - return 'Parameters failed schema validation.'; + const errors = SchemaValidator.validate(this.schema.parameters, params); + if (errors) { + return errors; } if (!path.isAbsolute(params.file_path)) { |
