@@ -334,7 +334,8 @@ def _display_channel_table(channels: dict, is_filtered: bool):
334334@manifest_app .command (name = "primitives" )
335335def list_primitives (
336336 search : str = typer .Argument ("" , help = "Search pattern for command name." ),
337- json_out : bool = typer .Option (False , "--json" , help = "Output as raw JSON for AI." )
337+ json_out : bool = typer .Option (False , "--json" , help = "Output as raw JSON for AI." ),
338+ json_schema : bool = typer .Option (False , "--json-schema" , help = "Output with json schema" )
338339):
339340 """
340341 Explore MOSS Primitives (Commands).
@@ -351,23 +352,29 @@ def list_primitives(
351352 "description" : cmd .meta ().description ,
352353 "params" : cmd .meta ().json_schema
353354 } for name , cmd in results .items ()}
354- console .json (data = data )
355+ console .print_json (data = data )
355356 return
356-
357- _display_command_detail (list (results .values ())[0 ])
357+ if len (primitives ) == 0 :
358+ console .print ("no primitive found" )
359+ return
360+ for key , cmd in results .items ():
361+ _display_command_detail (cmd , json_schema )
358362
359363
360- def _display_command_detail (cmd ):
364+ def _display_command_detail (cmd , with_json_schema : bool ):
361365 meta = cmd .meta ()
362- console .print (f"\n [bold green]Command:[/bold green] { meta .name } " )
366+ console .print (f"\n [bold green]==== Command:[/bold green] { meta .name } ==== " )
363367 console .print (f"[dim]Dynamic: { cmd .is_dynamic ()} [/dim]\n " )
364368
365369 # 重点展示接口定义
366- console .print (Panel (cmd .meta ().interface , title = "Interface Prompt" , border_style = "yellow" ))
370+ console .print (f"[dim]Interface:[/dim]\n " )
371+ console .print (Syntax (cmd .meta ().interface , 'python' ))
367372
368373 # 展示 JSON Schema
369- console .print ("\n [bold]Arguments Schema:[/bold]" )
370- console .json (data = meta .json_schema )
374+ if with_json_schema and meta .json_schema is not None :
375+ console .print ("\n [bold]Arguments Schema:[/bold]" )
376+ console .print_json (data = meta .json_schema )
377+ console .print ("" )
371378
372379
373380@manifest_app .command (name = "contracts" )
0 commit comments