summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/filesearch/fileSearch.ts
diff options
context:
space:
mode:
authorBryant Chandler <[email protected]>2025-08-05 23:33:27 -0700
committerGitHub <[email protected]>2025-08-06 06:33:27 +0000
commitaab850668c99e1c39a55036069d9f4b06ca458f4 (patch)
treef134a01a96c18f4185536503c91033454b31e1ec /packages/core/src/utils/filesearch/fileSearch.ts
parent8b1d5a2e3c84e488d90184e7da856cf1130ea5ef (diff)
feat(file-search): Add support for non-recursive file search (#5648)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/core/src/utils/filesearch/fileSearch.ts')
-rw-r--r--packages/core/src/utils/filesearch/fileSearch.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/core/src/utils/filesearch/fileSearch.ts b/packages/core/src/utils/filesearch/fileSearch.ts
index 5915821a..db14bc65 100644
--- a/packages/core/src/utils/filesearch/fileSearch.ts
+++ b/packages/core/src/utils/filesearch/fileSearch.ts
@@ -19,6 +19,7 @@ export type FileSearchOptions = {
useGeminiignore: boolean;
cache: boolean;
cacheTtl: number;
+ maxDepth?: number;
};
export class AbortError extends Error {
@@ -215,6 +216,7 @@ export class FileSearch {
const cacheKey = cache.getCacheKey(
this.absoluteDir,
this.ignore.getFingerprint(),
+ this.options.maxDepth,
);
const cachedResults = cache.read(cacheKey);
@@ -230,6 +232,7 @@ export class FileSearch {
const cacheKey = cache.getCacheKey(
this.absoluteDir,
this.ignore.getFingerprint(),
+ this.options.maxDepth,
);
cache.write(cacheKey, this.allFiles, this.options.cacheTtl * 1000);
}
@@ -257,6 +260,10 @@ export class FileSearch {
return dirFilter(`${relativePath}/`);
});
+ if (this.options.maxDepth !== undefined) {
+ api.withMaxDepth(this.options.maxDepth);
+ }
+
return api.crawl(this.absoluteDir).withPromise();
}