Files
moltbot/docs/tools/apply-patch.md
Vincent Koc 1f7d0ef310 docs: typography hygiene + Related CardGroups across 4 pages
docs/concepts/context.md: replaced 12 curly quote and italic-marker
typography characters with ASCII equivalents so grep, copy-paste, and
Mintlify search hit clean tokens. Converted the 4-bullet Related list
into a CardGroup linking context-engine, compaction, system-prompt,
and agent-loop. Verified all four targets exist.

docs/concepts/soul.md: replaced 7 typography characters (curly
apostrophe in 'agent's' and similar) with ASCII equivalents. Renamed
'## Related docs' to '## Related' for consistency with sibling pages
and converted the 3-bullet list into a CardGroup linking
agent-workspace, system-prompt, and the SOUL.md template.

docs/tools/perplexity-search.md: removed the duplicate
'# Perplexity Search API' H1 (Mintlify renders title from frontmatter).
Replaced 2 typography characters and converted the 4-bullet Related
list into a CardGroup; verified web/brave-search/exa-search targets.

docs/tools/apply-patch.md: converted the 3-bullet Related list into a
CardGroup linking diffs, exec, and code-execution.
2026-05-05 18:36:06 -07:00

65 lines
1.9 KiB
Markdown

---
summary: "Apply multi-file patches with the apply_patch tool"
read_when:
- You need structured file edits across multiple files
- You want to document or debug patch-based edits
title: "apply_patch tool"
---
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.
The tool accepts a single `input` string that wraps one or more file operations:
```
*** 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
```
## Parameters
- `input` (required): Full patch contents including `*** Begin Patch` and `*** End Patch`.
## Notes
- Patch paths support relative paths (from the workspace directory) and absolute paths.
- `tools.exec.applyPatch.workspaceOnly` defaults to `true` (workspace-contained). Set it to `false` only if you intentionally want `apply_patch` to write/delete outside the workspace directory.
- Use `*** Move to:` within an `*** Update File:` hunk to rename files.
- `*** End of File` marks an EOF-only insert when needed.
- Available by default for OpenAI and OpenAI Codex models. Set
`tools.exec.applyPatch.enabled: false` to disable it.
- Optionally gate by model via
`tools.exec.applyPatch.allowModels`.
- Config is only under `tools.exec`.
## Example
```json
{
"tool": "apply_patch",
"input": "*** Begin Patch\n*** Update File: src/index.ts\n@@\n-const foo = 1\n+const foo = 2\n*** End Patch"
}
```
## Related
<CardGroup cols={2}>
<Card title="Diffs" href="/tools/diffs" icon="code-compare">
Read-only diff viewer for change presentation.
</Card>
<Card title="Exec tool" href="/tools/exec" icon="terminal">
Shell command execution from the agent.
</Card>
<Card title="Code execution" href="/tools/code-execution" icon="square-code">
Sandboxed remote Python analysis with xAI.
</Card>
</CardGroup>