diff options
| author | Gal Zahavi <[email protected]> | 2025-08-18 16:39:05 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-18 23:39:05 +0000 |
| commit | 6fc68ff8d4536f35f0ed76af535d5e1e7ac37675 (patch) | |
| tree | 90df004ab64647037154c3f9923b5082d4ea23b1 /packages/core/src/tools/glob.ts | |
| parent | fb3ceb0da4e2cd636013c2c36a9c0016c01aa47f (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/glob.ts')
| -rw-r--r-- | packages/core/src/tools/glob.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/core/src/tools/glob.ts b/packages/core/src/tools/glob.ts index 65454232..ae82de76 100644 --- a/packages/core/src/tools/glob.ts +++ b/packages/core/src/tools/glob.ts @@ -6,7 +6,7 @@ import fs from 'fs'; import path from 'path'; -import { glob } from 'glob'; +import { glob, escape } from 'glob'; import { SchemaValidator } from '../utils/schemaValidator.js'; import { BaseDeclarativeTool, @@ -137,7 +137,13 @@ class GlobToolInvocation extends BaseToolInvocation< let allEntries: GlobPath[] = []; for (const searchDir of searchDirectories) { - const entries = (await glob(this.params.pattern, { + let pattern = this.params.pattern; + const fullPath = path.join(searchDir, pattern); + if (fs.existsSync(fullPath)) { + pattern = escape(pattern); + } + + const entries = (await glob(pattern, { cwd: searchDir, withFileTypes: true, nodir: true, |
