Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/core/src/tools/read-many-files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)**',
);
});

Expand Down
23 changes: 0 additions & 23 deletions packages/core/src/tools/read-many-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down