bug(core): read_many_files skips explicitly requested binary assets in added workspace directories (regression from #30211)
What happened?
After #30211 (1930f2539), read_many_files skips explicitly requested non-text assets (images, PDFs, audio) whenever they live in a secondary workspace directory (added via --include-directories or /directory add), or when an absolute path is passed in include.
ReadManyFilesToolInvocation.execute (packages/core/src/tools/read-many-files.ts:246-281) globs include patterns against every directory in workspaceContext.getDirectories(). Then, at lines 344-360, it computes:
const relativePathForDisplay = path
.relative(this.config.getTargetDir(), filePath)
.replace(/\\/g, '/');
and passes relativePathForDisplay into isAssetExplicitlyRequested(include, relativePathForDisplay, filePath, matcherCache).
For a secondary workspace directory ws2 when targetDir is ws1, relativePathForDisplay is ../ws2/assets/logo.png:
- Path-qualified patterns like
assets/logo.pngordocs/*.pdffailisMatchPath('../ws2/assets/logo.png'), and the basename fallback (!normalizedPattern.includes('/')at line156) is skipped because the pattern contains/. - Even passing the exact absolute path (
/path/to/ws2/assets/logo.png) fails becauseisAssetExplicitlyRequestedonly matches againstrelativePath(never againstnormalizedFilePath), andnormalizedPatterncontains/.
Local Reproduction
Tested on main (e5d88fb2c / 0.70.0-nightly.20261110.g1603e9bab) with WorkspaceContext(ws1, [ws2]), ws1/assets/root-logo.png, ws2/assets/logo.png, and ws2/docs/manual.pdf:
include: ['assets/root-logo.png'](primary workspacews1):- Result: Read and returned
inlineData(image/png).
- Result: Read and returned
include: ['assets/logo.png'](secondary workspacews2):- Result:
isAssetExplicitlyRequested(['assets/logo.png'], '../ws2/assets/logo.png', logoPath)returnsfalse. - Skipped:
../ws2/assets/logo.png (Reason: asset file (image/pdf/audio) was not explicitly requested by name or extension) llmContent:["No files matching the criteria were found or all were skipped."]
- Result:
include: ['docs/*.pdf'](secondary workspacews2):- Skipped:
../ws2/docs/manual.pdf (Reason: asset file (image/pdf/audio) was not explicitly requested by name or extension)
- Skipped:
include: ['<abs>/ws2/assets/logo.png'](exact absolute path):- Skipped:
../ws2/assets/logo.png (Reason: asset file (image/pdf/audio) was not explicitly requested by name or extension)
- Skipped:
What did you expect to happen?
Explicitly requested images, PDFs, and audio files in any configured workspace directory (or specified by absolute path) should be matched against each workspace directory's relative path (and the normalized absolute filePath), not solely against path.relative(targetDir, filePath)—while still rejecting generic wildcard globs like **/* or reports/**.
Client information
Client Information
- Repository:
google-gemini/gemini-cli(mainat commite5d88fb2c,package.jsonversion0.70.0-nightly.20261110.g1603e9bab) - Platform: macOS (
darwin) - Node.js:
v26.10.0 - Reproduced locally via
ReadManyFilesToolfrom@google/gemini-cli-core
Login information
N/A (reproduced directly against ReadManyFilesTool in @google/gemini-cli-core)
Anything else we need to know?
Regression introduced in #30211 (1930f2539), which fixed #29045. packages/core/src/tools/read-many-files.test.ts currently only tests isAssetExplicitlyRequested with primary-root relative paths (assets/logo.png) and tests multi-workspace reading with text files, so this case isn't covered yet.
Hi maintainers, I reproduced this locally on main and would be happy to put together a small PR with unit tests for isAssetExplicitlyRequested and multi-workspace ReadManyFilesTool execution. If this looks good, could a maintainer please add the help wanted label and assign this issue to me? Thank you!
Hi maintainers, I reproduced this regression locally on Windows and opened PR #30468 with a minimal fix and vitest regression tests covering added workspace directories, exact absolute paths, Windows path/drive handling, and symlinked workspace roots (with CLA signed and Gemini Code Assist review clean). Could a maintainer please review it or add the \help wanted\ label if appropriate? Thank you!