Self-Healing Fuzzy Unified Diff & Search/Replace Code Patcher
apply_fuzzy_code_patchApplies unified diffs (@@ ... @@) or SEARCH/REPLACE blocks to source code using sliding-window token similarity to resolve drifted line numbers, align indentation, and verify bracket balance. Use when healing and applying a code edit or diff that failed exact line matching due to line-number drift or whitespace differences; for inspecting function signatures, call trees, and cyclomatic complexity without modifying code, use analyze_ast_symbol_graph instead. Read-only call (32 KB, 60 RPM): accepts 'original_code' (with enum defaults), uses '?demo=true' or L402 (75 sats); HTTP 400 if invalid.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patch | Yes | Unified diff hunk or <<<<<<< SEARCH ... ======= ... >>>>>>> REPLACE block to apply. | |
| fuzz_strategy | No | Line-matching tolerance and indentation behavior; defaults to 'whitespace_normalized_auto_indent' when omitted. | |
| original_code | Yes | Complete original source file content before patching. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hunks_total | Yes | Total patch hunks parsed from the input patch. | |
| patched_code | Yes | Resulting source code after applying all matched hunks. | |
| hunks_applied | Yes | Number of hunks successfully anchored and applied. | |
| syntax_balance_verified | Yes | True when post-patch {}, (), and [] delimiters remain balanced. |