summaryrefslogtreecommitdiff
path: root/packages/cli/src/config/config.ts
diff options
context:
space:
mode:
authorTIRUMALASETTI PRANITH <[email protected]>2025-08-02 03:52:17 +0530
committerGitHub <[email protected]>2025-08-01 22:22:17 +0000
commit15a1f1af9d0e4628e9e82f81d384d614899770e3 (patch)
tree19c1c76b177faa5c774f06de2f150a13a03fc57b /packages/cli/src/config/config.ts
parent387706607dfa372f4f0c6fee14286bf4a290b258 (diff)
fix(config): Resolve duplicate config loading from home directory (#5090)
Co-authored-by: Allen Hutchison <[email protected]> Co-authored-by: Allen Hutchison <[email protected]>
Diffstat (limited to 'packages/cli/src/config/config.ts')
-rw-r--r--packages/cli/src/config/config.ts17
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,