Skip to content

review,diff: add --include glob flag to scope reviews to matching files - #5

Merged
selyafi merged 1 commit into
mainfrom
feat/review-include-flag
Jun 16, 2026
Merged

review,diff: add --include glob flag to scope reviews to matching files#5
selyafi merged 1 commit into
mainfrom
feat/review-include-flag

Conversation

@selyafi

@selyafi selyafi commented Jun 16, 2026

Copy link
Copy Markdown
Owner

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

  • Engine (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 shared fileMatchesAny / matchPattern / splitRawSegments helpers, 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 to Exclude. No patterns = no-op ("review everything").
  • Wiring (internal/app/review.go): registered in 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 (--include 'internal/' --exclude 'internal/gen/').
  • No silent omissions: the narrowing is surfaced in the run summary (or stderr on the bypass path); an --include that matches no changed file is a clean pre-model error, and malformed globs fail up front.
  • Adapters: the three over-budget hints now name --include/--exclude.
  • Docs: README paragraph + new ## Unreleased CHANGELOG section.

Tests

TDD throughout — 10 new diff.Include unit tests + 5 new command-level --include tests (including include→exclude composition). Each watched fail before implementing. Full go test ./..., go vet ./..., and go build ./... green.

Closes diffsmith-dko.

🤖 Generated with Claude Code

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>
@selyafi
selyafi merged commit 3bf8b53 into main Jun 16, 2026
2 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.

1 participant