( filePath: string, type: MemoryType, processedPaths: Set<string>, includeExternal: boolean, depth: number = 0, parent?: string, )
| 618 | * Returns an array of MemoryFileInfo objects with includes first, then main file |
| 619 | */ |
| 620 | export async function processMemoryFile( |
| 621 | filePath: string, |
| 622 | type: MemoryType, |
| 623 | processedPaths: Set<string>, |
| 624 | includeExternal: boolean, |
| 625 | depth: number = 0, |
| 626 | parent?: string, |
| 627 | ): Promise<MemoryFileInfo[]> { |
| 628 | // Skip if already processed or max depth exceeded. |
| 629 | // Normalize paths for comparison to handle Windows drive letter casing |
| 630 | // differences (e.g., C:\Users vs c:\Users). |
| 631 | const normalizedPath = normalizePathForComparison(filePath) |
| 632 | if (processedPaths.has(normalizedPath) || depth >= MAX_INCLUDE_DEPTH) { |
| 633 | return [] |
| 634 | } |
| 635 | |
| 636 | // Skip if path is excluded by claudeMdExcludes setting |
| 637 | if (isClaudeMdExcluded(filePath, type)) { |
| 638 | return [] |
| 639 | } |
| 640 | |
| 641 | // Resolve symlink path early for @import resolution |
| 642 | const { resolvedPath, isSymlink } = safeResolvePath( |
| 643 | getFsImplementation(), |
| 644 | filePath, |
| 645 | ) |
| 646 | |
| 647 | processedPaths.add(normalizedPath) |
| 648 | if (isSymlink) { |
| 649 | processedPaths.add(normalizePathForComparison(resolvedPath)) |
| 650 | } |
| 651 | |
| 652 | const { info: memoryFile, includePaths: resolvedIncludePaths } = |
| 653 | await safelyReadMemoryFileAsync(filePath, type, resolvedPath) |
| 654 | if (!memoryFile || !memoryFile.content.trim()) { |
| 655 | return [] |
| 656 | } |
| 657 | |
| 658 | // Add parent information |
| 659 | if (parent) { |
| 660 | memoryFile.parent = parent |
| 661 | } |
| 662 | |
| 663 | const result: MemoryFileInfo[] = [] |
| 664 | |
| 665 | // Add the main file first (parent before children) |
| 666 | result.push(memoryFile) |
| 667 | |
| 668 | for (const resolvedIncludePath of resolvedIncludePaths) { |
| 669 | const isExternal = !pathInOriginalCwd(resolvedIncludePath) |
| 670 | if (isExternal && !includeExternal) { |
| 671 | continue |
| 672 | } |
| 673 | |
| 674 | // Recursively process included files with this file as parent |
| 675 | const includedFiles = await processMemoryFile( |
| 676 | resolvedIncludePath, |
| 677 | type, |
no test coverage detected