MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / execute

Method execute

src/tools/builtin/memory.ts:109–133  ·  view source on GitHub ↗
(args: z.infer<typeof ForgetArgs>, ctx: ToolContext)

Source from the content-addressed store, hash-verified

107 argsSchema = ForgetArgs;
108
109 async execute(args: z.infer<typeof ForgetArgs>, ctx: ToolContext): Promise<ToolResult> {
110 const cwd = ctx.cwd ?? process.cwd();
111 const scope = args.scope ?? 'project';
112 if (!args.fact_contains && !args.all) {
113 return {
114 content: '[FORGET_NEEDS_TARGET] Pass either `fact_contains: "<substring>"` to target specific facts, or `all: true` to clear everything in this scope.',
115 isError: true,
116 };
117 }
118 const store = getSessionStore();
119 const db = (store as any).db as { prepare: (sql: string) => any };
120 // User facts live under the '*' sentinel cwd; project facts under the real cwd.
121 const scopeWhere = scope === 'user' ? `scope = 'user'` : `cwd = ? AND scope = 'project'`;
122 const scopeArgs = scope === 'user' ? [] : [cwd];
123 const label = scope === 'user' ? 'user memory' : cwd;
124 const { exportMemory } = await import('../../context/memory-mirror.js');
125 if (args.all) {
126 const result = db.prepare(`DELETE FROM session_facts WHERE ${scopeWhere}`).run(...scopeArgs);
127 await exportMemory(cwd); // keep the MEMORY.md mirror in sync
128 return { content: `Forgot ${result.changes} fact(s) from ${label}.` };
129 }
130 const result = db.prepare(`DELETE FROM session_facts WHERE ${scopeWhere} AND fact LIKE ?`).run(...scopeArgs, `%${args.fact_contains}%`);
131 await exportMemory(cwd); // keep the MEMORY.md mirror in sync
132 return { content: `Forgot ${result.changes} fact(s) matching "${args.fact_contains}" from ${label}.` };
133 }
134}

Callers

nothing calls this directly

Calls 3

getSessionStoreFunction · 0.85
exportMemoryFunction · 0.85
runMethod · 0.65

Tested by

no test coverage detected