opencode-supermemory 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -9,7 +9,7 @@ Your agent remembers what you tell it - across sessions, across projects.
9
9
  ### For Humans
10
10
 
11
11
  ```bash
12
- bunx opencode-supermemory install
12
+ bunx opencode-supermemory@latest install
13
13
  ```
14
14
 
15
15
  Then get your API key from [console.supermemory.ai](https://console.supermemory.ai) and set it:
@@ -33,7 +33,7 @@ If you're an LLM agent helping set up opencode-supermemory, follow these steps:
33
33
  #### Step 1: Run the installer
34
34
 
35
35
  ```bash
36
- bunx opencode-supermemory install --no-tui
36
+ bunx opencode-supermemory@latest install --no-tui
37
37
  ```
38
38
 
39
39
  This will:
@@ -228,7 +228,7 @@ Add to `~/.config/opencode/oh-my-opencode.json`:
228
228
 
229
229
  ```json
230
230
  {
231
- "disabled_hooks": ["anthropic-auto-compact"]
231
+ "disabled_hooks": ["anthropic-context-window-limit-recovery"]
232
232
  }
233
233
  ```
234
234
 
package/dist/cli.js CHANGED
@@ -5,9 +5,83 @@ import { mkdirSync, writeFileSync, readFileSync, existsSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { homedir } from "node:os";
7
7
  import * as readline from "node:readline";
8
+
9
+ // src/services/jsonc.ts
10
+ function stripJsoncComments(content) {
11
+ let result = "";
12
+ let i = 0;
13
+ let inString = false;
14
+ let inSingleLineComment = false;
15
+ let inMultiLineComment = false;
16
+ while (i < content.length) {
17
+ const char = content[i];
18
+ const nextChar = content[i + 1];
19
+ if (!inSingleLineComment && !inMultiLineComment) {
20
+ if (char === '"') {
21
+ let backslashCount = 0;
22
+ let j = i - 1;
23
+ while (j >= 0 && content[j] === "\\") {
24
+ backslashCount++;
25
+ j--;
26
+ }
27
+ if (backslashCount % 2 === 0) {
28
+ inString = !inString;
29
+ }
30
+ result += char;
31
+ i++;
32
+ continue;
33
+ }
34
+ }
35
+ if (inString) {
36
+ result += char;
37
+ i++;
38
+ continue;
39
+ }
40
+ if (!inSingleLineComment && !inMultiLineComment) {
41
+ if (char === "/" && nextChar === "/") {
42
+ inSingleLineComment = true;
43
+ i += 2;
44
+ continue;
45
+ }
46
+ if (char === "/" && nextChar === "*") {
47
+ inMultiLineComment = true;
48
+ i += 2;
49
+ continue;
50
+ }
51
+ }
52
+ if (inSingleLineComment) {
53
+ if (char === `
54
+ `) {
55
+ inSingleLineComment = false;
56
+ result += char;
57
+ }
58
+ i++;
59
+ continue;
60
+ }
61
+ if (inMultiLineComment) {
62
+ if (char === "*" && nextChar === "/") {
63
+ inMultiLineComment = false;
64
+ i += 2;
65
+ continue;
66
+ }
67
+ if (char === `
68
+ `) {
69
+ result += char;
70
+ }
71
+ i++;
72
+ continue;
73
+ }
74
+ result += char;
75
+ i++;
76
+ }
77
+ return result;
78
+ }
79
+
80
+ // src/cli.ts
8
81
  var OPENCODE_CONFIG_DIR = join(homedir(), ".config", "opencode");
9
82
  var OPENCODE_COMMAND_DIR = join(OPENCODE_CONFIG_DIR, "command");
10
- var PLUGIN_NAME = "opencode-supermemory";
83
+ var OH_MY_OPENCODE_CONFIG = join(OPENCODE_CONFIG_DIR, "oh-my-opencode.json");
84
+ var PLUGIN_NAME = "opencode-supermemory@latest";
11
85
  var SUPERMEMORY_INIT_COMMAND = `---
12
86
  description: Initialize Supermemory with comprehensive codebase knowledge
13
87
  ---
@@ -191,7 +265,7 @@ function addPluginToConfig(configPath) {
191
265
  console.log("✓ Plugin already registered in config");
192
266
  return true;
193
267
  }
194
- const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
268
+ const jsonContent = stripJsoncComments(content);
195
269
  let config;
196
270
  try {
197
271
  config = JSON.parse(jsonContent);
@@ -249,6 +323,49 @@ function createCommand() {
249
323
  console.log(`✓ Created /supermemory-init command`);
250
324
  return true;
251
325
  }
326
+ function isOhMyOpencodeInstalled() {
327
+ const configPath = findOpencodeConfig();
328
+ if (!configPath)
329
+ return false;
330
+ try {
331
+ const content = readFileSync(configPath, "utf-8");
332
+ return content.includes("oh-my-opencode");
333
+ } catch {
334
+ return false;
335
+ }
336
+ }
337
+ function isAutoCompactAlreadyDisabled() {
338
+ if (!existsSync(OH_MY_OPENCODE_CONFIG))
339
+ return false;
340
+ try {
341
+ const content = readFileSync(OH_MY_OPENCODE_CONFIG, "utf-8");
342
+ const config = JSON.parse(content);
343
+ const disabledHooks = config.disabled_hooks;
344
+ return disabledHooks?.includes("anthropic-context-window-limit-recovery") ?? false;
345
+ } catch {
346
+ return false;
347
+ }
348
+ }
349
+ function disableAutoCompactHook() {
350
+ try {
351
+ let config = {};
352
+ if (existsSync(OH_MY_OPENCODE_CONFIG)) {
353
+ const content = readFileSync(OH_MY_OPENCODE_CONFIG, "utf-8");
354
+ config = JSON.parse(content);
355
+ }
356
+ const disabledHooks = config.disabled_hooks || [];
357
+ if (!disabledHooks.includes("anthropic-context-window-limit-recovery")) {
358
+ disabledHooks.push("anthropic-context-window-limit-recovery");
359
+ }
360
+ config.disabled_hooks = disabledHooks;
361
+ writeFileSync(OH_MY_OPENCODE_CONFIG, JSON.stringify(config, null, 2));
362
+ console.log(`✓ Disabled anthropic-context-window-limit-recovery hook in oh-my-opencode.json`);
363
+ return true;
364
+ } catch (err) {
365
+ console.error("✗ Failed to update oh-my-opencode.json:", err);
366
+ return false;
367
+ }
368
+ }
252
369
  async function install(options) {
253
370
  console.log(`
254
371
  \uD83E\uDDE0 opencode-supermemory installer
@@ -291,6 +408,28 @@ Step 2: Create /supermemory-init command`);
291
408
  } else {
292
409
  createCommand();
293
410
  }
411
+ if (isOhMyOpencodeInstalled()) {
412
+ console.log(`
413
+ Step 3: Configure Oh My OpenCode`);
414
+ console.log("Detected Oh My OpenCode plugin.");
415
+ console.log("Supermemory handles context compaction, so the built-in context-window-limit-recovery hook should be disabled.");
416
+ if (isAutoCompactAlreadyDisabled()) {
417
+ console.log("✓ anthropic-context-window-limit-recovery hook already disabled");
418
+ } else {
419
+ if (options.tui) {
420
+ const shouldDisable = await confirm(rl, "Disable anthropic-context-window-limit-recovery hook to let Supermemory handle context?");
421
+ if (!shouldDisable) {
422
+ console.log("Skipped.");
423
+ } else {
424
+ disableAutoCompactHook();
425
+ }
426
+ } else if (options.disableAutoCompact) {
427
+ disableAutoCompactHook();
428
+ } else {
429
+ console.log("Skipped. Use --disable-context-recovery to disable the hook in non-interactive mode.");
430
+ }
431
+ }
432
+ }
294
433
  console.log(`
295
434
  ` + "─".repeat(50));
296
435
  console.log(`
@@ -319,12 +458,14 @@ function printHelp() {
319
458
  opencode-supermemory - Persistent memory for OpenCode agents
320
459
 
321
460
  Commands:
322
- install Install and configure the plugin
323
- --no-tui Run in non-interactive mode (for LLM agents)
461
+ install Install and configure the plugin
462
+ --no-tui Run in non-interactive mode (for LLM agents)
463
+ --disable-context-recovery Disable Oh My OpenCode's context-window-limit-recovery hook (use with --no-tui)
324
464
 
325
465
  Examples:
326
- bunx opencode-supermemory install
327
- bunx opencode-supermemory install --no-tui
466
+ bunx opencode-supermemory@latest install
467
+ bunx opencode-supermemory@latest install --no-tui
468
+ bunx opencode-supermemory@latest install --no-tui --disable-context-recovery
328
469
  `);
329
470
  }
330
471
  var args = process.argv.slice(2);
@@ -334,12 +475,14 @@ if (args.length === 0 || args[0] === "help" || args[0] === "--help" || args[0] =
334
475
  }
335
476
  if (args[0] === "install") {
336
477
  const noTui = args.includes("--no-tui");
337
- install({ tui: !noTui }).then((code) => process.exit(code));
478
+ const disableAutoCompact = args.includes("--disable-context-recovery");
479
+ install({ tui: !noTui, disableAutoCompact }).then((code) => process.exit(code));
338
480
  } else if (args[0] === "setup") {
339
481
  console.log(`Note: 'setup' is deprecated. Use 'install' instead.
340
482
  `);
341
483
  const noTui = args.includes("--no-tui");
342
- install({ tui: !noTui }).then((code) => process.exit(code));
484
+ const disableAutoCompact = args.includes("--disable-context-recovery");
485
+ install({ tui: !noTui, disableAutoCompact }).then((code) => process.exit(code));
343
486
  } else {
344
487
  console.error(`Unknown command: ${args[0]}`);
345
488
  printHelp();
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAmDA,eAAO,MAAM,mBAAmB,oBAAuD,CAAC;AAExF,eAAO,MAAM,MAAM;;;;;;;;CAQlB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,mBAAmB,oBAAuD,CAAC;AAExF,eAAO,MAAM,MAAM;;;;;;;;CAQlB,CAAC;AAEF,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAuC/D,eAAO,MAAM,iBAAiB,EAAE,MA6Y/B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAuC/D,eAAO,MAAM,iBAAiB,EAAE,MAwa/B,CAAC"}
package/dist/index.js CHANGED
@@ -13605,6 +13605,79 @@ Supermemory.Connections = Connections;
13605
13605
  import { existsSync, readFileSync } from "node:fs";
13606
13606
  import { join } from "node:path";
13607
13607
  import { homedir } from "node:os";
13608
+
13609
+ // src/services/jsonc.ts
13610
+ function stripJsoncComments(content) {
13611
+ let result = "";
13612
+ let i = 0;
13613
+ let inString = false;
13614
+ let inSingleLineComment = false;
13615
+ let inMultiLineComment = false;
13616
+ while (i < content.length) {
13617
+ const char = content[i];
13618
+ const nextChar = content[i + 1];
13619
+ if (!inSingleLineComment && !inMultiLineComment) {
13620
+ if (char === '"') {
13621
+ let backslashCount = 0;
13622
+ let j = i - 1;
13623
+ while (j >= 0 && content[j] === "\\") {
13624
+ backslashCount++;
13625
+ j--;
13626
+ }
13627
+ if (backslashCount % 2 === 0) {
13628
+ inString = !inString;
13629
+ }
13630
+ result += char;
13631
+ i++;
13632
+ continue;
13633
+ }
13634
+ }
13635
+ if (inString) {
13636
+ result += char;
13637
+ i++;
13638
+ continue;
13639
+ }
13640
+ if (!inSingleLineComment && !inMultiLineComment) {
13641
+ if (char === "/" && nextChar === "/") {
13642
+ inSingleLineComment = true;
13643
+ i += 2;
13644
+ continue;
13645
+ }
13646
+ if (char === "/" && nextChar === "*") {
13647
+ inMultiLineComment = true;
13648
+ i += 2;
13649
+ continue;
13650
+ }
13651
+ }
13652
+ if (inSingleLineComment) {
13653
+ if (char === `
13654
+ `) {
13655
+ inSingleLineComment = false;
13656
+ result += char;
13657
+ }
13658
+ i++;
13659
+ continue;
13660
+ }
13661
+ if (inMultiLineComment) {
13662
+ if (char === "*" && nextChar === "/") {
13663
+ inMultiLineComment = false;
13664
+ i += 2;
13665
+ continue;
13666
+ }
13667
+ if (char === `
13668
+ `) {
13669
+ result += char;
13670
+ }
13671
+ i++;
13672
+ continue;
13673
+ }
13674
+ result += char;
13675
+ i++;
13676
+ }
13677
+ return result;
13678
+ }
13679
+
13680
+ // src/config.ts
13608
13681
  var CONFIG_DIR = join(homedir(), ".config", "opencode");
13609
13682
  var CONFIG_FILES = [
13610
13683
  join(CONFIG_DIR, "supermemory.jsonc"),
@@ -13624,7 +13697,7 @@ function loadConfig() {
13624
13697
  if (existsSync(path2)) {
13625
13698
  try {
13626
13699
  const content = readFileSync(path2, "utf-8");
13627
- const json2 = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
13700
+ const json2 = stripJsoncComments(content);
13628
13701
  return JSON.parse(json2);
13629
13702
  } catch {}
13630
13703
  }
@@ -13698,11 +13771,11 @@ class SupermemoryClient {
13698
13771
  searchMode: "hybrid"
13699
13772
  }), TIMEOUT_MS);
13700
13773
  log("searchMemories: success", { count: result.results?.length || 0 });
13701
- return result;
13774
+ return { success: true, ...result };
13702
13775
  } catch (error45) {
13703
- log("searchMemories: error", { error: String(error45) });
13704
- console.error("Supermemory: search failed", error45);
13705
- return { results: [], total: 0, timing: 0 };
13776
+ const errorMessage = error45 instanceof Error ? error45.message : String(error45);
13777
+ log("searchMemories: error", { error: errorMessage });
13778
+ return { success: false, error: errorMessage, results: [], total: 0, timing: 0 };
13706
13779
  }
13707
13780
  }
13708
13781
  async getProfile(containerTag, query) {
@@ -13713,34 +13786,39 @@ class SupermemoryClient {
13713
13786
  q: query
13714
13787
  }), TIMEOUT_MS);
13715
13788
  log("getProfile: success", { hasProfile: !!result?.profile });
13716
- return result;
13789
+ return { success: true, ...result };
13717
13790
  } catch (error45) {
13718
- log("getProfile: error", { error: String(error45) });
13719
- console.error("Supermemory: profile fetch failed", error45);
13720
- return null;
13791
+ const errorMessage = error45 instanceof Error ? error45.message : String(error45);
13792
+ log("getProfile: error", { error: errorMessage });
13793
+ return { success: false, error: errorMessage, profile: null };
13721
13794
  }
13722
13795
  }
13723
13796
  async addMemory(content, containerTag, metadata) {
13797
+ log("addMemory: start", { containerTag, contentLength: content.length });
13724
13798
  try {
13725
- return await withTimeout(this.getClient().memories.add({
13799
+ const result = await withTimeout(this.getClient().memories.add({
13726
13800
  content,
13727
13801
  containerTag,
13728
13802
  metadata
13729
13803
  }), TIMEOUT_MS);
13804
+ log("addMemory: success", { id: result.id });
13805
+ return { success: true, ...result };
13730
13806
  } catch (error45) {
13731
- console.error("Supermemory: add memory failed", error45);
13732
- return null;
13807
+ const errorMessage = error45 instanceof Error ? error45.message : String(error45);
13808
+ log("addMemory: error", { error: errorMessage });
13809
+ return { success: false, error: errorMessage };
13733
13810
  }
13734
13811
  }
13735
- async forgetMemory(containerTag, memoryId) {
13812
+ async deleteMemory(memoryId) {
13813
+ log("deleteMemory: start", { memoryId });
13736
13814
  try {
13737
- return await withTimeout(this.getClient().memories.forget({
13738
- containerTag,
13739
- id: memoryId
13740
- }), TIMEOUT_MS);
13815
+ await withTimeout(this.getClient().memories.delete(memoryId), TIMEOUT_MS);
13816
+ log("deleteMemory: success", { memoryId });
13817
+ return { success: true };
13741
13818
  } catch (error45) {
13742
- console.error("Supermemory: forget memory failed", error45);
13743
- return null;
13819
+ const errorMessage = error45 instanceof Error ? error45.message : String(error45);
13820
+ log("deleteMemory: error", { memoryId, error: errorMessage });
13821
+ return { success: false, error: errorMessage };
13744
13822
  }
13745
13823
  }
13746
13824
  async listMemories(containerTag, limit = 20) {
@@ -13753,11 +13831,11 @@ class SupermemoryClient {
13753
13831
  sort: "createdAt"
13754
13832
  }), TIMEOUT_MS);
13755
13833
  log("listMemories: success", { count: result.memories?.length || 0 });
13756
- return result;
13834
+ return { success: true, ...result };
13757
13835
  } catch (error45) {
13758
- log("listMemories: error", { error: String(error45) });
13759
- console.error("Supermemory: list memories failed", error45);
13760
- return { memories: [], pagination: { currentPage: 1, totalItems: 0, totalPages: 0 } };
13836
+ const errorMessage = error45 instanceof Error ? error45.message : String(error45);
13837
+ log("listMemories: error", { error: errorMessage });
13838
+ return { success: false, error: errorMessage, memories: [], pagination: { currentPage: 1, totalItems: 0, totalPages: 0 } };
13761
13839
  }
13762
13840
  }
13763
13841
  async ingestConversation(conversationId, messages, containerTags, metadata) {
@@ -13779,15 +13857,15 @@ class SupermemoryClient {
13779
13857
  if (!response.ok) {
13780
13858
  const errorText = await response.text();
13781
13859
  log("ingestConversation: error response", { status: response.status, error: errorText });
13782
- return null;
13860
+ return { success: false, error: `HTTP ${response.status}: ${errorText}` };
13783
13861
  }
13784
13862
  const result = await response.json();
13785
13863
  log("ingestConversation: success", { conversationId, status: result.status });
13786
- return result;
13864
+ return { success: true, ...result };
13787
13865
  } catch (error45) {
13788
- log("ingestConversation: error", { error: String(error45) });
13789
- console.error("Supermemory: ingest conversation failed", error45);
13790
- return null;
13866
+ const errorMessage = error45 instanceof Error ? error45.message : String(error45);
13867
+ log("ingestConversation: error", { error: errorMessage });
13868
+ return { success: false, error: errorMessage };
13791
13869
  }
13792
13870
  }
13793
13871
  }
@@ -14077,8 +14155,10 @@ function createCompactionHook(ctx, tags, options) {
14077
14155
  try {
14078
14156
  const result = await supermemoryClient.addMemory(`[Session Summary]
14079
14157
  ${summaryContent}`, tags.project, { type: "conversation" });
14080
- if (result) {
14158
+ if (result.success) {
14081
14159
  log("[compaction] summary saved as memory", { sessionID, memoryId: result.id });
14160
+ } else {
14161
+ log("[compaction] failed to save summary", { error: result.error });
14082
14162
  }
14083
14163
  } catch (err) {
14084
14164
  log("[compaction] failed to save summary", { error: String(err) });
@@ -14331,20 +14411,23 @@ var SupermemoryPlugin = async (ctx) => {
14331
14411
  const isFirstMessage = !injectedSessions.has(input.sessionID);
14332
14412
  if (isFirstMessage) {
14333
14413
  injectedSessions.add(input.sessionID);
14334
- const [profile, userMemories, projectMemoriesList] = await Promise.all([
14414
+ const [profileResult, userMemoriesResult, projectMemoriesListResult] = await Promise.all([
14335
14415
  supermemoryClient.getProfile(tags.user, userMessage),
14336
14416
  supermemoryClient.searchMemories(userMessage, tags.user),
14337
14417
  supermemoryClient.listMemories(tags.project, CONFIG.maxProjectMemories)
14338
14418
  ]);
14419
+ const profile = profileResult.success ? profileResult : null;
14420
+ const userMemories = userMemoriesResult.success ? userMemoriesResult : { results: [] };
14421
+ const projectMemoriesList = projectMemoriesListResult.success ? projectMemoriesListResult : { memories: [] };
14339
14422
  const projectMemories = {
14340
- results: (projectMemoriesList?.memories || []).map((m) => ({
14423
+ results: (projectMemoriesList.memories || []).map((m) => ({
14341
14424
  id: m.id,
14342
14425
  memory: m.summary,
14343
14426
  similarity: 1,
14344
14427
  title: m.title,
14345
14428
  metadata: m.metadata
14346
14429
  })),
14347
- total: projectMemoriesList?.memories?.length || 0,
14430
+ total: projectMemoriesList.memories?.length || 0,
14348
14431
  timing: 0
14349
14432
  };
14350
14433
  const memoryContext = formatContextForPrompt(profile, userMemories, projectMemories);
@@ -14460,10 +14543,10 @@ var SupermemoryPlugin = async (ctx) => {
14460
14543
  const scope = args.scope || "project";
14461
14544
  const containerTag = scope === "user" ? tags.user : tags.project;
14462
14545
  const result = await supermemoryClient.addMemory(sanitizedContent, containerTag, { type: args.type });
14463
- if (!result) {
14546
+ if (!result.success) {
14464
14547
  return JSON.stringify({
14465
14548
  success: false,
14466
- error: "Failed to add memory"
14549
+ error: result.error || "Failed to add memory"
14467
14550
  });
14468
14551
  }
14469
14552
  return JSON.stringify({
@@ -14483,23 +14566,41 @@ var SupermemoryPlugin = async (ctx) => {
14483
14566
  }
14484
14567
  const scope = args.scope;
14485
14568
  if (scope === "user") {
14486
- const results = await supermemoryClient.searchMemories(args.query, tags.user);
14487
- return formatSearchResults(args.query, scope, results, args.limit);
14569
+ const result = await supermemoryClient.searchMemories(args.query, tags.user);
14570
+ if (!result.success) {
14571
+ return JSON.stringify({
14572
+ success: false,
14573
+ error: result.error || "Failed to search memories"
14574
+ });
14575
+ }
14576
+ return formatSearchResults(args.query, scope, result, args.limit);
14488
14577
  }
14489
14578
  if (scope === "project") {
14490
- const results = await supermemoryClient.searchMemories(args.query, tags.project);
14491
- return formatSearchResults(args.query, scope, results, args.limit);
14579
+ const result = await supermemoryClient.searchMemories(args.query, tags.project);
14580
+ if (!result.success) {
14581
+ return JSON.stringify({
14582
+ success: false,
14583
+ error: result.error || "Failed to search memories"
14584
+ });
14585
+ }
14586
+ return formatSearchResults(args.query, scope, result, args.limit);
14492
14587
  }
14493
- const [userResults, projectResults] = await Promise.all([
14588
+ const [userResult, projectResult] = await Promise.all([
14494
14589
  supermemoryClient.searchMemories(args.query, tags.user),
14495
14590
  supermemoryClient.searchMemories(args.query, tags.project)
14496
14591
  ]);
14592
+ if (!userResult.success || !projectResult.success) {
14593
+ return JSON.stringify({
14594
+ success: false,
14595
+ error: userResult.error || projectResult.error || "Failed to search memories"
14596
+ });
14597
+ }
14497
14598
  const combined = [
14498
- ...(userResults.results || []).map((r) => ({
14599
+ ...(userResult.results || []).map((r) => ({
14499
14600
  ...r,
14500
14601
  scope: "user"
14501
14602
  })),
14502
- ...(projectResults.results || []).map((r) => ({
14603
+ ...(projectResult.results || []).map((r) => ({
14503
14604
  ...r,
14504
14605
  scope: "project"
14505
14606
  }))
@@ -14517,18 +14618,18 @@ var SupermemoryPlugin = async (ctx) => {
14517
14618
  });
14518
14619
  }
14519
14620
  case "profile": {
14520
- const profile = await supermemoryClient.getProfile(tags.user, args.query);
14521
- if (!profile) {
14621
+ const result = await supermemoryClient.getProfile(tags.user, args.query);
14622
+ if (!result.success) {
14522
14623
  return JSON.stringify({
14523
14624
  success: false,
14524
- error: "Failed to fetch profile"
14625
+ error: result.error || "Failed to fetch profile"
14525
14626
  });
14526
14627
  }
14527
14628
  return JSON.stringify({
14528
14629
  success: true,
14529
14630
  profile: {
14530
- static: profile.profile?.static || [],
14531
- dynamic: profile.profile?.dynamic || []
14631
+ static: result.profile?.static || [],
14632
+ dynamic: result.profile?.dynamic || []
14532
14633
  }
14533
14634
  });
14534
14635
  }
@@ -14537,6 +14638,12 @@ var SupermemoryPlugin = async (ctx) => {
14537
14638
  const limit = args.limit || 20;
14538
14639
  const containerTag = scope === "user" ? tags.user : tags.project;
14539
14640
  const result = await supermemoryClient.listMemories(containerTag, limit);
14641
+ if (!result.success) {
14642
+ return JSON.stringify({
14643
+ success: false,
14644
+ error: result.error || "Failed to list memories"
14645
+ });
14646
+ }
14540
14647
  const memories = result.memories || [];
14541
14648
  return JSON.stringify({
14542
14649
  success: true,
@@ -14558,12 +14665,11 @@ var SupermemoryPlugin = async (ctx) => {
14558
14665
  });
14559
14666
  }
14560
14667
  const scope = args.scope || "project";
14561
- const containerTag = scope === "user" ? tags.user : tags.project;
14562
- const result = await supermemoryClient.forgetMemory(containerTag, args.memoryId);
14563
- if (!result) {
14668
+ const result = await supermemoryClient.deleteMemory(args.memoryId);
14669
+ if (!result.success) {
14564
14670
  return JSON.stringify({
14565
14671
  success: false,
14566
- error: "Failed to forget memory"
14672
+ error: result.error || "Failed to delete memory"
14567
14673
  });
14568
14674
  }
14569
14675
  return JSON.stringify({
@@ -1,18 +1,76 @@
1
1
  import Supermemory from "supermemory";
2
- import type { MemoryType, ConversationMessage, ConversationIngestResponse } from "../types/index.js";
2
+ import type { MemoryType, ConversationMessage } from "../types/index.js";
3
3
  export declare class SupermemoryClient {
4
4
  private client;
5
5
  private getClient;
6
- searchMemories(query: string, containerTag: string): Promise<Supermemory.Search.SearchMemoriesResponse>;
7
- getProfile(containerTag: string, query?: string): Promise<Supermemory.ProfileResponse | null>;
6
+ searchMemories(query: string, containerTag: string): Promise<{
7
+ results: Array<Supermemory.Search.SearchMemoriesResponse.Result>;
8
+ timing: number;
9
+ total: number;
10
+ success: true;
11
+ error?: undefined;
12
+ } | {
13
+ success: false;
14
+ error: string;
15
+ results: never[];
16
+ total: number;
17
+ timing: number;
18
+ }>;
19
+ getProfile(containerTag: string, query?: string): Promise<{
20
+ profile: Supermemory.ProfileResponse.Profile;
21
+ searchResults?: Supermemory.ProfileResponse.SearchResults;
22
+ success: true;
23
+ error?: undefined;
24
+ } | {
25
+ success: false;
26
+ error: string;
27
+ profile: null;
28
+ }>;
8
29
  addMemory(content: string, containerTag: string, metadata?: {
9
30
  type?: MemoryType;
10
31
  tool?: string;
11
32
  [key: string]: unknown;
12
- }): Promise<Supermemory.Memories.MemoryAddResponse | null>;
13
- forgetMemory(containerTag: string, memoryId?: string): Promise<Supermemory.Memories.MemoryForgetResponse | null>;
14
- listMemories(containerTag: string, limit?: number): Promise<Supermemory.Memories.MemoryListResponse>;
15
- ingestConversation(conversationId: string, messages: ConversationMessage[], containerTags: string[], metadata?: Record<string, string | number | boolean>): Promise<ConversationIngestResponse | null>;
33
+ }): Promise<{
34
+ id: string;
35
+ status: string;
36
+ success: true;
37
+ error?: undefined;
38
+ } | {
39
+ success: false;
40
+ error: string;
41
+ }>;
42
+ deleteMemory(memoryId: string): Promise<{
43
+ success: boolean;
44
+ error?: undefined;
45
+ } | {
46
+ success: boolean;
47
+ error: string;
48
+ }>;
49
+ listMemories(containerTag: string, limit?: number): Promise<{
50
+ memories: Array<Supermemory.Memories.MemoryListResponse.Memory>;
51
+ pagination: Supermemory.Memories.MemoryListResponse.Pagination;
52
+ success: true;
53
+ error?: undefined;
54
+ } | {
55
+ success: false;
56
+ error: string;
57
+ memories: never[];
58
+ pagination: {
59
+ currentPage: number;
60
+ totalItems: number;
61
+ totalPages: number;
62
+ };
63
+ }>;
64
+ ingestConversation(conversationId: string, messages: ConversationMessage[], containerTags: string[], metadata?: Record<string, string | number | boolean>): Promise<{
65
+ success: false;
66
+ error: string;
67
+ } | {
68
+ id: string;
69
+ conversationId: string;
70
+ status: string;
71
+ success: true;
72
+ error?: undefined;
73
+ }>;
16
74
  }
17
75
  export declare const supermemoryClient: SupermemoryClient;
18
76
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/services/client.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AAGtC,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,mBAAmB,CAAC;AAe3B,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAA4B;IAE1C,OAAO,CAAC,SAAS;IAcX,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAsBlD,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAmB/C,SAAS,CACb,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE;IAiBnE,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE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ries.
3
+ * Handles // and /* comments, URLs in strings, and escaped quotes.
4
+ */
5
+ export declare function stripJsoncComments(content: string): string;
6
+ //# sourceMappingURL=jsonc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonc.d.ts","sourceRoot":"","sources":["../../src/services/jsonc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA8E1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-supermemory",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "OpenCode plugin that gives coding agents persistent memory using Supermemory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",