yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
resource_catalog.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_SERVICE_RESOURCE_CATALOG_H_
2#define YAZE_SRC_CLI_SERVICE_RESOURCE_CATALOG_H_
3
4#include <string>
5#include <vector>
6
7#include "absl/status/status.h"
8#include "absl/status/statusor.h"
9#include "absl/strings/string_view.h"
10
11namespace yaze {
12namespace cli {
13
15 std::string flag;
16 std::string type;
18 std::string description;
19};
20
22 std::string name;
23 std::string synopsis;
24 std::string stability;
25 std::vector<ResourceArgument> arguments;
26 std::vector<std::string> effects;
27 struct ReturnValue {
28 std::string field;
29 std::string type;
30 std::string description;
31 };
32 std::vector<ReturnValue> returns;
33};
34
36 std::string resource;
37 std::string description;
38 std::vector<ResourceAction> actions;
39};
40
41// ResourceCatalog exposes a machine-readable description of CLI resources so that
42// both humans and AI agents can introspect capabilities at runtime.
44 public:
45 static const ResourceCatalog& Instance();
46
47 absl::StatusOr<ResourceSchema> GetResource(absl::string_view name) const;
48 const std::vector<ResourceSchema>& AllResources() const;
49
50 // Serialize helpers for `z3ed agent describe`. These return compact JSON
51 // strings so we avoid introducing a hard dependency on nlohmann::json.
52 std::string SerializeResource(const ResourceSchema& schema) const;
53 std::string SerializeResources(const std::vector<ResourceSchema>& schemas) const;
54 std::string SerializeResourcesAsYaml(
55 const std::vector<ResourceSchema>& schemas,
56 absl::string_view version,
57 absl::string_view last_updated) const;
58
59 private:
61
62 static std::string EscapeJson(absl::string_view value);
63 static std::string EscapeYaml(absl::string_view value);
64
65 std::vector<ResourceSchema> resources_;
66};
67
68} // namespace cli
69} // namespace yaze
70
71#endif // YAZE_SRC_CLI_SERVICE_RESOURCE_CATALOG_H_
static std::string EscapeJson(absl::string_view value)
absl::StatusOr< ResourceSchema > GetResource(absl::string_view name) const
static const ResourceCatalog & Instance()
std::string SerializeResourcesAsYaml(const std::vector< ResourceSchema > &schemas, absl::string_view version, absl::string_view last_updated) const
const std::vector< ResourceSchema > & AllResources() const
std::string SerializeResources(const std::vector< ResourceSchema > &schemas) const
std::string SerializeResource(const ResourceSchema &schema) const
std::vector< ResourceSchema > resources_
static std::string EscapeYaml(absl::string_view value)
Main namespace for the application.
Definition controller.cc:20
std::vector< ResourceArgument > arguments
std::vector< ReturnValue > returns
std::vector< std::string > effects
std::vector< ResourceAction > actions