Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opencode-supermemory",
"version": "2.1.0",
"version": "2.1.1",
"description": "OpenCode plugin that gives coding agents persistent memory using Supermemory",
"type": "module",
"main": "dist/index.js",
Expand Down
24 changes: 24 additions & 0 deletions src/services/memory-tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,28 @@ describe("shared supermemory tool", () => {
expect(result.success).toBe(true);
expect(containers).toEqual([tags.canonical, "legacy_user"]);
});

test("list shows each document's content when v5 has no summary", async () => {
const result = JSON.parse(
await executeSupermemoryTool({ mode: "list" }, tags, {
configured: true,
memoryClient: client({
listMemoriesScoped: async () => ({
success: true,
memories: [
{ id: "doc_1", summary: null, content: "Use bun for builds", title: "Bun" },
{ id: "doc_2", summary: "Legacy summary", content: "raw" },
{ id: "doc_3", summary: null, title: "Still processing" },
],
pagination: { currentPage: 1, totalItems: 3, totalPages: 1 },
}),
} as Partial<MemoryToolClient>),
}),
);
expect(result.memories.map((memory: { content: string }) => memory.content)).toEqual([
"Use bun for builds",
"Legacy summary",
"Still processing",
]);
});
});
2 changes: 1 addition & 1 deletion src/services/memory-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export async function executeSupermemoryTool(
count: memories.length,
memories: memories.map((memory) => ({
id: memory.id,
content: memory.summary,
content: memory.summary || memory.content || memory.title || null,
createdAt: memory.createdAt,
metadata: memory.metadata,
})),
Expand Down
42 changes: 42 additions & 0 deletions src/services/v5-client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { describe, expect, test } from "bun:test";

import { V5Client } from "./v5-client.js";

function clientWithDocument(metadata: Record<string, unknown>) {
const client = new V5Client("sm_test", "http://127.0.0.1:9", {
update: async () => ({}),
}, 5_000);
(client as unknown as { sdk: unknown }).sdk = {
list: async () => ({
documents: [
{ id: "doc_1", title: "Bun", summary: null, system: { status: "done", createdAt: "2026-10-01T00:00:00Z" } },
],
pagination: { currentPage: 1, totalItems: 1, totalPages: 1 },
}),
documents: {
get: async () => ({ id: "doc_1", content: "Use bun for builds", metadata }),
},
};
return client;
}

const projectScope = {
containerTags: ["repo_test__0123456789abcdef"],
filters: { AND: [{ key: "sm_scope", value: "project", filterType: "metadata" as const }] },
limit: 20,
order: "desc" as const,
sort: "createdAt" as const,
includeContent: true,
};

describe("V5Client document list", () => {
test("hydrates content when the read omits reserved sm_* keys", async () => {
const result = await clientWithDocument({ type: "preference" }).memories.list(projectScope);
expect(result.memories[0]).toMatchObject({ id: "doc_1", content: "Use bun for builds" });
});

test("skips content when the document states another scope", async () => {
const result = await clientWithDocument({ sm_scope: "personal" }).memories.list(projectScope);
expect(result.memories[0]?.content).toBeUndefined();
});
});
11 changes: 7 additions & 4 deletions src/services/v5-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,17 @@ export class V5Client {
}, remainingMs);
}),
]);
// The list already filtered by scope and reads omit sm_* keys, so only a stated mismatch is wrong.
const scopeMatches =
request.filters?.AND.every(({ key, value }) => {
const actual = document.metadata?.[key];
return actual === undefined || actual === value;
}) ?? true;
if (
document.id === item.id &&
(typeof document.content === "string" ||
document.content === null) &&
(request.filters?.AND.every(
({ key, value }) => document.metadata?.[key] === value,
) ??
true)
scopeMatches
) {
content = document.content;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// AUTO-GENERATED by scripts/sync-version.mjs — do not edit by hand.
// Sourced from package.json "version" so the two cannot drift.
export const PLUGIN_VERSION = "2.1.0";
export const PLUGIN_VERSION = "2.1.1";
Loading