MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getDirectoriesToProcess

Function getDirectoriesToProcess

source code/utils/attachments.ts:1658–1691  ·  view source on GitHub ↗
(
  targetPath: string,
  originalCwd: string,
)

Source from the content-addressed store, hash-verified

1656 * @returns Object with nestedDirs and cwdLevelDirs arrays, both ordered from parent to child
1657 */
1658export function getDirectoriesToProcess(
1659 targetPath: string,
1660 originalCwd: string,
1661): { nestedDirs: string[]; cwdLevelDirs: string[] } {
1662 // Build list of directories from original CWD to targetPath's directory
1663 const targetDir = dirname(resolve(targetPath))
1664 const nestedDirs: string[] = []
1665 let currentDir = targetDir
1666
1667 // Walk up from target directory to original CWD
1668 while (currentDir !== originalCwd && currentDir !== parse(currentDir).root) {
1669 if (currentDir.startsWith(originalCwd)) {
1670 nestedDirs.push(currentDir)
1671 }
1672 currentDir = dirname(currentDir)
1673 }
1674
1675 // Reverse to get order from CWD down to target
1676 nestedDirs.reverse()
1677
1678 // Build list of directories from root to CWD (for conditional rules only)
1679 const cwdLevelDirs: string[] = []
1680 currentDir = originalCwd
1681
1682 while (currentDir !== parse(currentDir).root) {
1683 cwdLevelDirs.push(currentDir)
1684 currentDir = dirname(currentDir)
1685 }
1686
1687 // Reverse to get order from root to CWD
1688 cwdLevelDirs.reverse()
1689
1690 return { nestedDirs, cwdLevelDirs }
1691}
1692
1693/**
1694 * Converts memory files to attachments, filtering out already-loaded files.

Callers 1

Calls 2

parseFunction · 0.85
resolveFunction · 0.70

Tested by

no test coverage detected