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
55 resources::CommandHandler* Get(const std::string& name) const;
56
60 const CommandMetadata* GetMetadata(const std::string& name) const;
61
65 std::vector<std::string> GetCommandsInCategory(
66 const std::string& category) const;
67
71 std::vector<std::string> GetCategories() const;
72
76 std::vector<std::string> GetAgentCommands() const;
77
81 std::string ExportFunctionSchemas() const;
82
86 std::string GenerateHelp(const std::string& name) const;
87
91 std::string GenerateCategoryHelp(const std::string& category) const;
92
96 std::string GenerateCompleteHelp() const;
97
101 absl::Status Execute(const std::string& name,
102 const std::vector<std::string>& args,
103 Rom* rom_context = nullptr,
104 std::string* captured_output = nullptr);
105
109 bool HasCommand(const std::string& name) const;
110
114 size_t Count() const { return handlers_.size(); }
115
116 private:
117 CommandRegistry() = default;
118
119 // Storage
120 std::map<std::string, std::unique_ptr<resources::CommandHandler>> handlers_;
121 std::map<std::string, CommandMetadata> metadata_;
122 std::map<std::string, std::string> aliases_; // alias → canonical name
123
124 // Auto-register all commands
125 void RegisterAllCommands();
126};
127
128} // namespace cli
129} // namespace yaze
130
131#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:24
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.
Base class for CLI command handlers.