Skip to content

fix: truncation accuracy + Copilot init + binary file detection#859

Merged
aeppling merged 14 commits intomasterfrom
develop
Mar 26, 2026
Merged

fix: truncation accuracy + Copilot init + binary file detection#859
aeppling merged 14 commits intomasterfrom
develop

Conversation

@pszymkowiak
Copy link
Collaborator

Summary

  • fix(truncation): accurate overflow counts in diff, git diff, and git log — no more vague ... (truncated) markers
  • fix(read): detect binary files, prevent empty output on filter failure, default to no filtering (show full content)
  • fix(diff): never truncate diff content — show all changes in full
  • feat(init): add --copilot flag for GitHub Copilot integration
  • docs: fix Copilot setup instructions + add Vibe status in README
  • fix: rewrite swift test commands (PR fix: rewrite swift test commands #767)

Important

Squash merge this PR with a fix: title so release-please creates v0.33.2.

Test plan

zerone0x and others added 13 commits March 21, 2026 22:58
Fixes #765

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: zerone0x <hi@trine.dev>
- Split Copilot into VS Code (transparent rewrite) and CLI (deny-with-suggestion)
- Use --copilot flag (consistent with --gemini, --codex, --opencode)
- Add Mistral Vibe as planned (blocked on upstream #531)
- Fix Copilot section with VS Code vs CLI details
- Update tool count from 9 to 10
- Verified all 10 tools against actual codebase

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
- Add `rtk init --copilot` that creates .github/hooks/rtk-rewrite.json
  and .github/copilot-instructions.md in the current project
- Hook routes through `rtk hook copilot` (auto-detects VS Code vs CLI)
- VS Code Copilot Chat: transparent rewrite via updatedInput
- Copilot CLI: deny-with-suggestion (CLI limitation)
- Update README: split Copilot VS Code/CLI, add Vibe status, 10 tools

Closes #823

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Silent truncation caused a user to make irreversible decisions on
incomplete data. rtk diff was capping at 50 changes and 70-80 char
lines without clear warning to the LLM.

- Remove all line truncation (70/80 char limits)
- Remove change count limit (was 50, now unlimited)
- Remove truncate import (no longer needed)
- Same fix for condense_unified_diff (stdin/git diff path)
- Add 3 tests verifying zero truncation on large inputs

The only compression remaining is the summary header
(+N added, -N removed, ~N modified) and stripping diff metadata.

Fixes #827

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
…lure

- Detect binary files (null bytes in first 8KB) before filtering
- Show clear message: [binary file] path (size) instead of empty output
- Fallback to raw content if filter produces empty output on non-empty file
- Prevents LLM from concluding a 70MB file is "empty" (was #822)

Fixes #822

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
Changed default filter level from "minimal" to "none". RTK read now
shows complete file content by default. Filtering is opt-in:

  rtk read file.rs              # full content (was: minimal filter)
  rtk read file.rs -l minimal   # light filtering (opt-in)
  rtk read file.rs -l aggressive # signatures only (opt-in)

Also adds fallback: if a filter produces empty output on non-empty
file, show raw content with a warning.

Fixes #822

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
The overflow message "+N more" in condense_unified_diff was lying.
The `changes` vec was capped at 15 entries, so `changes.len() - 10`
could only reach 5 — reporting "+5 more" when 190 lines were actually
truncated. Fix: track `added + removed` directly and compute true
overflow as `(added + removed) - 10`.

Adds 7 accuracy tests across 4 modules to lock in correct overflow
reporting:
- diff_cmd: overflow count matches true total (200 changes → "+190 more")
- diff_cmd: no spurious overflow message for 8 changes
- git: format_status overflow count is exact (25 staged → "+10 more")
- git: compact_diff recovery hint present when hunk is truncated
- grep: documents uncapped-vector invariant that prevents the diff bug
- filter: smart_truncate kept + reported_more == total_lines

Closes the test gap flagged in testing-patterns.md backlog for diff_cmd.rs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Two silent truncation bugs in git.rs:

1. compact_diff: hunk truncation showed "... (truncated)" with no count.
   An LLM had no way to know if 5 or 450 lines were dropped. Replace
   with "... (N lines truncated)" by tracking hunk_skipped separately
   from hunk_shown — flush the count at each hunk/file boundary.

2. filter_log_output: commit body beyond 3 lines was silently dropped.
   A 20-line body explaining a breaking change would show 3 lines with
   no indicator that 17 were omitted. Now appends "[+N lines omitted]"
   when body_omitted > 0.

Adds 2 RED-then-GREEN tests to lock in the new behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
docs(readme): fix Copilot setup + add Vibe
Keep truncation accuracy fix (HEAD) — accurate overflow counts in
condense_unified_diff. Drop test_condense_unified_no_truncation from
develop (incompatible). Add test_no_truncation_large_diff and
test_long_lines_not_truncated from develop (test compute_diff, no conflict).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Run cargo fmt on diff_cmd.rs and init.rs (line length violations)
- Add Unreleased section to CHANGELOG.md with the two bug fixes
  from this PR (required by doc review CI gate)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
fix(truncation): accurate overflow counts and omission indicators
Copy link

@KuSh KuSh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@aeppling aeppling merged commit 966bcbe into master Mar 26, 2026
23 checks passed
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.

5 participants