Apply *chunks* to *original_content* and return the new content.
(
file_path: str,
original_content: str,
chunks: List[UpdateChunk],
)
| 750 | return result |
| 751 | |
| 752 | def apply_update_chunks( |
| 753 | file_path: str, |
| 754 | original_content: str, |
| 755 | chunks: List[UpdateChunk], |
| 756 | ) -> str: |
| 757 | """Apply *chunks* to *original_content* and return the new content.""" |
| 758 | original_lines = original_content.split("\n") |
| 759 | |
| 760 | # Drop trailing empty element for consistent line counting |
| 761 | if original_lines and original_lines[-1] == "": |
| 762 | original_lines.pop() |
| 763 | |
| 764 | replacements = _compute_replacements(original_lines, file_path, chunks) |
| 765 | new_lines = _apply_replacements(original_lines, replacements) |
| 766 | |
| 767 | # Ensure trailing newline |
| 768 | if not new_lines or new_lines[-1] != "": |
| 769 | new_lines.append("") |
| 770 | |
| 771 | return "\n".join(new_lines) |
| 772 | |
| 773 | def _apply_multi_file_patch(patch_text: str, skill_dir: Path) -> None: |
| 774 | """Parse and apply a ``*** Begin Patch`` block to a skill directory. |
no test coverage detected