From bb28e71e503274c41f9bfcfea32e2e1b1ff8ff8d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 21 Jan 2026 21:44:05 -0600 Subject: [PATCH] Fix grep and glob tools --- src/lib/tools/GlobTool.ts | 3 ++- src/lib/tools/GrepTool.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/tools/GlobTool.ts b/src/lib/tools/GlobTool.ts index 667b47f8..1408f42e 100644 --- a/src/lib/tools/GlobTool.ts +++ b/src/lib/tools/GlobTool.ts @@ -51,7 +51,8 @@ export class GlobTool implements Tool { if (args.path) { // User explicitly specified a path parameter - searchPath = join(this.cwd, args.path); + // If path is absolute, use it directly; otherwise join with cwd + searchPath = args.path.startsWith('/') ? args.path : join(this.cwd, args.path); pattern = args.pattern; } else { // Parse the pattern to extract base directory diff --git a/src/lib/tools/GrepTool.ts b/src/lib/tools/GrepTool.ts index 40472df8..da076fed 100644 --- a/src/lib/tools/GrepTool.ts +++ b/src/lib/tools/GrepTool.ts @@ -48,7 +48,10 @@ export class GrepTool implements Tool { throw new Error("pattern is required"); } - const searchPath = args.path ? join(this.cwd, args.path) : this.cwd; + // If path is absolute, use it directly; otherwise join with cwd + const searchPath = args.path + ? (args.path.startsWith('/') ? args.path : join(this.cwd, args.path)) + : this.cwd; try { // Check if search path exists