mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
feat(cli): add /agents slash command to list available agents (#16182)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type { SlashCommand, CommandContext } from './types.js';
|
||||
import { CommandKind } from './types.js';
|
||||
import { MessageType, type HistoryItemAgentsList } from '../types.js';
|
||||
|
||||
export const agentsCommand: SlashCommand = {
|
||||
name: 'agents',
|
||||
description: 'List available local and remote agents',
|
||||
kind: CommandKind.BUILT_IN,
|
||||
autoExecute: true,
|
||||
action: async (context: CommandContext) => {
|
||||
const { config } = context.services;
|
||||
if (!config) {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: 'Config not loaded.',
|
||||
};
|
||||
}
|
||||
|
||||
const agentRegistry = config.getAgentRegistry();
|
||||
if (!agentRegistry) {
|
||||
return {
|
||||
type: 'message',
|
||||
messageType: 'error',
|
||||
content: 'Agent registry not found.',
|
||||
};
|
||||
}
|
||||
|
||||
const agents = agentRegistry.getAllDefinitions().map((def) => ({
|
||||
name: def.name,
|
||||
displayName: def.displayName,
|
||||
description: def.description,
|
||||
kind: def.kind,
|
||||
}));
|
||||
|
||||
const agentsListItem: HistoryItemAgentsList = {
|
||||
type: MessageType.AGENTS_LIST,
|
||||
agents,
|
||||
};
|
||||
|
||||
context.ui.addItem(agentsListItem, Date.now());
|
||||
|
||||
return;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user