diff --git a/.changeset/beige-monkeys-prove.md b/.changeset/beige-monkeys-prove.md new file mode 100644 index 00000000..b74ed5c7 --- /dev/null +++ b/.changeset/beige-monkeys-prove.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Improve file handling for NextJS folder naming conventions and increase file listing limits. Fix glob pattern interpretation issues with parentheses in folder names diff --git a/src/services/glob/list-files.ts b/src/services/glob/list-files.ts index bea3e1cc..19327c31 100644 --- a/src/services/glob/list-files.ts +++ b/src/services/glob/list-files.ts @@ -4,6 +4,7 @@ import * as path from "path" import { arePathsEqual } from "../../utils/path" export async function listFiles(dirPath: string, recursive: boolean, limit: number): Promise<[string[], boolean]> { + // First resolve the path normally - path.resolve doesn't care about glob special characters const absolutePath = path.resolve(dirPath) // Do not allow listing files in root or home directory, which cline tends to want to do when the user's prompt is vague. const root = process.platform === "win32" ? path.parse(absolutePath).root : "/" @@ -48,6 +49,7 @@ export async function listFiles(dirPath: string, recursive: boolean, limit: numb } // * globs all files in one dir, ** globs files in nested directories + // For non-recursive listing, we still use a simple pattern const filePaths = recursive ? await globbyLevelByLevel(limit, options) : (await globby("*", options)).slice(0, limit) return [filePaths, filePaths.length >= limit] @@ -80,7 +82,11 @@ async function globbyLevelByLevel(limit: number, options?: Options) { } results.add(file) if (file.endsWith("/")) { - queue.push(`${file}*`) + // Escape parentheses in the path to prevent glob pattern interpretation + // This is crucial for NextJS folder naming conventions which use parentheses like (auth), (dashboard) + // Without escaping, glob treats parentheses as special pattern grouping characters + const escapedFile = file.replace(/\(/g, "\\(").replace(/\)/g, "\\)") + queue.push(`${escapedFile}*`) } } }