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:
11
dist/index.js
vendored
11
dist/index.js
vendored
@@ -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 {
|
||||
|
||||
11
src/index.ts
11
src/index.ts
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user