From 52a93bc3e17c3dc1cbc4641b1d16945678e96bf0 Mon Sep 17 00:00:00 2001 From: Omkar Chebale Date: Sun, 27 Sep 2026 19:43:19 +0530 Subject: [PATCH 1/2] Create the OpenCode config directory before writing install defaults On a machine where ~/.config/opencode does not exist yet (plugin installed before OpenCode was ever run, fresh CI/Docker/headless boxes), install crashed with ENOENT writing supermemory.json, before any later step that creates the directory could run. --- src/cli.test.ts | 22 ++++++++++++++++++++++ src/cli.ts | 1 + 2 files changed, 23 insertions(+) create mode 100644 src/cli.test.ts diff --git a/src/cli.test.ts b/src/cli.test.ts new file mode 100644 index 0000000..4ec3ee6 --- /dev/null +++ b/src/cli.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, test } from "bun:test"; +import { existsSync, mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +describe("cli install", () => { + test("works on a machine without ~/.config/opencode", () => { + const home = mkdtempSync(join(tmpdir(), "sm-cli-home-")); + try { + const env: Record = { ...process.env, HOME: home, USERPROFILE: home }; + delete env.SUPERMEMORY_API_KEY; + + const result = Bun.spawnSync(["bun", join(import.meta.dir, "cli.ts"), "install", "--no-tui"], { env }); + + expect(result.stderr.toString()).not.toContain("ENOENT"); + expect(result.exitCode).toBe(0); + expect(existsSync(join(home, ".config", "opencode", "supermemory.json"))).toBe(true); + } finally { + rmSync(home, { recursive: true, force: true }); + } + }); +}); diff --git a/src/cli.ts b/src/cli.ts index 686c7d5..d63c00d 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -416,6 +416,7 @@ interface InstallOptions { async function install(options: InstallOptions): Promise { console.log("\n🧠 opencode-supermemory installer\n"); + mkdirSync(OPENCODE_CONFIG_DIR, { recursive: true }); writeInstallDefaults(existsSync(DEFAULT_CONFIG_FILE)); const rl = options.tui ? createReadline() : null; From 595016106b10c9b13fe78acfcd299df69c02e522 Mon Sep 17 00:00:00 2001 From: Ishaan Gupta Date: Mon, 28 Sep 2026 01:17:55 +0530 Subject: [PATCH 2/2] Delete src/cli.test.ts --- src/cli.test.ts | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 src/cli.test.ts diff --git a/src/cli.test.ts b/src/cli.test.ts deleted file mode 100644 index 4ec3ee6..0000000 --- a/src/cli.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { describe, expect, test } from "bun:test"; -import { existsSync, mkdtempSync, rmSync } from "node:fs"; -import { tmpdir } from "node:os"; -import { join } from "node:path"; - -describe("cli install", () => { - test("works on a machine without ~/.config/opencode", () => { - const home = mkdtempSync(join(tmpdir(), "sm-cli-home-")); - try { - const env: Record = { ...process.env, HOME: home, USERPROFILE: home }; - delete env.SUPERMEMORY_API_KEY; - - const result = Bun.spawnSync(["bun", join(import.meta.dir, "cli.ts"), "install", "--no-tui"], { env }); - - expect(result.stderr.toString()).not.toContain("ENOENT"); - expect(result.exitCode).toBe(0); - expect(existsSync(join(home, ".config", "opencode", "supermemory.json"))).toBe(true); - } finally { - rmSync(home, { recursive: true, force: true }); - } - }); -});