Skip to content

[FEATURE] Add MultiEdit Tool #60

@edenreich

Description

@edenreich

Summary

Introduce MultiEdit, a batch editing tool built on top of Edit to perform multiple exact find-and-replace operations on a single file in one atomic action. Prefer MultiEdit over Edit when changing several parts of the same file.

Why

Reduces round trips and risk of partial edits; guarantees all-or-nothing changes when multiple replacements are needed.

Spec (condensed)

  • name: MultiEdit

  • input:

    • file_path (string, absolute)
    • edits (array, min 1) of objects:
      • old_string (string, exact match incl. whitespace)
      • new_string (string)
      • replace_all (boolean, default false)
  • Preconditions: Must use Read first; verify directory path.

  • Behavior:

    • Apply edits in order, each on the result of previous.
    • Atomic: if any edit fails, none are applied.
    • Same requirements as Edit.
  • Warnings / Failures:

    • Fail if old_string doesn’t match exactly.
    • Fail if old_string == new_string.
    • Earlier edits may affect later matches—caller must plan accordingly.
  • Guidelines:

    • Keep code idiomatic and unbroken.
    • Always use absolute paths.
    • Use replace_all for broad renames.
    • No emojis unless explicitly requested.
    • To create a new file: supply a new absolute path; first edit uses empty old_string and full file content in new_string.

Acceptance Criteria

  • CLI exposes MultiEdit adhering to the above spec.
  • Edits execute sequentially and transactionally (all-or-nothing).
  • Proper error messages for mismatches, identical old/new strings, and partial-failure scenarios.
  • Verified workflow: ReadMultiEdit on existing file and on new-file creation path.
  • Tests cover ordered edits, replace_all, rollback on failure, and .ipynb guard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions