From 6fc68ff8d4536f35f0ed76af535d5e1e7ac37675 Mon Sep 17 00:00:00 2001 From: Gal Zahavi <38544478+galz10@users.noreply.github.com> Date: Mon, 18 Aug 2025 16:39:05 -0700 Subject: fix(tools): Handle special characters in file paths for glob and read_many_files (#6507) Co-authored-by: Jacob Richman --- packages/core/src/tools/read-many-files.test.ts | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'packages/core/src/tools/read-many-files.test.ts') diff --git a/packages/core/src/tools/read-many-files.test.ts b/packages/core/src/tools/read-many-files.test.ts index a57b3851..b432998d 100644 --- a/packages/core/src/tools/read-many-files.test.ts +++ b/packages/core/src/tools/read-many-files.test.ts @@ -527,6 +527,43 @@ describe('ReadManyFilesTool', () => { expect(truncatedFileContent).toContain('L200'); expect(truncatedFileContent).not.toContain('L2400'); }); + + it('should read files with special characters like [] and () in the path', async () => { + const filePath = 'src/app/[test]/(dashboard)/testing/components/code.tsx'; + createFile(filePath, 'Content of receive-detail'); + const params = { paths: [filePath] }; + const invocation = tool.build(params); + const result = await invocation.execute(new AbortController().signal); + const expectedPath = path.join(tempRootDir, filePath); + expect(result.llmContent).toEqual([ + `--- ${expectedPath} --- + +Content of receive-detail + +`, + ]); + expect(result.returnDisplay).toContain( + 'Successfully read and concatenated content from **1 file(s)**', + ); + }); + + it('should read files with special characters in the name', async () => { + createFile('file[1].txt', 'Content of file[1]'); + const params = { paths: ['file[1].txt'] }; + const invocation = tool.build(params); + const result = await invocation.execute(new AbortController().signal); + const expectedPath = path.join(tempRootDir, 'file[1].txt'); + expect(result.llmContent).toEqual([ + `--- ${expectedPath} --- + +Content of file[1] + +`, + ]); + expect(result.returnDisplay).toContain( + 'Successfully read and concatenated content from **1 file(s)**', + ); + }); }); describe('Batch Processing', () => { -- cgit v1.2.3