fix(coding-agent): fixed find tool glob pattern matching for **/filename

This commit is contained in:
can1357
2026-01-14 05:13:44 +01:00
parent 733dd7ad1c
commit bfd81ad5e8
+5 -1
View File
@@ -218,7 +218,11 @@ export function createFindTool(session: ToolSession, options?: FindToolOptions):
// When pattern contains path separators (e.g. "reports/**"), use --full-path
// so fd matches against the full path, not just the filename.
// Also prepend **/ to anchor the pattern at any depth in the search path.
const hasPathSeparator = pattern.includes("/") || pattern.includes("\\");
// Note: "**/foo.rs" is a glob construct (filename at any depth), not a path.
// Only patterns with real path components like "foo/bar" or "foo/**/bar" need --full-path.
const patternWithoutLeadingStarStar = pattern.replace(/^\*\*\//, "");
const hasPathSeparator =
patternWithoutLeadingStarStar.includes("/") || patternWithoutLeadingStarStar.includes("\\");
const effectivePattern = hasPathSeparator && !pattern.startsWith("**/") ? `**/${pattern}` : pattern;
const args: string[] = [
"--glob", // Use glob pattern