| 21 | .describe("Array of edit operations to perform sequentially on the file"), |
| 22 | }), |
| 23 | async execute(params, ctx) { |
| 24 | const tool = await EditTool.init() |
| 25 | const results = [] |
| 26 | for (const [, edit] of params.edits.entries()) { |
| 27 | const result = await tool.execute( |
| 28 | { |
| 29 | filePath: params.filePath, |
| 30 | oldString: edit.oldString, |
| 31 | newString: edit.newString, |
| 32 | replaceAll: edit.replaceAll, |
| 33 | }, |
| 34 | ctx, |
| 35 | ) |
| 36 | results.push(result) |
| 37 | } |
| 38 | return { |
| 39 | title: path.relative(Instance.worktree, params.filePath), |
| 40 | metadata: { |
| 41 | results: results.map((r) => r.metadata), |
| 42 | }, |
| 43 | output: results.at(-1)!.output, |
| 44 | } |
| 45 | }, |
| 46 | }) |