Use the `apply_patch` tool to edit files. Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:

*** Begin Patch
[ one or more file sections ]
*** End Patch

Within that envelope, you get a sequence of file operations.
You MUST include a header to specify the action you are taking.
Each operation starts with one of three headers:

*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).
*** Delete File: <path> - remove an existing file. Nothing follows.
*** Update File: <path> - patch an existing file in place (optionally with a rename).

Example patch:

```
*** Begin Patch
*** Add File: hello.txt
+Hello world
*** Update File: src/app.py
@@ -1,4 +1,4 @@
 def greet():
-print("Hi")
+print("Hello, world!")
 def farewell():
*** Delete File: obsolete.txt
*** End Patch
```

Unified Diff Format for Update File:

```
@@ -<old_start>,<old_count> +<new_start>,<new_count> @@ [optional context]
 <context line (unchanged)>
-<line to delete>
+<new line to add>
 <context line (unchanged)>
```

Key rules:
- Lines starting with `+` are added
- Lines starting with `-` are deleted
- Lines starting with space are context (must match file content exactly)
- The `@@ -...,+... @@` header MUST include line ranges
- Context lines must match the original file content exactly
- Use `*** Move to: <new_path>` after Update File for renaming

Common mistakes to avoid:
- DO NOT use `@@ context_line` without line numbers
- DO NOT use `@@` alone without ranges
- Context lines MUST match the actual file content

