@@ -303,8 +303,10 @@ func hasRootMarkers(dir string, markers []string) bool {
303303 return true
304304 }
305305 for _, pattern := range markers {
306โ // Use fsext.GlobWithDoubleStar to find matches
307โ matches, _, err := fsext.Glob(pattern, dir, 1)
306+ // Use filepath.Glob for a non-recursive check in the root
307+ // directory. This avoids walking the entire tree (which is
308+ // catastrophic in large monorepos with node_modules, etc.).
309+ matches, err := filepath.Glob(filepath.Join(dir, pattern))
308310 if err == nil && len(matches) > 0 {
309311 return true
310312 }