diff

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unified

func Unified(oldBody, newBody string) string

Unified produces a standard unified diff (3 context lines) of two file bodies for the agent harness’s edit/write tools. The output round-trips through Parse so the existing renderDiffBlock pipeline renders agent edits exactly like any other diff block. Returns "" when the bodies are identical. No ---/+++ file header is emitted: toolDiffMsg carries the path separately and Parse drops pre-@@ lines anyway.

Types

type Hunk

type Hunk struct {
	OldStart int
	OldLines int
	NewStart int
	NewLines int
	Lines    []string
}

Hunk represents a unified diff hunk.

func Parse

func Parse(s string) []Hunk

Parse turns a unified diff string into a slice of Hunks. Lines whose first character is neither space, +, -, nor \ are kept verbatim (no prefix re-writing) so renderDiffBlock’s existing prefix-based styling applies. Lines before the first `@@` (file headers like "--- a/f") are dropped — we already know the path from the FileUpdateChange record.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL