agentera 3.0.0-dev.2 → 3.0.0-dev.20

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 (612) hide show
  1. package/README.md +65 -6
  2. package/bundle/.agentera-npx-bundle.json +1 -1
  3. package/bundle/.codex-plugin/plugin.json +92 -0
  4. package/bundle/.cursor/agents/agentera.md +7 -0
  5. package/bundle/.cursor/hooks.json +32 -0
  6. package/bundle/.cursor-plugin/plugin.json +34 -0
  7. package/bundle/.github/hooks/postToolUse.json +9 -0
  8. package/bundle/.github/hooks/preToolUse.json +8 -0
  9. package/bundle/.github/hooks/sessionEnd.json +8 -0
  10. package/bundle/.github/hooks/sessionStart.json +8 -0
  11. package/bundle/.github/plugin/plugin.json +7 -0
  12. package/bundle/.opencode/agents/agentera.md +12 -0
  13. package/bundle/.opencode/commands/agentera.md +5 -0
  14. package/bundle/.opencode/package.json +31 -0
  15. package/bundle/.opencode/plugins/agentera.js +820 -0
  16. package/bundle/CHANGELOG.md +1108 -0
  17. package/bundle/DESIGN.md +233 -0
  18. package/bundle/LICENSE +201 -0
  19. package/bundle/README.md +141 -0
  20. package/bundle/UPGRADE.md +227 -0
  21. package/bundle/agents/openai.yaml +87 -0
  22. package/bundle/extract-corpus-parity.json +21 -0
  23. package/bundle/hooks/codex-hooks.json +31 -0
  24. package/bundle/hooks/codex-plugin-hooks.json +31 -0
  25. package/bundle/plugin.json +13 -0
  26. package/bundle/references/adapters/cursor.md +53 -42
  27. package/bundle/references/adapters/opencode.md +46 -47
  28. package/bundle/references/adapters/package-manifest-interface-model.yaml +32 -43
  29. package/bundle/references/adapters/package-registry.yaml +19 -53
  30. package/bundle/references/adapters/package-surface-characterization.md +61 -48
  31. package/bundle/references/adapters/runtime-adapter-characterization.md +44 -79
  32. package/bundle/references/adapters/runtime-adapter-registry.yaml +21 -182
  33. package/bundle/references/adapters/runtime-feature-parity.md +114 -174
  34. package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +288 -0
  35. package/bundle/references/adapters/runtime-lifecycle-authority.yaml +90 -0
  36. package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
  37. package/bundle/references/adapters/runtime-retired-resources.yaml +33 -0
  38. package/bundle/references/analysis/benchmark.md +6 -6
  39. package/bundle/references/analysis/startup-measurement-contract.yaml +37 -26
  40. package/bundle/references/artifacts/artifact-registry-interface-model.yaml +6 -5
  41. package/bundle/references/cli/agent-ready-state-contract.yaml +26 -23
  42. package/bundle/references/cli/app-lifecycle-vocabulary.yaml +4 -4
  43. package/bundle/references/cli/audience-namespace-cli-migration.yaml +40 -26
  44. package/bundle/references/cli/bundle-skill-vocabulary.yaml +4 -32
  45. package/bundle/references/cli/capability-instruction-contract.yaml +98 -57
  46. package/bundle/references/cli/capability-instruction-structure.md +144 -0
  47. package/bundle/references/cli/capability-tool-classification.yaml +12 -12
  48. package/bundle/references/cli/coexistence-probe.yaml +13 -0
  49. package/bundle/references/cli/parity-expected-actual-template.md +30 -0
  50. package/bundle/references/cli/routing-execution-vocabulary.yaml +12 -12
  51. package/bundle/references/cli/routing-model.md +94 -0
  52. package/bundle/references/cli/single-name-protocol.yaml +42 -0
  53. package/bundle/references/cli/trigger-schema-enrichment.md +136 -0
  54. package/bundle/references/cli/update-channels.yaml +43 -7
  55. package/bundle/references/cli/upgrade-repair-wording.md +45 -0
  56. package/bundle/references/cli/v3-handoff-manifest.schema.yaml +98 -0
  57. package/bundle/references/cli/vocabulary-index.yaml +20 -15
  58. package/bundle/references/cli/vocabulary.md +342 -326
  59. package/bundle/references/meta/documentation-inventory.md +9 -3
  60. package/bundle/registry.json +14 -14
  61. package/bundle/skills/agentera/SKILL.md +136 -408
  62. package/bundle/skills/agentera/agents/audit.toml +6 -0
  63. package/bundle/skills/agentera/agents/build.toml +6 -0
  64. package/bundle/skills/agentera/agents/design.toml +6 -0
  65. package/bundle/skills/agentera/agents/discuss.toml +6 -0
  66. package/bundle/skills/agentera/agents/document.toml +6 -0
  67. package/bundle/skills/agentera/agents/optimize.toml +6 -0
  68. package/bundle/skills/agentera/agents/orchestrate.toml +6 -0
  69. package/bundle/skills/agentera/agents/plan.toml +6 -0
  70. package/bundle/skills/agentera/agents/profile.toml +6 -0
  71. package/bundle/skills/agentera/agents/research.toml +6 -0
  72. package/bundle/skills/agentera/agents/status.toml +6 -0
  73. package/bundle/skills/agentera/agents/vision.toml +6 -0
  74. package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/artifacts.yaml +10 -10
  75. package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/exit.yaml +2 -2
  76. package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/triggers.yaml +15 -6
  77. package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/validation.yaml +13 -12
  78. package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/artifacts.yaml +12 -12
  79. package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +3 -3
  80. package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/triggers.yaml +13 -3
  81. package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/validation.yaml +11 -11
  82. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/artifacts.yaml +6 -6
  83. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/exit.yaml +5 -5
  84. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/triggers.yaml +15 -3
  85. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/validation.yaml +7 -7
  86. package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/artifacts.yaml +12 -11
  87. package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/exit.yaml +2 -2
  88. package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/triggers.yaml +11 -3
  89. package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/validation.yaml +9 -8
  90. package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/artifacts.yaml +10 -10
  91. package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/triggers.yaml +14 -4
  92. package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/validation.yaml +8 -8
  93. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/artifacts.yaml +9 -9
  94. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/exit.yaml +2 -2
  95. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/triggers.yaml +11 -3
  96. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/validation.yaml +9 -9
  97. package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/artifacts.yaml +12 -11
  98. package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/exit.yaml +7 -6
  99. package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/triggers.yaml +16 -3
  100. package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +120 -0
  101. package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +63 -0
  102. package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/exit.yaml +2 -2
  103. package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/triggers.yaml +15 -3
  104. package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +89 -0
  105. package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/artifacts.yaml +2 -2
  106. package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/exit.yaml +3 -3
  107. package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/triggers.yaml +7 -3
  108. package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/validation.yaml +2 -2
  109. package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +24 -0
  110. package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/triggers.yaml +9 -3
  111. package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/validation.yaml +2 -2
  112. package/bundle/skills/agentera/capabilities/{hej → status}/schemas/artifacts.yaml +14 -11
  113. package/bundle/skills/agentera/capabilities/{hej → status}/schemas/triggers.yaml +12 -8
  114. package/bundle/skills/agentera/capabilities/{hej → status}/schemas/validation.yaml +5 -5
  115. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/artifacts.yaml +8 -8
  116. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/exit.yaml +7 -6
  117. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/triggers.yaml +19 -5
  118. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/validation.yaml +18 -20
  119. package/bundle/skills/agentera/capability_schema_contract.yaml +201 -38
  120. package/bundle/skills/agentera/protocol.yaml +29 -29
  121. package/bundle/skills/agentera/references/contract.md +338 -322
  122. package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +4 -4
  123. package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +10 -10
  124. package/bundle/skills/agentera/schemas/artifacts/design.yaml +4 -4
  125. package/bundle/skills/agentera/schemas/artifacts/docs.yaml +8 -7
  126. package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +5 -5
  127. package/bundle/skills/agentera/schemas/artifacts/health.yaml +5 -5
  128. package/bundle/skills/agentera/schemas/artifacts/objective.yaml +4 -4
  129. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +263 -11
  130. package/bundle/skills/agentera/schemas/artifacts/progress.yaml +20 -41
  131. package/bundle/skills/agentera/schemas/artifacts/todo.yaml +43 -24
  132. package/bundle/skills/agentera/schemas/artifacts/vision.yaml +3 -3
  133. package/dist/analytics/extractCorpus/cli.js +163 -0
  134. package/dist/analytics/extractCorpus/cli.js.map +1 -0
  135. package/dist/analytics/extractCorpus/copilotSessions.js +276 -0
  136. package/dist/analytics/extractCorpus/copilotSessions.js.map +1 -0
  137. package/dist/analytics/extractCorpus/core.js +393 -0
  138. package/dist/analytics/extractCorpus/core.js.map +1 -0
  139. package/dist/analytics/extractCorpus/corpus.js +168 -0
  140. package/dist/analytics/extractCorpus/corpus.js.map +1 -0
  141. package/dist/analytics/extractCorpus/coverageAudit.js +261 -0
  142. package/dist/analytics/extractCorpus/coverageAudit.js.map +1 -0
  143. package/dist/analytics/extractCorpus/cursorSessions.js +426 -0
  144. package/dist/analytics/extractCorpus/cursorSessions.js.map +1 -0
  145. package/dist/analytics/extractCorpus/extractCorpusParity.js +105 -0
  146. package/dist/analytics/extractCorpus/extractCorpusParity.js.map +1 -0
  147. package/dist/analytics/extractCorpus/filesystemSources.js +119 -0
  148. package/dist/analytics/extractCorpus/filesystemSources.js.map +1 -0
  149. package/dist/analytics/extractCorpus/index.js +12 -0
  150. package/dist/analytics/extractCorpus/index.js.map +1 -0
  151. package/dist/analytics/extractCorpus/jsonlSessions.js +205 -0
  152. package/dist/analytics/extractCorpus/jsonlSessions.js.map +1 -0
  153. package/dist/analytics/extractCorpus/sqliteCaps.js +44 -0
  154. package/dist/analytics/extractCorpus/sqliteCaps.js.map +1 -0
  155. package/dist/analytics/extractCorpus/sqliteSessions.js +368 -0
  156. package/dist/analytics/extractCorpus/sqliteSessions.js.map +1 -0
  157. package/dist/analytics/extractCorpus.js +2 -1790
  158. package/dist/analytics/extractCorpus.js.map +1 -1
  159. package/dist/analytics/usageStats.js +93 -27
  160. package/dist/analytics/usageStats.js.map +1 -1
  161. package/dist/bin/agentera.js +3 -1
  162. package/dist/bin/agentera.js.map +1 -1
  163. package/dist/capabilities/audit/instructions.js +4 -0
  164. package/dist/capabilities/audit/instructions.js.map +1 -0
  165. package/dist/capabilities/build/instructions.js +5 -0
  166. package/dist/capabilities/build/instructions.js.map +1 -0
  167. package/dist/capabilities/design/instructions.js +5 -0
  168. package/dist/capabilities/design/instructions.js.map +1 -0
  169. package/dist/capabilities/discuss/instructions.js +6 -0
  170. package/dist/capabilities/discuss/instructions.js.map +1 -0
  171. package/dist/capabilities/document/instructions.js +4 -0
  172. package/dist/capabilities/document/instructions.js.map +1 -0
  173. package/dist/capabilities/index.js +38 -0
  174. package/dist/capabilities/index.js.map +1 -0
  175. package/dist/capabilities/optimize/instructions.js +5 -0
  176. package/dist/capabilities/optimize/instructions.js.map +1 -0
  177. package/dist/capabilities/orchestrate/instructions.js +10 -0
  178. package/dist/capabilities/orchestrate/instructions.js.map +1 -0
  179. package/dist/capabilities/plan/instructions.js +6 -0
  180. package/dist/capabilities/plan/instructions.js.map +1 -0
  181. package/dist/capabilities/profile/instructions.js +5 -0
  182. package/dist/capabilities/profile/instructions.js.map +1 -0
  183. package/dist/capabilities/research/instructions.js +6 -0
  184. package/dist/capabilities/research/instructions.js.map +1 -0
  185. package/dist/capabilities/status/instructions.js +5 -0
  186. package/dist/capabilities/status/instructions.js.map +1 -0
  187. package/dist/capabilities/vision/instructions.js +5 -0
  188. package/dist/capabilities/vision/instructions.js.map +1 -0
  189. package/dist/cli/appContext.js +16 -17
  190. package/dist/cli/appContext.js.map +1 -1
  191. package/dist/cli/capabilityContext/benchmark.js +564 -0
  192. package/dist/cli/capabilityContext/benchmark.js.map +1 -0
  193. package/dist/cli/capabilityContext/bespoke.js +36 -0
  194. package/dist/cli/capabilityContext/bespoke.js.map +1 -0
  195. package/dist/cli/capabilityContext/build.js +190 -0
  196. package/dist/cli/capabilityContext/build.js.map +1 -0
  197. package/dist/cli/capabilityContext/closeout.js +230 -0
  198. package/dist/cli/capabilityContext/closeout.js.map +1 -0
  199. package/dist/cli/capabilityContext/contract.js +190 -0
  200. package/dist/cli/capabilityContext/contract.js.map +1 -0
  201. package/dist/cli/capabilityContext/evidence.js +456 -0
  202. package/dist/cli/capabilityContext/evidence.js.map +1 -0
  203. package/dist/cli/capabilityContext/index.js +4 -0
  204. package/dist/cli/capabilityContext/index.js.map +1 -0
  205. package/dist/cli/capabilityContext/orchestration.js +117 -0
  206. package/dist/cli/capabilityContext/orchestration.js.map +1 -0
  207. package/dist/cli/capabilityContext/planState.js +279 -0
  208. package/dist/cli/capabilityContext/planState.js.map +1 -0
  209. package/dist/cli/capabilityContext/progress.js +138 -0
  210. package/dist/cli/capabilityContext/progress.js.map +1 -0
  211. package/dist/cli/capabilityContext/shared.js +94 -0
  212. package/dist/cli/capabilityContext/shared.js.map +1 -0
  213. package/dist/cli/capabilityContext/slim.js +108 -0
  214. package/dist/cli/capabilityContext/slim.js.map +1 -0
  215. package/dist/cli/capabilityContext/startup.js +217 -0
  216. package/dist/cli/capabilityContext/startup.js.map +1 -0
  217. package/dist/cli/capabilityContext/types.js +41 -0
  218. package/dist/cli/capabilityContext/types.js.map +1 -0
  219. package/dist/cli/capabilityContext.js +1 -2420
  220. package/dist/cli/capabilityContext.js.map +1 -1
  221. package/dist/cli/commands/appHome.js +23 -0
  222. package/dist/cli/commands/appHome.js.map +1 -0
  223. package/dist/cli/commands/capability.js +3 -10
  224. package/dist/cli/commands/capability.js.map +1 -1
  225. package/dist/cli/commands/compact.js +1 -1
  226. package/dist/cli/commands/compact.js.map +1 -1
  227. package/dist/cli/commands/doctor.js +116 -96
  228. package/dist/cli/commands/doctor.js.map +1 -1
  229. package/dist/cli/commands/lint.js +16 -41
  230. package/dist/cli/commands/lint.js.map +1 -1
  231. package/dist/cli/commands/prime/bundleStatus.js +185 -0
  232. package/dist/cli/commands/prime/bundleStatus.js.map +1 -0
  233. package/dist/cli/commands/prime/collectOrientationState.js +179 -0
  234. package/dist/cli/commands/prime/collectOrientationState.js.map +1 -0
  235. package/dist/cli/commands/prime/orientationOutput.js +233 -0
  236. package/dist/cli/commands/prime/orientationOutput.js.map +1 -0
  237. package/dist/cli/commands/prime/types.js +2 -0
  238. package/dist/cli/commands/prime/types.js.map +1 -0
  239. package/dist/cli/commands/prime/v1Migration.js +39 -0
  240. package/dist/cli/commands/prime/v1Migration.js.map +1 -0
  241. package/dist/cli/commands/prime.js +11 -519
  242. package/dist/cli/commands/prime.js.map +1 -1
  243. package/dist/cli/commands/query.js +5 -2
  244. package/dist/cli/commands/query.js.map +1 -1
  245. package/dist/cli/commands/report.js +50 -14
  246. package/dist/cli/commands/report.js.map +1 -1
  247. package/dist/cli/commands/schema.js +113 -24
  248. package/dist/cli/commands/schema.js.map +1 -1
  249. package/dist/cli/commands/state/decisions.js +403 -0
  250. package/dist/cli/commands/state/decisions.js.map +1 -0
  251. package/dist/cli/commands/state/docs.js +97 -0
  252. package/dist/cli/commands/state/docs.js.map +1 -0
  253. package/dist/cli/commands/state/experiments.js +68 -0
  254. package/dist/cli/commands/state/experiments.js.map +1 -0
  255. package/dist/cli/commands/state/health.js +116 -0
  256. package/dist/cli/commands/state/health.js.map +1 -0
  257. package/dist/cli/commands/state/index.js +51 -0
  258. package/dist/cli/commands/state/index.js.map +1 -0
  259. package/dist/cli/commands/state/objective.js +69 -0
  260. package/dist/cli/commands/state/objective.js.map +1 -0
  261. package/dist/cli/commands/state/plan.js +274 -0
  262. package/dist/cli/commands/state/plan.js.map +1 -0
  263. package/dist/cli/commands/state/progress.js +47 -0
  264. package/dist/cli/commands/state/progress.js.map +1 -0
  265. package/dist/cli/commands/state/shared.js +15 -0
  266. package/dist/cli/commands/state/shared.js.map +1 -0
  267. package/dist/cli/commands/state/todo.js +121 -0
  268. package/dist/cli/commands/state/todo.js.map +1 -0
  269. package/dist/cli/commands/state/write.js +341 -0
  270. package/dist/cli/commands/state/write.js.map +1 -0
  271. package/dist/cli/commands/upgrade.js +79 -1
  272. package/dist/cli/commands/upgrade.js.map +1 -1
  273. package/dist/cli/commands/upgradeVerify.js +81 -0
  274. package/dist/cli/commands/upgradeVerify.js.map +1 -0
  275. package/dist/cli/commands/validate.js +56 -96
  276. package/dist/cli/commands/validate.js.map +1 -1
  277. package/dist/cli/commands/verify.js +13 -7
  278. package/dist/cli/commands/verify.js.map +1 -1
  279. package/dist/cli/contracts/bundleStatus.js +2 -0
  280. package/dist/cli/contracts/bundleStatus.js.map +1 -0
  281. package/dist/cli/contracts/orientationState.js +2 -0
  282. package/dist/cli/contracts/orientationState.js.map +1 -0
  283. package/dist/cli/dispatch/argvParser.js +33 -0
  284. package/dist/cli/dispatch/argvParser.js.map +1 -0
  285. package/dist/cli/dispatch/check.js +328 -0
  286. package/dist/cli/dispatch/check.js.map +1 -0
  287. package/dist/cli/dispatch/commands.js +27 -0
  288. package/dist/cli/dispatch/commands.js.map +1 -0
  289. package/dist/cli/dispatch/index.js +183 -0
  290. package/dist/cli/dispatch/index.js.map +1 -0
  291. package/dist/cli/dispatch/lifecycle.js +671 -0
  292. package/dist/cli/dispatch/lifecycle.js.map +1 -0
  293. package/dist/cli/dispatch/prime.js +104 -0
  294. package/dist/cli/dispatch/prime.js.map +1 -0
  295. package/dist/cli/dispatch/shared.js +64 -0
  296. package/dist/cli/dispatch/shared.js.map +1 -0
  297. package/dist/cli/dispatch/state.js +148 -0
  298. package/dist/cli/dispatch/state.js.map +1 -0
  299. package/dist/cli/dispatch.js +1 -957
  300. package/dist/cli/dispatch.js.map +1 -1
  301. package/dist/cli/errors.js +54 -0
  302. package/dist/cli/errors.js.map +1 -0
  303. package/dist/cli/help.js +262 -0
  304. package/dist/cli/help.js.map +1 -0
  305. package/dist/cli/orientation/attention.js +163 -0
  306. package/dist/cli/orientation/attention.js.map +1 -0
  307. package/dist/cli/orientation/corpusCoverage.js +71 -0
  308. package/dist/cli/orientation/corpusCoverage.js.map +1 -0
  309. package/dist/cli/orientation.js +194 -114
  310. package/dist/cli/orientation.js.map +1 -1
  311. package/dist/cli/planArtifacts.js +172 -0
  312. package/dist/cli/planArtifacts.js.map +1 -0
  313. package/dist/cli/planEvidence.js +158 -0
  314. package/dist/cli/planEvidence.js.map +1 -0
  315. package/dist/cli/planLifecycleState.js +34 -0
  316. package/dist/cli/planLifecycleState.js.map +1 -0
  317. package/dist/cli/prime-blob.js +68 -2
  318. package/dist/cli/prime-blob.js.map +1 -1
  319. package/dist/cli/startupCompletenessContract.js +56 -0
  320. package/dist/cli/startupCompletenessContract.js.map +1 -0
  321. package/dist/cli/stateQuery.js +17 -2
  322. package/dist/cli/stateQuery.js.map +1 -1
  323. package/dist/cli/todoMarkdown.js +33 -0
  324. package/dist/cli/todoMarkdown.js.map +1 -0
  325. package/dist/cli/todoSeverity.js +19 -0
  326. package/dist/cli/todoSeverity.js.map +1 -0
  327. package/dist/core/atomicWriter.js +21 -0
  328. package/dist/core/atomicWriter.js.map +1 -0
  329. package/dist/core/envPaths.js +21 -0
  330. package/dist/core/envPaths.js.map +1 -0
  331. package/dist/core/jsonValue.js +6 -0
  332. package/dist/core/jsonValue.js.map +1 -0
  333. package/dist/core/pyjson.js +67 -2
  334. package/dist/core/pyjson.js.map +1 -1
  335. package/dist/core/yaml.js +8 -0
  336. package/dist/core/yaml.js.map +1 -1
  337. package/dist/eval/evalSkills.js +30 -25
  338. package/dist/eval/evalSkills.js.map +1 -1
  339. package/dist/eval/semanticEval.js +43 -19
  340. package/dist/eval/semanticEval.js.map +1 -1
  341. package/dist/eval/semanticFixtures.js +16 -4
  342. package/dist/eval/semanticFixtures.js.map +1 -1
  343. package/dist/hooks/common.js +9 -26
  344. package/dist/hooks/common.js.map +1 -1
  345. package/dist/hooks/compaction/apply.js +269 -0
  346. package/dist/hooks/compaction/apply.js.map +1 -0
  347. package/dist/hooks/compaction/dryRun.js +183 -0
  348. package/dist/hooks/compaction/dryRun.js.map +1 -0
  349. package/dist/hooks/compaction/index.js +23 -0
  350. package/dist/hooks/compaction/index.js.map +1 -0
  351. package/dist/hooks/compaction/parse.js +258 -0
  352. package/dist/hooks/compaction/parse.js.map +1 -0
  353. package/dist/hooks/compaction/retention.js +202 -0
  354. package/dist/hooks/compaction/retention.js.map +1 -0
  355. package/dist/hooks/compaction/status.js +243 -0
  356. package/dist/hooks/compaction/status.js.map +1 -0
  357. package/dist/hooks/compaction/types.js +6 -0
  358. package/dist/hooks/compaction/types.js.map +1 -0
  359. package/dist/hooks/cursorPreToolUse.js +1 -1
  360. package/dist/hooks/cursorPreToolUse.js.map +1 -1
  361. package/dist/hooks/cursorSessionStart.js +10 -2
  362. package/dist/hooks/cursorSessionStart.js.map +1 -1
  363. package/dist/hooks/sessionStart.js +18 -11
  364. package/dist/hooks/sessionStart.js.map +1 -1
  365. package/dist/hooks/sessionStop.js +8 -14
  366. package/dist/hooks/sessionStop.js.map +1 -1
  367. package/dist/hooks/validateArtifact/agentFacing.js +10 -0
  368. package/dist/hooks/validateArtifact/agentFacing.js.map +1 -0
  369. package/dist/hooks/validateArtifact/index.js +151 -0
  370. package/dist/hooks/validateArtifact/index.js.map +1 -0
  371. package/dist/hooks/validateArtifact/markdown.js +146 -0
  372. package/dist/hooks/validateArtifact/markdown.js.map +1 -0
  373. package/dist/hooks/validateArtifact/runtime.js +86 -0
  374. package/dist/hooks/validateArtifact/runtime.js.map +1 -0
  375. package/dist/hooks/validateArtifact/schema.js +541 -0
  376. package/dist/hooks/validateArtifact/schema.js.map +1 -0
  377. package/dist/hooks/validateArtifact/traversal.js +106 -0
  378. package/dist/hooks/validateArtifact/traversal.js.map +1 -0
  379. package/dist/hooks/validateArtifact/violations.js +108 -0
  380. package/dist/hooks/validateArtifact/violations.js.map +1 -0
  381. package/dist/migrate/v2HandoffManifest.js +455 -0
  382. package/dist/migrate/v2HandoffManifest.js.map +1 -0
  383. package/dist/registries/artifactProtocolIds.js +77 -0
  384. package/dist/registries/artifactProtocolIds.js.map +1 -0
  385. package/dist/registries/artifactRegistry.js +62 -15
  386. package/dist/registries/artifactRegistry.js.map +1 -1
  387. package/dist/registries/capabilityContract.js +156 -12
  388. package/dist/registries/capabilityContract.js.map +1 -1
  389. package/dist/registries/evaluatorHandoffContract.js +171 -0
  390. package/dist/registries/evaluatorHandoffContract.js.map +1 -0
  391. package/dist/registries/packageRegistry.js +40 -6
  392. package/dist/registries/packageRegistry.js.map +1 -1
  393. package/dist/registries/runtimeAdapterRegistry.js +30 -21
  394. package/dist/registries/runtimeAdapterRegistry.js.map +1 -1
  395. package/dist/registries/triggerLoader.js +211 -0
  396. package/dist/registries/triggerLoader.js.map +1 -0
  397. package/dist/release/releaseMetadata.js +235 -0
  398. package/dist/release/releaseMetadata.js.map +1 -0
  399. package/dist/runtime/lifecycleAdapterContract.js +458 -0
  400. package/dist/runtime/lifecycleAdapterContract.js.map +1 -0
  401. package/dist/runtime/lifecycleAdapters.js +766 -0
  402. package/dist/runtime/lifecycleAdapters.js.map +1 -0
  403. package/dist/runtime/lifecycleAuthority.js +493 -0
  404. package/dist/runtime/lifecycleAuthority.js.map +1 -0
  405. package/dist/runtime/lifecycleOperationContract.js +113 -0
  406. package/dist/runtime/lifecycleOperationContract.js.map +1 -0
  407. package/dist/runtime/lifecycleOperations.js +635 -0
  408. package/dist/runtime/lifecycleOperations.js.map +1 -0
  409. package/dist/runtime/lifecycleOwnershipJournal.js +623 -0
  410. package/dist/runtime/lifecycleOwnershipJournal.js.map +1 -0
  411. package/dist/runtime/lifecyclePublication.js +395 -0
  412. package/dist/runtime/lifecyclePublication.js.map +1 -0
  413. package/dist/runtime/lifecycleSnapshot.js +439 -0
  414. package/dist/runtime/lifecycleSnapshot.js.map +1 -0
  415. package/dist/runtime/retiredRuntimeCleanup.js +238 -0
  416. package/dist/runtime/retiredRuntimeCleanup.js.map +1 -0
  417. package/dist/setup/codex/agents.js +96 -0
  418. package/dist/setup/codex/agents.js.map +1 -0
  419. package/dist/setup/codex/cli.js +161 -0
  420. package/dist/setup/codex/cli.js.map +1 -0
  421. package/dist/setup/codex/configToml.js +639 -0
  422. package/dist/setup/codex/configToml.js.map +1 -0
  423. package/dist/setup/codex/constants.js +29 -0
  424. package/dist/setup/codex/constants.js.map +1 -0
  425. package/dist/setup/codex/installRoot.js +64 -0
  426. package/dist/setup/codex/installRoot.js.map +1 -0
  427. package/dist/setup/codex/state.js +270 -0
  428. package/dist/setup/codex/state.js.map +1 -0
  429. package/dist/setup/codex.js +11 -1055
  430. package/dist/setup/codex.js.map +1 -1
  431. package/dist/setup/copilot.js +1 -1
  432. package/dist/setup/copilot.js.map +1 -1
  433. package/dist/setup/cursor.js +7 -5
  434. package/dist/setup/cursor.js.map +1 -1
  435. package/dist/setup/cursorSurfaces.js +67 -0
  436. package/dist/setup/cursorSurfaces.js.map +1 -0
  437. package/dist/setup/doctor/core.js +296 -0
  438. package/dist/setup/doctor/core.js.map +1 -0
  439. package/dist/setup/doctor/diagnostics.js +201 -0
  440. package/dist/setup/doctor/diagnostics.js.map +1 -0
  441. package/dist/setup/doctor/opencode.js +301 -0
  442. package/dist/setup/doctor/opencode.js.map +1 -0
  443. package/dist/setup/doctor/report.js +425 -0
  444. package/dist/setup/doctor/report.js.map +1 -0
  445. package/dist/setup/doctor.js +9 -1275
  446. package/dist/setup/doctor.js.map +1 -1
  447. package/dist/setup/opencode.js +13 -0
  448. package/dist/setup/opencode.js.map +1 -0
  449. package/dist/setup/opencodeConstants.js +2 -0
  450. package/dist/setup/opencodeConstants.js.map +1 -0
  451. package/dist/setup/smokeChecks.js +109 -0
  452. package/dist/setup/smokeChecks.js.map +1 -0
  453. package/dist/state/installRoot.js +64 -24
  454. package/dist/state/installRoot.js.map +1 -1
  455. package/dist/state/startupAnalysis/benchmark.js +371 -0
  456. package/dist/state/startupAnalysis/benchmark.js.map +1 -0
  457. package/dist/state/startupAnalysis/contract.js +126 -0
  458. package/dist/state/startupAnalysis/contract.js.map +1 -0
  459. package/dist/state/startupAnalysis/helpers.js +287 -0
  460. package/dist/state/startupAnalysis/helpers.js.map +1 -0
  461. package/dist/state/startupAnalysis/index.js +7 -0
  462. package/dist/state/startupAnalysis/index.js.map +1 -0
  463. package/dist/state/startupAnalysis/metrics.js +341 -0
  464. package/dist/state/startupAnalysis/metrics.js.map +1 -0
  465. package/dist/state/startupAnalysis/records.js +199 -0
  466. package/dist/state/startupAnalysis/records.js.map +1 -0
  467. package/dist/state/startupAnalysis/report.js +112 -0
  468. package/dist/state/startupAnalysis/report.js.map +1 -0
  469. package/dist/state/startupAnalysis/threshold.js +500 -0
  470. package/dist/state/startupAnalysis/threshold.js.map +1 -0
  471. package/dist/state/startupAnalysis.js +2 -1952
  472. package/dist/state/startupAnalysis.js.map +1 -1
  473. package/dist/state/write/assign.js +21 -0
  474. package/dist/state/write/assign.js.map +1 -0
  475. package/dist/state/write/errors.js +12 -0
  476. package/dist/state/write/errors.js.map +1 -0
  477. package/dist/state/write/explain.js +155 -0
  478. package/dist/state/write/explain.js.map +1 -0
  479. package/dist/state/write/fields.js +62 -0
  480. package/dist/state/write/fields.js.map +1 -0
  481. package/dist/state/write/index.js +11 -0
  482. package/dist/state/write/index.js.map +1 -0
  483. package/dist/state/write/input.js +22 -0
  484. package/dist/state/write/input.js.map +1 -0
  485. package/dist/state/write/lock.js +108 -0
  486. package/dist/state/write/lock.js.map +1 -0
  487. package/dist/state/write/operations.js +220 -0
  488. package/dist/state/write/operations.js.map +1 -0
  489. package/dist/state/write/serialize.js +2 -0
  490. package/dist/state/write/serialize.js.map +1 -0
  491. package/dist/state/write/transaction.js +787 -0
  492. package/dist/state/write/transaction.js.map +1 -0
  493. package/dist/state/write/validate.js +8 -0
  494. package/dist/state/write/validate.js.map +1 -0
  495. package/dist/upgrade/appContentRefresh.js +374 -0
  496. package/dist/upgrade/appContentRefresh.js.map +1 -0
  497. package/dist/upgrade/appModel.js +11 -6
  498. package/dist/upgrade/appModel.js.map +1 -1
  499. package/dist/upgrade/atomicWriter.js +2 -0
  500. package/dist/upgrade/atomicWriter.js.map +1 -0
  501. package/dist/upgrade/bundleEvidence.js +34 -0
  502. package/dist/upgrade/bundleEvidence.js.map +1 -0
  503. package/dist/upgrade/channels.js +27 -7
  504. package/dist/upgrade/channels.js.map +1 -1
  505. package/dist/upgrade/coexistenceProbe.js +105 -0
  506. package/dist/upgrade/coexistenceProbe.js.map +1 -0
  507. package/dist/upgrade/compatibility.js +52 -16
  508. package/dist/upgrade/compatibility.js.map +1 -1
  509. package/dist/upgrade/doctor.js +195 -193
  510. package/dist/upgrade/doctor.js.map +1 -1
  511. package/dist/upgrade/doctorClassifier.js +188 -0
  512. package/dist/upgrade/doctorClassifier.js.map +1 -0
  513. package/dist/upgrade/installedHooksRetirement.js +190 -0
  514. package/dist/upgrade/installedHooksRetirement.js.map +1 -0
  515. package/dist/upgrade/legacyAgentCleanup.js +183 -0
  516. package/dist/upgrade/legacyAgentCleanup.js.map +1 -0
  517. package/dist/upgrade/lifecycleUpgrade.js +427 -0
  518. package/dist/upgrade/lifecycleUpgrade.js.map +1 -0
  519. package/dist/upgrade/migrateArtifactsV1ToV2.js +568 -0
  520. package/dist/upgrade/migrateArtifactsV1ToV2.js.map +1 -0
  521. package/dist/upgrade/migrateArtifactsV2ToV3.js +273 -144
  522. package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -1
  523. package/dist/upgrade/nextMajorDoctor.js +156 -0
  524. package/dist/upgrade/nextMajorDoctor.js.map +1 -0
  525. package/dist/upgrade/npxPlatformStatus.js +23 -0
  526. package/dist/upgrade/npxPlatformStatus.js.map +1 -0
  527. package/dist/upgrade/projectIntegration.js +259 -104
  528. package/dist/upgrade/projectIntegration.js.map +1 -1
  529. package/dist/upgrade/projectIntegrationDecision.js +141 -0
  530. package/dist/upgrade/projectIntegrationDecision.js.map +1 -0
  531. package/dist/upgrade/runtimeMigration.js +342 -89
  532. package/dist/upgrade/runtimeMigration.js.map +1 -1
  533. package/dist/upgrade/upgradeCommands.js +8 -0
  534. package/dist/upgrade/upgradeCommands.js.map +1 -1
  535. package/dist/upgrade/upgradeLock.js +54 -0
  536. package/dist/upgrade/upgradeLock.js.map +1 -0
  537. package/dist/upgrade/upgradeOrchestrator.js +170 -46
  538. package/dist/upgrade/upgradeOrchestrator.js.map +1 -1
  539. package/dist/upgrade/upgradeSnapshot.js +93 -0
  540. package/dist/upgrade/upgradeSnapshot.js.map +1 -0
  541. package/dist/upgrade/v3CapabilitySurface.js +15 -0
  542. package/dist/upgrade/v3CapabilitySurface.js.map +1 -0
  543. package/dist/upgrade/versionResolution.js +12 -4
  544. package/dist/upgrade/versionResolution.js.map +1 -1
  545. package/dist/validate/appHomeContract.js +5 -5
  546. package/dist/validate/appHomeContract.js.map +1 -1
  547. package/dist/validate/capability.js +135 -14
  548. package/dist/validate/capability.js.map +1 -1
  549. package/dist/validate/crossCapability.js +1 -1
  550. package/dist/validate/crossCapability.js.map +1 -1
  551. package/dist/validate/lifecycleAdapters/legacyPythonParity.js +93 -0
  552. package/dist/validate/lifecycleAdapters/legacyPythonParity.js.map +1 -0
  553. package/dist/validate/lifecycleAdapters/nodeFormChecks.js +481 -0
  554. package/dist/validate/lifecycleAdapters/nodeFormChecks.js.map +1 -0
  555. package/dist/validate/lifecycleAdapters/shared.js +198 -0
  556. package/dist/validate/lifecycleAdapters/shared.js.map +1 -0
  557. package/dist/validate/lifecycleAdapters.js +91 -702
  558. package/dist/validate/lifecycleAdapters.js.map +1 -1
  559. package/dist/validate/selfAudit.js +63 -21
  560. package/dist/validate/selfAudit.js.map +1 -1
  561. package/dist/validate/vocabularyAuthority.js +303 -0
  562. package/dist/validate/vocabularyAuthority.js.map +1 -0
  563. package/package.json +30 -27
  564. package/bundle/references/v1-section-mapping.md +0 -47
  565. package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
  566. package/bundle/skills/agentera/agents/dokumentera.toml +0 -6
  567. package/bundle/skills/agentera/agents/hej.toml +0 -6
  568. package/bundle/skills/agentera/agents/inspektera.toml +0 -6
  569. package/bundle/skills/agentera/agents/inspirera.toml +0 -6
  570. package/bundle/skills/agentera/agents/optimera.toml +0 -6
  571. package/bundle/skills/agentera/agents/orkestrera.toml +0 -6
  572. package/bundle/skills/agentera/agents/planera.toml +0 -6
  573. package/bundle/skills/agentera/agents/profilera.toml +0 -6
  574. package/bundle/skills/agentera/agents/realisera.toml +0 -6
  575. package/bundle/skills/agentera/agents/resonera.toml +0 -6
  576. package/bundle/skills/agentera/agents/visionera.toml +0 -6
  577. package/bundle/skills/agentera/agents/visualisera.toml +0 -6
  578. package/bundle/skills/agentera/capabilities/dokumentera/instructions.md +0 -428
  579. package/bundle/skills/agentera/capabilities/hej/instructions.md +0 -331
  580. package/bundle/skills/agentera/capabilities/inspektera/instructions.md +0 -514
  581. package/bundle/skills/agentera/capabilities/inspirera/instructions.md +0 -280
  582. package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +0 -24
  583. package/bundle/skills/agentera/capabilities/optimera/instructions.md +0 -437
  584. package/bundle/skills/agentera/capabilities/orkestrera/instructions.md +0 -433
  585. package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +0 -107
  586. package/bundle/skills/agentera/capabilities/planera/instructions.md +0 -368
  587. package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +0 -62
  588. package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +0 -61
  589. package/bundle/skills/agentera/capabilities/profilera/instructions.md +0 -419
  590. package/bundle/skills/agentera/capabilities/realisera/instructions.md +0 -403
  591. package/bundle/skills/agentera/capabilities/resonera/instructions.md +0 -329
  592. package/bundle/skills/agentera/capabilities/visionera/instructions.md +0 -309
  593. package/bundle/skills/agentera/capabilities/visualisera/instructions.md +0 -400
  594. package/bundle/skills/hej/.claude-plugin/plugin.json +0 -6
  595. package/bundle/skills/hej/SKILL.md +0 -69
  596. package/bundle/skills/hej/agents/hej.toml +0 -11
  597. package/bundle/skills/hej/agents/openai.yaml +0 -8
  598. package/dist/cli/commands/backfill.js +0 -84
  599. package/dist/cli/commands/backfill.js.map +0 -1
  600. package/dist/cli/commands/state.js +0 -1012
  601. package/dist/cli/commands/state.js.map +0 -1
  602. package/dist/core/git.js +0 -43
  603. package/dist/core/git.js.map +0 -1
  604. package/dist/hooks/compaction.js +0 -935
  605. package/dist/hooks/compaction.js.map +0 -1
  606. package/dist/hooks/validateArtifact.js +0 -933
  607. package/dist/hooks/validateArtifact.js.map +0 -1
  608. package/dist/state/progressCommit.js +0 -289
  609. package/dist/state/progressCommit.js.map +0 -1
  610. /package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/exit.yaml +0 -0
  611. /package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/exit.yaml +0 -0
  612. /package/bundle/skills/agentera/capabilities/{hej → status}/schemas/exit.yaml +0 -0
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Path resolution and artifact identification.
3
+ *
4
+ * Given an arbitrary `cwd` and a candidate write path, decide which
5
+ * (if any) protocol-tracked artifact the write targets, applying
6
+ * `.agentera/docs.yaml` path overrides when present.
7
+ */
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+ import { resolvePath } from "../../core/paths.js";
11
+ import { loadYamlMapping } from "../../core/yaml.js";
12
+ import { ARTIFACT_PROTOCOL_PATHS, HUMAN_FACING_ARTIFACT_IDS, normalizeArtifactProtocolId, } from "../../registries/artifactProtocolIds.js";
13
+ import { DEFAULT_ARTIFACT_PATHS } from "../common.js";
14
+ import { COMPACTABLE_YAML_ARTIFACTS, compactFile, compactYamlFile } from "../compaction/index.js";
15
+ import { isMapping } from "./schema.js";
16
+ const AGENT_YAML_RE = /\.agentera\/([a-z_]+)\.yaml$/;
17
+ function resolvePathRel(fp, cwd) {
18
+ return path.isAbsolute(fp) ? fp : path.join(cwd, fp);
19
+ }
20
+ function docsPathOverrides(cwd) {
21
+ const docsPath = path.join(cwd, ".agentera", "docs.yaml");
22
+ if (!fs.existsSync(docsPath) || !fs.statSync(docsPath).isFile())
23
+ return {};
24
+ let data;
25
+ try {
26
+ // cast: docs.yaml path-override mapping parsed from a YAML file
27
+ data = loadYamlMapping(fs.readFileSync(docsPath, "utf8"));
28
+ }
29
+ catch (exc) {
30
+ process.stderr.write(`warning: failed to load docs path overrides: ${exc.message}\n`);
31
+ return {};
32
+ }
33
+ const mapping = data.mapping;
34
+ if (!Array.isArray(mapping))
35
+ return {};
36
+ const overrides = {};
37
+ for (const entry of mapping) {
38
+ if (!isMapping(entry))
39
+ continue;
40
+ const artifact = entry.artifact;
41
+ const p = entry.path;
42
+ if (typeof artifact === "string" && typeof p === "string")
43
+ overrides[artifact] = p;
44
+ }
45
+ return overrides;
46
+ }
47
+ export function defaultArtifactPath(artifact, cwd) {
48
+ const rel = docsPathOverrides(cwd)[artifact] ?? DEFAULT_ARTIFACT_PATHS[artifact] ?? "";
49
+ return rel ? resolvePathRel(rel, cwd) : "";
50
+ }
51
+ export function artifactPaths(cwd) {
52
+ const paths = { ...DEFAULT_ARTIFACT_PATHS, ...docsPathOverrides(cwd) };
53
+ const resolved = {};
54
+ for (const [artifact, p] of Object.entries(paths))
55
+ resolved[artifact] = resolvePathRel(p, cwd);
56
+ return resolved;
57
+ }
58
+ function samePath(left, right) {
59
+ return resolvePath(left) === resolvePath(right);
60
+ }
61
+ export function artifactForWrite(absPath, relPath, basename, cwd) {
62
+ for (const [artifact, mappedPath] of Object.entries(artifactPaths(cwd))) {
63
+ if (samePath(absPath, mappedPath))
64
+ return artifact;
65
+ }
66
+ const match = AGENT_YAML_RE.exec(relPath);
67
+ if (match) {
68
+ const id = match[1];
69
+ return id in ARTIFACT_PROTOCOL_PATHS ? id : null;
70
+ }
71
+ if (HUMAN_FACING_ARTIFACT_IDS.has(normalizeArtifactProtocolId(basename) ?? "")) {
72
+ return normalizeArtifactProtocolId(basename);
73
+ }
74
+ return null;
75
+ }
76
+ function readIfNeeded(content, absPath) {
77
+ if (content !== null && content !== undefined)
78
+ return content;
79
+ try {
80
+ return fs.readFileSync(absPath, "utf8");
81
+ }
82
+ catch {
83
+ return null;
84
+ }
85
+ }
86
+ function compactAfterValidWrite(artifact, absPath) {
87
+ if (!fs.existsSync(absPath))
88
+ return [];
89
+ try {
90
+ if (artifact === "todo") {
91
+ compactFile(absPath, "todo-resolved");
92
+ }
93
+ else if (artifact in COMPACTABLE_YAML_ARTIFACTS) {
94
+ compactYamlFile(absPath, artifact);
95
+ }
96
+ else {
97
+ return [];
98
+ }
99
+ }
100
+ catch (exc) {
101
+ return [`${artifact}: compaction failed: ${exc.message}`];
102
+ }
103
+ return [];
104
+ }
105
+ export { readIfNeeded, compactAfterValidWrite };
106
+ //# sourceMappingURL=traversal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traversal.js","sourceRoot":"","sources":["../../../src/hooks/validateArtifact/traversal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,O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EAAE,CAAC;IACvC,IAAI,CAAC;QACH,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QACxC,CAAC;aAAM,IAAI,QAAQ,IAAI,0BAA0B,EAAE,CAAC;YAClD,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,QAAQ,wBAAyB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * YAML-side violation orchestrators.
3
+ *
4
+ * `validateYamlContent` is the single entry point: parse, walk the
5
+ * schema singleton groups, run sequence validation, apply artifact-
6
+ * specific rules (plan, decisions), and finally run BUDGET and
7
+ * VALIDATION_RULES checks. Lower-level helpers live in `schema.ts`.
8
+ */
9
+ import path from "node:path";
10
+ import { parseYaml } from "../../core/yaml.js";
11
+ import { resolveSourceRoot } from "../../core/sourceRoot.js";
12
+ import { loadYamlMapping } from "../../core/yaml.js";
13
+ import { expectedSequenceOrder, isMapping, sequenceInOrder, validationRuleSeverity, validateDecisionAlternatives, validateDecisionSatisfaction, validateFullPlanContract, validatePlanDependencies, validatePlanKnownFields, validateSequences, validateSingletonGroup, collectSingletonGroups, wordCount, } from "./schema.js";
14
+ function schemasDirDefault() {
15
+ return path.join(resolveSourceRoot(), "skills", "agentera", "schemas", "artifacts");
16
+ }
17
+ export function validateYamlContent(content, schema, name) {
18
+ const violations = [];
19
+ let data;
20
+ try {
21
+ data = parseYaml(content);
22
+ }
23
+ catch (exc) {
24
+ return [`${name}: invalid YAML: ${exc.message}`];
25
+ }
26
+ if (!isMapping(data)) {
27
+ return [`${name}: root must be a mapping`];
28
+ }
29
+ for (const [group, groupLower, fields] of collectSingletonGroups(schema)) {
30
+ let scope;
31
+ if (groupLower in data && isMapping(data[groupLower])) {
32
+ scope = data[groupLower];
33
+ }
34
+ else if (fields.some((f) => f in data)) {
35
+ scope = data;
36
+ }
37
+ else {
38
+ continue;
39
+ }
40
+ validateSingletonGroup(violations, name, schema, group, scope, groupLower);
41
+ }
42
+ if (name === "plan") {
43
+ validatePlanKnownFields(data, schema, violations);
44
+ validateFullPlanContract(data, violations);
45
+ validatePlanDependencies(data, violations);
46
+ }
47
+ validateSequences(data, schema, name, violations);
48
+ if (name === "decisions") {
49
+ violations.push(...validateDecisionAlternatives(data, name));
50
+ violations.push(...validateDecisionSatisfaction(data, name));
51
+ }
52
+ const wordBudgetSeverity = validationRuleSeverity(schema, "word_budget");
53
+ for (const be of Object.values(schema.BUDGET ?? {})) {
54
+ if (!isMapping(be))
55
+ continue;
56
+ const mw = be.max_words;
57
+ const scope = be.scope ?? "";
58
+ if (mw && String(scope).includes("full_file") && wordBudgetSeverity === "error") {
59
+ const wc = wordCount(content);
60
+ if (wc > Number(mw))
61
+ violations.push(`${name}: word count (${wc}) exceeds budget (${mw})`);
62
+ }
63
+ }
64
+ for (const groupKey of ["VALIDATION", "VALIDATION_RULES"]) {
65
+ for (const ve of Object.values(schema[groupKey] ?? {})) {
66
+ if (!isMapping(ve))
67
+ continue;
68
+ const rule = String(ve.rule ?? "");
69
+ if (ve.severity !== "error")
70
+ continue;
71
+ if (rule.includes("unique") && rule.includes("number")) {
72
+ for (const [key, val] of Object.entries(data)) {
73
+ if (Array.isArray(val)) {
74
+ const nums = val
75
+ .filter((e) => isMapping(e) && "number" in e)
76
+ .map((e) => e.number);
77
+ if (nums.length > 0) {
78
+ if (nums.length !== new Set(nums).size) {
79
+ violations.push(`${name}: duplicate numbers in '${key}'`);
80
+ }
81
+ const direction = expectedSequenceOrder(name, key);
82
+ if (!sequenceInOrder(nums, direction)) {
83
+ violations.push(`${name}: '${key}' not in ${direction} order`);
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ else if (rule === "closure_consistency") {
90
+ const header = isMapping(data.header) ? data.header : {};
91
+ const status = data.status ?? header.status;
92
+ if (typeof status === "string" && status === "closed") {
93
+ for (const field of ["closed_at", "final_value", "target_ref", "reason"]) {
94
+ let val = data[field];
95
+ if (val === null || val === undefined)
96
+ val = header[field];
97
+ if (val === null || val === undefined || (typeof val === "string" && !val.trim())) {
98
+ violations.push(`${name}: closure field '${field}' is required when status is 'closed'`);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ return violations;
106
+ }
107
+ export { loadYamlMapping, schemasDirDefault };
108
+ //# sourceMappingURL=violations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"violations.js","sourceRoot":"","sources":["../../../src/hooks/validateArtifact/violations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,qBAAqB,EAErB,SAAS,EAET,eAAe,EACf,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAE5B,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,SAAS,GACV,MAAM,aAAa,CAAC;AAIrB,SAAS,iBAAiB;IACxB,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,MAAkB,EAAE,IAAY;IACnF,MAAM,UAAU,GAAa,EAAE,CAAC;IA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I,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC;gBAC5C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;oBACtD,KAAK,MAAM,KAAK,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC;wBACzE,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;wBACtB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;4BAAE,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;wBAC3D,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;4BAClF,UAAU,CAAC,IAAI,CACb,GAAG,IAAI,oBAAoB,KAAK,uCAAuC,CACxE,CAAC;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,455 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { isLifecycleOwnershipStateDirectory } from "../runtime/lifecycleOwnershipJournal.js";
4
+ import { AGENTERA_PROFILE_DIR_ENV, PROFILERA_PROFILE_DIR_ENV, resolveProfileDirOverride, } from "../core/envPaths.js";
5
+ import { expanduser, isFile, pathExists, resolvePath } from "../core/paths.js";
6
+ import { opencodeConfigDir } from "../setup/opencode.js";
7
+ import { doctorRoots, loadSuiteVersion } from "../upgrade/appModel.js";
8
+ import { MANAGED_APP_CONTENT_ROOT_ENTRIES } from "../upgrade/appContentRefresh.js";
9
+ import { AGENTERA_USER_STATE_NAMES, ROOT_USER_STATE_DIR_NAMES, ROOT_USER_STATE_FILE_NAMES, } from "../upgrade/doctor.js";
10
+ /** Contract authority: references/cli/v3-handoff-manifest.schema.yaml */
11
+ export const V2_HANDOFF_MANIFEST_SCHEMA_REL = "references/cli/v3-handoff-manifest.schema.yaml";
12
+ export const V2_HANDOFF_MANIFEST_FILENAME = "v3-handoff.json";
13
+ export const V2_HANDOFF_SCHEMA_VERSION = "agentera.v3_handoff_manifest.v1";
14
+ export const READER_PREFLIGHT_BUDGET_MS = 100;
15
+ export const USER_DATA_CATALOG_DIRS = [
16
+ "benchmarks",
17
+ "intermediate",
18
+ "sessions",
19
+ "history",
20
+ "corpus",
21
+ ];
22
+ export const PROFILE_FILE_MEMBERS = ["PROFILE.md", "USAGE.md"];
23
+ function isRecord(value) {
24
+ return value !== null && typeof value === "object" && !Array.isArray(value);
25
+ }
26
+ function asNonEmptyString(value, field) {
27
+ if (typeof value !== "string" || !value.trim()) {
28
+ throw new Error(`${field} must be a non-empty string`);
29
+ }
30
+ return value.trim();
31
+ }
32
+ function parseDirectoryEntry(raw) {
33
+ const id = asNonEmptyString(raw.id, "user_data_inventory.id");
34
+ if (!USER_DATA_CATALOG_DIRS.includes(id)) {
35
+ throw new Error(`user_data_inventory id ${id} is not in the catalog`);
36
+ }
37
+ if (raw.kind !== "directory") {
38
+ throw new Error(`user_data_inventory entry ${id} must have kind=directory`);
39
+ }
40
+ if (typeof raw.exists !== "boolean") {
41
+ throw new Error(`user_data_inventory entry ${id} must have boolean exists`);
42
+ }
43
+ return {
44
+ id: id,
45
+ relative_path: asNonEmptyString(raw.relative_path, `user_data_inventory.${id}.relative_path`),
46
+ kind: "directory",
47
+ exists: raw.exists,
48
+ };
49
+ }
50
+ function parseProfileFilesEntry(raw) {
51
+ if (raw.id !== "profile_files") {
52
+ throw new Error("profile_files entry must have id=profile_files");
53
+ }
54
+ if (raw.kind !== "profile_files") {
55
+ throw new Error("profile_files entry must have kind=profile_files");
56
+ }
57
+ if (!Array.isArray(raw.members)) {
58
+ throw new Error("profile_files entry must have members array");
59
+ }
60
+ const members = raw.members.map((member, index) => {
61
+ if (!isRecord(member)) {
62
+ throw new Error(`profile_files.members[${index}] must be an object`);
63
+ }
64
+ if (member.kind !== "file") {
65
+ throw new Error(`profile_files.members[${index}] must have kind=file`);
66
+ }
67
+ if (typeof member.exists !== "boolean") {
68
+ throw new Error(`profile_files.members[${index}] must have boolean exists`);
69
+ }
70
+ return {
71
+ relative_path: asNonEmptyString(member.relative_path, `profile_files.members[${index}].relative_path`),
72
+ kind: "file",
73
+ exists: member.exists,
74
+ };
75
+ });
76
+ return { id: "profile_files", kind: "profile_files", members };
77
+ }
78
+ function parseUserDataInventory(raw) {
79
+ if (!Array.isArray(raw) || raw.length < 6) {
80
+ throw new Error("user_data_inventory must be an array with at least six entries");
81
+ }
82
+ const entries = raw.map((item, index) => {
83
+ if (!isRecord(item)) {
84
+ throw new Error(`user_data_inventory[${index}] must be an object`);
85
+ }
86
+ if (item.kind === "profile_files") {
87
+ return parseProfileFilesEntry(item);
88
+ }
89
+ return parseDirectoryEntry(item);
90
+ });
91
+ const ids = new Set(entries.map((entry) => entry.id));
92
+ for (const id of [...USER_DATA_CATALOG_DIRS, "profile_files"]) {
93
+ if (!ids.has(id)) {
94
+ throw new Error(`user_data_inventory missing catalog id ${id}`);
95
+ }
96
+ }
97
+ return entries;
98
+ }
99
+ export function parseV2HandoffManifest(raw) {
100
+ if (!isRecord(raw)) {
101
+ throw new Error("manifest must be a JSON object");
102
+ }
103
+ const schemaVersion = asNonEmptyString(raw.schema_version, "schema_version");
104
+ if (schemaVersion !== V2_HANDOFF_SCHEMA_VERSION) {
105
+ throw new Error(`schema_version must be ${V2_HANDOFF_SCHEMA_VERSION}`);
106
+ }
107
+ const writtenAt = asNonEmptyString(raw.written_at, "written_at");
108
+ if (Number.isNaN(Date.parse(writtenAt))) {
109
+ throw new Error("written_at must be an ISO-8601 UTC timestamp");
110
+ }
111
+ if (!Array.isArray(raw.runtime_adapters)) {
112
+ throw new Error("runtime_adapters must be an array");
113
+ }
114
+ const runtimeAdapters = raw.runtime_adapters.map((adapter, index) => asNonEmptyString(adapter, `runtime_adapters[${index}]`));
115
+ return {
116
+ schema_version: V2_HANDOFF_SCHEMA_VERSION,
117
+ written_at: writtenAt,
118
+ installed_v2_version: asNonEmptyString(raw.installed_v2_version, "installed_v2_version"),
119
+ app_home_path: asNonEmptyString(raw.app_home_path, "app_home_path"),
120
+ user_data_inventory: parseUserDataInventory(raw.user_data_inventory),
121
+ runtime_adapters: runtimeAdapters,
122
+ };
123
+ }
124
+ export function v2HandoffManifestPath(appHome) {
125
+ return path.join(resolvePath(appHome), V2_HANDOFF_MANIFEST_FILENAME);
126
+ }
127
+ export function readV2HandoffManifestFile(appHome) {
128
+ const manifestPath = v2HandoffManifestPath(appHome);
129
+ if (!isFile(manifestPath)) {
130
+ return null;
131
+ }
132
+ const started = performance.now();
133
+ let parsed;
134
+ try {
135
+ parsed = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
136
+ }
137
+ catch (exc) {
138
+ throw new Error(`failed to read ${V2_HANDOFF_MANIFEST_FILENAME}: ${exc.message}`);
139
+ }
140
+ const manifest = parseV2HandoffManifest(parsed);
141
+ const elapsedMs = performance.now() - started;
142
+ return { manifest, elapsedMs };
143
+ }
144
+ function agenteraUserStateDirIsRecognized(dir) {
145
+ if (!pathExists(dir) || !fs.statSync(dir).isDirectory()) {
146
+ return false;
147
+ }
148
+ for (const entry of fs.readdirSync(dir)) {
149
+ const full = path.join(dir, entry);
150
+ const st = fs.statSync(full);
151
+ if (AGENTERA_USER_STATE_NAMES.has(entry) && st.isFile()) {
152
+ continue;
153
+ }
154
+ if ((entry === "optimize" || entry === "optimera") && st.isDirectory()) {
155
+ // "optimera" is the v2 stable legacy objective dir name; keep it
156
+ // recognized so v2->v3 migration preserves legacy objective state.
157
+ continue;
158
+ }
159
+ if (entry === "runtime-lifecycle" && isLifecycleOwnershipStateDirectory(full)) {
160
+ continue;
161
+ }
162
+ return false;
163
+ }
164
+ return true;
165
+ }
166
+ function isPreservedUserStateEntry(appHome, entry) {
167
+ const full = path.join(appHome, entry);
168
+ if (!pathExists(full)) {
169
+ return false;
170
+ }
171
+ const st = fs.statSync(full);
172
+ if (ROOT_USER_STATE_FILE_NAMES.has(entry) && st.isFile()) {
173
+ return true;
174
+ }
175
+ if (ROOT_USER_STATE_DIR_NAMES.has(entry) && st.isDirectory()) {
176
+ return true;
177
+ }
178
+ if (entry === ".agentera" && agenteraUserStateDirIsRecognized(full)) {
179
+ return true;
180
+ }
181
+ if (USER_DATA_CATALOG_DIRS.includes(entry) &&
182
+ st.isDirectory()) {
183
+ return true;
184
+ }
185
+ return false;
186
+ }
187
+ function listPreservedTopLevelFromScan(appHome) {
188
+ if (!pathExists(appHome)) {
189
+ return [];
190
+ }
191
+ const preserved = [];
192
+ for (const entry of fs.readdirSync(appHome)) {
193
+ if (entry === "app" || entry === V2_HANDOFF_MANIFEST_FILENAME) {
194
+ continue;
195
+ }
196
+ if (isPreservedUserStateEntry(appHome, entry)) {
197
+ preserved.push(entry);
198
+ }
199
+ }
200
+ return preserved.sort();
201
+ }
202
+ function listPreservedAbsolutePathsFromScan(appHome) {
203
+ const preserved = [];
204
+ for (const entry of listPreservedTopLevelFromScan(appHome)) {
205
+ const full = path.join(appHome, entry);
206
+ preserved.push(full);
207
+ if (entry === ".agentera" && pathExists(full) && fs.statSync(full).isDirectory()) {
208
+ for (const name of AGENTERA_USER_STATE_NAMES) {
209
+ const nested = path.join(full, name);
210
+ if (isFile(nested)) {
211
+ preserved.push(nested);
212
+ }
213
+ }
214
+ }
215
+ }
216
+ return preserved.sort();
217
+ }
218
+ function listPreservedTopLevelFromManifest(manifest) {
219
+ const preserved = new Set();
220
+ for (const entry of manifest.user_data_inventory) {
221
+ if (entry.kind === "directory" && entry.exists) {
222
+ preserved.add(entry.relative_path);
223
+ }
224
+ if (entry.kind === "profile_files") {
225
+ for (const member of entry.members) {
226
+ if (member.exists) {
227
+ preserved.add(member.relative_path);
228
+ }
229
+ }
230
+ }
231
+ }
232
+ return [...preserved].sort();
233
+ }
234
+ function listPreservedAbsolutePathsFromManifest(manifest, appHome) {
235
+ const root = resolvePath(appHome);
236
+ const preserved = [];
237
+ for (const rel of listPreservedTopLevelFromManifest(manifest)) {
238
+ preserved.push(path.join(root, rel));
239
+ }
240
+ const agenteraDir = path.join(root, ".agentera");
241
+ if (pathExists(agenteraDir) && fs.statSync(agenteraDir).isDirectory()) {
242
+ preserved.push(agenteraDir);
243
+ for (const name of AGENTERA_USER_STATE_NAMES) {
244
+ const nested = path.join(agenteraDir, name);
245
+ if (isFile(nested)) {
246
+ preserved.push(nested);
247
+ }
248
+ }
249
+ }
250
+ return preserved.sort();
251
+ }
252
+ export function isManifestCatalogEntryPreserved(manifest, entry) {
253
+ for (const item of manifest.user_data_inventory) {
254
+ if (item.kind === "directory" && item.relative_path === entry) {
255
+ return item.exists;
256
+ }
257
+ if (item.kind === "profile_files") {
258
+ for (const member of item.members) {
259
+ if (member.relative_path === entry) {
260
+ return member.exists;
261
+ }
262
+ }
263
+ }
264
+ }
265
+ if (entry === ".agentera") {
266
+ const agenteraDir = path.join(resolvePath(manifest.app_home_path), ".agentera");
267
+ return agenteraUserStateDirIsRecognized(agenteraDir);
268
+ }
269
+ return false;
270
+ }
271
+ function profileDirEnvVar(env) {
272
+ if (env[AGENTERA_PROFILE_DIR_ENV]) {
273
+ return AGENTERA_PROFILE_DIR_ENV;
274
+ }
275
+ if (env[PROFILERA_PROFILE_DIR_ENV]) {
276
+ return PROFILERA_PROFILE_DIR_ENV;
277
+ }
278
+ return null;
279
+ }
280
+ function opencodeConfigDirEnvVar(env) {
281
+ if (env.OPENCODE_CONFIG_DIR) {
282
+ return "OPENCODE_CONFIG_DIR";
283
+ }
284
+ if (env.XDG_CONFIG_HOME) {
285
+ return "XDG_CONFIG_HOME";
286
+ }
287
+ return null;
288
+ }
289
+ function listUserDataPathsAtRoot(root) {
290
+ const preserved = new Set([root]);
291
+ for (const dir of USER_DATA_CATALOG_DIRS) {
292
+ const full = path.join(root, dir);
293
+ if (pathExists(full) && fs.statSync(full).isDirectory()) {
294
+ preserved.add(full);
295
+ }
296
+ }
297
+ for (const file of PROFILE_FILE_MEMBERS) {
298
+ const full = path.join(root, file);
299
+ if (isFile(full)) {
300
+ preserved.add(full);
301
+ }
302
+ }
303
+ return [...preserved].sort();
304
+ }
305
+ function opencodeConfigDirHasArtifacts(configDir) {
306
+ if (isFile(path.join(configDir, "plugins", "agentera.js"))) {
307
+ return true;
308
+ }
309
+ const agentsDir = path.join(configDir, "agents");
310
+ if (pathExists(agentsDir) && fs.statSync(agentsDir).isDirectory()) {
311
+ if (fs.readdirSync(agentsDir).some((name) => isFile(path.join(agentsDir, name)))) {
312
+ return true;
313
+ }
314
+ }
315
+ return pathExists(path.join(configDir, "skills", "agentera"));
316
+ }
317
+ function listOpencodeConfigCatalog(configDir) {
318
+ const preserved = new Set([configDir]);
319
+ for (const rel of ["plugins/agentera.js", "agents", "commands", "skills"]) {
320
+ const full = path.join(configDir, rel);
321
+ if (pathExists(full)) {
322
+ preserved.add(full);
323
+ }
324
+ }
325
+ return [...preserved].sort();
326
+ }
327
+ export function buildExternalHandoffCatalog(appHome, opts) {
328
+ if (!opts?.env) {
329
+ return [];
330
+ }
331
+ const env = opts.env;
332
+ const home = resolvePath(opts.home ?? appHome);
333
+ const resolvedAppHome = resolvePath(appHome);
334
+ const catalog = [];
335
+ const profileEnvVar = profileDirEnvVar(env);
336
+ const profileOverride = resolveProfileDirOverride(env);
337
+ if (profileEnvVar && profileOverride) {
338
+ const profileDir = resolvePath(expanduser(profileOverride));
339
+ if (profileDir !== resolvedAppHome) {
340
+ catalog.push({
341
+ surface: "custom_profile_dir",
342
+ root: profileDir,
343
+ envVar: profileEnvVar,
344
+ entries: listUserDataPathsAtRoot(profileDir),
345
+ });
346
+ }
347
+ }
348
+ const opencodeEnvVar = opencodeConfigDirEnvVar(env);
349
+ if (opencodeEnvVar) {
350
+ const configDir = opencodeConfigDir(home, env);
351
+ const defaultDir = resolvePath(path.join(home, ".config", "opencode"));
352
+ if (configDir !== defaultDir && opencodeConfigDirHasArtifacts(configDir)) {
353
+ catalog.push({
354
+ surface: "opencode_runtime_config_dir",
355
+ root: configDir,
356
+ envVar: opencodeEnvVar,
357
+ entries: listOpencodeConfigCatalog(configDir),
358
+ });
359
+ }
360
+ }
361
+ return catalog;
362
+ }
363
+ function mergePreservedAbsolutePaths(base, handoffCatalog) {
364
+ const merged = new Set(base);
365
+ for (const entry of handoffCatalog) {
366
+ for (const absolutePath of entry.entries) {
367
+ merged.add(absolutePath);
368
+ }
369
+ }
370
+ return [...merged].sort();
371
+ }
372
+ export function handoffCatalogMessage(entry) {
373
+ if (entry.surface === "custom_profile_dir") {
374
+ return `custom profile dir (${entry.envVar}=${entry.root}) cataloged for v2→v3 handoff`;
375
+ }
376
+ return `opencode runtime config dir (${entry.envVar} → ${entry.root}) cataloged for v2→v3 handoff`;
377
+ }
378
+ export function resolveMigrationUserStatePreflight(appHome, opts) {
379
+ const resolvedHome = resolvePath(appHome);
380
+ const handoffCatalog = buildExternalHandoffCatalog(resolvedHome, opts);
381
+ const manifestRead = readV2HandoffManifestFile(resolvedHome);
382
+ if (manifestRead) {
383
+ return {
384
+ source: "manifest",
385
+ elapsedMs: manifestRead.elapsedMs,
386
+ manifest: manifestRead.manifest,
387
+ preservedTopLevel: listPreservedTopLevelFromManifest(manifestRead.manifest),
388
+ preservedAbsolutePaths: mergePreservedAbsolutePaths(listPreservedAbsolutePathsFromManifest(manifestRead.manifest, resolvedHome), handoffCatalog),
389
+ handoffCatalog,
390
+ };
391
+ }
392
+ const started = performance.now();
393
+ const preservedTopLevel = listPreservedTopLevelFromScan(resolvedHome);
394
+ const preservedAbsolutePaths = mergePreservedAbsolutePaths(listPreservedAbsolutePathsFromScan(resolvedHome), handoffCatalog);
395
+ return {
396
+ source: "scan",
397
+ elapsedMs: performance.now() - started,
398
+ manifest: null,
399
+ preservedTopLevel,
400
+ preservedAbsolutePaths,
401
+ handoffCatalog,
402
+ };
403
+ }
404
+ export function appHomeHasUnrecognizedEntriesWithPreflight(appHome, preflight) {
405
+ if (!pathExists(appHome)) {
406
+ return [];
407
+ }
408
+ const unknown = [];
409
+ for (const entry of fs.readdirSync(appHome)) {
410
+ if (entry === "app" || entry === V2_HANDOFF_MANIFEST_FILENAME) {
411
+ continue;
412
+ }
413
+ if (MANAGED_APP_CONTENT_ROOT_ENTRIES.has(entry)) {
414
+ continue;
415
+ }
416
+ if (preflight.source === "manifest" && preflight.manifest) {
417
+ if (isManifestCatalogEntryPreserved(preflight.manifest, entry)) {
418
+ continue;
419
+ }
420
+ }
421
+ else if (isPreservedUserStateEntry(appHome, entry)) {
422
+ continue;
423
+ }
424
+ unknown.push(entry);
425
+ }
426
+ return unknown;
427
+ }
428
+ export function isV2HandoffManifestStale(manifest, ctx) {
429
+ if (resolvePath(manifest.app_home_path) !== resolvePath(ctx.appHome)) {
430
+ return true;
431
+ }
432
+ if (manifest.installed_v2_version !== ctx.installedVersion) {
433
+ return true;
434
+ }
435
+ const writtenAtMs = Date.parse(manifest.written_at);
436
+ const markerMs = ctx.bundleMarkerMtimeMs;
437
+ if (Number.isNaN(writtenAtMs) || Math.floor(writtenAtMs / 1000) < Math.floor(markerMs / 1000)) {
438
+ return true;
439
+ }
440
+ return false;
441
+ }
442
+ export function bundleMarkerFreshnessContext(appHome, sourceRoot) {
443
+ const roots = doctorRoots(appHome);
444
+ const markerPath = path.join(roots.activeBundleRoot, ".agentera-bundle.json");
445
+ if (!isFile(markerPath)) {
446
+ return null;
447
+ }
448
+ const installedVersion = loadSuiteVersion(roots.activeBundleRoot) ?? loadSuiteVersion(sourceRoot) ?? "unknown";
449
+ return {
450
+ appHome: resolvePath(appHome),
451
+ installedVersion,
452
+ bundleMarkerMtimeMs: fs.statSync(markerPath).mtimeMs,
453
+ };
454
+ }
455
+ //# sourceMappingURL=v2HandoffManifest.js.map