Write file changes to a project's git repo as one commit, without a git client.
Use it in a client with no shell access, or when git cannot push
from this machine: no SSH key that ``list_ssh_keys`` lists for
the account, and no ``$XHOSTD_TOKEN`` in the environment.
Never ask the user to paste a token. A commit stores code and
deploys nothing; ``deploy`` is its own call.
One commit carries any mix of three change kinds:
* ``files``: whole content. It creates a file, replaces one, or
deletes one (pass null).
* ``edits``: anchored replacements inside a file that already
exists.
* ``patches``: anchored hunks, for several changes to one file in
one payload.
``edits`` and ``patches`` carry only the changed region of a file,
so a one-line fix in a 78 KB file sends the anchor and not the
file. ``files`` carries the whole content.
``edits`` maps a path to a list of
``{"old_string": ..., "new_string": ..., "replace_all": false}``.
``old_string`` must occur EXACTLY ONCE in the file unless
``replace_all`` is true. If it occurs zero times or more than
once, the whole commit fails and nothing is written — add
surrounding lines until the anchor is unique.
``patches`` maps a path to hunks. A hunk header is ``@@``, or
``@@ anchor`` where the anchor is a line or unique substring
copied from the file. Put the anchor on a line the hunk covers,
or on the line directly above it: matching starts there and runs to
the end of the file. Body lines start with a space (context),
``-`` (remove), or ``+`` (add). There are no line numbers and no
line counts. Each hunk needs at least one context or ``-`` line
to locate the change::
@@ export const VERSION
-export const VERSION = "1.4.0"
+export const VERSION = "1.5.0"
Matching is byte-exact for both: no whitespace, indentation, or
line-ending tolerance. Copy anchors from ``read_source_file`` output.
Edits and hunks apply in order, each against the result of the
previous one.
A path belongs to exactly ONE of the three fields. The commit is
all-or-nothing, so a failure never leaves the repo half-updated.
Returns {sha}. Deploy it with deploy(project, environment, sha). A
project with a connected source repository refuses this call: its
code comes from that repository, and a push there reaches the
project. A 503 commits nothing:
another write holds the repo, or the project is under scheduled
maintenance. Retry in a minute.
Reference: https://docs.xhostd.com/mcp-tools#commit_files