Skip to content

Commit 4ec85af

Browse files
Jille00saoudrizwan
andauthored
fix: improve file handling for NextJS folder naming conventions and increase limits (RooCodeInc#2398)
* fix: improve file handling for NextJS folder naming conventions and increase limits * Update WorkspaceTracker.ts * Update list-files.ts * Update beige-monkeys-prove.md --------- Co-authored-by: Saoud Rizwan <[email protected]>
1 parent 00f8805 commit 4ec85af

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/beige-monkeys-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": patch
3+
---
4+
5+
Improve file handling for NextJS folder naming conventions and increase file listing limits. Fix glob pattern interpretation issues with parentheses in folder names

src/services/glob/list-files.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from "path"
44
import { arePathsEqual } from "../../utils/path"
55

66
export async function listFiles(dirPath: string, recursive: boolean, limit: number): Promise<[string[], boolean]> {
7+
// First resolve the path normally - path.resolve doesn't care about glob special characters
78
const absolutePath = path.resolve(dirPath)
89
// Do not allow listing files in root or home directory, which cline tends to want to do when the user's prompt is vague.
910
const root = process.platform === "win32" ? path.parse(absolutePath).root : "/"
@@ -48,6 +49,7 @@ export async function listFiles(dirPath: string, recursive: boolean, limit: numb
4849
}
4950

5051
// * globs all files in one dir, ** globs files in nested directories
52+
// For non-recursive listing, we still use a simple pattern
5153
const filePaths = recursive ? await globbyLevelByLevel(limit, options) : (await globby("*", options)).slice(0, limit)
5254

5355
return [filePaths, filePaths.length >= limit]
@@ -80,7 +82,11 @@ async function globbyLevelByLevel(limit: number, options?: Options) {
8082
}
8183
results.add(file)
8284
if (file.endsWith("/")) {
83-
queue.push(`${file}*`)
85+
// Escape parentheses in the path to prevent glob pattern interpretation
86+
// This is crucial for NextJS folder naming conventions which use parentheses like (auth), (dashboard)
87+
// Without escaping, glob treats parentheses as special pattern grouping characters
88+
const escapedFile = file.replace(/\(/g, "\\(").replace(/\)/g, "\\)")
89+
queue.push(`${escapedFile}*`)
8490
}
8591
}
8692
}

0 commit comments

Comments
 (0)