mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
fix(cli): sanitize skill names and clean up comments
Part of https://github.com/google-gemini/gemini-cli/pull/21758
This commit is contained in:
@@ -108,4 +108,18 @@ describe('SkillCommandLoader', () => {
|
|||||||
postSubmitPrompt: 'hello world',
|
postSubmitPrompt: 'hello world',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should sanitize skill names with spaces', async () => {
|
||||||
|
const mockSkills = [{ name: 'my awesome skill', description: 'Desc' }];
|
||||||
|
mockSkillManager.getDisplayableSkills.mockReturnValue(mockSkills);
|
||||||
|
|
||||||
|
const loader = new SkillCommandLoader(mockConfig);
|
||||||
|
const commands = await loader.loadCommands(new AbortController().signal);
|
||||||
|
|
||||||
|
expect(commands[0].name).toBe('my-awesome-skill');
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const actionResult = await commands[0].action!({} as any, '');
|
||||||
|
expect(actionResult.toolArgs).toEqual({ name: 'my awesome skill' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,23 +31,23 @@ export class SkillCommandLoader implements ICommandLoader {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only include enabled skills that are not built-in (since built-in skills
|
// Convert all displayable skills into slash commands.
|
||||||
// are usually internal or have dedicated slash commands).
|
|
||||||
// Actually, the user says "if you have a skill called google-foo", so we
|
|
||||||
// should probably include all user/workspace/extension skills.
|
|
||||||
const skills = skillManager.getDisplayableSkills();
|
const skills = skillManager.getDisplayableSkills();
|
||||||
|
|
||||||
return skills.map((skill) => ({
|
return skills.map((skill) => {
|
||||||
name: skill.name,
|
const commandName = skill.name.trim().replace(/\s+/g, '-');
|
||||||
description: skill.description || `Activate the ${skill.name} skill`,
|
return {
|
||||||
kind: CommandKind.SKILL,
|
name: commandName,
|
||||||
autoExecute: true,
|
description: skill.description || `Activate the ${skill.name} skill`,
|
||||||
action: async (_context, args) => ({
|
kind: CommandKind.SKILL,
|
||||||
|
autoExecute: true,
|
||||||
|
action: async (_context, args) => ({
|
||||||
type: 'tool',
|
type: 'tool',
|
||||||
toolName: ACTIVATE_SKILL_TOOL_NAME,
|
toolName: ACTIVATE_SKILL_TOOL_NAME,
|
||||||
toolArgs: { name: skill.name },
|
toolArgs: { name: skill.name },
|
||||||
postSubmitPrompt: args.trim().length > 0 ? args.trim() : undefined,
|
postSubmitPrompt: args.trim().length > 0 ? args.trim() : undefined,
|
||||||
}),
|
}),
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user