apply_patch.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. 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:
  2. *** Begin Patch
  3. [ one or more file sections ]
  4. *** End Patch
  5. Within that envelope, you get a sequence of file operations.
  6. You MUST include a header to specify the action you are taking.
  7. Each operation starts with one of three headers:
  8. *** Add File: <path> - create a new file. Every following line is a + line (the initial contents).
  9. *** Delete File: <path> - remove an existing file. Nothing follows.
  10. *** Update File: <path> - patch an existing file in place (optionally with a rename).
  11. Example patch:
  12. ```
  13. *** Begin Patch
  14. *** Add File: hello.txt
  15. +Hello world
  16. *** Update File: src/app.py
  17. *** Move to: src/main.py
  18. @@ def greet():
  19. -print("Hi")
  20. +print("Hello, world!")
  21. *** Delete File: obsolete.txt
  22. *** End Patch
  23. ```
  24. It is important to remember:
  25. - You must include a header with your intended action (Add/Delete/Update)
  26. - You must prefix new lines with `+` even when creating a new file