fix(cli): write version-aware plugin entry during installation

Previously, the installer always wrote 'oh-my-opencode' without a version,
causing users who installed beta versions (e.g., bunx oh-my-opencode@beta)
to unexpectedly load the stable version on next OpenCode startup.

Now the installer queries npm dist-tags and writes:
- @latest when current version matches the latest tag
- @beta when current version matches the beta tag
- @<version> when no tag matches (pins to specific version)

This ensures:
- bunx oh-my-opencode install → @latest (tracks stable)
- bunx oh-my-opencode@beta install → @beta (tracks beta tag)
- bunx oh-my-opencode@3.0.0-beta.2 install → @3.0.0-beta.2 (pinned)
This commit is contained in:
aw338WoWmUI
2026-01-11 12:53:41 +08:00
committed by Spark
parent 9afef676e0
commit 79d46eea54
3 changed files with 199 additions and 12 deletions
+5 -2
View File
@@ -11,6 +11,9 @@ import {
detectCurrentConfig,
} from "./config-manager"
const packageJson = await import("../../package.json")
const VERSION = packageJson.version
const SYMBOLS = {
check: color.green("✓"),
cross: color.red("✗"),
@@ -250,7 +253,7 @@ async function runNonTuiInstall(args: InstallArgs): Promise<number> {
const config = argsToConfig(args)
printStep(step++, totalSteps, "Adding oh-my-opencode plugin...")
const pluginResult = addPluginToOpenCodeConfig()
const pluginResult = await addPluginToOpenCodeConfig(VERSION)
if (!pluginResult.success) {
printError(`Failed: ${pluginResult.error}`)
return 1
@@ -360,7 +363,7 @@ export async function install(args: InstallArgs): Promise<number> {
if (!config) return 1
s.start("Adding oh-my-opencode to OpenCode config")
const pluginResult = addPluginToOpenCodeConfig()
const pluginResult = await addPluginToOpenCodeConfig(VERSION)
if (!pluginResult.success) {
s.stop(`Failed to add plugin: ${pluginResult.error}`)
p.outro(color.red("Installation failed."))