multiedit.txt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. This is a tool for making multiple edits to a single file in one operation. It is built on top of the Edit tool and allows you to perform multiple find-and-replace operations efficiently. Prefer this tool over the Edit tool when you need to make multiple edits to the same file.
  2. Before using this tool:
  3. 1. Use the Read tool to understand the file's contents and context
  4. 2. Verify the directory path is correct
  5. To make multiple file edits, provide the following:
  6. 1. file_path: The absolute path to the file to modify (must be absolute, not relative)
  7. 2. edits: An array of edit operations to perform, where each edit contains:
  8. - oldString: The text to replace (must match the file contents exactly, including all whitespace and indentation)
  9. - newString: The edited text to replace the oldString
  10. - replaceAll: Replace all occurrences of oldString. This parameter is optional and defaults to false.
  11. IMPORTANT:
  12. - All edits are applied in sequence, in the order they are provided
  13. - Each edit operates on the result of the previous edit
  14. - All edits must be valid for the operation to succeed - if any edit fails, none will be applied
  15. - This tool is ideal when you need to make several changes to different parts of the same file
  16. CRITICAL REQUIREMENTS:
  17. 1. All edits follow the same requirements as the single Edit tool
  18. 2. The edits are atomic - either all succeed or none are applied
  19. 3. Plan your edits carefully to avoid conflicts between sequential operations
  20. WARNING:
  21. - The tool will fail if edits.oldString doesn't match the file contents exactly (including whitespace)
  22. - The tool will fail if edits.oldString and edits.newString are the same
  23. - Since edits are applied in sequence, ensure that earlier edits don't affect the text that later edits are trying to find
  24. When making edits:
  25. - Ensure all edits result in idiomatic, correct code
  26. - Do not leave the code in a broken state
  27. - Always use absolute file paths (starting with /)
  28. - Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
  29. - Use replaceAll for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.
  30. If you want to create a new file, use:
  31. - A new file path, including dir name if needed
  32. - First edit: empty oldString and the new file's contents as newString
  33. - Subsequent edits: normal edit operations on the created content