refactor(doctor): use plugin-identity constants for package names

Update doctor checks to use centralized constants from plugin-identity:
- PACKAGE_NAME now references PUBLISHED_PACKAGE_NAME
- System check uses PLUGIN_NAME and LEGACY_PLUGIN_NAME for plugin
  registration validation and legacy name detection
- Formatters updated for consistency

🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
YeonGyu-Kim
2026-04-10 11:16:08 +09:00
parent 58a981e07b
commit 41b9b4d724
6 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ describe("system check", () => {
//#then
const outdatedIssue = result.issues.find((issue) => issue.title === "Loaded plugin is outdated")
expect(outdatedIssue?.fix).toBe(
`Update: cd "/Users/test/Library/Caches/opencode with spaces" && bun add ${PLUGIN_NAME}@canary`
'Update: cd "/Users/test/Library/Caches/opencode with spaces" && bun add oh-my-opencode@canary'
)
})
})
+3 -3
View File
@@ -6,7 +6,7 @@ import { findOpenCodeBinary, getOpenCodeVersion, compareVersions } from "./syste
import { getPluginInfo } from "./system-plugin"
import { getLatestPluginVersion, getLoadedPluginVersion, getSuggestedInstallTag } from "./system-loaded-version"
import { parseJsonc } from "../../../shared"
import { PLUGIN_NAME, LEGACY_PLUGIN_NAME } from "../../../shared/plugin-identity"
import { PUBLISHED_PACKAGE_NAME, PLUGIN_NAME, LEGACY_PLUGIN_NAME } from "../../../shared/plugin-identity"
function isConfigValid(configPath: string | null): boolean {
if (!configPath) return true
@@ -85,7 +85,7 @@ export async function checkSystem(): Promise<CheckResult> {
issues.push({
title: `${PLUGIN_NAME} is not registered`,
description: "Plugin entry is missing from OpenCode configuration.",
fix: `Run: bunx ${PLUGIN_NAME} install`,
fix: `Run: bunx ${PUBLISHED_PACKAGE_NAME} install`,
severity: "error",
affects: ["all agents"],
})
@@ -125,7 +125,7 @@ export async function checkSystem(): Promise<CheckResult> {
issues.push({
title: "Loaded plugin is outdated",
description: `Loaded ${systemInfo.loadedVersion}, latest ${latestVersion}.`,
fix: `Update: cd "${loadedInfo.cacheDir}" && bun add ${PLUGIN_NAME}@${installTag}`,
fix: `Update: cd "${loadedInfo.cacheDir}" && bun add ${PUBLISHED_PACKAGE_NAME}@${installTag}`,
severity: "warning",
affects: ["plugin features"],
})
+2 -2
View File
@@ -1,5 +1,5 @@
import color from "picocolors"
import { PLUGIN_NAME } from "../../shared"
import { PUBLISHED_PACKAGE_NAME } from "../../shared"
export const SYMBOLS = {
check: color.green("\u2713"),
@@ -39,6 +39,6 @@ export const EXIT_CODES = {
export const MIN_OPENCODE_VERSION = "1.4.0"
export const PACKAGE_NAME = PLUGIN_NAME
export const PACKAGE_NAME = PUBLISHED_PACKAGE_NAME
export const OPENCODE_BINARIES = ["opencode", "opencode-desktop"] as const
+3 -1
View File
@@ -1,4 +1,5 @@
import color from "picocolors"
import { PLUGIN_NAME } from "../../shared"
import type { DoctorResult } from "./types"
import { SYMBOLS } from "./constants"
import { formatHeader, formatIssue } from "./format-shared"
@@ -15,7 +16,8 @@ export function formatDefault(result: DoctorResult): string {
const pluginVer = result.systemInfo.pluginVersion ?? "unknown"
lines.push(
` ${color.green(SYMBOLS.check)} ${color.green(
`System OK (opencode ${opencodeVer} · oh-my-opencode ${pluginVer})`
`System OK (opencode ${opencodeVer} · oh-my-opencode ${pluginVer})`
.replace("oh-my-opencode", PLUGIN_NAME)
)}`
)
} else {
+2 -1
View File
@@ -1,4 +1,5 @@
import color from "picocolors"
import { PLUGIN_NAME } from "../../shared"
import type { DoctorResult } from "./types"
import { formatHeader, formatStatusSymbol, formatIssue } from "./format-shared"
@@ -12,7 +13,7 @@ export function formatVerbose(result: DoctorResult): string {
lines.push(`${color.bold("System Information")}`)
lines.push(`${color.dim("\u2500".repeat(40))}`)
lines.push(` ${formatStatusSymbol("pass")} opencode ${systemInfo.opencodeVersion ?? "unknown"}`)
lines.push(` ${formatStatusSymbol("pass")} oh-my-opencode ${systemInfo.pluginVersion ?? "unknown"}`)
lines.push(` ${formatStatusSymbol("pass")} ${PLUGIN_NAME} ${systemInfo.pluginVersion ?? "unknown"}`)
if (systemInfo.loadedVersion) {
lines.push(` ${formatStatusSymbol("pass")} loaded ${systemInfo.loadedVersion}`)
}
+1 -1
View File
@@ -81,7 +81,7 @@ describe("formatDoctorOutput", () => {
const output = stripAnsi(formatDoctorOutput(result, "default"))
//#then
expect(output).toContain("System OK (opencode 1.0.200 · oh-my-opencode 3.4.0)")
expect(output).toContain("System OK (opencode 1.0.200 · oh-my-openagent 3.4.0)")
})
it("shows issue count and details when issues exist", async () => {