Merge pull request #3785 from Biemmmmm/fix/resolve-plugin-root-in-commands
fix: resolve ${CLAUDE_PLUGIN_ROOT} in plugin commands, agents, and skills
This commit is contained in:
@@ -4,6 +4,7 @@ import { parseFrontmatter } from "../../shared/frontmatter"
|
||||
import { isMarkdownFile } from "../../shared/file-utils"
|
||||
import { log } from "../../shared/logger"
|
||||
import { parseToolsConfig } from "../../shared/parse-tools-config"
|
||||
import { resolvePluginPath } from "./plugin-path-resolver"
|
||||
import type { AgentFrontmatter, ClaudeCodeAgentConfig } from "../claude-code-agent-loader/types"
|
||||
import { mapClaudeModelToOpenCode } from "../claude-code-agent-loader/claude-model-mapper"
|
||||
import type { LoadedPlugin } from "./types"
|
||||
@@ -38,7 +39,7 @@ export function loadPluginAgents(plugins: LoadedPlugin[]): Record<string, Claude
|
||||
const config: ClaudeCodeAgentConfig = {
|
||||
description: formattedDescription,
|
||||
mode: "subagent",
|
||||
prompt: body.trim(),
|
||||
prompt: resolvePluginPath(body.trim(), plugin.installPath),
|
||||
...(modelString ? { model: modelString } : {}),
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { parseFrontmatter } from "../../shared/frontmatter"
|
||||
import { resolveSymlink } from "../../shared/file-utils"
|
||||
import { sanitizeModelField } from "../../shared/model-sanitizer"
|
||||
import { resolveSkillPathReferences } from "../../shared/skill-path-resolver"
|
||||
import { resolvePluginPath } from "./plugin-path-resolver"
|
||||
import { log } from "../../shared/logger"
|
||||
import type { CommandDefinition } from "../claude-code-command-loader/types"
|
||||
import type { SkillMetadata } from "../opencode-skill-loader/types"
|
||||
@@ -39,7 +40,8 @@ export function loadPluginSkillsAsCommands(
|
||||
const formattedDescription = `(plugin: ${plugin.name} - Skill) ${originalDescription}`
|
||||
|
||||
const resolvedBody = resolveSkillPathReferences(body.trim(), resolvedPath)
|
||||
const wrappedTemplate = `<skill-instruction>\nBase directory for this skill: ${resolvedPath}/\nFile references (@path) in this skill are relative to this directory.\n\n${resolvedBody}\n</skill-instruction>\n\n<user-request>\n$ARGUMENTS\n</user-request>`
|
||||
const pluginResolvedBody = resolvePluginPath(resolvedBody, plugin.installPath)
|
||||
const wrappedTemplate = `<skill-instruction>\nBase directory for this skill: ${resolvedPath}/\nFile references (@path) in this skill are relative to this directory.\n\n${pluginResolvedBody}\n</skill-instruction>\n\n<user-request>\n$ARGUMENTS\n</user-request>`
|
||||
|
||||
const definition = {
|
||||
name: namespacedName,
|
||||
|
||||
Reference in New Issue
Block a user