MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / safelyReadMemoryFileAsync

Function safelyReadMemoryFileAsync

source code/utils/claudemd.ts:426–439  ·  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

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