diff options
Diffstat (limited to 'packages/cli/src/config/config.ts')
| -rw-r--r-- | packages/cli/src/config/config.ts | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index a147bca8..9274b65e 100644 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -4,6 +4,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +import * as fs from 'fs'; +import * as path from 'path'; +import { homedir } from 'node:os'; import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; import process from 'node:process'; @@ -244,16 +247,24 @@ export async function loadHierarchicalGeminiMemory( memoryImportFormat: 'flat' | 'tree' = 'tree', fileFilteringOptions?: FileFilteringOptions, ): Promise<{ memoryContent: string; fileCount: number }> { + // FIX: Use real, canonical paths for a reliable comparison to handle symlinks. + const realCwd = fs.realpathSync(path.resolve(currentWorkingDirectory)); + const realHome = fs.realpathSync(path.resolve(homedir())); + const isHomeDirectory = realCwd === realHome; + + // If it is the home directory, pass an empty string to the core memory + // function to signal that it should skip the workspace search. + const effectiveCwd = isHomeDirectory ? '' : currentWorkingDirectory; + if (debugMode) { logger.debug( `CLI: Delegating hierarchical memory load to server for CWD: ${currentWorkingDirectory} (memoryImportFormat: ${memoryImportFormat})`, ); } - // Directly call the server function. - // The server function will use its own homedir() for the global path. + // Directly call the server function with the corrected path. return loadServerHierarchicalMemory( - currentWorkingDirectory, + effectiveCwd, debugMode, fileService, extensionContextFilePaths, |
