feat: Add simple chat session for AI agent interaction and enhance message rendering
This commit is contained in:
@@ -12,7 +12,7 @@ namespace agent {
|
||||
namespace {
|
||||
|
||||
constexpr absl::string_view kUsage =
|
||||
"Usage: agent <run|plan|diff|accept|test|test-conversation|gui|learn|list|commit|revert|describe|resource-list|dungeon-list-sprites|overworld-find-tile|overworld-describe-map|overworld-list-warps|chat> "
|
||||
"Usage: agent <run|plan|diff|accept|test|test-conversation|gui|learn|list|commit|revert|describe|resource-list|dungeon-list-sprites|overworld-find-tile|overworld-describe-map|overworld-list-warps|chat|simple-chat> "
|
||||
"[options]";
|
||||
|
||||
} // namespace
|
||||
@@ -80,6 +80,9 @@ absl::Status Agent::Run(const std::vector<std::string>& arg_vec) {
|
||||
if (subcommand == "chat") {
|
||||
return agent::HandleChatCommand(rom_);
|
||||
}
|
||||
if (subcommand == "simple-chat") {
|
||||
return agent::HandleSimpleChatCommand(subcommand_args, rom_);
|
||||
}
|
||||
|
||||
return absl::InvalidArgumentError(std::string(agent::kUsage));
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ absl::Status HandleOverworldListWarpsCommand(
|
||||
const std::vector<std::string>& arg_vec,
|
||||
Rom* rom_context = nullptr);
|
||||
absl::Status HandleChatCommand(Rom& rom);
|
||||
absl::Status HandleSimpleChatCommand(const std::vector<std::string>& arg_vec, Rom& rom);
|
||||
absl::Status HandleTestConversationCommand(
|
||||
const std::vector<std::string>& arg_vec);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "cli/service/ai/gemini_ai_service.h"
|
||||
#include "cli/service/ai/ollama_ai_service.h"
|
||||
#include "cli/service/ai/service_factory.h"
|
||||
#include "cli/service/agent/simple_chat_session.h"
|
||||
#include "cli/service/planning/proposal_registry.h"
|
||||
#include "cli/service/planning/tile16_proposal_generator.h"
|
||||
#include "cli/service/resources/resource_catalog.h"
|
||||
@@ -571,6 +572,32 @@ absl::Status HandleChatCommand(Rom& rom) {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status HandleSimpleChatCommand(const std::vector<std::string>& arg_vec,
|
||||
Rom& rom) {
|
||||
RETURN_IF_ERROR(EnsureRomLoaded(rom, "agent simple-chat"));
|
||||
|
||||
// Parse flags
|
||||
std::optional<std::string> batch_file;
|
||||
for (size_t i = 0; i < arg_vec.size(); ++i) {
|
||||
const std::string& arg = arg_vec[i];
|
||||
if (absl::StartsWith(arg, "--file=")) {
|
||||
batch_file = arg.substr(7);
|
||||
} else if (arg == "--file" && i + 1 < arg_vec.size()) {
|
||||
batch_file = arg_vec[i + 1];
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleChatSession session;
|
||||
session.SetRomContext(&rom);
|
||||
|
||||
if (batch_file.has_value()) {
|
||||
return session.RunBatch(*batch_file);
|
||||
} else {
|
||||
return session.RunInteractive();
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status HandleAcceptCommand(const std::vector<std::string>& arg_vec,
|
||||
Rom& rom) {
|
||||
std::optional<std::string> proposal_id;
|
||||
|
||||
Reference in New Issue
Block a user