From f9913becf9dff13320009c201125eb46456278dc Mon Sep 17 00:00:00 2001 From: srivathsav004 Date: Thu, 25 Dec 2025 18:21:51 +0530 Subject: [PATCH] fix: remove requestedExplicitly check for non-text files Remove the requestedExplicitly check that filtered out images and PDFs unless explicitly requested by name or extension. Now all files matching glob patterns are included regardless of file type. Fixes issue where directories with assets appeared empty and "list all files" queries returned misleading results. --- .../core/src/tools/read-many-files.test.ts | 18 +++++++++++---- packages/core/src/tools/read-many-files.ts | 23 ------------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/packages/core/src/tools/read-many-files.test.ts b/packages/core/src/tools/read-many-files.test.ts index 0eaba66..0ad9624 100644 --- a/packages/core/src/tools/read-many-files.test.ts +++ b/packages/core/src/tools/read-many-files.test.ts @@ -411,24 +411,32 @@ describe('ReadManyFilesTool', () => { ]); }); - it('should skip PDF files if not explicitly requested by extension or name', async () => { + it('should include PDF files even if not explicitly requested by extension or name', async () => { createBinaryFile('document.pdf', Buffer.from('%PDF-1.4...')); createFile('notes.txt', 'text notes'); const params = { paths: ['*'] }; // Generic glob, not specific to .pdf const invocation = tool.build(params); const result = await invocation.execute(new AbortController().signal); const content = result.llmContent as string[]; - const expectedPath = path.join(tempRootDir, 'notes.txt'); + const expectedPathTxt = path.join(tempRootDir, 'notes.txt'); + const expectedPathPdf = path.join(tempRootDir, 'document.pdf'); expect( content.some( (c) => typeof c === 'string' && - c.includes(`--- ${expectedPath} ---\n\ntext notes\n\n`), + c.includes(`--- ${expectedPathTxt} ---\n\ntext notes\n\n`), + ), + ).toBe(true); + expect( + content.some( + (c) => + typeof c === 'object' && + c.inlineData && + c.inlineData.mimeType === 'application/pdf', ), ).toBe(true); - expect(result.returnDisplay).toContain('**Skipped 1 item(s):**'); expect(result.returnDisplay).toContain( - '- `document.pdf` (Reason: asset file (image/pdf) was not explicitly requested by name or extension)', + 'Successfully read and concatenated content from **3 file(s)**', ); }); diff --git a/packages/core/src/tools/read-many-files.ts b/packages/core/src/tools/read-many-files.ts index 1eed74c..112acdf 100644 --- a/packages/core/src/tools/read-many-files.ts +++ b/packages/core/src/tools/read-many-files.ts @@ -336,29 +336,6 @@ ${finalExclusionPatternsForDescription const fileType = await detectFileType(filePath); - if (fileType === 'image' || fileType === 'pdf') { - const fileExtension = path.extname(filePath).toLowerCase(); - const fileNameWithoutExtension = path.basename( - filePath, - fileExtension, - ); - const requestedExplicitly = inputPatterns.some( - (pattern: string) => - pattern.toLowerCase().includes(fileExtension) || - pattern.includes(fileNameWithoutExtension), - ); - - if (!requestedExplicitly) { - return { - success: false, - filePath, - relativePathForDisplay, - reason: - 'asset file (image/pdf) was not explicitly requested by name or extension', - }; - } - } - // Use processSingleFileContent for all file types now const fileReadResult = await processSingleFileContent( filePath,