agentera 3.0.0-dev.3 → 3.0.0-dev.30

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 (762) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +96 -6
  3. package/bundle/.agentera-npx-bundle.json +1 -1
  4. package/bundle/CHANGELOG.md +1133 -0
  5. package/bundle/DESIGN.md +229 -0
  6. package/bundle/LICENSE +201 -0
  7. package/bundle/README.md +136 -0
  8. package/bundle/UPGRADE.md +201 -0
  9. package/bundle/extract-corpus-parity.json +21 -0
  10. package/bundle/fixtures/routing/hybrid-corpus.yaml +154 -0
  11. package/bundle/references/adapters/package-manifest-interface-model.yaml +42 -252
  12. package/bundle/references/adapters/package-registry.yaml +20 -188
  13. package/bundle/references/adapters/package-surface-characterization.md +36 -37
  14. package/bundle/references/adapters/runtime-lifecycle-adapters.yaml +74 -0
  15. package/bundle/references/adapters/runtime-lifecycle-authority.yaml +62 -0
  16. package/bundle/references/adapters/runtime-lifecycle-operation-contract.yaml +84 -0
  17. package/bundle/references/adapters/runtime-retired-resources.yaml +97 -0
  18. package/bundle/references/analysis/benchmark.md +10 -6
  19. package/bundle/references/analysis/evidence-tier-authority.yaml +516 -0
  20. package/bundle/references/analysis/startup-measurement-contract.yaml +37 -26
  21. package/bundle/references/analysis/verification-policy.yaml +142 -0
  22. package/bundle/references/artifacts/artifact-registry-interface-model.yaml +9 -8
  23. package/bundle/references/artifacts/state-storage-authority.yaml +2167 -0
  24. package/bundle/references/artifacts/verbosity-budget-authority.yaml +42 -0
  25. package/bundle/references/cli/agent-ready-state-contract.yaml +64 -81
  26. package/bundle/references/cli/app-lifecycle-vocabulary.yaml +7 -8
  27. package/bundle/references/cli/audience-namespace-cli-migration.yaml +58 -29
  28. package/bundle/references/cli/bundle-skill-vocabulary.yaml +12 -49
  29. package/bundle/references/cli/capability-instruction-contract.yaml +96 -58
  30. package/bundle/references/cli/capability-instruction-structure.md +144 -0
  31. package/bundle/references/cli/capability-tool-classification.yaml +14 -14
  32. package/bundle/references/cli/coexistence-probe.yaml +13 -0
  33. package/bundle/references/cli/hybrid-route-contract.yaml +416 -0
  34. package/bundle/references/cli/parity-expected-actual-template.md +30 -0
  35. package/bundle/references/cli/prime-consumer-compatibility.yaml +651 -0
  36. package/bundle/references/cli/routing-execution-vocabulary.yaml +16 -38
  37. package/bundle/references/cli/routing-model.md +139 -0
  38. package/bundle/references/cli/single-name-protocol.yaml +42 -0
  39. package/bundle/references/cli/trigger-schema-enrichment.md +140 -0
  40. package/bundle/references/cli/update-channels.yaml +45 -7
  41. package/bundle/references/cli/upgrade-repair-wording.md +25 -0
  42. package/bundle/references/cli/v3-handoff-manifest.schema.yaml +97 -0
  43. package/bundle/references/cli/vocabulary-index.yaml +23 -18
  44. package/bundle/references/cli/vocabulary.md +346 -331
  45. package/bundle/references/meta/documentation-inventory.md +10 -3
  46. package/bundle/registry.json +14 -14
  47. package/bundle/skills/agentera/SKILL.md +182 -407
  48. package/bundle/skills/agentera/capabilities/audit/schemas/artifacts.yaml +84 -0
  49. package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/exit.yaml +2 -2
  50. package/bundle/skills/agentera/capabilities/audit/schemas/triggers.yaml +25 -0
  51. package/bundle/skills/agentera/capabilities/{inspektera → audit}/schemas/validation.yaml +20 -19
  52. package/bundle/skills/agentera/capabilities/build/schemas/artifacts.yaml +85 -0
  53. package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/exit.yaml +3 -3
  54. package/bundle/skills/agentera/capabilities/build/schemas/triggers.yaml +27 -0
  55. package/bundle/skills/agentera/capabilities/{realisera → build}/schemas/validation.yaml +16 -16
  56. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/artifacts.yaml +12 -12
  57. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/exit.yaml +5 -5
  58. package/bundle/skills/agentera/capabilities/design/schemas/triggers.yaml +16 -0
  59. package/bundle/skills/agentera/capabilities/{visualisera → design}/schemas/validation.yaml +7 -7
  60. package/bundle/skills/agentera/capabilities/discuss/schemas/artifacts.yaml +49 -0
  61. package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/exit.yaml +2 -2
  62. package/bundle/skills/agentera/capabilities/discuss/schemas/triggers.yaml +20 -0
  63. package/bundle/skills/agentera/capabilities/{resonera → discuss}/schemas/validation.yaml +9 -8
  64. package/bundle/skills/agentera/capabilities/document/schemas/artifacts.yaml +80 -0
  65. package/bundle/skills/agentera/capabilities/document/schemas/triggers.yaml +16 -0
  66. package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/validation.yaml +18 -18
  67. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/artifacts.yaml +17 -17
  68. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/exit.yaml +2 -2
  69. package/bundle/skills/agentera/capabilities/optimize/schemas/triggers.yaml +16 -0
  70. package/bundle/skills/agentera/capabilities/{optimera → optimize}/schemas/validation.yaml +9 -9
  71. package/bundle/skills/agentera/capabilities/orchestrate/schemas/artifacts.yaml +76 -0
  72. package/bundle/skills/agentera/capabilities/{orkestrera → orchestrate}/schemas/exit.yaml +9 -7
  73. package/bundle/skills/agentera/capabilities/orchestrate/schemas/triggers.yaml +23 -0
  74. package/bundle/skills/agentera/capabilities/orchestrate/schemas/validation.yaml +121 -0
  75. package/bundle/skills/agentera/capabilities/plan/schemas/artifacts.yaml +63 -0
  76. package/bundle/skills/agentera/capabilities/{planera → plan}/schemas/exit.yaml +2 -2
  77. package/bundle/skills/agentera/capabilities/plan/schemas/triggers.yaml +23 -0
  78. package/bundle/skills/agentera/capabilities/plan/schemas/validation.yaml +89 -0
  79. package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/artifacts.yaml +4 -4
  80. package/bundle/skills/agentera/capabilities/{profilera → profile}/schemas/exit.yaml +3 -3
  81. package/bundle/skills/agentera/capabilities/profile/schemas/triggers.yaml +20 -0
  82. package/bundle/skills/agentera/capabilities/profile/schemas/validation.yaml +85 -0
  83. package/bundle/skills/agentera/capabilities/research/schemas/artifacts.yaml +24 -0
  84. package/bundle/skills/agentera/capabilities/research/schemas/triggers.yaml +16 -0
  85. package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/validation.yaml +2 -2
  86. package/bundle/skills/agentera/capabilities/status/schemas/artifacts.yaml +72 -0
  87. package/bundle/skills/agentera/capabilities/status/schemas/triggers.yaml +22 -0
  88. package/bundle/skills/agentera/capabilities/{hej → status}/schemas/validation.yaml +5 -5
  89. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/artifacts.yaml +16 -16
  90. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/exit.yaml +7 -6
  91. package/bundle/skills/agentera/capabilities/vision/schemas/triggers.yaml +23 -0
  92. package/bundle/skills/agentera/capabilities/{visionera → vision}/schemas/validation.yaml +18 -20
  93. package/bundle/skills/agentera/capability_schema_contract.yaml +200 -37
  94. package/bundle/skills/agentera/protocol.yaml +29 -29
  95. package/bundle/skills/agentera/references/contract.md +387 -329
  96. package/bundle/skills/agentera/route-phrases.yaml +81 -0
  97. package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +5 -4
  98. package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +40 -22
  99. package/bundle/skills/agentera/schemas/artifacts/design.yaml +5 -4
  100. package/bundle/skills/agentera/schemas/artifacts/docs.yaml +15 -19
  101. package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +145 -14
  102. package/bundle/skills/agentera/schemas/artifacts/health.yaml +58 -21
  103. package/bundle/skills/agentera/schemas/artifacts/objective.yaml +22 -8
  104. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +327 -15
  105. package/bundle/skills/agentera/schemas/artifacts/progress.yaml +51 -53
  106. package/bundle/skills/agentera/schemas/artifacts/todo.yaml +82 -28
  107. package/bundle/skills/agentera/schemas/artifacts/vision.yaml +3 -3
  108. package/dist/analytics/extractCorpus/cli.js +191 -0
  109. package/dist/analytics/extractCorpus/cli.js.map +1 -0
  110. package/dist/analytics/extractCorpus/copilotSessions.js +276 -0
  111. package/dist/analytics/extractCorpus/copilotSessions.js.map +1 -0
  112. package/dist/analytics/extractCorpus/core.js +393 -0
  113. package/dist/analytics/extractCorpus/core.js.map +1 -0
  114. package/dist/analytics/extractCorpus/corpus.js +168 -0
  115. package/dist/analytics/extractCorpus/corpus.js.map +1 -0
  116. package/dist/analytics/extractCorpus/coverageAudit.js +261 -0
  117. package/dist/analytics/extractCorpus/coverageAudit.js.map +1 -0
  118. package/dist/analytics/extractCorpus/cursorSessions.js +426 -0
  119. package/dist/analytics/extractCorpus/cursorSessions.js.map +1 -0
  120. package/dist/analytics/extractCorpus/evidenceTiers.js +561 -0
  121. package/dist/analytics/extractCorpus/evidenceTiers.js.map +1 -0
  122. package/dist/analytics/extractCorpus/extractCorpusParity.js +106 -0
  123. package/dist/analytics/extractCorpus/extractCorpusParity.js.map +1 -0
  124. package/dist/analytics/extractCorpus/filesystemSources.js +119 -0
  125. package/dist/analytics/extractCorpus/filesystemSources.js.map +1 -0
  126. package/dist/analytics/extractCorpus/index.js +15 -0
  127. package/dist/analytics/extractCorpus/index.js.map +1 -0
  128. package/dist/analytics/extractCorpus/jsonlSessions.js +205 -0
  129. package/dist/analytics/extractCorpus/jsonlSessions.js.map +1 -0
  130. package/dist/analytics/extractCorpus/sqliteCaps.js +44 -0
  131. package/dist/analytics/extractCorpus/sqliteCaps.js.map +1 -0
  132. package/dist/analytics/extractCorpus/sqliteSessions.js +368 -0
  133. package/dist/analytics/extractCorpus/sqliteSessions.js.map +1 -0
  134. package/dist/analytics/extractCorpus/tierReader.js +109 -0
  135. package/dist/analytics/extractCorpus/tierReader.js.map +1 -0
  136. package/dist/analytics/extractCorpus.js +2 -1790
  137. package/dist/analytics/extractCorpus.js.map +1 -1
  138. package/dist/analytics/profileSignals.js +212 -0
  139. package/dist/analytics/profileSignals.js.map +1 -0
  140. package/dist/analytics/usageStats.js +191 -41
  141. package/dist/analytics/usageStats.js.map +1 -1
  142. package/dist/bin/agentera.js +3 -1
  143. package/dist/bin/agentera.js.map +1 -1
  144. package/dist/capabilities/audit/instructions.js +16 -0
  145. package/dist/capabilities/audit/instructions.js.map +1 -0
  146. package/dist/capabilities/build/instructions.js +18 -0
  147. package/dist/capabilities/build/instructions.js.map +1 -0
  148. package/dist/capabilities/design/instructions.js +5 -0
  149. package/dist/capabilities/design/instructions.js.map +1 -0
  150. package/dist/capabilities/discuss/instructions.js +16 -0
  151. package/dist/capabilities/discuss/instructions.js.map +1 -0
  152. package/dist/capabilities/document/instructions.js +12 -0
  153. package/dist/capabilities/document/instructions.js.map +1 -0
  154. package/dist/capabilities/index.js +39 -0
  155. package/dist/capabilities/index.js.map +1 -0
  156. package/dist/capabilities/optimize/instructions.js +14 -0
  157. package/dist/capabilities/optimize/instructions.js.map +1 -0
  158. package/dist/capabilities/orchestrate/instructions.js +41 -0
  159. package/dist/capabilities/orchestrate/instructions.js.map +1 -0
  160. package/dist/capabilities/plan/instructions.js +15 -0
  161. package/dist/capabilities/plan/instructions.js.map +1 -0
  162. package/dist/capabilities/profile/instructions.js +5 -0
  163. package/dist/capabilities/profile/instructions.js.map +1 -0
  164. package/dist/capabilities/research/instructions.js +6 -0
  165. package/dist/capabilities/research/instructions.js.map +1 -0
  166. package/dist/capabilities/status/instructions.js +5 -0
  167. package/dist/capabilities/status/instructions.js.map +1 -0
  168. package/dist/capabilities/status/startupInstructions.js +35 -0
  169. package/dist/capabilities/status/startupInstructions.js.map +1 -0
  170. package/dist/capabilities/vision/instructions.js +5 -0
  171. package/dist/capabilities/vision/instructions.js.map +1 -0
  172. package/dist/cli/appContext.js +30 -23
  173. package/dist/cli/appContext.js.map +1 -1
  174. package/dist/cli/argvalidate.js.map +1 -1
  175. package/dist/cli/capabilityContext/benchmark.js +564 -0
  176. package/dist/cli/capabilityContext/benchmark.js.map +1 -0
  177. package/dist/cli/capabilityContext/bespoke.js +44 -0
  178. package/dist/cli/capabilityContext/bespoke.js.map +1 -0
  179. package/dist/cli/capabilityContext/build.js +191 -0
  180. package/dist/cli/capabilityContext/build.js.map +1 -0
  181. package/dist/cli/capabilityContext/closeout.js +231 -0
  182. package/dist/cli/capabilityContext/closeout.js.map +1 -0
  183. package/dist/cli/capabilityContext/contract.js +214 -0
  184. package/dist/cli/capabilityContext/contract.js.map +1 -0
  185. package/dist/cli/capabilityContext/evidence.js +469 -0
  186. package/dist/cli/capabilityContext/evidence.js.map +1 -0
  187. package/dist/cli/capabilityContext/index.js +4 -0
  188. package/dist/cli/capabilityContext/index.js.map +1 -0
  189. package/dist/cli/capabilityContext/orchestration.js +128 -0
  190. package/dist/cli/capabilityContext/orchestration.js.map +1 -0
  191. package/dist/cli/capabilityContext/planState.js +280 -0
  192. package/dist/cli/capabilityContext/planState.js.map +1 -0
  193. package/dist/cli/capabilityContext/progress.js +143 -0
  194. package/dist/cli/capabilityContext/progress.js.map +1 -0
  195. package/dist/cli/capabilityContext/shared.js +100 -0
  196. package/dist/cli/capabilityContext/shared.js.map +1 -0
  197. package/dist/cli/capabilityContext/slim.js +153 -0
  198. package/dist/cli/capabilityContext/slim.js.map +1 -0
  199. package/dist/cli/capabilityContext/startup.js +257 -0
  200. package/dist/cli/capabilityContext/startup.js.map +1 -0
  201. package/dist/cli/capabilityContext/types.js +51 -0
  202. package/dist/cli/capabilityContext/types.js.map +1 -0
  203. package/dist/cli/capabilityContext.js +1 -2420
  204. package/dist/cli/capabilityContext.js.map +1 -1
  205. package/dist/cli/commands/appHome.js +23 -0
  206. package/dist/cli/commands/appHome.js.map +1 -0
  207. package/dist/cli/commands/capability.js +3 -10
  208. package/dist/cli/commands/capability.js.map +1 -1
  209. package/dist/cli/commands/compact.js +41 -12
  210. package/dist/cli/commands/compact.js.map +1 -1
  211. package/dist/cli/commands/doctor.js +59 -97
  212. package/dist/cli/commands/doctor.js.map +1 -1
  213. package/dist/cli/commands/durability.js +82 -0
  214. package/dist/cli/commands/durability.js.map +1 -0
  215. package/dist/cli/commands/entityMigrate.js +132 -0
  216. package/dist/cli/commands/entityMigrate.js.map +1 -0
  217. package/dist/cli/commands/lint.js +26 -43
  218. package/dist/cli/commands/lint.js.map +1 -1
  219. package/dist/cli/commands/prime/briefOrientation.js +592 -0
  220. package/dist/cli/commands/prime/briefOrientation.js.map +1 -0
  221. package/dist/cli/commands/prime/bundleStatus.js +191 -0
  222. package/dist/cli/commands/prime/bundleStatus.js.map +1 -0
  223. package/dist/cli/commands/prime/collectEntityOrientation.js +260 -0
  224. package/dist/cli/commands/prime/collectEntityOrientation.js.map +1 -0
  225. package/dist/cli/commands/prime/collectOrientationState.js +180 -0
  226. package/dist/cli/commands/prime/collectOrientationState.js.map +1 -0
  227. package/dist/cli/commands/prime/orientationOutput.js +350 -0
  228. package/dist/cli/commands/prime/orientationOutput.js.map +1 -0
  229. package/dist/cli/commands/prime/types.js +2 -0
  230. package/dist/cli/commands/prime/types.js.map +1 -0
  231. package/dist/cli/commands/prime/v1Migration.js +39 -0
  232. package/dist/cli/commands/prime/v1Migration.js.map +1 -0
  233. package/dist/cli/commands/prime.js +61 -556
  234. package/dist/cli/commands/prime.js.map +1 -1
  235. package/dist/cli/commands/query.js +66 -51
  236. package/dist/cli/commands/query.js.map +1 -1
  237. package/dist/cli/commands/report.js +100 -24
  238. package/dist/cli/commands/report.js.map +1 -1
  239. package/dist/cli/commands/route.js +142 -0
  240. package/dist/cli/commands/route.js.map +1 -0
  241. package/dist/cli/commands/schema.js +260 -78
  242. package/dist/cli/commands/schema.js.map +1 -1
  243. package/dist/cli/commands/state/decisions.js +388 -0
  244. package/dist/cli/commands/state/decisions.js.map +1 -0
  245. package/dist/cli/commands/state/docs.js +71 -0
  246. package/dist/cli/commands/state/docs.js.map +1 -0
  247. package/dist/cli/commands/state/experimentRecords.js +139 -0
  248. package/dist/cli/commands/state/experimentRecords.js.map +1 -0
  249. package/dist/cli/commands/state/experiments.js +15 -0
  250. package/dist/cli/commands/state/experiments.js.map +1 -0
  251. package/dist/cli/commands/state/get.js +127 -0
  252. package/dist/cli/commands/state/get.js.map +1 -0
  253. package/dist/cli/commands/state/health.js +15 -0
  254. package/dist/cli/commands/state/health.js.map +1 -0
  255. package/dist/cli/commands/state/index.js +60 -0
  256. package/dist/cli/commands/state/index.js.map +1 -0
  257. package/dist/cli/commands/state/list.js +176 -0
  258. package/dist/cli/commands/state/list.js.map +1 -0
  259. package/dist/cli/commands/state/objective.js +26 -0
  260. package/dist/cli/commands/state/objective.js.map +1 -0
  261. package/dist/cli/commands/state/plan.js +15 -0
  262. package/dist/cli/commands/state/plan.js.map +1 -0
  263. package/dist/cli/commands/state/planTasks.js +142 -0
  264. package/dist/cli/commands/state/planTasks.js.map +1 -0
  265. package/dist/cli/commands/state/plans.js +143 -0
  266. package/dist/cli/commands/state/plans.js.map +1 -0
  267. package/dist/cli/commands/state/progress.js +14 -0
  268. package/dist/cli/commands/state/progress.js.map +1 -0
  269. package/dist/cli/commands/state/shared.js +15 -0
  270. package/dist/cli/commands/state/shared.js.map +1 -0
  271. package/dist/cli/commands/state/todo.js +42 -0
  272. package/dist/cli/commands/state/todo.js.map +1 -0
  273. package/dist/cli/commands/state/write.js +418 -0
  274. package/dist/cli/commands/state/write.js.map +1 -0
  275. package/dist/cli/commands/upgrade.js +146 -4
  276. package/dist/cli/commands/upgrade.js.map +1 -1
  277. package/dist/cli/commands/upgradeVerify.js +119 -0
  278. package/dist/cli/commands/upgradeVerify.js.map +1 -0
  279. package/dist/cli/commands/validate.js +109 -209
  280. package/dist/cli/commands/validate.js.map +1 -1
  281. package/dist/cli/commands/verify.js +30 -8
  282. package/dist/cli/commands/verify.js.map +1 -1
  283. package/dist/cli/contracts/bundleStatus.js +2 -0
  284. package/dist/cli/contracts/bundleStatus.js.map +1 -0
  285. package/dist/cli/contracts/orientationState.js +2 -0
  286. package/dist/cli/contracts/orientationState.js.map +1 -0
  287. package/dist/cli/dispatch/argvParser.js +33 -0
  288. package/dist/cli/dispatch/argvParser.js.map +1 -0
  289. package/dist/cli/dispatch/check.js +390 -0
  290. package/dist/cli/dispatch/check.js.map +1 -0
  291. package/dist/cli/dispatch/commands.js +27 -0
  292. package/dist/cli/dispatch/commands.js.map +1 -0
  293. package/dist/cli/dispatch/index.js +226 -0
  294. package/dist/cli/dispatch/index.js.map +1 -0
  295. package/dist/cli/dispatch/lifecycle.js +653 -0
  296. package/dist/cli/dispatch/lifecycle.js.map +1 -0
  297. package/dist/cli/dispatch/prime.js +119 -0
  298. package/dist/cli/dispatch/prime.js.map +1 -0
  299. package/dist/cli/dispatch/shared.js +64 -0
  300. package/dist/cli/dispatch/shared.js.map +1 -0
  301. package/dist/cli/dispatch/state.js +174 -0
  302. package/dist/cli/dispatch/state.js.map +1 -0
  303. package/dist/cli/dispatch.js +1 -957
  304. package/dist/cli/dispatch.js.map +1 -1
  305. package/dist/cli/errors.js +53 -0
  306. package/dist/cli/errors.js.map +1 -0
  307. package/dist/cli/help.js +418 -0
  308. package/dist/cli/help.js.map +1 -0
  309. package/dist/cli/migrationRequired.js +87 -0
  310. package/dist/cli/migrationRequired.js.map +1 -0
  311. package/dist/cli/orientation/attention.js +67 -0
  312. package/dist/cli/orientation/attention.js.map +1 -0
  313. package/dist/cli/orientation/corpusCoverage.js +103 -0
  314. package/dist/cli/orientation/corpusCoverage.js.map +1 -0
  315. package/dist/cli/orientation.js +357 -148
  316. package/dist/cli/orientation.js.map +1 -1
  317. package/dist/cli/planArtifacts.js +351 -0
  318. package/dist/cli/planArtifacts.js.map +1 -0
  319. package/dist/cli/planEvidence.js +158 -0
  320. package/dist/cli/planEvidence.js.map +1 -0
  321. package/dist/cli/planLifecycleState.js +34 -0
  322. package/dist/cli/planLifecycleState.js.map +1 -0
  323. package/dist/cli/planTaskIndex.js +12 -0
  324. package/dist/cli/planTaskIndex.js.map +1 -0
  325. package/dist/cli/prime-blob.js +69 -2
  326. package/dist/cli/prime-blob.js.map +1 -1
  327. package/dist/cli/startupCompletenessContract.js +57 -0
  328. package/dist/cli/startupCompletenessContract.js.map +1 -0
  329. package/dist/cli/stateQuery.js +63 -10
  330. package/dist/cli/stateQuery.js.map +1 -1
  331. package/dist/cli/structured.js.map +1 -1
  332. package/dist/cli/todoMarkdown.js +33 -0
  333. package/dist/cli/todoMarkdown.js.map +1 -0
  334. package/dist/cli/todoSeverity.js +19 -0
  335. package/dist/cli/todoSeverity.js.map +1 -0
  336. package/dist/core/atomicWriter.js +21 -0
  337. package/dist/core/atomicWriter.js.map +1 -0
  338. package/dist/core/difflib.js.map +1 -1
  339. package/dist/core/envPaths.js +21 -0
  340. package/dist/core/envPaths.js.map +1 -0
  341. package/dist/core/jsonValue.js +6 -0
  342. package/dist/core/jsonValue.js.map +1 -0
  343. package/dist/core/paths.js.map +1 -1
  344. package/dist/core/pyjson.js +67 -2
  345. package/dist/core/pyjson.js.map +1 -1
  346. package/dist/core/skillIdentity.js +24 -0
  347. package/dist/core/skillIdentity.js.map +1 -0
  348. package/dist/core/sourceRoot.js.map +1 -1
  349. package/dist/core/text.js +11 -0
  350. package/dist/core/text.js.map +1 -0
  351. package/dist/core/toml.js.map +1 -1
  352. package/dist/core/yaml.js +8 -0
  353. package/dist/core/yaml.js.map +1 -1
  354. package/dist/eval/evalSkills.js +30 -25
  355. package/dist/eval/evalSkills.js.map +1 -1
  356. package/dist/eval/hybridRouteEvaluation.js +156 -0
  357. package/dist/eval/hybridRouteEvaluation.js.map +1 -0
  358. package/dist/eval/semanticEval.js +43 -19
  359. package/dist/eval/semanticEval.js.map +1 -1
  360. package/dist/eval/semanticFixtures.js +16 -4
  361. package/dist/eval/semanticFixtures.js.map +1 -1
  362. package/dist/hooks/common.js +10 -27
  363. package/dist/hooks/common.js.map +1 -1
  364. package/dist/hooks/compaction/apply.js +447 -0
  365. package/dist/hooks/compaction/apply.js.map +1 -0
  366. package/dist/hooks/compaction/dryRun.js +185 -0
  367. package/dist/hooks/compaction/dryRun.js.map +1 -0
  368. package/dist/hooks/compaction/index.js +23 -0
  369. package/dist/hooks/compaction/index.js.map +1 -0
  370. package/dist/hooks/compaction/parse.js +326 -0
  371. package/dist/hooks/compaction/parse.js.map +1 -0
  372. package/dist/hooks/compaction/retention.js +203 -0
  373. package/dist/hooks/compaction/retention.js.map +1 -0
  374. package/dist/hooks/compaction/status.js +361 -0
  375. package/dist/hooks/compaction/status.js.map +1 -0
  376. package/dist/hooks/compaction/types.js +6 -0
  377. package/dist/hooks/compaction/types.js.map +1 -0
  378. package/dist/hooks/cursorPreToolUse.js +1 -1
  379. package/dist/hooks/cursorPreToolUse.js.map +1 -1
  380. package/dist/hooks/cursorSessionStart.js +14 -21
  381. package/dist/hooks/cursorSessionStart.js.map +1 -1
  382. package/dist/hooks/projectHookInput.js +26 -0
  383. package/dist/hooks/projectHookInput.js.map +1 -0
  384. package/dist/hooks/sessionStart.js +55 -170
  385. package/dist/hooks/sessionStart.js.map +1 -1
  386. package/dist/hooks/sessionStop.js +12 -26
  387. package/dist/hooks/sessionStop.js.map +1 -1
  388. package/dist/hooks/validateArtifact/agentFacing.js +10 -0
  389. package/dist/hooks/validateArtifact/agentFacing.js.map +1 -0
  390. package/dist/hooks/validateArtifact/index.js +151 -0
  391. package/dist/hooks/validateArtifact/index.js.map +1 -0
  392. package/dist/hooks/validateArtifact/markdown.js +146 -0
  393. package/dist/hooks/validateArtifact/markdown.js.map +1 -0
  394. package/dist/hooks/validateArtifact/runtime.js +86 -0
  395. package/dist/hooks/validateArtifact/runtime.js.map +1 -0
  396. package/dist/hooks/validateArtifact/schema.js +541 -0
  397. package/dist/hooks/validateArtifact/schema.js.map +1 -0
  398. package/dist/hooks/validateArtifact/traversal.js +108 -0
  399. package/dist/hooks/validateArtifact/traversal.js.map +1 -0
  400. package/dist/hooks/validateArtifact/violations.js +108 -0
  401. package/dist/hooks/validateArtifact/violations.js.map +1 -0
  402. package/dist/migrate/v2HandoffManifest.js +455 -0
  403. package/dist/migrate/v2HandoffManifest.js.map +1 -0
  404. package/dist/registries/artifactProtocolIds.js +77 -0
  405. package/dist/registries/artifactProtocolIds.js.map +1 -0
  406. package/dist/registries/artifactRegistry.js +222 -62
  407. package/dist/registries/artifactRegistry.js.map +1 -1
  408. package/dist/registries/capabilityContract.js +141 -12
  409. package/dist/registries/capabilityContract.js.map +1 -1
  410. package/dist/registries/evaluatorHandoffContract.js +171 -0
  411. package/dist/registries/evaluatorHandoffContract.js.map +1 -0
  412. package/dist/registries/evidenceTierContract.js +362 -0
  413. package/dist/registries/evidenceTierContract.js.map +1 -0
  414. package/dist/registries/hybridRoute.js +203 -0
  415. package/dist/registries/hybridRoute.js.map +1 -0
  416. package/dist/registries/hybridRouteReceipt.js +221 -0
  417. package/dist/registries/hybridRouteReceipt.js.map +1 -0
  418. package/dist/registries/packageRegistry.js +90 -230
  419. package/dist/registries/packageRegistry.js.map +1 -1
  420. package/dist/registries/triggerLoader.js +175 -0
  421. package/dist/registries/triggerLoader.js.map +1 -0
  422. package/dist/registries/verbosityBudgetContract.js +206 -0
  423. package/dist/registries/verbosityBudgetContract.js.map +1 -0
  424. package/dist/release/releaseMetadata.js +319 -0
  425. package/dist/release/releaseMetadata.js.map +1 -0
  426. package/dist/runtime/lifecycleAdapterContract.js +458 -0
  427. package/dist/runtime/lifecycleAdapterContract.js.map +1 -0
  428. package/dist/runtime/lifecycleAdapters.js +778 -0
  429. package/dist/runtime/lifecycleAdapters.js.map +1 -0
  430. package/dist/runtime/lifecycleAuthority.js +454 -0
  431. package/dist/runtime/lifecycleAuthority.js.map +1 -0
  432. package/dist/runtime/lifecycleOperationContract.js +114 -0
  433. package/dist/runtime/lifecycleOperationContract.js.map +1 -0
  434. package/dist/runtime/lifecycleOperations.js +635 -0
  435. package/dist/runtime/lifecycleOperations.js.map +1 -0
  436. package/dist/runtime/lifecycleOwnershipJournal.js +623 -0
  437. package/dist/runtime/lifecycleOwnershipJournal.js.map +1 -0
  438. package/dist/runtime/lifecyclePublication.js +416 -0
  439. package/dist/runtime/lifecyclePublication.js.map +1 -0
  440. package/dist/runtime/lifecycleSnapshot.js +439 -0
  441. package/dist/runtime/lifecycleSnapshot.js.map +1 -0
  442. package/dist/runtime/nativeResourceCleanup.js +317 -0
  443. package/dist/runtime/nativeResourceCleanup.js.map +1 -0
  444. package/dist/setup/codex/cli.js +130 -0
  445. package/dist/setup/codex/cli.js.map +1 -0
  446. package/dist/setup/codex/configToml.js +558 -0
  447. package/dist/setup/codex/configToml.js.map +1 -0
  448. package/dist/setup/codex/constants.js +14 -0
  449. package/dist/setup/codex/constants.js.map +1 -0
  450. package/dist/setup/codex/installRoot.js +64 -0
  451. package/dist/setup/codex/installRoot.js.map +1 -0
  452. package/dist/setup/codex/state.js +252 -0
  453. package/dist/setup/codex/state.js.map +1 -0
  454. package/dist/setup/codex.js +9 -1055
  455. package/dist/setup/codex.js.map +1 -1
  456. package/dist/setup/opencode.js +21 -0
  457. package/dist/setup/opencode.js.map +1 -0
  458. package/dist/setup/opencodeConstants.js +2 -0
  459. package/dist/setup/opencodeConstants.js.map +1 -0
  460. package/dist/setup/sharedSkill.js +46 -0
  461. package/dist/setup/sharedSkill.js.map +1 -0
  462. package/dist/setup/smokeChecks.js +82 -0
  463. package/dist/setup/smokeChecks.js.map +1 -0
  464. package/dist/state/archiveDiscovery.js +578 -0
  465. package/dist/state/archiveDiscovery.js.map +1 -0
  466. package/dist/state/archivePublication.js +226 -0
  467. package/dist/state/archivePublication.js.map +1 -0
  468. package/dist/state/archiveRecovery.js +238 -0
  469. package/dist/state/archiveRecovery.js.map +1 -0
  470. package/dist/state/archiveReplay.js +54 -0
  471. package/dist/state/archiveReplay.js.map +1 -0
  472. package/dist/state/canonicalMigrationRecord.js +37 -0
  473. package/dist/state/canonicalMigrationRecord.js.map +1 -0
  474. package/dist/state/decisionEntities.js +322 -0
  475. package/dist/state/decisionEntities.js.map +1 -0
  476. package/dist/state/decisionLegacyValidation.js +216 -0
  477. package/dist/state/decisionLegacyValidation.js.map +1 -0
  478. package/dist/state/decisionMigrationProvenance.js +117 -0
  479. package/dist/state/decisionMigrationProvenance.js.map +1 -0
  480. package/dist/state/decisionOverlay.js +278 -0
  481. package/dist/state/decisionOverlay.js.map +1 -0
  482. package/dist/state/decisionRevision.js +632 -0
  483. package/dist/state/decisionRevision.js.map +1 -0
  484. package/dist/state/decisionRevisionPublication.js +532 -0
  485. package/dist/state/decisionRevisionPublication.js.map +1 -0
  486. package/dist/state/directRetrieval.js +373 -0
  487. package/dist/state/directRetrieval.js.map +1 -0
  488. package/dist/state/durability.js +325 -0
  489. package/dist/state/durability.js.map +1 -0
  490. package/dist/state/entityCutover.js +294 -0
  491. package/dist/state/entityCutover.js.map +1 -0
  492. package/dist/state/entityCutoverGit.js +128 -0
  493. package/dist/state/entityCutoverGit.js.map +1 -0
  494. package/dist/state/entityMigrationCausality.js +99 -0
  495. package/dist/state/entityMigrationCausality.js.map +1 -0
  496. package/dist/state/entityMigrationPreview.js +864 -0
  497. package/dist/state/entityMigrationPreview.js.map +1 -0
  498. package/dist/state/entityPublicationContext.js +662 -0
  499. package/dist/state/entityPublicationContext.js.map +1 -0
  500. package/dist/state/entityStorage.js +881 -0
  501. package/dist/state/entityStorage.js.map +1 -0
  502. package/dist/state/experimentArchive.js +64 -0
  503. package/dist/state/experimentArchive.js.map +1 -0
  504. package/dist/state/experimentIdentity.js +203 -0
  505. package/dist/state/experimentIdentity.js.map +1 -0
  506. package/dist/state/experimentRetrieval.js +447 -0
  507. package/dist/state/experimentRetrieval.js.map +1 -0
  508. package/dist/state/healthEntities.js +266 -0
  509. package/dist/state/healthEntities.js.map +1 -0
  510. package/dist/state/healthEntityValidation.js +19 -0
  511. package/dist/state/healthEntityValidation.js.map +1 -0
  512. package/dist/state/healthRepair.js +70 -0
  513. package/dist/state/healthRepair.js.map +1 -0
  514. package/dist/state/installRoot.js +64 -24
  515. package/dist/state/installRoot.js.map +1 -1
  516. package/dist/state/legacyEntityCutoverEvidence.js +66 -0
  517. package/dist/state/legacyEntityCutoverEvidence.js.map +1 -0
  518. package/dist/state/legacyIdentity.js +48 -0
  519. package/dist/state/legacyIdentity.js.map +1 -0
  520. package/dist/state/legacySummaryRecord.js +7 -0
  521. package/dist/state/legacySummaryRecord.js.map +1 -0
  522. package/dist/state/listAccounting.js +55 -0
  523. package/dist/state/listAccounting.js.map +1 -0
  524. package/dist/state/listClassification.js +18 -0
  525. package/dist/state/listClassification.js.map +1 -0
  526. package/dist/state/listCursor.js +43 -0
  527. package/dist/state/listCursor.js.map +1 -0
  528. package/dist/state/listRetrieval.js +813 -0
  529. package/dist/state/listRetrieval.js.map +1 -0
  530. package/dist/state/migrationSourceBinding.js +31 -0
  531. package/dist/state/migrationSourceBinding.js.map +1 -0
  532. package/dist/state/objectiveExperimentEntities.js +323 -0
  533. package/dist/state/objectiveExperimentEntities.js.map +1 -0
  534. package/dist/state/planEntities.js +444 -0
  535. package/dist/state/planEntities.js.map +1 -0
  536. package/dist/state/planIdentity.js +45 -0
  537. package/dist/state/planIdentity.js.map +1 -0
  538. package/dist/state/planRetrieval.js +314 -0
  539. package/dist/state/planRetrieval.js.map +1 -0
  540. package/dist/state/planTaskRetrieval.js +285 -0
  541. package/dist/state/planTaskRetrieval.js.map +1 -0
  542. package/dist/state/progressEntities.js +360 -0
  543. package/dist/state/progressEntities.js.map +1 -0
  544. package/dist/state/projectRoot.js +63 -0
  545. package/dist/state/projectRoot.js.map +1 -0
  546. package/dist/state/projectionPolicy.js +184 -0
  547. package/dist/state/projectionPolicy.js.map +1 -0
  548. package/dist/state/retrievalAuthority.js +343 -0
  549. package/dist/state/retrievalAuthority.js.map +1 -0
  550. package/dist/state/safeProjectFile.js +153 -0
  551. package/dist/state/safeProjectFile.js.map +1 -0
  552. package/dist/state/startupAnalysis/benchmark.js +433 -0
  553. package/dist/state/startupAnalysis/benchmark.js.map +1 -0
  554. package/dist/state/startupAnalysis/contract.js +126 -0
  555. package/dist/state/startupAnalysis/contract.js.map +1 -0
  556. package/dist/state/startupAnalysis/helpers.js +287 -0
  557. package/dist/state/startupAnalysis/helpers.js.map +1 -0
  558. package/dist/state/startupAnalysis/index.js +7 -0
  559. package/dist/state/startupAnalysis/index.js.map +1 -0
  560. package/dist/state/startupAnalysis/metrics.js +341 -0
  561. package/dist/state/startupAnalysis/metrics.js.map +1 -0
  562. package/dist/state/startupAnalysis/records.js +199 -0
  563. package/dist/state/startupAnalysis/records.js.map +1 -0
  564. package/dist/state/startupAnalysis/report.js +112 -0
  565. package/dist/state/startupAnalysis/report.js.map +1 -0
  566. package/dist/state/startupAnalysis/threshold.js +513 -0
  567. package/dist/state/startupAnalysis/threshold.js.map +1 -0
  568. package/dist/state/startupAnalysis.js +2 -1952
  569. package/dist/state/startupAnalysis.js.map +1 -1
  570. package/dist/state/startupProjection.js +567 -0
  571. package/dist/state/startupProjection.js.map +1 -0
  572. package/dist/state/stateMode.js +83 -0
  573. package/dist/state/stateMode.js.map +1 -0
  574. package/dist/state/summaryEntityRead.js +26 -0
  575. package/dist/state/summaryEntityRead.js.map +1 -0
  576. package/dist/state/summaryMigrationProvenance.js +67 -0
  577. package/dist/state/summaryMigrationProvenance.js.map +1 -0
  578. package/dist/state/summarySourceRowAuthority.js +37 -0
  579. package/dist/state/summarySourceRowAuthority.js.map +1 -0
  580. package/dist/state/todoDocsEntities.js +230 -0
  581. package/dist/state/todoDocsEntities.js.map +1 -0
  582. package/dist/state/todoDocsEntityValidation.js +26 -0
  583. package/dist/state/todoDocsEntityValidation.js.map +1 -0
  584. package/dist/state/write/assign.js +21 -0
  585. package/dist/state/write/assign.js.map +1 -0
  586. package/dist/state/write/candidateMutation.js +281 -0
  587. package/dist/state/write/candidateMutation.js.map +1 -0
  588. package/dist/state/write/errors.js +12 -0
  589. package/dist/state/write/errors.js.map +1 -0
  590. package/dist/state/write/experimentPublication.js +193 -0
  591. package/dist/state/write/experimentPublication.js.map +1 -0
  592. package/dist/state/write/explain.js +291 -0
  593. package/dist/state/write/explain.js.map +1 -0
  594. package/dist/state/write/fields.js +62 -0
  595. package/dist/state/write/fields.js.map +1 -0
  596. package/dist/state/write/helpers.js +30 -0
  597. package/dist/state/write/helpers.js.map +1 -0
  598. package/dist/state/write/index.js +12 -0
  599. package/dist/state/write/index.js.map +1 -0
  600. package/dist/state/write/input.js +22 -0
  601. package/dist/state/write/input.js.map +1 -0
  602. package/dist/state/write/lock.js +838 -0
  603. package/dist/state/write/lock.js.map +1 -0
  604. package/dist/state/write/mutation.js +235 -0
  605. package/dist/state/write/mutation.js.map +1 -0
  606. package/dist/state/write/operations.js +353 -0
  607. package/dist/state/write/operations.js.map +1 -0
  608. package/dist/state/write/planEvaluation.js +121 -0
  609. package/dist/state/write/planEvaluation.js.map +1 -0
  610. package/dist/state/write/planPublication.js +135 -0
  611. package/dist/state/write/planPublication.js.map +1 -0
  612. package/dist/state/write/serialize.js +2 -0
  613. package/dist/state/write/serialize.js.map +1 -0
  614. package/dist/state/write/transaction.js +44 -0
  615. package/dist/state/write/transaction.js.map +1 -0
  616. package/dist/state/write/validate.js +8 -0
  617. package/dist/state/write/validate.js.map +1 -0
  618. package/dist/upgrade/appContentRefresh.js +384 -0
  619. package/dist/upgrade/appContentRefresh.js.map +1 -0
  620. package/dist/upgrade/appModel.js +8 -6
  621. package/dist/upgrade/appModel.js.map +1 -1
  622. package/dist/upgrade/atomicWriter.js +2 -0
  623. package/dist/upgrade/atomicWriter.js.map +1 -0
  624. package/dist/upgrade/bundleEvidence.js +34 -0
  625. package/dist/upgrade/bundleEvidence.js.map +1 -0
  626. package/dist/upgrade/channels.js +21 -10
  627. package/dist/upgrade/channels.js.map +1 -1
  628. package/dist/upgrade/coexistenceProbe.js +105 -0
  629. package/dist/upgrade/coexistenceProbe.js.map +1 -0
  630. package/dist/upgrade/compatibility.js +56 -20
  631. package/dist/upgrade/compatibility.js.map +1 -1
  632. package/dist/upgrade/doctor.js +197 -191
  633. package/dist/upgrade/doctor.js.map +1 -1
  634. package/dist/upgrade/doctorClassifier.js +188 -0
  635. package/dist/upgrade/doctorClassifier.js.map +1 -0
  636. package/dist/upgrade/installedHooksRetirement.js +197 -0
  637. package/dist/upgrade/installedHooksRetirement.js.map +1 -0
  638. package/dist/upgrade/legacyAgentCleanup.js +283 -0
  639. package/dist/upgrade/legacyAgentCleanup.js.map +1 -0
  640. package/dist/upgrade/lifecycleUpgrade.js +114 -0
  641. package/dist/upgrade/lifecycleUpgrade.js.map +1 -0
  642. package/dist/upgrade/migrateArtifactsV2ToV3.js +363 -137
  643. package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -1
  644. package/dist/upgrade/migrationPublication.js +123 -0
  645. package/dist/upgrade/migrationPublication.js.map +1 -0
  646. package/dist/upgrade/nextMajorDoctor.js +156 -0
  647. package/dist/upgrade/nextMajorDoctor.js.map +1 -0
  648. package/dist/upgrade/npxPlatformStatus.js +23 -0
  649. package/dist/upgrade/npxPlatformStatus.js.map +1 -0
  650. package/dist/upgrade/projectIntegration.js +142 -171
  651. package/dist/upgrade/projectIntegration.js.map +1 -1
  652. package/dist/upgrade/projectIntegrationDecision.js +51 -0
  653. package/dist/upgrade/projectIntegrationDecision.js.map +1 -0
  654. package/dist/upgrade/runtimeMigration.js +336 -281
  655. package/dist/upgrade/runtimeMigration.js.map +1 -1
  656. package/dist/upgrade/upgradeCommands.js +9 -0
  657. package/dist/upgrade/upgradeCommands.js.map +1 -1
  658. package/dist/upgrade/upgradeLock.js +86 -0
  659. package/dist/upgrade/upgradeLock.js.map +1 -0
  660. package/dist/upgrade/upgradeOrchestrator.js +212 -56
  661. package/dist/upgrade/upgradeOrchestrator.js.map +1 -1
  662. package/dist/upgrade/v3CapabilitySurface.js +15 -0
  663. package/dist/upgrade/v3CapabilitySurface.js.map +1 -0
  664. package/dist/upgrade/versionResolution.js +12 -4
  665. package/dist/upgrade/versionResolution.js.map +1 -1
  666. package/dist/validate/appHomeContract.js +5 -9
  667. package/dist/validate/appHomeContract.js.map +1 -1
  668. package/dist/validate/capability.js +144 -14
  669. package/dist/validate/capability.js.map +1 -1
  670. package/dist/validate/crossCapability.js +12 -9
  671. package/dist/validate/crossCapability.js.map +1 -1
  672. package/dist/validate/selfAudit.js +73 -36
  673. package/dist/validate/selfAudit.js.map +1 -1
  674. package/dist/validate/vocabularyAuthority.js +303 -0
  675. package/dist/validate/vocabularyAuthority.js.map +1 -0
  676. package/package.json +45 -27
  677. package/bundle/references/adapters/cursor.md +0 -213
  678. package/bundle/references/adapters/opencode.md +0 -530
  679. package/bundle/references/adapters/runtime-adapter-characterization.md +0 -79
  680. package/bundle/references/adapters/runtime-adapter-interface-model.yaml +0 -200
  681. package/bundle/references/adapters/runtime-adapter-registry.yaml +0 -548
  682. package/bundle/references/adapters/runtime-feature-parity.md +0 -189
  683. package/bundle/references/v1-section-mapping.md +0 -47
  684. package/bundle/skills/agentera/.claude-plugin/plugin.json +0 -27
  685. package/bundle/skills/agentera/agents/dokumentera.toml +0 -6
  686. package/bundle/skills/agentera/agents/hej.toml +0 -6
  687. package/bundle/skills/agentera/agents/inspektera.toml +0 -6
  688. package/bundle/skills/agentera/agents/inspirera.toml +0 -6
  689. package/bundle/skills/agentera/agents/optimera.toml +0 -6
  690. package/bundle/skills/agentera/agents/orkestrera.toml +0 -6
  691. package/bundle/skills/agentera/agents/planera.toml +0 -6
  692. package/bundle/skills/agentera/agents/profilera.toml +0 -6
  693. package/bundle/skills/agentera/agents/realisera.toml +0 -6
  694. package/bundle/skills/agentera/agents/resonera.toml +0 -6
  695. package/bundle/skills/agentera/agents/visionera.toml +0 -6
  696. package/bundle/skills/agentera/agents/visualisera.toml +0 -6
  697. package/bundle/skills/agentera/capabilities/dokumentera/instructions.md +0 -428
  698. package/bundle/skills/agentera/capabilities/dokumentera/schemas/artifacts.yaml +0 -73
  699. package/bundle/skills/agentera/capabilities/dokumentera/schemas/triggers.yaml +0 -35
  700. package/bundle/skills/agentera/capabilities/hej/instructions.md +0 -331
  701. package/bundle/skills/agentera/capabilities/hej/schemas/artifacts.yaml +0 -69
  702. package/bundle/skills/agentera/capabilities/hej/schemas/triggers.yaml +0 -58
  703. package/bundle/skills/agentera/capabilities/inspektera/instructions.md +0 -514
  704. package/bundle/skills/agentera/capabilities/inspektera/schemas/artifacts.yaml +0 -76
  705. package/bundle/skills/agentera/capabilities/inspektera/schemas/triggers.yaml +0 -38
  706. package/bundle/skills/agentera/capabilities/inspirera/instructions.md +0 -280
  707. package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +0 -24
  708. package/bundle/skills/agentera/capabilities/inspirera/schemas/triggers.yaml +0 -34
  709. package/bundle/skills/agentera/capabilities/optimera/instructions.md +0 -437
  710. package/bundle/skills/agentera/capabilities/optimera/schemas/triggers.yaml +0 -39
  711. package/bundle/skills/agentera/capabilities/orkestrera/instructions.md +0 -433
  712. package/bundle/skills/agentera/capabilities/orkestrera/schemas/artifacts.yaml +0 -64
  713. package/bundle/skills/agentera/capabilities/orkestrera/schemas/triggers.yaml +0 -42
  714. package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +0 -107
  715. package/bundle/skills/agentera/capabilities/planera/instructions.md +0 -368
  716. package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +0 -62
  717. package/bundle/skills/agentera/capabilities/planera/schemas/triggers.yaml +0 -34
  718. package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +0 -61
  719. package/bundle/skills/agentera/capabilities/profilera/instructions.md +0 -419
  720. package/bundle/skills/agentera/capabilities/profilera/schemas/triggers.yaml +0 -45
  721. package/bundle/skills/agentera/capabilities/profilera/schemas/validation.yaml +0 -57
  722. package/bundle/skills/agentera/capabilities/realisera/instructions.md +0 -403
  723. package/bundle/skills/agentera/capabilities/realisera/schemas/artifacts.yaml +0 -80
  724. package/bundle/skills/agentera/capabilities/realisera/schemas/triggers.yaml +0 -39
  725. package/bundle/skills/agentera/capabilities/resonera/instructions.md +0 -329
  726. package/bundle/skills/agentera/capabilities/resonera/schemas/artifacts.yaml +0 -47
  727. package/bundle/skills/agentera/capabilities/resonera/schemas/triggers.yaml +0 -46
  728. package/bundle/skills/agentera/capabilities/visionera/instructions.md +0 -309
  729. package/bundle/skills/agentera/capabilities/visionera/schemas/triggers.yaml +0 -41
  730. package/bundle/skills/agentera/capabilities/visualisera/instructions.md +0 -400
  731. package/bundle/skills/agentera/capabilities/visualisera/schemas/triggers.yaml +0 -33
  732. package/bundle/skills/hej/.claude-plugin/plugin.json +0 -6
  733. package/bundle/skills/hej/SKILL.md +0 -69
  734. package/bundle/skills/hej/agents/hej.toml +0 -11
  735. package/bundle/skills/hej/agents/openai.yaml +0 -8
  736. package/dist/cli/commands/backfill.js +0 -84
  737. package/dist/cli/commands/backfill.js.map +0 -1
  738. package/dist/cli/commands/state.js +0 -1012
  739. package/dist/cli/commands/state.js.map +0 -1
  740. package/dist/core/git.js +0 -43
  741. package/dist/core/git.js.map +0 -1
  742. package/dist/hooks/compaction.js +0 -935
  743. package/dist/hooks/compaction.js.map +0 -1
  744. package/dist/hooks/validateArtifact.js +0 -933
  745. package/dist/hooks/validateArtifact.js.map +0 -1
  746. package/dist/registries/runtimeAdapterRegistry.js +0 -315
  747. package/dist/registries/runtimeAdapterRegistry.js.map +0 -1
  748. package/dist/setup/copilot.js +0 -227
  749. package/dist/setup/copilot.js.map +0 -1
  750. package/dist/setup/cursor.js +0 -127
  751. package/dist/setup/cursor.js.map +0 -1
  752. package/dist/setup/doctor.js +0 -1276
  753. package/dist/setup/doctor.js.map +0 -1
  754. package/dist/state/progressCommit.js +0 -289
  755. package/dist/state/progressCommit.js.map +0 -1
  756. package/dist/upgrade/migrateArtifactsV1ToV2.js +0 -571
  757. package/dist/upgrade/migrateArtifactsV1ToV2.js.map +0 -1
  758. package/dist/validate/lifecycleAdapters.js +0 -772
  759. package/dist/validate/lifecycleAdapters.js.map +0 -1
  760. /package/bundle/skills/agentera/capabilities/{dokumentera → document}/schemas/exit.yaml +0 -0
  761. /package/bundle/skills/agentera/capabilities/{inspirera → research}/schemas/exit.yaml +0 -0
  762. /package/bundle/skills/agentera/capabilities/{hej → status}/schemas/exit.yaml +0 -0
@@ -0,0 +1,662 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { assertValidatedProjectRoot } from "./projectRoot.js";
5
+ import { reject } from "./write/errors.js";
6
+ const DIRECTORY_FLAGS = fs.constants.O_RDONLY
7
+ | (fs.constants.O_DIRECTORY ?? 0)
8
+ | (fs.constants.O_NOFOLLOW ?? 0);
9
+ const FILE_FLAGS = fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0);
10
+ function samePublished(left, right) {
11
+ return left.dev === right.dev
12
+ && left.ino === right.ino
13
+ && left.type === right.type
14
+ && left.size === right.size
15
+ && left.sha256 === right.sha256;
16
+ }
17
+ function fdPath(fd, name) {
18
+ return name ? `/proc/self/fd/${fd}/${name}` : `/proc/self/fd/${fd}`;
19
+ }
20
+ function identity(stat) {
21
+ return {
22
+ dev: stat.dev,
23
+ ino: stat.ino,
24
+ size: stat.size,
25
+ mtimeNs: stat.mtimeNs,
26
+ ctimeNs: stat.ctimeNs,
27
+ nlink: stat.nlink,
28
+ };
29
+ }
30
+ function sameObject(left, right) {
31
+ return left.dev === right.dev && left.ino === right.ino;
32
+ }
33
+ function sameIdentity(left, right) {
34
+ return left.dev === right.dev
35
+ && left.ino === right.ino
36
+ && left.size === right.size
37
+ && left.mtimeNs === right.mtimeNs
38
+ && left.ctimeNs === right.ctimeNs
39
+ && left.nlink === right.nlink;
40
+ }
41
+ function readDescriptor(fd) {
42
+ const stat = fs.fstatSync(fd, { bigint: true });
43
+ if (!stat.isFile() || stat.size > BigInt(Number.MAX_SAFE_INTEGER)) {
44
+ throw new Error("state mode marker descriptor is not a readable regular file");
45
+ }
46
+ const bytes = Buffer.alloc(Number(stat.size));
47
+ let offset = 0;
48
+ while (offset < bytes.length) {
49
+ const count = fs.readSync(fd, bytes, offset, bytes.length - offset, offset);
50
+ if (count === 0)
51
+ break;
52
+ offset += count;
53
+ }
54
+ if (offset !== bytes.length)
55
+ throw new Error("state mode marker changed while its exact bytes were read");
56
+ return bytes;
57
+ }
58
+ function publishedIdentity(fd) {
59
+ const stat = fs.fstatSync(fd, { bigint: true });
60
+ const bytes = readDescriptor(fd);
61
+ return {
62
+ dev: stat.dev,
63
+ ino: stat.ino,
64
+ type: stat.mode & BigInt(fs.constants.S_IFMT),
65
+ size: stat.size,
66
+ sha256: createHash("sha256").update(bytes).digest("hex"),
67
+ };
68
+ }
69
+ function matchesPublished(fd, expected) {
70
+ const stat = fs.fstatSync(fd, { bigint: true });
71
+ if (stat.dev !== expected.dev
72
+ || stat.ino !== expected.ino
73
+ || (stat.mode & BigInt(fs.constants.S_IFMT)) !== expected.type
74
+ || stat.size !== expected.size)
75
+ return false;
76
+ return createHash("sha256").update(readDescriptor(fd)).digest("hex") === expected.sha256;
77
+ }
78
+ function openMatches(parentFd, name, expectedFd, flags) {
79
+ let observed;
80
+ try {
81
+ observed = fs.openSync(fdPath(parentFd, name), flags);
82
+ return sameObject(fs.fstatSync(observed, { bigint: true }), fs.fstatSync(expectedFd, { bigint: true }));
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ finally {
88
+ if (observed !== undefined)
89
+ fs.closeSync(observed);
90
+ }
91
+ }
92
+ function syncDirectory(fd) {
93
+ fs.fsyncSync(fd);
94
+ }
95
+ function publicationConflict(markerPath) {
96
+ reject({
97
+ class: "conflict",
98
+ message: `state mode marker '${markerPath}' changed after entity mode detection; this is a conflict and cannot fall back to legacy state`,
99
+ syntax: "agentera state <artifact-id> <verb> ... --format json",
100
+ example: `restore the exact '${markerPath}' marker selected at command start and retry`,
101
+ });
102
+ }
103
+ /**
104
+ * Pins one entity write to the root and exact valid marker selected by mode
105
+ * detection. Node cannot combine pathname validation and mutation atomically,
106
+ * so publication uses held directory descriptors, validates before and after
107
+ * every observable boundary, and rolls back only links and empty directories
108
+ * whose descriptor identities still match this attempt. Success linearizes at
109
+ * the final root, marker, directory-chain, and target validation.
110
+ */
111
+ export class EntityPublicationContext {
112
+ projectRoot;
113
+ validatedRoot;
114
+ markerPath;
115
+ rootFd;
116
+ markerParentEntries;
117
+ markerFd;
118
+ markerIdentity;
119
+ markerBytes;
120
+ createdDirectories = new Map();
121
+ closed = false;
122
+ constructor(root, markerPath, expectedBytes) {
123
+ this.projectRoot = root.path;
124
+ this.validatedRoot = root;
125
+ this.markerPath = markerPath;
126
+ this.markerBytes = Buffer.from(expectedBytes);
127
+ this.rootFd = fs.openSync(root.path, DIRECTORY_FLAGS);
128
+ this.markerParentEntries = [];
129
+ let markerFd;
130
+ try {
131
+ const rootStat = fs.fstatSync(this.rootFd, { bigint: true });
132
+ const rootIdentity = root.identities.at(-1);
133
+ if (rootStat.dev !== rootIdentity.dev || rootStat.ino !== rootIdentity.ino) {
134
+ throw new Error(`project root '${root.path}' changed while its publication context was opened`);
135
+ }
136
+ const segments = markerPath.split("/").filter(Boolean);
137
+ let parentFd = this.rootFd;
138
+ for (const name of segments.slice(0, -1)) {
139
+ const fd = fs.openSync(fdPath(parentFd, name), DIRECTORY_FLAGS);
140
+ this.markerParentEntries.push({ parentFd, name, fd, created: false });
141
+ parentFd = fd;
142
+ }
143
+ markerFd = fs.openSync(fdPath(parentFd, segments.at(-1)), FILE_FLAGS);
144
+ const before = fs.fstatSync(markerFd, { bigint: true });
145
+ const bytes = readDescriptor(markerFd);
146
+ const after = fs.fstatSync(markerFd, { bigint: true });
147
+ if (!before.isFile() || !sameIdentity(identity(before), after) || !bytes.equals(expectedBytes)) {
148
+ publicationConflict(markerPath);
149
+ }
150
+ this.markerFd = markerFd;
151
+ this.markerIdentity = identity(after);
152
+ this.assertValid();
153
+ markerFd = undefined;
154
+ }
155
+ catch (error) {
156
+ if (markerFd !== undefined)
157
+ fs.closeSync(markerFd);
158
+ for (const entry of this.markerParentEntries.reverse())
159
+ fs.closeSync(entry.fd);
160
+ fs.closeSync(this.rootFd);
161
+ throw error;
162
+ }
163
+ }
164
+ static open(root, markerPath, expectedBytes) {
165
+ return new EntityPublicationContext(root, markerPath, expectedBytes);
166
+ }
167
+ pinnedPath(relativePath = "") {
168
+ if (this.closed)
169
+ throw new Error("entity publication context is closed");
170
+ return relativePath ? path.join(fdPath(this.rootFd), relativePath) : fdPath(this.rootFd);
171
+ }
172
+ assertValid() {
173
+ if (this.closed)
174
+ throw new Error("entity publication context is closed");
175
+ assertValidatedProjectRoot(this.validatedRoot);
176
+ const currentRoot = fs.fstatSync(this.rootFd, { bigint: true });
177
+ const expectedRoot = this.validatedRoot.identities.at(-1);
178
+ if (currentRoot.dev !== expectedRoot.dev || currentRoot.ino !== expectedRoot.ino) {
179
+ throw new Error(`project root '${this.projectRoot}' changed after validation; restore the exact real directory and retry`);
180
+ }
181
+ for (const entry of this.markerParentEntries) {
182
+ if (!openMatches(entry.parentFd, entry.name, entry.fd, DIRECTORY_FLAGS)) {
183
+ publicationConflict(this.markerPath);
184
+ }
185
+ }
186
+ const parentFd = this.markerParentEntries.at(-1)?.fd ?? this.rootFd;
187
+ const markerName = this.markerPath.split("/").filter(Boolean).at(-1);
188
+ if (!openMatches(parentFd, markerName, this.markerFd, FILE_FLAGS)
189
+ || !sameIdentity(this.markerIdentity, fs.fstatSync(this.markerFd, { bigint: true }))
190
+ || !readDescriptor(this.markerFd).equals(this.markerBytes))
191
+ publicationConflict(this.markerPath);
192
+ }
193
+ publishImmutable(relativeTarget, bytes) {
194
+ const normalized = relativeTarget.split(path.sep).join("/");
195
+ const segments = normalized.split("/").filter(Boolean);
196
+ if (segments.length < 2
197
+ || path.isAbsolute(relativeTarget)
198
+ || segments.includes("..")
199
+ || segments.includes("."))
200
+ throw new Error(`unsafe entity publication target '${relativeTarget}'`);
201
+ this.assertValid();
202
+ const directories = [];
203
+ const createdPaths = [];
204
+ let stageFd;
205
+ let stageName;
206
+ let targetLinked = false;
207
+ try {
208
+ let parentFd = this.rootFd;
209
+ for (const name of segments.slice(0, -1)) {
210
+ this.assertBoundary(directories);
211
+ const entryParentFd = parentFd;
212
+ let fd;
213
+ let created = false;
214
+ try {
215
+ fd = fs.openSync(fdPath(entryParentFd, name), DIRECTORY_FLAGS);
216
+ }
217
+ catch (error) {
218
+ if (error.code !== "ENOENT")
219
+ throw error;
220
+ this.assertBoundary(directories);
221
+ fs.mkdirSync(fdPath(entryParentFd, name));
222
+ created = true;
223
+ fd = fs.openSync(fdPath(entryParentFd, name), DIRECTORY_FLAGS);
224
+ }
225
+ const entry = { parentFd: entryParentFd, name, fd, created };
226
+ directories.push(entry);
227
+ if (created)
228
+ createdPaths.push({ relativePath: segments.slice(0, directories.length).join("/"), fd });
229
+ parentFd = fd;
230
+ if (created)
231
+ syncDirectory(entryParentFd);
232
+ this.assertBoundary(directories);
233
+ }
234
+ const directoryFd = directories.at(-1).fd;
235
+ const targetName = segments.at(-1);
236
+ stageName = `.${targetName}.${process.pid}.${randomUUID()}.tmp`;
237
+ this.assertBoundary(directories);
238
+ stageFd = fs.openSync(fdPath(directoryFd, stageName), fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL | (fs.constants.O_NOFOLLOW ?? 0), 0o600);
239
+ this.assertBoundary(directories, { name: stageName, fd: stageFd });
240
+ fs.writeFileSync(stageFd, bytes, "utf8");
241
+ fs.fsyncSync(stageFd);
242
+ this.assertBoundary(directories, { name: stageName, fd: stageFd });
243
+ try {
244
+ this.assertBoundary(directories, { name: stageName, fd: stageFd });
245
+ fs.linkSync(fdPath(directoryFd, stageName), fdPath(directoryFd, targetName));
246
+ targetLinked = true;
247
+ }
248
+ catch (error) {
249
+ if (error.code !== "EEXIST")
250
+ throw error;
251
+ this.removeOwnedFile(directoryFd, stageName, stageFd);
252
+ stageName = undefined;
253
+ syncDirectory(directoryFd);
254
+ this.assertBoundary(directories);
255
+ this.removeCreatedDirectories(directories);
256
+ return null;
257
+ }
258
+ syncDirectory(directoryFd);
259
+ this.assertBoundary(directories, { name: stageName, fd: stageFd }, { name: targetName, fd: stageFd });
260
+ this.removeOwnedFile(directoryFd, stageName, stageFd);
261
+ stageName = undefined;
262
+ syncDirectory(directoryFd);
263
+ this.assertBoundary(directories, undefined, { name: targetName, fd: stageFd });
264
+ for (const createdPath of createdPaths)
265
+ this.createdDirectories.set(createdPath.relativePath, identity(fs.fstatSync(createdPath.fd, { bigint: true })));
266
+ return publishedIdentity(stageFd);
267
+ }
268
+ catch (error) {
269
+ const directoryFd = directories.at(-1)?.fd;
270
+ const targetName = segments.at(-1);
271
+ const cleanupFailures = [];
272
+ if (directoryFd !== undefined && stageFd !== undefined && targetLinked) {
273
+ try {
274
+ this.removeOwnedFile(directoryFd, targetName, stageFd);
275
+ }
276
+ catch {
277
+ cleanupFailures.push("entity");
278
+ }
279
+ }
280
+ if (directoryFd !== undefined && stageFd !== undefined && stageName !== undefined) {
281
+ try {
282
+ this.removeOwnedFile(directoryFd, stageName, stageFd);
283
+ }
284
+ catch {
285
+ cleanupFailures.push("stage");
286
+ }
287
+ }
288
+ if (directoryFd !== undefined) {
289
+ try {
290
+ syncDirectory(directoryFd);
291
+ }
292
+ catch {
293
+ cleanupFailures.push("directory sync");
294
+ }
295
+ }
296
+ try {
297
+ this.removeCreatedDirectories(directories);
298
+ }
299
+ catch {
300
+ cleanupFailures.push("directory");
301
+ }
302
+ if (cleanupFailures.length > 0) {
303
+ throw new Error(`entity publication failed and exact rollback could not remove its ${cleanupFailures.join(", ")}; inspect the pinned project state before retrying`, { cause: error });
304
+ }
305
+ throw error;
306
+ }
307
+ finally {
308
+ if (stageFd !== undefined)
309
+ fs.closeSync(stageFd);
310
+ for (const entry of directories.reverse())
311
+ fs.closeSync(entry.fd);
312
+ }
313
+ }
314
+ publishPreowned(relativeTarget, relativeReceipt, expected) {
315
+ const targetSegments = relativeTarget.split(path.sep).filter(Boolean);
316
+ const receiptSegments = relativeReceipt.split(path.sep).filter(Boolean);
317
+ if ([targetSegments, receiptSegments].some((segments) => segments.length < 2 || segments.includes("..") || segments.includes("."))
318
+ || path.isAbsolute(relativeTarget) || path.isAbsolute(relativeReceipt))
319
+ throw new Error("unsafe preowned publication path");
320
+ this.assertValid();
321
+ const receiptDirectories = [];
322
+ const targetDirectories = [];
323
+ const createdPaths = [];
324
+ let receiptFd;
325
+ let targetFd;
326
+ let linked = false;
327
+ try {
328
+ let receiptParent = this.rootFd;
329
+ for (const name of receiptSegments.slice(0, -1)) {
330
+ const fd = fs.openSync(fdPath(receiptParent, name), DIRECTORY_FLAGS);
331
+ receiptDirectories.push({ parentFd: receiptParent, name, fd, created: false });
332
+ receiptParent = fd;
333
+ }
334
+ receiptFd = fs.openSync(fdPath(receiptParent, receiptSegments.at(-1)), FILE_FLAGS);
335
+ const receiptIdentity = publishedIdentity(receiptFd);
336
+ if (!samePublished(receiptIdentity, expected))
337
+ throw new Error(`migration ownership receipt '${relativeReceipt}' changed`);
338
+ let targetParent = this.rootFd;
339
+ for (const [index, name] of targetSegments.slice(0, -1).entries()) {
340
+ this.assertBoundary(targetDirectories);
341
+ const parentFd = targetParent;
342
+ let fd;
343
+ let created = false;
344
+ try {
345
+ fd = fs.openSync(fdPath(parentFd, name), DIRECTORY_FLAGS);
346
+ }
347
+ catch (error) {
348
+ if (error.code !== "ENOENT")
349
+ throw error;
350
+ fs.mkdirSync(fdPath(parentFd, name));
351
+ created = true;
352
+ fd = fs.openSync(fdPath(parentFd, name), DIRECTORY_FLAGS);
353
+ syncDirectory(parentFd);
354
+ }
355
+ targetDirectories.push({ parentFd, name, fd, created });
356
+ if (created)
357
+ createdPaths.push({ relativePath: targetSegments.slice(0, index + 1).join("/"), fd });
358
+ targetParent = fd;
359
+ }
360
+ const targetName = targetSegments.at(-1);
361
+ try {
362
+ fs.linkSync(fdPath(receiptParent, receiptSegments.at(-1)), fdPath(targetParent, targetName));
363
+ linked = true;
364
+ syncDirectory(targetParent);
365
+ }
366
+ catch (error) {
367
+ if (error.code !== "EEXIST")
368
+ throw error;
369
+ }
370
+ targetFd = fs.openSync(fdPath(targetParent, targetName), FILE_FLAGS);
371
+ const targetIdentity = publishedIdentity(targetFd);
372
+ if (!sameObject(fs.fstatSync(receiptFd, { bigint: true }), fs.fstatSync(targetFd, { bigint: true })) || !samePublished(targetIdentity, expected)) {
373
+ throw new Error(`canonical target '${relativeTarget}' collides with migration ownership receipt; byte-identical replacement inodes are never adopted`);
374
+ }
375
+ this.assertBoundary(targetDirectories, undefined, { name: targetName, fd: targetFd });
376
+ for (const createdPath of createdPaths)
377
+ this.createdDirectories.set(createdPath.relativePath, identity(fs.fstatSync(createdPath.fd, { bigint: true })));
378
+ return targetIdentity;
379
+ }
380
+ catch (error) {
381
+ const targetParent = targetDirectories.at(-1)?.fd;
382
+ if (linked && targetParent !== undefined && receiptFd !== undefined)
383
+ this.removeOwnedFile(targetParent, targetSegments.at(-1), receiptFd);
384
+ this.removeCreatedDirectories(targetDirectories);
385
+ throw error;
386
+ }
387
+ finally {
388
+ if (targetFd !== undefined)
389
+ fs.closeSync(targetFd);
390
+ if (receiptFd !== undefined)
391
+ fs.closeSync(receiptFd);
392
+ for (const entry of targetDirectories.reverse())
393
+ fs.closeSync(entry.fd);
394
+ for (const entry of receiptDirectories.reverse())
395
+ fs.closeSync(entry.fd);
396
+ }
397
+ }
398
+ removeExact(relativeTarget, expected) {
399
+ const segments = relativeTarget.split(path.sep).filter(Boolean);
400
+ if (segments.length < 2 || path.isAbsolute(relativeTarget) || segments.includes("..") || segments.includes("."))
401
+ throw new Error(`unsafe entity rollback target '${relativeTarget}'`);
402
+ const directories = [];
403
+ let targetFd;
404
+ try {
405
+ let parentFd = this.rootFd;
406
+ for (const name of segments.slice(0, -1)) {
407
+ let fd;
408
+ try {
409
+ fd = fs.openSync(fdPath(parentFd, name), DIRECTORY_FLAGS);
410
+ }
411
+ catch (error) {
412
+ if (error.code === "ENOENT")
413
+ return "absent";
414
+ throw error;
415
+ }
416
+ directories.push({ parentFd, name, fd, created: false });
417
+ parentFd = fd;
418
+ }
419
+ const directoryFd = directories.at(-1).fd;
420
+ const targetName = segments.at(-1);
421
+ try {
422
+ targetFd = fs.openSync(fdPath(directoryFd, targetName), FILE_FLAGS);
423
+ }
424
+ catch (error) {
425
+ if (error.code === "ENOENT")
426
+ return "absent";
427
+ throw error;
428
+ }
429
+ if (!matchesPublished(targetFd, expected))
430
+ return "identity_mismatch";
431
+ const rollbackName = `.${targetName}.${process.pid}.${randomUUID()}.rollback`;
432
+ fs.renameSync(fdPath(directoryFd, targetName), fdPath(directoryFd, rollbackName));
433
+ if (openMatches(directoryFd, rollbackName, targetFd, FILE_FLAGS)) {
434
+ this.removeOwnedFile(directoryFd, rollbackName, targetFd);
435
+ }
436
+ else {
437
+ try {
438
+ fs.linkSync(fdPath(directoryFd, rollbackName), fdPath(directoryFd, targetName));
439
+ fs.unlinkSync(fdPath(directoryFd, rollbackName));
440
+ }
441
+ catch (error) {
442
+ if (error.code !== "EEXIST")
443
+ throw error;
444
+ }
445
+ syncDirectory(directoryFd);
446
+ return "identity_mismatch";
447
+ }
448
+ syncDirectory(directoryFd);
449
+ return "removed";
450
+ }
451
+ finally {
452
+ if (targetFd !== undefined)
453
+ fs.closeSync(targetFd);
454
+ for (const entry of directories.reverse())
455
+ fs.closeSync(entry.fd);
456
+ this.removeAttemptDirectories();
457
+ }
458
+ }
459
+ removeAttemptDirectories() {
460
+ const paths = [...this.createdDirectories.keys()].sort((left, right) => right.split("/").length - left.split("/").length);
461
+ for (const relativePath of paths) {
462
+ const segments = relativePath.split("/");
463
+ const descriptors = [];
464
+ let targetFd;
465
+ let parentFd = this.rootFd;
466
+ try {
467
+ for (const name of segments.slice(0, -1)) {
468
+ const fd = fs.openSync(fdPath(parentFd, name), DIRECTORY_FLAGS);
469
+ descriptors.push(fd);
470
+ parentFd = fd;
471
+ }
472
+ targetFd = fs.openSync(fdPath(parentFd, segments.at(-1)), DIRECTORY_FLAGS);
473
+ const expected = this.createdDirectories.get(relativePath);
474
+ const observed = fs.fstatSync(targetFd, { bigint: true });
475
+ if (observed.dev !== expected.dev || observed.ino !== expected.ino) {
476
+ this.createdDirectories.delete(relativePath);
477
+ continue;
478
+ }
479
+ fs.rmdirSync(fdPath(parentFd, segments.at(-1)));
480
+ syncDirectory(parentFd);
481
+ this.createdDirectories.delete(relativePath);
482
+ }
483
+ catch (error) {
484
+ const code = error.code ?? "";
485
+ if (code === "ENOENT")
486
+ this.createdDirectories.delete(relativePath);
487
+ else if (!["ENOTEMPTY", "EEXIST"].includes(code))
488
+ throw error;
489
+ }
490
+ finally {
491
+ if (targetFd !== undefined)
492
+ fs.closeSync(targetFd);
493
+ for (const fd of descriptors.reverse())
494
+ fs.closeSync(fd);
495
+ }
496
+ }
497
+ }
498
+ replaceExisting(relativeTarget, expectedBytes, bytes) {
499
+ return this.replaceOwned(relativeTarget, expectedBytes, bytes);
500
+ }
501
+ restoreExact(relativeTarget, expected, bytes) {
502
+ // Recovery stays bound to the pinned root and exact archived target even when context invalidation caused the primary failure.
503
+ return this.replaceOwned(relativeTarget, expected, bytes, false);
504
+ }
505
+ replaceOwned(relativeTarget, expected, bytes, verifyContext = true) {
506
+ const segments = relativeTarget.split(path.sep).filter(Boolean);
507
+ if (segments.length < 2 || path.isAbsolute(relativeTarget) || segments.includes("..") || segments.includes("."))
508
+ throw new Error(`unsafe entity replacement target '${relativeTarget}'`);
509
+ const directories = [];
510
+ let targetFd;
511
+ let stageFd;
512
+ let stageName;
513
+ let backupName;
514
+ let displacedName;
515
+ let displacedFd;
516
+ let displacedOwned = false;
517
+ let replacementVisible = false;
518
+ try {
519
+ let parentFd = this.rootFd;
520
+ for (const name of segments.slice(0, -1)) {
521
+ const fd = fs.openSync(fdPath(parentFd, name), DIRECTORY_FLAGS);
522
+ directories.push({ parentFd, name, fd, created: false });
523
+ parentFd = fd;
524
+ }
525
+ const directoryFd = directories.at(-1).fd;
526
+ const targetName = segments.at(-1);
527
+ targetFd = fs.openSync(fdPath(directoryFd, targetName), FILE_FLAGS);
528
+ this.assertBoundary(directories, undefined, { name: targetName, fd: targetFd }, verifyContext);
529
+ const previousBytes = readDescriptor(targetFd);
530
+ if (typeof expected === "string" ? !previousBytes.equals(Buffer.from(expected)) : !matchesPublished(targetFd, expected))
531
+ throw new Error(`entity '${relativeTarget}' ownership changed before replacement; preserve both changes and retry explicitly`);
532
+ backupName = `.${targetName}.${process.pid}.${randomUUID()}.previous`;
533
+ fs.linkSync(fdPath(directoryFd, targetName), fdPath(directoryFd, backupName));
534
+ if (!openMatches(directoryFd, backupName, targetFd, FILE_FLAGS))
535
+ throw new Error(`entity '${relativeTarget}' prior value could not be pinned for replacement`);
536
+ stageName = `.${targetName}.${process.pid}.${randomUUID()}.tmp`;
537
+ stageFd = fs.openSync(fdPath(directoryFd, stageName), fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL | (fs.constants.O_NOFOLLOW ?? 0), 0o600);
538
+ fs.writeFileSync(stageFd, bytes, "utf8");
539
+ fs.fsyncSync(stageFd);
540
+ this.assertBoundary(directories, { name: stageName, fd: stageFd }, { name: targetName, fd: targetFd }, verifyContext);
541
+ if (verifyContext) {
542
+ fs.renameSync(fdPath(directoryFd, stageName), fdPath(directoryFd, targetName));
543
+ replacementVisible = true;
544
+ stageName = undefined;
545
+ }
546
+ else {
547
+ displacedName = `.${targetName}.${process.pid}.${randomUUID()}.displaced`;
548
+ fs.renameSync(fdPath(directoryFd, targetName), fdPath(directoryFd, displacedName));
549
+ displacedFd = fs.openSync(fdPath(directoryFd, displacedName), FILE_FLAGS);
550
+ if (typeof expected === "string" || !matchesPublished(displacedFd, expected)) {
551
+ try {
552
+ fs.linkSync(fdPath(directoryFd, displacedName), fdPath(directoryFd, targetName));
553
+ if (!openMatches(directoryFd, targetName, displacedFd, FILE_FLAGS))
554
+ throw new Error("competing entity could not be returned to its pathname");
555
+ syncDirectory(directoryFd);
556
+ }
557
+ catch (restoreError) {
558
+ throw new Error(`entity '${relativeTarget}' ownership changed immediately before restoration; competing bytes remain at '${displacedName}'`, { cause: restoreError });
559
+ }
560
+ throw new Error(`entity '${relativeTarget}' ownership changed immediately before restoration; competing bytes were preserved at the target and '${displacedName}'`);
561
+ }
562
+ displacedOwned = true;
563
+ try {
564
+ fs.linkSync(fdPath(directoryFd, stageName), fdPath(directoryFd, targetName));
565
+ }
566
+ catch (publishError) {
567
+ if (publishError.code === "EEXIST")
568
+ throw new Error(`entity '${relativeTarget}' ownership changed during no-clobber restoration publication; competing bytes were preserved`, { cause: publishError });
569
+ throw publishError;
570
+ }
571
+ replacementVisible = true;
572
+ this.removeOwnedFile(directoryFd, stageName, stageFd);
573
+ stageName = undefined;
574
+ this.removeOwnedFile(directoryFd, displacedName, targetFd);
575
+ displacedName = undefined;
576
+ }
577
+ syncDirectory(directoryFd);
578
+ this.assertBoundary(directories, undefined, { name: targetName, fd: stageFd }, verifyContext);
579
+ this.removeOwnedFile(directoryFd, backupName, targetFd);
580
+ backupName = undefined;
581
+ return { previousBytes: previousBytes.toString("utf8"), publishedIdentity: publishedIdentity(stageFd) };
582
+ }
583
+ catch (error) {
584
+ const directoryFd = directories.at(-1)?.fd;
585
+ if (verifyContext && replacementVisible && directoryFd !== undefined && stageFd !== undefined && targetFd !== undefined) {
586
+ const ownsReplacement = openMatches(directoryFd, segments.at(-1), stageFd, FILE_FLAGS);
587
+ const ownsPrior = backupName !== undefined && openMatches(directoryFd, backupName, targetFd, FILE_FLAGS);
588
+ if (ownsReplacement && ownsPrior) {
589
+ fs.renameSync(fdPath(directoryFd, backupName), fdPath(directoryFd, segments.at(-1)));
590
+ backupName = undefined;
591
+ syncDirectory(directoryFd);
592
+ }
593
+ else if (ownsReplacement) {
594
+ throw new Error(`entity '${relativeTarget}' replacement failed and its descriptor-pinned prior value could not be restored`, { cause: error });
595
+ }
596
+ }
597
+ throw error;
598
+ }
599
+ finally {
600
+ const directoryFd = directories.at(-1)?.fd;
601
+ if (directoryFd !== undefined && stageFd !== undefined && stageName !== undefined)
602
+ this.removeOwnedFile(directoryFd, stageName, stageFd);
603
+ if (directoryFd !== undefined && targetFd !== undefined && backupName !== undefined)
604
+ this.removeOwnedFile(directoryFd, backupName, targetFd);
605
+ if (directoryFd !== undefined && targetFd !== undefined && displacedName !== undefined && displacedOwned)
606
+ this.removeOwnedFile(directoryFd, displacedName, targetFd);
607
+ if (displacedFd !== undefined)
608
+ fs.closeSync(displacedFd);
609
+ if (stageFd !== undefined)
610
+ fs.closeSync(stageFd);
611
+ if (targetFd !== undefined)
612
+ fs.closeSync(targetFd);
613
+ for (const entry of directories.reverse())
614
+ fs.closeSync(entry.fd);
615
+ }
616
+ }
617
+ close() {
618
+ if (this.closed)
619
+ return;
620
+ this.closed = true;
621
+ fs.closeSync(this.markerFd);
622
+ for (const entry of this.markerParentEntries.reverse())
623
+ fs.closeSync(entry.fd);
624
+ fs.closeSync(this.rootFd);
625
+ }
626
+ assertBoundary(directories, stage, target, verifyContext = true) {
627
+ if (verifyContext)
628
+ this.assertValid();
629
+ for (const entry of directories) {
630
+ if (!openMatches(entry.parentFd, entry.name, entry.fd, DIRECTORY_FLAGS)) {
631
+ throw new Error(`entity publication directory '${entry.name}' changed during publication`);
632
+ }
633
+ }
634
+ const directoryFd = directories.at(-1)?.fd;
635
+ if (directoryFd !== undefined && stage && !openMatches(directoryFd, stage.name, stage.fd, FILE_FLAGS)) {
636
+ throw new Error("entity publication stage changed during publication");
637
+ }
638
+ if (directoryFd !== undefined && target && !openMatches(directoryFd, target.name, target.fd, FILE_FLAGS)) {
639
+ throw new Error("entity publication target changed during publication");
640
+ }
641
+ }
642
+ removeOwnedFile(parentFd, name, expectedFd) {
643
+ if (!openMatches(parentFd, name, expectedFd, FILE_FLAGS))
644
+ return;
645
+ fs.unlinkSync(fdPath(parentFd, name));
646
+ }
647
+ removeCreatedDirectories(directories) {
648
+ for (const entry of [...directories].reverse()) {
649
+ if (!entry.created || !openMatches(entry.parentFd, entry.name, entry.fd, DIRECTORY_FLAGS))
650
+ continue;
651
+ try {
652
+ fs.rmdirSync(fdPath(entry.parentFd, entry.name));
653
+ syncDirectory(entry.parentFd);
654
+ }
655
+ catch (error) {
656
+ if (!["ENOTEMPTY", "EEXIST", "ENOENT"].includes(error.code ?? ""))
657
+ throw error;
658
+ }
659
+ }
660
+ }
661
+ }
662
+ //# sourceMappingURL=entityPublicationContext.js.map