From a46e6283f73f1c037c7a76b05966dea96b34325b Mon Sep 17 00:00:00 2001 From: imtiazNDMA Date: Wed, 27 May 2026 20:59:09 +0500 Subject: [PATCH] fix(core): include skill base directory in /skill-name command template When invoking a skill via /skill-name, the command system only injected the raw SKILL.md content as the prompt template. This meant the agent had no knowledge of the skill's base directory or its reference files. Now the template includes the skill's base directory in the same format as the SkillTool output, so the agent can use Glob/Grep/Read to find and inspect reference files. Fixes #24831 --- packages/opencode/src/command/index.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/command/index.ts b/packages/opencode/src/command/index.ts index 96e171733df0..4fe0b43f8f2f 100644 --- a/packages/opencode/src/command/index.ts +++ b/packages/opencode/src/command/index.ts @@ -1,3 +1,5 @@ +import path from "path" +import { pathToFileURL } from "url" import { BusEvent } from "@/bus/bus-event" import { InstanceState } from "@/effect/instance-state" import { EffectBridge } from "@/effect/bridge" @@ -140,12 +142,24 @@ export const layer = Layer.effect( for (const item of yield* skill.all()) { if (commands[item.name]) continue + const dir = path.dirname(item.location) + const base = pathToFileURL(dir).href commands[item.name] = { name: item.name, description: item.description, source: "skill", get template() { - return item.content + return [ + ``, + `# Skill: ${item.name}`, + "", + item.content.trim(), + "", + `Base directory for this skill: ${base}`, + "Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.", + "Note: you can use Glob, Grep, and Read tools to find and inspect reference files.", + "", + ].join("\n") }, hints: [], }