@@ -11,43 +11,60 @@ import {
1111} from './types.js' ;
1212import { MessageType , type HistoryItemToolsList } from '../types.js' ;
1313
14+ async function listTools (
15+ context : CommandContext ,
16+ showDescriptions : boolean ,
17+ ) : Promise < void > {
18+ const toolRegistry = context . services . config ?. getToolRegistry ( ) ;
19+ if ( ! toolRegistry ) {
20+ context . ui . addItem ( {
21+ type : MessageType . ERROR ,
22+ text : 'Could not retrieve tool registry.' ,
23+ } ) ;
24+ return ;
25+ }
26+
27+ const tools = toolRegistry . getAllTools ( ) ;
28+ // Filter out MCP tools by checking for the absence of a serverName property
29+ const geminiTools = tools . filter ( ( tool ) => ! ( 'serverName' in tool ) ) ;
30+
31+ const toolsListItem : HistoryItemToolsList = {
32+ type : MessageType . TOOLS_LIST ,
33+ tools : geminiTools . map ( ( tool ) => ( {
34+ name : tool . name ,
35+ displayName : tool . displayName ,
36+ description : tool . description ,
37+ } ) ) ,
38+ showDescriptions,
39+ } ;
40+
41+ context . ui . addItem ( toolsListItem ) ;
42+ }
43+
44+ const toolsDescSubCommand : SlashCommand = {
45+ name : 'desc' ,
46+ altNames : [ 'descriptions' ] ,
47+ description : 'List available Gemini CLI tools with descriptions.' ,
48+ kind : CommandKind . BUILT_IN ,
49+ autoExecute : true ,
50+ action : async ( context : CommandContext ) : Promise < void > =>
51+ listTools ( context , true ) ,
52+ } ;
53+
1454export const toolsCommand : SlashCommand = {
1555 name : 'tools' ,
16- description : 'List available Gemini CLI tools. Usage: /tools [desc]' ,
56+ description :
57+ 'List available Gemini CLI tools. Use /tools desc to include descriptions.' ,
1758 kind : CommandKind . BUILT_IN ,
1859 autoExecute : false ,
60+ subCommands : [ toolsDescSubCommand ] ,
1961 action : async ( context : CommandContext , args ?: string ) : Promise < void > => {
2062 const subCommand = args ?. trim ( ) ;
2163
22- // Default to NOT showing descriptions. The user must opt in with an argument.
23- let useShowDescriptions = false ;
24- if ( subCommand === 'desc' || subCommand === 'descriptions' ) {
25- useShowDescriptions = true ;
26- }
27-
28- const toolRegistry = context . services . config ?. getToolRegistry ( ) ;
29- if ( ! toolRegistry ) {
30- context . ui . addItem ( {
31- type : MessageType . ERROR ,
32- text : 'Could not retrieve tool registry.' ,
33- } ) ;
34- return ;
35- }
36-
37- const tools = toolRegistry . getAllTools ( ) ;
38- // Filter out MCP tools by checking for the absence of a serverName property
39- const geminiTools = tools . filter ( ( tool ) => ! ( 'serverName' in tool ) ) ;
40-
41- const toolsListItem : HistoryItemToolsList = {
42- type : MessageType . TOOLS_LIST ,
43- tools : geminiTools . map ( ( tool ) => ( {
44- name : tool . name ,
45- displayName : tool . displayName ,
46- description : tool . description ,
47- } ) ) ,
48- showDescriptions : useShowDescriptions ,
49- } ;
50-
51- context . ui . addItem ( toolsListItem ) ;
64+ // Keep backward compatibility for typed arguments while exposing desc in TUI via subcommands.
65+ const useShowDescriptions =
66+ subCommand === 'desc' || subCommand === 'descriptions' ;
67+
68+ await listTools ( context , useShowDescriptions ) ;
5269 } ,
5370} ;
0 commit comments