Expand description
Unified-diff rendering for file-modifying tools.
Produces a compact, user-facing unified diff (with +N -M stats and a
line cap) so channel adapters and the web UI can show exactly what an
edit_file / write_file call changed, instead of a bare success line.
Structs§
- Unified
Diff - A rendered unified diff plus its summary stats.
Constants§
- DEFAULT_
DIFF_ MAX_ LINES - Default cap on rendered diff lines (matching the 120-line convention popularized by Grok Build’s diff view).
- FILE_
DIFF_ METADATA_ KEY - Key under which file-modifying tools attach their diff payload to
ToolResult::metadata. Shared so the producer (tools) and consumers (tool executor →AgentEvent::FileDiff) cannot silently desync.
Functions§
- file_
diff_ metadata - Build the metadata payload for a file edit diff.
- format_
diff_ chat_ message - Format a chat-facing message for a file diff: a one-line header with the
path and
+N -Mstats, followed by a fenced ```diff block. - unified_
diff - Compute a unified diff between
oldandnew, capped atmax_linesrendered lines. ReturnsNonewhen the contents are identical.