From eb8d7191ff2e004f8bd42cd7c405a01d50960e4e Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 7 Apr 2026 15:10:41 +0900 Subject: [PATCH] fix(auto-update): align PACKAGE_NAME with published package name (#3129) Changed PACKAGE_NAME from 'oh-my-openagent' to 'oh-my-opencode' in auto-update-checker/constants.ts to match package.json. This fixes getCachedVersion() returning null, causing 'unknown' in version toast. TDD: red-green confirmed. 39 tests pass, tsc clean. Closes #3129 --- .../checker/plugin-entry.test.ts | 3 +-- src/hooks/auto-update-checker/constants.test.ts | 15 +++++++++++++++ src/hooks/auto-update-checker/constants.ts | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/hooks/auto-update-checker/checker/plugin-entry.test.ts b/src/hooks/auto-update-checker/checker/plugin-entry.test.ts index b3aaf87c4..c621099b6 100644 --- a/src/hooks/auto-update-checker/checker/plugin-entry.test.ts +++ b/src/hooks/auto-update-checker/checker/plugin-entry.test.ts @@ -3,8 +3,7 @@ import { spawnSync } from "node:child_process" import * as fs from "node:fs" import * as os from "node:os" import * as path from "node:path" - -const PACKAGE_NAME = "oh-my-openagent" +import { PACKAGE_NAME } from "../constants" type PluginEntryResult = { entry: string diff --git a/src/hooks/auto-update-checker/constants.test.ts b/src/hooks/auto-update-checker/constants.test.ts index 31bd2efc1..bc9fcbc26 100644 --- a/src/hooks/auto-update-checker/constants.test.ts +++ b/src/hooks/auto-update-checker/constants.test.ts @@ -1,5 +1,7 @@ import { describe, expect, it } from "bun:test" +import { readFileSync } from "node:fs" import { join } from "node:path" +import { fileURLToPath } from "node:url" import { getOpenCodeCacheDir } from "../../shared/data-path" describe("auto-update-checker constants", () => { @@ -11,4 +13,17 @@ describe("auto-update-checker constants", () => { join(getOpenCodeCacheDir(), "packages", "node_modules", PACKAGE_NAME, "package.json") ) }) + + it("PACKAGE_NAME matches the published package.json name", async () => { + // given the canonical package.json shipped with the plugin + const here = fileURLToPath(import.meta.url) + const repoPackageJsonPath = join(here, "..", "..", "..", "..", "package.json") + const repoPackageJson = JSON.parse(readFileSync(repoPackageJsonPath, "utf-8")) as { name: string } + + // when the auto-update-checker constants are loaded + const { PACKAGE_NAME } = await import(`./constants?test=${Date.now()}`) + + // then PACKAGE_NAME equals the actually published package name + expect(PACKAGE_NAME).toBe(repoPackageJson.name) + }) }) diff --git a/src/hooks/auto-update-checker/constants.ts b/src/hooks/auto-update-checker/constants.ts index 54eb2c7f6..9a40ecfb4 100644 --- a/src/hooks/auto-update-checker/constants.ts +++ b/src/hooks/auto-update-checker/constants.ts @@ -3,7 +3,7 @@ import * as os from "node:os" import { getOpenCodeCacheDir } from "../../shared/data-path" import { getOpenCodeConfigDir } from "../../shared/opencode-config-dir" -export const PACKAGE_NAME = "oh-my-openagent" +export const PACKAGE_NAME = "oh-my-opencode" export const NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags` export const NPM_FETCH_TIMEOUT = 5000