Skip to content

Commit 79e3c6b

Browse files
committed
🤖 fix: reuse file path schema for edit tools
Generated with
1 parent eba1f76 commit 79e3c6b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/utils/tools/toolDefinitions.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import { TOOL_EDIT_WARNING } from "@/types/tools";
1717

1818
import { zodToJsonSchema } from "zod-to-json-schema";
1919

20+
const FILE_EDIT_FILE_PATH = z
21+
.string()
22+
.describe("Path to the file to edit (absolute or relative to the current workspace)");
23+
2024
interface ToolSchema {
2125
name: string;
2226
description: string;
@@ -73,7 +77,7 @@ export const TOOL_DEFINITIONS = {
7377
"⚠️ CRITICAL: Always check tool results - edits WILL fail if old_string is not found or unique. Do not proceed with dependent operations (commits, pushes, builds) until confirming success.\n\n" +
7478
"Apply one or more edits to a file by replacing exact text matches. All edits are applied sequentially. Each old_string must be unique in the file unless replace_count > 1 or replace_count is -1.",
7579
schema: z.object({
76-
file_path: z.string().describe("The absolute path to the file to edit"),
80+
file_path: FILE_EDIT_FILE_PATH,
7781
old_string: z
7882
.string()
7983
.describe(
@@ -94,7 +98,7 @@ export const TOOL_DEFINITIONS = {
9498
"⚠️ CRITICAL: Always check tool results - edits WILL fail if line numbers are invalid or file content has changed. Do not proceed with dependent operations (commits, pushes, builds) until confirming success.\n\n" +
9599
"Replace a range of lines in a file. Use this for line-based edits when you know the exact line numbers to modify.",
96100
schema: z.object({
97-
file_path: z.string().describe("The absolute path to the file to edit"),
101+
file_path: FILE_EDIT_FILE_PATH,
98102
start_line: z.number().int().min(1).describe("1-indexed start line (inclusive) to replace"),
99103
end_line: z.number().int().min(1).describe("1-indexed end line (inclusive) to replace"),
100104
new_lines: z
@@ -115,7 +119,7 @@ export const TOOL_DEFINITIONS = {
115119
`Optional before/after substrings must uniquely match surrounding content. ${TOOL_EDIT_WARNING}`,
116120
schema: z
117121
.object({
118-
file_path: z.string().describe("The absolute path to the file to edit"),
122+
file_path: FILE_EDIT_FILE_PATH,
119123
content: z.string().describe("The content to insert"),
120124
before: z
121125
.string()

0 commit comments

Comments
 (0)