yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
command_registry.h
Go to the documentation of this file.
1#ifndef YAZE_CLI_SERVICE_COMMAND_REGISTRY_H_
2#define YAZE_CLI_SERVICE_COMMAND_REGISTRY_H_
3
4#include <map>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include "absl/status/statusor.h"
11
12namespace yaze {
13namespace cli {
14
30 public:
32 std::string name; // e.g., "resource-list"
33 std::string category; // e.g., "resource", "emulator", "dungeon"
34 std::string description; // Short description
35 std::string usage; // Full usage string
36 bool available_to_agent; // Can AI call this via tool dispatch?
37 bool requires_rom; // Requires ROM context?
38 bool requires_grpc; // Requires gRPC/emulator running?
39 std::vector<std::string> aliases; // Alternative names
40 std::vector<std::string> examples; // Usage examples
41 std::string todo_reference; // TODO tracker reference (if incomplete)
42 };
43
44 static CommandRegistry& Instance();
45
49 void Register(std::unique_ptr<resources::CommandHandler> handler,
50 const CommandMetadata& metadata);
51
56 std::vector<std::unique_ptr<resources::CommandHandler>> handlers);
57
61 resources::CommandHandler* Get(const std::string& name) const;
62
66 const CommandMetadata* GetMetadata(const std::string& name) const;
67
71 std::vector<std::string> GetCommandsInCategory(
72 const std::string& category) const;
73
77 std::vector<std::string> GetCategories() const;
78
82 std::vector<std::string> GetAgentCommands() const;
83
87 std::string ExportFunctionSchemas() const;
88
92 std::string GenerateHelp(const std::string& name) const;
93
97 std::string GenerateCategoryHelp(const std::string& category) const;
98
102 std::string GenerateCompleteHelp() const;
103
107 absl::Status Execute(const std::string& name,
108 const std::vector<std::string>& args,
109 Rom* rom_context = nullptr,
110 std::string* captured_output = nullptr);
111
115 bool HasCommand(const std::string& name) const;
116
120 size_t Count() const { return handlers_.size(); }
121
122 private:
123 CommandRegistry() = default;
124
125 // Storage
126 std::map<std::string, std::unique_ptr<resources::CommandHandler>> handlers_;
127 std::map<std::string, CommandMetadata> metadata_;
128 std::map<std::string, std::string> aliases_; // alias → canonical name
129
130 // Auto-register CLI commands
131 void RegisterCliCommands();
132};
133
134} // namespace cli
135} // namespace yaze
136
137#endif // YAZE_CLI_SERVICE_COMMAND_REGISTRY_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Single source of truth for all z3ed commands.
std::map< std::string, std::string > aliases_
std::vector< std::string > GetCommandsInCategory(const std::string &category) const
Get all commands in a category.
static CommandRegistry & Instance()
std::string GenerateCategoryHelp(const std::string &category) const
Generate category help text.
std::string ExportFunctionSchemas() const
Export function schemas for AI tool calling (JSON)
const CommandMetadata * GetMetadata(const std::string &name) const
Get command metadata.
std::string GenerateCompleteHelp() const
Generate complete help text (all commands)
std::vector< std::string > GetAgentCommands() const
Get all commands available to AI agents.
size_t Count() const
Get total command count.
std::map< std::string, CommandMetadata > metadata_
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.
std::map< std::string, std::unique_ptr< resources::CommandHandler > > handlers_
resources::CommandHandler * Get(const std::string &name) const
Get a command handler by name or alias.
bool HasCommand(const std::string &name) const
Check if command exists.
std::vector< std::string > GetCategories() const
Get all categories.
void Register(std::unique_ptr< resources::CommandHandler > handler, const CommandMetadata &metadata)
Register a command handler.
std::string GenerateHelp(const std::string &name) const
Generate help text for a command.
void RegisterHandlers(std::vector< std::unique_ptr< resources::CommandHandler > > handlers)
Register a set of command handlers (idempotent)
Base class for CLI command handlers.