Single source of truth for all z3ed commands. More...
#include <command_registry.h>
Classes | |
| struct | CommandMetadata |
Public Member Functions | |
| void | Register (std::unique_ptr< resources::CommandHandler > handler, const CommandMetadata &metadata) |
| Register a command handler. | |
| void | RegisterHandlers (std::vector< std::unique_ptr< resources::CommandHandler > > handlers) |
| Register a set of command handlers (idempotent) | |
| resources::CommandHandler * | Get (const std::string &name) const |
| Get a command handler by name or alias. | |
| const CommandMetadata * | GetMetadata (const std::string &name) const |
| Get command metadata. | |
| std::vector< std::string > | GetCommandsInCategory (const std::string &category) const |
| Get all commands in a category. | |
| std::vector< std::string > | GetCategories () const |
| Get all categories. | |
| std::vector< std::string > | GetAgentCommands () const |
| Get all commands available to AI agents. | |
| std::string | ExportFunctionSchemas () const |
| Export function schemas for AI tool calling (JSON) | |
| std::string | GenerateHelp (const std::string &name, const util::AnsiStyle &style=util::AnsiStyle(false)) const |
| Generate help text for a command. | |
| std::string | GenerateCategoryHelp (const std::string &category, const util::AnsiStyle &style=util::AnsiStyle(false)) const |
| Generate category help text. | |
| std::string | GenerateCompleteHelp (const util::AnsiStyle &style=util::AnsiStyle(false)) const |
| Generate complete help text (all commands) | |
| absl::Status | Execute (const std::string &name, const std::vector< std::string > &args, Rom *rom_context=nullptr, std::string *captured_output=nullptr) |
| Execute a command by name. | |
| bool | HasCommand (const std::string &name) const |
| Check if command exists. | |
| size_t | Count () const |
| Get total command count. | |
Static Public Member Functions | |
| static CommandRegistry & | Instance () |
Private Member Functions | |
| CommandRegistry ()=default | |
| void | RegisterCliCommands () |
Private Attributes | |
| std::map< std::string, std::unique_ptr< resources::CommandHandler > > | handlers_ |
| std::map< std::string, CommandMetadata > | metadata_ |
| std::map< std::string, std::string > | aliases_ |
Single source of truth for all z3ed commands.
Serves as the central registry for:
Ensures consistency: if a command exists, it's available to both human users (CLI) and AI agents (tool calling).
Definition at line 30 of file command_registry.h.
|
privatedefault |
|
static |
Definition at line 18 of file command_registry.cc.
References RegisterCliCommands().
Referenced by yaze::cli::anonymous_namespace{agent.cc}::GenerateAgentHelp(), yaze::cli::handlers::HandleAgentCommand(), yaze::cli::api::HandleCommandExecute(), yaze::cli::api::HandleCommandList(), and yaze::cli::handlers::RegisterAgentCommandHandlers().

| void yaze::cli::CommandRegistry::Register | ( | std::unique_ptr< resources::CommandHandler > | handler, |
| const CommandMetadata & | metadata ) |
Register a command handler.
Definition at line 28 of file command_registry.cc.
References yaze::cli::CommandRegistry::CommandMetadata::aliases, aliases_, handlers_, and metadata_.
Referenced by RegisterHandlers().
| void yaze::cli::CommandRegistry::RegisterHandlers | ( | std::vector< std::unique_ptr< resources::CommandHandler > > | handlers | ) |
Register a set of command handlers (idempotent)
Definition at line 45 of file command_registry.cc.
References yaze::cli::CommandRegistry::CommandMetadata::available_to_agent, yaze::cli::CommandRegistry::CommandMetadata::category, yaze::cli::CommandRegistry::CommandMetadata::description, yaze::cli::CommandRegistry::CommandMetadata::examples, handlers_, yaze::cli::CommandRegistry::CommandMetadata::name, Register(), yaze::cli::CommandRegistry::CommandMetadata::requires_grpc, yaze::cli::CommandRegistry::CommandMetadata::requires_rom, yaze::cli::CommandRegistry::CommandMetadata::todo_reference, and yaze::cli::CommandRegistry::CommandMetadata::usage.
Referenced by yaze::cli::handlers::RegisterAgentCommandHandlers(), and RegisterCliCommands().

| resources::CommandHandler * yaze::cli::CommandRegistry::Get | ( | const std::string & | name | ) | const |
Get a command handler by name or alias.
Definition at line 444 of file command_registry.cc.
References aliases_, and handlers_.
Referenced by Execute(), and HasCommand().
| const CommandRegistry::CommandMetadata * yaze::cli::CommandRegistry::GetMetadata | ( | const std::string & | name | ) | const |
Get command metadata.
Definition at line 463 of file command_registry.cc.
References aliases_, and metadata_.
Referenced by GenerateCategoryHelp(), GenerateHelp(), yaze::cli::Cli::PrintCategoryHelp(), and yaze::cli::Cli::PrintCommandSummary().
| std::vector< std::string > yaze::cli::CommandRegistry::GetCommandsInCategory | ( | const std::string & | category | ) | const |
Get all commands in a category.
Definition at line 476 of file command_registry.cc.
References metadata_.
Referenced by GenerateCategoryHelp(), yaze::cli::Cli::PrintAgentHelp(), yaze::cli::Cli::PrintAliasHelp(), yaze::cli::Cli::PrintCategoryHelp(), yaze::cli::Cli::PrintCommandSummary(), yaze::cli::Cli::PrintOverview(), yaze::cli::Cli::PrintScopedHelp(), and yaze::cli::Cli::Run().
| std::vector< std::string > yaze::cli::CommandRegistry::GetCategories | ( | ) | const |
Get all categories.
Definition at line 487 of file command_registry.cc.
References metadata_.
Referenced by GenerateCompleteHelp(), yaze::cli::Cli::PrintCommandSummary(), and yaze::cli::Cli::PrintOverview().
| std::vector< std::string > yaze::cli::CommandRegistry::GetAgentCommands | ( | ) | const |
Get all commands available to AI agents.
Definition at line 498 of file command_registry.cc.
References metadata_.
| std::string yaze::cli::CommandRegistry::ExportFunctionSchemas | ( | ) | const |
Export function schemas for AI tool calling (JSON)
Each command carries a JSON Schema parameters object derived from its usage string, keyed by literal flag name.
Definition at line 508 of file command_registry.cc.
References metadata_, yaze::cli::ParseUsageParameters(), and yaze::cli::UsageParametersToJsonSchema().

| std::string yaze::cli::CommandRegistry::GenerateHelp | ( | const std::string & | name, |
| const util::AnsiStyle & | style = util::AnsiStyle(false) ) const |
Generate help text for a command.
Help is plain text unless the caller passes an enabled style.
Definition at line 545 of file command_registry.cc.
References GetMetadata(), yaze::cli::util::AnsiStyle::Heading(), yaze::cli::util::AnsiStyle::Highlight(), and yaze::cli::util::AnsiStyle::Reset().
Referenced by Execute(), and yaze::cli::Cli::PrintScopedHelp().

| std::string yaze::cli::CommandRegistry::GenerateCategoryHelp | ( | const std::string & | category, |
| const util::AnsiStyle & | style = util::AnsiStyle(false) ) const |
Generate category help text.
Definition at line 587 of file command_registry.cc.
References GetCommandsInCategory(), GetMetadata(), yaze::cli::util::AnsiStyle::Heading(), yaze::cli::util::AnsiStyle::Highlight(), and yaze::cli::util::AnsiStyle::Reset().
Referenced by GenerateCompleteHelp(), and yaze::cli::Cli::PrintAliasHelp().
| std::string yaze::cli::CommandRegistry::GenerateCompleteHelp | ( | const util::AnsiStyle & | style = util::AnsiStyle(false) | ) | const |
Generate complete help text (all commands)
Definition at line 614 of file command_registry.cc.
References GenerateCategoryHelp(), GetCategories(), yaze::cli::util::AnsiStyle::Heading(), and yaze::cli::util::AnsiStyle::Reset().
Referenced by yaze::cli::Cli::PrintScopedHelp().

| absl::Status yaze::cli::CommandRegistry::Execute | ( | const std::string & | name, |
| const std::vector< std::string > & | args, | ||
| Rom * | rom_context = nullptr, | ||
| std::string * | captured_output = nullptr ) |
Execute a command by name.
Definition at line 628 of file command_registry.cc.
References yaze::cli::util::AnsiStyle::ForStream(), GenerateHelp(), and Get().
Referenced by yaze::cli::Cli::Run(), and yaze::cli::Cli::RunAlias().

| bool yaze::cli::CommandRegistry::HasCommand | ( | const std::string & | name | ) | const |
Check if command exists.
Definition at line 673 of file command_registry.cc.
References Get().
Referenced by yaze::cli::Cli::PrintScopedHelp(), yaze::cli::Cli::Run(), and yaze::cli::Cli::RunAlias().

|
inline |
Get total command count.
Definition at line 131 of file command_registry.h.
References handlers_.
Referenced by yaze::cli::Cli::PrintCommandSummary(), and anonymous_namespace{cli_main.cc}::RunSelfTest().
|
private |
Definition at line 677 of file command_registry.cc.
References yaze::cli::handlers::CreateCliCommandHandlers(), and RegisterHandlers().
Referenced by Instance().

|
private |
Definition at line 137 of file command_registry.h.
Referenced by Count(), Get(), Register(), and RegisterHandlers().
|
private |
Definition at line 138 of file command_registry.h.
Referenced by ExportFunctionSchemas(), GetAgentCommands(), GetCategories(), GetCommandsInCategory(), GetMetadata(), and Register().
|
private |
Definition at line 139 of file command_registry.h.
Referenced by Get(), GetMetadata(), and Register().