FeaturesTools
apply_diff
Perform surgical, high-precision code modifications using targeted search-and-replace blocks.
apply_diff
The apply_diff utility executes granular modifications to your files by targeting specific segments of code. This approach is engineered for maximum stability, particularly when working with extensive or complex source files.
Parameters
path(required): The relative link to the file being modified.diff(required): The specific search/replace instruction. Line number references are essential for ensuring the modification is applied at the exact intended location.
Operational Workflow
Sypha utilizes a "Search/Replace Block" methodology. The AI identifies a specific section of code to match (verified via line numbers) and designates the corresponding replacement code.
<<<<<<< SEARCH
:start_line:12
:end_line:14
-------
const isActive = false;
=======
const isActive = true;
>>>>>>> REPLACEKey Attributes
- Resilient Matching: If neighboring edits cause the code to shift slightly, Sypha utilizes intelligent pattern mapping to locate the correct block.
- Style Alignment: The tool automatically detects and mirrors the existing indentation patterns within your file.
- Safety Review: All proposed changes are visualized in a diff interface for your approval before any physical file modifications occur.
Primary Use Cases
- Executing precise refactors of individual methods or classes.
- Resolving isolated bugs with zero impact on surrounding logic.
- Implementing feature updates that require minor adjustments across multiple project files.
[!TIP] Prioritize
apply_difffor targeted modifications. For initializing brand new files or replacing massive segments of an existing asset (90%+), thewrite_to_filetool is generally more efficient.