MCPcopy Create free account
hub / github.com/Noumena-Network/code / getLocalAgentMemoryDir

Function getLocalAgentMemoryDir

src/tools/AgentTool/agentMemory.ts:37–60  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

35 * falls back to legacy .claude locations when they already exist.
36 */
37function 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.

Callers 1

getAgentMemoryDirFunction · 0.85

Calls 4

existsSyncFunction · 0.90
getProjectRootFunction · 0.85
getCwdFunction · 0.85
sanitizePathFunction · 0.50

Tested by

no test coverage detected