fix: compressed_glob now uses --glob flag for fd

Bug: fd interprets patterns as regex by default, not glob.
Fix: Add --glob flag, strip **/ prefix for find fallback.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-01-08 13:10:36 +02:00
parent 0879633faf
commit fdbd3e5723
2 changed files with 12 additions and 10 deletions

11
dist/index.js vendored
View File

@@ -208,16 +208,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
return { content: [{ type: "text", text: "Error: pattern is required" }] };
}
const basePath = args?.path || ".";
// Use find or fd for globbing
// Use fd with glob mode for proper ** support
let cmd;
try {
// Try fd first (faster)
// Try fd first with --glob flag for proper glob pattern support
execSync("which fd", { encoding: "utf-8" });
cmd = `fd --type f "${pattern}" "${basePath}" 2>/dev/null || true`;
cmd = `fd --type f --glob "${pattern}" "${basePath}" 2>/dev/null || true`;
}
catch {
// Fall back to find
cmd = `find "${basePath}" -type f -name "${pattern}" 2>/dev/null || true`;
// Fall back to find - extract just filename pattern from glob
const simplePattern = pattern.replace(/^\*\*\//, '');
cmd = `find "${basePath}" -type f -name "${simplePattern}" 2>/dev/null || true`;
}
let output;
try {

View File

@@ -239,15 +239,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
const basePath = (args?.path as string) || ".";
// Use find or fd for globbing
// Use fd with glob mode for proper ** support
let cmd: string;
try {
// Try fd first (faster)
// Try fd first with --glob flag for proper glob pattern support
execSync("which fd", { encoding: "utf-8" });
cmd = `fd --type f "${pattern}" "${basePath}" 2>/dev/null || true`;
cmd = `fd --type f --glob "${pattern}" "${basePath}" 2>/dev/null || true`;
} catch {
// Fall back to find
cmd = `find "${basePath}" -type f -name "${pattern}" 2>/dev/null || true`;
// Fall back to find - extract just filename pattern from glob
const simplePattern = pattern.replace(/^\*\*\//, '');
cmd = `find "${basePath}" -type f -name "${simplePattern}" 2>/dev/null || true`;
}
let output: string;