opencode-supermemory 0.1.3 → 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
@@ -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,6 +5,79 @@ 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
83
  var OH_MY_OPENCODE_CONFIG = join(OPENCODE_CONFIG_DIR, "oh-my-opencode.json");
@@ -192,7 +265,7 @@ function addPluginToConfig(configPath) {
192
265
  console.log("✓ Plugin already registered in config");
193
266
  return true;
194
267
  }
195
- const jsonContent = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
268
+ const jsonContent = stripJsoncComments(content);
196
269
  let config;
197
270
  try {
198
271
  config = JSON.parse(jsonContent);
@@ -268,7 +341,7 @@ function isAutoCompactAlreadyDisabled() {
268
341
  const content = readFileSync(OH_MY_OPENCODE_CONFIG, "utf-8");
269
342
  const config = JSON.parse(content);
270
343
  const disabledHooks = config.disabled_hooks;
271
- return disabledHooks?.includes("anthropic-auto-compact") ?? false;
344
+ return disabledHooks?.includes("anthropic-context-window-limit-recovery") ?? false;
272
345
  } catch {
273
346
  return false;
274
347
  }
@@ -281,12 +354,12 @@ function disableAutoCompactHook() {
281
354
  config = JSON.parse(content);
282
355
  }
283
356
  const disabledHooks = config.disabled_hooks || [];
284
- if (!disabledHooks.includes("anthropic-auto-compact")) {
285
- disabledHooks.push("anthropic-auto-compact");
357
+ if (!disabledHooks.includes("anthropic-context-window-limit-recovery")) {
358
+ disabledHooks.push("anthropic-context-window-limit-recovery");
286
359
  }
287
360
  config.disabled_hooks = disabledHooks;
288
361
  writeFileSync(OH_MY_OPENCODE_CONFIG, JSON.stringify(config, null, 2));
289
- console.log(`✓ Disabled anthropic-auto-compact hook in oh-my-opencode.json`);
362
+ console.log(`✓ Disabled anthropic-context-window-limit-recovery hook in oh-my-opencode.json`);
290
363
  return true;
291
364
  } catch (err) {
292
365
  console.error("✗ Failed to update oh-my-opencode.json:", err);
@@ -339,12 +412,12 @@ Step 2: Create /supermemory-init command`);
339
412
  console.log(`
340
413
  Step 3: Configure Oh My OpenCode`);
341
414
  console.log("Detected Oh My OpenCode plugin.");
342
- console.log("Supermemory handles context compaction, so the built-in auto-compact hook should be disabled.");
415
+ console.log("Supermemory handles context compaction, so the built-in context-window-limit-recovery hook should be disabled.");
343
416
  if (isAutoCompactAlreadyDisabled()) {
344
- console.log("✓ anthropic-auto-compact hook already disabled");
417
+ console.log("✓ anthropic-context-window-limit-recovery hook already disabled");
345
418
  } else {
346
419
  if (options.tui) {
347
- const shouldDisable = await confirm(rl, "Disable anthropic-auto-compact hook to let Supermemory handle context?");
420
+ const shouldDisable = await confirm(rl, "Disable anthropic-context-window-limit-recovery hook to let Supermemory handle context?");
348
421
  if (!shouldDisable) {
349
422
  console.log("Skipped.");
350
423
  } else {
@@ -353,7 +426,7 @@ Step 3: Configure Oh My OpenCode`);
353
426
  } else if (options.disableAutoCompact) {
354
427
  disableAutoCompactHook();
355
428
  } else {
356
- console.log("Skipped. Use --disable-auto-compact to disable the hook in non-interactive mode.");
429
+ console.log("Skipped. Use --disable-context-recovery to disable the hook in non-interactive mode.");
357
430
  }
358
431
  }
359
432
  }
@@ -387,12 +460,12 @@ opencode-supermemory - Persistent memory for OpenCode agents
387
460
  Commands:
388
461
  install Install and configure the plugin
389
462
  --no-tui Run in non-interactive mode (for LLM agents)
390
- --disable-auto-compact Disable Oh My OpenCode's auto-compact hook (use with --no-tui)
463
+ --disable-context-recovery Disable Oh My OpenCode's context-window-limit-recovery hook (use with --no-tui)
391
464
 
392
465
  Examples:
393
466
  bunx opencode-supermemory@latest install
394
467
  bunx opencode-supermemory@latest install --no-tui
395
- bunx opencode-supermemory@latest install --no-tui --disable-auto-compact
468
+ bunx opencode-supermemory@latest install --no-tui --disable-context-recovery
396
469
  `);
397
470
  }
398
471
  var args = process.argv.slice(2);
@@ -402,13 +475,13 @@ if (args.length === 0 || args[0] === "help" || args[0] === "--help" || args[0] =
402
475
  }
403
476
  if (args[0] === "install") {
404
477
  const noTui = args.includes("--no-tui");
405
- const disableAutoCompact = args.includes("--disable-auto-compact");
478
+ const disableAutoCompact = args.includes("--disable-context-recovery");
406
479
  install({ tui: !noTui, disableAutoCompact }).then((code) => process.exit(code));
407
480
  } else if (args[0] === "setup") {
408
481
  console.log(`Note: 'setup' is deprecated. Use 'install' instead.
409
482
  `);
410
483
  const noTui = args.includes("--no-tui");
411
- const disableAutoCompact = args.includes("--disable-auto-compact");
484
+ const disableAutoCompact = args.includes("--disable-context-recovery");
412
485
  install({ tui: !noTui, disableAutoCompact }).then((code) => process.exit(code));
413
486
  } else {
414
487
  console.error(`Unknown command: ${args[0]}`);
@@ -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"}
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
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Strips comments from JSONC content while respecting string boundaries.
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.3",
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",