Skip to content

Commit 87b091f

Browse files
feat: use @latest for plugin config and add Oh My OpenCode integration (#4)
* Update installation command to use latest version bunx opencode-supermemory@latest setup Note: 'setup' is deprecated. Use 'install' instead. happens. bun uses cache instead always if u don't make it @latest. same can be said for the plugin. version locking is bad here incase frequent update. suggestion to update the plugin to always have @latest in config.json too. * fix: use @latest tag in plugin config to bypass bun cache This ensures the plugin always fetches the latest version instead of using cached versions, which is important for frequently updated packages. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> * feat: add Oh My OpenCode integration with --disable-auto-compact flag - Detect Oh My OpenCode plugin in user's config - Add option to disable anthropic-auto-compact hook for Supermemory compatibility - In TUI mode: prompt user for confirmation - In --no-tui mode: require explicit --disable-auto-compact flag - Update help text and examples to use @latest tag Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 7448e8c commit 87b091f

2 files changed

Lines changed: 89 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Your agent remembers what you tell it - across sessions, across projects.
99
### For Humans
1010

1111
```bash
12-
bunx opencode-supermemory install
12+
bunx opencode-supermemory@latest install
1313
```
1414

1515
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:
3333
#### Step 1: Run the installer
3434

3535
```bash
36-
bunx opencode-supermemory install --no-tui
36+
bunx opencode-supermemory@latest install --no-tui
3737
```
3838

3939
This will:

src/cli.ts

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import * as readline from "node:readline";
66

77
const OPENCODE_CONFIG_DIR = join(homedir(), ".config", "opencode");
88
const OPENCODE_COMMAND_DIR = join(OPENCODE_CONFIG_DIR, "command");
9-
const PLUGIN_NAME = "opencode-supermemory";
9+
const OH_MY_OPENCODE_CONFIG = join(OPENCODE_CONFIG_DIR, "oh-my-opencode.json");
10+
const PLUGIN_NAME = "opencode-supermemory@latest";
1011

1112
const SUPERMEMORY_INIT_COMMAND = `---
1213
description: Initialize Supermemory with comprehensive codebase knowledge
@@ -269,8 +270,58 @@ function createCommand(): boolean {
269270
return true;
270271
}
271272

273+
function isOhMyOpencodeInstalled(): boolean {
274+
const configPath = findOpencodeConfig();
275+
if (!configPath) return false;
276+
277+
try {
278+
const content = readFileSync(configPath, "utf-8");
279+
return content.includes("oh-my-opencode");
280+
} catch {
281+
return false;
282+
}
283+
}
284+
285+
function isAutoCompactAlreadyDisabled(): boolean {
286+
if (!existsSync(OH_MY_OPENCODE_CONFIG)) return false;
287+
288+
try {
289+
const content = readFileSync(OH_MY_OPENCODE_CONFIG, "utf-8");
290+
const config = JSON.parse(content);
291+
const disabledHooks = config.disabled_hooks as string[] | undefined;
292+
return disabledHooks?.includes("anthropic-auto-compact") ?? false;
293+
} catch {
294+
return false;
295+
}
296+
}
297+
298+
function disableAutoCompactHook(): boolean {
299+
try {
300+
let config: Record<string, unknown> = {};
301+
302+
if (existsSync(OH_MY_OPENCODE_CONFIG)) {
303+
const content = readFileSync(OH_MY_OPENCODE_CONFIG, "utf-8");
304+
config = JSON.parse(content);
305+
}
306+
307+
const disabledHooks = (config.disabled_hooks as string[]) || [];
308+
if (!disabledHooks.includes("anthropic-auto-compact")) {
309+
disabledHooks.push("anthropic-auto-compact");
310+
}
311+
config.disabled_hooks = disabledHooks;
312+
313+
writeFileSync(OH_MY_OPENCODE_CONFIG, JSON.stringify(config, null, 2));
314+
console.log(`✓ Disabled anthropic-auto-compact hook in oh-my-opencode.json`);
315+
return true;
316+
} catch (err) {
317+
console.error("✗ Failed to update oh-my-opencode.json:", err);
318+
return false;
319+
}
320+
}
321+
272322
interface InstallOptions {
273323
tui: boolean;
324+
disableAutoCompact: boolean;
274325
}
275326

276327
async function install(options: InstallOptions): Promise<number> {
@@ -319,7 +370,31 @@ async function install(options: InstallOptions): Promise<number> {
319370
createCommand();
320371
}
321372

322-
// Step 3: API key instructions
373+
// Step 3: Configure Oh My OpenCode (if installed)
374+
if (isOhMyOpencodeInstalled()) {
375+
console.log("\nStep 3: Configure Oh My OpenCode");
376+
console.log("Detected Oh My OpenCode plugin.");
377+
console.log("Supermemory handles context compaction, so the built-in auto-compact hook should be disabled.");
378+
379+
if (isAutoCompactAlreadyDisabled()) {
380+
console.log("✓ anthropic-auto-compact hook already disabled");
381+
} else {
382+
if (options.tui) {
383+
const shouldDisable = await confirm(rl!, "Disable anthropic-auto-compact hook to let Supermemory handle context?");
384+
if (!shouldDisable) {
385+
console.log("Skipped.");
386+
} else {
387+
disableAutoCompactHook();
388+
}
389+
} else if (options.disableAutoCompact) {
390+
disableAutoCompactHook();
391+
} else {
392+
console.log("Skipped. Use --disable-auto-compact to disable the hook in non-interactive mode.");
393+
}
394+
}
395+
}
396+
397+
// Step 4: API key instructions
323398
console.log("\n" + "─".repeat(50));
324399
console.log("\n🔑 Final step: Set your API key\n");
325400
console.log("Get your API key from: https://console.supermemory.ai");
@@ -339,12 +414,14 @@ function printHelp(): void {
339414
opencode-supermemory - Persistent memory for OpenCode agents
340415
341416
Commands:
342-
install Install and configure the plugin
343-
--no-tui Run in non-interactive mode (for LLM agents)
417+
install Install and configure the plugin
418+
--no-tui Run in non-interactive mode (for LLM agents)
419+
--disable-auto-compact Disable Oh My OpenCode's auto-compact hook (use with --no-tui)
344420
345421
Examples:
346-
bunx opencode-supermemory install
347-
bunx opencode-supermemory install --no-tui
422+
bunx opencode-supermemory@latest install
423+
bunx opencode-supermemory@latest install --no-tui
424+
bunx opencode-supermemory@latest install --no-tui --disable-auto-compact
348425
`);
349426
}
350427

@@ -357,12 +434,14 @@ if (args.length === 0 || args[0] === "help" || args[0] === "--help" || args[0] =
357434

358435
if (args[0] === "install") {
359436
const noTui = args.includes("--no-tui");
360-
install({ tui: !noTui }).then((code) => process.exit(code));
437+
const disableAutoCompact = args.includes("--disable-auto-compact");
438+
install({ tui: !noTui, disableAutoCompact }).then((code) => process.exit(code));
361439
} else if (args[0] === "setup") {
362440
// Backwards compatibility
363441
console.log("Note: 'setup' is deprecated. Use 'install' instead.\n");
364442
const noTui = args.includes("--no-tui");
365-
install({ tui: !noTui }).then((code) => process.exit(code));
443+
const disableAutoCompact = args.includes("--disable-auto-compact");
444+
install({ tui: !noTui, disableAutoCompact }).then((code) => process.exit(code));
366445
} else {
367446
console.error(`Unknown command: ${args[0]}`);
368447
printHelp();

0 commit comments

Comments
 (0)