Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/cli/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,18 @@ export async function loadHierarchicalGeminiMemory(
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 resolveRealpath = (p: string) => {
const resolvedPath = path.resolve(p);
try {
return fs.realpathSync(resolvedPath);
} catch {
// Fallback to resolved path if realpathSync fails (e.g., if the path doesn't exist)
return resolvedPath;
}
};

const realCwd = resolveRealpath(currentWorkingDirectory);
const realHome = resolveRealpath(homedir());
const isHomeDirectory = realCwd === realHome;

// If it is the home directory, pass an empty string to the core memory
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
BadRequestError,
UnauthorizedError,
ForbiddenError,
} from './errors';
} from './errors.js';

describe('toFriendlyError', () => {
it('should return the original error if it is not an object', () => {
Expand Down
23 changes: 23 additions & 0 deletions patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- packages/cli/src/config/config.ts
+++ packages/cli/src/config/config.ts
@@ -272,8 +272,18 @@
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 resolveRealpath = (p: string) => {
+ const resolvedPath = path.resolve(p);
+ try {
+ return fs.realpathSync(resolvedPath);
+ } catch {
+ // Fallback to resolved path if realpathSync fails (e.g., if the path doesn't exist)
+ return resolvedPath;
+ }
+ };
+
+ const realCwd = resolveRealpath(currentWorkingDirectory);
+ const realHome = resolveRealpath(homedir());
const isHomeDirectory = realCwd === realHome;

// If it is the home directory, pass an empty string to the core memory