#ifndef YAZE_CLI_SERVICE_AI_AI_ACTION_PARSER_H_ #define YAZE_CLI_SERVICE_AI_AI_ACTION_PARSER_H_ #include #include #include #include "absl/status/statusor.h" namespace yaze { namespace cli { namespace ai { /** * @enum AIActionType * @brief Types of actions the AI can request */ enum class AIActionType { kOpenEditor, // Open a specific editor window kSelectTile, // Select a tile from the tile16 selector kPlaceTile, // Place a tile at a specific position kSaveTile, // Save tile changes to ROM kVerifyTile, // Verify a tile was placed correctly kClickButton, // Click a specific button kWait, // Wait for a duration or condition kScreenshot, // Take a screenshot for verification kInvalidAction }; /** * @struct AIAction * @brief Represents a single action to be performed in the GUI */ struct AIAction { AIActionType type; std::map parameters; AIAction() : type(AIActionType::kInvalidAction) {} AIAction(AIActionType t) : type(t) {} AIAction(AIActionType t, const std::map& params) : type(t), parameters(params) {} }; /** * @class AIActionParser * @brief Parses natural language commands into structured GUI actions * * Understands commands like: * - "Place tile 0x42 at overworld position (5, 7)" * - "Open the overworld editor" * - "Select tile 100 from the tile selector" */ class AIActionParser { public: /** * Parse a natural language command into a sequence of AI actions * @param command The command to parse * @return Vector of actions, or error status */ static absl::StatusOr> ParseCommand( const std::string& command); /** * Convert an action back to a human-readable string */ static std::string ActionToString(const AIAction& action); private: static AIActionType ParseActionType(const std::string& verb); static std::map ExtractParameters( const std::string& command, AIActionType type); // Pattern matchers for different command types static bool MatchesPlaceTilePattern(const std::string& command, std::map* params); static bool MatchesSelectTilePattern(const std::string& command, std::map* params); static bool MatchesOpenEditorPattern(const std::string& command, std::map* params); }; } // namespace ai } // namespace cli } // namespace yaze #endif // YAZE_CLI_SERVICE_AI_AI_ACTION_PARSER_H_