@hasna/mementos 0.10.18 → 0.10.19

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.
Files changed (2) hide show
  1. package/dist/mcp/index.js +56 -0
  2. package/package.json +1 -1
package/dist/mcp/index.js CHANGED
@@ -9937,6 +9937,62 @@ server.tool("memory_health", "Comprehensive health check for memories. Detects:
9937
9937
  return { content: [{ type: "text", text: formatError(e) }], isError: true };
9938
9938
  }
9939
9939
  });
9940
+ server.tool("memory_diff", "Show what changed between two versions of a memory. Compares value, importance, scope. Omit v1/v2 to diff the two most recent versions.", {
9941
+ id: exports_external.string().optional().describe("Memory ID or partial ID"),
9942
+ key: exports_external.string().optional().describe("Memory key (alternative to id)"),
9943
+ v1: exports_external.coerce.number().optional().describe("First version number (default: second-to-last)"),
9944
+ v2: exports_external.coerce.number().optional().describe("Second version number (default: current/latest)")
9945
+ }, async (args) => {
9946
+ try {
9947
+ let memId;
9948
+ if (args.id) {
9949
+ memId = resolvePartialId(getDatabase(), "memories", args.id) ?? args.id;
9950
+ } else if (args.key) {
9951
+ const row = getDatabase().query("SELECT id FROM memories WHERE key = ? LIMIT 1").get(args.key);
9952
+ memId = row?.id;
9953
+ }
9954
+ if (!memId)
9955
+ return { content: [{ type: "text", text: `Memory not found: ${args.id || args.key}` }], isError: true };
9956
+ const memory = getMemory(memId);
9957
+ if (!memory)
9958
+ return { content: [{ type: "text", text: `Memory not found: ${memId}` }], isError: true };
9959
+ const versions = getMemoryVersions(memId);
9960
+ const allVersions = [
9961
+ ...versions,
9962
+ { version: memory.version, value: memory.value, importance: memory.importance, scope: memory.scope, created_at: memory.updated_at, summary: memory.summary }
9963
+ ].sort((a, b) => a.version - b.version);
9964
+ if (allVersions.length < 2) {
9965
+ return { content: [{ type: "text", text: `Only 1 version exists for "${memory.key}". No diff available.` }] };
9966
+ }
9967
+ const v1Num = args.v1 ?? allVersions[allVersions.length - 2]?.version ?? 1;
9968
+ const v2Num = args.v2 ?? allVersions[allVersions.length - 1]?.version ?? memory.version;
9969
+ const ver1 = allVersions.find((v) => v.version === v1Num);
9970
+ const ver2 = allVersions.find((v) => v.version === v2Num);
9971
+ if (!ver1 || !ver2) {
9972
+ return { content: [{ type: "text", text: `Versions not found: v${v1Num}, v${v2Num}. Available: ${allVersions.map((v) => `v${v.version}`).join(", ")}` }], isError: true };
9973
+ }
9974
+ const parts = [`Diff for "${memory.key}" (v${v1Num} \u2192 v${v2Num})`];
9975
+ parts.push(`Time: ${ver1.created_at?.slice(0, 16)} \u2192 ${ver2.created_at?.slice(0, 16)}`);
9976
+ if (ver1.value !== ver2.value) {
9977
+ parts.push(`
9978
+ --- v${v1Num} value ---`);
9979
+ parts.push(ver1.value.slice(0, 500) + (ver1.value.length > 500 ? "..." : ""));
9980
+ parts.push(`
9981
+ +++ v${v2Num} value +++`);
9982
+ parts.push(ver2.value.slice(0, 500) + (ver2.value.length > 500 ? "..." : ""));
9983
+ } else {
9984
+ parts.push("value: unchanged");
9985
+ }
9986
+ if (ver1.importance !== ver2.importance)
9987
+ parts.push(`importance: ${ver1.importance} \u2192 ${ver2.importance}`);
9988
+ if (ver1.scope !== ver2.scope)
9989
+ parts.push(`scope: ${ver1.scope} \u2192 ${ver2.scope}`);
9990
+ return { content: [{ type: "text", text: parts.join(`
9991
+ `) }] };
9992
+ } catch (e) {
9993
+ return { content: [{ type: "text", text: formatError(e) }], isError: true };
9994
+ }
9995
+ });
9940
9996
  server.tool("memory_search", "Search memories by keyword across key, value, summary, and tags", {
9941
9997
  query: exports_external.string(),
9942
9998
  scope: exports_external.enum(["global", "shared", "private"]).optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.10.18",
3
+ "version": "0.10.19",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",