मुख्य सामग्री पर जाएं

apply_patch टूल

Apply file changes using a structured patch format. This is ideal for multi-file or multi-hunk edits where a single edit call would be brittle. यह टूल एक एकल input स्ट्रिंग स्वीकार करता है जो एक या अधिक फ़ाइल ऑपरेशनों को समेटती है:
*** 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

पैरामीटर

  • input (आवश्यक): पूर्ण पैच सामग्री, जिसमें *** Begin Patch और *** End Patch शामिल हैं।

नोट्स

  • पाथ्स को वर्कस्पेस रूट के सापेक्ष रेज़ॉल्व किया जाता है।
  • tools.exec.applyPatch.workspaceOnly डिफ़ॉल्ट रूप से true (workspace-contained) होता है। इसे false केवल तभी सेट करें जब आप जानबूझकर चाहते हों कि apply_patch workspace directory के बाहर लिखे/हटाए।
  • आवश्यकता होने पर *** End of File केवल-EOF इन्सर्ट को चिह्नित करता है।
  • आवश्यकता होने पर *** End of File केवल-EOF इन्सर्ट को चिह्नित करता है।
  • 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.
  • विन्यास केवल tools.exec के अंतर्गत है।

उदाहरण

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