mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-29 22:44:45 -07:00
fix: Handle colons in skill description frontmatter (#16345)
Co-authored-by: gemini-code-assist[bot] <gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -100,4 +100,98 @@ describe('skillLoader', () => {
|
||||
expect(skills).toEqual([]);
|
||||
expect(coreEvents.emitFeedback).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should parse skill with colon in description (issue #16323)', async () => {
|
||||
const skillDir = path.join(testRootDir, 'colon-skill');
|
||||
await fs.mkdir(skillDir, { recursive: true });
|
||||
const skillFile = path.join(skillDir, 'SKILL.md');
|
||||
await fs.writeFile(
|
||||
skillFile,
|
||||
`---
|
||||
name: foo
|
||||
description: Simple story generation assistant for fiction writing. Use for creating characters, scenes, storylines, and prose. Trigger words: character, scene, storyline, story, prose, fiction, writing.
|
||||
---
|
||||
# Instructions
|
||||
Do something.
|
||||
`,
|
||||
);
|
||||
|
||||
const skills = await loadSkillsFromDir(testRootDir);
|
||||
|
||||
expect(skills).toHaveLength(1);
|
||||
expect(skills[0].name).toBe('foo');
|
||||
expect(skills[0].description).toContain('Trigger words:');
|
||||
});
|
||||
|
||||
it('should parse skill with multiple colons in description', async () => {
|
||||
const skillDir = path.join(testRootDir, 'multi-colon-skill');
|
||||
await fs.mkdir(skillDir, { recursive: true });
|
||||
const skillFile = path.join(skillDir, 'SKILL.md');
|
||||
await fs.writeFile(
|
||||
skillFile,
|
||||
`---
|
||||
name: multi-colon
|
||||
description: Use this for tasks like: coding, reviewing, testing. Keywords: async, await, promise.
|
||||
---
|
||||
# Instructions
|
||||
Do something.
|
||||
`,
|
||||
);
|
||||
|
||||
const skills = await loadSkillsFromDir(testRootDir);
|
||||
|
||||
expect(skills).toHaveLength(1);
|
||||
expect(skills[0].name).toBe('multi-colon');
|
||||
expect(skills[0].description).toContain('tasks like:');
|
||||
expect(skills[0].description).toContain('Keywords:');
|
||||
});
|
||||
|
||||
it('should parse skill with quoted YAML description (backward compatibility)', async () => {
|
||||
const skillDir = path.join(testRootDir, 'quoted-skill');
|
||||
await fs.mkdir(skillDir, { recursive: true });
|
||||
const skillFile = path.join(skillDir, 'SKILL.md');
|
||||
await fs.writeFile(
|
||||
skillFile,
|
||||
`---
|
||||
name: quoted-skill
|
||||
description: "A skill with colons: like this one: and another."
|
||||
---
|
||||
# Instructions
|
||||
Do something.
|
||||
`,
|
||||
);
|
||||
|
||||
const skills = await loadSkillsFromDir(testRootDir);
|
||||
|
||||
expect(skills).toHaveLength(1);
|
||||
expect(skills[0].name).toBe('quoted-skill');
|
||||
expect(skills[0].description).toBe(
|
||||
'A skill with colons: like this one: and another.',
|
||||
);
|
||||
});
|
||||
|
||||
it('should parse skill with multi-line YAML description', async () => {
|
||||
const skillDir = path.join(testRootDir, 'multiline-skill');
|
||||
await fs.mkdir(skillDir, { recursive: true });
|
||||
const skillFile = path.join(skillDir, 'SKILL.md');
|
||||
await fs.writeFile(
|
||||
skillFile,
|
||||
`---
|
||||
name: multiline-skill
|
||||
description:
|
||||
Expertise in reviewing code for style, security, and performance. Use when the
|
||||
user asks for "feedback," a "review," or to "check" their changes.
|
||||
---
|
||||
# Instructions
|
||||
Do something.
|
||||
`,
|
||||
);
|
||||
|
||||
const skills = await loadSkillsFromDir(testRootDir);
|
||||
|
||||
expect(skills).toHaveLength(1);
|
||||
expect(skills[0].name).toBe('multiline-skill');
|
||||
expect(skills[0].description).toContain('Expertise in reviewing code');
|
||||
expect(skills[0].description).toContain('check');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user