fix: one-step codex installs by preferring bundled plugins (#383)

Co-authored-by: The Future is Work <future@Thes-Mac-Studio.local>
This commit is contained in:
thefutureisw0rk
2026-03-25 21:39:45 -07:00
committed by GitHub
parent 27b9831084
commit f819e435a5
2 changed files with 57 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ import { defineCommand } from "citty"
import { promises as fs } from "fs"
import os from "os"
import path from "path"
import { fileURLToPath } from "url"
import { loadClaudePlugin } from "../parsers/claude"
import { targets, validateScope } from "../targets"
import { pathExists } from "../utils/files"
@@ -233,7 +234,12 @@ async function resolvePluginPath(input: string): Promise<ResolvedPluginPath> {
throw new Error(`Local plugin path not found: ${directPath}`)
}
// Otherwise, always fetch the latest from GitHub
const bundledPluginPath = await resolveBundledPluginPath(input)
if (bundledPluginPath) {
return { path: bundledPluginPath }
}
// Otherwise, fetch the latest from GitHub
return await resolveGitHubPluginPath(input)
}
@@ -255,6 +261,16 @@ function resolveOutputRoot(value: unknown): string {
return path.join(os.homedir(), ".config", "opencode")
}
async function resolveBundledPluginPath(pluginName: string): Promise<string | null> {
const bundledRoot = fileURLToPath(new URL("../../plugins/", import.meta.url))
const pluginPath = path.join(bundledRoot, pluginName)
const manifestPath = path.join(pluginPath, ".claude-plugin", "plugin.json")
if (await pathExists(manifestPath)) {
return pluginPath
}
return null
}
async function resolveGitHubPluginPath(pluginName: string): Promise<ResolvedPluginPath> {
const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), "compound-plugin-"))
const source = resolveGitHubSource()