mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 10:01:29 -07:00
feat(skills): implement linking for agent skills (#18295)
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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() ?? '',
|
||||
|
||||
Reference in New Issue
Block a user