fix(skill): provide directory context in system prompt and slash-command paths#33787
fix(skill): provide directory context in system prompt and slash-command paths#33787shyuan wants to merge 1 commit into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: Related PR:
These appear to be complementary fixes for different aspects of skill context handling rather than direct duplicates. No other duplicate PRs found addressing the same specific issues of URL-encoded |
|
Re: the bot's note about #29429 Worth clarifying since the bot framed them as "complementary" — for bug 2 (slash-command skills lacking directory context), #29429 and this PR actually overlap on the same lines in
I went with the lightweight approach because it resolves the reported symptom (agent can't locate bundled |
1602dcb to
26508f0
Compare
The skill's base directory was missing or URL-encoded in two code paths, preventing the agent from resolving bundled resources (references/, scripts/) relative to the skill install directory. 1. System prompt <available_skills> <location> used pathToFileURL, URL-encoding characters like # from git-tagged plugin cache dirs. Emit the plain filesystem path instead — same fix as anomalyco#33580 but for the second occurrence in skill/index.ts fmt(). 2. Skills invoked as slash commands (/skill-name) injected only the raw SKILL.md content into the prompt with no directory context at all. The agent had no way to locate bundled files. Inject the base directory hint, matching the skill tool's output format.
26508f0 to
3aab7ef
Compare
|
Superseded by #34052 (
The only remaining unique change here was a doc-string typo ( |
Issue for this PR
Closes #33786
Type of change
What does this PR do?
The skill's base directory was missing or URL-encoded in two code paths, preventing the agent from resolving bundled resources (references/, scripts/) relative to the skill install directory.
1. System prompt
<available_skills>URL-encoded<location>Skill.fmt()inpackages/opencode/src/skill/index.tsusedpathToFileURL(skill.location).hreffor the<location>field. This is the same bug #33580 fixed in theskilltool's base directory, but this second occurrence in the system prompt was missed. When a skill lives in a git-tagged plugin cache dir (e.g....git#v1.3.0), the agent sees...git%23v1.3.0and cannot use the path. Changed to emitskill.locationdirectly.2. Slash-command skills had no directory context
When a user types
/skill-name, the skill is registered as a command (packages/opencode/src/command/index.ts) whosetemplatereturned onlyitem.content— the raw SKILL.md body. Unlike theskilltool, there was noBase directoryhint, so the agent had no way to locate bundled files. Added the base directory + relative-path hint to the template, matching theskilltool's output format.How did you verify your code works?
bun test test/skill/skill.test.ts— 16 tests passbun test test/tool/skill.test.ts— 2 tests passSkill.fmt()now emits a plain path, and skill-as-command templates now include the base directory lineScreenshots / recordings
N/A — no UI change.
Checklist