MCPcopy
hub / github.com/Doorman11991/smallcode / save

Method save

bin/memory.js:78–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76
77 // Save all memory objects to disk
78 save() {
79 if (!fs.existsSync(this.memDir)) {
80 fs.mkdirSync(this.memDir, { recursive: true });
81 }
82 const data = {
83 version: 1,
84 objects: Array.from(this.objects.values()).map(o => o.toJSON()),
85 updatedAt: new Date().toISOString(),
86 };
87 fs.writeFileSync(path.join(this.memDir, 'index.json'), JSON.stringify(data, null, 2));
88
89 // Also write individual markdown files for human review
90 for (const obj of this.objects.values()) {
91 const filename = `${obj.type}-${obj.id}.md`;
92 const md = `# ${obj.title}\n\nType: ${obj.type}\nTags: ${obj.tags.join(', ')}\nCreated: ${obj.createdAt}\n\n${obj.content}\n`;
93 fs.writeFileSync(path.join(this.memDir, filename), md);
94 }
95 }
96
97 // Save/remember a new memory object
98 remember(type, title, content, { tags, source, relations } = {}) {

Callers 6

initMethod · 0.95
rememberMethod · 0.95
forgetMethod · 0.95
runTUIFunction · 0.45
chatCompletionFunction · 0.45
chatCompletionFunction · 0.45

Calls 1

toJSONMethod · 0.45

Tested by

no test coverage detected