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

Function safelyReadMemoryFileAsync

src/utils/claudemd.ts:424–437  ·  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

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