Skip to content

patch_file

Use patch_file for a small known text replacement in one file

NameTypeRequiredDefaultDescription
project_nameAnnotated[str, Field(description='Name of the Bridge Town project.')]Yes
pathAnnotated[str, Field(description='Project-relative path of the UTF-8 text file to patch.')]Yes
find_textAnnotated[str, Field(description='Exact substring to find in the file. Must appear exactly as many times as expected_occurrences (default 1).')]Yes
replace_textAnnotated[str, Field(description='Text to replace each occurrence of find_text with.')]Yes
expected_occurrencesAnnotated[int, Field(description='Expected number of times find_text appears. Defaults to 1. Use to guard against partial matches in files with repeated content.')]No1
commit_messageAnnotated[str, Field(description='Git commit message. If omitted, the server generates a default message.')]No''
branch`Annotated[strNone, Field(description=“Branch to operate on. Defaults to the project’s default branch when omitted or null.”)]`NoNone
expected_shaAnnotated[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 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.

{
"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"
}
}
{
"path": "model/revenue.py",
"project": "forecasts",
"commit_sha": "abc1234def5678901234567890abcdef12345678",
"replacements_applied": 1
}
  • Module: Models
  • Requires authentication via API token or Auth0 JWT.