MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / multiFileEdit

Function multiFileEdit

src/tools/executors/files.ts:198–218  ·  view source on GitHub ↗
(args: Record<string, unknown>, context: ToolContext)

Source from the content-addressed store, hash-verified

196}
197
198export 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}

Callers

nothing calls this directly

Calls 2

resolveWorkspacePathFunction · 0.85
editOneFileFunction · 0.85

Tested by

no test coverage detected