← 返回 Codex版本差异已标注
instructions · LINES 254–289
apply_patch
本段证据绑定
运行版本 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
```
请牢记:
- 必须包含说明预期操作的头部。
- 即使创建新文件,新增行也必须以 `+` 开头。
相关源码
该分段的精确来源可能跨多个 builder 或模板;以下为 Agent 的固定源码入口。commit 与 SHA-256 用于核对固定版本。
SRCgpt-5.2-codex_prompt.mdcodex-rs/core/gpt-5.2-codex_prompt.md
SOURCE
SRCgpt-5.2-codex_instructions_template.mdcodex-rs/core/templates/model_instructions/gpt-5.2-codex_instructions_template.md88f776588f SOURCE
SRCbase_instructions.rscodex-rs/core/src/context/base_instructions.rs88f776588f SOURCE
SRCpermissions_instructions.rscodex-rs/core/src/context/permissions_instructions.rs88f776588f SOURCE
SRCdeveloper_instructions.rscodex-rs/core/src/context/developer_instructions.rs88f776588f SOURCE
SRCuser_instructions.rscodex-rs/core/src/context/user_instructions.rs88f776588f SOURCE
SRCmulti_agent_mode_instructions.rscodex-rs/core/src/context/multi_agent_mode_instructions.rs88f776588f SOURCE
SRCCodex 0.151.0 GPT-5.2 base promptcodex-rs/core/gpt_5_2_prompt.md88f776588f SOURCE
78c290807c