review,diff: add --include glob flag to scope reviews to matching files - #5
Merged
Conversation
diff.Include keeps only files matching at least one gitignore-lite pattern (the allowlist inverse of Exclude), reusing the shared match and raw-segment helpers so the rules, rename old/new-path union, and positional segment safety all carry over. Wired via registerModelFlowFlags so it lands on review, inbox, and bare diffsmith. applyIncludes runs BEFORE applyExcludes on both the bypass (--print-prompt/--dry-run) and TUI paths, so --exclude carves exceptions out of the included set (gitignore precedence). A nothing-included result is a clean pre-model error; the narrowing is surfaced in the run summary/stderr, never silent. Adapter over-budget hints now name --include/--exclude. README + CHANGELOG (Unreleased) updated. Closes diffsmith-dko. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
--include <pattern>(repeatable) — the allowlist counterpart of--exclude— so a review can be scoped to one area of a large diff before the prompt is built.How
internal/diff/include.go):diff.Include()keeps only files matching at least one gitignore-lite pattern and drops the rest from both the parsed file list and the rebuilt raw diff. Reuses the sharedfileMatchesAny/matchPattern/splitRawSegmentshelpers, so pattern rules (trailing/= dir tree at any depth, no/= basename glob, else full-path glob), the rename old/new-path union, and the positional raw-segment safety check are identical toExclude. No patterns = no-op ("review everything").internal/app/review.go): registered inregisterModelFlowFlags, so it lands onreview,inbox, and barediffsmith.applyIncludes()runs beforeapplyExcludes()on both the bypass (--print-prompt/--dry-run) and TUI paths, so--excludecarves exceptions out of the included set (--include 'internal/' --exclude 'internal/gen/').--includethat matches no changed file is a clean pre-model error, and malformed globs fail up front.--include/--exclude.## UnreleasedCHANGELOG section.Tests
TDD throughout — 10 new
diff.Includeunit tests + 5 new command-level--includetests (including include→exclude composition). Each watched fail before implementing. Fullgo test ./...,go vet ./..., andgo build ./...green.Closes diffsmith-dko.
🤖 Generated with Claude Code