summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/memoryDiscovery.ts
diff options
context:
space:
mode:
authorYuki Okita <[email protected]>2025-08-06 02:01:01 +0900
committerGitHub <[email protected]>2025-08-05 17:01:01 +0000
commit5c8268b6f44e96ef1975999baac71c022875c321 (patch)
treedc9d98a133358b85fac5af5daf3d1c48690093ce /packages/core/src/utils/memoryDiscovery.ts
parentd0cda58f1fc23daa1d69f782c5ab9593b30217cb (diff)
feat: Multi-Directory Workspace Support (part 3: configuration in settings.json) (#5354)
Co-authored-by: Allen Hutchison <[email protected]>
Diffstat (limited to 'packages/core/src/utils/memoryDiscovery.ts')
-rw-r--r--packages/core/src/utils/memoryDiscovery.ts39
1 files changed, 36 insertions, 3 deletions
diff --git a/packages/core/src/utils/memoryDiscovery.ts b/packages/core/src/utils/memoryDiscovery.ts
index 323b13c5..f53d27a9 100644
--- a/packages/core/src/utils/memoryDiscovery.ts
+++ b/packages/core/src/utils/memoryDiscovery.ts
@@ -83,6 +83,36 @@ async function findProjectRoot(startDir: string): Promise<string | null> {
async function getGeminiMdFilePathsInternal(
currentWorkingDirectory: string,
+ includeDirectoriesToReadGemini: readonly string[],
+ userHomePath: string,
+ debugMode: boolean,
+ fileService: FileDiscoveryService,
+ extensionContextFilePaths: string[] = [],
+ fileFilteringOptions: FileFilteringOptions,
+ maxDirs: number,
+): Promise<string[]> {
+ const dirs = new Set<string>([
+ ...includeDirectoriesToReadGemini,
+ currentWorkingDirectory,
+ ]);
+ const paths = [];
+ for (const dir of dirs) {
+ const pathsByDir = await getGeminiMdFilePathsInternalForEachDir(
+ dir,
+ userHomePath,
+ debugMode,
+ fileService,
+ extensionContextFilePaths,
+ fileFilteringOptions,
+ maxDirs,
+ );
+ paths.push(...pathsByDir);
+ }
+ return Array.from(new Set<string>(paths));
+}
+
+async function getGeminiMdFilePathsInternalForEachDir(
+ dir: string,
userHomePath: string,
debugMode: boolean,
fileService: FileDiscoveryService,
@@ -115,8 +145,8 @@ async function getGeminiMdFilePathsInternal(
// FIX: Only perform the workspace search (upward and downward scans)
// if a valid currentWorkingDirectory is provided.
- if (currentWorkingDirectory) {
- const resolvedCwd = path.resolve(currentWorkingDirectory);
+ if (dir) {
+ const resolvedCwd = path.resolve(dir);
if (debugMode)
logger.debug(
`Searching for ${geminiMdFilename} starting from CWD: ${resolvedCwd}`,
@@ -257,6 +287,7 @@ function concatenateInstructions(
*/
export async function loadServerHierarchicalMemory(
currentWorkingDirectory: string,
+ includeDirectoriesToReadGemini: readonly string[],
debugMode: boolean,
fileService: FileDiscoveryService,
extensionContextFilePaths: string[] = [],
@@ -274,6 +305,7 @@ export async function loadServerHierarchicalMemory(
const userHomePath = homedir();
const filePaths = await getGeminiMdFilePathsInternal(
currentWorkingDirectory,
+ includeDirectoriesToReadGemini,
userHomePath,
debugMode,
fileService,
@@ -282,7 +314,8 @@ export async function loadServerHierarchicalMemory(
maxDirs,
);
if (filePaths.length === 0) {
- if (debugMode) logger.debug('No GEMINI.md files found in hierarchy.');
+ if (debugMode)
+ logger.debug('No GEMINI.md files found in hierarchy of the workspace.');
return { memoryContent: '', fileCount: 0 };
}
const contentsWithPaths = await readGeminiMdFiles(