Skip to content

chore(tools): Add start_line/end_line paging to diff tools#622

Merged
JeanMertz merged 3 commits intomainfrom
prr190
May 7, 2026
Merged

chore(tools): Add start_line/end_line paging to diff tools#622
JeanMertz merged 3 commits intomainfrom
prr190

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

Both git_diff_file and git_diff_commit previously had only one escape hatch when a diff exceeded the 500-line truncation cap: the pattern grep parameter. That left no way to inspect a specific region of a large diff without already knowing what to search for.

This change adds start_line and end_line parameters to both tools, mirroring the interface of fs_read_file. When either bound is supplied, the diff is sliced to that 1-based output-line window before any further processing, and the truncation cap is bypassed entirely — the caller owns their window size. Slice markers are injected last (... (starting from line #N) ... / ... (truncated after line #M) ...) so they survive an intermediate pattern grep.

The two features compose: when both a range and a pattern are given, the diff is sliced first and pattern greps within that slice. This lets the model page to a known region and then narrow further.

Three new helpers in diff_filter.rs carry the implementation: validate_line_range (static cross-cut checks), slice_diff (extracts the line window), and add_slice_markers (appends the context markers). The truncation note now surfaces both escape hatches so the model knows to use start_line/end_line when it hits the cap.

Tool schemas and the git-reading skill description are updated to document the new parameters and include paging/compose examples.

JeanMertz added 3 commits May 7, 2026 16:38
Both `git_diff_file` and `git_diff_commit` previously had only one
escape hatch when a diff exceeded the 500-line truncation cap: the
`pattern` grep parameter. That left no way to inspect a specific region
of a large diff without already knowing what to search for.

This change adds `start_line` and `end_line` parameters to both tools,
mirroring the interface of `fs_read_file`. When either bound is
supplied, the diff is sliced to that 1-based output-line window before
any further processing, and the truncation cap is bypassed entirely —
the caller owns their window size. Slice markers are injected last (`...
(starting from line #N) ...` / `... (truncated after line #M) ...`) so
they survive an intermediate `pattern` grep.

The two features compose: when both a range and a `pattern` are given,
the diff is sliced first and `pattern` greps within that slice. This
lets the model page to a known region and then narrow further.

Three new helpers in `diff_filter.rs` carry the implementation:
`validate_line_range` (static cross-cut checks), `slice_diff` (extracts
the line window), and `add_slice_markers` (appends the context markers).
The truncation note now surfaces both escape hatches so the model knows
to use `start_line`/`end_line` when it hits the cap.

Tool schemas and the `git-reading` skill description are updated to
document the new parameters and include paging/compose examples.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit a14205d into main May 7, 2026
14 checks passed
@JeanMertz JeanMertz deleted the prr190 branch May 7, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant