fix(#2941): hint at global: prefix when bare skill name matches a global skill (#2973)

* test(#2941): add regression for bare-skill-name global: hint

When a bare skill name matches an existing global skill, the skip warning
must hint at the global: prefix. When no global skill matches, the original
'Skill not found' warning is unchanged.

* fix(#2941): hint at global: prefix when a bare skill name matches a global skill

When buildAgentSkillsBlock skips a bare skill name that doesn't exist as a
project-relative path, check if it matches an existing global skill. If so,
append a hint to the warning: 'a global skill named X exists; use global:X
to reference it'. When no global skill matches, the warning is unchanged.

getGlobalSkillDir and getGlobalSkillsBase are already imported in this module
for the global: branch. The hint is guarded on globalSkillsBase being non-null
(runtimes without a skills directory don't support the prefix).

* chore(#2941): add changeset fragment

* chore(#2941): backfill changeset PR number 2973

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-08-01 10:58:50 -04:00
committed by GitHub
parent 608be0e7cf
commit 000a322489
3 changed files with 62 additions and 1 deletions

View File

@@ -2201,8 +2201,21 @@ function buildAgentSkillsBlock(
const skillMdPath = path.join(projectRoot, skillPath, 'SKILL.md');
if (!fs.existsSync(skillMdPath)) {
// #2941: if the bare name matches a global skill, hint at the global: prefix.
// The bare name resolves as project-relative (which doesn't exist), but the
// user likely meant to reference a global skill. getGlobalSkillDir is already
// imported for the global: branch above; guard on globalSkillsBase being non-null
// since runtimes without a skills directory don't support the prefix.
let hint = '';
if (globalSkillsBase !== null) {
const baseName = path.basename(skillPath);
const globalDir = getGlobalSkillDir(runtime, baseName) as string;
if (globalDir && fs.existsSync(path.join(globalDir, 'SKILL.md'))) {
hint = ` — a global skill named "${baseName}" exists; use "global:${baseName}" to reference it`;
}
}
warn(
`[agent-skills] WARNING: Skill not found at "${skillPath}/SKILL.md" — skipping\n`,
`[agent-skills] WARNING: Skill not found at "${skillPath}/SKILL.md"${hint} — skipping\n`,
);
continue;
}