edit_file_block
Apply surgical edits to specific text blocks in files by finding and replacing exact strings, ensuring precision and safety.
Instructions
Apply surgical edits to specific blocks of text in a file. Make Sure you have Called FIRST_STEP_get_instructions first before this tool.
Makes precise changes to files by finding and replacing exact text matches. This is safer than rewriting entire files.
RESTRICTIONS:
Cannot edit outputs.tf files - use write_outputs tool instead
Cannot edit facets.yaml files - use write_config_files tool instead
Best practices:
Include enough context in old_string to make it unique
Use expected_replacements=1 for safety (default)
For multiple replacements, specify the exact count expected
Args: file_path (str): Path to the file to edit (must be within working directory) old_string (str): Exact text to find and replace (include context for uniqueness) new_string (str): Replacement text expected_replacements (int): Expected number of matches (default: 1, prevents unintended changes)
Returns: str: JSON formatted response with success status, message, and optional error details
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| old_string | Yes | ||
| new_string | Yes | ||
| expected_replacements | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |