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: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:

- run: bun run typecheck

- run: bun test

- run: bun run build

- run: npm publish --access public
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"opencode-supermemory": "./dist/cli.js"
},
"scripts": {
"test": "bun test",
"build": "bun build ./src/index.ts --outdir ./dist --target node && bun build ./src/cli.ts --outfile ./dist/cli.js --target node && tsc --emitDeclarationOnly",
"dev": "tsc --watch",
"typecheck": "tsc --noEmit"
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { formatContextForPrompt } from "./services/context.js";
import { getTags } from "./services/tags.js";
import { stripPrivateContent, isFullyPrivate } from "./services/privacy.js";
import { createCompactionHook, type CompactionContext } from "./services/compaction.js";
import { createSyntheticPartId } from "./services/part-id.js";

import { isConfigured, CONFIG } from "./config.js";
import { log } from "./services/logger.js";
Expand Down Expand Up @@ -112,7 +113,7 @@ export const SupermemoryPlugin: Plugin = async (ctx: PluginInput) => {
if (detectMemoryKeyword(userMessage)) {
log("chat.message: memory keyword detected");
const nudgePart: Part = {
id: `prt_supermemory-nudge-${Date.now()}`,
id: createSyntheticPartId("nudge"),
sessionID: input.sessionID,
messageID: output.message.id,
type: "text",
Expand Down Expand Up @@ -157,7 +158,7 @@ export const SupermemoryPlugin: Plugin = async (ctx: PluginInput) => {

if (memoryContext) {
const contextPart: Part = {
id: `prt_supermemory-context-${Date.now()}`,
id: createSyntheticPartId("context"),
sessionID: input.sessionID,
messageID: output.message.id,
type: "text",
Expand Down
13 changes: 13 additions & 0 deletions src/services/part-id.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, test } from "bun:test";

import { createSyntheticPartId } from "./part-id.js";

describe("createSyntheticPartId", () => {
test("generates prt-prefixed context ids compatible with current OpenCode schema", () => {
expect(createSyntheticPartId("context", 1234567890)).toBe("prt_supermemory-context-1234567890");
});

test("generates prt-prefixed nudge ids compatible with current OpenCode schema", () => {
expect(createSyntheticPartId("nudge", 1234567890)).toBe("prt_supermemory-nudge-1234567890");
});
});
3 changes: 3 additions & 0 deletions src/services/part-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function createSyntheticPartId(kind: "context" | "nudge", now = Date.now()): string {
return `prt_supermemory-${kind}-${now}`;
}