| |
| |
| |
| |
| |
|
|
| import { type Config, ACTIVATE_SKILL_TOOL_NAME } from '@google/gemini-cli-core'; |
| import { CommandKind, type SlashCommand } from '../ui/commands/types.js'; |
| import { type ICommandLoader } from './types.js'; |
|
|
| |
| |
| |
| export class SkillCommandLoader implements ICommandLoader { |
| constructor(private config: Config | null) {} |
|
|
| |
| |
| |
| |
| |
| |
| |
| async loadCommands(_signal: AbortSignal): Promise<SlashCommand[]> { |
| if (!this.config || !this.config.isSkillsSupportEnabled()) { |
| return []; |
| } |
|
|
| const skillManager = this.config.getSkillManager(); |
| if (!skillManager || !skillManager.isAdminEnabled()) { |
| return []; |
| } |
|
|
| |
| const skills = skillManager.getDisplayableSkills(); |
|
|
| return skills.map((skill) => { |
| const commandName = skill.name.trim().replace(/\s+/g, '-'); |
| return { |
| name: commandName, |
| description: skill.description || `Activate the ${skill.name} skill`, |
| kind: CommandKind.SKILL, |
| autoExecute: true, |
| extensionName: skill.extensionName, |
| action: async (_context, args) => ({ |
| type: 'tool', |
| toolName: ACTIVATE_SKILL_TOOL_NAME, |
| toolArgs: { name: skill.name }, |
| postSubmitPrompt: |
| args.trim().length > 0 |
| ? args.trim() |
| : `Use the skill ${skill.name}`, |
| }), |
| }; |
| }); |
| } |
| } |
|
|