Generates and manages tile16 editing proposals. More...
#include <tile16_proposal_generator.h>
Public Member Functions | |
Tile16ProposalGenerator ()=default | |
absl::StatusOr< Tile16Proposal > | GenerateFromCommands (const std::string &prompt, const std::vector< std::string > &commands, const std::string &ai_service, Rom *rom) |
Generate a tile16 proposal from an AI-generated command list. | |
absl::Status | ApplyProposal (const Tile16Proposal &proposal, Rom *rom) |
Apply a proposal to a ROM (typically a sandbox). | |
absl::StatusOr< gfx::Bitmap > | GenerateDiff (const Tile16Proposal &proposal, Rom *before_rom, Rom *after_rom) |
Generate a visual diff bitmap for a proposal. | |
absl::Status | SaveProposal (const Tile16Proposal &proposal, const std::string &path) |
Save a proposal to a JSON file for later review. | |
absl::StatusOr< Tile16Proposal > | LoadProposal (const std::string &path) |
Load a proposal from a JSON file. | |
Private Member Functions | |
absl::StatusOr< Tile16Change > | ParseSetTileCommand (const std::string &command, Rom *rom) |
Parse a single "overworld set-tile" command into a Tile16Change. | |
absl::StatusOr< std::vector< Tile16Change > > | ParseSetAreaCommand (const std::string &command, Rom *rom) |
Parse a "overworld set-area" command into multiple Tile16Changes. | |
absl::StatusOr< std::vector< Tile16Change > > | ParseReplaceTileCommand (const std::string &command, Rom *rom) |
Parse a "overworld replace-tile" command into multiple Tile16Changes. | |
std::string | GenerateProposalId () const |
Generate a unique proposal ID. | |
Friends | |
class | Tile16ProposalGeneratorTest |
Generates and manages tile16 editing proposals.
This class bridges the AI service with the overworld editing system, providing a safe sandbox workflow for reviewing and applying changes.
Definition at line 63 of file tile16_proposal_generator.h.
|
default |
absl::StatusOr< Tile16Proposal > yaze::cli::Tile16ProposalGenerator::GenerateFromCommands | ( | const std::string & | prompt, |
const std::vector< std::string > & | commands, | ||
const std::string & | ai_service, | ||
Rom * | rom | ||
) |
Generate a tile16 proposal from an AI-generated command list.
prompt | The original user prompt |
commands | List of commands from AI (e.g., "overworld set-tile ...") |
ai_service | Name of the AI service used |
rom | Reference ROM for validation |
Definition at line 488 of file tile16_proposal_generator.cc.
References yaze::cli::Tile16Proposal::ai_service, yaze::cli::Tile16Proposal::changes, yaze::cli::Tile16Proposal::created_at, GenerateProposalId(), yaze::cli::Tile16Proposal::id, ParseReplaceTileCommand(), ParseSetAreaCommand(), ParseSetTileCommand(), yaze::cli::Tile16Proposal::PENDING, yaze::cli::Tile16Proposal::prompt, yaze::cli::Tile16Proposal::reasoning, and yaze::cli::Tile16Proposal::status.
Referenced by yaze::cli::agent::CreateProposalFromAgentResponse(), and yaze::cli::agent::HandlePlanCommand().
absl::Status yaze::cli::Tile16ProposalGenerator::ApplyProposal | ( | const Tile16Proposal & | proposal, |
Rom * | rom | ||
) |
Apply a proposal to a ROM (typically a sandbox).
This modifies the ROM in memory but doesn't save to disk. Used for preview and testing.
proposal | The proposal to apply |
rom | The ROM to modify |
Definition at line 548 of file tile16_proposal_generator.cc.
References yaze::cli::Tile16Proposal::changes, yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::zelda3::Overworld::set_current_world(), and yaze::zelda3::Overworld::SetTile().
Referenced by yaze::cli::agent::CreateProposalFromAgentResponse().
absl::StatusOr< gfx::Bitmap > yaze::cli::Tile16ProposalGenerator::GenerateDiff | ( | const Tile16Proposal & | proposal, |
Rom * | before_rom, | ||
Rom * | after_rom | ||
) |
Generate a visual diff bitmap for a proposal.
Creates a side-by-side or overlay comparison of before/after state.
proposal | The proposal to visualize |
before_rom | ROM in original state |
after_rom | ROM with proposal applied |
Definition at line 583 of file tile16_proposal_generator.cc.
References yaze::cli::Tile16Proposal::changes, yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::zelda3::Overworld::set_current_world(), and yaze::gfx::Bitmap::SetPixel().
absl::Status yaze::cli::Tile16ProposalGenerator::SaveProposal | ( | const Tile16Proposal & | proposal, |
const std::string & | path | ||
) |
Save a proposal to a JSON file for later review.
proposal | The proposal to save |
path | File path to save to |
Definition at line 701 of file tile16_proposal_generator.cc.
References yaze::cli::Tile16Proposal::ToJson().
Referenced by yaze::cli::agent::CreateProposalFromAgentResponse(), and yaze::cli::agent::HandlePlanCommand().
absl::StatusOr< Tile16Proposal > yaze::cli::Tile16ProposalGenerator::LoadProposal | ( | const std::string & | path | ) |
Load a proposal from a JSON file.
path | File path to load from |
Definition at line 717 of file tile16_proposal_generator.cc.
References yaze::cli::Tile16Proposal::FromJson().
|
private |
Parse a single "overworld set-tile" command into a Tile16Change.
Expected format: "overworld set-tile --map 0 --x 10 --y 20 --tile 0x02E"
Definition at line 242 of file tile16_proposal_generator.cc.
References yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::cli::Tile16Change::map_id, yaze::cli::Tile16Change::new_tile, yaze::cli::Tile16Change::old_tile, yaze::zelda3::Overworld::set_current_world(), yaze::cli::Tile16Change::x, and yaze::cli::Tile16Change::y.
Referenced by GenerateFromCommands().
|
private |
Parse a "overworld set-area" command into multiple Tile16Changes.
Expected format: "overworld set-area --map 0 --x 10 --y 20 --width 5 --height 3 --tile 0x02E"
Definition at line 305 of file tile16_proposal_generator.cc.
References yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::cli::Tile16Change::map_id, yaze::cli::Tile16Change::new_tile, yaze::cli::Tile16Change::old_tile, yaze::zelda3::Overworld::set_current_world(), yaze::cli::Tile16Change::x, and yaze::cli::Tile16Change::y.
Referenced by GenerateFromCommands().
|
private |
Parse a "overworld replace-tile" command into multiple Tile16Changes.
Expected format: "overworld replace-tile --map 0 --old-tile 0x02E --new-tile 0x030" Can also specify optional bounds: –x-min 0 –y-min 0 –x-max 31 –y-max 31
Definition at line 395 of file tile16_proposal_generator.cc.
References yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::cli::Tile16Change::map_id, yaze::cli::Tile16Change::new_tile, yaze::cli::Tile16Change::old_tile, yaze::zelda3::Overworld::set_current_world(), yaze::cli::Tile16Change::x, and yaze::cli::Tile16Change::y.
Referenced by GenerateFromCommands().
|
private |
Generate a unique proposal ID.
Definition at line 231 of file tile16_proposal_generator.cc.
Referenced by GenerateFromCommands().
|
friend |
Definition at line 68 of file tile16_proposal_generator.h.