(args: Record<string, unknown>, context: ToolContext)
| 196 | } |
| 197 | |
| 198 | export async function multiFileEdit(args: Record<string, unknown>, context: ToolContext): Promise<ToolResult> { |
| 199 | const edits = (Array.isArray(args.edits) ? args.edits : []) as EditSpec[] |
| 200 | if (edits.length === 0) { |
| 201 | return { text: "FAILED: edits array is empty", isError: true } |
| 202 | } |
| 203 | |
| 204 | // Group edits by file, preserving order within each file. |
| 205 | const byFile = new Map<string, EditSpec[]>() |
| 206 | for (const edit of edits) { |
| 207 | const key = resolveWorkspacePath(context.cwd, edit.file_path) |
| 208 | if (!byFile.has(key)) byFile.set(key, []) |
| 209 | byFile.get(key)!.push(edit) |
| 210 | } |
| 211 | |
| 212 | const results: string[] = [] |
| 213 | for (const fileEdits of byFile.values()) { |
| 214 | results.push(...editOneFile(context.cwd, fileEdits)) |
| 215 | } |
| 216 | const anyFailed = results.some((r) => r.startsWith("FAILED")) |
| 217 | return { text: results.join("\n"), isError: anyFailed && results.every((r) => r.startsWith("FAILED")) } |
| 218 | } |
nothing calls this directly
no test coverage detected