@@ -103,7 +103,9 @@ const plugin: JupyterFrontEndPlugin<void> = {
103103 describedBy : {
104104 args : { }
105105 } ,
106- execute : async ( ) => {
106+ execute : async ( args : any ) => {
107+ const query = args [ 'query' ] as string | undefined ;
108+
107109 const commandList : Array < {
108110 id : string ;
109111 label ?: string ;
@@ -112,23 +114,45 @@ const plugin: JupyterFrontEndPlugin<void> = {
112114 args ?: any ;
113115 } > = [ ] ;
114116
117+ // Get all command IDs
115118 const commandIds = commands . listCommands ( ) ;
116119
117120 for ( const id of commandIds ) {
121+ // Get command metadata using various CommandRegistry methods
118122 const description = await commands . describedBy ( id ) ;
119123 const label = commands . label ( id ) ;
120124 const caption = commands . caption ( id ) ;
121125 const usage = commands . usage ( id ) ;
122126
123- commandList . push ( {
127+ const command = {
124128 id,
125129 label : label || undefined ,
126130 caption : caption || undefined ,
127131 description : usage || undefined ,
128132 args : description ?. args || undefined
129- } ) ;
133+ } ;
134+
135+ // Filter by query if provided
136+ if ( query ) {
137+ const searchTerm = query . toLowerCase ( ) ;
138+ const matchesQuery =
139+ id . toLowerCase ( ) . includes ( searchTerm ) ||
140+ label ?. toLowerCase ( ) . includes ( searchTerm ) ||
141+ caption ?. toLowerCase ( ) . includes ( searchTerm ) ||
142+ usage ?. toLowerCase ( ) . includes ( searchTerm ) ;
143+
144+ if ( matchesQuery ) {
145+ commandList . push ( command ) ;
146+ }
147+ } else {
148+ commandList . push ( command ) ;
149+ }
130150 }
131- return commandList ;
151+ return {
152+ success : true ,
153+ commandCount : commandList . length ,
154+ commands : commandList
155+ } ;
132156 }
133157 } ) ;
134158 }
0 commit comments