MCPcopy Create free account
hub / github.com/MarsWang42/Awel / addMemory

Function addMemory

packages/cli/src/memory.ts:40–59  ·  view source on GitHub ↗
(
    projectCwd: string,
    opts: { content: string; tags: string[]; scope: 'always' | 'contextual'; source: 'user' | 'agent' }
)

Source from the content-addressed store, hash-verified

38}
39
40export function addMemory(
41 projectCwd: string,
42 opts: { content: string; tags: string[]; scope: 'always' | 'contextual'; source: 'user' | 'agent' }
43): MemoryEntry {
44 const entries = readMemories(projectCwd);
45 const now = new Date().toISOString();
46 const entry: MemoryEntry = {
47 id: randomUUID(),
48 content: opts.content,
49 tags: opts.tags,
50 scope: opts.scope,
51 source: opts.source,
52 createdAt: now,
53 usageCount: 0,
54 lastUsedAt: now,
55 };
56 entries.push(entry);
57 writeMemories(projectCwd, entries);
58 return entry;
59}
60
61export function deleteMemory(projectCwd: string, id: string): boolean {
62 const entries = readMemories(projectCwd);

Callers 1

createMemoryToolFunction · 0.85

Calls 2

readMemoriesFunction · 0.85
writeMemoriesFunction · 0.85

Tested by

no test coverage detected