File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,18 @@ class CommandRegistry {
9191 }
9292 }
9393
94+ // Alias-only group: auto-forward when every child points to the same command.
95+ // Example: `mmx search "query"` should work even when both `search query`
96+ // and `search web` are registered as aliases for the same implementation.
97+ if ( matched . length > 0 && node . children . size > 1 ) {
98+ const children = Array . from ( node . children . values ( ) ) ;
99+ const commands = children . map ( ( child ) => child . command ) ;
100+ const first = commands [ 0 ] ;
101+ if ( first && commands . every ( ( command ) => command === first ) ) {
102+ return { command : first , extra : commandPath . slice ( matched . length ) } ;
103+ }
104+ }
105+
94106 // If we matched some path but no command, show help for that group
95107 if ( matched . length > 0 && node . children . size > 0 ) {
96108 const subcommands = Array . from ( node . children . entries ( ) )
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ describe('command aliases', () => {
88 expect ( web . command ) . toBe ( query . command ) ;
99 } ) ;
1010
11+ it ( 'auto-forwards search shorthand when child commands are aliases' , ( ) => {
12+ const shorthand = registry . resolve ( [ 'search' , 'MiniMax AI latest news' ] ) ;
13+ const query = registry . resolve ( [ 'search' , 'query' ] ) ;
14+ expect ( shorthand . command ) . toBe ( query . command ) ;
15+ expect ( shorthand . extra ) . toEqual ( [ 'MiniMax AI latest news' ] ) ;
16+ } ) ;
17+
1118 it ( 'resolves "speech generate" same as "speech synthesize"' , ( ) => {
1219 const generate = registry . resolve ( [ 'speech' , 'generate' ] ) ;
1320 const synthesize = registry . resolve ( [ 'speech' , 'synthesize' ] ) ;
You can’t perform that action at this time.
0 commit comments