8#include "absl/status/status.h"
9#include "absl/strings/str_format.h"
20 const char* command) {
21 const auto plan = parser.
GetString(
"plan");
22 const auto project = parser.
GetString(
"project");
23 const bool has_plan = plan.has_value() && !plan->empty();
24 const bool has_project = project.has_value() && !project->empty();
25 if (has_plan == has_project) {
26 return absl::InvalidArgumentError(absl::StrFormat(
27 "%s: pass exactly one of --plan or --project", command));
29 return absl::OkStatus();
36 plan.has_value() && !plan->empty()) {
43 return absl::FailedPreconditionError(
44 absl::StrFormat(
"Project %s has no [planning] file", project.
filepath));
49absl::StatusOr<std::string>
ReadText(
const std::string& path) {
50 std::ifstream file(path, std::ios::binary);
51 if (!file.is_open()) {
52 return absl::NotFoundError(absl::StrFormat(
"Cannot read %s", path));
54 return std::string(std::istreambuf_iterator<char>(file), {});
57template <
typename Entry>
59 const std::vector<Entry>& entries) {
61 for (
const auto& entry : entries) {
73 "Print a yaze.plan/1 file's SHA-256, entry IDs and agent status. Agents "
74 "copy sha256 into an agent update's base_sha256.";
76 {
"--plan",
"Path to the yaze.plan/1 JSON file",
""},
77 {
"--project",
"Path to a .yaze project; uses its [planning] file",
""},
84 return ValidatePlanSource(parser,
"plan-read");
98 AddIds(formatter,
"milestones", plan.
milestones);
101 AddIds(formatter,
"decisions", plan.
decisions);
105 formatter.
AddField(
"present", section !=
nullptr);
107 if (section !=
nullptr) {
108 if (
auto it = section->find(
"observations");
109 it != section->end() && it->is_object()) {
110 for (
auto obs = it->begin(); obs != it->end(); ++obs) {
122 return absl::OkStatus();
130 "Check, diff and apply a yaze.plan.agent_update/1 document to a plan's "
131 "agent_status section. Human notes, answers, titles, route order and "
132 "unknown sections are never written. A stale base_sha256 is refused "
133 "before writing; an unchanged update does not write.";
135 {
"--plan",
"Path to the yaze.plan/1 JSON file",
""},
136 {
"--project",
"Path to a .yaze project; uses its [planning] file",
""},
137 {
"--update",
"Path to the agent update JSON (required)",
""},
138 {
"--dry-run",
"Validate and print the diff without writing",
""},
146 const auto update = parser.
GetString(
"update");
147 if (!update.has_value() || update->empty()) {
148 return absl::InvalidArgumentError(
"plan-agent-apply: --update is required");
150 return absl::OkStatus();
161 const bool dry_run = parser.
HasFlag(
"dry-run");
165 formatter.
AddField(
"dry_run", dry_run);
177 return absl::OkStatus();
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Descriptor Describe() const override
Provide metadata for TUI/help summaries.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status Execute(Rom *rom, const resources::ArgumentParser &parser, resources::OutputFormatter &formatter) override
Execute the command business logic.
absl::Status ValidateArgs(const resources::ArgumentParser &parser) override
Validate command arguments.
Descriptor Describe() const override
Provide metadata for TUI/help summaries.
Utility for parsing common CLI argument patterns.
std::optional< std::string > GetString(const std::string &name) const
Parse a named argument (e.g., –format=json or –format json)
bool HasFlag(const std::string &name) const
Check if a flag is present.
std::vector< PlanMilestone > milestones
static absl::StatusOr< ProjectPlan > LoadFromFile(const std::string &path, std::string *source=nullptr)
std::vector< PlanRouteItem > route_items
std::vector< PlanRouteStep > route_steps
std::vector< PlanDecision > decisions
#define ASSIGN_OR_RETURN(type_variable_name, expression)
absl::Status ValidatePlanSource(const resources::ArgumentParser &parser, const char *command)
absl::StatusOr< std::string > ResolvePlanPath(const resources::ArgumentParser &parser)
void AddIds(resources::OutputFormatter &formatter, const char *key, const std::vector< Entry > &entries)
absl::StatusOr< std::string > ReadText(const std::string &path)
const PlanJson * FindPlanAgentStatus(const ProjectPlan &plan)
constexpr std::string_view kProjectPlanSchema
std::string ComputeSourceArtifactSha256(std::string_view content)
const char * PlanAgentChangeKindName(PlanAgentChangeKind kind)
nlohmann::ordered_json PlanJson
absl::StatusOr< PlanAgentFileResult > ApplyPlanAgentUpdateToFile(const std::string &path, const PlanAgentUpdate &update, bool dry_run)
std::vector< std::string > OrphanedPlanAgentObservations(const ProjectPlan &plan)
#define RETURN_IF_ERROR(expr)
std::vector< DescriptorEntry > entries
std::vector< PlanAgentChange > changes
std::string before_sha256
static absl::StatusOr< PlanAgentUpdate > Parse(std::string_view text)
Modern project structure with comprehensive settings consolidation.
PlanningSettings planning
std::string PlanningFilePath() const
absl::Status Open(const std::string &project_path)