diff --git a/packages/opencode/src/command/index.ts b/packages/opencode/src/command/index.ts index 4c71ff577673..b59db7f40af4 100644 --- a/packages/opencode/src/command/index.ts +++ b/packages/opencode/src/command/index.ts @@ -1,4 +1,5 @@ import { LayerNode } from "@opencode-ai/core/effect/layer-node" +import path from "path" import { InstanceState } from "@/effect/instance-state" import { EffectBridge } from "@/effect/bridge" import type { InstanceContext } from "@/project/instance-context" @@ -132,12 +133,20 @@ export const layer = Layer.effect( for (const item of yield* skill.all()) { if (commands[item.name]) continue + // Built-in skills have no on-disk directory, so omit the base-directory hint. + const dir = item.location === "" ? undefined : path.dirname(item.location) commands[item.name] = { name: item.name, description: item.description, source: "skill", get template() { - return item.content + if (!dir) return item.content + return [ + item.content, + "", + `Base directory for this skill: ${dir}`, + "Relative paths in this skill (e.g., scripts/, references/) are relative to this base directory.", + ].join("\n") }, hints: [], } diff --git a/packages/opencode/src/skill/index.ts b/packages/opencode/src/skill/index.ts index 08a88a215432..5e2040137711 100644 --- a/packages/opencode/src/skill/index.ts +++ b/packages/opencode/src/skill/index.ts @@ -1,6 +1,5 @@ import { LayerNode } from "@opencode-ai/core/effect/layer-node" import path from "path" -import { pathToFileURL } from "url" import { Effect, Layer, Context, Schema } from "effect" import { NamedError } from "@opencode-ai/core/util/error" import type { Agent } from "@/agent/agent" @@ -339,7 +338,7 @@ export function fmt(list: Info[], opts: { verbose: boolean }) { " ", ` ${skill.name}`, ` ${skill.description}`, - ` ${pathToFileURL(skill.location).href}`, + ` ${skill.location}`, " ", ]), "", diff --git a/packages/opencode/src/tool/skill.ts b/packages/opencode/src/tool/skill.ts index 9149bcc5ff0d..7a6306268e6f 100644 --- a/packages/opencode/src/tool/skill.ts +++ b/packages/opencode/src/tool/skill.ts @@ -51,7 +51,7 @@ export const SkillTool = Tool.define( info.content.trim(), "", `Base directory for this skill: ${base}`, - "Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.", + "Relative paths in this skill (e.g., scripts/, references/) are relative to this base directory.", "Note: file list is sampled.", "", "",