patch_file
Use patch_file for a small known text replacement in one file
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
project_name | Annotated[str, Field(description='Name of the Bridge Town project.')] | Yes | — | |
path | Annotated[str, Field(description='Project-relative path of the UTF-8 text file to patch.')] | Yes | — | |
find_text | Annotated[str, Field(description='Exact substring to find in the file. Must appear exactly as many times as expected_occurrences (default 1).')] | Yes | — | |
replace_text | Annotated[str, Field(description='Text to replace each occurrence of find_text with.')] | Yes | — | |
expected_occurrences | Annotated[int, Field(description='Expected number of times find_text appears. Defaults to 1. Use to guard against partial matches in files with repeated content.')] | No | 1 | |
commit_message | Annotated[str, Field(description='Git commit message. If omitted, the server generates a default message.')] | No | '' | |
branch | `Annotated[str | None, Field(description=“Branch to operate on. Defaults to the project’s default branch when omitted or null.”)]` | No | None |
expected_sha | Annotated[str, Field(description='Expected blob SHA-1 (40 hex chars) for optimistic concurrency control. If the file has been modified since you last read it, the call fails with a conflict error. Read the file first to get its current sha.')] | No | '' |
Returns
Section titled “Returns”Returns a structured object. Top-level fields:
path(string)project(string)commit_sha(string)replacements_applied(integer)
See the response example below for the full payload shape.
Example
Section titled “Example”Tool Call
Section titled “Tool Call”{ "name": "patch_file", "arguments": { "project_name": "forecasts", "path": "model/revenue.py", "find_text": "growth_rate = 0.10", "replace_text": "growth_rate = 0.15", "expected_occurrences": 1, "commit_message": "tweak: bump growth assumption" }}Response
Section titled “Response”{ "path": "model/revenue.py", "project": "forecasts", "commit_sha": "abc1234def5678901234567890abcdef12345678", "replacements_applied": 1}- Module:
Models - Requires authentication via API token or Auth0 JWT.