feat(skills): implement linking for agent skills (#18295)

This commit is contained in:
Grant McCloskey
2026-02-04 14:11:01 -08:00
committed by GitHub
parent 821355c429
commit a3af4a8cae
16 changed files with 584 additions and 8 deletions

View File

@@ -254,4 +254,21 @@ description:no-space-desc
expect(skills[0].name).toBe('no-space-name');
expect(skills[0].description).toBe('no-space-desc');
});
it('should sanitize skill names containing invalid filename characters', async () => {
const skillFile = path.join(testRootDir, 'SKILL.md');
await fs.writeFile(
skillFile,
`---
name: gke:prs-troubleshooter
description: Test sanitization
---
`,
);
const skills = await loadSkillsFromDir(testRootDir);
expect(skills).toHaveLength(1);
expect(skills[0].name).toBe('gke-prs-troubleshooter');
});
});

View File

@@ -121,10 +121,12 @@ export async function loadSkillsFromDir(
return [];
}
const skillFiles = await glob(['SKILL.md', '*/SKILL.md'], {
const pattern = ['SKILL.md', '*/SKILL.md'];
const skillFiles = await glob(pattern, {
cwd: absoluteSearchPath,
absolute: true,
nodir: true,
ignore: ['**/node_modules/**', '**/.git/**'],
});
for (const skillFile of skillFiles) {
@@ -171,8 +173,11 @@ export async function loadSkillFromFile(
return null;
}
// Sanitize name for use as a filename/directory name (e.g. replace ':' with '-')
const sanitizedName = frontmatter.name.replace(/[:\\/<>*?"|]/g, '-');
return {
name: frontmatter.name,
name: sanitizedName,
description: frontmatter.description,
location: filePath,
body: match[2]?.trim() ?? '',