feat: auto-resolve @path references in skill templates to absolute paths

Skill loaders previously only told agents that @path references are
relative to the skill directory, but agents often failed to resolve
them. Now @path/with/slash patterns are automatically expanded to
absolute paths during template construction.
This commit is contained in:
YeonGyu-Kim
2026-02-09 11:37:57 +09:00
parent 8dd07973a9
commit 70ac962fca
6 changed files with 133 additions and 4 deletions
@@ -5,6 +5,7 @@ import type { AgentConfig } from "@opencode-ai/sdk"
import { parseFrontmatter } from "../../shared/frontmatter"
import { sanitizeModelField } from "../../shared/model-sanitizer"
import { isMarkdownFile, resolveSymlink } from "../../shared/file-utils"
import { resolveSkillPathReferences } from "../../shared/skill-path-resolver"
import { log } from "../../shared/logger"
import { expandEnvVarsInObject } from "../claude-code-mcp-loader/env-expander"
import { transformMcpServer } from "../claude-code-mcp-loader/transformer"
@@ -297,11 +298,12 @@ export function loadPluginSkillsAsCommands(
const originalDescription = data.description || ""
const formattedDescription = `(plugin: ${plugin.name} - Skill) ${originalDescription}`
const resolvedBody = resolveSkillPathReferences(body.trim(), resolvedPath)
const wrappedTemplate = `<skill-instruction>
Base directory for this skill: ${resolvedPath}/
File references (@path) in this skill are relative to this directory.
${body.trim()}
${resolvedBody}
</skill-instruction>
<user-request>