* Returns the local agent memory directory, which is project-specific and not checked into VCS. * When CLAUDE_CODE_REMOTE_MEMORY_DIR is set, persists to the mount with project namespacing. * Otherwise, prefers /.ncode/agent-memory-local/ / and * falls back to legacy .claude locatio
(dirName: string)
| 35 | * falls back to legacy .claude locations when they already exist. |
| 36 | */ |
| 37 | function getLocalAgentMemoryDir(dirName: string): string { |
| 38 | if (process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR) { |
| 39 | return ( |
| 40 | join( |
| 41 | process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR, |
| 42 | 'projects', |
| 43 | sanitizePath( |
| 44 | findCanonicalGitRoot(getProjectRoot()) ?? getProjectRoot(), |
| 45 | ), |
| 46 | 'agent-memory-local', |
| 47 | dirName, |
| 48 | ) + sep |
| 49 | ) |
| 50 | } |
| 51 | const canonicalDir = join(getCwd(), '.ncode', 'agent-memory-local', dirName) |
| 52 | const legacyDir = join(getCwd(), '.claude', 'agent-memory-local', dirName) |
| 53 | if (existsSync(canonicalDir)) { |
| 54 | return canonicalDir + sep |
| 55 | } |
| 56 | if (existsSync(legacyDir)) { |
| 57 | return legacyDir + sep |
| 58 | } |
| 59 | return canonicalDir + sep |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns the agent memory directory for a given agent type and scope. |
no test coverage detected