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:
@@ -125,7 +125,7 @@ describe("system check", () => {
|
|||||||
//#then
|
//#then
|
||||||
const outdatedIssue = result.issues.find((issue) => issue.title === "Loaded plugin is outdated")
|
const outdatedIssue = result.issues.find((issue) => issue.title === "Loaded plugin is outdated")
|
||||||
expect(outdatedIssue?.fix).toBe(
|
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'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { findOpenCodeBinary, getOpenCodeVersion, compareVersions } from "./syste
|
|||||||
import { getPluginInfo } from "./system-plugin"
|
import { getPluginInfo } from "./system-plugin"
|
||||||
import { getLatestPluginVersion, getLoadedPluginVersion, getSuggestedInstallTag } from "./system-loaded-version"
|
import { getLatestPluginVersion, getLoadedPluginVersion, getSuggestedInstallTag } from "./system-loaded-version"
|
||||||
import { parseJsonc } from "../../../shared"
|
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 {
|
function isConfigValid(configPath: string | null): boolean {
|
||||||
if (!configPath) return true
|
if (!configPath) return true
|
||||||
@@ -85,7 +85,7 @@ export async function checkSystem(): Promise<CheckResult> {
|
|||||||
issues.push({
|
issues.push({
|
||||||
title: `${PLUGIN_NAME} is not registered`,
|
title: `${PLUGIN_NAME} is not registered`,
|
||||||
description: "Plugin entry is missing from OpenCode configuration.",
|
description: "Plugin entry is missing from OpenCode configuration.",
|
||||||
fix: `Run: bunx ${PLUGIN_NAME} install`,
|
fix: `Run: bunx ${PUBLISHED_PACKAGE_NAME} install`,
|
||||||
severity: "error",
|
severity: "error",
|
||||||
affects: ["all agents"],
|
affects: ["all agents"],
|
||||||
})
|
})
|
||||||
@@ -125,7 +125,7 @@ export async function checkSystem(): Promise<CheckResult> {
|
|||||||
issues.push({
|
issues.push({
|
||||||
title: "Loaded plugin is outdated",
|
title: "Loaded plugin is outdated",
|
||||||
description: `Loaded ${systemInfo.loadedVersion}, latest ${latestVersion}.`,
|
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",
|
severity: "warning",
|
||||||
affects: ["plugin features"],
|
affects: ["plugin features"],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import color from "picocolors"
|
import color from "picocolors"
|
||||||
import { PLUGIN_NAME } from "../../shared"
|
import { PUBLISHED_PACKAGE_NAME } from "../../shared"
|
||||||
|
|
||||||
export const SYMBOLS = {
|
export const SYMBOLS = {
|
||||||
check: color.green("\u2713"),
|
check: color.green("\u2713"),
|
||||||
@@ -39,6 +39,6 @@ export const EXIT_CODES = {
|
|||||||
|
|
||||||
export const MIN_OPENCODE_VERSION = "1.4.0"
|
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
|
export const OPENCODE_BINARIES = ["opencode", "opencode-desktop"] as const
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import color from "picocolors"
|
import color from "picocolors"
|
||||||
|
import { PLUGIN_NAME } from "../../shared"
|
||||||
import type { DoctorResult } from "./types"
|
import type { DoctorResult } from "./types"
|
||||||
import { SYMBOLS } from "./constants"
|
import { SYMBOLS } from "./constants"
|
||||||
import { formatHeader, formatIssue } from "./format-shared"
|
import { formatHeader, formatIssue } from "./format-shared"
|
||||||
@@ -15,7 +16,8 @@ export function formatDefault(result: DoctorResult): string {
|
|||||||
const pluginVer = result.systemInfo.pluginVersion ?? "unknown"
|
const pluginVer = result.systemInfo.pluginVersion ?? "unknown"
|
||||||
lines.push(
|
lines.push(
|
||||||
` ${color.green(SYMBOLS.check)} ${color.green(
|
` ${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 {
|
} else {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import color from "picocolors"
|
import color from "picocolors"
|
||||||
|
import { PLUGIN_NAME } from "../../shared"
|
||||||
import type { DoctorResult } from "./types"
|
import type { DoctorResult } from "./types"
|
||||||
import { formatHeader, formatStatusSymbol, formatIssue } from "./format-shared"
|
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.bold("System Information")}`)
|
||||||
lines.push(`${color.dim("\u2500".repeat(40))}`)
|
lines.push(`${color.dim("\u2500".repeat(40))}`)
|
||||||
lines.push(` ${formatStatusSymbol("pass")} opencode ${systemInfo.opencodeVersion ?? "unknown"}`)
|
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) {
|
if (systemInfo.loadedVersion) {
|
||||||
lines.push(` ${formatStatusSymbol("pass")} loaded ${systemInfo.loadedVersion}`)
|
lines.push(` ${formatStatusSymbol("pass")} loaded ${systemInfo.loadedVersion}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ describe("formatDoctorOutput", () => {
|
|||||||
const output = stripAnsi(formatDoctorOutput(result, "default"))
|
const output = stripAnsi(formatDoctorOutput(result, "default"))
|
||||||
|
|
||||||
//#then
|
//#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 () => {
|
it("shows issue count and details when issues exist", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user