… tool
Add getDefaultPermission() override to GrepToolInvocation in ripGrep.ts
to match the behavior of grep.ts, returning "ask" for paths outside
the workspace and "allow" for workspace-internal paths.
Also pass allowExternalPaths: true to resolveAndValidatePath in both
the execute() and validateToolParamValues() methods, so external paths
are not rejected at the validation layer (permission is deferred to
getDefaultPermission as designed).
Fixes issue where grep searches in arbitrary workspace paths would
fail with "Path is not within workspace" even when the user intended
to search external directories.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
TLDR
RipGrepToolwas missing agetDefaultPermission()override and passingallowExternalPaths: truetoresolveAndValidatePath, unlike its siblingGrepTool(grep.ts) which has both. This caused grep searches in arbitrary workspace paths to fail with "Path is not within workspace" even when the user explicitly specified an external path.This PR adds:
getDefaultPermission()override inGrepToolInvocation(ripGrep.ts) — returns"allow"for workspace-internal paths and"ask"for external paths, matchinggrep.tsbehavior.allowExternalPaths: truein bothexecute()andvalidateToolParamValues()— so external paths are not rejected at the validation layer; permission checks are deferred togetDefaultPermission()as designed.getDefaultPermission()returns"ask"for external paths.getDefaultPermission()covering no-path, workspace-internal, subdirectory, and external-path scenarios.Screenshots / Video Demo
N/A — no user-facing change. This is a bug fix that aligns
ripGrep.tspermission handling withgrep.tsand fixes the "Path is not within workspace" error when searching external directories.Dive Deeper
The root cause is a long-standing inconsistency between two grep tool implementations:
getDefaultPermission()allowExternalPathsgrep.tstrueripGrep.ts"allow")falseWhen commit
217d59c89("feat enable other dirs with core tools") addedgetDefaultPermission()andallowExternalPaths: trueto grep.ts, glob.ts, ls.ts, read-file.ts, and other core tools, ripGrep.ts was accidentally omitted. The subsequent PR #2637 ("fix search tool for multi dirs") added multi-directory search support to ripgrep but did not address this underlying permission/ validation gap.The fix ensures that:
"allow"(no confirmation needed)"ask"(user confirmation required)Reviewer Test Plan
Run the ripGrep tests to verify all 48 tests pass:
To manually validate the behavior change:
/tmpor../sibling-project)"Path is not within workspace"Testing Matrix
Linked issues / bugs
Fixes #2919