| 1 | import { Tool } from "../.."; |
| 2 | import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; |
| 3 | |
| 4 | export interface EditToolArgs { |
| 5 | filepath: string; |
| 6 | changes: string; |
| 7 | } |
| 8 | |
| 9 | export const editFileTool: Tool = { |
| 10 | type: "function", |
| 11 | displayTitle: "Edit File", |
| 12 | wouldLikeTo: "edit {{{ filepath }}}", |
| 13 | isCurrently: "editing {{{ filepath }}}", |
| 14 | hasAlready: "edited {{{ filepath }}}", |
| 15 | group: BUILT_IN_GROUP_NAME, |
| 16 | readonly: false, |
| 17 | function: { |
| 18 | name: BuiltInToolNames.EditExistingFile, |
| 19 | description: |
| 20 | "Use this tool to edit an existing file. If you don't know the contents of the file, read it first.", |
| 21 | parameters: { |
| 22 | type: "object", |
| 23 | required: ["filepath", "changes"], |
| 24 | properties: { |
| 25 | filepath: { |
| 26 | type: "string", |
| 27 | description: |
| 28 | "The path of the file to edit, relative to the root of the workspace.", |
| 29 | }, |
| 30 | changes: { |
| 31 | type: "string", |
| 32 | description: |
| 33 | "Any modifications to the file, showing only needed changes. Do NOT wrap this in a codeblock or write anything besides the code changes. In larger files, use brief language-appropriate placeholders for large unmodified sections, e.g. '// ... existing code ...'", |
| 34 | }, |
| 35 | }, |
| 36 | }, |
| 37 | }, |
| 38 | }; |