Add native OBW editor POC with shared MCP session (by Codex)

This commit is contained in:
Codex committed 2026-10-22 21:41:10 +02:00
1 parent 6e5fa72ed5
commit bde8b10762
48 files changed
+5614 -1

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "editor/world.hpp"
#include <mutex>
namespace bmh::editor {
// One command boundary for native widgets, MCP and synthetic tests. No command
// owns game rules or operates on a live career.
class Session {
public:
Json execute(const std::string &command, const Json &args = Json::object());
std::pair<std::string, std::string> asset_bytes(const std::string &key_or_path) const;
private:
struct Delta {
std::string table, id;
std::optional<Json> before, after;
};
struct FileDelta {
std::string name;
std::shared_ptr<const std::string> before, after;
};
struct Frame {
std::string label;
std::vector<Delta> changes;
std::vector<FileDelta> files;
uint64_t before = 0, after = 0;
};
mutable std::recursive_mutex mutex_;
std::unique_ptr<World> world_;
std::vector<Frame> history_;
size_t cursor_ = 0;
uint64_t revision_ = 0, state_ = 0, next_state_ = 1, saved_state_ = 0;
fs::path saved_path_;
fs::file_time_type saved_time_{};
uint64_t saved_size_ = 0;
World &world();
bool dirty() const;
Json info() const;
Json apply(const Json &, std::vector<FileDelta> files = {}, const std::string &label = "edit");
void frame(const Frame &, bool forward);
void replace(World value);
Json import_image(const Json &);
};
} // namespace bmh::editor