Skip to main content

Module diff

Module diff 

Source
Expand description

Diff-line marker conventions shared between the edit_file tool (which generates diff output) and the chat renderer (which colors added/removed lines red/green).

Kept in the render layer rather than in the tool impl because every consumer is the renderer. The producer today is generate_diff — inside the edit tool’s helper code — and uses the same constants to format its lines.

Enums§

DiffLineKind
Classification of a diff line. The chat renderer matches on this to choose a background color.

Constants§

DIFF_ADDED_MARKER
Marker for an ADDED line.
DIFF_REMOVED_MARKER
Marker for a REMOVED line. Formatted as {num:>4}{marker}{content} so the three-byte width stays aligned across line numbers up to 9,999. Lines without a matching prefix fall through to Context.

Functions§

parse_diff_line
Parse one line of diff output. Lines that don’t follow the {number}{marker}{content} shape — including malformed or truncated input — fall through to Context so the renderer’s match stays exhaustive without panicking.