diff options
| author | Niladri Das <[email protected]> | 2025-07-31 22:06:50 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-31 16:36:50 +0000 |
| commit | 9a6422f331294ea2f56d67599ed142d09cc33320 (patch) | |
| tree | 16f3e58fc1ce3b6de88082dd4bb194a6635bafac /packages/core/src/utils/memoryDiscovery.ts | |
| parent | ae86c7ba05567264ca2d115a7f96d887bc576457 (diff) | |
fix: CLAUDE.md compatibility for GEMINI.md '@' file import behavior (#2978)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Allen Hutchison <[email protected]>
Diffstat (limited to 'packages/core/src/utils/memoryDiscovery.ts')
| -rw-r--r-- | packages/core/src/utils/memoryDiscovery.ts | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/packages/core/src/utils/memoryDiscovery.ts b/packages/core/src/utils/memoryDiscovery.ts index 88c82373..a673a75e 100644 --- a/packages/core/src/utils/memoryDiscovery.ts +++ b/packages/core/src/utils/memoryDiscovery.ts @@ -43,7 +43,7 @@ async function findProjectRoot(startDir: string): Promise<string | null> { while (true) { const gitPath = path.join(currentDir, '.git'); try { - const stats = await fs.stat(gitPath); + const stats = await fs.lstat(gitPath); if (stats.isDirectory()) { return currentDir; } @@ -230,6 +230,7 @@ async function getGeminiMdFilePathsInternal( async function readGeminiMdFiles( filePaths: string[], debugMode: boolean, + importFormat: 'flat' | 'tree' = 'tree', ): Promise<GeminiFileContent[]> { const results: GeminiFileContent[] = []; for (const filePath of filePaths) { @@ -237,16 +238,19 @@ async function readGeminiMdFiles( const content = await fs.readFile(filePath, 'utf-8'); // Process imports in the content - const processedContent = await processImports( + const processedResult = await processImports( content, path.dirname(filePath), debugMode, + undefined, + undefined, + importFormat, ); - results.push({ filePath, content: processedContent }); + results.push({ filePath, content: processedResult.content }); if (debugMode) logger.debug( - `Successfully read and processed imports: ${filePath} (Length: ${processedContent.length})`, + `Successfully read and processed imports: ${filePath} (Length: ${processedResult.content.length})`, ); } catch (error: unknown) { const isTestEnv = process.env.NODE_ENV === 'test' || process.env.VITEST; @@ -293,12 +297,13 @@ export async function loadServerHierarchicalMemory( debugMode: boolean, fileService: FileDiscoveryService, extensionContextFilePaths: string[] = [], + importFormat: 'flat' | 'tree' = 'tree', fileFilteringOptions?: FileFilteringOptions, maxDirs: number = 200, ): Promise<{ memoryContent: string; fileCount: number }> { if (debugMode) logger.debug( - `Loading server hierarchical memory for CWD: ${currentWorkingDirectory}`, + `Loading server hierarchical memory for CWD: ${currentWorkingDirectory} (importFormat: ${importFormat})`, ); // For the server, homedir() refers to the server process's home. @@ -317,7 +322,11 @@ export async function loadServerHierarchicalMemory( if (debugMode) logger.debug('No GEMINI.md files found in hierarchy.'); return { memoryContent: '', fileCount: 0 }; } - const contentsWithPaths = await readGeminiMdFiles(filePaths, debugMode); + const contentsWithPaths = await readGeminiMdFiles( + filePaths, + debugMode, + importFormat, + ); // Pass CWD for relative path display in concatenated content const combinedInstructions = concatenateInstructions( contentsWithPaths, |
