2929from src .udbpy .gdb_extensions import command , command_args , gdbio , gdbutils , udb_base , udb_last
3030
3131# Agent modules are imported to trigger registration.
32+ from . import styles
3233from .agents import AgentRegistry , BaseAgent
3334from .amp_agent import AmpAgent # pylint: disable=unused-import
3435from .assets import MCP_INSTRUCTIONS , SYSTEM_PROMPT , THINKING_MSGS
@@ -585,9 +586,6 @@ async def explain_query(agent: BaseAgent, gateway: UdbMcpGateway, why: str) -> s
585586 server = uvicorn .Server (config )
586587 mcp_task = asyncio .create_task (server .serve (sockets = [sock ]))
587588
588- console_whizz (f" * { random .choice (THINKING_MSGS )} ..." )
589- print_agent (agent .display_name , agent .agent_bin )
590-
591589 explanation = await agent .ask (why , port , tools = gateway .tools )
592590
593591 finally :
@@ -611,6 +609,11 @@ async def explain_query(agent: BaseAgent, gateway: UdbMcpGateway, why: str) -> s
611609 short = "a" ,
612610 value = command_args .Choice (AgentRegistry .available_agents (), optional = True ),
613611 ),
612+ command_args .Option (
613+ long = "style" ,
614+ short = "s" ,
615+ value = command_args .Choice (styles .names (), optional = True ),
616+ ),
614617 allow_remainders = True ,
615618 ),
616619)
@@ -637,6 +640,12 @@ def explain(udb: udb_base.Udb, args: Any) -> None:
637640 why += ui .get_user_input (prompt = "> " ) + "\n "
638641 print ()
639642
643+ explain_style_description = ""
644+ if args .style :
645+ explain_style = styles .get (args .style )
646+ why += f"\n Explain in the style of { explain_style .prompt } "
647+ explain_style_description = explain_style .description
648+
640649 gateway = UdbMcpGateway (udb )
641650
642651 global event_loop
@@ -650,6 +659,9 @@ def explain(udb: udb_base.Udb, args: Any) -> None:
650659 gdbutils .breakpoints_suspended (),
651660 unittest .mock .patch .object (udb , "_volatile_mode_explained" , True ),
652661 ):
662+ console_whizz (f" * { random .choice (THINKING_MSGS )} ..." )
663+ print_agent (agent .display_name , agent .agent_bin , explain_style_description )
664+
653665 explanation = event_loop .run_until_complete (explain_query (agent , gateway , why ))
654666
655667 print_explanation (explanation )
0 commit comments