Showing what a tool changed on disk.
There are two cases, and they are not the same thing.
The patch is in the event. A Claude Edit carries old_string and
new_string; a Write carries the whole content. The diff is derivable
from the event alone — no filesystem access, no ambiguity, and it stays
correct even if the file changed again afterwards.
Only the path is in the event. A Codex file_change item and an
Antigravity replace_file_content name the file and the kind of change and
nothing else. The honest options are a git diff on that path or a stat
line. A git diff is cheap and accurate at the moment it runs — but it
shows the file's current state, which after several edits is not the diff of
that one tool call.
The rule: never present a reconstructed diff as if it were the tool's own
patch. At :stat, show the path and the change kind. At :full, render
the event's patch where one exists, and where one does not, label the
rendered git diff as the file's current state rather than as that call's
change.
Summary
Functions
The rendered diff body for a tool call, as iodata.
The line counts for a tool call's change, or nil when the event does not
carry enough to compute them.
A +12 −3 suffix for a summary line, or "" when there is nothing to count.
Types
@type stat() :: %{added: non_neg_integer(), removed: non_neg_integer()}
Functions
The rendered diff body for a tool call, as iodata.
Options:
:color— colourize (defaulttrue):indent— leading spaces (default 4):line_budget— maximum body lines before truncation (default 60):cwd— where to rungit difffor a path-only change
Returns [] when there is nothing to show. Never silently truncates: a
truncated diff that looks complete is worse than no diff.
The line counts for a tool call's change, or nil when the event does not
carry enough to compute them.
A +12 −3 suffix for a summary line, or "" when there is nothing to count.