Community translations by veiseule.ai — Help improve them on Crowdin
Skip to main content

công cụ apply_patch

Áp dụng các thay đổi tệp bằng định dạng bản vá có cấu trúc. Điều này lý tưởng cho nhiều tệp or multi-hunk edits where a single edit call would be brittle.

Công cụ chấp nhận một chuỗi input duy nhất, bao bọc một hoặc nhiều thao tác trên tệp:

*** Begin Patch
*** Add File: path/to/file.txt
+line 1
+line 2
*** Update File: src/app.ts
@@
-old line
+new line
*** Delete File: obsolete.txt
*** End Patch

Tham số

  • input (bắt buộc): Toàn bộ nội dung bản vá, bao gồm *** Begin Patch*** End Patch.

Ghi chú

  • Đường dẫn được phân giải tương đối so với thư mục gốc của workspace.
  • Dùng *** Move to: trong một hunk *** Update File: để đổi tên tệp.
  • *** End of File đánh dấu chèn chỉ-EOF khi cần.
  • Experimental and disabled by default. Enable with tools.exec.applyPatch.enabled.
  • OpenAI-only (including OpenAI Codex). Optionally gate by model via tools.exec.applyPatch.allowModels.
  • Cấu hình chỉ nằm dưới tools.exec.

Ví dụ

{
  "tool": "apply_patch",
  "input": "*** Begin Patch\n*** Update File: src/index.ts\n@@\n-const foo = 1\n+const foo = 2\n*** End Patch"
}