Skip to content

feat: add diff filtering for large staged changes#7

Merged
takai merged 5 commits intomainfrom
feat/filter-diff
Jan 28, 2026
Merged

feat: add diff filtering for large staged changes#7
takai merged 5 commits intomainfrom
feat/filter-diff

Conversation

@takai
Copy link
Owner

@takai takai commented Jan 28, 2026

Summary

  • Add diff filtering to handle large staged diffs that may exceed LLM context limits
  • Filter by file exclusion patterns (lock files, minified files, go.sum, etc.)
  • Truncate files exceeding max line limit (default: 100 lines per file)
  • Configurable via [filter] section in config.toml

Changes

  • internal/git/filter.go: New filtering module with glob pattern matching
  • internal/config/config.go: Add FilterConfig struct
  • internal/app/app.go: Integrate filtering into commitDiff()
  • README.md: Document new filter settings

Test plan

  • Unit tests pass (go test ./...)
  • Build succeeds (make build)
  • Manual test with large staged diff

takai added 5 commits January 28, 2026 21:01
Introduces a new filtering module for processing unified diffs with support for
line limits per file and glob-based pattern exclusion. Includes Options and Result
structs, a Filter function, and comprehensive unit tests covering truncation,
exclusion patterns, and deterministic output ordering.
Add FilterConfig struct to support configurable diff filtering with
max_file_lines, default_exclude_patterns, and exclude_patterns fields.
Implement merging of filter configuration from both user and repository
level configs, with repo-level settings taking precedence for
max_file_lines and default patterns, and exclude_patterns being
accumulated across layers.
Integrate diff filtering into the commitDiff function to apply exclusion patterns and file truncation before sending the diff to the LLM. Configure filtering options from the application config and append a filter notice when files are excluded or truncated.
The previous default of 200 lines per file was too permissive and could
cause diffs to exceed LLM context limits. Reducing to 100 lines provides
better compatibility with token constraints while still capturing
meaningful code changes for commit message generation.
@takai takai merged commit 8312756 into main Jan 28, 2026
1 check passed
@takai takai deleted the feat/filter-diff branch January 28, 2026 12:12
@asonas asonas mentioned this pull request Jan 28, 2026
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