fix(coding-agent): make find tool match path-based glob patterns

fd --glob matches against the basename unless --full-path is set, so
patterns containing '/' (e.g. 'src/**/*.spec.ts') silently returned no
results. When the pattern contains '/', switch fd into --full-path mode
and prepend '**/' unless the pattern already starts with '/', '**/', or
is '**'. Basename patterns keep the default matcher.

closes #3302
This commit is contained in:
Mario Zechner
2026-04-16 22:53:45 +02:00
parent ab518d8651
commit c5451af749
3 changed files with 85 additions and 1 deletions

View File

@@ -258,7 +258,18 @@ export function createFindToolDefinition(
return;
}
for (const gitignorePath of gitignoreFiles) args.push("--ignore-file", gitignorePath);
args.push(pattern, searchPath);
// fd --glob matches against the basename unless --full-path is set; in --full-path
// mode it matches against the absolute candidate path, so a path-containing
// pattern like 'src/**/*.spec.ts' needs a leading '**/' to match anything.
let effectivePattern = pattern;
if (pattern.includes("/")) {
args.push("--full-path");
if (!pattern.startsWith("/") && !pattern.startsWith("**/") && pattern !== "**") {
effectivePattern = `**/${pattern}`;
}
}
args.push(effectivePattern, searchPath);
const child = spawn(fdPath, args, { stdio: ["ignore", "pipe", "pipe"] });
const rl = createInterface({ input: child.stdout });