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

Function ensureMemoryDirExists

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

Source from the content-addressed store, hash-verified

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

Callers 2

loadAgentMemoryPromptFunction · 0.85
loadMemoryPromptFunction · 0.85

Calls 2

getFsImplementationFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected