feat: Implement advanced routing system for agent tool responses

- Introduced AdvancedRouter class for routing hex analysis, map editing, and palette analysis responses.
- Added methods for generating GUI automation scripts and synthesizing multi-tool responses.
- Implemented knowledge modules for agent pretraining, covering ROM structure, hex analysis patterns, and tool usage examples.
- Enhanced data handling with structured responses, including summaries, detailed data, and next steps for user guidance.
- Refactored project build process to utilize std::filesystem for cross-platform patch application.
This commit is contained in:
scawful
2025-10-05 01:44:23 -04:00
parent dc89d7b818
commit 7309baa8c2
5 changed files with 592 additions and 18 deletions

View File

@@ -2,6 +2,7 @@
#include "cli/z3ed.h"
#include "util/file_util.h"
#include "util/bps.h"
#include <filesystem>
#ifndef _WIN32
#include <glob.h>
#endif
@@ -40,17 +41,21 @@ absl::Status ProjectBuild::Run(const std::vector<std::string>& arg_vec) {
return status;
}
#ifdef _WIN32
return absl::UnimplementedError(
"Project build with patches is not implemented on Windows yet.");
#else
// Apply BPS patches
glob_t glob_result;
std::string pattern = project.patches_folder + "/*.bps";
glob(pattern.c_str(), GLOB_TILDE, NULL, &glob_result);
for (unsigned int i = 0; i < glob_result.gl_pathc; ++i) {
std::string patch_file = glob_result.gl_pathv[i];
// Apply BPS patches - cross-platform with std::filesystem
namespace fs = std::filesystem;
std::vector<std::string> bps_files;
try {
for (const auto& entry : fs::directory_iterator(project.patches_folder)) {
if (entry.path().extension() == ".bps") {
bps_files.push_back(entry.path().string());
}
}
} catch (const fs::filesystem_error& e) {
// Patches folder doesn't exist or not accessible
}
for (const auto& patch_file : bps_files) {
std::vector<uint8_t> patch_data;
auto patch_contents = util::LoadFile(patch_file);
std::copy(patch_contents.begin(), patch_contents.end(),
@@ -60,13 +65,21 @@ absl::Status ProjectBuild::Run(const std::vector<std::string>& arg_vec) {
rom.LoadFromData(patched_rom);
}
// Run asar on assembly files
glob_t glob_result_asm;
std::string pattern_asm = project.patches_folder + "/*.asm";
glob(pattern_asm.c_str(), GLOB_TILDE, NULL, &glob_result_asm);
for (unsigned int i = 0; i < glob_result_asm.gl_pathc; ++i) {
// Run asar on assembly files - cross-platform
std::vector<std::string> asm_files;
try {
for (const auto& entry : fs::directory_iterator(project.patches_folder)) {
if (entry.path().extension() == ".asm") {
asm_files.push_back(entry.path().string());
}
}
} catch (const fs::filesystem_error& e) {
// No asm files
}
for (const auto& asm_file : asm_files) {
AsarPatch asar_patch;
auto status = asar_patch.Run({glob_result_asm.gl_pathv[i]});
auto status = asar_patch.Run({asm_file});
if (!status.ok()) {
return status;
}
@@ -82,7 +95,6 @@ absl::Status ProjectBuild::Run(const std::vector<std::string>& arg_vec) {
std::cout << " Output ROM: " << output_file << std::endl;
return absl::OkStatus();
#endif
}
} // namespace cli