agentera 0.0.0 → 3.0.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +6 -45
  2. package/bundle/.agentera-npx-bundle.json +4 -0
  3. package/bundle/references/adapters/cursor.md +213 -0
  4. package/bundle/references/adapters/opencode.md +530 -0
  5. package/bundle/references/adapters/package-manifest-interface-model.yaml +337 -0
  6. package/bundle/references/adapters/package-registry.yaml +247 -0
  7. package/bundle/references/adapters/package-surface-characterization.md +48 -0
  8. package/bundle/references/adapters/runtime-adapter-characterization.md +79 -0
  9. package/bundle/references/adapters/runtime-adapter-interface-model.yaml +200 -0
  10. package/bundle/references/adapters/runtime-adapter-registry.yaml +548 -0
  11. package/bundle/references/adapters/runtime-feature-parity.md +189 -0
  12. package/bundle/references/analysis/benchmark.md +267 -0
  13. package/bundle/references/analysis/startup-measurement-contract.yaml +424 -0
  14. package/bundle/references/artifacts/artifact-registry-interface-model.yaml +288 -0
  15. package/bundle/references/cli/agent-ready-state-contract.yaml +950 -0
  16. package/bundle/references/cli/app-lifecycle-vocabulary.yaml +241 -0
  17. package/bundle/references/cli/audience-namespace-cli-migration.yaml +355 -0
  18. package/bundle/references/cli/bundle-skill-vocabulary.yaml +278 -0
  19. package/bundle/references/cli/capability-instruction-contract.yaml +123 -0
  20. package/bundle/references/cli/capability-tool-classification.yaml +53 -0
  21. package/bundle/references/cli/routing-execution-vocabulary.yaml +281 -0
  22. package/bundle/references/cli/update-channels.yaml +147 -0
  23. package/bundle/references/cli/vocabulary-index.yaml +160 -0
  24. package/bundle/references/cli/vocabulary.md +566 -0
  25. package/bundle/references/meta/documentation-inventory.md +43 -0
  26. package/bundle/references/v1-section-mapping.md +47 -0
  27. package/bundle/registry.json +39 -0
  28. package/bundle/skills/agentera/.claude-plugin/plugin.json +27 -0
  29. package/bundle/skills/agentera/SKILL.md +470 -0
  30. package/bundle/skills/agentera/agents/dokumentera.toml +6 -0
  31. package/bundle/skills/agentera/agents/hej.toml +6 -0
  32. package/bundle/skills/agentera/agents/inspektera.toml +6 -0
  33. package/bundle/skills/agentera/agents/inspirera.toml +6 -0
  34. package/bundle/skills/agentera/agents/optimera.toml +6 -0
  35. package/bundle/skills/agentera/agents/orkestrera.toml +6 -0
  36. package/bundle/skills/agentera/agents/planera.toml +6 -0
  37. package/bundle/skills/agentera/agents/profilera.toml +6 -0
  38. package/bundle/skills/agentera/agents/realisera.toml +6 -0
  39. package/bundle/skills/agentera/agents/resonera.toml +6 -0
  40. package/bundle/skills/agentera/agents/visionera.toml +6 -0
  41. package/bundle/skills/agentera/agents/visualisera.toml +6 -0
  42. package/bundle/skills/agentera/capabilities/dokumentera/instructions.md +428 -0
  43. package/bundle/skills/agentera/capabilities/dokumentera/schemas/artifacts.yaml +73 -0
  44. package/bundle/skills/agentera/capabilities/dokumentera/schemas/exit.yaml +35 -0
  45. package/bundle/skills/agentera/capabilities/dokumentera/schemas/triggers.yaml +35 -0
  46. package/bundle/skills/agentera/capabilities/dokumentera/schemas/validation.yaml +139 -0
  47. package/bundle/skills/agentera/capabilities/hej/instructions.md +331 -0
  48. package/bundle/skills/agentera/capabilities/hej/schemas/artifacts.yaml +69 -0
  49. package/bundle/skills/agentera/capabilities/hej/schemas/exit.yaml +32 -0
  50. package/bundle/skills/agentera/capabilities/hej/schemas/triggers.yaml +58 -0
  51. package/bundle/skills/agentera/capabilities/hej/schemas/validation.yaml +55 -0
  52. package/bundle/skills/agentera/capabilities/inspektera/instructions.md +514 -0
  53. package/bundle/skills/agentera/capabilities/inspektera/schemas/artifacts.yaml +76 -0
  54. package/bundle/skills/agentera/capabilities/inspektera/schemas/exit.yaml +36 -0
  55. package/bundle/skills/agentera/capabilities/inspektera/schemas/triggers.yaml +38 -0
  56. package/bundle/skills/agentera/capabilities/inspektera/schemas/validation.yaml +113 -0
  57. package/bundle/skills/agentera/capabilities/inspirera/instructions.md +280 -0
  58. package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +24 -0
  59. package/bundle/skills/agentera/capabilities/inspirera/schemas/exit.yaml +33 -0
  60. package/bundle/skills/agentera/capabilities/inspirera/schemas/triggers.yaml +34 -0
  61. package/bundle/skills/agentera/capabilities/inspirera/schemas/validation.yaml +58 -0
  62. package/bundle/skills/agentera/capabilities/optimera/instructions.md +437 -0
  63. package/bundle/skills/agentera/capabilities/optimera/schemas/artifacts.yaml +69 -0
  64. package/bundle/skills/agentera/capabilities/optimera/schemas/exit.yaml +35 -0
  65. package/bundle/skills/agentera/capabilities/optimera/schemas/triggers.yaml +39 -0
  66. package/bundle/skills/agentera/capabilities/optimera/schemas/validation.yaml +91 -0
  67. package/bundle/skills/agentera/capabilities/orkestrera/instructions.md +433 -0
  68. package/bundle/skills/agentera/capabilities/orkestrera/schemas/artifacts.yaml +64 -0
  69. package/bundle/skills/agentera/capabilities/orkestrera/schemas/exit.yaml +34 -0
  70. package/bundle/skills/agentera/capabilities/orkestrera/schemas/triggers.yaml +42 -0
  71. package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +107 -0
  72. package/bundle/skills/agentera/capabilities/planera/instructions.md +368 -0
  73. package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +62 -0
  74. package/bundle/skills/agentera/capabilities/planera/schemas/exit.yaml +33 -0
  75. package/bundle/skills/agentera/capabilities/planera/schemas/triggers.yaml +34 -0
  76. package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +61 -0
  77. package/bundle/skills/agentera/capabilities/profilera/instructions.md +419 -0
  78. package/bundle/skills/agentera/capabilities/profilera/schemas/artifacts.yaml +18 -0
  79. package/bundle/skills/agentera/capabilities/profilera/schemas/exit.yaml +34 -0
  80. package/bundle/skills/agentera/capabilities/profilera/schemas/triggers.yaml +45 -0
  81. package/bundle/skills/agentera/capabilities/profilera/schemas/validation.yaml +57 -0
  82. package/bundle/skills/agentera/capabilities/realisera/instructions.md +403 -0
  83. package/bundle/skills/agentera/capabilities/realisera/schemas/artifacts.yaml +80 -0
  84. package/bundle/skills/agentera/capabilities/realisera/schemas/exit.yaml +35 -0
  85. package/bundle/skills/agentera/capabilities/realisera/schemas/triggers.yaml +39 -0
  86. package/bundle/skills/agentera/capabilities/realisera/schemas/validation.yaml +110 -0
  87. package/bundle/skills/agentera/capabilities/resonera/instructions.md +329 -0
  88. package/bundle/skills/agentera/capabilities/resonera/schemas/artifacts.yaml +47 -0
  89. package/bundle/skills/agentera/capabilities/resonera/schemas/exit.yaml +35 -0
  90. package/bundle/skills/agentera/capabilities/resonera/schemas/triggers.yaml +46 -0
  91. package/bundle/skills/agentera/capabilities/resonera/schemas/validation.yaml +77 -0
  92. package/bundle/skills/agentera/capabilities/visionera/instructions.md +309 -0
  93. package/bundle/skills/agentera/capabilities/visionera/schemas/artifacts.yaml +57 -0
  94. package/bundle/skills/agentera/capabilities/visionera/schemas/exit.yaml +35 -0
  95. package/bundle/skills/agentera/capabilities/visionera/schemas/triggers.yaml +41 -0
  96. package/bundle/skills/agentera/capabilities/visionera/schemas/validation.yaml +74 -0
  97. package/bundle/skills/agentera/capabilities/visualisera/instructions.md +400 -0
  98. package/bundle/skills/agentera/capabilities/visualisera/schemas/artifacts.yaml +44 -0
  99. package/bundle/skills/agentera/capabilities/visualisera/schemas/exit.yaml +34 -0
  100. package/bundle/skills/agentera/capabilities/visualisera/schemas/triggers.yaml +33 -0
  101. package/bundle/skills/agentera/capabilities/visualisera/schemas/validation.yaml +80 -0
  102. package/bundle/skills/agentera/capability_schema_contract.yaml +385 -0
  103. package/bundle/skills/agentera/protocol.yaml +463 -0
  104. package/bundle/skills/agentera/references/contract.md +1039 -0
  105. package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +60 -0
  106. package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +461 -0
  107. package/bundle/skills/agentera/schemas/artifacts/design.yaml +55 -0
  108. package/bundle/skills/agentera/schemas/artifacts/docs.yaml +402 -0
  109. package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +373 -0
  110. package/bundle/skills/agentera/schemas/artifacts/health.yaml +484 -0
  111. package/bundle/skills/agentera/schemas/artifacts/objective.yaml +399 -0
  112. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +342 -0
  113. package/bundle/skills/agentera/schemas/artifacts/progress.yaml +325 -0
  114. package/bundle/skills/agentera/schemas/artifacts/todo.yaml +110 -0
  115. package/bundle/skills/agentera/schemas/artifacts/vision.yaml +262 -0
  116. package/bundle/skills/hej/.claude-plugin/plugin.json +6 -0
  117. package/bundle/skills/hej/SKILL.md +69 -0
  118. package/bundle/skills/hej/agents/hej.toml +11 -0
  119. package/bundle/skills/hej/agents/openai.yaml +8 -0
  120. package/dist/analytics/extractCorpus.js +1791 -0
  121. package/dist/analytics/extractCorpus.js.map +1 -0
  122. package/dist/analytics/usageStats.js +487 -0
  123. package/dist/analytics/usageStats.js.map +1 -0
  124. package/dist/bin/agentera.js +4 -0
  125. package/dist/bin/agentera.js.map +1 -0
  126. package/dist/cli/appContext.js +226 -0
  127. package/dist/cli/appContext.js.map +1 -0
  128. package/dist/cli/argvalidate.js +41 -0
  129. package/dist/cli/argvalidate.js.map +1 -0
  130. package/dist/cli/capabilityContext.js +2421 -0
  131. package/dist/cli/capabilityContext.js.map +1 -0
  132. package/dist/cli/commands/backfill.js +84 -0
  133. package/dist/cli/commands/backfill.js.map +1 -0
  134. package/dist/cli/commands/capability.js +44 -0
  135. package/dist/cli/commands/capability.js.map +1 -0
  136. package/dist/cli/commands/compact.js +148 -0
  137. package/dist/cli/commands/compact.js.map +1 -0
  138. package/dist/cli/commands/doctor.js +180 -0
  139. package/dist/cli/commands/doctor.js.map +1 -0
  140. package/dist/cli/commands/lint.js +179 -0
  141. package/dist/cli/commands/lint.js.map +1 -0
  142. package/dist/cli/commands/prime.js +544 -0
  143. package/dist/cli/commands/prime.js.map +1 -0
  144. package/dist/cli/commands/query.js +346 -0
  145. package/dist/cli/commands/query.js.map +1 -0
  146. package/dist/cli/commands/report.js +210 -0
  147. package/dist/cli/commands/report.js.map +1 -0
  148. package/dist/cli/commands/schema.js +306 -0
  149. package/dist/cli/commands/schema.js.map +1 -0
  150. package/dist/cli/commands/state.js +1012 -0
  151. package/dist/cli/commands/state.js.map +1 -0
  152. package/dist/cli/commands/upgrade.js +48 -0
  153. package/dist/cli/commands/upgrade.js.map +1 -0
  154. package/dist/cli/commands/validate.js +519 -0
  155. package/dist/cli/commands/validate.js.map +1 -0
  156. package/dist/cli/commands/verify.js +204 -0
  157. package/dist/cli/commands/verify.js.map +1 -0
  158. package/dist/cli/dispatch.js +958 -0
  159. package/dist/cli/dispatch.js.map +1 -0
  160. package/dist/cli/orientation.js +595 -0
  161. package/dist/cli/orientation.js.map +1 -0
  162. package/dist/cli/prime-blob.js +3 -0
  163. package/dist/cli/prime-blob.js.map +1 -0
  164. package/dist/cli/stateQuery.js +292 -0
  165. package/dist/cli/stateQuery.js.map +1 -0
  166. package/dist/cli/structured.js +18 -0
  167. package/dist/cli/structured.js.map +1 -0
  168. package/dist/core/difflib.js +274 -0
  169. package/dist/core/difflib.js.map +1 -0
  170. package/dist/core/git.js +43 -0
  171. package/dist/core/git.js.map +1 -0
  172. package/dist/core/paths.js +50 -0
  173. package/dist/core/paths.js.map +1 -0
  174. package/dist/core/pyjson.js +101 -0
  175. package/dist/core/pyjson.js.map +1 -0
  176. package/dist/core/sourceRoot.js +72 -0
  177. package/dist/core/sourceRoot.js.map +1 -0
  178. package/dist/core/toml.js +11 -0
  179. package/dist/core/toml.js.map +1 -0
  180. package/dist/core/yaml.js +25 -0
  181. package/dist/core/yaml.js.map +1 -0
  182. package/dist/eval/evalSkills.js +258 -0
  183. package/dist/eval/evalSkills.js.map +1 -0
  184. package/dist/eval/semanticEval.js +148 -0
  185. package/dist/eval/semanticEval.js.map +1 -0
  186. package/dist/eval/semanticFixtures.js +227 -0
  187. package/dist/eval/semanticFixtures.js.map +1 -0
  188. package/dist/hooks/common.js +160 -0
  189. package/dist/hooks/common.js.map +1 -0
  190. package/dist/hooks/compaction.js +935 -0
  191. package/dist/hooks/compaction.js.map +1 -0
  192. package/dist/hooks/cursorPreToolUse.js +19 -0
  193. package/dist/hooks/cursorPreToolUse.js.map +1 -0
  194. package/dist/hooks/cursorSessionStart.js +71 -0
  195. package/dist/hooks/cursorSessionStart.js.map +1 -0
  196. package/dist/hooks/sessionStart.js +209 -0
  197. package/dist/hooks/sessionStart.js.map +1 -0
  198. package/dist/hooks/sessionStop.js +212 -0
  199. package/dist/hooks/sessionStop.js.map +1 -0
  200. package/dist/hooks/validateArtifact.js +933 -0
  201. package/dist/hooks/validateArtifact.js.map +1 -0
  202. package/dist/registries/artifactRegistry.js +206 -0
  203. package/dist/registries/artifactRegistry.js.map +1 -0
  204. package/dist/registries/capabilityContract.js +310 -0
  205. package/dist/registries/capabilityContract.js.map +1 -0
  206. package/dist/registries/packageRegistry.js +641 -0
  207. package/dist/registries/packageRegistry.js.map +1 -0
  208. package/dist/registries/runtimeAdapterRegistry.js +315 -0
  209. package/dist/registries/runtimeAdapterRegistry.js.map +1 -0
  210. package/dist/setup/codex.js +1056 -0
  211. package/dist/setup/codex.js.map +1 -0
  212. package/dist/setup/copilot.js +227 -0
  213. package/dist/setup/copilot.js.map +1 -0
  214. package/dist/setup/cursor.js +127 -0
  215. package/dist/setup/cursor.js.map +1 -0
  216. package/dist/setup/doctor.js +1276 -0
  217. package/dist/setup/doctor.js.map +1 -0
  218. package/dist/state/installRoot.js +279 -0
  219. package/dist/state/installRoot.js.map +1 -0
  220. package/dist/state/progressCommit.js +289 -0
  221. package/dist/state/progressCommit.js.map +1 -0
  222. package/dist/state/startupAnalysis.js +1953 -0
  223. package/dist/state/startupAnalysis.js.map +1 -0
  224. package/dist/upgrade/appModel.js +189 -0
  225. package/dist/upgrade/appModel.js.map +1 -0
  226. package/dist/upgrade/channels.js +208 -0
  227. package/dist/upgrade/channels.js.map +1 -0
  228. package/dist/upgrade/compatibility.js +201 -0
  229. package/dist/upgrade/compatibility.js.map +1 -0
  230. package/dist/upgrade/doctor.js +373 -0
  231. package/dist/upgrade/doctor.js.map +1 -0
  232. package/dist/upgrade/migrateArtifactsV2ToV3.js +332 -0
  233. package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -0
  234. package/dist/upgrade/runtimeMigration.js +484 -0
  235. package/dist/upgrade/runtimeMigration.js.map +1 -0
  236. package/dist/upgrade/upgradeCommands.js +36 -0
  237. package/dist/upgrade/upgradeCommands.js.map +1 -0
  238. package/dist/upgrade/upgradeOrchestrator.js +299 -0
  239. package/dist/upgrade/upgradeOrchestrator.js.map +1 -0
  240. package/dist/upgrade/versionResolution.js +179 -0
  241. package/dist/upgrade/versionResolution.js.map +1 -0
  242. package/dist/validate/appHomeContract.js +150 -0
  243. package/dist/validate/appHomeContract.js.map +1 -0
  244. package/dist/validate/capability.js +412 -0
  245. package/dist/validate/capability.js.map +1 -0
  246. package/dist/validate/crossCapability.js +145 -0
  247. package/dist/validate/crossCapability.js.map +1 -0
  248. package/dist/validate/lifecycleAdapters.js +772 -0
  249. package/dist/validate/lifecycleAdapters.js.map +1 -0
  250. package/dist/validate/selfAudit.js +107 -0
  251. package/dist/validate/selfAudit.js.map +1 -0
  252. package/package.json +28 -8
  253. package/LICENSE +0 -201
  254. package/bin/agentera.mjs +0 -50
  255. package/lib/exec.mjs +0 -116
  256. package/lib/resolve.mjs +0 -129
@@ -0,0 +1,641 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { loadYamlMapping } from "../core/yaml.js";
4
+ import { resolvePath } from "../core/paths.js";
5
+ import { resolveSourceRoot } from "../core/sourceRoot.js";
6
+ export const EXPECTED_PACKAGE_ORDER = ["agentera"];
7
+ export const REQUIRED_GROUPS = [
8
+ "identity",
9
+ "version_authority",
10
+ "version_surfaces",
11
+ "runtime_package_manifests",
12
+ "bundle_surfaces",
13
+ "package_commands",
14
+ "docs_targets",
15
+ "release_policy",
16
+ ];
17
+ const REQUIRED_FIELDS = {
18
+ identity: ["id", "name", "skill_path", "expected_capabilities"],
19
+ version_authority: [
20
+ "persisted_authority",
21
+ "selector",
22
+ "access_interface",
23
+ "future_authority_change_requires",
24
+ ],
25
+ version_surfaces: ["surfaces", "excluded_runtime_manifests"],
26
+ runtime_package_manifests: ["manifests", "shared_paths", "shared_paths_policy"],
27
+ bundle_surfaces: ["directories", "files", "skip_parts", "skip_suffixes"],
28
+ package_commands: ["commands", "safety"],
29
+ docs_targets: ["version_files_source", "version_files", "index_targets", "excluded_version_files"],
30
+ release_policy: [
31
+ "semver_policy_source",
32
+ "version_bump_required_for_interface_only_change",
33
+ "release_publication_in_scope",
34
+ ],
35
+ };
36
+ const CONSUMER_GROUPS = {
37
+ validator: ["identity", "version_authority", "version_surfaces", "runtime_package_manifests"],
38
+ upgrade: ["identity", "version_authority", "bundle_surfaces", "package_commands"],
39
+ docs: ["identity", "version_authority", "docs_targets", "release_policy"],
40
+ tests: REQUIRED_GROUPS,
41
+ };
42
+ const APPROVED_EXECUTABLES = new Set(["npx"]);
43
+ const APPROVED_ACTIONS = new Set(["remove-legacy-skills", "install-agentera-skill"]);
44
+ const APPROVED_RUNTIMES = new Set(["all", "claude", "opencode"]);
45
+ const APPROVED_RUNTIME_AGENTS = new Set(["claude-code", "opencode"]);
46
+ const CLEANUP_ACTIONS = new Set(["remove-legacy-skills"]);
47
+ const RUNTIME_INSTALL_ACTIONS = new Set(["install-agentera-skill"]);
48
+ const FORBIDDEN_INSTALL_ROOT_FIELDS = new Set([
49
+ "install_root",
50
+ "install_root_classification",
51
+ "AGENTERA_HOME_precedence",
52
+ "default_durable_root",
53
+ "managed_classification",
54
+ "root_diagnostics",
55
+ ]);
56
+ const FORBIDDEN_RUNTIME_ADAPTER_FIELDS = new Set([
57
+ "runtime_discovery",
58
+ "host_detection",
59
+ "lifecycle_events",
60
+ "artifact_validation",
61
+ "config_targets",
62
+ "diagnostics",
63
+ "documentation_claims",
64
+ ]);
65
+ export class RegistryError extends Error {
66
+ constructor(message) {
67
+ super(message);
68
+ this.name = "RegistryError";
69
+ }
70
+ }
71
+ function defaultRoot() {
72
+ return resolveSourceRoot();
73
+ }
74
+ export function defaultRegistryPath(root = defaultRoot()) {
75
+ return path.join(root, "references/adapters/package-registry.yaml");
76
+ }
77
+ function isMapping(value) {
78
+ return value !== null && typeof value === "object" && !Array.isArray(value);
79
+ }
80
+ function isStringList(value) {
81
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
82
+ }
83
+ export class PackageRegistry {
84
+ records;
85
+ root;
86
+ constructor(records, root = defaultRoot()) {
87
+ this.records = records;
88
+ this.root = root;
89
+ }
90
+ get packageIds() {
91
+ return this.records.map((record) => record.identity.id);
92
+ }
93
+ get(packageId = "agentera") {
94
+ for (const record of this.records) {
95
+ if (record.identity.id === packageId) {
96
+ return record;
97
+ }
98
+ }
99
+ throw new RegistryError(`unknown package id: ${packageId}`);
100
+ }
101
+ suiteVersion(packageId = "agentera") {
102
+ const record = this.get(packageId);
103
+ const authority = record.version_authority;
104
+ if (authority.persisted_authority !== "registry.json" ||
105
+ authority.selector !== "skills[0].version") {
106
+ throw new RegistryError("unsupported suite version authority selector");
107
+ }
108
+ let data;
109
+ try {
110
+ data = JSON.parse(fs.readFileSync(path.join(this.root, authority.persisted_authority), "utf8"));
111
+ }
112
+ catch (exc) {
113
+ throw new RegistryError(`registry.json missing skills[0].version`);
114
+ }
115
+ const version = data?.skills?.[0]?.version;
116
+ if (version === undefined) {
117
+ throw new RegistryError("registry.json missing skills[0].version");
118
+ }
119
+ if (typeof version !== "string" || !version) {
120
+ throw new RegistryError("registry.json skills[0].version must be a non-empty string");
121
+ }
122
+ return version;
123
+ }
124
+ consumerView(consumer, packageId = "agentera") {
125
+ const groups = CONSUMER_GROUPS[consumer];
126
+ if (groups === undefined) {
127
+ throw new RegistryError(`unknown registry consumer: ${consumer}`);
128
+ }
129
+ const record = this.get(packageId);
130
+ const view = {};
131
+ for (const group of groups) {
132
+ view[group] = record[group];
133
+ }
134
+ view.suite_version = this.suiteVersion(packageId);
135
+ return view;
136
+ }
137
+ versionSurfaceIds(packageId = "agentera") {
138
+ return this.get(packageId).version_surfaces.surfaces.map((s) => s.id);
139
+ }
140
+ runtimeManifestIds(packageId = "agentera") {
141
+ return this.get(packageId).runtime_package_manifests.manifests.map((m) => m.id);
142
+ }
143
+ runtimeManifestPaths(packageId = "agentera") {
144
+ const paths = {};
145
+ for (const manifest of this.get(packageId).runtime_package_manifests.manifests) {
146
+ if (!(manifest.runtime in paths)) {
147
+ paths[manifest.runtime] = manifest.path;
148
+ }
149
+ }
150
+ return paths;
151
+ }
152
+ runtimePackageShapes(packageId = "agentera") {
153
+ const shapes = {};
154
+ for (const manifest of this.get(packageId).runtime_package_manifests.manifests) {
155
+ shapes[manifest.runtime] = manifest.package_shape;
156
+ }
157
+ return shapes;
158
+ }
159
+ sharedPathRequirements(packageId = "agentera") {
160
+ const requirements = {};
161
+ for (const entry of this.get(packageId).runtime_package_manifests.shared_paths) {
162
+ requirements[entry.path] = entry.kind;
163
+ }
164
+ return requirements;
165
+ }
166
+ nonVersionBearingRuntimeManifests(packageId = "agentera") {
167
+ return this.get(packageId).runtime_package_manifests.manifests.filter((m) => m.version_bearing === false);
168
+ }
169
+ }
170
+ export function loadRegistry(registryPath = defaultRegistryPath(), root = defaultRoot()) {
171
+ const data = loadYamlMapping(fs.readFileSync(registryPath, "utf8"));
172
+ const errors = validateRegistryData(data, root);
173
+ if (errors.length > 0) {
174
+ throw new RegistryError("PackageManifest registry validation failed: " + errors.join("; "));
175
+ }
176
+ return new PackageRegistry(data.records, root);
177
+ }
178
+ export function validateRegistryFile(registryPath = defaultRegistryPath(), root = defaultRoot()) {
179
+ return validateRegistryData(loadYamlMapping(fs.readFileSync(registryPath, "utf8")), root);
180
+ }
181
+ export function validateRegistryData(data, root = defaultRoot()) {
182
+ const errors = [];
183
+ if (!isMapping(data)) {
184
+ return ["registry must be a YAML object"];
185
+ }
186
+ if (data.schema_version !== "agentera.packageRegistry.v1") {
187
+ errors.push("registry.schema_version must be agentera.packageRegistry.v1");
188
+ }
189
+ if (JSON.stringify(data.package_order) !== JSON.stringify([...EXPECTED_PACKAGE_ORDER])) {
190
+ errors.push("registry.package_order must be agentera");
191
+ }
192
+ const records = data.records;
193
+ if (!Array.isArray(records)) {
194
+ return [...errors, "registry.records must be a list"];
195
+ }
196
+ const seen = new Set();
197
+ const ids = [];
198
+ records.forEach((record, index) => {
199
+ const prefix = `records[${index}]`;
200
+ if (!isMapping(record)) {
201
+ errors.push(`${prefix} must be an object`);
202
+ return;
203
+ }
204
+ errors.push(...validateForbiddenFields(prefix, record));
205
+ for (const group of REQUIRED_GROUPS) {
206
+ if (!(group in record)) {
207
+ errors.push(`${prefix}: missing required group ${group}`);
208
+ }
209
+ }
210
+ for (const group of Object.keys(record)) {
211
+ if (!REQUIRED_GROUPS.includes(group)) {
212
+ errors.push(`${prefix}: unknown group ${group}`);
213
+ }
214
+ }
215
+ for (const group of REQUIRED_GROUPS) {
216
+ const groupValue = record[group];
217
+ if (isMapping(groupValue)) {
218
+ errors.push(...validateGroup(`${prefix}.${group}`, group, groupValue, root));
219
+ }
220
+ else if (group in record) {
221
+ errors.push(`${prefix}.${group} must be an object`);
222
+ }
223
+ }
224
+ const identity = record.identity;
225
+ const packageId = isMapping(identity) ? identity.id : null;
226
+ if (typeof packageId !== "string") {
227
+ return;
228
+ }
229
+ ids.push(packageId);
230
+ if (!EXPECTED_PACKAGE_ORDER.includes(packageId)) {
231
+ errors.push(`${prefix}.identity.id unknown package id: ${packageId}`);
232
+ }
233
+ if (seen.has(packageId)) {
234
+ errors.push(`duplicate package id: ${packageId}`);
235
+ }
236
+ seen.add(packageId);
237
+ });
238
+ if (JSON.stringify(ids) !== JSON.stringify([...EXPECTED_PACKAGE_ORDER])) {
239
+ errors.push("registry.records must be ordered as agentera");
240
+ }
241
+ return errors;
242
+ }
243
+ function validateGroup(prefix, group, value, root) {
244
+ const errors = [];
245
+ errors.push(...validateForbiddenFields(prefix, value));
246
+ for (const field of REQUIRED_FIELDS[group]) {
247
+ if (!(field in value)) {
248
+ errors.push(`${prefix}: missing required field ${field}`);
249
+ }
250
+ }
251
+ for (const field of Object.keys(value)) {
252
+ if (!REQUIRED_FIELDS[group].includes(field)) {
253
+ errors.push(`${prefix}: unknown field ${field}`);
254
+ }
255
+ }
256
+ switch (group) {
257
+ case "identity":
258
+ errors.push(...validateIdentity(prefix, value, root));
259
+ break;
260
+ case "version_authority":
261
+ errors.push(...validateVersionAuthority(prefix, value, root));
262
+ break;
263
+ case "version_surfaces":
264
+ errors.push(...validateVersionSurfaces(prefix, value, root));
265
+ break;
266
+ case "runtime_package_manifests":
267
+ errors.push(...validateRuntimeManifests(prefix, value, root));
268
+ break;
269
+ case "bundle_surfaces":
270
+ errors.push(...validateBundleSurfaces(prefix, value, root));
271
+ break;
272
+ case "package_commands":
273
+ errors.push(...validatePackageCommands(prefix, value));
274
+ break;
275
+ case "docs_targets":
276
+ errors.push(...validateDocsTargets(prefix, value, root));
277
+ break;
278
+ case "release_policy":
279
+ errors.push(...validateReleasePolicy(prefix, value));
280
+ break;
281
+ }
282
+ return errors;
283
+ }
284
+ function validateIdentity(prefix, value, root) {
285
+ const errors = [];
286
+ for (const field of ["id", "name"]) {
287
+ if (typeof value[field] !== "string" || !value[field]) {
288
+ errors.push(`${prefix}.${field} must be a non-empty string`);
289
+ }
290
+ }
291
+ if (!Number.isInteger(value.expected_capabilities)) {
292
+ errors.push(`${prefix}.expected_capabilities must be an integer`);
293
+ }
294
+ errors.push(...validateRepoPath(`${prefix}.skill_path`, value.skill_path, root));
295
+ return errors;
296
+ }
297
+ function validateVersionAuthority(prefix, value, root) {
298
+ const errors = [];
299
+ errors.push(...validateRepoPath(`${prefix}.persisted_authority`, value.persisted_authority, root));
300
+ for (const field of ["selector", "access_interface", "future_authority_change_requires"]) {
301
+ if (typeof value[field] !== "string" || !value[field]) {
302
+ errors.push(`${prefix}.${field} must be a non-empty string`);
303
+ }
304
+ }
305
+ if (value.access_interface !== "PackageManifest") {
306
+ errors.push(`${prefix}.access_interface must be PackageManifest`);
307
+ }
308
+ return errors;
309
+ }
310
+ function validateVersionSurfaces(prefix, value, root) {
311
+ const errors = [];
312
+ const surfaces = value.surfaces;
313
+ if (!Array.isArray(surfaces)) {
314
+ errors.push(`${prefix}.surfaces must be a list`);
315
+ }
316
+ else {
317
+ errors.push(...validateIdList(`${prefix}.surfaces`, surfaces));
318
+ surfaces.forEach((surface, index) => {
319
+ const surfacePrefix = `${prefix}.surfaces[${index}]`;
320
+ if (!isMapping(surface)) {
321
+ errors.push(`${surfacePrefix} must be an object`);
322
+ return;
323
+ }
324
+ errors.push(...validateRequiredObjectFields(surfacePrefix, surface, ["id", "path", "selector"]));
325
+ errors.push(...validateRepoPath(`${surfacePrefix}.path`, surface.path, root));
326
+ });
327
+ }
328
+ errors.push(...validatePathList(`${prefix}.excluded_runtime_manifests`, value.excluded_runtime_manifests, root));
329
+ return errors;
330
+ }
331
+ function validateRuntimeManifests(prefix, value, root) {
332
+ const errors = [];
333
+ const manifests = value.manifests;
334
+ if (!Array.isArray(manifests)) {
335
+ errors.push(`${prefix}.manifests must be a list`);
336
+ }
337
+ else {
338
+ errors.push(...validateIdList(`${prefix}.manifests`, manifests));
339
+ let nonVersionBearing = 0;
340
+ manifests.forEach((manifest, index) => {
341
+ const manifestPrefix = `${prefix}.manifests[${index}]`;
342
+ if (!isMapping(manifest)) {
343
+ errors.push(`${manifestPrefix} must be an object`);
344
+ return;
345
+ }
346
+ errors.push(...validateRequiredObjectFields(manifestPrefix, manifest, [
347
+ "id",
348
+ "runtime",
349
+ "path",
350
+ "version_bearing",
351
+ "package_shape",
352
+ ]));
353
+ errors.push(...validateRepoPath(`${manifestPrefix}.path`, manifest.path, root));
354
+ if (typeof manifest.version_bearing !== "boolean") {
355
+ errors.push(`${manifestPrefix}.version_bearing must be a boolean`);
356
+ }
357
+ else if (manifest.version_bearing === false) {
358
+ nonVersionBearing += 1;
359
+ }
360
+ });
361
+ if (nonVersionBearing === 0) {
362
+ errors.push(`${prefix}.manifests must include non-version-bearing runtime package manifests separately`);
363
+ }
364
+ }
365
+ const sharedPaths = value.shared_paths;
366
+ if (!Array.isArray(sharedPaths)) {
367
+ errors.push(`${prefix}.shared_paths must be a list`);
368
+ }
369
+ else {
370
+ errors.push(...validateIdList(`${prefix}.shared_paths`, sharedPaths));
371
+ sharedPaths.forEach((entry, index) => {
372
+ const entryPrefix = `${prefix}.shared_paths[${index}]`;
373
+ if (!isMapping(entry)) {
374
+ errors.push(`${entryPrefix} must be an object`);
375
+ return;
376
+ }
377
+ errors.push(...validateRequiredObjectFields(entryPrefix, entry, ["id", "path", "kind"]));
378
+ errors.push(...validateRepoPath(`${entryPrefix}.path`, entry.path, root));
379
+ if (entry.kind !== "dir" && entry.kind !== "file") {
380
+ errors.push(`${entryPrefix}.kind must be dir or file`);
381
+ }
382
+ });
383
+ }
384
+ if (typeof value.shared_paths_policy !== "string" || !value.shared_paths_policy) {
385
+ errors.push(`${prefix}.shared_paths_policy must be a non-empty string`);
386
+ }
387
+ return errors;
388
+ }
389
+ function validateBundleSurfaces(prefix, value, root) {
390
+ const errors = [];
391
+ for (const field of ["directories", "files"]) {
392
+ const entries = value[field];
393
+ if (!Array.isArray(entries)) {
394
+ errors.push(`${prefix}.${field} must be a list`);
395
+ continue;
396
+ }
397
+ errors.push(...validateIdList(`${prefix}.${field}`, entries));
398
+ entries.forEach((entry, index) => {
399
+ const entryPrefix = `${prefix}.${field}[${index}]`;
400
+ if (!isMapping(entry)) {
401
+ errors.push(`${entryPrefix} must be an object`);
402
+ return;
403
+ }
404
+ errors.push(...validateRequiredObjectFields(entryPrefix, entry, ["id", "path"]));
405
+ errors.push(...validateRepoPath(`${entryPrefix}.path`, entry.path, root));
406
+ });
407
+ }
408
+ for (const field of ["skip_parts", "skip_suffixes"]) {
409
+ if (!isStringList(value[field])) {
410
+ errors.push(`${prefix}.${field} must be a list of strings`);
411
+ }
412
+ }
413
+ return errors;
414
+ }
415
+ function validatePackageCommands(prefix, value) {
416
+ const errors = [];
417
+ const commands = value.commands;
418
+ if (!Array.isArray(commands)) {
419
+ errors.push(`${prefix}.commands must be a list`);
420
+ }
421
+ else {
422
+ errors.push(...validateIdList(`${prefix}.commands`, commands));
423
+ commands.forEach((command, index) => {
424
+ const commandPrefix = `${prefix}.commands[${index}]`;
425
+ if (!isMapping(command)) {
426
+ errors.push(`${commandPrefix} must be an object`);
427
+ return;
428
+ }
429
+ errors.push(...validateRequiredObjectFields(commandPrefix, command, [
430
+ "id",
431
+ "runtime",
432
+ "action",
433
+ "phase",
434
+ "argv",
435
+ "skipped_without_update_packages_message",
436
+ ]));
437
+ errors.push(...validateCommandSpec(commandPrefix, command));
438
+ });
439
+ }
440
+ const safety = value.safety;
441
+ const expectedSafety = {
442
+ argv_only: true,
443
+ update_packages_required_to_plan: true,
444
+ yes_required_to_execute: true,
445
+ preserve_existing_write_gates: true,
446
+ cleanup_phase: "cleanup",
447
+ runtime_install_phase: "runtime-install",
448
+ };
449
+ if (!isMapping(safety)) {
450
+ errors.push(`${prefix}.safety must be an object`);
451
+ }
452
+ else if (!shallowEqual(safety, expectedSafety)) {
453
+ errors.push(`${prefix}.safety must preserve approved write gates and phase names`);
454
+ }
455
+ return errors;
456
+ }
457
+ function validateDocsTargets(prefix, value, root) {
458
+ const errors = [];
459
+ if (typeof value.version_files_source !== "string" || !value.version_files_source) {
460
+ errors.push(`${prefix}.version_files_source must be a non-empty string`);
461
+ }
462
+ for (const field of ["version_files", "index_targets", "excluded_version_files"]) {
463
+ errors.push(...validatePathList(`${prefix}.${field}`, value[field], root));
464
+ }
465
+ return errors;
466
+ }
467
+ function validateReleasePolicy(prefix, value) {
468
+ const errors = [];
469
+ if (typeof value.semver_policy_source !== "string" || !value.semver_policy_source) {
470
+ errors.push(`${prefix}.semver_policy_source must be a non-empty string`);
471
+ }
472
+ for (const field of [
473
+ "version_bump_required_for_interface_only_change",
474
+ "release_publication_in_scope",
475
+ ]) {
476
+ if (typeof value[field] !== "boolean") {
477
+ errors.push(`${prefix}.${field} must be a boolean`);
478
+ }
479
+ }
480
+ return errors;
481
+ }
482
+ function validateCommandSpec(prefix, command) {
483
+ const errors = [];
484
+ const runtime = command.runtime;
485
+ const action = command.action;
486
+ const phase = command.phase;
487
+ const argv = command.argv;
488
+ if (!APPROVED_RUNTIMES.has(runtime)) {
489
+ errors.push(`${prefix}.runtime ${pyRepr(runtime)} is not approved`);
490
+ }
491
+ if (!APPROVED_ACTIONS.has(action)) {
492
+ errors.push(`${prefix}.action ${pyRepr(action)} is not approved`);
493
+ }
494
+ if (!Array.isArray(argv) || argv.length === 0 || !argv.every((part) => typeof part === "string")) {
495
+ errors.push(`${prefix}.argv must be a list of strings`);
496
+ return errors;
497
+ }
498
+ if (!APPROVED_EXECUTABLES.has(argv[0])) {
499
+ errors.push(`${prefix}.argv uses unapproved executable ${pyRepr(argv[0])}`);
500
+ }
501
+ if (argv.length < 3 || argv[1] !== "skills" || !["remove", "add"].includes(argv[2])) {
502
+ errors.push(`${prefix}.argv must use approved skills action`);
503
+ }
504
+ if (CLEANUP_ACTIONS.has(action) && (runtime !== "all" || phase !== "cleanup" || argv[2] !== "remove")) {
505
+ errors.push(`${prefix}: cleanup commands must stay separate from runtime installs`);
506
+ }
507
+ if (RUNTIME_INSTALL_ACTIONS.has(action)) {
508
+ if (runtime === "all" || phase !== "runtime-install" || argv[2] !== "add") {
509
+ errors.push(`${prefix}: runtime install commands must stay out of cleanup`);
510
+ }
511
+ if (!argv.includes("-a")) {
512
+ errors.push(`${prefix}: runtime install commands must declare runtime agent`);
513
+ }
514
+ else {
515
+ const agentIndex = argv.indexOf("-a") + 1;
516
+ const agent = agentIndex < argv.length ? argv[agentIndex] : null;
517
+ if (agent === null || !APPROVED_RUNTIME_AGENTS.has(agent)) {
518
+ errors.push(`${prefix}: runtime install agent ${pyRepr(agent)} is not approved`);
519
+ }
520
+ }
521
+ }
522
+ if (typeof command.skipped_without_update_packages_message !== "string") {
523
+ errors.push(`${prefix}.skipped_without_update_packages_message must be a string`);
524
+ }
525
+ return errors;
526
+ }
527
+ function validateRequiredObjectFields(prefix, value, expected) {
528
+ const errors = [];
529
+ for (const field of expected) {
530
+ if (!(field in value)) {
531
+ errors.push(`${prefix}: missing required field ${field}`);
532
+ }
533
+ }
534
+ for (const field of Object.keys(value)) {
535
+ if (!expected.includes(field)) {
536
+ errors.push(`${prefix}: unknown field ${field}`);
537
+ }
538
+ }
539
+ for (const field of ["id", "runtime", "action", "phase", "selector", "package_shape"]) {
540
+ if (field in value && (typeof value[field] !== "string" || !value[field])) {
541
+ errors.push(`${prefix}.${field} must be a non-empty string`);
542
+ }
543
+ }
544
+ return errors;
545
+ }
546
+ function validateIdList(prefix, entries) {
547
+ const errors = [];
548
+ const seen = new Set();
549
+ entries.forEach((entry, index) => {
550
+ if (!isMapping(entry)) {
551
+ return;
552
+ }
553
+ const entryId = entry.id;
554
+ if (typeof entryId !== "string" || !entryId) {
555
+ errors.push(`${prefix}[${index}].id must be a non-empty string`);
556
+ return;
557
+ }
558
+ if (seen.has(entryId)) {
559
+ errors.push(`${prefix}: duplicate id ${entryId}`);
560
+ }
561
+ seen.add(entryId);
562
+ });
563
+ return errors;
564
+ }
565
+ function validatePathList(prefix, value, root) {
566
+ if (!isStringList(value)) {
567
+ return [`${prefix} must be a list of repo-relative paths`];
568
+ }
569
+ const errors = [];
570
+ value.forEach((p, index) => {
571
+ errors.push(...validateRepoPath(`${prefix}[${index}]`, p, root));
572
+ });
573
+ return errors;
574
+ }
575
+ function validateRepoPath(prefix, value, root) {
576
+ if (typeof value !== "string" || !value) {
577
+ return [`${prefix} must be a repo-relative path`];
578
+ }
579
+ if (path.isAbsolute(value) || value.split(/[\\/]/).includes("..")) {
580
+ return [`${prefix} must stay inside repo root`];
581
+ }
582
+ const resolvedRoot = resolvePath(root);
583
+ const resolved = resolvePath(path.join(resolvedRoot, value));
584
+ const rel = path.relative(resolvedRoot, resolved);
585
+ if (rel !== "" && (rel.startsWith("..") || path.isAbsolute(rel))) {
586
+ return [`${prefix} must stay inside repo root`];
587
+ }
588
+ // Existence is advisory for a package DISTRIBUTION spec: surfaces such as
589
+ // version files, plugin manifests, and build outputs may be generated at
590
+ // build/release time or be runtime-specific, and need not be present in every
591
+ // checkout (e.g. a node-only tree without the Python build files). Structural
592
+ // and traversal safety above still apply.
593
+ return [];
594
+ }
595
+ function validateForbiddenFields(prefix, value) {
596
+ const errors = [];
597
+ for (const field of Object.keys(value).sort()) {
598
+ if (FORBIDDEN_INSTALL_ROOT_FIELDS.has(field)) {
599
+ errors.push(`${prefix}: forbidden install-root field ${field}`);
600
+ }
601
+ if (FORBIDDEN_RUNTIME_ADAPTER_FIELDS.has(field)) {
602
+ errors.push(`${prefix}: forbidden RuntimeAdapter field ${field}`);
603
+ }
604
+ const nested = value[field];
605
+ if (isMapping(nested)) {
606
+ errors.push(...validateForbiddenFields(`${prefix}.${field}`, nested));
607
+ }
608
+ else if (Array.isArray(nested)) {
609
+ nested.forEach((item, index) => {
610
+ if (isMapping(item)) {
611
+ errors.push(...validateForbiddenFields(`${prefix}.${field}[${index}]`, item));
612
+ }
613
+ });
614
+ }
615
+ }
616
+ return errors;
617
+ }
618
+ function shallowEqual(a, b) {
619
+ const ak = Object.keys(a);
620
+ const bk = Object.keys(b);
621
+ if (ak.length !== bk.length) {
622
+ return false;
623
+ }
624
+ for (const k of ak) {
625
+ if (a[k] !== b[k]) {
626
+ return false;
627
+ }
628
+ }
629
+ return true;
630
+ }
631
+ /** Mirror Python repr() for the scalar values used in validator messages. */
632
+ function pyRepr(value) {
633
+ if (value === null || value === undefined) {
634
+ return "None";
635
+ }
636
+ if (typeof value === "string") {
637
+ return `'${value}'`;
638
+ }
639
+ return String(value);
640
+ }
641
+ //# sourceMappingURL=packageRegistry.js.map