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. | |
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 |
Generate help text for a command. | |
std::string | GenerateCategoryHelp (const std::string &category) const |
Generate category help text. | |
std::string | GenerateCompleteHelp () const |
Generate complete help text (all commands) | |
absl::Status | Execute (const std::string &name, const std::vector< std::string > &args, Rom *rom_context=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 | RegisterAllCommands () |
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 29 of file command_registry.h.
|
privatedefault |
|
static |
Definition at line 11 of file command_registry.cc.
References RegisterAllCommands().
Referenced by yaze::cli::anonymous_namespace{agent.cc}::GenerateAgentHelp(), yaze::cli::handlers::HandleAgentCommand(), yaze::cli::ModernCLI::Run(), yaze::cli::ModernCLI::ShowCategoryHelp(), yaze::cli::ModernCLI::ShowCommandSummary(), and yaze::cli::ModernCLI::ShowHelp().
void yaze::cli::CommandRegistry::Register | ( | std::unique_ptr< resources::CommandHandler > | handler, |
const CommandMetadata & | metadata | ||
) |
Register a command handler.
Definition at line 21 of file command_registry.cc.
References yaze::cli::CommandRegistry::CommandMetadata::aliases, aliases_, handlers_, and metadata_.
Referenced by RegisterAllCommands().
resources::CommandHandler * yaze::cli::CommandRegistry::Get | ( | const std::string & | name | ) | const |
Get a command handler by name or alias.
Definition at line 37 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 56 of file command_registry.cc.
References aliases_, and metadata_.
Referenced by GenerateCategoryHelp(), and GenerateHelp().
std::vector< std::string > yaze::cli::CommandRegistry::GetCommandsInCategory | ( | const std::string & | category | ) | const |
Get all commands in a category.
Definition at line 69 of file command_registry.cc.
References metadata_.
Referenced by GenerateCategoryHelp().
std::vector< std::string > yaze::cli::CommandRegistry::GetCategories | ( | ) | const |
Get all categories.
Definition at line 80 of file command_registry.cc.
References metadata_.
Referenced by GenerateCompleteHelp().
std::vector< std::string > yaze::cli::CommandRegistry::GetAgentCommands | ( | ) | const |
Get all commands available to AI agents.
Definition at line 90 of file command_registry.cc.
References metadata_.
std::string yaze::cli::CommandRegistry::ExportFunctionSchemas | ( | ) | const |
Export function schemas for AI tool calling (JSON)
Definition at line 100 of file command_registry.cc.
std::string yaze::cli::CommandRegistry::GenerateHelp | ( | const std::string & | name | ) | const |
Generate help text for a command.
Definition at line 106 of file command_registry.cc.
References GetMetadata().
std::string yaze::cli::CommandRegistry::GenerateCategoryHelp | ( | const std::string & | category | ) | const |
Generate category help text.
Definition at line 139 of file command_registry.cc.
References GetCommandsInCategory(), and GetMetadata().
Referenced by GenerateCompleteHelp().
std::string yaze::cli::CommandRegistry::GenerateCompleteHelp | ( | ) | const |
Generate complete help text (all commands)
Definition at line 163 of file command_registry.cc.
References GenerateCategoryHelp(), and GetCategories().
absl::Status yaze::cli::CommandRegistry::Execute | ( | const std::string & | name, |
const std::vector< std::string > & | args, | ||
Rom * | rom_context = nullptr |
||
) |
Execute a command by name.
Definition at line 175 of file command_registry.cc.
References Get().
bool yaze::cli::CommandRegistry::HasCommand | ( | const std::string & | name | ) | const |
Check if command exists.
Definition at line 186 of file command_registry.cc.
References Get().
|
inline |
|
private |
Definition at line 190 of file command_registry.cc.
References yaze::cli::CommandRegistry::CommandMetadata::available_to_agent, yaze::cli::CommandRegistry::CommandMetadata::category, yaze::cli::handlers::CreateAllCommandHandlers(), yaze::cli::CommandRegistry::CommandMetadata::description, yaze::cli::CommandRegistry::CommandMetadata::examples, yaze::cli::CommandRegistry::CommandMetadata::name, Register(), yaze::cli::CommandRegistry::CommandMetadata::requires_grpc, yaze::cli::CommandRegistry::CommandMetadata::requires_rom, and yaze::cli::CommandRegistry::CommandMetadata::usage.
Referenced by Instance().
|
private |
Definition at line 118 of file command_registry.h.
Referenced by Count(), Get(), and Register().
|
private |
Definition at line 119 of file command_registry.h.
Referenced by GetAgentCommands(), GetCategories(), GetCommandsInCategory(), GetMetadata(), and Register().
|
private |
Definition at line 120 of file command_registry.h.
Referenced by Get(), GetMetadata(), and Register().