cc-claw 0.24.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/mcp-server.js +31 -2
- package/dist/cli.js +10593 -9427
- package/package.json +2 -2
|
@@ -335,10 +335,11 @@ server.tool(
|
|
|
335
335
|
\u2022 forget \u2014 Delete memories by keyword match or specific ID.
|
|
336
336
|
\u2022 history \u2014 Search raw conversation history by keyword (message_log table).
|
|
337
337
|
\u2022 summaries \u2014 Search session summaries (episodic layer). Use this to find work done in past sessions, story drafts, analysis results, or anything captured in session summaries but not explicitly tagged.
|
|
338
|
+
\u2022 optimize \u2014 Analyze memories for duplicates, mergeable entries, and stale content. Returns suggestions. Set apply=true to auto-apply all suggestions.
|
|
338
339
|
|
|
339
340
|
IMPORTANT: Always use this tool for memories. Do NOT save to your own memory files.`,
|
|
340
341
|
{
|
|
341
|
-
action: z.enum(["remember", "recall", "list", "forget", "history", "summaries"]).describe("Action to perform"),
|
|
342
|
+
action: z.enum(["remember", "recall", "list", "forget", "history", "summaries", "optimize"]).describe("Action to perform"),
|
|
342
343
|
// remember params
|
|
343
344
|
tag: z.string().optional().describe("Memory tag / trigger phrase"),
|
|
344
345
|
content: z.string().optional().describe("Memory content to save"),
|
|
@@ -349,7 +350,11 @@ IMPORTANT: Always use this tool for memories. Do NOT save to your own memory fil
|
|
|
349
350
|
keyword: z.string().optional().describe("Keyword to match for deletion"),
|
|
350
351
|
memoryId: z.number().optional().describe("Specific memory ID to delete"),
|
|
351
352
|
// history params
|
|
352
|
-
chatId: z.string().optional().describe("Chat ID for history search")
|
|
353
|
+
chatId: z.string().optional().describe("Chat ID for history search"),
|
|
354
|
+
// optimize params
|
|
355
|
+
backendId: z.string().optional().describe("Backend to use for analysis (e.g., claude, gemini, ollama)"),
|
|
356
|
+
model: z.string().optional().describe("Model to use for analysis"),
|
|
357
|
+
apply: z.boolean().optional().describe("If true, apply all suggestions automatically")
|
|
353
358
|
},
|
|
354
359
|
async (params) => {
|
|
355
360
|
try {
|
|
@@ -418,6 +423,30 @@ IMPORTANT: Always use this tool for memories. Do NOT save to your own memory fil
|
|
|
418
423
|
);
|
|
419
424
|
return ok(lines.join("\n\n---\n\n"));
|
|
420
425
|
}
|
|
426
|
+
case "optimize": {
|
|
427
|
+
const endpoint = params.apply ? "/api/memory/optimize/apply" : "/api/memory/optimize";
|
|
428
|
+
const result = await callApi(endpoint, {
|
|
429
|
+
chatId: params.chatId ?? CHAT_ID,
|
|
430
|
+
backendId: params.backendId,
|
|
431
|
+
model: params.model
|
|
432
|
+
});
|
|
433
|
+
if (params.apply) {
|
|
434
|
+
if (result.applied === 0) return ok("No optimization suggestions found \u2014 memories are already well-optimized.");
|
|
435
|
+
const lines2 = (result.suggestions ?? []).map(
|
|
436
|
+
(s) => `${s.type}: ${s.reason} (IDs: ${s.memoryIds.join(", ")})`
|
|
437
|
+
);
|
|
438
|
+
return ok(`Applied ${result.applied} optimization(s):
|
|
439
|
+
${lines2.join("\n")}`);
|
|
440
|
+
}
|
|
441
|
+
if (!result.suggestions?.length) return ok("No optimization suggestions \u2014 memories are already well-optimized.");
|
|
442
|
+
const lines = result.suggestions.map(
|
|
443
|
+
(s, i) => `${i + 1}. [${s.type}] ${s.reason} (IDs: ${s.memoryIds.join(", ")})`
|
|
444
|
+
);
|
|
445
|
+
return ok(`Found ${result.suggestions.length} suggestion(s):
|
|
446
|
+
${lines.join("\n")}
|
|
447
|
+
|
|
448
|
+
Call optimize with apply=true to apply all.`);
|
|
449
|
+
}
|
|
421
450
|
}
|
|
422
451
|
} catch (err) {
|
|
423
452
|
return fail(`cc_claw_memory.${params.action} failed: ${err instanceof Error ? err.message : String(err)}`);
|