| 1 | import { Tool } from "../.."; |
| 2 | import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; |
| 3 | |
| 4 | export const readFileTool: Tool = { |
| 5 | type: "function", |
| 6 | displayTitle: "Read File", |
| 7 | wouldLikeTo: "read {{{ filepath }}}", |
| 8 | isCurrently: "reading {{{ filepath }}}", |
| 9 | hasAlready: "read {{{ filepath }}}", |
| 10 | readonly: true, |
| 11 | isInstant: true, |
| 12 | group: BUILT_IN_GROUP_NAME, |
| 13 | function: { |
| 14 | name: BuiltInToolNames.ReadFile, |
| 15 | description: |
| 16 | "Use this tool if you need to view the contents of an existing file.", |
| 17 | parameters: { |
| 18 | type: "object", |
| 19 | required: ["filepath"], |
| 20 | properties: { |
| 21 | filepath: { |
| 22 | type: "string", |
| 23 | description: |
| 24 | "The path of the file to read, relative to the root of the workspace (NOT uri or absolute path)", |
| 25 | }, |
| 26 | }, |
| 27 | }, |
| 28 | }, |
| 29 | systemMessageDescription: { |
| 30 | prefix: `To read a file with a known filepath, use the ${BuiltInToolNames.ReadFile} tool. For example, to read a file located at 'path/to/file.txt', you would respond with this:`, |
| 31 | exampleArgs: [["filepath", "path/to/the_file.txt"]], |
| 32 | }, |
| 33 | defaultToolPolicy: "allowedWithoutPermission", |
| 34 | toolCallIcon: "DocumentIcon", |
| 35 | }; |