summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/read-many-files.test.ts
diff options
context:
space:
mode:
authorGal Zahavi <[email protected]>2025-08-18 16:39:05 -0700
committerGitHub <[email protected]>2025-08-18 23:39:05 +0000
commit6fc68ff8d4536f35f0ed76af535d5e1e7ac37675 (patch)
tree90df004ab64647037154c3f9923b5082d4ea23b1 /packages/core/src/tools/read-many-files.test.ts
parentfb3ceb0da4e2cd636013c2c36a9c0016c01aa47f (diff)
fix(tools): Handle special characters in file paths for glob and read_many_files (#6507)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/core/src/tools/read-many-files.test.ts')
-rw-r--r--packages/core/src/tools/read-many-files.test.ts37
1 files changed, 37 insertions, 0 deletions
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', () => {