From aab850668c99e1c39a55036069d9f4b06ca458f4 Mon Sep 17 00:00:00 2001 From: Bryant Chandler Date: Tue, 5 Aug 2025 23:33:27 -0700 Subject: feat(file-search): Add support for non-recursive file search (#5648) Co-authored-by: Jacob Richman --- packages/core/src/utils/filesearch/fileSearch.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'packages/core/src/utils/filesearch/fileSearch.ts') 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(); } -- cgit v1.2.3