31 return absl::OkStatus();
34 std::vector<std::string> args;
35 for (
int i = 1; i < argc; ++i) {
36 args.push_back(argv[i]);
39 if (args[0] ==
"help") {
40 if (args.size() > 1) {
41 const std::string& target = args[1];
43 if (target ==
"all") {
44 std::cout << registry.GenerateCompleteHelp() <<
"\n";
45 }
else if (registry.HasCommand(target)) {
46 std::cout << registry.GenerateHelp(target) <<
"\n";
53 return absl::OkStatus();
57 if (args[0] ==
"agent") {
58 std::vector<std::string> agent_args(args.begin() + 1, args.end());
65 std::string command_name = args[0];
66 std::vector<std::string> command_args(args.begin() + 1, args.end());
68 if (registry.HasCommand(command_name)) {
69 return registry.Execute(command_name, command_args,
nullptr);
72 return absl::NotFoundError(absl::StrCat(
"Unknown command: ", command_name));
77 auto categories = registry.GetCategories();
80 using namespace ftxui;
82 auto banner = text(
"🎮 Z3ED - AI-Powered ROM Editor CLI") | bold | center;
84 std::vector<std::vector<std::string>> rows;
85 rows.push_back({
"Category",
"Commands",
"Description"});
88 rows.push_back({
"agent",
"simple-chat, plan, run, todo, test",
89 "AI agent workflows + tool routing"});
92 for (
const auto& category : categories) {
93 auto commands = registry.GetCommandsInCategory(category);
94 std::string cmd_list = commands.size() > 3
95 ? absl::StrCat(commands.size(),
" commands")
96 : absl::StrJoin(commands,
", ");
99 if (category ==
"resource")
100 desc =
"ROM resource inspection";
101 else if (category ==
"dungeon")
102 desc =
"Dungeon editing";
103 else if (category ==
"overworld")
104 desc =
"Overworld editing";
105 else if (category ==
"emulator")
106 desc =
"Emulator debugging";
107 else if (category ==
"graphics")
108 desc =
"Graphics/palette/sprites";
109 else if (category ==
"gui")
110 desc =
"GUI automation";
111 else if (category ==
"game")
112 desc =
"Messages/dialogue/music";
113 else if (category ==
"rom")
114 desc =
"ROM inspection/validation";
115 else if (category ==
"test")
116 desc =
"Test discovery/execution";
117 else if (category ==
"tools")
118 desc =
"Utilities and doctor tools";
120 desc = category +
" commands";
122 rows.push_back({category, cmd_list, desc});
126 summary.SelectAll().Border(LIGHT);
127 summary.SelectRow(0).Decorate(bold);
132 text(absl::StrFormat(
"Total: %zu commands across %zu categories",
133 registry.Count(), categories.size() + 1)) |
135 text(
"Try `z3ed agent simple-chat` for AI-powered ROM inspection") |
137 text(
"Use `z3ed --list-commands` for complete list") | dim | center});
139 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
140 Render(screen, layout);
145 std::cout <<
"Z3ED - AI-Powered ROM Editor CLI\n\n";
146 std::cout <<
"Categories:\n";
147 std::cout <<
" agent - AI conversational agent + debugging tools\n";
148 for (
const auto& category : categories) {
149 auto commands = registry.GetCommandsInCategory(category);
150 std::cout <<
" " << category <<
" - " << commands.size() <<
" commands\n";
152 std::cout <<
"\nTotal: " << registry.Count() <<
" commands\n";
153 std::cout <<
"Use 'help <category>' for more details.\n";
159 auto commands = registry.GetCommandsInCategory(category);
161#ifndef __EMSCRIPTEN__
162 using namespace ftxui;
164 std::vector<std::vector<std::string>> rows;
165 rows.push_back({
"Command",
"Description",
"Requirements"});
167 for (
const auto& cmd_name : commands) {
168 auto* metadata = registry.GetMetadata(cmd_name);
170 std::string requirements;
171 if (metadata->requires_rom)
172 requirements +=
"ROM ";
173 if (metadata->requires_grpc)
174 requirements +=
"gRPC ";
175 if (requirements.empty())
176 requirements =
"—";
178 rows.push_back({cmd_name, metadata->description, requirements});
182 if (rows.size() == 1) {
183 rows.push_back({
"—",
"No commands in this category",
"—"});
187 detail.SelectAll().Border(LIGHT);
188 detail.SelectRow(0).Decorate(bold);
191 vbox({text(absl::StrCat(
"Category: ", category)) | bold | center,
192 separator(), detail.Render(), separator(),
193 text(
"Commands are auto-registered from CommandRegistry") | dim |
196 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
197 Render(screen, layout);
201 std::cout <<
"Category: " << category <<
"\n\n";
202 for (
const auto& cmd_name : commands) {
203 auto* metadata = registry.GetMetadata(cmd_name);
205 std::cout <<
" " << cmd_name <<
" - " << metadata->description <<
"\n";
208 if (commands.empty()) {
209 std::cout <<
" No commands in this category.\n";
216 auto categories = registry.GetCategories();
218#ifndef __EMSCRIPTEN__
219 using namespace ftxui;
221 std::vector<std::vector<std::string>> rows;
222 rows.push_back({
"Command",
"Category",
"Description"});
224 for (
const auto& category : categories) {
225 auto commands = registry.GetCommandsInCategory(category);
226 for (
const auto& cmd_name : commands) {
227 auto* metadata = registry.GetMetadata(cmd_name);
229 rows.push_back({cmd_name, metadata->category, metadata->description});
234 if (rows.size() == 1) {
235 rows.push_back({
"—",
"—",
"No commands registered"});
238 Table command_table(rows);
239 command_table.SelectAll().Border(LIGHT);
240 command_table.SelectRow(0).Decorate(bold);
243 vbox({text(
"Z3ED Command Summary") | bold | center, separator(),
244 command_table.Render(), separator(),
245 text(absl::StrFormat(
"Total: %zu commands across %zu categories",
246 registry.Count(), categories.size())) |
248 text(
"Use `z3ed --tui` for interactive command palette.") | center |
251 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(layout));
252 Render(screen, layout);
256 std::cout <<
"Z3ED Command Summary\n\n";
257 for (
const auto& category : categories) {
258 auto commands = registry.GetCommandsInCategory(category);
259 for (
const auto& cmd_name : commands) {
260 auto* metadata = registry.GetMetadata(cmd_name);
262 std::cout <<
" " << cmd_name <<
" [" << metadata->category <<
"] - "
263 << metadata->description <<
"\n";
267 std::cout <<
"\nTotal: " << registry.Count() <<
" commands across "
268 << categories.size() <<
" categories\n";