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(const std::string& category) const;
66
70 std::vector<std::string> GetCategories() const;
71
75 std::vector<std::string> GetAgentCommands() const;
76
80 std::string ExportFunctionSchemas() const;
81
85 std::string GenerateHelp(const std::string& name) const;
86
90 std::string GenerateCategoryHelp(const std::string& category) const;
91
95 std::string GenerateCompleteHelp() const;
96
100 absl::Status Execute(const std::string& name,
101 const std::vector<std::string>& args,
102 Rom* rom_context = nullptr);
103
107 bool HasCommand(const std::string& name) const;
108
112 size_t Count() const { return handlers_.size(); }
113
114 private:
115 CommandRegistry() = default;
116
117 // Storage
118 std::map<std::string, std::unique_ptr<resources::CommandHandler>> handlers_;
119 std::map<std::string, CommandMetadata> metadata_;
120 std::map<std::string, std::string> aliases_; // alias → canonical name
121
122 // Auto-register all commands
123 void RegisterAllCommands();
124};
125
126} // namespace cli
127} // namespace yaze
128
129#endif // YAZE_CLI_SERVICE_COMMAND_REGISTRY_H_
130
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:74
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.
absl::Status Execute(const std::string &name, const std::vector< std::string > &args, Rom *rom_context=nullptr)
Execute a command by name.
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_
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.
Main namespace for the application.
Definition controller.cc:20