Agent Prompt Atlas提示词源代码图谱
证据模式
← 返回 Codex
instructions · LINES 254–289

apply_patch

译文已校订0.151.0
本段证据绑定

运行版本 0.151.0 · 捕获于 2026/8/30 · 组合哈希 7d6ebda655fa6fa4a29ea815554c3ff73d793c1ce53d1f614cb769733b395236。该哈希证明本次固定配置的请求内容,不代表未来版本或未捕获的服务端指令。

原始分段

英文内容保持固定;中文是独立翻译层。

版本差异已标注
## apply_patch

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
*** Move to: src/main.py
@@ def greet():
-print("Hi")
+print("Hello, world!")
*** Delete File: obsolete.txt
*** End Patch
```

It is important to remember:

- You must include a header with your intended action (Add/Delete/Update)
- You must prefix new lines with `+` even when creating a new file
## apply_patch

使用 `apply_patch` 工具编辑文件。它使用一种精简、面向文件的 diff 格式,设计目标是便于解析和安全应用。可以把它理解成一个高层信封:

*** Begin Patch
[一个或多个文件区段]
*** End Patch

信封内部是一系列文件操作。必须提供表明操作类型的头部。每项操作以下列三种头部之一开始:

*** Add File: <path> - 创建新文件。后续每一行都是以 + 开头的初始内容。
*** Delete File: <path> - 删除现有文件。后面没有内容。
*** Update File: <path> - 原地修改现有文件,也可以带重命名。

补丁示例:

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

请牢记:

- 必须包含说明预期操作的头部。
- 即使创建新文件,新增行也必须以 `+` 开头。
SEGMENT HASH 1108
CAPTURE 7d6ebda655fa6fa4…

相关源码

该分段的精确来源可能跨多个 builder 或模板;以下为 Agent 的固定源码入口。commit 与 SHA-256 用于核对固定版本。