MCPcopy
hub / github.com/codeaashu/claude-code / ensureMemoryDirExists

Function ensureMemoryDirExists

src/memdir/memdir.ts:129–147  ·  view source on GitHub ↗
(memoryDir: string)

Source from the content-addressed store, hash-verified

127 * try/catch needed for the happy path.
128 */
129export async function ensureMemoryDirExists(memoryDir: string): Promise<void> {
130 const fs = getFsImplementation()
131 try {
132 await fs.mkdir(memoryDir)
133 } catch (e) {
134 // fs.mkdir already handles EEXIST internally. Anything reaching here is
135 // a real problem (EACCES/EPERM/EROFS) — log so --debug shows why. Prompt
136 // building continues either way; the model's Write will surface the
137 // real perm error (and FileWriteTool does its own mkdir of the parent).
138 const code =
139 e instanceof Error && 'code' in e && typeof e.code === 'string'
140 ? e.code
141 : undefined
142 logForDebugging(
143 `ensureMemoryDirExists failed for ${memoryDir}: ${code ?? String(e)}`,
144 { level: 'debug' },
145 )
146 }
147}
148
149/**
150 * Log memory directory file/subdir counts asynchronously.

Callers 2

loadAgentMemoryPromptFunction · 0.85
loadMemoryPromptFunction · 0.85

Calls 2

getFsImplementationFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected