Files
oh-my-opencode/src/cli/config-manager/plugin-name-with-version.ts
T
YeonGyu-Kim 1c54fdad26 feat(compat): package rename compatibility layer for oh-my-opencode → oh-my-openagent
- Add legacy plugin startup warning when oh-my-opencode config detected
- Update CLI installer and TUI installer for new package name
- Split monolithic config-manager.test.ts into focused test modules
- Add plugin config detection tests for legacy name fallback
- Update processed-command-store to use plugin-identity constants
- Add claude-code-plugin-loader discovery test for both config names
- Update chat-params and ultrawork-db tests for plugin identity

Part of #2823
2026-03-26 19:44:55 +09:00

34 lines
938 B
TypeScript

import { PLUGIN_NAME } from "../../shared"
import { fetchNpmDistTags } from "./npm-dist-tags"
const DEFAULT_PACKAGE_NAME = PLUGIN_NAME
const PRIORITIZED_TAGS = ["latest", "beta", "next"] as const
function getFallbackEntry(version: string, packageName: string): string {
const prereleaseMatch = version.match(/-([a-zA-Z][a-zA-Z0-9-]*)(?:\.|$)/)
if (prereleaseMatch) {
return `${packageName}@${prereleaseMatch[1]}`
}
return packageName
}
export async function getPluginNameWithVersion(
currentVersion: string,
packageName: string = DEFAULT_PACKAGE_NAME
): Promise<string> {
const distTags = await fetchNpmDistTags(packageName)
if (distTags) {
const allTags = new Set([...PRIORITIZED_TAGS, ...Object.keys(distTags)])
for (const tag of allTags) {
if (distTags[tag] === currentVersion) {
return `${packageName}@${tag}`
}
}
}
return getFallbackEntry(currentVersion, packageName)
}