6#include "absl/flags/declare.h"
7#include "absl/flags/flag.h"
8#include "absl/status/status.h"
9#include "absl/strings/str_cat.h"
24absl::Status
HandleRunCommand(
const std::vector<std::string>& args, Rom& rom);
28 const std::vector<std::string>& args);
49 std::ostringstream help;
50 help <<
"Usage: agent <subcommand> [options]\n\n";
52 help <<
"AI-Powered Agent Commands:\n";
53 help <<
" simple-chat Interactive AI chat\n";
54 help <<
" test-conversation Automated test conversation\n";
55 help <<
" plan Generate execution plan\n";
56 help <<
" run Execute plan in sandbox\n";
57 help <<
" diff Review the latest proposal diff\n";
58 help <<
" accept Apply proposal changes to ROM\n";
59 help <<
" commit Save current ROM changes\n";
60 help <<
" revert Reload ROM from disk\n";
61 help <<
" learn Manage learned knowledge\n";
62 help <<
" todo Task management\n";
63 help <<
" test Run tests\n";
64 help <<
" list/describe List/describe proposals\n\n";
67 help <<
"Tool Commands (AI can call these):\n";
68 auto agent_commands = registry.GetAgentCommands();
69 const size_t preview_count = std::min<size_t>(10, agent_commands.size());
70 for (
size_t i = 0; i < preview_count; ++i) {
71 const auto& cmd = agent_commands[i];
72 if (
auto* meta = registry.GetMetadata(cmd); meta !=
nullptr) {
74 for (
size_t pad = cmd.length(); pad < 24; ++pad)
76 help << meta->description <<
"\n";
79 if (agent_commands.size() > preview_count) {
80 help <<
" ... and " << (agent_commands.size() - preview_count)
81 <<
" more (see z3ed --list-commands)\n";
85 help <<
"Global Options:\n";
86 help <<
" --rom=<path> Path to ROM file\n";
87 help <<
" --ai_provider=<name> AI provider: ollama | gemini\n";
88 help <<
" --format=<type> Output format: text | json\n\n";
90 help <<
"For detailed help: z3ed agent <command> --help\n";
91 help <<
"For all commands: z3ed --list-commands\n";
96constexpr absl::string_view
kUsage =
"";
111 if (arg_vec.empty()) {
113 return absl::InvalidArgumentError(
"No subcommand specified");
116 const std::string& subcommand = arg_vec[0];
117 std::vector<std::string> subcommand_args(arg_vec.begin() + 1, arg_vec.end());
121 if (subcommand ==
"simple-chat" || subcommand ==
"chat") {
123 return registry.Execute(
"simple-chat", subcommand_args,
nullptr);
128 if (subcommand ==
"run") {
132 if (subcommand ==
"plan") {
136 if (subcommand ==
"diff") {
140 if (subcommand ==
"accept") {
144 if (subcommand ==
"commit") {
148 if (subcommand ==
"revert") {
152 if (subcommand ==
"test") {
156 if (subcommand ==
"test-conversation") {
160 if (subcommand ==
"gui") {
163 return absl::InvalidArgumentError(
164 "Use 'z3ed gui-<command>' or see 'z3ed --help gui' for available GUI "
165 "automation commands");
168 if (subcommand ==
"learn") {
172 if (subcommand ==
"todo") {
176 if (subcommand ==
"list") {
180 if (subcommand ==
"describe") {
189 if (registry.HasCommand(subcommand)) {
190 return registry.Execute(subcommand, subcommand_args,
nullptr);
195 return absl::InvalidArgumentError(
196 absl::StrCat(
"Unknown agent command: ", subcommand));
ABSL_DECLARE_FLAG(bool, quiet)
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
static CommandRegistry & Instance()
absl::Status HandleLearnCommand(const std::vector< std::string > &args)
absl::Status HandleAcceptCommand(const std::vector< std::string > &args, Rom &rom)
absl::Status HandleTestConversationCommand(const std::vector< std::string > &args)
absl::Status HandleRunCommand(const std::vector< std::string > &args, Rom &rom)
absl::Status HandleTestCommand(const std::vector< std::string > &args)
absl::Status HandleCommitCommand(Rom &rom)
absl::Status HandleDescribeCommand(const std::vector< std::string > &args)
absl::Status HandleDiffCommand(Rom &rom, const std::vector< std::string > &args)
absl::Status HandleRevertCommand(Rom &rom)
absl::Status HandleListCommand()
absl::Status HandlePlanCommand(const std::vector< std::string > &args)
constexpr absl::string_view kUsage
std::string GenerateAgentHelp()
absl::Status HandleTestConversationCommand(const std::vector< std::string > &)
absl::Status HandleAcceptCommand(const std::vector< std::string > &, Rom &)
absl::Status HandleLearnCommand(const std::vector< std::string > &)
absl::Status HandleRunCommand(const std::vector< std::string > &, Rom &)
absl::Status HandleCommitCommand(Rom &)
absl::Status HandleRevertCommand(Rom &)
absl::Status HandleTestCommand(const std::vector< std::string > &)
std::string GenerateAgentHelp()
absl::Status HandleAgentCommand(const std::vector< std::string > &args)
Unified agent command handler using CommandRegistry.
absl::Status HandleTodoCommand(const std::vector< std::string > &args)
Handle z3ed agent todo commands.