MCPcopy
hub / github.com/claude-code-best/claude-code / safelyReadMemoryFileAsync

Function safelyReadMemoryFileAsync

src/utils/claudemd.ts:423–436  ·  view source on GitHub ↗

* Used by processMemoryFile → getMemoryFiles so the event loop stays * responsive during the directory walk (many readFile attempts, most * ENOENT). When includeBasePath is given, @include paths are resolved in * the same lex pass and returned alongside the parsed file.

(
  filePath: string,
  type: MemoryType,
  includeBasePath?: string,
)

Source from the content-addressed store, hash-verified

421 * the same lex pass and returned alongside the parsed file.
422 */
423async function safelyReadMemoryFileAsync(
424 filePath: string,
425 type: MemoryType,
426 includeBasePath?: string,
427): Promise<{ info: MemoryFileInfo | null; includePaths: string[] }> {
428 try {
429 const fs = getFsImplementation()
430 const rawContent = await fs.readFile(filePath, { encoding: 'utf-8' })
431 return parseMemoryFileContent(rawContent, filePath, type, includeBasePath)
432 } catch (error) {
433 handleMemoryFileReadError(error, filePath)
434 return { info: null, includePaths: [] }
435 }
436}
437
438type MarkdownToken = {
439 type: string

Callers 2

processMemoryFileFunction · 0.85
claudemd.tsFile · 0.85

Calls 4

getFsImplementationFunction · 0.85
parseMemoryFileContentFunction · 0.85
readFileMethod · 0.80

Tested by

no test coverage detected