fix: resolve ${CLAUDE_PLUGIN_ROOT} in plugin commands, agents, and skills

When loading Claude Code plugins, the hooks JSON config already had
${CLAUDE_PLUGIN_ROOT} replaced via resolvePluginPath. However, command
markdown bodies, agent prompts, and skill content were passed through
as-is, leaving the variable unresolved. This caused plugin commands
(e.g. codex:review) to fail when executed in OpenCode because the shell
had no CLAUDE_PLUGIN_ROOT environment variable set.

Apply resolvePluginPath to:
- command-loader.ts: command body before wrapping in template
- agent-loader.ts: agent prompt body
- skill-loader.ts: skill body after @path resolution
This commit is contained in:
Biem
2026-05-04 19:47:08 +08:00
parent 6b9731923d
commit a26117d944
3 changed files with 8 additions and 3 deletions
@@ -3,6 +3,7 @@ import { basename, join } from "path"
import { parseFrontmatter } from "../../shared/frontmatter"
import { isMarkdownFile } from "../../shared/file-utils"
import { sanitizeModelField } from "../../shared/model-sanitizer"
import { resolvePluginPath } from "./plugin-path-resolver"
import { log } from "../../shared/logger"
import type { CommandDefinition, CommandFrontmatter } from "../claude-code-command-loader/types"
import type { LoadedPlugin } from "./types"
@@ -26,7 +27,8 @@ export function loadPluginCommands(plugins: LoadedPlugin[]): Record<string, Comm
const content = readFileSync(commandPath, "utf-8")
const { data, body } = parseFrontmatter<CommandFrontmatter>(content)
const wrappedTemplate = `<command-instruction>\n${body.trim()}\n</command-instruction>\n\n<user-request>\n$ARGUMENTS\n</user-request>`
const resolvedBody = resolvePluginPath(body, plugin.installPath)
const wrappedTemplate = `<command-instruction>\n${resolvedBody.trim()}\n</command-instruction>\n\n<user-request>\n$ARGUMENTS\n</user-request>`
const formattedDescription = `(plugin: ${plugin.name}) ${data.description || ""}`
const definition = {