* Checks whether a CLAUDE.md file path is excluded by the claudeMdExcludes setting. * Only applies to User, Project, and Local memory types. * Managed, AutoMem, and TeamMem types are never excluded. * * Matches both the original path and the realpath-resolved path to handle symlinks * (e.g., /t
(filePath: string, type: MemoryType)
| 545 | * (e.g., /tmp -> /private/tmp on macOS). |
| 546 | */ |
| 547 | function isClaudeMdExcluded(filePath: string, type: MemoryType): boolean { |
| 548 | if (type !== 'User' && type !== 'Project' && type !== 'Local') { |
| 549 | return false |
| 550 | } |
| 551 | |
| 552 | const patterns = getInitialSettings().claudeMdExcludes |
| 553 | if (!patterns || patterns.length === 0) { |
| 554 | return false |
| 555 | } |
| 556 | |
| 557 | const matchOpts = { dot: true } |
| 558 | const normalizedPath = filePath.replaceAll('\\', '/') |
| 559 | |
| 560 | // Build an expanded pattern list that includes realpath-resolved versions of |
| 561 | // absolute patterns. This handles symlinks like /tmp -> /private/tmp on macOS: |
| 562 | // the user writes "/tmp/project/CLAUDE.md" in their exclude, but the system |
| 563 | // resolves the CWD to "/private/tmp/project/...", so the file path uses the |
| 564 | // real path. By resolving the patterns too, both sides match. |
| 565 | const expandedPatterns = resolveExcludePatterns(patterns).filter( |
| 566 | p => p.length > 0, |
| 567 | ) |
| 568 | if (expandedPatterns.length === 0) { |
| 569 | return false |
| 570 | } |
| 571 | |
| 572 | return picomatch.isMatch(normalizedPath, expandedPatterns, matchOpts) |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Expands exclude patterns by resolving symlinks in absolute path prefixes. |
no test coverage detected