MCPcopy Index your code
hub / github.com/codeaashu/claude-code / processMemoryFile

Function processMemoryFile

src/utils/claudemd.ts:618–685  ·  view source on GitHub ↗
(
  filePath: string,
  type: MemoryType,
  processedPaths: Set<string>,
  includeExternal: boolean,
  depth: number = 0,
  parent?: string,
)

Source from the content-addressed store, hash-verified

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

Callers 3

processMdRulesFunction · 0.85
claudemd.tsFile · 0.85

Calls 9

isClaudeMdExcludedFunction · 0.85
safeResolvePathFunction · 0.85
getFsImplementationFunction · 0.85
pathInOriginalCwdFunction · 0.85
hasMethod · 0.45
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected