fix: skip reading binary files during scans - #6
Open
alloutflo wants to merge 1 commit into
Open
Conversation
alloutflo
marked this pull request as ready for review
August 9, 2026 13:16
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 does this PR do?
Avoid reading file contents when
scanRepoalready knows from the extension that a file is binary.classifyPath, keeping a single source for every existing category and reason.fileInfoonly for binary path classifications; other files still collect token and sample data..pngand a larger-than-MAX_READ.pdf.MAX_READJSON files still read their contents and retain content-dependent classification.0.1.2and add the required changelog entry.Binary results keep the existing contract:
category: "binary",trim: true,binary: true,tokens: 0, and the exact reasonbinary asset (skipped by agents, excluded to be safe).Fixes #4
Verification
The focused regression test fails against the original scan path because the
.pngreachesreadFileSync; it passes with this fast path. The final checks are:npm test— passed, 8/8npx --yes node@18 --test test/ctxtrim.test.js— passed, 6/6npx --yes node@20 --test test/ctxtrim.test.js— passed, 6/6node bin/ctxtrim.js test/fixtures/sample-repo --format json— passednode --checkfor every JavaScript file — passednpm pack --dry-run --json— passed with the expected nine package files and no bundled dependenciesgit diff --check— passedChecklist
node --test)CHANGELOG.mdentryNotes
The regression explicitly observes
readFileSync,openSync, andreadSync. It also compares.pngand.pdfresult fields directly withclassify, so the fast path cannot drift from the established category/reason contract.