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

Function copySnapshotToLocal

src/tools/AgentTool/agentMemorySnapshot.ts:56–77  ·  view source on GitHub ↗
(
  agentType: string,
  scope: AgentMemoryScope,
)

Source from the content-addressed store, hash-verified

54}
55
56async function copySnapshotToLocal(
57 agentType: string,
58 scope: AgentMemoryScope,
59): Promise<void> {
60 const snapshotMemDir = getSnapshotDirForAgent(agentType)
61 const localMemDir = getAgentMemoryDir(agentType, scope)
62
63 await mkdir(localMemDir, { recursive: true })
64
65 try {
66 const files = await readdir(snapshotMemDir, { withFileTypes: true })
67 for (const dirent of files) {
68 if (!dirent.isFile() || dirent.name === SNAPSHOT_JSON) continue
69 const content = await readFile(join(snapshotMemDir, dirent.name), {
70 encoding: 'utf-8',
71 })
72 await writeFile(join(localMemDir, dirent.name), content)
73 }
74 } catch (e) {
75 logForDebugging(`Failed to copy snapshot to local agent memory: ${e}`)
76 }
77}
78
79async function saveSyncedMeta(
80 agentType: string,

Callers 2

initializeFromSnapshotFunction · 0.85
replaceFromSnapshotFunction · 0.85

Calls 6

getSnapshotDirForAgentFunction · 0.85
getAgentMemoryDirFunction · 0.85
mkdirFunction · 0.85
readdirFunction · 0.85
readFileFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected