@rpamis/comet 0.4.3 → 0.4.5

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 (464) hide show
  1. package/README.md +372 -332
  2. package/assets/manifest.json +1 -1
  3. package/assets/skills/comet/scripts/comet-archive.mjs +113 -97
  4. package/assets/skills/comet/scripts/comet-check.mjs +117 -104
  5. package/assets/skills/comet/scripts/comet-entry-runtime.mjs +59 -59
  6. package/assets/skills/comet/scripts/comet-guard.mjs +170 -157
  7. package/assets/skills/comet/scripts/comet-handoff.mjs +110 -97
  8. package/assets/skills/comet/scripts/comet-hook-guard.mjs +110 -97
  9. package/assets/skills/comet/scripts/comet-hook-router.mjs +272 -153
  10. package/assets/skills/comet/scripts/comet-intent.mjs +31 -31
  11. package/assets/skills/comet/scripts/comet-resume-probe.mjs +104 -91
  12. package/assets/skills/comet/scripts/comet-runtime.mjs +311 -296
  13. package/assets/skills/comet/scripts/comet-state.mjs +221 -207
  14. package/assets/skills/comet/scripts/comet-yaml-validate.mjs +25 -25
  15. package/assets/skills/comet-archive/SKILL.md +13 -9
  16. package/assets/skills/comet-build/SKILL.md +4 -6
  17. package/assets/skills/comet-classic/SKILL.md +1 -1
  18. package/assets/skills/comet-classic/reference/scripts.md +9 -1
  19. package/assets/skills/comet-design/SKILL.md +0 -2
  20. package/assets/skills/comet-hotfix/SKILL.md +1 -3
  21. package/assets/skills/comet-native/SKILL.md +8 -7
  22. package/assets/skills/comet-native/reference/artifacts.md +51 -7
  23. package/assets/skills/comet-native/reference/clarification.md +5 -5
  24. package/assets/skills/comet-native/reference/commands.md +15 -13
  25. package/assets/skills/comet-native/reference/recovery.md +3 -3
  26. package/assets/skills/comet-native/reference/workspace.md +10 -4
  27. package/assets/skills/comet-native/scripts/comet-native-archive.mjs +257 -169
  28. package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +238 -153
  29. package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +241 -124
  30. package/assets/skills/comet-native/scripts/comet-native-init.mjs +189 -108
  31. package/assets/skills/comet-native/scripts/comet-native-new.mjs +220 -139
  32. package/assets/skills/comet-native/scripts/comet-native-next.mjs +245 -160
  33. package/assets/skills/comet-native/scripts/comet-native-root.mjs +210 -129
  34. package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +284 -196
  35. package/assets/skills/comet-native/scripts/comet-native-select.mjs +212 -128
  36. package/assets/skills/comet-native/scripts/comet-native-show.mjs +207 -126
  37. package/assets/skills/comet-native/scripts/comet-native-spec.mjs +203 -118
  38. package/assets/skills/comet-native/scripts/comet-native-status.mjs +208 -124
  39. package/assets/skills/comet-open/SKILL.md +0 -2
  40. package/assets/skills/comet-tweak/SKILL.md +1 -1
  41. package/assets/skills/comet-verify/SKILL.md +0 -2
  42. package/assets/skills-zh/comet-archive/SKILL.md +13 -9
  43. package/assets/skills-zh/comet-build/SKILL.md +4 -6
  44. package/assets/skills-zh/comet-classic/SKILL.md +1 -1
  45. package/assets/skills-zh/comet-classic/reference/scripts.md +9 -1
  46. package/assets/skills-zh/comet-design/SKILL.md +0 -2
  47. package/assets/skills-zh/comet-hotfix/SKILL.md +1 -3
  48. package/assets/skills-zh/comet-native/SKILL.md +8 -7
  49. package/assets/skills-zh/comet-native/reference/artifacts.md +51 -7
  50. package/assets/skills-zh/comet-native/reference/clarification.md +5 -5
  51. package/assets/skills-zh/comet-native/reference/commands.md +16 -10
  52. package/assets/skills-zh/comet-native/reference/recovery.md +3 -3
  53. package/assets/skills-zh/comet-native/reference/workspace.md +10 -4
  54. package/assets/skills-zh/comet-open/SKILL.md +0 -2
  55. package/assets/skills-zh/comet-tweak/SKILL.md +1 -1
  56. package/assets/skills-zh/comet-verify/SKILL.md +0 -2
  57. package/bin/comet-daemon-router.js +23 -7
  58. package/bin/fast-runtime-router.js +1 -1
  59. package/dist/app/cli/index.js +1 -0
  60. package/dist/app/cli/index.js.map +1 -1
  61. package/dist/app/commands/daemon-server.d.ts.map +1 -1
  62. package/dist/app/commands/daemon-server.js +13 -2
  63. package/dist/app/commands/daemon-server.js.map +1 -1
  64. package/dist/app/commands/doctor.d.ts.map +1 -1
  65. package/dist/app/commands/doctor.js +17 -10
  66. package/dist/app/commands/doctor.js.map +1 -1
  67. package/dist/app/commands/i18n.d.ts +1 -1
  68. package/dist/app/commands/i18n.d.ts.map +1 -1
  69. package/dist/app/commands/i18n.js +4 -0
  70. package/dist/app/commands/i18n.js.map +1 -1
  71. package/dist/app/commands/project-knowledge.d.ts +2 -0
  72. package/dist/app/commands/project-knowledge.d.ts.map +1 -1
  73. package/dist/app/commands/project-knowledge.js +64 -7
  74. package/dist/app/commands/project-knowledge.js.map +1 -1
  75. package/dist/app/commands/uninstall.d.ts +1 -0
  76. package/dist/app/commands/uninstall.d.ts.map +1 -1
  77. package/dist/app/commands/uninstall.js +65 -10
  78. package/dist/app/commands/uninstall.js.map +1 -1
  79. package/dist/domains/agent-learning/coordinator.d.ts +8 -1
  80. package/dist/domains/agent-learning/coordinator.d.ts.map +1 -1
  81. package/dist/domains/agent-learning/coordinator.js +58 -0
  82. package/dist/domains/agent-learning/coordinator.js.map +1 -1
  83. package/dist/domains/agent-learning/experience-journal.d.ts +21 -1
  84. package/dist/domains/agent-learning/experience-journal.d.ts.map +1 -1
  85. package/dist/domains/agent-learning/experience-journal.js +190 -11
  86. package/dist/domains/agent-learning/experience-journal.js.map +1 -1
  87. package/dist/domains/bundle/bundle-platform.d.ts.map +1 -1
  88. package/dist/domains/bundle/bundle-platform.js +6 -1
  89. package/dist/domains/bundle/bundle-platform.js.map +1 -1
  90. package/dist/domains/comet-classic/classic-archive-entry.d.ts +1 -1
  91. package/dist/domains/comet-classic/classic-archive-entry.d.ts.map +1 -1
  92. package/dist/domains/comet-classic/classic-archive-entry.js +5 -2
  93. package/dist/domains/comet-classic/classic-archive-entry.js.map +1 -1
  94. package/dist/domains/comet-classic/classic-archive.d.ts.map +1 -1
  95. package/dist/domains/comet-classic/classic-archive.js +5 -1
  96. package/dist/domains/comet-classic/classic-archive.js.map +1 -1
  97. package/dist/domains/comet-classic/classic-branch-binding.d.ts.map +1 -1
  98. package/dist/domains/comet-classic/classic-branch-binding.js +5 -4
  99. package/dist/domains/comet-classic/classic-branch-binding.js.map +1 -1
  100. package/dist/domains/comet-classic/classic-check-entry.d.ts +1 -1
  101. package/dist/domains/comet-classic/classic-check-entry.d.ts.map +1 -1
  102. package/dist/domains/comet-classic/classic-check-entry.js +5 -2
  103. package/dist/domains/comet-classic/classic-check-entry.js.map +1 -1
  104. package/dist/domains/comet-classic/classic-check-snapshot.d.ts.map +1 -1
  105. package/dist/domains/comet-classic/classic-check-snapshot.js +68 -26
  106. package/dist/domains/comet-classic/classic-check-snapshot.js.map +1 -1
  107. package/dist/domains/comet-classic/classic-design-readiness.d.ts +1 -1
  108. package/dist/domains/comet-classic/classic-guard-entry.d.ts +1 -1
  109. package/dist/domains/comet-classic/classic-guard-entry.d.ts.map +1 -1
  110. package/dist/domains/comet-classic/classic-guard-entry.js +5 -2
  111. package/dist/domains/comet-classic/classic-guard-entry.js.map +1 -1
  112. package/dist/domains/comet-classic/classic-handoff-entry.d.ts +1 -1
  113. package/dist/domains/comet-classic/classic-handoff-entry.d.ts.map +1 -1
  114. package/dist/domains/comet-classic/classic-handoff-entry.js +5 -2
  115. package/dist/domains/comet-classic/classic-handoff-entry.js.map +1 -1
  116. package/dist/domains/comet-classic/classic-progress.d.ts +60 -2
  117. package/dist/domains/comet-classic/classic-progress.d.ts.map +1 -1
  118. package/dist/domains/comet-classic/classic-progress.js +199 -22
  119. package/dist/domains/comet-classic/classic-progress.js.map +1 -1
  120. package/dist/domains/comet-classic/classic-recovery.d.ts +20 -1
  121. package/dist/domains/comet-classic/classic-recovery.d.ts.map +1 -1
  122. package/dist/domains/comet-classic/classic-resume-probe.d.ts.map +1 -1
  123. package/dist/domains/comet-classic/classic-resume-probe.js +3 -2
  124. package/dist/domains/comet-classic/classic-resume-probe.js.map +1 -1
  125. package/dist/domains/comet-classic/classic-script-entry.d.ts +3 -1
  126. package/dist/domains/comet-classic/classic-script-entry.d.ts.map +1 -1
  127. package/dist/domains/comet-classic/classic-script-entry.js +34 -3
  128. package/dist/domains/comet-classic/classic-script-entry.js.map +1 -1
  129. package/dist/domains/comet-classic/classic-state-command.d.ts.map +1 -1
  130. package/dist/domains/comet-classic/classic-state-command.js +3 -2
  131. package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
  132. package/dist/domains/comet-classic/classic-state-entry.d.ts +1 -1
  133. package/dist/domains/comet-classic/classic-state-entry.d.ts.map +1 -1
  134. package/dist/domains/comet-classic/classic-state-entry.js +5 -2
  135. package/dist/domains/comet-classic/classic-state-entry.js.map +1 -1
  136. package/dist/domains/comet-classic/classic-store.d.ts.map +1 -1
  137. package/dist/domains/comet-classic/classic-store.js +67 -1
  138. package/dist/domains/comet-classic/classic-store.js.map +1 -1
  139. package/dist/domains/comet-entry/resume-probe.d.ts.map +1 -1
  140. package/dist/domains/comet-entry/resume-probe.js +3 -2
  141. package/dist/domains/comet-entry/resume-probe.js.map +1 -1
  142. package/dist/domains/comet-native/native-acceptance.d.ts +5 -1
  143. package/dist/domains/comet-native/native-acceptance.d.ts.map +1 -1
  144. package/dist/domains/comet-native/native-acceptance.js +13 -2
  145. package/dist/domains/comet-native/native-acceptance.js.map +1 -1
  146. package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
  147. package/dist/domains/comet-native/native-archive-command.js +167 -37
  148. package/dist/domains/comet-native/native-archive-command.js.map +1 -1
  149. package/dist/domains/comet-native/native-artifact-language.d.ts +10 -1
  150. package/dist/domains/comet-native/native-artifact-language.d.ts.map +1 -1
  151. package/dist/domains/comet-native/native-artifact-language.js +65 -12
  152. package/dist/domains/comet-native/native-artifact-language.js.map +1 -1
  153. package/dist/domains/comet-native/native-artifacts.d.ts +10 -1
  154. package/dist/domains/comet-native/native-artifacts.d.ts.map +1 -1
  155. package/dist/domains/comet-native/native-artifacts.js +130 -21
  156. package/dist/domains/comet-native/native-artifacts.js.map +1 -1
  157. package/dist/domains/comet-native/native-builder-acceptance-review.d.ts +16 -0
  158. package/dist/domains/comet-native/native-builder-acceptance-review.d.ts.map +1 -0
  159. package/dist/domains/comet-native/native-builder-acceptance-review.js +65 -0
  160. package/dist/domains/comet-native/native-builder-acceptance-review.js.map +1 -0
  161. package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
  162. package/dist/domains/comet-native/native-cli-help.js +8 -4
  163. package/dist/domains/comet-native/native-cli-help.js.map +1 -1
  164. package/dist/domains/comet-native/native-cli-shared.d.ts +4 -2
  165. package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
  166. package/dist/domains/comet-native/native-cli-shared.js +37 -9
  167. package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
  168. package/dist/domains/comet-native/native-cli.d.ts +4 -1
  169. package/dist/domains/comet-native/native-cli.d.ts.map +1 -1
  170. package/dist/domains/comet-native/native-cli.js +9 -5
  171. package/dist/domains/comet-native/native-cli.js.map +1 -1
  172. package/dist/domains/comet-native/native-doctor-command.d.ts.map +1 -1
  173. package/dist/domains/comet-native/native-doctor-command.js +144 -3
  174. package/dist/domains/comet-native/native-doctor-command.js.map +1 -1
  175. package/dist/domains/comet-native/native-git-provenance.d.ts.map +1 -1
  176. package/dist/domains/comet-native/native-git-provenance.js +3 -2
  177. package/dist/domains/comet-native/native-git-provenance.js.map +1 -1
  178. package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
  179. package/dist/domains/comet-native/native-hook-guard.js +57 -26
  180. package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
  181. package/dist/domains/comet-native/native-local-execution.d.ts +1 -0
  182. package/dist/domains/comet-native/native-local-execution.d.ts.map +1 -1
  183. package/dist/domains/comet-native/native-local-execution.js +7 -0
  184. package/dist/domains/comet-native/native-local-execution.js.map +1 -1
  185. package/dist/domains/comet-native/native-lock.d.ts.map +1 -1
  186. package/dist/domains/comet-native/native-lock.js +12 -0
  187. package/dist/domains/comet-native/native-lock.js.map +1 -1
  188. package/dist/domains/comet-native/native-loop-runtime.d.ts +2 -0
  189. package/dist/domains/comet-native/native-loop-runtime.d.ts.map +1 -1
  190. package/dist/domains/comet-native/native-loop-runtime.js +6 -0
  191. package/dist/domains/comet-native/native-loop-runtime.js.map +1 -1
  192. package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
  193. package/dist/domains/comet-native/native-next-command.js +57 -28
  194. package/dist/domains/comet-native/native-next-command.js.map +1 -1
  195. package/dist/domains/comet-native/native-output-language.d.ts.map +1 -1
  196. package/dist/domains/comet-native/native-output-language.js +7 -0
  197. package/dist/domains/comet-native/native-output-language.js.map +1 -1
  198. package/dist/domains/comet-native/native-portable-acceptance.d.ts +2 -0
  199. package/dist/domains/comet-native/native-portable-acceptance.d.ts.map +1 -1
  200. package/dist/domains/comet-native/native-portable-acceptance.js +11 -1
  201. package/dist/domains/comet-native/native-portable-acceptance.js.map +1 -1
  202. package/dist/domains/comet-native/native-portable-archive.d.ts +1 -0
  203. package/dist/domains/comet-native/native-portable-archive.d.ts.map +1 -1
  204. package/dist/domains/comet-native/native-portable-archive.js +3 -0
  205. package/dist/domains/comet-native/native-portable-archive.js.map +1 -1
  206. package/dist/domains/comet-native/native-portable-checks.d.ts +14 -4
  207. package/dist/domains/comet-native/native-portable-checks.d.ts.map +1 -1
  208. package/dist/domains/comet-native/native-portable-checks.js +159 -60
  209. package/dist/domains/comet-native/native-portable-checks.js.map +1 -1
  210. package/dist/domains/comet-native/native-portable-continuation.d.ts +2 -1
  211. package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
  212. package/dist/domains/comet-native/native-portable-continuation.js +121 -39
  213. package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
  214. package/dist/domains/comet-native/native-portable-requirements.d.ts +1 -0
  215. package/dist/domains/comet-native/native-portable-requirements.d.ts.map +1 -1
  216. package/dist/domains/comet-native/native-portable-requirements.js +68 -18
  217. package/dist/domains/comet-native/native-portable-requirements.js.map +1 -1
  218. package/dist/domains/comet-native/native-portable-shape-coordination.d.ts.map +1 -1
  219. package/dist/domains/comet-native/native-portable-shape-coordination.js +18 -5
  220. package/dist/domains/comet-native/native-portable-shape-coordination.js.map +1 -1
  221. package/dist/domains/comet-native/native-portable-state.d.ts.map +1 -1
  222. package/dist/domains/comet-native/native-portable-state.js +12 -3
  223. package/dist/domains/comet-native/native-portable-state.js.map +1 -1
  224. package/dist/domains/comet-native/native-portable-status.d.ts.map +1 -1
  225. package/dist/domains/comet-native/native-portable-status.js +10 -4
  226. package/dist/domains/comet-native/native-portable-status.js.map +1 -1
  227. package/dist/domains/comet-native/native-portable-types.d.ts +2 -1
  228. package/dist/domains/comet-native/native-portable-types.d.ts.map +1 -1
  229. package/dist/domains/comet-native/native-portable-types.js.map +1 -1
  230. package/dist/domains/comet-native/native-portable-verification.d.ts +3 -0
  231. package/dist/domains/comet-native/native-portable-verification.d.ts.map +1 -1
  232. package/dist/domains/comet-native/native-portable-verification.js +28 -35
  233. package/dist/domains/comet-native/native-portable-verification.js.map +1 -1
  234. package/dist/domains/comet-native/native-portable-verifier-coordination.d.ts +2 -0
  235. package/dist/domains/comet-native/native-portable-verifier-coordination.d.ts.map +1 -1
  236. package/dist/domains/comet-native/native-portable-verifier-coordination.js +9 -0
  237. package/dist/domains/comet-native/native-portable-verifier-coordination.js.map +1 -1
  238. package/dist/domains/comet-native/native-runner-input-artifacts.d.ts +9 -0
  239. package/dist/domains/comet-native/native-runner-input-artifacts.d.ts.map +1 -0
  240. package/dist/domains/comet-native/native-runner-input-artifacts.js +102 -0
  241. package/dist/domains/comet-native/native-runner-input-artifacts.js.map +1 -0
  242. package/dist/domains/comet-native/native-runner-input.d.ts +90 -64
  243. package/dist/domains/comet-native/native-runner-input.d.ts.map +1 -1
  244. package/dist/domains/comet-native/native-runner-input.js +107 -22
  245. package/dist/domains/comet-native/native-runner-input.js.map +1 -1
  246. package/dist/domains/comet-native/native-script-entry.d.ts.map +1 -1
  247. package/dist/domains/comet-native/native-script-entry.js +9 -3
  248. package/dist/domains/comet-native/native-script-entry.js.map +1 -1
  249. package/dist/domains/comet-native/native-snapshot.d.ts.map +1 -1
  250. package/dist/domains/comet-native/native-snapshot.js +7 -2
  251. package/dist/domains/comet-native/native-snapshot.js.map +1 -1
  252. package/dist/domains/comet-native/native-verification-receipt-runtime.d.ts.map +1 -1
  253. package/dist/domains/comet-native/native-verification-receipt-runtime.js +5 -4
  254. package/dist/domains/comet-native/native-verification-receipt-runtime.js.map +1 -1
  255. package/dist/domains/comet-native/native-workspace-finish.d.ts +26 -0
  256. package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
  257. package/dist/domains/comet-native/native-workspace-finish.js +520 -15
  258. package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
  259. package/dist/domains/comet-plugin/integration.d.ts +1 -0
  260. package/dist/domains/comet-plugin/integration.d.ts.map +1 -1
  261. package/dist/domains/comet-plugin/integration.js +20 -10
  262. package/dist/domains/comet-plugin/integration.js.map +1 -1
  263. package/dist/domains/comet-plugin/plugin-runtime.d.ts +8 -2
  264. package/dist/domains/comet-plugin/plugin-runtime.d.ts.map +1 -1
  265. package/dist/domains/comet-plugin/plugin-runtime.js +18 -4
  266. package/dist/domains/comet-plugin/plugin-runtime.js.map +1 -1
  267. package/dist/domains/dashboard/project-directory.d.ts +4 -0
  268. package/dist/domains/dashboard/project-directory.d.ts.map +1 -1
  269. package/dist/domains/dashboard/project-directory.js +30 -2
  270. package/dist/domains/dashboard/project-directory.js.map +1 -1
  271. package/dist/domains/dashboard/server.d.ts.map +1 -1
  272. package/dist/domains/dashboard/server.js +28 -3
  273. package/dist/domains/dashboard/server.js.map +1 -1
  274. package/dist/domains/dashboard/web/assets/{abnfDiagram-VCTEODGH-qlcciI25.js → abnfDiagram-VCTEODGH-m9_t3fwH.js} +1 -1
  275. package/dist/domains/dashboard/web/assets/{arc-KVm4k9kp.js → arc-CDiwRrMg.js} +1 -1
  276. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-ypJOsR2Y.js +1 -0
  277. package/dist/domains/dashboard/web/assets/{architectureDiagram-5GKGNRK7-C366RdBK.js → architectureDiagram-5GKGNRK7-Xwj-hlQB.js} +1 -1
  278. package/dist/domains/dashboard/web/assets/{blockDiagram-I7D4REHJ-DAuTc2OO.js → blockDiagram-I7D4REHJ-Cme6qNK_.js} +1 -1
  279. package/dist/domains/dashboard/web/assets/{c4Diagram-7LVT6UL2-CFB0RZmL.js → c4Diagram-7LVT6UL2-Cxs1dU7y.js} +1 -1
  280. package/dist/domains/dashboard/web/assets/channel-BFTjR7Ng.js +1 -0
  281. package/dist/domains/dashboard/web/assets/{chunk-4HAMMTFA-DTV6lyGQ.js → chunk-4HAMMTFA-DBQykIWE.js} +1 -1
  282. package/dist/domains/dashboard/web/assets/{chunk-75Z2AOVW-DgJm4cEX.js → chunk-75Z2AOVW-Dh-E6TAx.js} +1 -1
  283. package/dist/domains/dashboard/web/assets/{chunk-DU6HZSFF-NAtcgGZr.js → chunk-DU6HZSFF-W3lPaoVP.js} +2 -2
  284. package/dist/domains/dashboard/web/assets/{chunk-F27PBJKO-BcFXHZMJ.js → chunk-F27PBJKO-dzf1fpYi.js} +1 -1
  285. package/dist/domains/dashboard/web/assets/{chunk-GMAD6QVW-wNemar9b.js → chunk-GMAD6QVW-CeuSGVHV.js} +1 -1
  286. package/dist/domains/dashboard/web/assets/{chunk-GVQU2GXP-BiVCDO9d.js → chunk-GVQU2GXP-BrGrIBgk.js} +1 -1
  287. package/dist/domains/dashboard/web/assets/{chunk-IMKFNOWR-D9GDj4b6.js → chunk-IMKFNOWR-DXiTC1Xo.js} +1 -1
  288. package/dist/domains/dashboard/web/assets/{chunk-L3NEJ4N5-DkPl5vac.js → chunk-L3NEJ4N5-DnyD3Ocj.js} +1 -1
  289. package/dist/domains/dashboard/web/assets/{chunk-OSK3NFVY-RbbxGqtJ.js → chunk-OSK3NFVY-6vxhPm51.js} +1 -1
  290. package/dist/domains/dashboard/web/assets/{chunk-P2QGCYS3-B9_X57eT.js → chunk-P2QGCYS3-DChNsVqO.js} +1 -1
  291. package/dist/domains/dashboard/web/assets/{chunk-POPQ4Y6H-DE4bOH0D.js → chunk-POPQ4Y6H-RBgha6dE.js} +1 -1
  292. package/dist/domains/dashboard/web/assets/{chunk-PWAF6VOD-Bo-W1iA1.js → chunk-PWAF6VOD-CayoKmnh.js} +1 -1
  293. package/dist/domains/dashboard/web/assets/{chunk-SHT3W25Y-BhLxs4rZ.js → chunk-SHT3W25Y-sOkLJZoB.js} +1 -1
  294. package/dist/domains/dashboard/web/assets/{chunk-SVP7TREG-BCXfn8uF.js → chunk-SVP7TREG-j0QRwmsq.js} +1 -1
  295. package/dist/domains/dashboard/web/assets/{chunk-TICWLB2K-DqSBgE5L.js → chunk-TICWLB2K-D7Re_d_T.js} +1 -1
  296. package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-Dbkt1xEZ.js → chunk-XXDRQBXY-BFV70fKF.js} +1 -1
  297. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-gDSLbV2K.js +1 -0
  298. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-gDSLbV2K.js +1 -0
  299. package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-DrwNpMyX.js → cose-bilkent-JH36ORCC-k7gqx2Br.js} +1 -1
  300. package/dist/domains/dashboard/web/assets/{cynefin-OW5HDTMX-BbDlivxs.js → cynefin-OW5HDTMX-CWI6FZT8.js} +1 -1
  301. package/dist/domains/dashboard/web/assets/{cynefinDiagram-5FMLGOSQ-DmLmRN42.js → cynefinDiagram-5FMLGOSQ-D-O3RrOu.js} +1 -1
  302. package/dist/domains/dashboard/web/assets/{dagre-GXQ25YYZ-Cgm5DNgI.js → dagre-GXQ25YYZ-BR1jxWfn.js} +1 -1
  303. package/dist/domains/dashboard/web/assets/{diagram-S7CK7UJ4-Bnht1X2m.js → diagram-S7CK7UJ4-B6gXFYBj.js} +1 -1
  304. package/dist/domains/dashboard/web/assets/{diagram-UQ7AKVKN-LELTI4PR.js → diagram-UQ7AKVKN-BBW6aRk8.js} +1 -1
  305. package/dist/domains/dashboard/web/assets/{diagram-VSXAHHWV-Do0fZuNG.js → diagram-VSXAHHWV-BC0CZeyH.js} +1 -1
  306. package/dist/domains/dashboard/web/assets/{diagram-VX7I27RA-B0rZTUwt.js → diagram-VX7I27RA-BmwBIkwS.js} +1 -1
  307. package/dist/domains/dashboard/web/assets/{diagram-Z3DM3KII-wn8xCc_j.js → diagram-Z3DM3KII-DTZgX9SF.js} +1 -1
  308. package/dist/domains/dashboard/web/assets/{dist-CYwDKy2m.js → dist-brXLwleg.js} +1 -1
  309. package/dist/domains/dashboard/web/assets/{ebnfDiagram-PWID7BFC-CMDOpP2T.js → ebnfDiagram-PWID7BFC-CsMXo0C6.js} +1 -1
  310. package/dist/domains/dashboard/web/assets/{erDiagram-RLTQ6QDP-C2d43bdq.js → erDiagram-RLTQ6QDP-DQ9ewX94.js} +1 -1
  311. package/dist/domains/dashboard/web/assets/{es-BzaOcXwu.js → es-CgcAhzLf.js} +1 -1
  312. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-Ll12Q19y.js +1 -0
  313. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-Bf2-9XUn.js +1 -0
  314. package/dist/domains/dashboard/web/assets/{ganttDiagram-EL5Y4UJY-hTH7TzhY.js → ganttDiagram-EL5Y4UJY-DIFkXe6G.js} +1 -1
  315. package/dist/domains/dashboard/web/assets/{gitGraph-4MIJSDKK-C3CCywb-.js → gitGraph-4MIJSDKK-BHY8ZnpE.js} +1 -1
  316. package/dist/domains/dashboard/web/assets/{gitGraphDiagram-WWUBYQGX-DW6jDckj.js → gitGraphDiagram-WWUBYQGX-cBn9dMzs.js} +1 -1
  317. package/dist/domains/dashboard/web/assets/{index-CTZPz_mx.js → index-C_6nf1Fw.js} +3 -3
  318. package/dist/domains/dashboard/web/assets/{index-CWNqBYyI.css → index-Gaxnq6Jd.css} +1 -1
  319. package/dist/domains/dashboard/web/assets/{info-A6RAGUB7-Bg3eKis8.js → info-A6RAGUB7-DtUaS9jN.js} +1 -1
  320. package/dist/domains/dashboard/web/assets/{infoDiagram-27XIBGKW-7zk6ytVJ.js → infoDiagram-27XIBGKW-CIl0e_EN.js} +1 -1
  321. package/dist/domains/dashboard/web/assets/{ishikawaDiagram-5VMMS53U-CGDCTmCQ.js → ishikawaDiagram-5VMMS53U-DAdtPZ_c.js} +1 -1
  322. package/dist/domains/dashboard/web/assets/{journeyDiagram-3NMN7TZE-C8_L_e8a.js → journeyDiagram-3NMN7TZE-CBokRgde.js} +1 -1
  323. package/dist/domains/dashboard/web/assets/{kanban-definition-UXKFOSKX-D5x6qTgM.js → kanban-definition-UXKFOSKX-DrqCYJ-7.js} +1 -1
  324. package/dist/domains/dashboard/web/assets/katex-D29apahB.js +257 -0
  325. package/dist/domains/dashboard/web/assets/{line-DC93oja4.js → line-BDlVqlh4.js} +1 -1
  326. package/dist/domains/dashboard/web/assets/{linear-81TNubkB.js → linear-DTAzui9x.js} +1 -1
  327. package/dist/domains/dashboard/web/assets/{mermaid-parser.core-D60d8uy9.js → mermaid-parser.core-CFw-xbYY.js} +3 -3
  328. package/dist/domains/dashboard/web/assets/{mermaid.core-l4Wgjz2Q.js → mermaid.core-Ck7fB8UD.js} +4 -4
  329. package/dist/domains/dashboard/web/assets/{mindmap-definition-YA3MSWOX-Dfqu1201.js → mindmap-definition-YA3MSWOX-C7kb9KL9.js} +1 -1
  330. package/dist/domains/dashboard/web/assets/{packet-AYTQ26CC-CsFZBhTs.js → packet-AYTQ26CC-P8Mtt0tp.js} +1 -1
  331. package/dist/domains/dashboard/web/assets/{pegDiagram-XKGWAZYB-myFMaA7n.js → pegDiagram-XKGWAZYB-DUDD9qv5.js} +1 -1
  332. package/dist/domains/dashboard/web/assets/{pie-WAS4IAKB-FMuCTNSk.js → pie-WAS4IAKB-dEmLxiDR.js} +1 -1
  333. package/dist/domains/dashboard/web/assets/{pieDiagram-E7YTZNPT-CSR4B4Z1.js → pieDiagram-E7YTZNPT-BUssAcqk.js} +1 -1
  334. package/dist/domains/dashboard/web/assets/purify.es-Bvo9QlJ8.js +3 -0
  335. package/dist/domains/dashboard/web/assets/{quadrantDiagram-AXDQQJYC-BiE4kEeP.js → quadrantDiagram-AXDQQJYC-BzaAWdQL.js} +1 -1
  336. package/dist/domains/dashboard/web/assets/{radar-RG4KPBEZ-BZ-n7JtG.js → radar-RG4KPBEZ-mqtvaz9w.js} +1 -1
  337. package/dist/domains/dashboard/web/assets/{railroad-74A4TZTK-CWVtRfHu.js → railroad-74A4TZTK-7tTnGpoz.js} +1 -1
  338. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CpJvyBJM.js +1 -0
  339. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-BJ5g77l6.js +1 -0
  340. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-BslCK-Gr.js +1 -0
  341. package/dist/domains/dashboard/web/assets/{railroadDiagram-O6MQD6OU-CBj7v1de.js → railroadDiagram-O6MQD6OU-DM1AKXm0.js} +1 -1
  342. package/dist/domains/dashboard/web/assets/{requirementDiagram-BXWQKSXE-DSDgb54n.js → requirementDiagram-BXWQKSXE--H5KiPSc.js} +1 -1
  343. package/dist/domains/dashboard/web/assets/{sankeyDiagram-P5KCCOFB-1-oXLUAP.js → sankeyDiagram-P5KCCOFB-JweUq_u2.js} +1 -1
  344. package/dist/domains/dashboard/web/assets/{sequenceDiagram-WJ2MYXX4-DAF4nGs_.js → sequenceDiagram-WJ2MYXX4-pxb1iTGb.js} +1 -1
  345. package/dist/domains/dashboard/web/assets/{src-CTWLVUqE.js → src-joFOxopw.js} +1 -1
  346. package/dist/domains/dashboard/web/assets/{stateDiagram-D77RDMKH-DzENBaJT.js → stateDiagram-D77RDMKH-CDu5crd8.js} +1 -1
  347. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-wV5AqWaM.js +1 -0
  348. package/dist/domains/dashboard/web/assets/{swimlanes-42K2YHIH-CnxFUZJc.js → swimlanes-42K2YHIH-ioSqowJ4.js} +1 -1
  349. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-DOPLn-V5.js +8 -0
  350. package/dist/domains/dashboard/web/assets/{timeline-definition-24CTP7MA-KtvPzpZM.js → timeline-definition-24CTP7MA-2YXSYkS3.js} +1 -1
  351. package/dist/domains/dashboard/web/assets/{treeView-Q6P3EWNA-Bdu3P9iY.js → treeView-Q6P3EWNA-DEGims38.js} +1 -1
  352. package/dist/domains/dashboard/web/assets/{treemap-WGGIJYW6-DFnn23JR.js → treemap-WGGIJYW6-CJvBhTlR.js} +1 -1
  353. package/dist/domains/dashboard/web/assets/{vennDiagram-4TSXK5OY-BjpviP26.js → vennDiagram-4TSXK5OY-CHdNWhBK.js} +1 -1
  354. package/dist/domains/dashboard/web/assets/{wardley-WFR3VGLG-CEo4a-j4.js → wardley-WFR3VGLG-CVO9PCjo.js} +1 -1
  355. package/dist/domains/dashboard/web/assets/{wardleyDiagram-VM6X3IG4-Bf54n6im.js → wardleyDiagram-VM6X3IG4-RToPmij6.js} +1 -1
  356. package/dist/domains/dashboard/web/assets/{xychartDiagram-S5SC5T6Z-CU-hI0Cm.js → xychartDiagram-S5SC5T6Z-DaWHnpHE.js} +1 -1
  357. package/dist/domains/dashboard/web/index.html +2 -2
  358. package/dist/domains/project-knowledge/host-review.d.ts +15 -2
  359. package/dist/domains/project-knowledge/host-review.d.ts.map +1 -1
  360. package/dist/domains/project-knowledge/host-review.js +65 -25
  361. package/dist/domains/project-knowledge/host-review.js.map +1 -1
  362. package/dist/domains/project-knowledge/index.d.ts +1 -0
  363. package/dist/domains/project-knowledge/index.d.ts.map +1 -1
  364. package/dist/domains/project-knowledge/index.js +1 -0
  365. package/dist/domains/project-knowledge/index.js.map +1 -1
  366. package/dist/domains/project-knowledge/learning.d.ts +2 -1
  367. package/dist/domains/project-knowledge/learning.d.ts.map +1 -1
  368. package/dist/domains/project-knowledge/learning.js +6 -0
  369. package/dist/domains/project-knowledge/learning.js.map +1 -1
  370. package/dist/domains/project-knowledge/plugin.d.ts.map +1 -1
  371. package/dist/domains/project-knowledge/plugin.js +3 -1
  372. package/dist/domains/project-knowledge/plugin.js.map +1 -1
  373. package/dist/domains/skill/dsh-adapter.d.ts +5 -1
  374. package/dist/domains/skill/dsh-adapter.d.ts.map +1 -1
  375. package/dist/domains/skill/dsh-adapter.js +222 -87
  376. package/dist/domains/skill/dsh-adapter.js.map +1 -1
  377. package/dist/domains/skill/platform-inspect.d.ts +1 -0
  378. package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
  379. package/dist/domains/skill/platform-inspect.js +8 -4
  380. package/dist/domains/skill/platform-inspect.js.map +1 -1
  381. package/dist/domains/skill/platform-install.d.ts.map +1 -1
  382. package/dist/domains/skill/platform-install.js +7 -7
  383. package/dist/domains/skill/platform-install.js.map +1 -1
  384. package/dist/domains/workflow-contract/hook-target-scope.d.ts.map +1 -1
  385. package/dist/domains/workflow-contract/hook-target-scope.js +2 -1
  386. package/dist/domains/workflow-contract/hook-target-scope.js.map +1 -1
  387. package/dist/platform/fs/file-system.d.ts +2 -0
  388. package/dist/platform/fs/file-system.d.ts.map +1 -1
  389. package/dist/platform/fs/file-system.js +11 -0
  390. package/dist/platform/fs/file-system.js.map +1 -1
  391. package/dist/platform/install/dsh-profiles.d.ts +3 -0
  392. package/dist/platform/install/dsh-profiles.d.ts.map +1 -0
  393. package/dist/platform/install/dsh-profiles.js +40 -0
  394. package/dist/platform/install/dsh-profiles.js.map +1 -0
  395. package/dist/platform/install/platforms.d.ts.map +1 -1
  396. package/dist/platform/install/platforms.js +1 -0
  397. package/dist/platform/install/platforms.js.map +1 -1
  398. package/dist/platform/install/project-registry.d.ts +7 -1
  399. package/dist/platform/install/project-registry.d.ts.map +1 -1
  400. package/dist/platform/install/project-registry.js +49 -5
  401. package/dist/platform/install/project-registry.js.map +1 -1
  402. package/dist/platform/paths/git-worktree-cache.d.ts +3 -0
  403. package/dist/platform/paths/git-worktree-cache.d.ts.map +1 -0
  404. package/dist/platform/paths/git-worktree-cache.js +109 -0
  405. package/dist/platform/paths/git-worktree-cache.js.map +1 -0
  406. package/dist/platform/paths/git-worktree.d.ts +6 -0
  407. package/dist/platform/paths/git-worktree.d.ts.map +1 -1
  408. package/dist/platform/paths/git-worktree.js +191 -30
  409. package/dist/platform/paths/git-worktree.js.map +1 -1
  410. package/dist/platform/paths/project-worktree-root.d.ts +3 -0
  411. package/dist/platform/paths/project-worktree-root.d.ts.map +1 -0
  412. package/dist/platform/paths/project-worktree-root.js +14 -0
  413. package/dist/platform/paths/project-worktree-root.js.map +1 -0
  414. package/dist/platform/process/comet-daemon.d.ts +3 -0
  415. package/dist/platform/process/comet-daemon.d.ts.map +1 -1
  416. package/dist/platform/process/comet-daemon.js +8 -6
  417. package/dist/platform/process/comet-daemon.js.map +1 -1
  418. package/dist/platform/process/external-command.d.ts +3 -0
  419. package/dist/platform/process/external-command.d.ts.map +1 -1
  420. package/dist/platform/process/external-command.js +69 -2
  421. package/dist/platform/process/external-command.js.map +1 -1
  422. package/dist/platform/process/git.d.ts.map +1 -1
  423. package/dist/platform/process/git.js +3 -4
  424. package/dist/platform/process/git.js.map +1 -1
  425. package/dist/platform/process/hook-adapter.d.ts +2 -0
  426. package/dist/platform/process/hook-adapter.d.ts.map +1 -1
  427. package/dist/platform/process/hook-adapter.js +45 -3
  428. package/dist/platform/process/hook-adapter.js.map +1 -1
  429. package/dist/platform/process/hook-read-cache.d.ts +2 -0
  430. package/dist/platform/process/hook-read-cache.d.ts.map +1 -1
  431. package/dist/platform/process/hook-read-cache.js +25 -13
  432. package/dist/platform/process/hook-read-cache.js.map +1 -1
  433. package/dist/platform/process/process-identity.d.ts.map +1 -1
  434. package/dist/platform/process/process-identity.js +18 -51
  435. package/dist/platform/process/process-identity.js.map +1 -1
  436. package/dist/platform/process/runtime-metrics.d.ts +10 -1
  437. package/dist/platform/process/runtime-metrics.d.ts.map +1 -1
  438. package/dist/platform/process/runtime-metrics.js +37 -2
  439. package/dist/platform/process/runtime-metrics.js.map +1 -1
  440. package/dist/platform/process/windows-process-broker.d.ts +1 -0
  441. package/dist/platform/process/windows-process-broker.d.ts.map +1 -1
  442. package/dist/platform/process/windows-process-broker.js +70 -11
  443. package/dist/platform/process/windows-process-broker.js.map +1 -1
  444. package/dist/platform/process/windows-process-identity.d.ts +6 -0
  445. package/dist/platform/process/windows-process-identity.d.ts.map +1 -0
  446. package/dist/platform/process/windows-process-identity.js +190 -0
  447. package/dist/platform/process/windows-process-identity.js.map +1 -0
  448. package/eval/local/tasks/comet-classic-layout-lifecycle/environment/current-comet-package.json +11 -3
  449. package/eval/local/tasks/comet-native-wave-f-dashboard-readonly/environment/current-comet-package.json +11 -3
  450. package/eval/local/tests/scaffold/test_task_resolution.py +6 -2
  451. package/package.json +14 -8
  452. package/dist/domains/dashboard/web/assets/architecture-7GRP2DOG-QeljAKq2.js +0 -1
  453. package/dist/domains/dashboard/web/assets/channel-_AqwP0KA.js +0 -1
  454. package/dist/domains/dashboard/web/assets/classDiagram-ZZMXUADV-CRo4aB_7.js +0 -1
  455. package/dist/domains/dashboard/web/assets/classDiagram-v2-VYDZK3BY-CRo4aB_7.js +0 -1
  456. package/dist/domains/dashboard/web/assets/eventmodeling-NTZA5JFV-KYANo3DQ.js +0 -1
  457. package/dist/domains/dashboard/web/assets/flowDiagram-HODETNUW-CSROlLuj.js +0 -1
  458. package/dist/domains/dashboard/web/assets/katex-CXMH3UgJ.js +0 -257
  459. package/dist/domains/dashboard/web/assets/purify.es-ChwZkWde.js +0 -3
  460. package/dist/domains/dashboard/web/assets/railroad-abnf-HS5TGJTU-CkHwwI2i.js +0 -1
  461. package/dist/domains/dashboard/web/assets/railroad-ebnf-LZEXJU2U-8xzEHL6v.js +0 -1
  462. package/dist/domains/dashboard/web/assets/railroad-peg-WCYAUIDC-nSHBw0tH.js +0 -1
  463. package/dist/domains/dashboard/web/assets/stateDiagram-v2-MP3YSRHH-CNw52Fkn.js +0 -1
  464. package/dist/domains/dashboard/web/assets/swimlanesDiagram-VR7AAH4N-6TRvbqqI.js +0 -8
@@ -1,184 +1,301 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var mm=Object.create;var Il=Object.defineProperty;var vm=Object.getOwnPropertyDescriptor;var gm=Object.getOwnPropertyNames;var wm=Object.getPrototypeOf,ym=Object.prototype.hasOwnProperty;var Yi=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var E=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(i){throw r=[i],i}};var N=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Nm=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gm(e))!ym.call(t,n)&&n!==r&&Il(t,n,{get:()=>e[n],enumerable:!(i=vm(e,n))||i.enumerable});return t};var ft=(t,e,r)=>(r=t!=null?mm(wm(t)):{},Nm(e||!t||!t.__esModule?Il(r,"default",{value:t,enumerable:!0}):r,t));var P=N(U=>{"use strict";var go=Symbol.for("yaml.alias"),Ll=Symbol.for("yaml.document"),Qi=Symbol.for("yaml.map"),Bl=Symbol.for("yaml.pair"),wo=Symbol.for("yaml.scalar"),Zi=Symbol.for("yaml.seq"),Je=Symbol.for("yaml.node.type"),jm=t=>!!t&&typeof t=="object"&&t[Je]===go,Om=t=>!!t&&typeof t=="object"&&t[Je]===Ll,Hm=t=>!!t&&typeof t=="object"&&t[Je]===Qi,Dm=t=>!!t&&typeof t=="object"&&t[Je]===Bl,Fl=t=>!!t&&typeof t=="object"&&t[Je]===wo,Lm=t=>!!t&&typeof t=="object"&&t[Je]===Zi;function Ml(t){if(t&&typeof t=="object")switch(t[Je]){case Qi:case Zi:return!0}return!1}function Bm(t){if(t&&typeof t=="object")switch(t[Je]){case go:case Qi:case wo:case Zi:return!0}return!1}var Fm=t=>(Fl(t)||Ml(t))&&!!t.anchor;U.ALIAS=go;U.DOC=Ll;U.MAP=Qi;U.NODE_TYPE=Je;U.PAIR=Bl;U.SCALAR=wo;U.SEQ=Zi;U.hasAnchor=Fm;U.isAlias=jm;U.isCollection=Ml;U.isDocument=Om;U.isMap=Hm;U.isNode=Bm;U.isPair=Dm;U.isScalar=Fl;U.isSeq=Lm});var Hr=N(yo=>{"use strict";var q=P(),ae=Symbol("break visit"),Vl=Symbol("skip children"),Oe=Symbol("remove node");function en(t,e){let r=ql(e);q.isDocument(t)?Xt(null,t.contents,r,Object.freeze([t]))===Oe&&(t.contents=null):Xt(null,t,r,Object.freeze([]))}en.BREAK=ae;en.SKIP=Vl;en.REMOVE=Oe;function Xt(t,e,r,i){let n=Wl(t,e,r,i);if(q.isNode(n)||q.isPair(n))return zl(t,i,n),Xt(t,n,r,i);if(typeof n!="symbol"){if(q.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=Xt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ae)return ae;o===Oe&&(e.items.splice(a,1),a-=1)}}}else if(q.isPair(e)){i=Object.freeze(i.concat(e));let a=Xt("key",e.key,r,i);if(a===ae)return ae;a===Oe&&(e.key=null);let o=Xt("value",e.value,r,i);if(o===ae)return ae;o===Oe&&(e.value=null)}}return n}async function tn(t,e){let r=ql(e);q.isDocument(t)?await Qt(null,t.contents,r,Object.freeze([t]))===Oe&&(t.contents=null):await Qt(null,t,r,Object.freeze([]))}tn.BREAK=ae;tn.SKIP=Vl;tn.REMOVE=Oe;async function Qt(t,e,r,i){let n=await Wl(t,e,r,i);if(q.isNode(n)||q.isPair(n))return zl(t,i,n),Qt(t,n,r,i);if(typeof n!="symbol"){if(q.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await Qt(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ae)return ae;o===Oe&&(e.items.splice(a,1),a-=1)}}}else if(q.isPair(e)){i=Object.freeze(i.concat(e));let a=await Qt("key",e.key,r,i);if(a===ae)return ae;a===Oe&&(e.key=null);let o=await Qt("value",e.value,r,i);if(o===ae)return ae;o===Oe&&(e.value=null)}}return n}function ql(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Wl(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(q.isMap(e))return r.Map?.(t,e,i);if(q.isSeq(e))return r.Seq?.(t,e,i);if(q.isPair(e))return r.Pair?.(t,e,i);if(q.isScalar(e))return r.Scalar?.(t,e,i);if(q.isAlias(e))return r.Alias?.(t,e,i)}function zl(t,e,r){let i=e[e.length-1];if(q.isCollection(i))i.items[t]=r;else if(q.isPair(i))t==="key"?i.key=r:i.value=r;else if(q.isDocument(i))i.contents=r;else{let n=q.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}yo.visit=en;yo.visitAsync=tn});var No=N(Jl=>{"use strict";var Gl=P(),Mm=Hr(),Vm={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},qm=t=>t.replace(/[!,[\]{}]/g,e=>Vm[e]),Dr=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||r(`The ${e} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,i]of Object.entries(this.tags))if(e.startsWith(i))return r+qm(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&Gl.isNode(e.contents)){let a={};Mm.visit(e.contents,(o,s)=>{Gl.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
5
- `)}};Dr.defaultYaml={explicit:!1,version:"1.2"};Dr.defaultTags={"!!":"tag:yaml.org,2002:"};Jl.Directives=Dr});var rn=N(Lr=>{"use strict";var Ul=P(),Wm=Hr();function zm(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function Kl(t){let e=new Set;return Wm.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function Yl(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function Gm(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Kl(t));let o=Yl(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Ul.isScalar(o.node)||Ul.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}Lr.anchorIsValid=zm;Lr.anchorNames=Kl;Lr.createNodeAnchors=Gm;Lr.findNewAnchor=Yl});var bo=N(Xl=>{"use strict";function Br(t,e,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=Br(t,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=Br(t,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=Br(t,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=Br(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}Xl.applyReviver=Br});var pt=N(Zl=>{"use strict";var Jm=P();function Ql(t,e,r){if(Array.isArray(t))return t.map((i,n)=>Ql(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!Jm.hasAnchor(t))return t.toJSON(e,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(t,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=t.toJSON(e,r);return r.onCreate&&r.onCreate(n),n}return typeof t=="bigint"&&!r?.keep?Number(t):t}Zl.toJS=Ql});var nn=N(tu=>{"use strict";var Um=bo(),eu=P(),Km=pt(),ko=class{constructor(e){Object.defineProperty(this,eu.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!eu.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=Km.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Um.applyReviver(a,{"":s},"",s):s}};tu.NodeBase=ko});var Fr=N(ru=>{"use strict";var Ym=rn(),Xm=Hr(),Zt=P(),Qm=nn(),Zm=pt(),So=class extends Qm.NodeBase{constructor(e){super(Zt.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],Xm.visit(e,{Node:(a,o)=>{(Zt.isAlias(o)||Zt.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=i.get(o);if(s||(Zm.toJS(o,null,r),s=i.get(o)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=an(n,o,i)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,r,i){let n=`*${this.source}`;if(e){if(Ym.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(e.implicitKey)return`${n} `}return n}};function an(t,e,r){if(Zt.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(Zt.isCollection(e)){let i=0;for(let n of e.items){let a=an(t,n,r);a>i&&(i=a)}return i}else if(Zt.isPair(e)){let i=an(t,e.key,r),n=an(t,e.value,r);return Math.max(i,n)}return 1}ru.Alias=So});var B=N(Eo=>{"use strict";var ev=P(),tv=nn(),rv=pt(),iv=t=>!t||typeof t!="function"&&typeof t!="object",ht=class extends tv.NodeBase{constructor(e){super(ev.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:rv.toJS(this.value,e,r)}toString(){return String(this.value)}};ht.BLOCK_FOLDED="BLOCK_FOLDED";ht.BLOCK_LITERAL="BLOCK_LITERAL";ht.PLAIN="PLAIN";ht.QUOTE_DOUBLE="QUOTE_DOUBLE";ht.QUOTE_SINGLE="QUOTE_SINGLE";Eo.Scalar=ht;Eo.isScalarValue=iv});var Mr=N(nu=>{"use strict";var nv=Fr(),jt=P(),iu=B(),av="tag:yaml.org,2002:";function ov(t,e,r){if(e){let i=r.filter(a=>a.tag===e),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return r.find(i=>i.identify?.(t)&&!i.format)}function sv(t,e,r){if(jt.isDocument(t)&&(t=t.contents),jt.isNode(t))return t;if(jt.isPair(t)){let d=r.schema[jt.MAP].createNode?.(r.schema,null,r);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,c;if(i&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new nv.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=av+e.slice(2));let l=ov(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new iu.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?o[jt.MAP]:Symbol.iterator in Object(t)?o[jt.SEQ]:o[jt.MAP]}a&&(a(l),delete r.onTagObj);let u=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new iu.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}nu.createNode=sv});var sn=N(on=>{"use strict";var cv=Mr(),He=P(),lv=nn();function xo(t,e,r){let i=r;for(let n=e.length-1;n>=0;--n){let a=e[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return cv.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var au=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Co=class extends lv.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(i=>He.isNode(i)||He.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(au(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(He.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,xo(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[r,...i]=e;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(He.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(e,r){let[i,...n]=e,a=this.get(i,!0);return n.length===0?!r&&He.isScalar(a)?a.value:a:He.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!He.isPair(r))return!1;let i=r.value;return i==null||e&&He.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[r,...i]=e;if(i.length===0)return this.has(r);let n=this.get(r,!0);return He.isCollection(n)?n.hasIn(i):!1}setIn(e,r){let[i,...n]=e;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(He.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,xo(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};on.Collection=Co;on.collectionFromPath=xo;on.isEmptyPath=au});var Vr=N(cn=>{"use strict";var uv=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Po(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var dv=(t,e,r)=>t.endsWith(`
6
- `)?Po(r,e):r.includes(`
4
+ var uw=Object.create;var kd=Object.defineProperty;var dw=Object.getOwnPropertyDescriptor;var fw=Object.getOwnPropertyNames;var pw=Object.getPrototypeOf,hw=Object.prototype.hasOwnProperty;var qn=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var x=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(i){throw r=[i],i}};var N=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var mw=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of fw(e))!hw.call(t,n)&&n!==r&&kd(t,n,{get:()=>e[n],enumerable:!(i=dw(e,n))||i.enumerable});return t};var kt=(t,e,r)=>(r=t!=null?uw(pw(t)):{},mw(e||!t||!t.__esModule?kd(r,"default",{value:t,enumerable:!0}):r,t));var _=N(X=>{"use strict";var Rs=Symbol.for("yaml.alias"),Ad=Symbol.for("yaml.document"),Wn=Symbol.for("yaml.map"),Id=Symbol.for("yaml.pair"),_s=Symbol.for("yaml.scalar"),zn=Symbol.for("yaml.seq"),it=Symbol.for("yaml.node.type"),Iw=t=>!!t&&typeof t=="object"&&t[it]===Rs,Tw=t=>!!t&&typeof t=="object"&&t[it]===Ad,$w=t=>!!t&&typeof t=="object"&&t[it]===Wn,jw=t=>!!t&&typeof t=="object"&&t[it]===Id,Td=t=>!!t&&typeof t=="object"&&t[it]===_s,Ow=t=>!!t&&typeof t=="object"&&t[it]===zn;function $d(t){if(t&&typeof t=="object")switch(t[it]){case Wn:case zn:return!0}return!1}function Hw(t){if(t&&typeof t=="object")switch(t[it]){case Rs:case Wn:case _s:case zn:return!0}return!1}var Dw=t=>(Td(t)||$d(t))&&!!t.anchor;X.ALIAS=Rs;X.DOC=Ad;X.MAP=Wn;X.NODE_TYPE=it;X.PAIR=Id;X.SCALAR=_s;X.SEQ=zn;X.hasAnchor=Dw;X.isAlias=Iw;X.isCollection=$d;X.isDocument=Tw;X.isMap=$w;X.isNode=Hw;X.isPair=jw;X.isScalar=Td;X.isSeq=Ow});var wi=N(As=>{"use strict";var J=_(),ce=Symbol("break visit"),jd=Symbol("skip children"),Ve=Symbol("remove node");function Gn(t,e){let r=Od(e);J.isDocument(t)?xr(null,t.contents,r,Object.freeze([t]))===Ve&&(t.contents=null):xr(null,t,r,Object.freeze([]))}Gn.BREAK=ce;Gn.SKIP=jd;Gn.REMOVE=Ve;function xr(t,e,r,i){let n=Hd(t,e,r,i);if(J.isNode(n)||J.isPair(n))return Dd(t,i,n),xr(t,n,r,i);if(typeof n!="symbol"){if(J.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=xr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Ve&&(e.items.splice(a,1),a-=1)}}}else if(J.isPair(e)){i=Object.freeze(i.concat(e));let a=xr("key",e.key,r,i);if(a===ce)return ce;a===Ve&&(e.key=null);let o=xr("value",e.value,r,i);if(o===ce)return ce;o===Ve&&(e.value=null)}}return n}async function Jn(t,e){let r=Od(e);J.isDocument(t)?await Cr(null,t.contents,r,Object.freeze([t]))===Ve&&(t.contents=null):await Cr(null,t,r,Object.freeze([]))}Jn.BREAK=ce;Jn.SKIP=jd;Jn.REMOVE=Ve;async function Cr(t,e,r,i){let n=await Hd(t,e,r,i);if(J.isNode(n)||J.isPair(n))return Dd(t,i,n),Cr(t,n,r,i);if(typeof n!="symbol"){if(J.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await Cr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Ve&&(e.items.splice(a,1),a-=1)}}}else if(J.isPair(e)){i=Object.freeze(i.concat(e));let a=await Cr("key",e.key,r,i);if(a===ce)return ce;a===Ve&&(e.key=null);let o=await Cr("value",e.value,r,i);if(o===ce)return ce;o===Ve&&(e.value=null)}}return n}function Od(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Hd(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(J.isMap(e))return r.Map?.(t,e,i);if(J.isSeq(e))return r.Seq?.(t,e,i);if(J.isPair(e))return r.Pair?.(t,e,i);if(J.isScalar(e))return r.Scalar?.(t,e,i);if(J.isAlias(e))return r.Alias?.(t,e,i)}function Dd(t,e,r){let i=e[e.length-1];if(J.isCollection(i))i.items[t]=r;else if(J.isPair(i))t==="key"?i.key=r:i.value=r;else if(J.isDocument(i))i.contents=r;else{let n=J.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}As.visit=Gn;As.visitAsync=Jn});var Is=N(Bd=>{"use strict";var Ld=_(),Lw=wi(),Bw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Mw=t=>t.replace(/[!,[\]{}]/g,e=>Bw[e]),yi=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return r(6,`Unsupported YAML version ${a}`,o),!1}}default:return r(0,`Unknown directive ${n}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||r(`The ${e} tag has no suffix`);let a=this.tags[i];if(a)try{return a+decodeURIComponent(n)}catch(o){return r(String(o)),null}return i==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,i]of Object.entries(this.tags))if(e.startsWith(i))return r+Mw(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&Ld.isNode(e.contents)){let a={};Lw.visit(e.contents,(o,s)=>{Ld.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
5
+ `)}};yi.defaultYaml={explicit:!1,version:"1.2"};yi.defaultTags={"!!":"tag:yaml.org,2002:"};Bd.Directives=yi});var Un=N(Ni=>{"use strict";var Md=_(),Fw=wi();function Vw(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function Fd(t){let e=new Set;return Fw.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function Vd(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function qw(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Fd(t));let o=Vd(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Md.isScalar(o.node)||Md.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:i}}Ni.anchorIsValid=Vw;Ni.anchorNames=Fd;Ni.createNodeAnchors=qw;Ni.findNewAnchor=Vd});var Ts=N(qd=>{"use strict";function bi(t,e,r,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,a=i.length;n<a;++n){let o=i[n],s=bi(t,i,String(n),o);s===void 0?delete i[n]:s!==o&&(i[n]=s)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let a=i.get(n),o=bi(t,i,n,a);o===void 0?i.delete(n):o!==a&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let a=bi(t,i,n,n);a===void 0?i.delete(n):a!==n&&(i.delete(n),i.add(a))}else for(let[n,a]of Object.entries(i)){let o=bi(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}qd.applyReviver=bi});var St=N(zd=>{"use strict";var Ww=_();function Wd(t,e,r){if(Array.isArray(t))return t.map((i,n)=>Wd(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!Ww.hasAnchor(t))return t.toJSON(e,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(t,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=t.toJSON(e,r);return r.onCreate&&r.onCreate(n),n}return typeof t=="bigint"&&!r?.keep?Number(t):t}zd.toJS=Wd});var Kn=N(Jd=>{"use strict";var zw=Ts(),Gd=_(),Gw=St(),$s=class{constructor(e){Object.defineProperty(this,Gd.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Gd.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=Gw.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof a=="function"?zw.applyReviver(a,{"":s},"",s):s}};Jd.NodeBase=$s});var ki=N(Ud=>{"use strict";var Jw=Un(),Uw=wi(),Pr=_(),Kw=Kn(),Yw=St(),js=class extends Kw.NodeBase{constructor(e){super(Pr.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],Uw.visit(e,{Node:(a,o)=>{(Pr.isAlias(o)||Pr.hasAnchor(o))&&i.push(o)}}),r&&(r.aliasResolveCache=i));let n;for(let a of i){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,r){if(!r)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:a}=r,o=this.resolve(n,r);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let s=i.get(o);if(s||(Yw.toJS(o,null,r),s=i.get(o)),s?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Yn(n,o,i)),s.count*s.aliasCount>a)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return s.res}toString(e,r,i){let n=`*${this.source}`;if(e){if(Jw.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(e.implicitKey)return`${n} `}return n}};function Yn(t,e,r){if(Pr.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(Pr.isCollection(e)){let i=0;for(let n of e.items){let a=Yn(t,n,r);a>i&&(i=a)}return i}else if(Pr.isPair(e)){let i=Yn(t,e.key,r),n=Yn(t,e.value,r);return Math.max(i,n)}return 1}Ud.Alias=js});var q=N(Os=>{"use strict";var Xw=_(),Qw=Kn(),Zw=St(),ey=t=>!t||typeof t!="function"&&typeof t!="object",Et=class extends Qw.NodeBase{constructor(e){super(Xw.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:Zw.toJS(this.value,e,r)}toString(){return String(this.value)}};Et.BLOCK_FOLDED="BLOCK_FOLDED";Et.BLOCK_LITERAL="BLOCK_LITERAL";Et.PLAIN="PLAIN";Et.QUOTE_DOUBLE="QUOTE_DOUBLE";Et.QUOTE_SINGLE="QUOTE_SINGLE";Os.Scalar=Et;Os.isScalarValue=ey});var Si=N(Yd=>{"use strict";var ty=ki(),Jt=_(),Kd=q(),ry="tag:yaml.org,2002:";function iy(t,e,r){if(e){let i=r.filter(a=>a.tag===e),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return r.find(i=>i.identify?.(t)&&!i.format)}function ny(t,e,r){if(Jt.isDocument(t)&&(t=t.contents),Jt.isNode(t))return t;if(Jt.isPair(t)){let d=r.schema[Jt.MAP].createNode?.(r.schema,null,r);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,l;if(i&&t&&typeof t=="object"){if(l=s.get(t),l)return l.anchor??(l.anchor=n(t)),new ty.Alias(l.anchor);l={anchor:null,node:null},s.set(t,l)}e?.startsWith("!!")&&(e=ry+e.slice(2));let c=iy(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new Kd.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[Jt.MAP]:Symbol.iterator in Object(t)?o[Jt.SEQ]:o[Jt.MAP]}a&&(a(c),delete r.onTagObj);let u=c?.createNode?c.createNode(r.schema,t,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,t,r):new Kd.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}Yd.createNode=ny});var Qn=N(Xn=>{"use strict";var ay=Si(),qe=_(),oy=Kn();function Hs(t,e,r){let i=r;for(let n=e.length-1;n>=0;--n){let a=e[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return ay.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Xd=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Ds=class extends oy.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(i=>qe.isNode(i)||qe.isPair(i)?i.clone(e):i),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Xd(e))this.add(r);else{let[i,...n]=e,a=this.get(i,!0);if(qe.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Hs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[r,...i]=e;if(i.length===0)return this.delete(r);let n=this.get(r,!0);if(qe.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}getIn(e,r){let[i,...n]=e,a=this.get(i,!0);return n.length===0?!r&&qe.isScalar(a)?a.value:a:qe.isCollection(a)?a.getIn(n,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!qe.isPair(r))return!1;let i=r.value;return i==null||e&&qe.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[r,...i]=e;if(i.length===0)return this.has(r);let n=this.get(r,!0);return qe.isCollection(n)?n.hasIn(i):!1}setIn(e,r){let[i,...n]=e;if(n.length===0)this.set(i,r);else{let a=this.get(i,!0);if(qe.isCollection(a))a.setIn(n,r);else if(a===void 0&&this.schema)this.set(i,Hs(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Xn.Collection=Ds;Xn.collectionFromPath=Hs;Xn.isEmptyPath=Xd});var Ei=N(Zn=>{"use strict";var sy=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Ls(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var cy=(t,e,r)=>t.endsWith(`
6
+ `)?Ls(r,e):r.includes(`
7
7
  `)?`
8
- `+Po(r,e):(t.endsWith(" ")?"":" ")+r;cn.indentComment=Po;cn.lineComment=dv;cn.stringifyComment=uv});var su=N(qr=>{"use strict";var fv="flow",Ro="block",ln="quoted";function pv(t,e,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return t;n<a&&(a=0);let c=Math.max(1+a,1+n-e.length);if(t.length<=c)return t;let l=[],u={},d=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):d=n-i);let f,m,w=!1,p=-1,h=-1,y=-1;r===Ro&&(p=ou(t,p,e.length),p!==-1&&(d=p+c));for(let k;k=t[p+=1];){if(r===ln&&k==="\\"){switch(h=p,t[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}y=p}if(k===`
9
- `)r===Ro&&(p=ou(t,p,e.length)),d=p+e.length+c,f=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
10
- `&&m!==" "){let x=t[p+1];x&&x!==" "&&x!==`
11
- `&&x!==" "&&(f=p)}if(p>=d)if(f)l.push(f),d=f+c,f=void 0;else if(r===ln){for(;m===" "||m===" ";)m=k,k=t[p+=1],w=!0;let x=p>y+1?p-2:h-1;if(u[x])return t;l.push(x),u[x]=!0,d=x+c,f=void 0}else w=!0}m=k}if(w&&s&&s(),l.length===0)return t;o&&o();let v=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let x=l[k],S=l[k+1]||t.length;x===0?v=`
12
- ${e}${t.slice(0,S)}`:(r===ln&&u[x]&&(v+=`${t[x]}\\`),v+=`
13
- ${e}${t.slice(x+1,S)}`)}return v}function ou(t,e,r){let i=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+r)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
- `);i=e,n=e+1,a=t[n]}return i}qr.FOLD_BLOCK=Ro;qr.FOLD_FLOW=fv;qr.FOLD_QUOTED=ln;qr.foldFlowLines=pv});var zr=N(cu=>{"use strict";var Ne=B(),mt=su(),dn=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),fn=t=>/^(%|---|\.\.\.)/m.test(t);function hv(t,e,r){if(!e||e<0)return!1;let i=e-r,n=t.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
- `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function Wr(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(fn(t)?" ":""),o="",s=0;for(let c=0,l=r[c];l;l=r[++c])if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(o+=r.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(r[c+1]){case"u":{o+=r.slice(s,c);let u=r.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=r.substr(c,6)}c+=5,s=c+1}break;case"n":if(i||r[c+2]==='"'||r.length<n)c+=1;else{for(o+=r.slice(s,c)+`
8
+ `+Ls(r,e):(t.endsWith(" ")?"":" ")+r;Zn.indentComment=Ls;Zn.lineComment=cy;Zn.stringifyComment=sy});var Zd=N(xi=>{"use strict";var ly="flow",Bs="block",ea="quoted";function uy(t,e,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return t;n<a&&(a=0);let l=Math.max(1+a,1+n-e.length);if(t.length<=l)return t;let c=[],u={},d=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?c.push(0):d=n-i);let f,p,v=!1,h=-1,m=-1,w=-1;r===Bs&&(h=Qd(t,h,e.length),h!==-1&&(d=h+l));for(let b;b=t[h+=1];){if(r===ea&&b==="\\"){switch(m=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}w=h}if(b===`
9
+ `)r===Bs&&(h=Qd(t,h,e.length)),d=h+e.length+l,f=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
10
+ `&&p!==" "){let E=t[h+1];E&&E!==" "&&E!==`
11
+ `&&E!==" "&&(f=h)}if(h>=d)if(f)c.push(f),d=f+l,f=void 0;else if(r===ea){for(;p===" "||p===" ";)p=b,b=t[h+=1],v=!0;let E=h>w+1?h-2:m-1;if(u[E])return t;c.push(E),u[E]=!0,d=E+l,f=void 0}else v=!0}p=b}if(v&&s&&s(),c.length===0)return t;o&&o();let g=t.slice(0,c[0]);for(let b=0;b<c.length;++b){let E=c[b],S=c[b+1]||t.length;E===0?g=`
12
+ ${e}${t.slice(0,S)}`:(r===ea&&u[E]&&(g+=`${t[E]}\\`),g+=`
13
+ ${e}${t.slice(E+1,S)}`)}return g}function Qd(t,e,r){let i=e,n=e+1,a=t[n];for(;a===" "||a===" ";)if(e<n+r)a=t[++e];else{do a=t[++e];while(a&&a!==`
14
+ `);i=e,n=e+1,a=t[n]}return i}xi.FOLD_BLOCK=Bs;xi.FOLD_FLOW=ly;xi.FOLD_QUOTED=ea;xi.foldFlowLines=uy});var Pi=N(ef=>{"use strict";var Pe=q(),xt=Zd(),ra=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),ia=t=>/^(%|---|\.\.\.)/m.test(t);function dy(t,e,r){if(!e||e<0)return!1;let i=e-r,n=t.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(t[a]===`
15
+ `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function Ci(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(ia(t)?" ":""),o="",s=0;for(let l=0,c=r[l];c;c=r[++l])if(c===" "&&r[l+1]==="\\"&&r[l+2]==="n"&&(o+=r.slice(s,l)+"\\ ",l+=1,s=l,c="\\"),c==="\\")switch(r[l+1]){case"u":{o+=r.slice(s,l);let u=r.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=r.substr(l,6)}l+=5,s=l+1}break;case"n":if(i||r[l+2]==='"'||r.length<n)l+=1;else{for(o+=r.slice(s,l)+`
16
16
 
17
- `;r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"';)o+=`
18
- `,c+=2;o+=a,r[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+r.slice(s):r,i?o:mt.foldFlowLines(o,a,mt.FOLD_QUOTED,dn(e,!1))}function _o(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(t))return Wr(t,e);let r=e.indent||(fn(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${r}`)+"'";return e.implicitKey?i:mt.foldFlowLines(i,r,mt.FOLD_FLOW,dn(e,!1))}function er(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=Wr;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=_o:a&&!n?i=Wr:i=r?_o:Wr}return i(t,e)}var Ao;try{Ao=new RegExp(`(^|(?<!
17
+ `;r[l+2]==="\\"&&r[l+3]==="n"&&r[l+4]!=='"';)o+=`
18
+ `,l+=2;o+=a,r[l+2]===" "&&(o+="\\"),l+=1,s=l+1}break;default:l+=1}return o=s?o+r.slice(s):r,i?o:xt.foldFlowLines(o,a,xt.FOLD_QUOTED,ra(e,!1))}function Ms(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return Ci(t,e);let r=e.indent||(ia(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${r}`)+"'";return e.implicitKey?i:xt.foldFlowLines(i,r,xt.FOLD_FLOW,ra(e,!1))}function Rr(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=Ci;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=Ms:a&&!n?i=Ci:i=r?Ms:Ci}return i(t,e)}var Fs;try{Fs=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{Ao=/\n+(?!\n|$)/g}function un({comment:t,type:e,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(r))return er(r,i);let l=i.indent||(i.forceBlockIndent||fn(r)?" ":""),u=o==="literal"?!0:o==="folded"||e===Ne.Scalar.BLOCK_FOLDED?!1:e===Ne.Scalar.BLOCK_LITERAL?!0:!hv(r,c,l.length);if(!r)return u?`|
23
+ |$)`,"g")}catch{Fs=/\n+(?!\n|$)/g}function ta({comment:t,type:e,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(r))return Rr(r,i);let c=i.indent||(i.forceBlockIndent||ia(r)?" ":""),u=o==="literal"?!0:o==="folded"||e===Pe.Scalar.BLOCK_FOLDED?!1:e===Pe.Scalar.BLOCK_LITERAL?!0:!dy(r,l,c.length);if(!r)return u?`|
24
24
  `:`>
25
25
  `;let d,f;for(f=r.length;f>0;--f){let S=r[f-1];if(S!==`
26
- `&&S!==" "&&S!==" ")break}let m=r.substring(f),w=m.indexOf(`
27
- `);w===-1?d="-":r===m||w!==m.length-1?(d="+",a&&a()):d="",m&&(r=r.slice(0,-m.length),m[m.length-1]===`
28
- `&&(m=m.slice(0,-1)),m=m.replace(Ao,`$&${l}`));let p=!1,h,y=-1;for(h=0;h<r.length;++h){let S=r[h];if(S===" ")p=!0;else if(S===`
29
- `)y=h;else break}let v=r.substring(0,y<h?y+1:h);v&&(r=r.substring(v.length),v=v.replace(/\n+/g,`$&${l}`));let x=(p?l?"2":"1":"")+d;if(t&&(x+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){let S=r.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),g=!1,R=dn(i,!0);o!=="folded"&&e!==Ne.Scalar.BLOCK_FOLDED&&(R.onOverflow=()=>{g=!0});let b=mt.foldFlowLines(`${v}${S}${m}`,l,mt.FOLD_BLOCK,R);if(!g)return`>${x}
31
- ${l}${b}`}return r=r.replace(/\n+/g,`$&${l}`),`|${x}
32
- ${l}${v}${r}${m}`}function mv(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=e;if(s&&a.includes(`
33
- `)||u&&/[[\]{},]/.test(a))return er(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
34
- `)?er(a,e):un(t,e,r,i);if(!s&&!u&&n!==Ne.Scalar.PLAIN&&a.includes(`
35
- `))return un(t,e,r,i);if(fn(a)){if(c==="")return e.forceBlockIndent=!0,un(t,e,r,i);if(s&&c===l)return er(a,e)}let d=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(d),{compat:m,tags:w}=e.doc.schema;if(w.some(f)||m?.some(f))return er(a,e)}return s?d:mt.foldFlowLines(d,c,mt.FOLD_FLOW,dn(e,!1))}function vv(t,e,r,i){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==Ne.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Ne.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case Ne.Scalar.BLOCK_FOLDED:case Ne.Scalar.BLOCK_LITERAL:return n||a?er(o.value,e):un(o,e,r,i);case Ne.Scalar.QUOTE_DOUBLE:return Wr(o.value,e);case Ne.Scalar.QUOTE_SINGLE:return _o(o.value,e);case Ne.Scalar.PLAIN:return mv(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=n&&u||d;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}cu.stringifyString=vv});var Gr=N(Io=>{"use strict";var gv=rn(),vt=P(),wv=Vr(),yv=zr();function Nv(t,e){let r=Object.assign({blockQuote:!0,commentString:wv.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function bv(t,e){if(e.tag){let n=t.filter(a=>a.tag===e.tag);if(n.length>0)return n.find(a=>a.format===e.format)??n[0]}let r,i;if(vt.isScalar(e)){i=e.value;let n=t.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else i=e,r=t.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function kv(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(vt.isScalar(t)||vt.isCollection(t))&&t.anchor;a&&gv.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Sv(t,e,r,i){if(vt.isPair(t))return t.toString(e,r,i);if(vt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,a=vt.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=bv(e.doc.schema.tags,a));let o=kv(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,r,i):vt.isScalar(a)?yv.stringifyString(a,e,r,i):a.toString(e,r,i);return o?vt.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${e.indent}${s}`:s}Io.createStringifyContext=Nv;Io.stringify=Sv});var fu=N(du=>{"use strict";var Ue=P(),lu=B(),uu=Gr(),Jr=Vr();function Ev({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=r,f=Ue.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Ue.isCollection(t)||!Ue.isNode(t)&&typeof t=="object"){let R="With simple keys, collection cannot be used as a key value";throw new Error(R)}}let m=!d&&(!t||f&&e==null&&!r.inFlow||Ue.isCollection(t)||(Ue.isScalar(t)?t.type===lu.Scalar.BLOCK_FOLDED||t.type===lu.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!m&&(d||!a),indent:s+c});let w=!1,p=!1,h=uu.stringify(t,r,()=>w=!0,()=>p=!0);if(!m&&!r.inFlow&&h.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(r.inFlow){if(a||e==null)return w&&i&&i(),h===""?"?":m?`? ${h}`:h}else if(a&&!d||e==null&&m)return h=`? ${h}`,f&&!w?h+=Jr.lineComment(h,r.indent,l(f)):p&&n&&n(),h;w&&(f=null),m?(f&&(h+=Jr.lineComment(h,r.indent,l(f))),h=`? ${h}
38
- ${s}:`):(h=`${h}:`,f&&(h+=Jr.lineComment(h,r.indent,l(f))));let y,v,k;Ue.isNode(e)?(y=!!e.spaceBefore,v=e.commentBefore,k=e.comment):(y=!1,v=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!m&&!f&&Ue.isScalar(e)&&(r.indentAtStart=h.length+1),p=!1,!u&&c.length>=2&&!r.inFlow&&!m&&Ue.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let x=!1,S=uu.stringify(e,r,()=>x=!0,()=>p=!0),g=" ";if(f||y||v){if(g=y?`
39
- `:"",v){let R=l(v);g+=`
40
- ${Jr.indentComment(R,r.indent)}`}S===""&&!r.inFlow?g===`
41
- `&&k&&(g=`
26
+ `&&S!==" "&&S!==" ")break}let p=r.substring(f),v=p.indexOf(`
27
+ `);v===-1?d="-":r===p||v!==p.length-1?(d="+",a&&a()):d="",p&&(r=r.slice(0,-p.length),p[p.length-1]===`
28
+ `&&(p=p.slice(0,-1)),p=p.replace(Fs,`$&${c}`));let h=!1,m,w=-1;for(m=0;m<r.length;++m){let S=r[m];if(S===" ")h=!0;else if(S===`
29
+ `)w=m;else break}let g=r.substring(0,w<m?w+1:m);g&&(r=r.substring(g.length),g=g.replace(/\n+/g,`$&${c}`));let E=(h?c?"2":"1":"")+d;if(t&&(E+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){let S=r.replace(/\n+/g,`
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),y=!1,A=ra(i,!0);o!=="folded"&&e!==Pe.Scalar.BLOCK_FOLDED&&(A.onOverflow=()=>{y=!0});let k=xt.foldFlowLines(`${g}${S}${p}`,c,xt.FOLD_BLOCK,A);if(!y)return`>${E}
31
+ ${c}${k}`}return r=r.replace(/\n+/g,`$&${c}`),`|${E}
32
+ ${c}${g}${r}${p}`}function fy(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:l,indentStep:c,inFlow:u}=e;if(s&&a.includes(`
33
+ `)||u&&/[[\]{},]/.test(a))return Rr(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
34
+ `)?Rr(a,e):ta(t,e,r,i);if(!s&&!u&&n!==Pe.Scalar.PLAIN&&a.includes(`
35
+ `))return ta(t,e,r,i);if(ia(a)){if(l==="")return e.forceBlockIndent=!0,ta(t,e,r,i);if(s&&l===c)return Rr(a,e)}let d=a.replace(/\n+/g,`$&
36
+ ${l}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:v}=e.doc.schema;if(v.some(f)||p?.some(f))return Rr(a,e)}return s?d:xt.foldFlowLines(d,l,xt.FOLD_FLOW,ra(e,!1))}function py(t,e,r,i){let{implicitKey:n,inFlow:a}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==Pe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Pe.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case Pe.Scalar.BLOCK_FOLDED:case Pe.Scalar.BLOCK_LITERAL:return n||a?Rr(o.value,e):ta(o,e,r,i);case Pe.Scalar.QUOTE_DOUBLE:return Ci(o.value,e);case Pe.Scalar.QUOTE_SINGLE:return Ms(o.value,e);case Pe.Scalar.PLAIN:return fy(o,e,r,i);default:return null}},c=l(s);if(c===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=n&&u||d;if(c=l(f),c===null)throw new Error(`Unsupported default string type ${f}`)}return c}ef.stringifyString=py});var Ri=N(Vs=>{"use strict";var hy=Un(),Ct=_(),my=Ei(),vy=Pi();function gy(t,e){let r=Object.assign({blockQuote:!0,commentString:my.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function wy(t,e){if(e.tag){let n=t.filter(a=>a.tag===e.tag);if(n.length>0)return n.find(a=>a.format===e.format)??n[0]}let r,i;if(Ct.isScalar(e)){i=e.value;let n=t.filter(a=>a.identify?.(i));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}r=n.find(a=>a.format===e.format)??n.find(a=>!a.format)}else i=e,r=t.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!r){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return r}function yy(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(Ct.isScalar(t)||Ct.isCollection(t))&&t.anchor;a&&hy.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=t.tag??(e.default?null:e.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Ny(t,e,r,i){if(Ct.isPair(t))return t.toString(e,r,i);if(Ct.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,a=Ct.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>n=l});n??(n=wy(e.doc.schema.tags,a));let o=yy(a,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,e,r,i):Ct.isScalar(a)?vy.stringifyString(a,e,r,i):a.toString(e,r,i);return o?Ct.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}Vs.createStringifyContext=gy;Vs.stringify=Ny});var af=N(nf=>{"use strict";var nt=_(),tf=q(),rf=Ri(),_i=Ei();function by({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:d}}=r,f=nt.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(nt.isCollection(t)||!nt.isNode(t)&&typeof t=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let p=!d&&(!t||f&&e==null&&!r.inFlow||nt.isCollection(t)||(nt.isScalar(t)?t.type===tf.Scalar.BLOCK_FOLDED||t.type===tf.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+l});let v=!1,h=!1,m=rf.stringify(t,r,()=>v=!0,()=>h=!0);if(!p&&!r.inFlow&&m.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(a||e==null)return v&&i&&i(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||e==null&&p)return m=`? ${m}`,f&&!v?m+=_i.lineComment(m,r.indent,c(f)):h&&n&&n(),m;v&&(f=null),p?(f&&(m+=_i.lineComment(m,r.indent,c(f))),m=`? ${m}
38
+ ${s}:`):(m=`${m}:`,f&&(m+=_i.lineComment(m,r.indent,c(f))));let w,g,b;nt.isNode(e)?(w=!!e.spaceBefore,g=e.commentBefore,b=e.comment):(w=!1,g=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!p&&!f&&nt.isScalar(e)&&(r.indentAtStart=m.length+1),h=!1,!u&&l.length>=2&&!r.inFlow&&!p&&nt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let E=!1,S=rf.stringify(e,r,()=>E=!0,()=>h=!0),y=" ";if(f||w||g){if(y=w?`
39
+ `:"",g){let A=c(g);y+=`
40
+ ${_i.indentComment(A,r.indent)}`}S===""&&!r.inFlow?y===`
41
+ `&&b&&(y=`
42
42
 
43
- `):g+=`
44
- ${r.indent}`}else if(!m&&Ue.isCollection(e)){let R=S[0],b=S.indexOf(`
45
- `),$=b!==-1,se=r.inFlow??e.flow??e.items.length===0;if($||!se){let Yt=!1;if($&&(R==="&"||R==="!")){let V=S.indexOf(" ");R==="&"&&V!==-1&&V<b&&S[V+1]==="!"&&(V=S.indexOf(" ",V+1)),(V===-1||b<V)&&(Yt=!0)}Yt||(g=`
43
+ `):y+=`
44
+ ${r.indent}`}else if(!p&&nt.isCollection(e)){let A=S[0],k=S.indexOf(`
45
+ `),D=k!==-1,pe=r.inFlow??e.flow??e.items.length===0;if(D||!pe){let Sr=!1;if(D&&(A==="&"||A==="!")){let G=S.indexOf(" ");A==="&"&&G!==-1&&G<k&&S[G+1]==="!"&&(G=S.indexOf(" ",G+1)),(G===-1||k<G)&&(Sr=!0)}Sr||(y=`
46
46
  ${r.indent}`)}}else(S===""||S[0]===`
47
- `)&&(g="");return h+=g+S,r.inFlow?x&&i&&i():k&&!x?h+=Jr.lineComment(h,r.indent,l(k)):p&&n&&n(),h}du.stringifyPair=Ev});var $o=N(To=>{"use strict";var pu=Yi("process");function xv(t,...e){t==="debug"&&console.log(...e)}function Cv(t,e){(t==="debug"||t==="warn")&&(typeof pu.emitWarning=="function"?pu.emitWarning(e):console.warn(e))}To.debug=xv;To.warn=Cv});var gn=N(vn=>{"use strict";var mn=P(),hu=B(),pn="<<",hn={identify:t=>t===pn||typeof t=="symbol"&&t.description===pn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new hu.Scalar(Symbol(pn)),{addToJSMap:mu}),stringify:()=>pn},Pv=(t,e)=>(hn.identify(e)||mn.isScalar(e)&&(!e.type||e.type===hu.Scalar.PLAIN)&&hn.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===hn.tag&&r.default);function mu(t,e,r){let i=vu(t,r);if(mn.isSeq(i))for(let n of i.items)jo(t,e,n);else if(Array.isArray(i))for(let n of i)jo(t,e,n);else jo(t,e,i)}function jo(t,e,r){let i=vu(t,r);if(!mn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,t,Map);for(let[a,o]of n)e instanceof Map?e.has(a)||e.set(a,o):e instanceof Set?e.add(a):Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function vu(t,e){return t&&mn.isAlias(e)?e.resolve(t.doc,t):e}vn.addMergeToJSMap=mu;vn.isMergeKey=Pv;vn.merge=hn});var Ho=N(yu=>{"use strict";var Rv=$o(),gu=gn(),_v=Gr(),wu=P(),Oo=pt();function Av(t,e,{key:r,value:i}){if(wu.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(gu.isMergeKey(t,r))gu.addMergeToJSMap(t,e,i);else{let n=Oo.toJS(r,"",t);if(e instanceof Map)e.set(n,Oo.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Iv(r,n,t),o=Oo.toJS(i,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function Iv(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(wu.isNode(t)&&r?.doc){let i=_v.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=t.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Rv.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(e)}yu.addPairToJSMap=Av});var gt=N(Do=>{"use strict";var Nu=Mr(),Tv=fu(),$v=Ho(),wn=P();function jv(t,e,r){let i=Nu.createNode(t,void 0,r),n=Nu.createNode(e,void 0,r);return new yn(i,n)}var yn=class t{constructor(e,r=null){Object.defineProperty(this,wn.NODE_TYPE,{value:wn.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return wn.isNode(r)&&(r=r.clone(e)),wn.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return $v.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Tv.stringifyPair(this,e,r,i):JSON.stringify(this)}};Do.Pair=yn;Do.createPair=jv});var Lo=N(ku=>{"use strict";var Ot=P(),bu=Gr(),Nn=Vr();function Ov(t,e,r){return(e.inFlow??t.flow?Dv:Hv)(t,e,r)}function Hv({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,u=Object.assign({},r,{indent:a,type:null}),d=!1,f=[];for(let w=0;w<e.length;++w){let p=e[w],h=null;if(Ot.isNode(p))!d&&p.spaceBefore&&f.push(""),bn(r,f,p.commentBefore,d),p.comment&&(h=p.comment);else if(Ot.isPair(p)){let v=Ot.isNode(p.key)?p.key:null;v&&(!d&&v.spaceBefore&&f.push(""),bn(r,f,v.commentBefore,d))}d=!1;let y=bu.stringify(p,u,()=>h=null,()=>d=!0);h&&(y+=Nn.lineComment(y,a,l(h))),d&&h&&(d=!1),f.push(i+y)}let m;if(f.length===0)m=n.start+n.end;else{m=f[0];for(let w=1;w<f.length;++w){let p=f[w];m+=p?`
48
- ${c}${p}`:`
49
- `}}return t?(m+=`
50
- `+Nn.indentComment(l(t),c),s&&s()):d&&o&&o(),m}function Dv({items:t},e,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;i+=a;let c=Object.assign({},e,{indent:i,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let w=0;w<t.length;++w){let p=t[w],h=null;if(Ot.isNode(p))p.spaceBefore&&d.push(""),bn(e,d,p.commentBefore,!1),p.comment&&(h=p.comment);else if(Ot.isPair(p)){let v=Ot.isNode(p.key)?p.key:null;v&&(v.spaceBefore&&d.push(""),bn(e,d,v.commentBefore,!1),v.comment&&(l=!0));let k=Ot.isNode(p.value)?p.value:null;k?(k.comment&&(h=k.comment),k.commentBefore&&(l=!0)):p.value==null&&v?.comment&&(h=v.comment)}h&&(l=!0);let y=bu.stringify(p,c,()=>h=null);l||(l=d.length>u||y.includes(`
51
- `)),w<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((v,k)=>v+k.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),h&&(y+=Nn.lineComment(y,i,s(h))),d.push(y),u=d.length}let{start:f,end:m}=r;if(d.length===0)return f+m;if(!l){let w=d.reduce((p,h)=>p+h.length+2,2);l=e.options.lineWidth>0&&w>e.options.lineWidth}if(l){let w=f;for(let p of d)w+=p?`
52
- ${a}${n}${p}`:`
53
- `;return`${w}
54
- ${n}${m}`}else return`${f}${o}${d.join(" ")}${o}${m}`}function bn({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=Nn.indentComment(e(i),t);r.push(a.trimStart())}}ku.stringifyCollection=Ov});var yt=N(Fo=>{"use strict";var Lv=Lo(),Bv=Ho(),Fv=sn(),wt=P(),kn=gt(),Mv=B();function Ur(t,e){let r=wt.isScalar(e)?e.value:e;for(let i of t)if(wt.isPair(i)&&(i.key===e||i.key===r||wt.isScalar(i.key)&&i.key.value===r))return i}var Bo=class extends Fv.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(wt.MAP,e),this.items=[]}static from(e,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(e),s=(c,l)=>{if(typeof a=="function")l=a.call(r,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(kn.createPair(c,l,i))};if(r instanceof Map)for(let[c,l]of r)s(c,l);else if(r&&typeof r=="object")for(let c of Object.keys(r))s(c,r[c]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let i;wt.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new kn.Pair(e,e?.value):i=new kn.Pair(e.key,e.value);let n=Ur(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);wt.isScalar(n.value)&&Mv.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let r=Ur(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=Ur(this.items,e)?.value;return(!r&&wt.isScalar(n)?n.value:n)??void 0}has(e){return!!Ur(this.items,e)}set(e,r){this.add(new kn.Pair(e,r),!0)}toJSON(e,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Bv.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!wt.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Lv.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};Fo.YAMLMap=Bo;Fo.findPair=Ur});var tr=N(Eu=>{"use strict";var Vv=P(),Su=yt(),qv={collection:"map",default:!0,nodeClass:Su.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Vv.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>Su.YAMLMap.from(t,e,r)};Eu.map=qv});var Nt=N(xu=>{"use strict";var Wv=Mr(),zv=Lo(),Gv=sn(),En=P(),Jv=B(),Uv=pt(),Mo=class extends Gv.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(En.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=Sn(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=Sn(e);if(typeof i!="number")return;let n=this.items[i];return!r&&En.isScalar(n)?n.value:n}has(e){let r=Sn(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=Sn(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];En.isScalar(n)&&Jv.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(e,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(Uv.toJS(a,String(n++),r));return i}toString(e,r,i){return e?zv.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let c=r instanceof Set?s:String(o++);s=n.call(r,c,s)}a.items.push(Wv.createNode(s,void 0,i))}}return a}};function Sn(t){let e=En.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}xu.YAMLSeq=Mo});var rr=N(Pu=>{"use strict";var Kv=P(),Cu=Nt(),Yv={collection:"seq",default:!0,nodeClass:Cu.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Kv.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>Cu.YAMLSeq.from(t,e,r)};Pu.seq=Yv});var Kr=N(Ru=>{"use strict";var Xv=zr(),Qv={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,i){return e=Object.assign({actualString:!0},e),Xv.stringifyString(t,e,r,i)}};Ru.string=Qv});var xn=N(Iu=>{"use strict";var _u=B(),Au={identify:t=>t==null,createNode:()=>new _u.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new _u.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Au.test.test(t)?t:e.options.nullStr};Iu.nullTag=Au});var Vo=N($u=>{"use strict";var Zv=B(),Tu={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Zv.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&Tu.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};$u.boolTag=Tu});var ir=N(ju=>{"use strict";function eg({format:t,minFractionDigits:e,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}ju.stringifyNumber=eg});var Wo=N(Cn=>{"use strict";var tg=B(),qo=ir(),rg={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:qo.stringifyNumber},ig={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():qo.stringifyNumber(t)}},ng={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new tg.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:qo.stringifyNumber};Cn.float=ng;Cn.floatExp=ig;Cn.floatNaN=rg});var Go=N(Rn=>{"use strict";var Ou=ir(),Pn=t=>typeof t=="bigint"||Number.isInteger(t),zo=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Hu(t,e,r){let{value:i}=t;return Pn(i)&&i>=0?r+i.toString(e):Ou.stringifyNumber(t)}var ag={identify:t=>Pn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>zo(t,2,8,r),stringify:t=>Hu(t,8,"0o")},og={identify:Pn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>zo(t,0,10,r),stringify:Ou.stringifyNumber},sg={identify:t=>Pn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>zo(t,2,16,r),stringify:t=>Hu(t,16,"0x")};Rn.int=og;Rn.intHex=sg;Rn.intOct=ag});var Lu=N(Du=>{"use strict";var cg=tr(),lg=xn(),ug=rr(),dg=Kr(),fg=Vo(),Jo=Wo(),Uo=Go(),pg=[cg.map,ug.seq,dg.string,lg.nullTag,fg.boolTag,Uo.intOct,Uo.int,Uo.intHex,Jo.floatNaN,Jo.floatExp,Jo.float];Du.schema=pg});var Mu=N(Fu=>{"use strict";var hg=B(),mg=tr(),vg=rr();function Bu(t){return typeof t=="bigint"||Number.isInteger(t)}var _n=({value:t})=>JSON.stringify(t),gg=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:_n},{identify:t=>t==null,createNode:()=>new hg.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_n},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:_n},{identify:Bu,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>Bu(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:_n}],wg={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},yg=[mg.map,vg.seq].concat(gg,wg);Fu.schema=yg});var Yo=N(Vu=>{"use strict";var Yr=Yi("buffer"),Ko=B(),Ng=zr(),bg={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Yr.Buffer=="function")return Yr.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof Yr.Buffer=="function")s=o instanceof Yr.Buffer?o.toString("base64"):Yr.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Ko.Scalar.BLOCK_LITERAL),e!==Ko.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),u=new Array(l);for(let d=0,f=0;d<l;++d,f+=c)u[d]=s.substr(f,c);s=u.join(e===Ko.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return Ng.stringifyString({comment:t,type:e,value:s},i,n,a)}};Vu.binary=bg});var Tn=N(In=>{"use strict";var An=P(),Xo=gt(),kg=B(),Sg=Nt();function qu(t,e){if(An.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!An.isPair(i)){if(An.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new Xo.Pair(new kg.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
47
+ `)&&(y="");return m+=y+S,r.inFlow?E&&i&&i():b&&!E?m+=_i.lineComment(m,r.indent,c(b)):h&&n&&n(),m}nf.stringifyPair=by});var Ws=N(qs=>{"use strict";var of=qn("process");function ky(t,...e){t==="debug"&&console.log(...e)}function Sy(t,e){(t==="debug"||t==="warn")&&(typeof of.emitWarning=="function"?of.emitWarning(e):console.warn(e))}qs.debug=ky;qs.warn=Sy});var ca=N(sa=>{"use strict";var oa=_(),sf=q(),na="<<",aa={identify:t=>t===na||typeof t=="symbol"&&t.description===na,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new sf.Scalar(Symbol(na)),{addToJSMap:cf}),stringify:()=>na},Ey=(t,e)=>(aa.identify(e)||oa.isScalar(e)&&(!e.type||e.type===sf.Scalar.PLAIN)&&aa.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===aa.tag&&r.default);function cf(t,e,r){let i=lf(t,r);if(oa.isSeq(i))for(let n of i.items)zs(t,e,n);else if(Array.isArray(i))for(let n of i)zs(t,e,n);else zs(t,e,i)}function zs(t,e,r){let i=lf(t,r);if(!oa.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,t,Map);for(let[a,o]of n)e instanceof Map?e.has(a)||e.set(a,o):e instanceof Set?e.add(a):Object.prototype.hasOwnProperty.call(e,a)||Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function lf(t,e){return t&&oa.isAlias(e)?e.resolve(t.doc,t):e}sa.addMergeToJSMap=cf;sa.isMergeKey=Ey;sa.merge=aa});var Js=N(ff=>{"use strict";var xy=Ws(),uf=ca(),Cy=Ri(),df=_(),Gs=St();function Py(t,e,{key:r,value:i}){if(df.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(uf.isMergeKey(t,r))uf.addMergeToJSMap(t,e,i);else{let n=Gs.toJS(r,"",t);if(e instanceof Map)e.set(n,Gs.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=Ry(r,n,t),o=Gs.toJS(i,a,t);a in e?Object.defineProperty(e,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[a]=o}}return e}function Ry(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(df.isNode(t)&&r?.doc){let i=Cy.createStringifyContext(r.doc,{});i.anchors=new Set;for(let a of r.anchors.keys())i.anchors.add(a.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=t.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),xy.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return n}return JSON.stringify(e)}ff.addPairToJSMap=Py});var Pt=N(Us=>{"use strict";var pf=Si(),_y=af(),Ay=Js(),la=_();function Iy(t,e,r){let i=pf.createNode(t,void 0,r),n=pf.createNode(e,void 0,r);return new ua(i,n)}var ua=class t{constructor(e,r=null){Object.defineProperty(this,la.NODE_TYPE,{value:la.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return la.isNode(r)&&(r=r.clone(e)),la.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Ay.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?_y.stringifyPair(this,e,r,i):JSON.stringify(this)}};Us.Pair=ua;Us.createPair=Iy});var Ks=N(mf=>{"use strict";var Ut=_(),hf=Ri(),da=Ei();function Ty(t,e,r){return(e.inFlow??t.flow?jy:$y)(t,e,r)}function $y({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:l,options:{commentString:c}}=r,u=Object.assign({},r,{indent:a,type:null}),d=!1,f=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(Ut.isNode(h))!d&&h.spaceBefore&&f.push(""),fa(r,f,h.commentBefore,d),h.comment&&(m=h.comment);else if(Ut.isPair(h)){let g=Ut.isNode(h.key)?h.key:null;g&&(!d&&g.spaceBefore&&f.push(""),fa(r,f,g.commentBefore,d))}d=!1;let w=hf.stringify(h,u,()=>m=null,()=>d=!0);m&&(w+=da.lineComment(w,a,c(m))),d&&m&&(d=!1),f.push(i+w)}let p;if(f.length===0)p=n.start+n.end;else{p=f[0];for(let v=1;v<f.length;++v){let h=f[v];p+=h?`
48
+ ${l}${h}`:`
49
+ `}}return t?(p+=`
50
+ `+da.indentComment(c(t),l),s&&s()):d&&o&&o(),p}function jy({items:t},e,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=e;i+=a;let l=Object.assign({},e,{indent:i,inFlow:!0,type:null}),c=!1,u=0,d=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(Ut.isNode(h))h.spaceBefore&&d.push(""),fa(e,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(Ut.isPair(h)){let g=Ut.isNode(h.key)?h.key:null;g&&(g.spaceBefore&&d.push(""),fa(e,d,g.commentBefore,!1),g.comment&&(c=!0));let b=Ut.isNode(h.value)?h.value:null;b?(b.comment&&(m=b.comment),b.commentBefore&&(c=!0)):h.value==null&&g?.comment&&(m=g.comment)}m&&(c=!0);let w=hf.stringify(h,l,()=>m=null);c||(c=d.length>u||w.includes(`
51
+ `)),v<t.length-1?w+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=d.reduce((g,b)=>g+b.length+2,2)+(w.length+2)>e.options.lineWidth)),c&&(w+=",")),m&&(w+=da.lineComment(w,i,s(m))),d.push(w),u=d.length}let{start:f,end:p}=r;if(d.length===0)return f+p;if(!c){let v=d.reduce((h,m)=>h+m.length+2,2);c=e.options.lineWidth>0&&v>e.options.lineWidth}if(c){let v=f;for(let h of d)v+=h?`
52
+ ${a}${n}${h}`:`
53
+ `;return`${v}
54
+ ${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function fa({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=da.indentComment(e(i),t);r.push(a.trimStart())}}mf.stringifyCollection=Ty});var _t=N(Xs=>{"use strict";var Oy=Ks(),Hy=Js(),Dy=Qn(),Rt=_(),pa=Pt(),Ly=q();function Ai(t,e){let r=Rt.isScalar(e)?e.value:e;for(let i of t)if(Rt.isPair(i)&&(i.key===e||i.key===r||Rt.isScalar(i.key)&&i.key.value===r))return i}var Ys=class extends Dy.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Rt.MAP,e),this.items=[]}static from(e,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(e),s=(l,c)=>{if(typeof a=="function")c=a.call(r,l,c);else if(Array.isArray(a)&&!a.includes(l))return;(c!==void 0||n)&&o.items.push(pa.createPair(l,c,i))};if(r instanceof Map)for(let[l,c]of r)s(l,c);else if(r&&typeof r=="object")for(let l of Object.keys(r))s(l,r[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let i;Rt.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new pa.Pair(e,e?.value):i=new pa.Pair(e.key,e.value);let n=Ai(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);Rt.isScalar(n.value)&&Ly.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(a){let o=this.items.findIndex(s=>a(i,s)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let r=Ai(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=Ai(this.items,e)?.value;return(!r&&Rt.isScalar(n)?n.value:n)??void 0}has(e){return!!Ai(this.items,e)}set(e,r){this.add(new pa.Pair(e,r),!0)}toJSON(e,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Hy.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Rt.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Oy.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};Xs.YAMLMap=Ys;Xs.findPair=Ai});var _r=N(gf=>{"use strict";var By=_(),vf=_t(),My={collection:"map",default:!0,nodeClass:vf.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return By.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>vf.YAMLMap.from(t,e,r)};gf.map=My});var At=N(wf=>{"use strict";var Fy=Si(),Vy=Ks(),qy=Qn(),ma=_(),Wy=q(),zy=St(),Qs=class extends qy.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ma.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=ha(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=ha(e);if(typeof i!="number")return;let n=this.items[i];return!r&&ma.isScalar(n)?n.value:n}has(e){let r=ha(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=ha(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];ma.isScalar(n)&&Wy.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(e,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(zy.toJS(a,String(n++),r));return i}toString(e,r,i){return e?Vy.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r)){let o=0;for(let s of r){if(typeof n=="function"){let l=r instanceof Set?s:String(o++);s=n.call(r,l,s)}a.items.push(Fy.createNode(s,void 0,i))}}return a}};function ha(t){let e=ma.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}wf.YAMLSeq=Qs});var Ar=N(Nf=>{"use strict";var Gy=_(),yf=At(),Jy={collection:"seq",default:!0,nodeClass:yf.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Gy.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>yf.YAMLSeq.from(t,e,r)};Nf.seq=Jy});var Ii=N(bf=>{"use strict";var Uy=Pi(),Ky={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,i){return e=Object.assign({actualString:!0},e),Uy.stringifyString(t,e,r,i)}};bf.string=Ky});var va=N(Ef=>{"use strict";var kf=q(),Sf={identify:t=>t==null,createNode:()=>new kf.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new kf.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Sf.test.test(t)?t:e.options.nullStr};Ef.nullTag=Sf});var Zs=N(Cf=>{"use strict";var Yy=q(),xf={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new Yy.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&xf.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};Cf.boolTag=xf});var Ir=N(Pf=>{"use strict";function Xy({format:t,minFractionDigits:e,tag:r,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(i,-0)?"-0":JSON.stringify(i);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=e-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Pf.stringifyNumber=Xy});var tc=N(ga=>{"use strict";var Qy=q(),ec=Ir(),Zy={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ec.stringifyNumber},eN={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():ec.stringifyNumber(t)}},tN={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new Qy.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:ec.stringifyNumber};ga.float=tN;ga.floatExp=eN;ga.floatNaN=Zy});var ic=N(ya=>{"use strict";var Rf=Ir(),wa=t=>typeof t=="bigint"||Number.isInteger(t),rc=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function _f(t,e,r){let{value:i}=t;return wa(i)&&i>=0?r+i.toString(e):Rf.stringifyNumber(t)}var rN={identify:t=>wa(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>rc(t,2,8,r),stringify:t=>_f(t,8,"0o")},iN={identify:wa,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>rc(t,0,10,r),stringify:Rf.stringifyNumber},nN={identify:t=>wa(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>rc(t,2,16,r),stringify:t=>_f(t,16,"0x")};ya.int=iN;ya.intHex=nN;ya.intOct=rN});var If=N(Af=>{"use strict";var aN=_r(),oN=va(),sN=Ar(),cN=Ii(),lN=Zs(),nc=tc(),ac=ic(),uN=[aN.map,sN.seq,cN.string,oN.nullTag,lN.boolTag,ac.intOct,ac.int,ac.intHex,nc.floatNaN,nc.floatExp,nc.float];Af.schema=uN});var jf=N($f=>{"use strict";var dN=q(),fN=_r(),pN=Ar();function Tf(t){return typeof t=="bigint"||Number.isInteger(t)}var Na=({value:t})=>JSON.stringify(t),hN=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Na},{identify:t=>t==null,createNode:()=>new dN.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Na},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Na},{identify:Tf,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>Tf(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Na}],mN={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},vN=[fN.map,pN.seq].concat(hN,mN);$f.schema=vN});var sc=N(Of=>{"use strict";var Ti=qn("buffer"),oc=q(),gN=Pi(),wN={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Ti.Buffer=="function")return Ti.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),i=new Uint8Array(r.length);for(let n=0;n<r.length;++n)i[n]=r.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof Ti.Buffer=="function")s=o instanceof Ti.Buffer?o.toString("base64"):Ti.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);s=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=oc.Scalar.BLOCK_LITERAL),e!==oc.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(s.length/l),u=new Array(c);for(let d=0,f=0;d<c;++d,f+=l)u[d]=s.substr(f,l);s=u.join(e===oc.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return gN.stringifyString({comment:t,type:e,value:s},i,n,a)}};Of.binary=wN});var Sa=N(ka=>{"use strict";var ba=_(),cc=Pt(),yN=q(),NN=At();function Hf(t,e){if(ba.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!ba.isPair(i)){if(ba.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new cc.Pair(new yN.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
56
56
  ${n.key.commentBefore}`:i.commentBefore),i.comment){let a=n.value??n.key;a.comment=a.comment?`${i.comment}
57
- ${a.comment}`:i.comment}i=n}t.items[r]=An.isPair(i)?i:new Xo.Pair(i)}}else e("Expected a sequence for this tag");return t}function Wu(t,e,r){let{replacer:i}=r,n=new Sg.YAMLSeq(t);n.tag="tag:yaml.org,2002:pairs";let a=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(Xo.createPair(s,c,r))}return n}var Eg={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:qu,createNode:Wu};In.createPairs=Wu;In.pairs=Eg;In.resolvePairs=qu});var es=N(Zo=>{"use strict";var zu=P(),Qo=pt(),Xr=yt(),xg=Nt(),Gu=Tn(),Ht=class t extends xg.YAMLSeq{constructor(){super(),this.add=Xr.YAMLMap.prototype.add.bind(this),this.delete=Xr.YAMLMap.prototype.delete.bind(this),this.get=Xr.YAMLMap.prototype.get.bind(this),this.has=Xr.YAMLMap.prototype.has.bind(this),this.set=Xr.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(zu.isPair(n)?(a=Qo.toJS(n.key,"",r),o=Qo.toJS(n.value,a,r)):a=Qo.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(e,r,i){let n=Gu.createPairs(e,r,i),a=new this;return a.items=n.items,a}};Ht.tag="tag:yaml.org,2002:omap";var Cg={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ht,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=Gu.resolvePairs(t,e),i=[];for(let{key:n}of r.items)zu.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Ht,r)},createNode:(t,e,r)=>Ht.from(t,e,r)};Zo.YAMLOMap=Ht;Zo.omap=Cg});var Xu=N(ts=>{"use strict";var Ju=B();function Uu({value:t,source:e},r){return e&&(t?Ku:Yu).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Ku={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ju.Scalar(!0),stringify:Uu},Yu={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ju.Scalar(!1),stringify:Uu};ts.falseTag=Yu;ts.trueTag=Ku});var Qu=N($n=>{"use strict";var Pg=B(),rs=ir(),Rg={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:rs.stringifyNumber},_g={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():rs.stringifyNumber(t)}},Ag={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Pg.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let i=t.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:rs.stringifyNumber};$n.float=Ag;$n.floatExp=_g;$n.floatNaN=Rg});var ed=N(Zr=>{"use strict";var Zu=ir(),Qr=t=>typeof t=="bigint"||Number.isInteger(t);function jn(t,e,r,{intAsBigInt:i}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),i){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return n==="-"?BigInt(-1)*o:o}let a=parseInt(t,r);return n==="-"?-1*a:a}function is(t,e,r){let{value:i}=t;if(Qr(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Zu.stringifyNumber(t)}var Ig={identify:Qr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>jn(t,2,2,r),stringify:t=>is(t,2,"0b")},Tg={identify:Qr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>jn(t,1,8,r),stringify:t=>is(t,8,"0")},$g={identify:Qr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>jn(t,0,10,r),stringify:Zu.stringifyNumber},jg={identify:Qr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>jn(t,2,16,r),stringify:t=>is(t,16,"0x")};Zr.int=$g;Zr.intBin=Ig;Zr.intHex=jg;Zr.intOct=Tg});var as=N(ns=>{"use strict";var Dn=P(),On=gt(),Hn=yt(),Dt=class t extends Hn.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;Dn.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new On.Pair(e.key,null):r=new On.Pair(e,null),Hn.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=Hn.findPair(this.items,e);return!r&&Dn.isPair(i)?Dn.isScalar(i.key)?i.key.value:i.key:i}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=Hn.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new On.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(On.createPair(o,null,i));return a}};Dt.tag="tag:yaml.org,2002:set";var Og={collection:"map",identify:t=>t instanceof Set,nodeClass:Dt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Dt.from(t,e,r),resolve(t,e){if(Dn.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Dt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};ns.YAMLSet=Dt;ns.set=Og});var ss=N(Ln=>{"use strict";var Hg=ir();function os(t,e){let r=t[0],i=r==="-"||r==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function td(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Hg.stringifyNumber(t);let i="";e<0&&(i="-",e*=r(-1));let n=r(60),a=[e%n];return e<60?a.unshift(0):(e=(e-a[0])/n,a.unshift(e%n),e>=60&&(e=(e-a[0])/n,a.unshift(e))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Dg={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>os(t,r),stringify:td},Lg={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>os(t,!1),stringify:td},rd={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(rd.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),u=e[8];if(u&&u!=="Z"){let d=os(u,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Ln.floatTime=Lg;Ln.intTime=Dg;Ln.timestamp=rd});var ad=N(nd=>{"use strict";var Bg=tr(),Fg=xn(),Mg=rr(),Vg=Kr(),qg=Yo(),id=Xu(),cs=Qu(),Bn=ed(),Wg=gn(),zg=es(),Gg=Tn(),Jg=as(),ls=ss(),Ug=[Bg.map,Mg.seq,Vg.string,Fg.nullTag,id.trueTag,id.falseTag,Bn.intBin,Bn.intOct,Bn.int,Bn.intHex,cs.floatNaN,cs.floatExp,cs.float,qg.binary,Wg.merge,zg.omap,Gg.pairs,Jg.set,ls.intTime,ls.floatTime,ls.timestamp];nd.schema=Ug});var md=N(fs=>{"use strict";var ld=tr(),Kg=xn(),ud=rr(),Yg=Kr(),Xg=Vo(),us=Wo(),ds=Go(),Qg=Lu(),Zg=Mu(),dd=Yo(),ei=gn(),fd=es(),pd=Tn(),od=ad(),hd=as(),Fn=ss(),sd=new Map([["core",Qg.schema],["failsafe",[ld.map,ud.seq,Yg.string]],["json",Zg.schema],["yaml11",od.schema],["yaml-1.1",od.schema]]),cd={binary:dd.binary,bool:Xg.boolTag,float:us.float,floatExp:us.floatExp,floatNaN:us.floatNaN,floatTime:Fn.floatTime,int:ds.int,intHex:ds.intHex,intOct:ds.intOct,intTime:Fn.intTime,map:ld.map,merge:ei.merge,null:Kg.nullTag,omap:fd.omap,pairs:pd.pairs,seq:ud.seq,set:hd.set,timestamp:Fn.timestamp},ew={"tag:yaml.org,2002:binary":dd.binary,"tag:yaml.org,2002:merge":ei.merge,"tag:yaml.org,2002:omap":fd.omap,"tag:yaml.org,2002:pairs":pd.pairs,"tag:yaml.org,2002:set":hd.set,"tag:yaml.org,2002:timestamp":Fn.timestamp};function tw(t,e,r){let i=sd.get(e);if(i&&!t)return r&&!i.includes(ei.merge)?i.concat(ei.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(sd.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${a} or define customTags array`)}if(Array.isArray(t))for(let a of t)n=n.concat(a);else typeof t=="function"&&(n=t(n.slice()));return r&&(n=n.concat(ei.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?cd[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(cd).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}fs.coreKnownTags=ew;fs.getTags=tw});var ms=N(vd=>{"use strict";var ps=P(),rw=tr(),iw=rr(),nw=Kr(),Mn=md(),aw=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,hs=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Mn.getTags(e,"compat"):e?Mn.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Mn.coreKnownTags:{},this.tags=Mn.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,ps.MAP,{value:rw.map}),Object.defineProperty(this,ps.SCALAR,{value:nw.string}),Object.defineProperty(this,ps.SEQ,{value:iw.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?aw:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};vd.Schema=hs});var wd=N(gd=>{"use strict";var ow=P(),vs=Gr(),ti=Vr();function sw(t,e){let r=[],i=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(r.push(c),i=!0):t.directives.docStart&&(i=!0)}i&&r.push("---");let n=vs.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(ti.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(ow.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);r.push(ti.indentComment(u,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=vs.stringify(t.contents,n,()=>s=null,c);s&&(l+=ti.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(vs.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
- `)?(r.push("..."),r.push(ti.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=t.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(ti.indentComment(a(c),"")))}return r.join(`
57
+ ${a.comment}`:i.comment}i=n}t.items[r]=ba.isPair(i)?i:new cc.Pair(i)}}else e("Expected a sequence for this tag");return t}function Df(t,e,r){let{replacer:i}=r,n=new NN.YAMLSeq(t);n.tag="tag:yaml.org,2002:pairs";let a=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(a++),o));let s,l;if(Array.isArray(o))if(o.length===2)s=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)s=c[0],l=o[s];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else s=o;n.items.push(cc.createPair(s,l,r))}return n}var bN={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Hf,createNode:Df};ka.createPairs=Df;ka.pairs=bN;ka.resolvePairs=Hf});var dc=N(uc=>{"use strict";var Lf=_(),lc=St(),$i=_t(),kN=At(),Bf=Sa(),Kt=class t extends kN.YAMLSeq{constructor(){super(),this.add=$i.YAMLMap.prototype.add.bind(this),this.delete=$i.YAMLMap.prototype.delete.bind(this),this.get=$i.YAMLMap.prototype.get.bind(this),this.has=$i.YAMLMap.prototype.has.bind(this),this.set=$i.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Lf.isPair(n)?(a=lc.toJS(n.key,"",r),o=lc.toJS(n.value,a,r)):a=lc.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(e,r,i){let n=Bf.createPairs(e,r,i),a=new this;return a.items=n.items,a}};Kt.tag="tag:yaml.org,2002:omap";var SN={collection:"seq",identify:t=>t instanceof Map,nodeClass:Kt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=Bf.resolvePairs(t,e),i=[];for(let{key:n}of r.items)Lf.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Kt,r)},createNode:(t,e,r)=>Kt.from(t,e,r)};uc.YAMLOMap=Kt;uc.omap=SN});var Wf=N(fc=>{"use strict";var Mf=q();function Ff({value:t,source:e},r){return e&&(t?Vf:qf).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Vf={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Mf.Scalar(!0),stringify:Ff},qf={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Mf.Scalar(!1),stringify:Ff};fc.falseTag=qf;fc.trueTag=Vf});var zf=N(Ea=>{"use strict";var EN=q(),pc=Ir(),xN={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:pc.stringifyNumber},CN={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():pc.stringifyNumber(t)}},PN={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new EN.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let i=t.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:pc.stringifyNumber};Ea.float=PN;Ea.floatExp=CN;Ea.floatNaN=xN});var Jf=N(Oi=>{"use strict";var Gf=Ir(),ji=t=>typeof t=="bigint"||Number.isInteger(t);function xa(t,e,r,{intAsBigInt:i}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),i){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return n==="-"?BigInt(-1)*o:o}let a=parseInt(t,r);return n==="-"?-1*a:a}function hc(t,e,r){let{value:i}=t;if(ji(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Gf.stringifyNumber(t)}var RN={identify:ji,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>xa(t,2,2,r),stringify:t=>hc(t,2,"0b")},_N={identify:ji,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>xa(t,1,8,r),stringify:t=>hc(t,8,"0")},AN={identify:ji,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>xa(t,0,10,r),stringify:Gf.stringifyNumber},IN={identify:ji,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>xa(t,2,16,r),stringify:t=>hc(t,16,"0x")};Oi.int=AN;Oi.intBin=RN;Oi.intHex=IN;Oi.intOct=_N});var vc=N(mc=>{"use strict";var Ra=_(),Ca=Pt(),Pa=_t(),Yt=class t extends Pa.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;Ra.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Ca.Pair(e.key,null):r=new Ca.Pair(e,null),Pa.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=Pa.findPair(this.items,e);return!r&&Ra.isPair(i)?Ra.isScalar(i.key)?i.key.value:i.key:i}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=Pa.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Ca.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(e,r,i){let{replacer:n}=i,a=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(Ca.createPair(o,null,i));return a}};Yt.tag="tag:yaml.org,2002:set";var TN={collection:"map",identify:t=>t instanceof Set,nodeClass:Yt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Yt.from(t,e,r),resolve(t,e){if(Ra.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Yt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};mc.YAMLSet=Yt;mc.set=TN});var wc=N(_a=>{"use strict";var $N=Ir();function gc(t,e){let r=t[0],i=r==="-"||r==="+"?t.substring(1):t,n=o=>e?BigInt(o):Number(o),a=i.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return r==="-"?n(-1)*a:a}function Uf(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return $N.stringifyNumber(t);let i="";e<0&&(i="-",e*=r(-1));let n=r(60),a=[e%n];return e<60?a.unshift(0):(e=(e-a[0])/n,a.unshift(e%n),e>=60&&(e=(e-a[0])/n,a.unshift(e))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var jN={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>gc(t,r),stringify:Uf},ON={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>gc(t,!1),stringify:Uf},Kf={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Kf.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(r,i-1,n,a||0,o||0,s||0,l),u=e[8];if(u&&u!=="Z"){let d=gc(u,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};_a.floatTime=ON;_a.intTime=jN;_a.timestamp=Kf});var Qf=N(Xf=>{"use strict";var HN=_r(),DN=va(),LN=Ar(),BN=Ii(),MN=sc(),Yf=Wf(),yc=zf(),Aa=Jf(),FN=ca(),VN=dc(),qN=Sa(),WN=vc(),Nc=wc(),zN=[HN.map,LN.seq,BN.string,DN.nullTag,Yf.trueTag,Yf.falseTag,Aa.intBin,Aa.intOct,Aa.int,Aa.intHex,yc.floatNaN,yc.floatExp,yc.float,MN.binary,FN.merge,VN.omap,qN.pairs,WN.set,Nc.intTime,Nc.floatTime,Nc.timestamp];Xf.schema=zN});var cp=N(Sc=>{"use strict";var rp=_r(),GN=va(),ip=Ar(),JN=Ii(),UN=Zs(),bc=tc(),kc=ic(),KN=If(),YN=jf(),np=sc(),Hi=ca(),ap=dc(),op=Sa(),Zf=Qf(),sp=vc(),Ia=wc(),ep=new Map([["core",KN.schema],["failsafe",[rp.map,ip.seq,JN.string]],["json",YN.schema],["yaml11",Zf.schema],["yaml-1.1",Zf.schema]]),tp={binary:np.binary,bool:UN.boolTag,float:bc.float,floatExp:bc.floatExp,floatNaN:bc.floatNaN,floatTime:Ia.floatTime,int:kc.int,intHex:kc.intHex,intOct:kc.intOct,intTime:Ia.intTime,map:rp.map,merge:Hi.merge,null:GN.nullTag,omap:ap.omap,pairs:op.pairs,seq:ip.seq,set:sp.set,timestamp:Ia.timestamp},XN={"tag:yaml.org,2002:binary":np.binary,"tag:yaml.org,2002:merge":Hi.merge,"tag:yaml.org,2002:omap":ap.omap,"tag:yaml.org,2002:pairs":op.pairs,"tag:yaml.org,2002:set":sp.set,"tag:yaml.org,2002:timestamp":Ia.timestamp};function QN(t,e,r){let i=ep.get(e);if(i&&!t)return r&&!i.includes(Hi.merge)?i.concat(Hi.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(ep.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${a} or define customTags array`)}if(Array.isArray(t))for(let a of t)n=n.concat(a);else typeof t=="function"&&(n=t(n.slice()));return r&&(n=n.concat(Hi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?tp[o]:o;if(!s){let l=JSON.stringify(o),c=Object.keys(tp).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return a.includes(s)||a.push(s),a},[])}Sc.coreKnownTags=XN;Sc.getTags=QN});var Cc=N(lp=>{"use strict";var Ec=_(),ZN=_r(),eb=Ar(),tb=Ii(),Ta=cp(),rb=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,xc=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Ta.getTags(e,"compat"):e?Ta.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Ta.coreKnownTags:{},this.tags=Ta.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Ec.MAP,{value:ZN.map}),Object.defineProperty(this,Ec.SCALAR,{value:tb.string}),Object.defineProperty(this,Ec.SEQ,{value:eb.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?rb:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};lp.Schema=xc});var dp=N(up=>{"use strict";var ib=_(),Pc=Ri(),Di=Ei();function nb(t,e){let r=[],i=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(r.push(l),i=!0):t.directives.docStart&&(i=!0)}i&&r.push("---");let n=Pc.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let l=a(t.commentBefore);r.unshift(Di.indentComment(l,""))}let o=!1,s=null;if(t.contents){if(ib.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let u=a(t.contents.commentBefore);r.push(Di.indentComment(u,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let l=s?void 0:()=>o=!0,c=Pc.stringify(t.contents,n,()=>s=null,l);s&&(c+=Di.lineComment(c,"",a(s))),(c[0]==="|"||c[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${c}`:r.push(c)}else r.push(Pc.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let l=a(t.comment);l.includes(`
58
+ `)?(r.push("..."),r.push(Di.indentComment(l,""))):r.push(`... ${l}`)}else r.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(Di.indentComment(a(l),"")))}return r.join(`
59
59
  `)+`
60
- `}gd.stringifyDocument=sw});var ri=N(yd=>{"use strict";var cw=Fr(),nr=sn(),fe=P(),lw=gt(),uw=pt(),dw=ms(),fw=wd(),gs=rn(),pw=bo(),hw=Mr(),ws=No(),ys=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,fe.NODE_TYPE,{value:fe.DOC});let n=null;typeof r=="function"||Array.isArray(r)?n=r:i===void 0&&r&&(i=r,r=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:o}=a;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new ws.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(t.prototype,{[fe.NODE_TYPE]:{value:fe.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=fe.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ar(this.contents)&&this.contents.add(e)}addIn(e,r){ar(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=gs.anchorNames(this);e.anchor=!r||i.has(r)?gs.findNewAnchor(r||"a",i):r}return new cw.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let h=v=>typeof v=="number"||v instanceof String||v instanceof Number,y=r.filter(h).map(String);y.length>0&&(r=r.concat(y)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:u}=i??{},{onAnchor:d,setAnchors:f,sourceObjects:m}=gs.createNodeAnchors(this,o||"a"),w={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:m},p=hw.createNode(e,u,w);return s&&fe.isCollection(p)&&(p.flow=!0),f(),p}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new lw.Pair(n,a)}delete(e){return ar(this.contents)?this.contents.delete(e):!1}deleteIn(e){return nr.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):ar(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return fe.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return nr.isEmptyPath(e)?!r&&fe.isScalar(this.contents)?this.contents.value:this.contents:fe.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return fe.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return nr.isEmptyPath(e)?this.contents!==void 0:fe.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=nr.collectionFromPath(this.schema,[e],r):ar(this.contents)&&this.contents.set(e,r)}setIn(e,r){nr.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=nr.collectionFromPath(this.schema,Array.from(e),r):ar(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new ws.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new ws.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new dw.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=uw.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:u}of s.anchors.values())a(u,l);return typeof o=="function"?pw.applyReviver(o,{"":c},"",c):c}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return fw.stringifyDocument(this,e)}};function ar(t){if(fe.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}yd.Document=ys});var ai=N(ni=>{"use strict";var ii=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Ns=class extends ii{constructor(e,r,i){super("YAMLParseError",e,r,i)}},bs=class extends ii{constructor(e,r,i){super("YAMLWarning",e,r,i)}},mw=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>e.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
61
- `),o=s+o}if(/[^ ]/.test(o)){let s=1,c=r.linePos[1];c?.line===i&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-a)));let l=" ".repeat(a)+"^".repeat(s);r.message+=`:
60
+ `}up.stringifyDocument=nb});var Li=N(fp=>{"use strict";var ab=ki(),Tr=Qn(),we=_(),ob=Pt(),sb=St(),cb=Cc(),lb=dp(),Rc=Un(),ub=Ts(),db=Si(),_c=Is(),Ac=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,we.NODE_TYPE,{value:we.DOC});let n=null;typeof r=="function"||Array.isArray(r)?n=r:i===void 0&&r&&(i=r,r=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=a;let{version:o}=a;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new _c.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(t.prototype,{[we.NODE_TYPE]:{value:we.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=we.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){$r(this.contents)&&this.contents.add(e)}addIn(e,r){$r(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=Rc.anchorNames(this);e.anchor=!r||i.has(r)?Rc.findNewAnchor(r||"a",i):r}return new ab.Alias(e.anchor)}createNode(e,r,i){let n;if(typeof r=="function")e=r.call({"":e},"",e),n=r;else if(Array.isArray(r)){let m=g=>typeof g=="number"||g instanceof String||g instanceof Number,w=r.filter(m).map(String);w.length>0&&(r=r.concat(w)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:c,tag:u}=i??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=Rc.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:p},h=db.createNode(e,u,v);return s&&we.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new ob.Pair(n,a)}delete(e){return $r(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Tr.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):$r(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return we.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Tr.isEmptyPath(e)?!r&&we.isScalar(this.contents)?this.contents.value:this.contents:we.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return we.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Tr.isEmptyPath(e)?this.contents!==void 0:we.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Tr.collectionFromPath(this.schema,[e],r):$r(this.contents)&&this.contents.set(e,r)}setIn(e,r){Tr.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Tr.collectionFromPath(this.schema,Array.from(e),r):$r(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new _c.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new _c.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(i)this.schema=new cb.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=sb.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:c,res:u}of s.anchors.values())a(u,c);return typeof o=="function"?ub.applyReviver(o,{"":l},"",l):l}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return lb.stringifyDocument(this,e)}};function $r(t){if(we.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}fp.Document=Ac});var Fi=N(Mi=>{"use strict";var Bi=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},Ic=class extends Bi{constructor(e,r,i){super("YAMLParseError",e,r,i)}},Tc=class extends Bi{constructor(e,r,i){super("YAMLWarning",e,r,i)}},fb=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>e.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=t.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),i>1&&/^ *$/.test(o.substring(0,a))){let s=t.substring(e.lineStarts[i-2],e.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
61
+ `),o=s+o}if(/[^ ]/.test(o)){let s=1,l=r.linePos[1];l?.line===i&&l.col>n&&(s=Math.max(1,Math.min(l.col-n,80-a)));let c=" ".repeat(a)+"^".repeat(s);r.message+=`:
62
62
 
63
63
  ${o}
64
- ${l}
65
- `}};ni.YAMLError=ii;ni.YAMLParseError=Ns;ni.YAMLWarning=bs;ni.prettifyError=mw});var oi=N(Nd=>{"use strict";function vw(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",m=!1,w=!1,p=null,h=null,y=null,v=null,k=null,x=null,S=null;for(let b of t)switch(w&&(b.type!=="space"&&b.type!=="newline"&&b.type!=="comma"&&a(b.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),w=!1),p&&(l&&b.type!=="comment"&&b.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),b.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&b.source.includes(" ")&&(p=b),u=!0;break;case"comment":{u||a(b,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let $=b.source.substring(1)||" ";d?d+=f+$:d=$,f="",l=!1;break}case"newline":l?d?d+=b.source:(!x||r!=="seq-item-ind")&&(c=!0):f+=b.source,l=!0,m=!0,(h||y)&&(v=b),u=!0;break;case"anchor":h&&a(b,"MULTIPLE_ANCHORS","A node can have at most one anchor"),b.source.endsWith(":")&&a(b.offset+b.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=b,S??(S=b.offset),l=!1,u=!1,w=!0;break;case"tag":{y&&a(b,"MULTIPLE_TAGS","A node can have at most one tag"),y=b,S??(S=b.offset),l=!1,u=!1,w=!0;break}case r:(h||y)&&a(b,"BAD_PROP_ORDER",`Anchors and tags must be after the ${b.source} indicator`),x&&a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.source} in ${e??"collection"}`),x=b,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){k&&a(b,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=b,l=!1,u=!1;break}default:a(b,"UNEXPECTED_TOKEN",`Unexpected ${b.type} token`),l=!1,u=!1}let g=t[t.length-1],R=g?g.offset+g.source.length:n;return w&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(l&&p.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:x,spaceBefore:c,comment:d,hasNewline:m,anchor:h,tag:y,newlineAfterProp:v,end:R,start:S??R}}Nd.resolveProps=vw});var Vn=N(bd=>{"use strict";function ks(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
66
- `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(ks(e.key)||ks(e.value))return!0}return!1;default:return!0}}bd.containsNewline=ks});var Ss=N(kd=>{"use strict";var gw=Vn();function ww(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&gw.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}kd.flowIndentCheck=ww});var Es=N(Ed=>{"use strict";var Sd=P();function yw(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||Sd.isScalar(a)&&Sd.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}Ed.mapIncludes=yw});var Ad=N(_d=>{"use strict";var xd=gt(),Nw=yt(),Cd=oi(),bw=Vn(),Pd=Ss(),kw=Es(),Rd="All mapping items must start at the same column";function Sw({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Nw.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let u of i.items){let{start:d,key:f,sep:m,value:w}=u,p=Cd.resolveProps(d,{indicator:"explicit-key-ind",next:f??m?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),h=!p.found;if(h){if(f&&(f.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&n(c,"BAD_INDENT",Rd)),!p.anchor&&!p.tag&&!m){l=p.end,p.comment&&(s.comment?s.comment+=`
67
- `+p.comment:s.comment=p.comment);continue}(p.newlineAfterProp||bw.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&n(c,"BAD_INDENT",Rd);r.atKey=!0;let y=p.end,v=f?t(r,f,p,n):e(r,y,d,null,p,n);r.schema.compat&&Pd.flowIndentCheck(i.indent,f,n),r.atKey=!1,kw.mapIncludes(r,s.items,v)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=Cd.resolveProps(m??[],{indicator:"map-value-ind",next:w,offset:v.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=k.end,k.found){h&&(w?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<k.found.offset-1024&&n(v.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=w?t(r,w,k,n):e(r,c,m,null,k,n);r.schema.compat&&Pd.flowIndentCheck(i.indent,w,n),c=x.range[2];let S=new xd.Pair(v,x);r.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}else{h&&n(v.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(v.comment?v.comment+=`
68
- `+k.comment:v.comment=k.comment);let x=new xd.Pair(v);r.options.keepSourceTokens&&(x.srcToken=u),s.items.push(x)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}_d.resolveBlockMap=Sw});var Td=N(Id=>{"use strict";var Ew=Nt(),xw=oi(),Cw=Ss();function Pw({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Ew.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let c=i.offset,l=null;for(let{start:u,value:d}of i.items){let f=xw.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(s.comment=f.comment);continue}let m=d?t(r,d,f,n):e(r,f.end,u,null,f,n);r.schema.compat&&Cw.flowIndentCheck(i.indent,d,n),c=m.range[2],s.items.push(m)}return s.range=[i.offset,c,l??c],s}Id.resolveBlockSeq=Pw});var or=N($d=>{"use strict";function Rw(t,e,r,i){let n="";if(t){let a=!1,o="";for(let s of t){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=c),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}$d.resolveEnd=Rw});var Dd=N(Hd=>{"use strict";var _w=P(),Aw=gt(),jd=yt(),Iw=Nt(),Tw=or(),Od=oi(),$w=Vn(),jw=Es(),xs="Block collections are not allowed within flow collections",Cs=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Ow({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?jd.YAMLMap:Iw.YAMLSeq),l=new c(r.schema);l.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=i.offset+i.start.source.length;for(let h=0;h<i.items.length;++h){let y=i.items[h],{start:v,key:k,sep:x,value:S}=y,g=Od.resolveProps(v,{flow:s,indicator:"explicit-key-ind",next:k??x?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!g.found){if(!g.anchor&&!g.tag&&!x&&!S){h===0&&g.comma?n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):h<i.items.length-1&&n(g.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),g.comment&&(l.comment?l.comment+=`
69
- `+g.comment:l.comment=g.comment),d=g.end;continue}!o&&r.options.strict&&$w.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)g.comma&&n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(g.comma||n(g.start,"MISSING_CHAR",`Missing , between ${s} items`),g.comment){let R="";e:for(let b of v)switch(b.type){case"comma":case"space":break;case"comment":R=b.source.substring(1);break e;default:break e}if(R){let b=l.items[l.items.length-1];_w.isPair(b)&&(b=b.value??b.key),b.comment?b.comment+=`
70
- `+R:b.comment=R,g.comment=g.comment.substring(R.length+1)}}if(!o&&!x&&!g.found){let R=S?t(r,S,g,n):e(r,g.end,x,null,g,n);l.items.push(R),d=R.range[2],Cs(S)&&n(R.range,"BLOCK_IN_FLOW",xs)}else{r.atKey=!0;let R=g.end,b=k?t(r,k,g,n):e(r,R,v,null,g,n);Cs(k)&&n(b.range,"BLOCK_IN_FLOW",xs),r.atKey=!1;let $=Od.resolveProps(x??[],{flow:s,indicator:"map-value-ind",next:S,offset:b.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if($.found){if(!o&&!g.found&&r.options.strict){if(x)for(let V of x){if(V===$.found)break;if(V.type==="newline"){n(V,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}g.start<$.found.offset-1024&&n($.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n($.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let se=S?t(r,S,$,n):$.found?e(r,$.end,x,null,$,n):null;se?Cs(S)&&n(se.range,"BLOCK_IN_FLOW",xs):$.comment&&(b.comment?b.comment+=`
71
- `+$.comment:b.comment=$.comment);let Yt=new Aw.Pair(b,se);if(r.options.keepSourceTokens&&(Yt.srcToken=y),o){let V=l;jw.mapIncludes(r,V.items,b)&&n(R,"DUPLICATE_KEY","Map keys must be unique"),V.items.push(Yt)}else{let V=new jd.YAMLMap(r.schema);V.flow=!0,V.items.push(Yt);let Al=(se??b).range;V.range=[b.range[0],Al[1],Al[2]],l.items.push(V)}d=se?se.range[2]:$.end}}let f=o?"}":"]",[m,...w]=i.end,p=d;if(m?.source===f)p=m.offset+m.source.length;else{let h=s[0].toUpperCase()+s.substring(1),y=u?`${h} must end with a ${f}`:`${h} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",y),m&&m.source.length!==1&&w.unshift(m)}if(w.length>0){let h=Tw.resolveEnd(w,p,r.options.strict,n);h.comment&&(l.comment?l.comment+=`
72
- `+h.comment:l.comment=h.comment),l.range=[i.offset,p,h.offset]}else l.range=[i.offset,p,p];return l}Hd.resolveFlowCollection=Ow});var Bd=N(Ld=>{"use strict";var Hw=P(),Dw=B(),Lw=yt(),Bw=Nt(),Fw=Ad(),Mw=Td(),Vw=Dd();function Ps(t,e,r,i,n,a){let o=r.type==="block-map"?Fw.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?Mw.resolveBlockSeq(t,e,r,i,a):Vw.resolveFlowCollection(t,e,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function qw(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:m}=i,w=f&&a?f.offset>a.offset?f:a:f??a;w&&(!m||m.offset<w.offset)&&n(w,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===Lw.YAMLMap.tagName&&s==="map"||o===Bw.YAMLSeq.tagName&&s==="seq")return Ps(t,e,r,n,o);let c=e.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!c){let f=e.schema.knownTags[o];if(f?.collection===s)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?n(a,"BAD_COLLECTION_TYPE",`${f.tag} used for ${s} collection, but expects ${f.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ps(t,e,r,n,o)}let l=Ps(t,e,r,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??l,d=Hw.isNode(u)?u:new Dw.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}Ld.composeCollection=qw});var _s=N(Fd=>{"use strict";var Rs=B();function Ww(t,e,r){let i=e.offset,n=zw(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?Rs.Scalar.BLOCK_FOLDED:Rs.Scalar.BLOCK_LITERAL,o=e.source?Gw(e.source):[],s=o.length;for(let p=o.length-1;p>=0;--p){let h=o[p][1];if(h===""||h==="\r")s=p;else break}if(s===0){let p=n.chomp==="+"&&o.length>0?`
73
- `.repeat(Math.max(1,o.length-1)):"",h=i+n.length;return e.source&&(h+=e.source.length),{value:p,type:a,comment:n.comment,range:[i,h,h]}}let c=e.indent+n.indent,l=e.offset+n.length,u=0;for(let p=0;p<s;++p){let[h,y]=o[p];if(y===""||y==="\r")n.indent===0&&h.length>c&&(c=h.length);else{h.length<c&&r(l+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=h.length),u=p,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=h.length+y.length+1}for(let p=o.length-1;p>=s;--p)o[p][0].length>c&&(s=p+1);let d="",f="",m=!1;for(let p=0;p<u;++p)d+=o[p][0].slice(c)+`
74
- `;for(let p=u;p<s;++p){let[h,y]=o[p];l+=h.length+y.length+1;let v=y[y.length-1]==="\r";if(v&&(y=y.slice(0,-1)),y&&h.length<c){let x=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-y.length-(v?2:1),"BAD_INDENT",x),h=""}a===Rs.Scalar.BLOCK_LITERAL?(d+=f+h.slice(c)+y,f=`
75
- `):h.length>c||y[0]===" "?(f===" "?f=`
76
- `:!m&&f===`
64
+ ${c}
65
+ `}};Mi.YAMLError=Bi;Mi.YAMLParseError=Ic;Mi.YAMLWarning=Tc;Mi.prettifyError=fb});var Vi=N(pp=>{"use strict";function pb(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let l=!1,c=s,u=s,d="",f="",p=!1,v=!1,h=null,m=null,w=null,g=null,b=null,E=null,S=null;for(let k of t)switch(v&&(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma"&&a(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(c&&k.type!=="comment"&&k.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),k.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes(" ")&&(h=k),u=!0;break;case"comment":{u||a(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let D=k.source.substring(1)||" ";d?d+=f+D:d=D,f="",c=!1;break}case"newline":c?d?d+=k.source:(!E||r!=="seq-item-ind")&&(l=!0):f+=k.source,c=!0,p=!0,(m||w)&&(g=k),u=!0;break;case"anchor":m&&a(k,"MULTIPLE_ANCHORS","A node can have at most one anchor"),k.source.endsWith(":")&&a(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=k,S??(S=k.offset),c=!1,u=!1,v=!0;break;case"tag":{w&&a(k,"MULTIPLE_TAGS","A node can have at most one tag"),w=k,S??(S=k.offset),c=!1,u=!1,v=!0;break}case r:(m||w)&&a(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`),E&&a(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${e??"collection"}`),E=k,c=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){b&&a(k,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=k,c=!1,u=!1;break}default:a(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,u=!1}let y=t[t.length-1],A=y?y.offset+y.source.length:n;return v&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&a(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:m,tag:w,newlineAfterProp:g,end:A,start:S??A}}pp.resolveProps=pb});var $a=N(hp=>{"use strict";function $c(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
66
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if($c(e.key)||$c(e.value))return!0}return!1;default:return!0}}hp.containsNewline=$c});var jc=N(mp=>{"use strict";var hb=$a();function mb(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&hb.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}mp.flowIndentCheck=mb});var Oc=N(gp=>{"use strict";var vp=_();function vb(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||vp.isScalar(a)&&vp.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}gp.mapIncludes=vb});var Sp=N(kp=>{"use strict";var wp=Pt(),gb=_t(),yp=Vi(),wb=$a(),Np=jc(),yb=Oc(),bp="All mapping items must start at the same column";function Nb({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??gb.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let l=i.offset,c=null;for(let u of i.items){let{start:d,key:f,sep:p,value:v}=u,h=yp.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),m=!h.found;if(m){if(f&&(f.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==i.indent&&n(l,"BAD_INDENT",bp)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||wb.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(l,"BAD_INDENT",bp);r.atKey=!0;let w=h.end,g=f?t(r,f,h,n):e(r,w,d,null,h,n);r.schema.compat&&Np.flowIndentCheck(i.indent,f,n),r.atKey=!1,yb.mapIncludes(r,s.items,g)&&n(w,"DUPLICATE_KEY","Map keys must be unique");let b=yp.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:g.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(l=b.end,b.found){m&&(v?.type==="block-map"&&!b.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<b.found.offset-1024&&n(g.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=v?t(r,v,b,n):e(r,l,p,null,b,n);r.schema.compat&&Np.flowIndentCheck(i.indent,v,n),l=E.range[2];let S=new wp.Pair(g,E);r.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}else{m&&n(g.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(g.comment?g.comment+=`
68
+ `+b.comment:g.comment=b.comment);let E=new wp.Pair(g);r.options.keepSourceTokens&&(E.srcToken=u),s.items.push(E)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,l,c??l],s}kp.resolveBlockMap=Nb});var xp=N(Ep=>{"use strict";var bb=At(),kb=Vi(),Sb=jc();function Eb({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??bb.YAMLSeq,s=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let l=i.offset,c=null;for(let{start:u,value:d}of i.items){let f=kb.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=f.end,f.comment&&(s.comment=f.comment);continue}let p=d?t(r,d,f,n):e(r,f.end,u,null,f,n);r.schema.compat&&Sb.flowIndentCheck(i.indent,d,n),l=p.range[2],s.items.push(p)}return s.range=[i.offset,l,c??l],s}Ep.resolveBlockSeq=Eb});var jr=N(Cp=>{"use strict";function xb(t,e,r,i){let n="";if(t){let a=!1,o="";for(let s of t){let{source:l,type:c}=s;switch(c){case"space":a=!0;break;case"comment":{r&&!a&&i(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=l),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:n,offset:e}}Cp.resolveEnd=xb});var Ap=N(_p=>{"use strict";var Cb=_(),Pb=Pt(),Pp=_t(),Rb=At(),_b=jr(),Rp=Vi(),Ab=$a(),Ib=Oc(),Hc="Block collections are not allowed within flow collections",Dc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Tb({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",l=a?.nodeClass??(o?Pp.YAMLMap:Rb.YAMLSeq),c=new l(r.schema);c.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let w=i.items[m],{start:g,key:b,sep:E,value:S}=w,y=Rp.resolveProps(g,{flow:s,indicator:"explicit-key-ind",next:b??E?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!y.found){if(!y.anchor&&!y.tag&&!E&&!S){m===0&&y.comma?n(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<i.items.length-1&&n(y.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),y.comment&&(c.comment?c.comment+=`
69
+ `+y.comment:c.comment=y.comment),d=y.end;continue}!o&&r.options.strict&&Ab.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)y.comma&&n(y.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(y.comma||n(y.start,"MISSING_CHAR",`Missing , between ${s} items`),y.comment){let A="";e:for(let k of g)switch(k.type){case"comma":case"space":break;case"comment":A=k.source.substring(1);break e;default:break e}if(A){let k=c.items[c.items.length-1];Cb.isPair(k)&&(k=k.value??k.key),k.comment?k.comment+=`
70
+ `+A:k.comment=A,y.comment=y.comment.substring(A.length+1)}}if(!o&&!E&&!y.found){let A=S?t(r,S,y,n):e(r,y.end,E,null,y,n);c.items.push(A),d=A.range[2],Dc(S)&&n(A.range,"BLOCK_IN_FLOW",Hc)}else{r.atKey=!0;let A=y.end,k=b?t(r,b,y,n):e(r,A,g,null,y,n);Dc(b)&&n(k.range,"BLOCK_IN_FLOW",Hc),r.atKey=!1;let D=Rp.resolveProps(E??[],{flow:s,indicator:"map-value-ind",next:S,offset:k.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(D.found){if(!o&&!y.found&&r.options.strict){if(E)for(let G of E){if(G===D.found)break;if(G.type==="newline"){n(G,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}y.start<D.found.offset-1024&&n(D.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n(D.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let pe=S?t(r,S,D,n):D.found?e(r,D.end,E,null,D,n):null;pe?Dc(S)&&n(pe.range,"BLOCK_IN_FLOW",Hc):D.comment&&(k.comment?k.comment+=`
71
+ `+D.comment:k.comment=D.comment);let Sr=new Pb.Pair(k,pe);if(r.options.keepSourceTokens&&(Sr.srcToken=w),o){let G=c;Ib.mapIncludes(r,G.items,k)&&n(A,"DUPLICATE_KEY","Map keys must be unique"),G.items.push(Sr)}else{let G=new Pp.YAMLMap(r.schema);G.flow=!0,G.items.push(Sr);let bd=(pe??k).range;G.range=[k.range[0],bd[1],bd[2]],c.items.push(G)}d=pe?pe.range[2]:D.end}}let f=o?"}":"]",[p,...v]=i.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),w=u?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=_b.resolveEnd(v,h,r.options.strict,n);m.comment&&(c.comment?c.comment+=`
72
+ `+m.comment:c.comment=m.comment),c.range=[i.offset,h,m.offset]}else c.range=[i.offset,h,h];return c}_p.resolveFlowCollection=Tb});var Tp=N(Ip=>{"use strict";var $b=_(),jb=q(),Ob=_t(),Hb=At(),Db=Sp(),Lb=xp(),Bb=Ap();function Lc(t,e,r,i,n,a){let o=r.type==="block-map"?Db.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?Lb.resolveBlockSeq(t,e,r,i,a):Bb.resolveFlowCollection(t,e,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function Mb(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=i,v=f&&a?f.offset>a.offset?f:a:f??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===Ob.YAMLMap.tagName&&s==="map"||o===Hb.YAMLSeq.tagName&&s==="seq")return Lc(t,e,r,n,o);let l=e.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!l){let f=e.schema.knownTags[o];if(f?.collection===s)e.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else return f?n(a,"BAD_COLLECTION_TYPE",`${f.tag} used for ${s} collection, but expects ${f.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Lc(t,e,r,n,o)}let c=Lc(t,e,r,n,o,l),u=l.resolve?.(c,f=>n(a,"TAG_RESOLVE_FAILED",f),e.options)??c,d=$b.isNode(u)?u:new jb.Scalar(u);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Ip.composeCollection=Mb});var Mc=N($p=>{"use strict";var Bc=q();function Fb(t,e,r){let i=e.offset,n=Vb(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?Bc.Scalar.BLOCK_FOLDED:Bc.Scalar.BLOCK_LITERAL,o=e.source?qb(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
+ `.repeat(Math.max(1,o.length-1)):"",m=i+n.length;return e.source&&(m+=e.source.length),{value:h,type:a,comment:n.comment,range:[i,m,m]}}let l=e.indent+n.indent,c=e.offset+n.length,u=0;for(let h=0;h<s;++h){let[m,w]=o[h];if(w===""||w==="\r")n.indent===0&&m.length>l&&(l=m.length);else{m.length<l&&r(c+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=m.length),u=h,l===0&&!t.atRoot&&r(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=m.length+w.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>l&&(s=h+1);let d="",f="",p=!1;for(let h=0;h<u;++h)d+=o[h][0].slice(l)+`
74
+ `;for(let h=u;h<s;++h){let[m,w]=o[h];c+=m.length+w.length+1;let g=w[w.length-1]==="\r";if(g&&(w=w.slice(0,-1)),w&&m.length<l){let E=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(c-w.length-(g?2:1),"BAD_INDENT",E),m=""}a===Bc.Scalar.BLOCK_LITERAL?(d+=f+m.slice(l)+w,f=`
75
+ `):m.length>l||w[0]===" "?(f===" "?f=`
76
+ `:!p&&f===`
77
77
  `&&(f=`
78
78
 
79
- `),d+=f+h.slice(c)+y,f=`
80
- `,m=!0):y===""?f===`
79
+ `),d+=f+m.slice(l)+w,f=`
80
+ `,p=!0):w===""?f===`
81
81
  `?d+=`
82
82
  `:f=`
83
- `:(d+=f+y,f=" ",m=!1)}switch(n.chomp){case"-":break;case"+":for(let p=s;p<o.length;++p)d+=`
84
- `+o[p][0].slice(c);d[d.length-1]!==`
83
+ `:(d+=f+w,f=" ",p=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<o.length;++h)d+=`
84
+ `+o[h][0].slice(l);d[d.length-1]!==`
85
85
  `&&(d+=`
86
86
  `);break;default:d+=`
87
- `}let w=i+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[i,w,w]}}function zw({offset:t,props:e},r,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],a=n[0],o=0,s="",c=-1;for(let f=1;f<n.length;++f){let m=n[f];if(!s&&(m==="-"||m==="+"))s=m;else{let w=Number(m);!o&&w?o=w:c===-1&&(c=t+f)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,u="",d=n.length;for(let f=1;f<e.length;++f){let m=e[f];switch(m.type){case"space":l=!0;case"newline":d+=m.source.length;break;case"comment":r&&!l&&i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=m.source.length,u=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let w=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",w);let p=m.source;p&&typeof p=="string"&&(d+=p.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function Gw(t){let e=t.split(/\n( *)/),r=e[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}Fd.resolveBlockScalar=Ww});var Is=N(Vd=>{"use strict";var As=B(),Jw=or();function Uw(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(f,m,w)=>r(i+f,m,w);switch(n){case"scalar":s=As.Scalar.PLAIN,c=Kw(a,l);break;case"single-quoted-scalar":s=As.Scalar.QUOTE_SINGLE,c=Yw(a,l);break;case"double-quoted-scalar":s=As.Scalar.QUOTE_DOUBLE,c=Xw(a,l);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let u=i+a.length,d=Jw.resolveEnd(o,u,e,r);return{value:c,type:s,comment:d.comment,range:[i,u,d.offset]}}function Kw(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),Md(t)}function Yw(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Md(t.slice(1,-1)).replace(/''/g,"'")}function Md(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let v=i+n.length+e.source.length;return{value:d,type:a,comment:n.comment,range:[i,v,v]}}function Vb({offset:t,props:e},r,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],a=n[0],o=0,s="",l=-1;for(let f=1;f<n.length;++f){let p=n[f];if(!s&&(p==="-"||p==="+"))s=p;else{let v=Number(p);!o&&v?o=v:l===-1&&(l=t+f)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,u="",d=n.length;for(let f=1;f<e.length;++f){let p=e[f];switch(p.type){case"space":c=!0;case"newline":d+=p.source.length;break;case"comment":r&&!c&&i(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,u=p.source.substring(1);break;case"error":i(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;i(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function qb(t){let e=t.split(/\n( *)/),r=e[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)a.push([e[o],e[o+1]]);return a}$p.resolveBlockScalar=Fb});var Vc=N(Op=>{"use strict";var Fc=q(),Wb=jr();function zb(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,l,c=(f,p,v)=>r(i+f,p,v);switch(n){case"scalar":s=Fc.Scalar.PLAIN,l=Gb(a,c);break;case"single-quoted-scalar":s=Fc.Scalar.QUOTE_SINGLE,l=Jb(a,c);break;case"double-quoted-scalar":s=Fc.Scalar.QUOTE_DOUBLE,l=Ub(a,c);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let u=i+a.length,d=Wb.resolveEnd(o,u,e,r);return{value:l,type:s,comment:d.comment,range:[i,u,d.offset]}}function Gb(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),jp(t)}function Jb(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),jp(t.slice(1,-1)).replace(/''/g,"'")}function jp(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
89
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=e.exec(t);if(!i)return t;let n=i[1],a=" ",o=e.lastIndex;for(r.lastIndex=o;i=r.exec(t);)i[1]===""?a===`
90
90
  `?n+=a:a=`
91
- `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(t),n+a+(i?.[1]??"")}function Xw(t,e){let r="";for(let i=1;i<t.length-1;++i){let n=t[i];if(!(n==="\r"&&t[i+1]===`
91
+ `:(n+=a+i[1],a=" "),o=r.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,i=s.exec(t),n+a+(i?.[1]??"")}function Ub(t,e){let r="";for(let i=1;i<t.length-1;++i){let n=t[i];if(!(n==="\r"&&t[i+1]===`
92
92
  `))if(n===`
93
- `){let{fold:a,offset:o}=Qw(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=Zw[a];if(o)r+=o;else if(a===`
93
+ `){let{fold:a,offset:o}=Kb(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=Yb[a];if(o)r+=o;else if(a===`
94
94
  `)for(a=t[i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="\r"&&t[i+1]===`
95
- `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=ey(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
95
+ `)for(a=t[++i+1];a===" "||a===" ";)a=t[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=Xb(t,i+1,s,e),i+=s}else{let s=t.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=t[i+1];for(;o===" "||o===" ";)o=t[++i+1];o!==`
96
96
  `&&!(o==="\r"&&t[i+2]===`
97
- `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function Qw(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
97
+ `)&&(r+=i>a?t.slice(a,i+1):n)}else r+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function Kb(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
98
98
  `||i==="\r")&&!(i==="\r"&&t[e+2]!==`
99
99
  `);)i===`
100
100
  `&&(r+=`
101
- `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var Zw={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function ey(t,e,r,i){let n=t.substr(e,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,r+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Vd.resolveFlowScalar=Uw});var zd=N(Wd=>{"use strict";var Lt=P(),qd=B(),ty=_s(),ry=Is();function iy(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?ty.resolveBlockScalar(t,e,i):ry.resolveFlowScalar(e,t.options.strict,i),c=r?t.directives.tagName(r.source,d=>i(r,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Lt.SCALAR]:c?l=ny(t.schema,n,c,r,i):e.type==="scalar"?l=ay(t,n,e,i):l=t.schema[Lt.SCALAR];let u;try{let d=l.resolve(n,f=>i(r??e,"TAG_RESOLVE_FAILED",f),t.options);u=Lt.isScalar(d)?d:new qd.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??e,"TAG_RESOLVE_FAILED",f),u=new qd.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function ny(t,e,r,i,n){if(r==="!")return t[Lt.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(e))return s;let o=t.knownTags[r];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[Lt.SCALAR])}function ay({atKey:t,directives:e,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(i))||r[Lt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[Lt.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),u=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}Wd.composeScalar=iy});var Jd=N(Gd=>{"use strict";function oy(t,e,r){if(e){r??(r=e.length);for(let i=r-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++i];n?.type==="space";)t+=n.source.length,n=e[++i];break}}return t}Gd.emptyScalarPosition=oy});var Yd=N($s=>{"use strict";var sy=Fr(),cy=P(),ly=Bd(),Ud=zd(),uy=or(),dy=Jd(),fy={composeNode:Kd,composeEmptyNode:Ts};function Kd(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,u=!0;switch(e.type){case"alias":l=py(t,e,i),(s||c)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Ud.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=ly.composeCollection(fy,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);i(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",d),u=!1}}return l??(l=Ts(t,e.offset,void 0,null,r,i)),s&&l.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!cy.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?l.comment=o:l.commentBefore=o),t.options.keepSourceTokens&&u&&(l.srcToken=e),l}function Ts(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:dy.emptyScalarPosition(e,r,i),indent:-1,source:""},d=Ud.composeScalar(t,u,s,l);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=c),d}function py({options:t},{offset:e,source:r,end:i},n){let a=new sy.Alias(r.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+r.length,s=uy.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}$s.composeEmptyNode=Ts;$s.composeNode=Kd});var Zd=N(Qd=>{"use strict";var hy=ri(),Xd=Yd(),my=or(),vy=oi();function gy(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new hy.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=vy.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Xd.composeNode(l,n,u,o):Xd.composeEmptyNode(l,u.end,i,null,u,o);let d=c.contents.range[2],f=my.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,d,f.offset],c}Qd.composeDoc=gy});var Os=N(rf=>{"use strict";var wy=Yi("process"),yy=No(),Ny=ri(),si=ai(),ef=P(),by=Zd(),ky=or();function ci(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function tf(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
101
+ `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var Yb={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Xb(t,e,r,i){let n=t.substr(e,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=t.substr(e-2,r+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Op.resolveFlowScalar=zb});var Lp=N(Dp=>{"use strict";var Xt=_(),Hp=q(),Qb=Mc(),Zb=Vc();function ek(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?Qb.resolveBlockScalar(t,e,i):Zb.resolveFlowScalar(e,t.options.strict,i),l=r?t.directives.tagName(r.source,d=>i(r,"TAG_RESOLVE_FAILED",d)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[Xt.SCALAR]:l?c=tk(t.schema,n,l,r,i):e.type==="scalar"?c=rk(t,n,e,i):c=t.schema[Xt.SCALAR];let u;try{let d=c.resolve(n,f=>i(r??e,"TAG_RESOLVE_FAILED",f),t.options);u=Xt.isScalar(d)?d:new Hp.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);i(r??e,"TAG_RESOLVE_FAILED",f),u=new Hp.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function tk(t,e,r,i,n){if(r==="!")return t[Xt.SCALAR];let a=[];for(let s of t.tags)if(!s.collection&&s.tag===r)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(e))return s;let o=t.knownTags[r];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[Xt.SCALAR])}function rk({atKey:t,directives:e,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(i))||r[Xt.SCALAR];if(r.compat){let s=r.compat.find(l=>l.default&&l.test?.test(i))??r[Xt.SCALAR];if(o.tag!==s.tag){let l=e.tagString(o.tag),c=e.tagString(s.tag),u=`Value may be parsed as either ${l} or ${c}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}Dp.composeScalar=ek});var Mp=N(Bp=>{"use strict";function ik(t,e,r){if(e){r??(r=e.length);for(let i=r-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++i];n?.type==="space";)t+=n.source.length,n=e[++i];break}}return t}Bp.emptyScalarPosition=ik});var qp=N(Wc=>{"use strict";var nk=ki(),ak=_(),ok=Tp(),Fp=Lp(),sk=jr(),ck=Mp(),lk={composeNode:Vp,composeEmptyNode:qc};function Vp(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:l}=r,c,u=!0;switch(e.type){case"alias":c=uk(t,e,i),(s||l)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Fp.composeScalar(t,e,l,i),s&&(c.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=ok.composeCollection(lk,t,e,r,i),s&&(c.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);i(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",d),u=!1}}return c??(c=qc(t,e.offset,void 0,null,r,i)),s&&c.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!ak.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&u&&(c.srcToken=e),c}function qc(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:l},c){let u={type:"scalar",offset:ck.emptyScalarPosition(e,r,i),indent:-1,source:""},d=Fp.composeScalar(t,u,s,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=l),d}function uk({options:t},{offset:e,source:r,end:i},n){let a=new nk.Alias(r.substring(1));a.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+r.length,s=sk.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}Wc.composeEmptyNode=qc;Wc.composeNode=Vp});var Gp=N(zp=>{"use strict";var dk=Li(),Wp=qp(),fk=jr(),pk=Vi();function hk(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),l=new dk.Document(void 0,s),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=pk.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=n?Wp.composeNode(c,n,u,o):Wp.composeEmptyNode(c,u.end,i,null,u,o);let d=l.contents.range[2],f=fk.resolveEnd(a,d,!1,o);return f.comment&&(l.comment=f.comment),l.range=[r,d,f.offset],l}zp.composeDoc=hk});var Gc=N(Kp=>{"use strict";var mk=qn("process"),vk=Is(),gk=Li(),qi=Fi(),Jp=_(),wk=Gp(),yk=jr();function Wi(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function Up(t){let e="",r=!1,i=!1;for(let n=0;n<t.length;++n){let a=t[n];switch(a[0]){case"#":e+=(e===""?"":i?`
103
103
 
104
104
  `:`
105
- `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var js=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=ci(r);a?this.warnings.push(new si.YAMLWarning(o,i,n)):this.errors.push(new si.YAMLParseError(o,i,n))},this.directives=new yy.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=tf(this.prelude);if(i){let a=e.contents;if(r)e.comment=e.comment?`${e.comment}
106
- ${i}`:i;else if(n||e.directives.docStart||!a)e.commentBefore=i;else if(ef.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];ef.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
105
+ `)+(a.substring(1)||" "),r=!0,i=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:e,afterEmptyLine:i}}var zc=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=Wi(r);a?this.warnings.push(new qi.YAMLWarning(o,i,n)):this.errors.push(new qi.YAMLParseError(o,i,n))},this.directives=new vk.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=Up(this.prelude);if(i){let a=e.contents;if(r)e.comment=e.comment?`${e.comment}
106
+ ${i}`:i;else if(n||e.directives.docStart||!a)e.commentBefore=i;else if(Jp.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Jp.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${i}
107
107
  ${s}`:i}else{let o=a.commentBefore;a.commentBefore=o?`${i}
108
- ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:tf(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(r,i)}*next(e){switch(wy.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=ci(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=by.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new si.YAMLParseError(ci(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new si.YAMLParseError(ci(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=ky.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
109
- ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new si.YAMLParseError(ci(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),n=new Ny.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};rf.Composer=js});var of=N(qn=>{"use strict";var Sy=_s(),Ey=Is(),xy=ai(),nf=zr();function Cy(t,e=!0,r){if(t){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new xy.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Ey.resolveFlowScalar(t,e,i);case"block-scalar":return Sy.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function Py(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=nf.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:i,source:`
110
- `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
- `),u=s.substring(0,l),d=s.substring(l+1)+`
112
- `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return af(f,c)||f.push({type:"newline",offset:-1,indent:i,source:`
113
- `}),{type:"block-scalar",offset:a,indent:i,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:c};default:return{type:"scalar",offset:a,indent:i,source:s,end:c}}}function Ry(t,e,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in t?t.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=nf.stringifyString({type:o,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":_y(t,c);break;case'"':Hs(t,c,"double-quoted-scalar");break;case"'":Hs(t,c,"single-quoted-scalar");break;default:Hs(t,c,"scalar")}}function _y(t,e){let r=e.indexOf(`
108
+ ${o}`:i}}if(r){for(let a=0;a<this.errors.length;++a)e.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)e.warnings.push(this.warnings[a])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Up(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(r,i)}*next(e){switch(mk.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=Wi(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=wk.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new qi.YAMLParseError(Wi(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new qi.YAMLParseError(Wi(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=yk.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
109
+ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new qi.YAMLParseError(Wi(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),n=new gk.Document(void 0,i);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,r,r],this.decorate(n,!1),yield n}}};Kp.Composer=zc});var Qp=N(ja=>{"use strict";var Nk=Mc(),bk=Vc(),kk=Fi(),Yp=Pi();function Sk(t,e=!0,r){if(t){let i=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(r)r(s,a,o);else throw new kk.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return bk.resolveFlowScalar(t,e,i);case"block-scalar":return Nk.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function Ek(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Yp.stringifyString({type:o,value:t},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:i,source:`
110
+ `}];switch(s[0]){case"|":case">":{let c=s.indexOf(`
111
+ `),u=s.substring(0,c),d=s.substring(c+1)+`
112
+ `,f=[{type:"block-scalar-header",offset:a,indent:i,source:u}];return Xp(f,l)||f.push({type:"newline",offset:-1,indent:i,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:i,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:i,source:s,end:l};case"'":return{type:"single-quoted-scalar",offset:a,indent:i,source:s,end:l};default:return{type:"scalar",offset:a,indent:i,source:s,end:l}}}function xk(t,e,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in t?t.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Yp.stringifyString({type:o,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":Ck(t,l);break;case'"':Jc(t,l,"double-quoted-scalar");break;case"'":Jc(t,l,"single-quoted-scalar");break;default:Jc(t,l,"scalar")}}function Ck(t,e){let r=e.indexOf(`
114
114
  `),i=e.substring(0,r),n=e.substring(r+1)+`
115
- `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];af(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
- `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:o,props:s,source:n})}}function af(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function Hs(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let i=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of i)a.offset+=n;delete t.props,Object.assign(t,{type:r,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
117
- `};delete t.items,Object.assign(t,{type:r,source:e,end:[n]});break}default:{let i="indent"in t?t.indent:-1,n="end"in t&&Array.isArray(t.end)?t.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(t))a!=="type"&&a!=="offset"&&delete t[a];Object.assign(t,{type:r,indent:i,source:e,end:n})}}}qn.createScalarToken=Py;qn.resolveAsScalar=Cy;qn.setScalarValue=Ry});var cf=N(sf=>{"use strict";var Ay=t=>"type"in t?zn(t):Wn(t);function zn(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=zn(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Wn(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Wn(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Wn(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function Wn({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=zn(e)),r)for(let a of r)n+=a.source;return i&&(n+=zn(i)),n}sf.stringify=Ay});var ff=N(df=>{"use strict";var Ds=Symbol("break visit"),Iy=Symbol("skip children"),lf=Symbol("remove item");function Bt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),uf(Object.freeze([]),t,e)}Bt.BREAK=Ds;Bt.SKIP=Iy;Bt.REMOVE=lf;Bt.itemAtPath=(t,e)=>{let r=t;for(let[i,n]of e){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Bt.parentCollection=(t,e)=>{let r=Bt.itemAtPath(t,e.slice(0,-1)),i=e[e.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function uf(t,e,r){let i=r(e,t);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=e[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=uf(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Ds)return Ds;s===lf&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}df.visit=Bt});var Gn=N(oe=>{"use strict";var Ls=of(),Ty=cf(),$y=ff(),Bs="\uFEFF",Fs="",Ms="",Vs="",jy=t=>!!t&&"items"in t,Oy=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Hy(t){switch(t){case Bs:return"<BOM>";case Fs:return"<DOC>";case Ms:return"<FLOW_END>";case Vs:return"<SCALAR>";default:return JSON.stringify(t)}}function Dy(t){switch(t){case Bs:return"byte-order-mark";case Fs:return"doc-mode";case Ms:return"flow-error-end";case Vs:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
+ `;if(t.type==="block-scalar"){let a=t.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,t.source=n}else{let{offset:a}=t,o="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];Xp(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
+ `});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:s,source:n})}}function Xp(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function Jc(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let i=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let a of i)a.offset+=n;delete t.props,Object.assign(t,{type:r,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
117
+ `};delete t.items,Object.assign(t,{type:r,source:e,end:[n]});break}default:{let i="indent"in t?t.indent:-1,n="end"in t&&Array.isArray(t.end)?t.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(t))a!=="type"&&a!=="offset"&&delete t[a];Object.assign(t,{type:r,indent:i,source:e,end:n})}}}ja.createScalarToken=Ek;ja.resolveAsScalar=Sk;ja.setScalarValue=xk});var eh=N(Zp=>{"use strict";var Pk=t=>"type"in t?Ha(t):Oa(t);function Ha(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Ha(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Oa(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Oa(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Oa(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function Oa({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Ha(e)),r)for(let a of r)n+=a.source;return i&&(n+=Ha(i)),n}Zp.stringify=Pk});var nh=N(ih=>{"use strict";var Uc=Symbol("break visit"),Rk=Symbol("skip children"),th=Symbol("remove item");function Qt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),rh(Object.freeze([]),t,e)}Qt.BREAK=Uc;Qt.SKIP=Rk;Qt.REMOVE=th;Qt.itemAtPath=(t,e)=>{let r=t;for(let[i,n]of e){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Qt.parentCollection=(t,e)=>{let r=Qt.itemAtPath(t,e.slice(0,-1)),i=e[e.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function rh(t,e,r){let i=r(e,t);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=e[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=rh(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Uc)return Uc;s===th&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}ih.visit=Qt});var Da=N(le=>{"use strict";var Kc=Qp(),_k=eh(),Ak=nh(),Yc="\uFEFF",Xc="",Qc="",Zc="",Ik=t=>!!t&&"items"in t,Tk=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function $k(t){switch(t){case Yc:return"<BOM>";case Xc:return"<DOC>";case Qc:return"<FLOW_END>";case Zc:return"<SCALAR>";default:return JSON.stringify(t)}}function jk(t){switch(t){case Yc:return"byte-order-mark";case Xc:return"doc-mode";case Qc:return"flow-error-end";case Zc:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
118
118
  `:case`\r
119
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}oe.createScalarToken=Ls.createScalarToken;oe.resolveAsScalar=Ls.resolveAsScalar;oe.setScalarValue=Ls.setScalarValue;oe.stringify=Ty.stringify;oe.visit=$y.visit;oe.BOM=Bs;oe.DOCUMENT=Fs;oe.FLOW_END=Ms;oe.SCALAR=Vs;oe.isCollection=jy;oe.isScalar=Oy;oe.prettyToken=Hy;oe.tokenType=Dy});var zs=N(hf=>{"use strict";var li=Gn();function be(t){switch(t){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var pf=new Set("0123456789ABCDEFabcdef"),Ly=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Jn=new Set(",[]{}"),By=new Set(` ,[]{}
121
- \r `),qs=t=>!t||By.has(t),Ws=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
119
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}le.createScalarToken=Kc.createScalarToken;le.resolveAsScalar=Kc.resolveAsScalar;le.setScalarValue=Kc.setScalarValue;le.stringify=_k.stringify;le.visit=Ak.visit;le.BOM=Yc;le.DOCUMENT=Xc;le.FLOW_END=Qc;le.SCALAR=Zc;le.isCollection=Ik;le.isScalar=Tk;le.prettyToken=$k;le.tokenType=jk});var rl=N(oh=>{"use strict";var zi=Da();function Re(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var ah=new Set("0123456789ABCDEFabcdef"),Ok=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),La=new Set(",[]{}"),Hk=new Set(` ,[]{}
121
+ \r `),el=t=>!t||Hk.has(t),tl=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
122
122
  `?!0:r==="\r"?this.buffer[e+1]===`
123
123
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let r=this.buffer[e];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+e];if(r==="\r"){let n=this.buffer[i+e+1];if(n===`
124
124
  `||!n&&!this.atEnd)return e+i+1}return r===`
125
- `||i>=this.indentNext||!r&&!this.atEnd?e+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&be(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
126
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===li.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,i=e.indexOf("#");for(;i!==-1;){let a=e[i-1];if(a===" "||a===" "){r=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let a=e[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield li.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&be(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!be(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&be(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(qs),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&be(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield li.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(qs),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||be(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
125
+ `||i>=this.indentNext||!r&&!this.atEnd?e+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&Re(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
126
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===zi.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,i=e.indexOf("#");for(;i!==-1;){let a=e[i-1];if(a===" "||a===" "){r=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let a=e[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield zi.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&Re(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Re(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Re(r)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(el),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&Re(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield zi.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(el),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Re(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let a=0;for(;this.buffer[r-1-a]==="\\";)a+=1;if(a%2===0)break;r=this.buffer.indexOf('"',r+1)}let i=this.buffer.substring(0,r),n=i.indexOf(`
127
127
  `,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=i.indexOf(`
128
- `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>be(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
128
+ `,a)}n!==-1&&(r=n-(i[n-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>Re(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,i;e:for(let a=this.pos;i=this.buffer[a];++a)switch(i){case" ":r+=1;break;case`
129
129
  `:e=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
130
130
  `)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(e+1);if(a===-1)break;e=this.buffer.indexOf(`
131
131
  `,a)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
132
132
  `;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let a=e-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
133
- `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield li.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(be(a)||e&&Jn.has(a))break;r=i}else if(be(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
133
+ `&&a>=this.pos&&a+1+r>s)e=a;else break}while(!0);return yield zi.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let a=this.buffer[i+1];if(Re(a)||e&&La.has(a))break;r=i}else if(Re(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
134
134
  `?(i+=1,n=`
135
- `,a=this.buffer[i+1]):r=i),a==="#"||e&&Jn.has(a))break;if(n===`
136
- `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&Jn.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield li.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(qs),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(be(i)||r&&Jn.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!be(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(Ly.has(r))r=this.buffer[++e];else if(r==="%"&&pf.has(this.buffer[e+1])&&pf.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
135
+ `,a=this.buffer[i+1]):r=i),a==="#"||e&&La.has(a))break;if(n===`
136
+ `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&La.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield zi.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(el),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(Re(i)||r&&La.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!Re(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(Ok.has(r))r=this.buffer[++e];else if(r==="%"&&ah.has(this.buffer[e+1])&&ah.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
137
137
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};hf.Lexer=Ws});var Js=N(mf=>{"use strict";var Gs=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<e?r=a+1:i=a}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let n=this.lineStarts[r-1];return{line:r,col:e-n+1}}}};mf.LineCounter=Gs});var Ks=N(Nf=>{"use strict";var Fy=Yi("process"),vf=Gn(),My=zs();function bt(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function gf(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function yf(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Un(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function sr(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Kn(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function wf(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!bt(e.start,"explicit-key-ind")&&!bt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,yf(e.value)?e.value.end?Kn(e.value.end,e.sep):e.value.end=e.sep:Kn(e.start,e.sep),delete e.sep)}var Us=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new My.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,r))yield*this.next(i);r||(yield*this.end())}*next(e){if(this.source=e,Fy.env.LOG_TOKENS&&console.log("|",vf.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=vf.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&wf(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&gf(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{gf(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=Un(this.peek(2)),i=sr(r),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
138
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||e&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let r=this.pos,i=this.buffer[r];for(;!e(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};oh.Lexer=tl});var nl=N(sh=>{"use strict";var il=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<e?r=a+1:i=a}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let n=this.lineStarts[r-1];return{line:r,col:e-n+1}}}};sh.LineCounter=il});var ol=N(fh=>{"use strict";var Dk=qn("process"),ch=Da(),Lk=rl();function It(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function lh(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function dh(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Ba(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Or(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Ma(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function uh(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!It(e.start,"explicit-key-ind")&&!It(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,dh(e.value)?e.value.end?Ma(e.value.end,e.sep):e.value.end=e.sep:Ma(e.start,e.sep),delete e.sep)}var al=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Lk.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,r))yield*this.next(i);r||(yield*this.end())}*next(e){if(this.source=e,Dk.env.LOG_TOKENS&&console.log("|",ch.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=ch.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let i=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in i?i.indent:0:r.type==="flow-collection"&&i.type==="document"&&(r.indent=0),r.type==="flow-collection"&&uh(r),i.type){case"document":i.value=r;break;case"block-scalar":i.props.push(r);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=r;else{Object.assign(n,{key:r,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:r}):n.value=r;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:r,sep:[]}):n.sep?n.value=r:Object.assign(n,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let n=r.items[r.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&lh(n.start)===-1&&(r.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<r.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{lh(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=Ba(this.peek(2)),i=Or(r),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
139
139
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
140
- `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Kn(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let c=r.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(bt(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(yf(r.key)&&!bt(r.sep,"newline")){let o=sr(r.start),s=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(bt(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=sr(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):bt(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!bt(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Kn(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||bt(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Un(i),a=sr(n);wf(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
140
+ `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ma(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&r.sep&&!r.value){let o=[];for(let s=0;s<r.sep.length;++s){let l=r.sep[s];switch(l.type){case"newline":o.push(s);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||r.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):n||r.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(It(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(dh(r.key)&&!It(r.sep,"newline")){let o=Or(r.start),s=r.key,l=r.sep;l.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:l}]})}else a.length>0?r.sep=r.sep.concat(a,this.sourceToken):r.sep.push(this.sourceToken);else if(It(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Or(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||n?e.items.push({start:a,key:null,sep:[this.sourceToken]}):It(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||r.value?(e.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!It(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&e.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let i="end"in r.value?r.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ma(n,r.start),n.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||It(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:n,sep:[]}):r.sep?this.stack.push(n):Object.assign(r,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Ba(i),a=Or(n);uh(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:a,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
141
141
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
142
- `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Un(e),i=sr(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Un(e),i=sr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Nf.Parser=Us});var xf=N(di=>{"use strict";var bf=Os(),Vy=ri(),ui=ai(),qy=$o(),Wy=P(),zy=Js(),kf=Ks();function Sf(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new zy.LineCounter||null,prettyErrors:e}}function Gy(t,e={}){let{lineCounter:r,prettyErrors:i}=Sf(e),n=new kf.Parser(r?.addNewLine),a=new bf.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(ui.prettifyError(t,r)),s.warnings.forEach(ui.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function Ef(t,e={}){let{lineCounter:r,prettyErrors:i}=Sf(e),n=new kf.Parser(r?.addNewLine),a=new bf.Composer(e),o=null;for(let s of a.compose(n.parse(t),!0,t.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new ui.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(ui.prettifyError(t,r)),o.warnings.forEach(ui.prettifyError(t,r))),o}function Jy(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=Ef(t,r);if(!n)return null;if(n.warnings.forEach(a=>qy.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},r))}function Uy(t,e,r){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=r??e??{};if(!n)return}return Wy.isDocument(t)&&!i?t.toString(r):new Vy.Document(t,i,r).toString(r)}di.parse=Jy;di.parseAllDocuments=Gy;di.parseDocument=Ef;di.stringify=Uy});var Ke=N(A=>{"use strict";var Ky=Os(),Yy=ri(),Xy=ms(),Ys=ai(),Qy=Fr(),kt=P(),Zy=gt(),eN=B(),tN=yt(),rN=Nt(),iN=Gn(),nN=zs(),aN=Js(),oN=Ks(),Yn=xf(),Cf=Hr();A.Composer=Ky.Composer;A.Document=Yy.Document;A.Schema=Xy.Schema;A.YAMLError=Ys.YAMLError;A.YAMLParseError=Ys.YAMLParseError;A.YAMLWarning=Ys.YAMLWarning;A.Alias=Qy.Alias;A.isAlias=kt.isAlias;A.isCollection=kt.isCollection;A.isDocument=kt.isDocument;A.isMap=kt.isMap;A.isNode=kt.isNode;A.isPair=kt.isPair;A.isScalar=kt.isScalar;A.isSeq=kt.isSeq;A.Pair=Zy.Pair;A.Scalar=eN.Scalar;A.YAMLMap=tN.YAMLMap;A.YAMLSeq=rN.YAMLSeq;A.CST=iN;A.Lexer=nN.Lexer;A.LineCounter=aN.LineCounter;A.Parser=oN.Parser;A.parse=Yn.parse;A.parseAllDocuments=Yn.parseAllDocuments;A.parseDocument=Yn.parseDocument;A.stringify=Yn.stringify;A.visit=Cf.visit;A.visitAsync=Cf.visitAsync});function dN(t){return t.toLowerCase().startsWith(".env")}function pi(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>dN(i))?"environment-file":r.some(i=>uN.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>lN.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var lN,uN,hi=E(()=>{"use strict";lN=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),uN=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});function St(t){return t!==0&&t!==0n&&t!=="0"}function De(t,e){return St(t.dev)&&St(e.dev)&&St(t.ino)&&St(e.ino)}function O(t,e){let r=St(t.dev)&&St(e.dev);if(r&&t.dev!==e.dev)return!1;let i=St(t.ino)&&St(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var mi=E(()=>{"use strict"});var Le=E(()=>{"use strict";mi()});import{createHash as fN}from"node:crypto";import{promises as Se}from"node:fs";import pe from"node:path";import{TextDecoder as pN}from"node:util";function Zs(t,e){let r=pe.relative(t,e);return r===""||!pe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${pe.sep}`)}function hN(t){let e=pe.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||pe.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let r=t.toLowerCase(),i=pi(t);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${t}`);return t}function mN(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function vN(t,e){return O({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Xn(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return De(r,i)?O(r,i):O(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function _f(t){let e=await Se.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await Se.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function gN(t,e){let r=pe.resolve(t),i=pe.resolve(e);if(!Zs(r,i))throw new Error("Native artifact path is outside its root");let n=[await _f(r)],a=r;for(let o of pe.relative(r,i).split(pe.sep).filter(Boolean)){a=pe.join(a,o);let s=await _f(a);if(!Zs(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Af(t){for(let e of t){let r=await Se.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!vN(e,r)||await Se.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function ce(t){let e=hN(t.ref),r=t.maxBytes===null?null:mN(t.maxBytes??If),i=pe.resolve(t.root,...e.split("/")),n=await gN(t.root,pe.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await Se.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);let o=await Se.realpath(i);if(!Zs(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await Se.open(i,"r");try{let[c,l,u]=await Promise.all([s.stat(),Se.lstat(i),Se.realpath(i)]);if(await Af(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Xn(a,c)||!Xn(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,m=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let k=r===null?m.length:r+1-f,x=await s.read(m,0,Math.min(m.length,k),null);if(x.bytesRead===0)break;if(f+=x.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);d.push(Buffer.from(m.subarray(0,x.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[w,p,h]=await Promise.all([s.stat(),Se.lstat(i),Se.realpath(i)]);if(await Af(n),!p.isFile()||p.isSymbolicLink()||h!==o||!Xn(c,w)||!Xn(c,p))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(d,f),v;try{v=new pN("utf-8",{fatal:!0}).decode(y)}catch(k){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:k})}return{ref:e,size:f,hash:t.includeHash===!1?null:fN("sha256").update(y).digest("hex"),text:v}}finally{await s.close()}}var If,Ee=E(()=>{"use strict";hi();Le();If=1024*1024});import{promises as tc}from"node:fs";async function rc(t,e){let r;for(let i=0;i<=ec.length;i+=1)try{return await t()}catch(n){r=n;let a=n.code;if(i===ec.length||!wN.has(a??""))throw n;await new Promise(o=>setTimeout(o,ec[i]))}throw r}async function ic(t,e){await rc(()=>tc.rename(t,e),`rename ${e}`)}async function nc(t){await rc(()=>tc.unlink(t),`unlink ${t}`)}async function ac(t,e){await rc(()=>tc.link(t,e),`link ${e}`)}var wN,ec,oc=E(()=>{"use strict";wN=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),ec=[50,100,200]});import{randomUUID as yN}from"crypto";import{promises as Q}from"fs";import xe from"path";function Qn(t,e){let r=xe.relative(t,e);return r===""||!xe.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${xe.sep}`)}function NN(t,e){return O({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Zn(t,e){return O({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function bN(t,e){return Zn(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Tf(t){let e=await Q.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await Q.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function cr(t){for(let e of t){let r=await Q.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!NN(e,r)||await Q.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function kN(t,e,r){let[i,n]=await Promise.all([Q.lstat(t),Q.realpath(t),r?cr(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Zn(i,e)||r&&!Qn(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function SN(t,e){let r=xe.resolve(t),i=xe.resolve(e);if(!Qn(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Tf(r)],a=xe.relative(r,i).split(xe.sep).filter(Boolean),o=r;for(let s of a){await cr(n),o=xe.join(o,s);try{await Q.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Tf(o);if(!Qn(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await cr(n),n}async function EN(t){let e;try{e=await Q.open(t,"r"),await e.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await e?.close()}}async function xN(t,e,r={}){let i=xe.dirname(t),n=r.containedRoot?await SN(r.containedRoot,i):null;n||await Q.mkdir(i,{recursive:!0});let a=xe.join(i,`.${xe.basename(t)}.${yN()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await Q.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([Q.lstat(a),Q.realpath(a)]);if(await cr(n),!l.isFile()||l.isSymbolicLink()||!Zn(s,l)||!Qn(n[0].realPath,u))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),c=await o.stat(),!Zn(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.afterTemporaryClose?.(),!c)throw new Error("Native atomic write temporary file was not written");if(c=await kN(a,c,n),await r.beforeCommit?.(),n){await cr(n);let l=await Q.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!bN(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await ac(a,t),await nc(a)):await ic(a,t),await EN(i)}catch(l){if(await o?.close(),!n)await Q.rm(a,{force:!0});else try{await cr(n),await Q.rm(a,{force:!0})}catch{}throw l}}async function Be(t,e,r={}){await xN(t,e,r)}async function le(t,e,r={}){await Be(t,JSON.stringify(e,null,2)+`
143
- `,r)}var L=E(()=>{"use strict";oc();Le()});function _N(t,e){return sc[t][e]}function ea(t){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${_N(t,r)}
144
- `).join(`
145
- `)}var sc,CN,PN,RN,$f,Mt=E(()=>{"use strict";sc={en:{outcome:"Outcome",scope:"Scope",nonGoals:"Non-goals",acceptanceExamples:"Acceptance examples",constraints:"Constraints and invariants",decisions:"Decisions",openQuestions:"Open questions",verificationExpectations:"Verification expectations"},"zh-CN":{outcome:"目标",scope:"范围",nonGoals:"非目标",acceptanceExamples:"验收示例",constraints:"约束与不变量",decisions:"决策",openQuestions:"待解决问题",verificationExpectations:"验证预期"}},CN={en:{verification:"Verification",currentResult:"Current result",acceptance:"Acceptance",checks:"Checks",blockers:"Blockers",risks:"Risks and skipped work",previousIterations:"Previous iterations",conclusion:"Conclusion"},"zh-CN":{verification:"验证",currentResult:"当前结果",acceptance:"验收",checks:"检查",blockers:"阻塞项",risks:"风险与跳过的工作",previousIterations:"之前的迭代",conclusion:"结论"}},PN={en:{acceptanceEvidence:"Acceptance evidence",commandsAndResults:"Commands and results",skippedChecks:"Skipped checks",specConsistency:"Spec consistency",knownLimitationsAndRisks:"Known limitations and risks",conclusion:"Conclusion"},"zh-CN":{acceptanceEvidence:"验收证据",commandsAndResults:"命令与结果",skippedChecks:"跳过的检查",specConsistency:"规格一致性",knownLimitationsAndRisks:"已知限制与风险",conclusion:"结论"}},RN=new Map,$f=new Map;for(let t of Object.keys(sc)){for(let[e,r]of Object.entries(sc[t]))RN.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(CN[t]))$f.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(PN[t]))$f.set(r.toLocaleLowerCase("en-US"),e)}});import Et from"path";function ON(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||Et.posix.isAbsolute(r)||Et.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return i}function lr(t){let e=ON(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Mf(t,e="docs"){let r=t??e;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function ia(t,e,r=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim().replaceAll("\\","/");if(i.length===0||Et.posix.isAbsolute(i)||Et.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${e} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function Ye(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Vf(t,e,r){let i=t??e;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function na(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>ta)throw new Error(`${e} exceeds ${ta} characters`);let r=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?r+=1:t[i]==="*"&&(r+=1,t[i+1]==="*"&&(i+=1));if(r>ra)throw new Error(`${e} contains more than ${ra} wildcard tokens`);return t}function Lf(t,e,r){if(t===void 0)return[...r];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(i=>na(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function vi(t,e,r){let i=t??e;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function Bf(t,e,r){let i=vi(t,e,r);if(i>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${r} is too large to convert to bytes safely`);return i}function HN(t){if(t===void 0)return{...Ce,include:[...Ce.include],exclude:[...Ce.exclude]};let e=Ye(t,"native.snapshot");return{include:Lf(e.include,"native.snapshot.include",Ce.include),exclude:Lf(e.exclude,"native.snapshot.exclude",Ce.exclude),max_files:vi(e.max_files,Ce.max_files,"native.snapshot.max_files"),max_total_bytes:vi(e.max_total_bytes,Ce.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:vi(e.max_duration_ms,Ce.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:vi(e.max_selection_records,Ce.max_selection_records,"native.snapshot.max_selection_records")}}function DN(t){if(t===void 0)return;let e=Ye(t,"native.pending_root_move"),r=e.id,i=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let s=Ye(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,u=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:u}}return{id:r,fromArtifactRoot:lr(i),toArtifactRoot:lr(n),stage:a,...o?{cleanup:o}:{}}}function LN(t){if(t===void 0)return;let e=Ye(t,"native.finish");if(e.pull_request===void 0)return{};let r=Ye(e.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(Et.posix.isAbsolute(i[0])||Et.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=r.timeout_ms??IN;if(!Number.isSafeInteger(n)||n<1||n>Df)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Df}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function BN(t,e={}){let r=Ye(t,"native"),i=r.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??Ff;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=r.document_writes??"allow";if(s!=="allow"&&s!=="revert")throw new Error("native.document_writes must be allow or revert");let c=DN(r.pending_root_move),l=LN(r.finish);return{artifact_root:lr(i),language:Vf(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:HN(r.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function FN(t){let e=Ye(t,"classic"),r=e.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=e.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=e.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=e.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Mf(e.artifact_layout),language:Vf(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function MN(t){let r=Ye(t,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>ia(i,`hook.allow_paths[${n}]`)))]}}function VN(t){if(t===void 0)return{...cc};let e=Ye(t,"memory"),r=e.learning??cc.learning,i=e.retrieval??cc.retrieval;if(typeof r!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:r,retrieval:i}}function uc(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function qN(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||Et.posix.isAbsolute(r)||Et.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(r.length>jf)throw new Error(`${e} exceeds ${jf} characters`);let i=0;for(let n=0;n<r.length;n+=1)r[n]==="?"?i+=1:r[n]==="*"&&(i+=1,r[n+1]==="*"&&(n+=1));if(i>Of)throw new Error(`${e} contains more than ${Of} wildcard tokens`);return r}function WN(t){let e=uc(t,"knowledge.local"),r=e.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>qN(n,`knowledge.local.include[${a}]`)))],max_file_mb:Bf(e.max_file_mb,Hf.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Bf(e.max_total_mb,Hf.max_total_mb,"knowledge.local.max_total_mb")};if(i.max_file_mb>i.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return i}function zN(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function GN(t){let e=uc(t,"knowledge.remote"),r=zN(e.endpoint),i=e.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=e.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=e.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function JN(t){if(t===void 0)return{...AN};let e=uc(t,"knowledge"),r=e.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=e.local===void 0?void 0:WN(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:GN(e.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function UN(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function KN(t,e,r,i,n,a,o,s){let c=t.schema!==void 0;if(!(c||t.default_workflow!==void 0||t.workflows!==void 0||!s.allowPartialProject&&t.native!==void 0)||s.allowPartialProject&&!c)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=t.workflows??[t.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let d=[...new Set(u)];if(!d.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(d.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:d,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function wi(t,e={}){let r=(0,lc.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=UN(n.ambient_resume),o=n.hook===void 0?void 0:MN(n.hook),s=VN(n.memory),c=JN(n.knowledge),l=n.native===void 0?void 0:BN(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=n.classic===void 0?void 0:FN(n.classic),d=KN(n,o,s,c,l,u,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:d,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...u?{classic:u}:{}}}var lc,gi,ta,ra,jf,Of,Ff,cc,Hf,AN,IN,Df,TN,$N,jN,Ce,xt=E(()=>{"use strict";lc=ft(Ke(),1),gi=Number.MAX_SAFE_INTEGER,ta=1024,ra=64,jf=1024,Of=64,Ff=5,cc={learning:!0,retrieval:!0},Hf={include:[],max_file_mb:1,max_total_mb:32},AN={provider:"local"},IN=12e4,Df=6e5,TN=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],$N=["**/.idea/**","**/.vscode/**",".codex/skills/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.svelte-kit/**","**/.vite/**","**/.parcel-cache/**","**/.turbo/**","**/.nx/cache/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.nyc_output/**","**/target/**","**/.gradle/**","**/.cxx/**","**/.externalNativeBuild/**","**/captures/**","**/__pycache__/**","**/.pytest_cache/**","**/.mypy_cache/**","**/.ruff_cache/**","**/.tox/**","**/.nox/**","**/.venv/**","**/venv/**","**/obj/**","**/CMakeFiles/**","**/cmake-build-*/**","**/.cache/**","**/tmp/**","**/temp/**","**/logs/**","**/*.tsbuildinfo","**/*.log","**/.DS_Store","**/Thumbs.db"],jN=[...TN,...$N].sort((t,e)=>t.localeCompare(e,"en")),Ce={include:["**/*"],exclude:[...jN],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as aa,promises as Vt}from"fs";function dc(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function qf(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function yi(t){return{dev:t.dev,ino:t.ino,birthtime:dc(t)}}function oa(t,e){let r=yi(t),i=yi(e);return De(r,i)?O(r,i):O(r,i)&&dc(t)===dc(e)&&qf(t)===qf(e)&&t.size===e.size}async function qt(t,e,r={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await Vt.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new Pe("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new Pe("too-large",`${i} exceeds ${e} bytes`);let o=await Vt.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:yi(a)});let s=process.platform==="win32"?aa.O_RDONLY:aa.O_RDONLY|aa.O_NOFOLLOW|aa.O_NONBLOCK,c;try{c=await Vt.open(t,s)}catch(l){throw l.code==="ELOOP"?new Pe("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),Vt.lstat(t,{bigint:n}),Vt.realpath(t)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!oa(a,l)||!oa(a,u))throw new Pe("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:yi(l)}),await r.hooks?.afterOpen?.();let f=[],m=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let v=e+1-m,{bytesRead:k}=await c.read(w,0,Math.min(w.length,v),null);if(k===0)break;if(m+=k,m>e)throw new Pe("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(w.subarray(0,k)))}await r.hooks?.beforeFinalCheck?.();let[p,h,y]=await Promise.all([c.stat({bigint:n}),Vt.lstat(t,{bigint:n}),Vt.realpath(t)]);if(!h.isFile()||h.isSymbolicLink()||y!==o||!oa(a,p)||!oa(a,h))throw new Pe("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:y,identity:yi(p)}),{bytes:Buffer.concat(f,m),stat:p,realPath:y}}finally{await c.close()}}var Pe,Ni=E(()=>{"use strict";mi();Pe=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as sa}from"fs";import Ct from"path";function YN(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function fc(t,e){let r=Ct.relative(t,e);return r===""||!Ct.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ct.sep}`)}async function Wf(t,e){let r=Ct.resolve(t),i=await sa.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return sa.realpath(r)}async function zf(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Ct.join(n,r[a]);let o;try{o=await sa.lstat(n)}catch(u){if(YN(u))return{exists:!1,kind:"missing"};throw u}let s=Ct.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let c=a===r.length-1;if(!c&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(c&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let l=await sa.realpath(n);if(!fc(e,l))throw new Error(`${i.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function ur(t,e,r){let i=ia(e,r.label),n=Ct.resolve(t),a=await Wf(n,r.label),o=i.split("/"),s=Ct.resolve(n,...o);if(!fc(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await zf(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Xe(t,e,r,i){let n=await ur(t,e,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await Wf(n.projectRoot,i.label);return qt(n.target,r,{...i,verify:async(o,s)=>{if(!fc(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await zf(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var Pt=E(()=>{"use strict";Ni();xt()});import{createHash as XN}from"crypto";function QN(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function ca(t,e={}){return(await la(t,e)).document}async function ZN(t){try{return(await Xe(t,bi,gi,{label:bi})).bytes}catch(e){if(QN(e))return null;throw e}}function eb(t){return t?{exists:!0,sha256:XN("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function la(t,e={}){let r=await ZN(t);return{document:r?wi(r.toString("utf8"),e):null,identity:eb(r)}}async function pc(t){return(await ca(t))?.config??null}var bi,dr=E(()=>{"use strict";xt();Pt();bi=".comet/config.yaml"});var fr=E(()=>{"use strict";oc();mi()});var KR,hc=E(()=>{"use strict";fr();dr();Pt();KR=16*1024});var gc=E(()=>{"use strict";fr();xt();dr();Pt();hc()});import{existsSync as Jf,promises as Wt}from"fs";import I from"path";import ab from"os";async function wc(t){try{return await Wt.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function sb(t){try{let e=await Wt.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function hr(t,e){let r=I.relative(t,e);return r===""||!I.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${I.sep}`)}async function pr(t){let e=[],r=t;for(;!await wc(r);){let n=I.dirname(r);if(n===r)break;e.push(I.basename(r)),r=n}let i=await Wt.realpath(r);return I.resolve(i,...e.reverse())}async function yc(t){try{return(await Wt.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function bc(t){let e=I.resolve(t);try{(await Wt.stat(e)).isDirectory()||(e=I.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=I.resolve(ab.homedir());for(;;){if(!(e===i&&r!==i)){let o=I.join(e,...Nc.split("/")),s=e===r||await sb(o);if(await wc(o)&&s)return e}if(await wc(I.join(e,".git")))return e;let a=I.dirname(e);if(a===e)return r;e=a}}function kc(t){return lr(t)}async function cb(t,e){let r=kc(e),i=I.resolve(t,...r.split("/")),n=await Wt.realpath(t),a=await pr(i);if(!hr(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Qe(t,e){let r=kc(e),i=await cb(t,r),n=I.join(i,"comet");if(await yc(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([pr(i),pr(n)]);if(!hr(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=I.resolve(t),c=I.join(s,".comet","runtime","native");if(await yc(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([Wt.realpath(s),pr(c)]);if(!hr(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:I.join(t,...Nc.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:I.join(n,"specs"),changesDir:I.join(n,"changes"),archiveDir:I.join(n,"archive"),runtimeDir:c,changesRuntimeDir:I.join(c,"changes"),locksDir:I.join(c,"locks"),transactionsDir:I.join(c,"transactions")}}function Uf(t){if(!ob.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ze(t,e){Uf(e);let r=I.join(t.changesRuntimeDir,e);if(!K(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function lb(t,e){Uf(e);let r=I.join(t.changesDir,e,"runtime");if(!K(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function he(t,e){let r=Ze(t,e);if(Jf(r))return r;let i=lb(t,e);return Jf(i)?i:r}function Re(t,e){let r=I.resolve(e);if(K(t.runtimeDir,r))return t.runtimeDir;if(K(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function K(t,e){return hr(I.resolve(t),I.resolve(e))}async function T(t,e){let r=I.resolve(t),i=I.resolve(e);if(!hr(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await yc(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([pr(r),pr(i)]);if(!hr(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var Nc,ob,j=E(()=>{"use strict";xt();Nc=".comet/config.yaml",ob=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});async function Z(t){let e=(await ca(t))?.config??null;return e?.native?e:null}async function da(t){let e=await Z(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}var ua,ue=E(()=>{"use strict";xt();dr();gc();L();j();ua=na});import{existsSync as db}from"node:fs";import Si from"node:path";function Yf(t,e){let r=e.toLowerCase();return Object.entries(t).find(([i,n])=>i.toLowerCase()===r&&n!==void 0)?.[1]}function pb(t){let e=(Yf(t,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(r=>r.trim().toLowerCase()).filter(Boolean);return[...new Set([...e,".ps1"])]}function hb(t,e,r){let n=Si.win32.isAbsolute(t)||/[\\/]/u.test(t)?[""]:(Yf(e,"PATH")??"").split(Si.delimiter).map(s=>s.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),o=Si.win32.extname(t)?[t]:pb(e).map(s=>`${t}${s}`);return n.flatMap(s=>o.map(c=>s?Si.join(s,c):Si.resolve(r,c)))}function Sc(t,e,r){return hb(t,e,r).find(i=>db(i))??t}function Ec(t){if(t.some(e=>fb.test(e)))throw new Error("Windows batch check arguments must not contain shell syntax")}var fb,w_,fa=E(()=>{"use strict";fb=/[&|<>()^%"!\r\n]/u,w_=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ")});import{execFileSync as mb}from"node:child_process";import Xf from"node:path";function wb(t){return t instanceof Error&&(t.code==="ETIMEDOUT"||t.killed===!0&&t.signal==="SIGTERM")}function pa(t,e,r={}){let i=r.timeoutMs??vb,n=r.maxBufferBytes??gb;if(!Number.isSafeInteger(i)||i<1)throw new Error("External command timeout must be a positive integer");if(!Number.isSafeInteger(n)||n<1)throw new Error("External command max buffer must be a positive integer");let a=Xf.resolve(r.cwd??process.cwd()),o=r.env??process.env,s=process.platform==="win32"?Sc(t,o,a):t,c=Xf.win32.extname(s).toLowerCase(),l=c===".bat"||c===".cmd";process.platform==="win32"&&l&&Ec(e);try{return mb(s,[...e],{cwd:a,env:o,...r.input!==void 0?{input:r.input}:{},encoding:"utf8",stdio:[r.input===void 0?"ignore":"pipe","pipe","pipe"],timeout:i,maxBuffer:n,windowsHide:!0,shell:process.platform==="win32"&&l})}catch(u){let d=typeof u.stderr=="string"?u.stderr.trim():Buffer.isBuffer(u.stderr)?u.stderr.toString("utf8").trim():"";throw new xc(t,e,d,{cause:u,timedOut:wb(u)})}}var vb,gb,xc,Qf=E(()=>{"use strict";fa();vb=6e4,gb=8*1024*1024,xc=class extends Error{constructor(r,i,n,a){super(`${r} ${i.join(" ")} failed${n?`: ${n}`:""}`,a);this.command=r;this.args=i;this.stderr=n;this.name="ExternalCommandError",this.timedOut=a?.timedOut===!0}command;args;stderr;timedOut}});import{promises as Zf}from"node:fs";import ep from"node:path";function bb(t){let e=Pc.get(t);if(!e)return;let r=e.value===null?Nb:yb;if(Date.now()-e.at>r){Pc.delete(t);return}return e.value}async function Ei(t){if(t===process.pid&&Cc!==null)return Cc;let e=bb(t);if(e!==void 0)return e;let r=await kb(t);return t===process.pid&&r!==null&&(Cc=r),t!==process.pid&&Pc.set(t,{value:r,at:Date.now()}),r}async function kb(t){if(!Number.isSafeInteger(t)||t<=0)return null;try{if(process.platform==="linux"){let[e,r]=await Promise.all([Zf.readFile(`/proc/${t}/stat`,"utf8"),Zf.readFile("/proc/sys/kernel/random/boot_id","utf8")]),i=e.slice(e.lastIndexOf(")")+2).trim().split(/\s+/u)[19];return/^\d+$/u.test(i??"")?`linux:${r.trim()}:${i}`:null}if(process.platform==="win32")return await Eb(t);if(process.platform==="darwin"){let e=pa("/bin/ps",["-p",String(t),"-o","lstart="],{timeoutMs:5e3,maxBufferBytes:4096,env:{...process.env,LC_ALL:"C",TZ:"UTC0"}}).trim();return e?`darwin:${e}`:null}}catch{}return null}function Sb(t){let e=t.trim();return/^\d+$/u.test(e)?`win32-ps:${e}`:null}async function Eb(t){try{let n=pa(ep.win32.join(process.env.SystemRoot??"C:\\Windows","System32","wbem","WMIC.exe"),["process","where",`processid=${t}`,"get","creationdate","/value"],{timeoutMs:5e3,maxBufferBytes:4096}),a=/^CreationDate=(\S+)/mu.exec(n);if(a)return`win32-wmic:${a[1]}`}catch{}let e=process.env.SystemRoot??"C:\\Windows",r=ep.win32.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe"),i=pa(r,["-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:8e3,maxBufferBytes:4096}).trim();return Sb(i)}function ha(t){let e=t.indexOf(":");return e===-1?"":t.slice(0,e)}async function Rc(t,e){if(!Number.isSafeInteger(t)||t<=0)return"alive";try{process.kill(t,0)}catch(i){if(i.code==="ESRCH")return"dead"}if(!e)return"unknown";let r=await Ei(t);return r===e?"alive":r===null||ha(r)!==ha(e)&&tp.has(ha(r))&&tp.has(ha(e))?"unknown":"dead"}var Cc,yb,Nb,Pc,tp,ma=E(()=>{"use strict";Qf();Cc=null,yb=6e4,Nb=1e4,Pc=new Map;tp=new Set(["win32-wmic","win32-ps"])});import{AsyncLocalStorage as xb}from"async_hooks";import{randomUUID as np}from"crypto";import{promises as me}from"fs";import ap from"os";import F from"path";function Rb(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function _b(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let r=t;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0||r.processIdentity!==void 0&&(typeof r.processIdentity!="string"||r.processIdentity.length===0))throw new Error(`Invalid Native lock metadata: ${e}`);return r}function op(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function ga(t,e){let r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return De(r,i)?O(r,i):O(r,i)&&t.size===e.size}function wa(t,e){return ga(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}function Ab(t,e){return t.status!==e.status?!1:!t.owner||!t.identity||!e.owner||!e.identity?t.owner===e.owner&&t.identity===e.identity:t.owner.id===e.owner.id&&wa(t.identity,e.identity)}async function _e(t){let e,r;try{let i=await qt(t,rp,{bigint:!0,label:"Native lock"});e=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof Pe?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${rp} bytes: ${t}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:i}):new Error(`Native lock changed while reading: ${t}`,{cause:i}):i}return{file:t,owner:_b(JSON.parse(e.toString("utf8")),t),identity:op(r)}}async function Ib(t){return(await _e(t))?.owner??null}async function Ac(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==ap.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=await Rc(t.owner.pid,t.owner.processIdentity);return{status:e==="alive"?"active":e==="dead"?"stale":"unknown",owner:t.owner,identity:t.identity}}async function Tb(t,e){try{await me.lstat(e);return}catch(r){if(r.code!=="ENOENT")throw r}try{await me.rename(t,e)}catch(r){if(r.code!=="ENOENT")throw r}}async function ya(t,e){let r=await _e(t.file);if(!r)return"missing";if(r.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!wa(r.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await me.mkdir(e,{recursive:!0});let i=F.join(e,`${F.basename(t.file)}.${t.owner.id}.${np()}.removed`);try{await me.rename(t.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await _e(i);if(!n||n.owner.id!==t.owner.id||!ga(n.identity,t.identity))throw await Tb(i,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await me.rm(i,{force:!0}),"removed"}async function sp(t){let e=await Ei(process.pid);return{id:np(),pid:process.pid,hostname:ap.hostname(),createdAt:new Date().toISOString(),operation:t,...e===null?{}:{processIdentity:e}}}async function cp(t,e){let r;try{r=await me.open(t,"wx")}catch(a){if(a.code==="EEXIST"){let o=await Ib(t);throw new Error(`Native lock is already held: ${t}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(e,null,2)+`
146
- `,"utf8"),await r.sync(),i=op(await r.stat({bigint:!0}))}finally{await r.close()}let n=await _e(t);if(!i||!n||n.owner.id!==e.id||!ga(n.identity,i))throw new Error(`Native lock changed after write: ${t}`);return n.identity}async function $b(t,e){let r=await T(t.runtimeDir,t.locksDir);await me.mkdir(r,{recursive:!0});let i=await T(t.runtimeDir,F.join(r,_c));await me.mkdir(i,{recursive:!0});let n=await sp(e),a=F.join(i,`.${n.id}.tmp`),o=F.join(i,`${n.id}.claim`);try{let s=await cp(a,n);await me.rename(a,o);let c=await _e(o);if(!c||!ga(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:r,owner:n,identity:c.identity}}finally{await me.rm(a,{force:!0})}}async function jb(t){let e=F.dirname(t.file),r=!1,i=F.basename(t.file);for(let n of await me.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=F.join(e,n.name);if(F.resolve(a)!==F.resolve(t.file))try{let o=await _e(a),s=await Ac(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await ya(o,e);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function lp(t){let e=await _e(t.file);if(e){if(e.owner.id!==t.owner.id||!wa(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await ya(e,F.dirname(t.file))}}async function Ob(t,e){let r=Date.now()+Cb;for(;;){let i=await $b(t,e);if(!await jb(i))return i;if(await lp(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function Hb(t){let e=va.get(t)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=e.then(()=>i);return va.set(t,n),await e,()=>{r(),va.get(t)===n&&va.delete(t)}}async function Ic(t,e,r){let i=F.resolve(t.locksDir),n=ip.getStore();if(n?.has(i))return r();let a=await Hb(i);try{let o=await Ob(t,e),s=new Map(n??[]);return s.set(i,o),await ip.run(s,async()=>{try{return await r()}finally{await lp(o)}})}finally{a()}}async function Na(t,e,r){return Ic(t,`acquire ${e}`,async()=>{let i=await T(t.runtimeDir,t.locksDir);await me.mkdir(i,{recursive:!0});let n=await T(t.runtimeDir,F.join(i,Rb(e))),a=await sp(r),o=await cp(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:i,owner:a,identity:o}})}async function ba(t){await _e(t.file)&&await Ic({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${F.basename(t.file)}`,async()=>{let e=await _e(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!wa(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let r=F.join(t.locksDir,_c);await ya(e,r)})}function Db(t,e=Date.now()){if(!t)return 0;let r=Date.parse(t.createdAt);return Number.isFinite(r)?Math.max(0,e-r):Number.POSITIVE_INFINITY}async function up(t){return Ac(await _e(t))}async function dp(t,e,r,i={}){return Ic(t,`take over ${F.basename(e)}`,async()=>{let n=await T(t.runtimeDir,t.locksDir),a=await T(t.runtimeDir,e);if(F.resolve(F.dirname(a))!==F.resolve(n))throw new Error(`Native lock takeover target is outside the lock directory: ${e}`);let o=await _e(a),s=await Ac(o);if(s.status==="missing")return{status:"missing"};if(r&&!Ab(r,s))return{status:"changed",diagnosis:s};let c=i.allowAgedUnknown===!0&&s.status==="unknown"&&Db(o?.owner??null)>=Pb;if(s.status!=="stale"&&!c||!o)return{status:"changed",diagnosis:s};let l=F.join(n,_c);return await ya(o,l)==="removed"?{status:"removed",owner:o.owner}:{status:"missing"}})}var rp,_c,Cb,Pb,ip,va,xi=E(()=>{"use strict";Ni();ma();j();Le();rp=16*1024,_c=".coordinator",Cb=5e3,Pb=900*1e3,ip=new xb,va=new Map});import{createHash as Lb}from"node:crypto";function mp(t){return t.replaceAll(`\r
142
+ `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=Ba(e),i=Or(r);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=Ba(e),i=Or(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};fh.Parser=al});var gh=N(Ji=>{"use strict";var ph=Gc(),Bk=Li(),Gi=Fi(),Mk=Ws(),Fk=_(),Vk=nl(),hh=ol();function mh(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Vk.LineCounter||null,prettyErrors:e}}function qk(t,e={}){let{lineCounter:r,prettyErrors:i}=mh(e),n=new hh.Parser(r?.addNewLine),a=new ph.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(Gi.prettifyError(t,r)),s.warnings.forEach(Gi.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function vh(t,e={}){let{lineCounter:r,prettyErrors:i}=mh(e),n=new hh.Parser(r?.addNewLine),a=new ph.Composer(e),o=null;for(let s of a.compose(n.parse(t),!0,t.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Gi.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Gi.prettifyError(t,r)),o.warnings.forEach(Gi.prettifyError(t,r))),o}function Wk(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=vh(t,r);if(!n)return null;if(n.warnings.forEach(a=>Mk.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},r))}function zk(t,e,r){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let n=Math.round(r);r=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=r??e??{};if(!n)return}return Fk.isDocument(t)&&!i?t.toString(r):new Bk.Document(t,i,r).toString(r)}Ji.parse=Wk;Ji.parseAllDocuments=qk;Ji.parseDocument=vh;Ji.stringify=zk});var at=N(T=>{"use strict";var Gk=Gc(),Jk=Li(),Uk=Cc(),sl=Fi(),Kk=ki(),Tt=_(),Yk=Pt(),Xk=q(),Qk=_t(),Zk=At(),eS=Da(),tS=rl(),rS=nl(),iS=ol(),Fa=gh(),wh=wi();T.Composer=Gk.Composer;T.Document=Jk.Document;T.Schema=Uk.Schema;T.YAMLError=sl.YAMLError;T.YAMLParseError=sl.YAMLParseError;T.YAMLWarning=sl.YAMLWarning;T.Alias=Kk.Alias;T.isAlias=Tt.isAlias;T.isCollection=Tt.isCollection;T.isDocument=Tt.isDocument;T.isMap=Tt.isMap;T.isNode=Tt.isNode;T.isPair=Tt.isPair;T.isScalar=Tt.isScalar;T.isSeq=Tt.isSeq;T.Pair=Yk.Pair;T.Scalar=Xk.Scalar;T.YAMLMap=Qk.YAMLMap;T.YAMLSeq=Zk.YAMLSeq;T.CST=eS;T.Lexer=tS.Lexer;T.LineCounter=rS.LineCounter;T.Parser=iS.Parser;T.parse=Fa.parse;T.parseAllDocuments=Fa.parseAllDocuments;T.parseDocument=Fa.parseDocument;T.stringify=Fa.stringify;T.visit=wh.visit;T.visitAsync=wh.visitAsync});import{AsyncLocalStorage as nS}from"node:async_hooks";import{performance as Va}from"node:perf_hooks";function cl(t=0){aS+=1,oS+=t;let e=sS.getStore();e&&(e.gitCommands+=1,e.gitDurationMs+=t)}function qa(t){let e=Va.now();try{return t()}finally{cl(Va.now()-e)}}async function ll(t){let e=Va.now();try{return await t()}finally{cl(Va.now()-e)}}var aS,oS,sS,Hr=x(()=>{"use strict";aS=0,oS=0,sS=new nS});import{existsSync as cS}from"node:fs";import Ui from"node:path";function yh(t,e){let r=e.toLowerCase();return Object.entries(t).find(([i,n])=>i.toLowerCase()===r&&n!==void 0)?.[1]}function uS(t){let e=(yh(t,"PATHEXT")??".COM;.EXE;.BAT;.CMD").split(";").map(r=>r.trim().toLowerCase()).filter(Boolean);return[...new Set([...e,".ps1"])]}function dS(t,e,r){let n=Ui.win32.isAbsolute(t)||/[\\/]/u.test(t)?[""]:(yh(e,"PATH")??"").split(Ui.delimiter).map(s=>s.trim().replace(/^"(.*)"$/u,"$1")).filter(Boolean),o=Ui.win32.extname(t)?[t]:uS(e).map(s=>`${t}${s}`);return n.flatMap(s=>o.map(l=>s?Ui.join(s,l):Ui.resolve(r,l)))}function Wa(t,e,r){return dS(t,e,r).find(i=>cS(i))??t}function ul(t){if(t.some(e=>lS.test(e)))throw new Error("Windows batch check arguments must not contain shell syntax")}var lS,VT,Ki=x(()=>{"use strict";lS=/[&|<>()^%"!\r\n]/u,VT=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ")});import{execFile as fS,execFileSync as zT}from"node:child_process";import Nh from"node:path";async function $t(t,e,r={}){let i=r.timeoutMs??pS,n=r.maxBufferBytes??hS;if(!Number.isSafeInteger(i)||i<1||!Number.isSafeInteger(n)||n<1)throw new Error("External command limits must be positive integers");let a=Nh.resolve(r.cwd??process.cwd()),o=r.env??process.env,s=process.platform==="win32"?Wa(t,o,a):t,l=process.platform==="win32"&&/\.(?:bat|cmd)$/iu.test(s);l&&ul(e);let c=()=>new Promise((u,d)=>{let f=!1,p=fS(s,[...e],{cwd:a,env:o,encoding:"utf8",maxBuffer:n,windowsHide:!0,shell:l},(w,g,b)=>{f||(f=!0,clearTimeout(m),r.signal?.removeEventListener("abort",h),w?d(new Yi(t,e,b.trim(),{cause:w,timedOut:mS(w)})):u(g))}),v=w=>{f||(f=!0,clearTimeout(m),r.signal?.removeEventListener("abort",h),p.kill("SIGKILL"),p.stdin?.destroy(),p.stdout?.destroy(),p.stderr?.destroy(),p.unref(),d(new Yi(t,e,"",{timedOut:w})))},h=()=>v(!1),m=setTimeout(()=>v(!0),i);r.signal?.addEventListener("abort",h,{once:!0}),r.signal?.aborted&&h(),p.stdin?.end(r.input)});return/^(?:git|git\.exe)$/iu.test(Nh.win32.basename(t))?ll(c):c()}function mS(t){return t instanceof Error&&(t.code==="ETIMEDOUT"||t.killed===!0&&t.signal==="SIGTERM")}var pS,hS,Yi,za=x(()=>{"use strict";Hr();Ki();pS=6e4,hS=8*1024*1024;Yi=class extends Error{constructor(r,i,n,a){super(`${r} ${i.join(" ")} failed${n?`: ${n}`:""}`,a);this.command=r;this.args=i;this.stderr=n;this.name="ExternalCommandError",this.timedOut=a?.timedOut===!0}command;args;stderr;timedOut}});function ES(t){return t.toLowerCase().startsWith(".env")}function Zi(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>ES(i))?"environment-file":r.some(i=>SS.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>kS.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var kS,SS,en=x(()=>{"use strict";kS=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),SS=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});function jt(t){return t!==0&&t!==0n&&t!=="0"}function We(t,e){return jt(t.dev)&&jt(e.dev)&&jt(t.ino)&&jt(e.ino)}function B(t,e){let r=jt(t.dev)&&jt(e.dev);if(r&&t.dev!==e.dev)return!1;let i=jt(t.ino)&&jt(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var tn=x(()=>{"use strict"});var ze=x(()=>{"use strict";tn()});import{createHash as xS}from"node:crypto";import{promises as Ae}from"node:fs";import ye from"node:path";import{TextDecoder as CS}from"node:util";function dl(t,e){let r=ye.relative(t,e);return r===""||!ye.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ye.sep}`)}function PS(t){let e=ye.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||ye.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let r=t.toLowerCase(),i=Zi(t);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${t}`);return t}function RS(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function _S(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Ga(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return We(r,i)?B(r,i):B(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function xh(t){let e=await Ae.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await Ae.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function AS(t,e){let r=ye.resolve(t),i=ye.resolve(e);if(!dl(r,i))throw new Error("Native artifact path is outside its root");let n=[await xh(r)],a=r;for(let o of ye.relative(r,i).split(ye.sep).filter(Boolean)){a=ye.join(a,o);let s=await xh(a);if(!dl(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Ch(t){for(let e of t){let r=await Ae.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!_S(e,r)||await Ae.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function M(t){let e=PS(t.ref),r=t.maxBytes===null?null:RS(t.maxBytes??fl),i=ye.resolve(t.root,...e.split("/")),n=await AS(t.root,ye.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await Ae.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);let o=await Ae.realpath(i);if(!dl(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await Ae.open(i,"r");try{let[l,c,u]=await Promise.all([s.stat(),Ae.lstat(i),Ae.realpath(i)]);if(await Ch(n),!l.isFile()||!c.isFile()||c.isSymbolicLink()||u!==o||!Ga(a,l)||!Ga(l,c))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?p.length:r+1-f,E=await s.read(p,0,Math.min(p.length,b),null);if(E.bytesRead===0)break;if(f+=E.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);d.push(Buffer.from(p.subarray(0,E.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),Ae.lstat(i),Ae.realpath(i)]);if(await Ch(n),!h.isFile()||h.isSymbolicLink()||m!==o||!Ga(l,v)||!Ga(l,h))throw new Error(`Native artifact changed while reading: ${e}`);let w=Buffer.concat(d,f),g;try{g=new CS("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:f,hash:t.includeHash===!1?null:xS("sha256").update(w).digest("hex"),text:g}}finally{await s.close()}}var fl,Ie=x(()=>{"use strict";en();ze();fl=1024*1024});import{promises as hl}from"node:fs";async function ml(t,e){let r;for(let i=0;i<=pl.length;i+=1)try{return await t()}catch(n){r=n;let a=n.code;if(i===pl.length||!IS.has(a??""))throw n;await new Promise(o=>setTimeout(o,pl[i]))}throw r}async function vl(t,e){await ml(()=>hl.rename(t,e),`rename ${e}`)}async function gl(t){await ml(()=>hl.unlink(t),`unlink ${t}`)}async function wl(t,e){await ml(()=>hl.link(t,e),`link ${e}`)}var IS,pl,yl=x(()=>{"use strict";IS=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),pl=[50,100,200]});import{randomUUID as TS}from"crypto";import{promises as re}from"fs";import Te from"path";function Ja(t,e){let r=Te.relative(t,e);return r===""||!Te.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Te.sep}`)}function $S(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Ua(t,e){return B({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function jS(t,e){return Ua(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Ph(t){let e=await re.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await re.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Br(t){for(let e of t){let r=await re.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!$S(e,r)||await re.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function OS(t,e,r){let[i,n]=await Promise.all([re.lstat(t),re.realpath(t),r?Br(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Ua(i,e)||r&&!Ja(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function HS(t,e){let r=Te.resolve(t),i=Te.resolve(e);if(!Ja(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Ph(r)],a=Te.relative(r,i).split(Te.sep).filter(Boolean),o=r;for(let s of a){await Br(n),o=Te.join(o,s);try{await re.mkdir(o)}catch(c){if(c.code!=="EEXIST")throw c}let l=await Ph(o);if(!Ja(n[0].realPath,l.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(l)}return await Br(n),n}async function DS(t){let e;try{e=await re.open(t,"r"),await e.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await e?.close()}}async function LS(t,e,r={}){let i=Te.dirname(t),n=r.containedRoot?await HS(r.containedRoot,i):null;n||await re.mkdir(i,{recursive:!0});let a=Te.join(i,`.${Te.basename(t)}.${TS()}.tmp`),o,s,l;try{if(await r.beforeTemporaryOpen?.(),o=await re.open(a,"wx"),s=await o.stat(),n){let[c,u]=await Promise.all([re.lstat(a),re.realpath(a)]);if(await Br(n),!c.isFile()||c.isSymbolicLink()||!Ua(s,c)||!Ja(n[0].realPath,u))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof e=="string"?await o.writeFile(e,"utf8"):await o.writeFile(e),await o.sync(),l=await o.stat(),!Ua(s,l))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await r.afterTemporaryClose?.(),!l)throw new Error("Native atomic write temporary file was not written");if(l=await OS(a,l,n),await r.beforeCommit?.(),n){await Br(n);let c=await re.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!l||!jS(c,l))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await wl(a,t),await gl(a)):await vl(a,t),await DS(i)}catch(c){if(await o?.close(),!n)await re.rm(a,{force:!0});else try{await Br(n),await re.rm(a,{force:!0})}catch{}throw c}}async function Ge(t,e,r={}){await LS(t,e,r)}async function ue(t,e,r={}){await Ge(t,JSON.stringify(e,null,2)+`
143
+ `,r)}var V=x(()=>{"use strict";yl();ze()});function _h(t,e){return Nl[t][e]}function Ka(t){return Ah.get(t.trim().toLocaleLowerCase("en-US"))??null}function FS(t){return tr[t].section}function VS(t,e){return tr[t].subsections[e]}function $h(t){return`${tr.en.subsections[t]}/${tr["zh-CN"].subsections[t]}`}function jh(t){return Ih.has(t.trim().toLocaleLowerCase("en-US"))}function Oh(t){return Th.get(t.trim().toLocaleLowerCase("en-US"))??null}function Ya(t,e={}){let r=["outcome","scope","nonGoals","acceptanceExamples"];return e.compact||r.push("constraints","decisions","openQuestions","verificationExpectations"),r.map(i=>{if(i!=="scope")return`# ${_h(t,i)}
144
+ `;let n=[`# ${_h(t,i)}
145
+ `];n.push(`## ${FS(t)}
146
+ `);for(let a of bl)n.push(`### ${VS(t,a)}
147
+ `);return n.join(`
148
+ `)}).join(`
149
+ `)}var bl,Nl,BS,MS,Ah,Rh,Ih,Th,tr,rr=x(()=>{"use strict";bl=["created","modified","deleted","notCreated"],Nl={en:{outcome:"Outcome",scope:"Scope",nonGoals:"Non-goals",acceptanceExamples:"Acceptance examples",constraints:"Constraints and invariants",decisions:"Decisions",openQuestions:"Open questions",verificationExpectations:"Verification expectations"},"zh-CN":{outcome:"目标",scope:"范围",nonGoals:"非目标",acceptanceExamples:"验收示例",constraints:"约束与不变量",decisions:"决策",openQuestions:"待解决问题",verificationExpectations:"验证预期"}},BS={en:{verification:"Verification",currentResult:"Current result",acceptance:"Acceptance",checks:"Checks",blockers:"Blockers",risks:"Risks and skipped work",previousIterations:"Previous iterations",conclusion:"Conclusion"},"zh-CN":{verification:"验证",currentResult:"当前结果",acceptance:"验收",checks:"检查",blockers:"阻塞项",risks:"风险与跳过的工作",previousIterations:"之前的迭代",conclusion:"结论"}},MS={en:{acceptanceEvidence:"Acceptance evidence",commandsAndResults:"Commands and results",skippedChecks:"Skipped checks",specConsistency:"Spec consistency",knownLimitationsAndRisks:"Known limitations and risks",conclusion:"Conclusion"},"zh-CN":{acceptanceEvidence:"验收证据",commandsAndResults:"命令与结果",skippedChecks:"跳过的检查",specConsistency:"规格一致性",knownLimitationsAndRisks:"已知限制与风险",conclusion:"结论"}},Ah=new Map,Rh=new Map,Ih=new Set,Th=new Map,tr={en:{section:"Directory structure",subsections:{created:"Created",modified:"Modified",deleted:"Deleted",notCreated:"Not created"}},"zh-CN":{section:"目录结构",subsections:{created:"新建",modified:"修改",deleted:"删除",notCreated:"明确不建"}}};for(let t of Object.keys(Nl)){for(let[e,r]of Object.entries(Nl[t]))Ah.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(BS[t]))Rh.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(MS[t]))Rh.set(r.toLocaleLowerCase("en-US"),e)}for(let t of Object.keys(tr)){Ih.add(tr[t].section.toLocaleLowerCase("en-US"));for(let[e,r]of Object.entries(tr[t].subsections))Th.set(r.toLocaleLowerCase("en-US"),e)}});import Ot from"path";function US(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||Ot.posix.isAbsolute(r)||Ot.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return i}function Mr(t){let e=US(t,"native.artifact_root");return e.length===0?".":e.join("/")}function qh(t,e="docs"){let r=t??e;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function Za(t,e,r=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim().replaceAll("\\","/");if(i.length===0||Ot.posix.isAbsolute(i)||Ot.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${e} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function ot(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Wh(t,e,r){let i=t??e;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function eo(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>Xa)throw new Error(`${e} exceeds ${Xa} characters`);let r=0;for(let i=0;i<t.length;i+=1)t[i]==="?"?r+=1:t[i]==="*"&&(r+=1,t[i+1]==="*"&&(i+=1));if(r>Qa)throw new Error(`${e} contains more than ${Qa} wildcard tokens`);return t}function Mh(t,e,r){if(t===void 0)return[...r];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(i=>eo(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function rn(t,e,r){let i=t??e;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function Fh(t,e,r){let i=rn(t,e,r);if(i>Math.floor(Number.MAX_SAFE_INTEGER/(1024*1024)))throw new Error(`${r} is too large to convert to bytes safely`);return i}function KS(t){if(t===void 0)return{...$e,include:[...$e.include],exclude:[...$e.exclude]};let e=ot(t,"native.snapshot");return{include:Mh(e.include,"native.snapshot.include",$e.include),exclude:Mh(e.exclude,"native.snapshot.exclude",$e.exclude),max_files:rn(e.max_files,$e.max_files,"native.snapshot.max_files"),max_total_bytes:rn(e.max_total_bytes,$e.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:rn(e.max_duration_ms,$e.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:rn(e.max_selection_records,$e.max_selection_records,"native.snapshot.max_selection_records")}}function YS(t){if(t===void 0)return;let e=ot(t,"native.pending_root_move"),r=e.id,i=e.from_artifact_root,n=e.to_artifact_root,a=e.stage;if(typeof r!="string"||!/^[a-f0-9-]{8,}$/u.test(r))throw new Error("native.pending_root_move.id is invalid");if(typeof i!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(e.cleanup!==void 0){let s=ot(e.cleanup,"native.pending_root_move.cleanup"),l=s.kind,c=s.state,u=s.manifest_hash;if(l!=="forward-source"&&l!=="restart-staging"&&l!=="rollback-destination"&&l!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(c!=="prepared"&&c!=="quarantined"&&c!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:l,state:c,manifestHash:u}}return{id:r,fromArtifactRoot:Mr(i),toArtifactRoot:Mr(n),stage:a,...o?{cleanup:o}:{}}}function XS(t){if(t===void 0)return;let e=ot(t,"native.finish");if(e.pull_request===void 0)return{};let r=ot(e.pull_request,"native.finish.pull_request");if(r.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(r.command)||r.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(r.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let i=r.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(Ot.posix.isAbsolute(i[0])||Ot.win32.isAbsolute(i[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=r.timeout_ms??WS;if(!Number.isSafeInteger(n)||n<1||n>Bh)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Bh}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function QS(t,e={}){let r=ot(t,"native"),i=r.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof i!="string")throw new Error("native.artifact_root must be a string");let n=r.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=r.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=r.max_verify_failures??Vh;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=r.document_writes??"allow";if(s!=="allow"&&s!=="revert")throw new Error("native.document_writes must be allow or revert");let l=YS(r.pending_root_move),c=XS(r.finish);return{artifact_root:Mr(i),language:Wh(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:KS(r.snapshot),...c?{finish:c}:{},...l?{pending_root_move:l}:{}}}function ZS(t){let e=ot(t,"classic"),r=e.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=e.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=e.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=e.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:qh(e.artifact_layout),language:Wh(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function eE(t){let r=ot(t,"hook").allow_paths??[];if(!Array.isArray(r))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(r.map((i,n)=>Za(i,`hook.allow_paths[${n}]`)))]}}function tE(t){if(t===void 0)return{...kl};let e=ot(t,"memory"),r=e.learning??kl.learning,i=e.retrieval??kl.retrieval;if(typeof r!="boolean")throw new Error("memory.learning must be true or false");if(typeof i!="boolean")throw new Error("memory.retrieval must be true or false");return{learning:r,retrieval:i}}function El(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function rE(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||Ot.posix.isAbsolute(r)||Ot.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${e} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${e} must target a Markdown file ending in .md`);if(r.length>Hh)throw new Error(`${e} exceeds ${Hh} characters`);let i=0;for(let n=0;n<r.length;n+=1)r[n]==="?"?i+=1:r[n]==="*"&&(i+=1,r[n+1]==="*"&&(n+=1));if(i>Dh)throw new Error(`${e} contains more than ${Dh} wildcard tokens`);return r}function iE(t){let e=El(t,"knowledge.local"),r=e.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>rE(n,`knowledge.local.include[${a}]`)))],max_file_mb:Fh(e.max_file_mb,Lh.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Fh(e.max_total_mb,Lh.max_total_mb,"knowledge.local.max_total_mb")};if(i.max_file_mb>i.max_total_mb)throw new Error("knowledge.local.max_file_mb must not exceed max_total_mb");return i}function nE(t){if(typeof t!="string"||t.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let e;try{e=new URL(t)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=e.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return e.toString()}function aE(t){let e=El(t,"knowledge.remote"),r=nE(e.endpoint),i=e.token_env;if(i!==void 0&&(typeof i!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(i)))throw new Error("knowledge.remote.token_env must be an environment variable name");let n=e.scope;if(n!==void 0&&(typeof n!="string"||n.length>512))throw new Error("knowledge.remote.scope must be a string of at most 512 characters");let a=e.timeout_ms??5e3;if(typeof a!="number"||!Number.isSafeInteger(a)||a<100||a>3e4)throw new Error("knowledge.remote.timeout_ms must be an integer between 100 and 30000");return{endpoint:r,...i===void 0?{}:{token_env:i},...n===void 0?{}:{scope:n},timeout_ms:a}}function oE(t){if(t===void 0)return{...qS};let e=El(t,"knowledge"),r=e.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=e.local===void 0?void 0:iE(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:aE(e.remote);if(n===void 0)throw new Error("knowledge.remote must be configured when knowledge.provider is remote");return{provider:r,...i?{local:i}:{},remote:n}}function sE(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function cE(t,e,r,i,n,a,o,s){let l=t.schema!==void 0;if(!(l||t.default_workflow!==void 0||t.workflows!==void 0||!s.allowPartialProject&&t.native!==void 0)||s.allowPartialProject&&!l)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let u=t.workflows??[t.default_workflow];if(!Array.isArray(u)||u.length===0||u.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let d=[...new Set(u)];if(!d.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(d.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:d,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function an(t,e={}){let r=(0,Sl.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${r.errors[0].message}`);let i=r.toJS();if(i==null)return{value:{},config:null,ambient_resume:!0};if(typeof i!="object"||Array.isArray(i))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=i,a=sE(n.ambient_resume),o=n.hook===void 0?void 0:eE(n.hook),s=tE(n.memory),l=oE(n.knowledge),c=n.native===void 0?void 0:QS(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),u=n.classic===void 0?void 0:ZS(n.classic),d=cE(n,o,s,l,c,u,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:d,ambient_resume:a,memory:s,knowledge:l,...o?{hook:o}:{},...c?{native:c}:{},...u?{classic:u}:{}}}var Sl,nn,Xa,Qa,Hh,Dh,Vh,kl,Lh,qS,WS,Bh,zS,GS,JS,$e,Ht=x(()=>{"use strict";Sl=kt(at(),1),nn=Number.MAX_SAFE_INTEGER,Xa=1024,Qa=64,Hh=1024,Dh=64,Vh=5,kl={learning:!0,retrieval:!0},Lh={include:[],max_file_mb:1,max_total_mb:32},qS={provider:"local"},WS=12e4,Bh=6e5,zS=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".devin/skills/**",".dsh/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".omp/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],GS=["**/.idea/**","**/.vscode/**",".codex/skills/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.svelte-kit/**","**/.vite/**","**/.parcel-cache/**","**/.turbo/**","**/.nx/cache/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.nyc_output/**","**/target/**","**/.gradle/**","**/.cxx/**","**/.externalNativeBuild/**","**/captures/**","**/__pycache__/**","**/.pytest_cache/**","**/.mypy_cache/**","**/.ruff_cache/**","**/.tox/**","**/.nox/**","**/.venv/**","**/venv/**","**/obj/**","**/CMakeFiles/**","**/cmake-build-*/**","**/.cache/**","**/tmp/**","**/temp/**","**/logs/**","**/*.tsbuildinfo","**/*.log","**/.DS_Store","**/Thumbs.db"],JS=[...zS,...GS].sort((t,e)=>t.localeCompare(e,"en")),$e={include:["**/*"],exclude:[...JS],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as to,promises as ir}from"fs";function xl(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function zh(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function on(t){return{dev:t.dev,ino:t.ino,birthtime:xl(t)}}function ro(t,e){let r=on(t),i=on(e);return We(r,i)?B(r,i):B(r,i)&&xl(t)===xl(e)&&zh(t)===zh(e)&&t.size===e.size}async function nr(t,e,r={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let i=r.label??"file",n=r.bigint===!0,a=await ir.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new je("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new je("too-large",`${i} exceeds ${e} bytes`);let o=await ir.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:on(a)});let s=process.platform==="win32"?to.O_RDONLY:to.O_RDONLY|to.O_NOFOLLOW|to.O_NONBLOCK,l;try{l=await ir.open(t,s)}catch(c){throw c.code==="ELOOP"?new je("not-regular-file",`${i} must be a regular file`,{cause:c}):c}try{let[c,u,d]=await Promise.all([l.stat({bigint:n}),ir.lstat(t,{bigint:n}),ir.realpath(t)]);if(!c.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!ro(a,c)||!ro(a,u))throw new je("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:d,identity:on(c)}),await r.hooks?.afterOpen?.();let f=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let g=e+1-p,{bytesRead:b}=await l.read(v,0,Math.min(v.length,g),null);if(b===0)break;if(p+=b,p>e)throw new je("too-large",`${i} exceeds ${e} bytes`);f.push(Buffer.from(v.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[h,m,w]=await Promise.all([l.stat({bigint:n}),ir.lstat(t,{bigint:n}),ir.realpath(t)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!ro(a,h)||!ro(a,m))throw new je("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:w,identity:on(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:w}}finally{await l.close()}}var je,sn=x(()=>{"use strict";tn();je=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as io}from"fs";import Dt from"path";function lE(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Cl(t,e){let r=Dt.relative(t,e);return r===""||!Dt.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Dt.sep}`)}async function Gh(t,e){let r=Dt.resolve(t),i=await io.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return io.realpath(r)}async function Jh(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=Dt.join(n,r[a]);let o;try{o=await io.lstat(n)}catch(u){if(lE(u))return{exists:!1,kind:"missing"};throw u}let s=Dt.relative(t,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${i.label} crosses a symbolic link or junction at ${s}`);let l=a===r.length-1;if(!l&&!o.isDirectory())throw new Error(`${i.label} ancestor ${s} must be a real directory`);if(l&&(i.expected==="file"&&!o.isFile()||i.expected==="directory"&&!o.isDirectory()||i.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${i.label} must be a real ${i.expected}`);let c=await io.realpath(n);if(!Cl(e,c))throw new Error(`${i.label} resolves outside the project root`);if(l)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function Fr(t,e,r){let i=Za(e,r.label),n=Dt.resolve(t),a=await Gh(n,r.label),o=i.split("/"),s=Dt.resolve(n,...o);if(!Cl(n,s))throw new Error(`${r.label} must stay inside the project root`);let l=await Jh(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:l.exists,kind:l.kind}}async function Je(t,e,r,i){let n=await Fr(t,e,{label:i.label,expected:"file"});if(!n.exists){let o=new Error(`${i.label} does not exist`);throw o.code="ENOENT",o}let a=await Gh(n.projectRoot,i.label);return nr(n.target,r,{...i,verify:async(o,s)=>{if(!Cl(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Jh(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var st=x(()=>{"use strict";sn();Ht()});import{createHash as uE}from"crypto";function dE(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function no(t,e={}){return(await ao(t,e)).document}async function fE(t){try{return(await Je(t,cn,nn,{label:cn})).bytes}catch(e){if(dE(e))return null;throw e}}function pE(t){return t?{exists:!0,sha256:uE("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function ao(t,e={}){let r=await fE(t);return{document:r?an(r.toString("utf8"),e):null,identity:pE(r)}}async function Pl(t){return(await no(t))?.config??null}var cn,Vr=x(()=>{"use strict";Ht();st();cn=".comet/config.yaml"});var qr=x(()=>{"use strict";yl();tn()});var U$,Rl=x(()=>{"use strict";qr();Vr();st();U$=16*1024});var Il=x(()=>{"use strict";qr();Ht();Vr();st();Rl()});import{existsSync as Kh,promises as ar}from"fs";import $ from"path";import wE from"os";async function Tl(t){try{return await ar.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function NE(t){try{let e=await ar.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function zr(t,e){let r=$.relative(t,e);return r===""||!$.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${$.sep}`)}async function Wr(t){let e=[],r=t;for(;!await Tl(r);){let n=$.dirname(r);if(n===r)break;e.push($.basename(r)),r=n}let i=await ar.realpath(r);return $.resolve(i,...e.reverse())}async function $l(t){try{return(await ar.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ol(t){let e=$.resolve(t);try{(await ar.stat(e)).isDirectory()||(e=$.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=$.resolve(wE.homedir());for(;;){if(!(e===i&&r!==i)){let o=$.join(e,...jl.split("/")),s=e===r||await NE(o);if(await Tl(o)&&s)return e}if(await Tl($.join(e,".git")))return e;let a=$.dirname(e);if(a===e)return r;e=a}}function Hl(t){return Mr(t)}async function bE(t,e){let r=Hl(e),i=$.resolve(t,...r.split("/")),n=await ar.realpath(t),a=await Wr(i);if(!zr(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Lt(t,e){let r=Hl(e),i=await bE(t,r),n=$.join(i,"comet");if(await $l(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Wr(i),Wr(n)]);if(!zr(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=$.resolve(t),l=$.join(s,".comet","runtime","native");if(await $l(l))throw new Error("The Native Runtime root must not be a symbolic link");let[c,u]=await Promise.all([ar.realpath(s),Wr(l)]);if(!zr(c,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:$.join(t,...jl.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:$.join(n,"specs"),changesDir:$.join(n,"changes"),archiveDir:$.join(n,"archive"),runtimeDir:l,changesRuntimeDir:$.join(l,"changes"),locksDir:$.join(l,"locks"),transactionsDir:$.join(l,"transactions")}}function Yh(t){if(!yE.test(t))throw new Error(`Invalid Native change name: ${t}`)}function ct(t,e){Yh(e);let r=$.join(t.changesRuntimeDir,e);if(!Q(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function kE(t,e){Yh(e);let r=$.join(t.changesDir,e,"runtime");if(!Q(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Ne(t,e){let r=ct(t,e);if(Kh(r))return r;let i=kE(t,e);return Kh(i)?i:r}function Oe(t,e){let r=$.resolve(e);if(Q(t.runtimeDir,r))return t.runtimeDir;if(Q(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function Q(t,e){return zr($.resolve(t),$.resolve(e))}async function j(t,e){let r=$.resolve(t),i=$.resolve(e);if(!zr(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await $l(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([Wr(r),Wr(i)]);if(!zr(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var jl,yE,L=x(()=>{"use strict";Ht();jl=".comet/config.yaml",yE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});async function be(t){let e=(await no(t))?.config??null;return e?.native?e:null}async function so(t){let e=await be(t);if(e?.native.pending_root_move)throw new Error(`Native root move ${e.native.pending_root_move.id} is incomplete; use comet native doctor --repair`)}var oo,he=x(()=>{"use strict";Ht();Vr();Il();V();L();oo=eo});import{createHash as Ll,randomUUID as EE}from"node:crypto";import{promises as me}from"node:fs";import xE from"node:os";import de from"node:path";async function Dl(t,e){let r=await me.lstat(t,{bigint:!0});if(!r.isFile()||r.isSymbolicLink()||r.size>BigInt(e))throw new Error("Invalid process probe cache");let i=await me.readFile(t),n=await me.lstat(t,{bigint:!0});if(r.ino!==n.ino||r.ctimeNs!==n.ctimeNs||r.size!==n.size)throw new Error("Process probe cache changed");return i}async function em(t){try{let e=JSON.parse((await Dl(de.join(t,"probe.json"),4096)).toString("utf8"));if(!/^probe-[a-f0-9-]+\.exe$/u.test(e.file??""))return null;let r=de.join(t,e.file),i=await Dl(r,65536);return Ll("sha256").update(i).digest("hex")===e.hash?r:null}catch{return null}}async function RE(t,e){let r,i=EE(),n=de.join(t,`probe-${i}.cs`),a=de.join(t,`probe-${i}.exe`),o=de.join(t,`probe-${i}.json`);try{if(await me.mkdir(t,{recursive:!0,mode:448}),(await me.lstat(t)).isSymbolicLink())return null;r=await me.open(de.join(t,"prepare.lock"),"wx",384);let s=await em(t);if(s)return s;await me.writeFile(n,Zh,{flag:"wx",mode:384});let l;for(let u of["Framework64","Framework"]){let d=de.join(e,"Microsoft.NET",u,"v4.0.30319","csc.exe");try{await me.access(d),l=d;break}catch{}}if(!l)return null;await $t(l,["/nologo","/target:exe","/platform:anycpu",`/out:${a}`,n],{timeoutMs:1500,maxBufferBytes:4096});let c=Ll("sha256").update(await Dl(a,65536)).digest("hex");return await me.writeFile(o,JSON.stringify({file:de.basename(a),hash:c}),{flag:"wx",mode:384}),await me.rename(o,de.join(t,"probe.json")),a}catch{return null}finally{await me.unlink(n).catch(()=>{}),await me.unlink(o).catch(()=>{}),r&&(await r.close().catch(()=>{}),await me.unlink(de.join(t,"prepare.lock")).catch(()=>{}))}}async function Qh(t,e,r){try{let i=await $t(de.join(e,"System32","wbem","WMIC.exe"),["process","where",`processid=${t}`,"get","creationdate","/value"],{timeoutMs:300,maxBufferBytes:4096,signal:r}),n=/^CreationDate=(\S+)/mu.exec(i);if(n)return`win32-wmic:${n[1]}`}catch{}if(r.aborted)return null;try{let n=(await $t(de.join(e,"System32","WindowsPowerShell","v1.0","powershell.exe"),["-NoLogo","-NoProfile","-NonInteractive","-Command",`(Get-Process -Id ${t} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks.ToString()`],{timeoutMs:1e3,maxBufferBytes:4096,signal:r})).trim();return/^\d+$/u.test(n)?`win32-ps:${n}`:null}catch{return null}}function _E(t,e){let r=co.get(t);if(r&&performance.now()<r.retryAfter)return r.promise;let i={promise:RE(t,e),retryAfter:1/0};return co.set(t,i),i.promise.then(n=>{co.get(t)===i&&(n?co.delete(t):i.retryAfter=performance.now()+PE)}),i.promise}async function tm(t,e={}){if(!Number.isSafeInteger(t)||t<=0)return null;let r=e.systemRoot??process.env.SystemRoot??"C:\\Windows",i=de.join(e.cacheRoot??de.join(xE.tmpdir(),"comet-process-identity"),CE),n=async c=>{if(!c)return null;try{let d=(await $t(c,[String(t)],{timeoutMs:1e3,maxBufferBytes:4096})).trim();return/^\d+$/u.test(d)?`win32-ps:${d}`:null}catch{return null}},a=await em(i);if(a){let c=await n(a);return c||Qh(t,r,new AbortController().signal)}let o=_E(i,r),s=new AbortController,l=c=>{if(!c)throw new Error("Probe unavailable");return c};try{return await Promise.any([o.then(n).then(l),Qh(t,r,s.signal).then(l)])}catch{return null}finally{s.abort()}}var Zh,CE,PE,co,rm=x(()=>{"use strict";za();Zh=`using System;
150
+ using System.Runtime.InteropServices;
151
+ class CometProcessIdentity {
152
+ [DllImport("kernel32.dll")] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
153
+ [DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
154
+ [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
155
+ static int Main(string[] args) {
156
+ int pid; if(args.Length != 1 || !int.TryParse(args[0], out pid) || pid <= 0) return 1;
157
+ IntPtr handle=OpenProcess(0x1000, false, pid); if(handle == IntPtr.Zero) return 1;
158
+ try { long creation, exit, kernel, user; if(!GetProcessTimes(handle,out creation,out exit,out kernel,out user)) return 1;
159
+ Console.WriteLine(DateTime.FromFileTimeUtc(creation).Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture)); return 0;
160
+ } finally { CloseHandle(handle); }
161
+ }
162
+ }`,CE=Ll("sha256").update(Zh).digest("hex"),PE=1e4,co=new Map});import{promises as im}from"node:fs";function IE(t){let e=Ml.get(t);if(e){if(Date.now()-e.at>AE){Ml.delete(t);return}return e.value}}async function un(t){if(t===process.pid&&Bl!==null)return Bl;let e=IE(t);if(e!==void 0)return e;let r=lo.get(t);r||(r=TE(t),lo.set(t,r));let i=await r;return lo.get(t)===r&&lo.delete(t),t===process.pid&&i!==null&&(Bl=i),i===null&&Ml.set(t,{value:null,at:Date.now()}),i}async function TE(t){if(!Number.isSafeInteger(t)||t<=0)return null;try{if(process.platform==="linux"){let[e,r]=await Promise.all([im.readFile(`/proc/${t}/stat`,"utf8"),im.readFile("/proc/sys/kernel/random/boot_id","utf8")]),i=e.slice(e.lastIndexOf(")")+2).trim().split(/\s+/u)[19];return/^\d+$/u.test(i??"")?`linux:${r.trim()}:${i}`:null}if(process.platform==="win32")return await tm(t);if(process.platform==="darwin"){let e=(await $t("/bin/ps",["-p",String(t),"-o","lstart="],{timeoutMs:5e3,maxBufferBytes:4096,env:{...process.env,LC_ALL:"C",TZ:"UTC0"}})).trim();return e?`darwin:${e}`:null}}catch{}return null}function uo(t){let e=t.indexOf(":");return e===-1?"":t.slice(0,e)}async function Fl(t,e){if(!Number.isSafeInteger(t)||t<=0)return"alive";try{process.kill(t,0)}catch(i){if(i.code==="ESRCH")return"dead"}if(!e)return"unknown";let r=await un(t);return r===e?"alive":r===null||uo(r)!==uo(e)&&nm.has(uo(r))&&nm.has(uo(e))?"unknown":"dead"}var Bl,AE,Ml,lo,nm,fo=x(()=>{"use strict";za();rm();Bl=null,AE=1e4,Ml=new Map,lo=new Map;nm=new Set(["win32-wmic","win32-ps"])});import{AsyncLocalStorage as $E}from"async_hooks";import{randomUUID as sm}from"crypto";import{promises as ke}from"fs";import cm from"os";import W from"path";function HE(t){if(!/^[a-z][a-z0-9-]*$/u.test(t))throw new Error(`Invalid Native lock name: ${t}`);return`${t}.lock`}function DE(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Invalid Native lock metadata: ${e}`);let r=t;if(typeof r.id!="string"||r.id.length===0||typeof r.pid!="number"||!Number.isSafeInteger(r.pid)||r.pid<1||typeof r.hostname!="string"||r.hostname.length===0||typeof r.createdAt!="string"||r.createdAt.length===0||typeof r.operation!="string"||r.operation.length===0||r.processIdentity!==void 0&&(typeof r.processIdentity!="string"||r.processIdentity.length===0))throw new Error(`Invalid Native lock metadata: ${e}`);return r}function lm(t){return{device:t.dev.toString(),inode:t.ino.toString(),size:t.size.toString(),birthtimeNs:t.birthtimeNs.toString(),ctimeNs:t.ctimeNs.toString(),mtimeNs:t.mtimeNs.toString()}}function ho(t,e){let r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs},i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs};return We(r,i)?B(r,i):B(r,i)&&t.size===e.size}function dn(t,e){return ho(t,e)&&t.size===e.size&&t.birthtimeNs===e.birthtimeNs&&t.ctimeNs===e.ctimeNs&&t.mtimeNs===e.mtimeNs}function LE(t,e){return t.status!==e.status?!1:!t.owner||!t.identity||!e.owner||!e.identity?t.owner===e.owner&&t.identity===e.identity:t.owner.id===e.owner.id&&dn(t.identity,e.identity)}async function Se(t){let e,r;try{let i=await nr(t,am,{bigint:!0,label:"Native lock"});e=i.bytes,r=i.stat}catch(i){if(i.code==="ENOENT")return null;throw i instanceof je?i.reason==="too-large"?new Error(`Native lock metadata exceeds ${am} bytes: ${t}`,{cause:i}):i.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${t}`,{cause:i}):new Error(`Native lock changed while reading: ${t}`,{cause:i}):i}return{file:t,owner:DE(JSON.parse(e.toString("utf8")),t),identity:lm(r)}}async function BE(t){return(await Se(t))?.owner??null}async function ql(t){if(!t)return{status:"missing",owner:null,identity:null};if(t.owner.hostname!==cm.hostname())return{status:"unknown",owner:t.owner,identity:t.identity};let e=await Fl(t.owner.pid,t.owner.processIdentity);return{status:e==="alive"?"active":e==="dead"?"stale":"unknown",owner:t.owner,identity:t.identity}}async function ME(t,e){try{await ke.lstat(e);return}catch(r){if(r.code!=="ENOENT")throw r}try{await ke.rename(t,e)}catch(r){if(r.code!=="ENOENT")throw r}}async function mo(t,e){let r=await Se(t.file);if(!r)return"missing";if(r.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!dn(r.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);await ke.mkdir(e,{recursive:!0});let i=W.join(e,`${W.basename(t.file)}.${t.owner.id}.${sm()}.removed`);try{await ke.rename(t.file,i)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await Se(i);if(!n||n.owner.id!==t.owner.id||!ho(n.identity,t.identity))throw await ME(i,t.file),new Error(`Native lock changed before quarantine: ${t.file}`);return await ke.rm(i,{force:!0}),"removed"}async function um(t){let e=await un(process.pid);return{id:sm(),pid:process.pid,hostname:cm.hostname(),createdAt:new Date().toISOString(),operation:t,...e===null?{}:{processIdentity:e}}}async function dm(t,e){let r;try{r=await ke.open(t,"wx")}catch(a){if(a.code==="EEXIST"){let o=await BE(t);throw new Error(`Native lock is already held: ${t}${o?` by pid ${o.pid} for ${o.operation}`:""}`,{cause:a})}throw a}let i;try{await r.writeFile(JSON.stringify(e,null,2)+`
163
+ `,"utf8"),await r.sync(),i=lm(await r.stat({bigint:!0}))}finally{await r.close()}let n=await Se(t);if(!i||!n||n.owner.id!==e.id||!ho(n.identity,i))throw new Error(`Native lock changed after write: ${t}`);return n.identity}async function FE(t,e){let r=await j(t.runtimeDir,t.locksDir);await ke.mkdir(r,{recursive:!0});let i=await j(t.runtimeDir,W.join(r,Vl));await ke.mkdir(i,{recursive:!0});let n=await um(e),a=W.join(i,`.${n.id}.tmp`),o=W.join(i,`${n.id}.claim`);try{let s=await dm(a,n);await ke.rename(a,o);let l=await Se(o);if(!l||!ho(s,l.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:t.runtimeDir,locksDir:r,owner:n,identity:l.identity}}finally{await ke.rm(a,{force:!0})}}async function VE(t){let e=W.dirname(t.file),r=!1,i=W.basename(t.file);for(let n of await ke.readdir(e,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=W.join(e,n.name);if(W.resolve(a)!==W.resolve(t.file))try{let o=await Se(a),s=await ql(o);if(s.status==="missing")continue;let l=await Se(a);if(!l)continue;if(!o||l.owner.id!==o.owner.id||!dn(l.identity,o.identity)){n.name<i&&(r=!0);continue}if(s.status==="stale"&&o){await mo(o,e);continue}n.name<i&&(r=!0)}catch{n.name<i&&(r=!0)}}return r}async function fm(t){let e=await Se(t.file);if(e){if(e.owner.id!==t.owner.id||!dn(e.identity,t.identity))throw new Error(`Native lock coordinator ownership changed: ${t.file}`);await mo(e,W.dirname(t.file))}}async function qE(t,e){let r=Date.now()+jE;for(;;){let i=await FE(t,e);if(!await VE(i))return i;if(await fm(i),Date.now()>=r)throw new Error(`Native lock coordinator is busy: ${t.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function WE(t){let e=po.get(t)??Promise.resolve(),r,i=new Promise(a=>{r=a}),n=e.then(()=>i);return po.set(t,n),await e,()=>{r(),po.get(t)===n&&po.delete(t)}}async function Wl(t,e,r){let i=W.resolve(t.locksDir),n=om.getStore();if(n?.has(i))return r();let a=await WE(i);try{let o=await qE(t,e),s=new Map(n??[]);return s.set(i,o),await om.run(s,async()=>{try{return await r()}finally{await fm(o)}})}finally{a()}}async function vo(t,e,r){return Wl(t,`acquire ${e}`,async()=>{let i=await j(t.runtimeDir,t.locksDir);await ke.mkdir(i,{recursive:!0});let n=await j(t.runtimeDir,W.join(i,HE(e))),a=await um(r),o=await dm(n,a);return{file:n,nativeRoot:t.runtimeDir,locksDir:i,owner:a,identity:o}})}async function go(t){await Se(t.file)&&await Wl({runtimeDir:t.nativeRoot,locksDir:t.locksDir},`release ${W.basename(t.file)}`,async()=>{let e=await Se(t.file);if(!e)return;if(e.owner.id!==t.owner.id)throw new Error(`Native lock ownership changed: ${t.file}`);if(!dn(e.identity,t.identity))throw new Error(`Native lock identity changed: ${t.file}`);let r=W.join(t.locksDir,Vl);await mo(e,r)})}function zE(t,e=Date.now()){if(!t)return 0;let r=Date.parse(t.createdAt);return Number.isFinite(r)?Math.max(0,e-r):Number.POSITIVE_INFINITY}async function pm(t){return ql(await Se(t))}async function hm(t,e,r,i={}){return Wl(t,`take over ${W.basename(e)}`,async()=>{let n=await j(t.runtimeDir,t.locksDir),a=await j(t.runtimeDir,e);if(W.resolve(W.dirname(a))!==W.resolve(n))throw new Error(`Native lock takeover target is outside the lock directory: ${e}`);let o=await Se(a),s=await ql(o);if(s.status==="missing")return{status:"missing"};if(r&&!LE(r,s))return{status:"changed",diagnosis:s};let l=i.allowAgedUnknown===!0&&s.status==="unknown"&&zE(o?.owner??null)>=OE;if(s.status!=="stale"&&!l||!o)return{status:"changed",diagnosis:s};let c=W.join(n,Vl);return await mo(o,c)==="removed"?{status:"removed",owner:o.owner}:{status:"missing"}})}var am,Vl,jE,OE,om,po,fn=x(()=>{"use strict";sn();fo();L();ze();am=16*1024,Vl=".coordinator",jE=5e3,OE=900*1e3,om=new $E,po=new Map});import{createHash as GE}from"node:crypto";function cr(t){return t.replaceAll(`\r
147
164
  `,`
148
165
  `).replaceAll("\r",`
149
- `)}function Vb(t){return Lb("sha256").update(mp(t)).digest("hex")}function Oc(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new H(`${e} must be an object`);return t}function vp(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new H(`${r} has unknown field(s): ${i.join(", ")}`)}function Hc(t,e){if(typeof t!="string"||t.trim().length===0)throw new H(`${e} must be a non-empty string`);return t.trim()}function pp(t,e){if(t!==void 0){if(typeof t!="string")throw new H(`${e} must be text`);return mp(t).replace(/^\n+|\n+$/gu,"")}}function ka(t,e){let r=Hc(t,e).toLowerCase();if(!Mb.test(r))throw new H(`${e} must be a SHA-256 hash`);return r}function hp(t,e,r){let i=Oc(t,e),n=Object.entries(i);if(n.length>fp)throw new H(`${e} must contain at most ${fp} entries`);let a={};for(let[o,s]of n){if($c(o,`${e} ID`)!==o)throw new H(`${e} ID must be normalized: ${o}`);s===null&&r?a[o]=null:a[o]=ka(s,`${e}.${o}`)}return a}function $c(t,e){let r=Hc(t,e);if(!Fb.test(r))throw new H(`${e} is not a valid stable requirement ID`);return r}function qb(t,e){let r=Hc(t,e);if(!Bb.test(r))throw new H(`${e} is not a valid capability ID`);return r}function Wb(t,e){let r=`Native delta operations[${e}]`,i=Oc(t,r);vp(i,new Set(["id","operation","to_id","title","body","expected_hash"]),r);let n=$c(i.id,`${r}.id`),a=i.operation;if(!["add","modify","remove","rename"].includes(String(a)))throw new H(`${r}.operation is invalid`);let o=a,s=i.to_id===void 0?void 0:$c(i.to_id,`${r}.to_id`),c=pp(i.title,`${r}.title`),l=pp(i.body,`${r}.body`),u=i.expected_hash===void 0?void 0:ka(i.expected_hash,`${r}.expected_hash`);if(o==="add"){if(s!==void 0||u!==void 0||!l?.trim())throw new H(`${r} add requires body and forbids to_id and expected_hash`)}else if(o==="modify"){if(s!==void 0||!u||!l?.trim())throw new H(`${r} modify requires body and expected_hash and forbids to_id`)}else if(o==="remove"){if(s!==void 0||c!==void 0||l!==void 0||!u)throw new H(`${r} remove requires expected_hash and forbids to_id, title, and body`)}else if(s===void 0||s===n||!u||l==="")throw new H(`${r} rename requires a different to_id and expected_hash`);return{id:n,operation:o,...s===void 0?{}:{to_id:s},...c===void 0?{}:{title:c},...l===void 0?{}:{body:l},...u===void 0?{}:{expected_hash:u}}}function zb(t){let e=Oc(t,"Native delta");if(vp(e,new Set(["schema","capability","base_hash","base_version","legacy_hash","base_requirements","independent_requirements","operations"]),"Native delta"),e.schema!==Tc)throw new H(`Native delta schema must be ${Tc}`);let r=qb(e.capability,"Native delta capability"),i=ka(e.base_hash,"Native delta base_hash");if(!Number.isSafeInteger(e.base_version)||Number(e.base_version)<1)throw new H("Native delta base_version must be a positive integer");let n=e.legacy_hash===void 0?void 0:ka(e.legacy_hash,"Native delta legacy_hash"),a;e.base_requirements!==void 0&&(a=hp(e.base_requirements,"Native delta base_requirements",!1));let o=e.independent_requirements===void 0?void 0:hp(e.independent_requirements,"Native delta independent_requirements",!0);if(!Array.isArray(e.operations))throw new H("Native delta operations must be an array");let s=e.operations.map(Wb),c=new Set;for(let[l,u]of s.entries()){let d=[u.id,...u.to_id===void 0?[]:[u.to_id]];for(let f of d){if(c.has(f))throw new H(`Native delta operations contain duplicate or overlapping requirement ID ${f} at ${l}`);c.add(f)}}if(o!==void 0){if(a===void 0)throw new H("Native delta independent_requirements requires base_requirements");for(let[l,u]of Object.entries(o)){if(c.has(l))throw new H(`Native delta requirement ${l} cannot be both addressed and independent`);let d=a[l];if(u===null?d!==void 0:d!==u)throw new H(`Native delta independent_requirements does not match baseline ${l}`)}}return{schema:Tc,capability:r,base_hash:i,base_version:Number(e.base_version),...n===void 0?{}:{legacy_hash:n},...a===void 0?{}:{base_requirements:a},...o===void 0?{}:{independent_requirements:o},operations:s}}function Gb(t){let e=(0,jc.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length>0)throw new H(`Native delta is invalid YAML: ${e.errors[0].message}`);return e.toJS({mapAsMap:!1})}function Dc(t){return zb(typeof t=="string"?Gb(t):t)}function Pi(t){return Vb(t)}var jc,Tc,Ci,Bb,Fb,Mb,fp,H,Sa=E(()=>{"use strict";jc=ft(Ke(),1),Tc="comet.native.delta.v1",Ci="delta.yaml",Bb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Fb=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u,Mb=/^[a-f0-9]{64}$/iu,fp=512,H=class extends Error{code="native-delta-invalid";constructor(e){super(e),this.name="NativeDeltaValidationError"}}});var Fe,et,tt,Ri=E(()=>{"use strict";Fe="comet.native.v3",et="comet.native.v2",tt="comet.native.v1"});import Jb from"node:path";function Ai(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Np(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function vr(t){if(!yp.test(t))throw new Error(`Invalid Native change name: ${t}`)}function bp(t){if(!yp.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function kp(t,e){if(t.length===0||Jb.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function tk(t,e){let r=Ai(t,`spec_changes[${e}]`);if(Np(r,Yb,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(bp(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&kp(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!Bc.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!Bc.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function rk(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function Fc(t,e){if(Np(t,e,nt),typeof t.name!="string")throw new Error("Native change name is required");if(vr(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!Xb.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!Qb.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let r=t.spec_changes.map(tk),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof t.verification_result!="string"||!Zb.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&kp(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!rk(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:r,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function Ii(t){let e=Ai(t,nt);if(e.schema!==tt)throw new Error(`Expected ${tt}`);return{schema:tt,...Fc(e,Ub)}}function _i(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Lc(t,e,r){if(t===null)return null;let i=typeof t=="string"?ek.exec(t):null;if(!i||i[1]!==r)throw new Error(`${e} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return t}function ik(t){if(t==null)return null;if(typeof t!="string"||!Bc.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function nk(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function Ti(t){let e=Ai(t,nt);if(e.schema!==et)throw new Error(`Expected ${et}`);if(_i(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${et} minimum_runtime_version must be 2`);return{schema:et,minimum_runtime_version:2,revision:_i(e.revision,"Native v2 revision"),...Fc(e,wp)}}function gr(t){let e=Ai(t,nt);if(e.schema!==Fe){if(e.schema===tt||e.schema===et){let o=e.schema===tt?Ii(e):Ti(e);throw new mr(o.name,o.schema)}throw new it(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=_i(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new it(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=_i(e.revision,"Native revision"),n=Fc(e,Kb),a=ik(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Fe,minimum_runtime_version:3,revision:i,verification_protocol:nk(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:Lc(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Lc(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Lc(e.partial_allowance,"Native partial_allowance","allowances")}}function Mc(t){let e=Ai(t,nt);if(e.schema===tt){let n=Ii(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Fe}`}}if(e.schema===et){let n=Ti(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Fe}`}}if(e.schema!==Fe){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new it(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=_i(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new it(e.schema,r).message};let i=gr(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var gp,Ub,wp,Kb,Yb,Xb,Qb,Zb,nt,Bc,yp,ek,mr,it,Ea=E(()=>{"use strict";Ri();gp=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],Ub=new Set(gp),wp=new Set([...gp,"minimum_runtime_version","revision"]),Kb=new Set([...wp,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),Yb=new Set(["capability","operation","source","base_hash"]),Xb=new Set(["shape","build","verify","archive"]),Qb=new Set(["implicit","confirmed"]),Zb=new Set(["pending","pass","fail"]),nt="comet-state.yaml",Bc=/^[a-f0-9]{64}$/u,yp=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ek=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,mr=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},it=class extends Error{constructor(r,i){super(r!==Fe||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"}});import{createHash as ak}from"crypto";function Ae(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function ok(t,e){e.has(t)&&Ae("cyclic structures are not supported"),e.add(t);try{let r=Object.keys(t);for(let i=0;i<t.length;i+=1)Object.prototype.hasOwnProperty.call(t,i)||Ae("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&Ae("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&Ae("symbol properties are not supported"),`[${t.map(i=>Vc(i,e)).join(",")}]`}finally{e.delete(t)}}function sk(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&Ae("only plain objects are supported"),e.has(t)&&Ae("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&Ae("symbol properties are not supported"),e.add(t);try{let i=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&Ae("accessor properties are not supported"),`${JSON.stringify(o)}:${Vc(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function Vc(t,e){if(t===null)return"null";switch(typeof t){case"boolean":return t?"true":"false";case"string":return JSON.stringify(t);case"number":return Number.isFinite(t)||Ae("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?ok(t,e):sk(t,e);case"bigint":case"function":case"symbol":case"undefined":return Ae(`${typeof t} values are not supported`)}return Ae("unsupported value type")}function qc(t){return Vc(t,new Set)}function W(t,e){if(t.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(t))throw new TypeError("Canonical hash tag must not contain a line break");return ak("sha256").update(`${t}
150
- ${qc(e)}`).digest("hex")}var z=E(()=>{"use strict"});var U_,Sp,xa=E(()=>{"use strict";Mt();z();U_=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Sp=Object.freeze({maxCriteria:1024})});var Wc=E(()=>{"use strict";xa()});var $i,ji,Ca=E(()=>{"use strict";$i="comet.native.v4",ji="comet.native.local-execution.v4"});import{promises as fk}from"node:fs";function ee(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function te(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function G(t,e,r){if(typeof t!="string"||!r?.empty&&t.length===0)throw new Error(`${e} must be ${r?.empty?"a string":"a non-empty string"}`);return t}function Gc(t,e){return t===null?null:G(t,e)}function Jc(t,e){let r=G(t,e);if(!vk.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function wr(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function D(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function wk(t,e){return t===null?null:D(t,e,Number.MIN_SAFE_INTEGER)}function M(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Me(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function Ia(t,e){return Me(t,e,(r,i)=>G(r,`${e}[${i}]`))}function zt(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function yr(t,e){let r=G(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function _a(t,e,r=!1){let i=G(t,e);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return i}function ve(t,e){let r=ee(t,e);return te(r,new Set(["text","truncated"]),e),{text:G(r.text,`${e}.text`,{empty:!0}),truncated:wr(r.truncated,`${e}.truncated`)}}function yk(t,e){let r=`Native spec_changes[${e}]`,i=ee(t,r);te(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=G(i.capability,`${r}.capability`);if(!hk.test(n))throw new Error(`${r}.capability is invalid`);let a=M(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:_a(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:_a(i.delta_source,`${r}.delta_source`),c=i.base_hash===void 0?void 0:i.base_hash===null?null:Jc(i.base_hash,`${r}.base_hash`);if(a==="remove"&&o!==null)throw new Error(`${r} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${r} ${a} requires a source`);if(s!==void 0&&a==="remove")throw new Error(`${r} remove cannot contain delta_source`);if(s!==void 0&&c==null)throw new Error(`${r} delta_source requires a non-null base_hash`);if(c!==void 0&&s===void 0&&a!=="remove")throw new Error(`${r} base_hash requires delta_source for non-remove specs`);return{capability:n,operation:a,source:o,...s===void 0?{}:{delta_source:s},...c===void 0?{}:{base_hash:c}}}function Nk(t){let e="Native workspace",r=ee(t,e);te(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=M(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=Gc(r.change_branch,`${e}.change_branch`),a=Gc(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:M(r.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function bk(t){let e="Native loop",r=ee(t,e);te(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),e);let i=Ia(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);zt(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:M(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:M(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:D(r.goal_cycle,`${e}.goal_cycle`,1),iteration:D(r.iteration,`${e}.iteration`),attempt:D(r.attempt,`${e}.attempt`),retry_epoch:D(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:D(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:D(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:D(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:Gc(r.next_action,`${e}.next_action`)}}function kk(t,e){let r=`Native acceptance[${e}]`,i=ee(t,r);te(i,new Set(["id","source","text","result","reason"]),r);let n=G(i.id,`${r}.id`);if(!mk.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:_a(i.source,`${r}.source`),text:G(i.text,`${r}.text`),result:M(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ve(i.reason,`${r}.reason`)}}function Sk(t,e){let r=`Native builder_handoff.checks[${e}]`,i=ee(t,r);return te(i,new Set(["name","result","note"]),r),{name:ve(i.name,`${r}.name`),result:M(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ve(i.note,`${r}.note`)}}function Ek(t){let e="Native builder_handoff",r=ee(t,e);te(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),e);let i=Ia(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);zt(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:ee(r.review,`${e}.review`);return n&&te(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:G(r.candidate_id,`${e}.candidate_id`),identity_provider:G(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:G(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),summary:ve(r.summary,`${e}.summary`),addressed_acceptance_ids:i,checks:Me(r.checks,`${e}.checks`,Sk),checks_truncated:wr(r.checks_truncated,`${e}.checks_truncated`),known_limits:Me(r.known_limits,`${e}.known_limits`,(a,o)=>ve(a,`${e}.known_limits[${o}]`)),known_limits_truncated:wr(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:M(n.status,["passed"],`${e}.review.status`),summary:ve(n.summary,`${e}.review.summary`),reviewer_execution_ref:G(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:yr(r.submitted_at,`${e}.submitted_at`)}}function xk(t,e){let r=`Native blockers[${e}]`,i=ee(t,r);te(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=Ia(i.acceptance_ids,`${r}.acceptance_ids`);return zt(n,`${r}.acceptance_ids`),{owner:M(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ve(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:M(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Ck(t,e){let r=`Native verification.checks[${e}]`,i=ee(t,r);return te(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:G(i.id,`${r}.id`),name:ve(i.name,`${r}.name`),argv_display:Me(i.argv_display,`${r}.argv_display`,(n,a)=>ve(n,`${r}.argv_display[${a}]`)),argv_truncated:wr(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:_a(i.cwd_ref,`${r}.cwd_ref`,!0),status:M(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:wk(i.exit_code,`${r}.exit_code`),duration_ms:D(i.duration_ms,`${r}.duration_ms`)}}function Pk(t){let e="Native verification",r=ee(t,e);te(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Me(r.checks,`${e}.checks`,Ck);zt(i.map(a=>a.id),`${e}.checks IDs`);let n=G(r.identity_provider,`${e}.identity_provider`);return{candidate_id:G(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:G(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),attempt:D(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":M(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:M(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:ve(r.summary,`${e}.summary`),risks:Me(r.risks,`${e}.risks`,(a,o)=>ve(a,`${e}.risks[${o}]`)),risks_truncated:wr(r.risks_truncated,`${e}.risks_truncated`),completed_at:yr(r.completed_at,`${e}.completed_at`)}}function Ep(t,e){let r=`Native history[${e}]`,i=ee(t,r);te(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=Ia(i.unresolved_ids,`${r}.unresolved_ids`);return zt(n,`${r}.unresolved_ids`),{goal_cycle:D(i.goal_cycle,`${r}.goal_cycle`,1),iteration:D(i.iteration,`${r}.iteration`),attempt:D(i.attempt,`${r}.attempt`),outcome:M(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ve(i.summary,`${r}.summary`),completed_at:yr(i.completed_at,`${r}.completed_at`)}}function Rk(t){let e="Native history_overflow.outcome_counts",r=ee(t,e),i=["pass","fail","blocked","execution-error","recovery"];return te(r,new Set(i),e),{pass:D(r.pass,`${e}.pass`),fail:D(r.fail,`${e}.fail`),blocked:D(r.blocked,`${e}.blocked`),"execution-error":D(r["execution-error"],`${e}.execution-error`),recovery:D(r.recovery,`${e}.recovery`)}}function _k(t){let e="Native history_overflow",r=ee(t,e);te(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let i=D(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:yr(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:yr(r.last_dropped_at,`${e}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=Rk(r.outcome_counts);if(Object.values(o).reduce((c,l)=>c+l,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function Ak(t){let e=new Set(t.acceptance.map(r=>r.id));for(let r of t.loop.previous_unresolved_ids)if(!e.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);for(let r of t.blockers)for(let i of r.acceptance_ids)if(!e.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(t.builder_handoff){if(!(t.builder_handoff.iteration===t.loop.iteration||t.phase==="build"&&t.loop.stage==="repairing"&&t.builder_handoff.iteration===t.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(t.builder_handoff.review?.reviewer_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(t.verification){if(!t.builder_handoff)throw new Error("Native verification requires a builder handoff");if(t.verification.candidate_id!==t.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(t.verification.identity_provider!==t.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(t.verification.assurance)!==(t.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(t.verification.assurance==="semantic-verification-unavailable"&&t.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(t.verification.assurance==="user-confirmed-degraded"&&t.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(t.verification.verifier_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=t.verification.iteration===t.loop.iteration&&t.verification.attempt===t.loop.attempt,n=t.phase==="build"&&t.loop.stage==="repairing"&&t.verification.iteration===t.loop.iteration-1&&t.verification.iteration===t.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Ik(t){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[t.phase].has(t.loop.stage))throw new Error(`Native loop stage ${t.loop.stage} is invalid for phase ${t.phase}`);let r=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(r!==null&&t.loop.stage!==r)throw new Error(`Native status ${t.status} requires loop stage ${r}`);if(t.status==="active"&&["await-user","blocked","done"].includes(t.loop.stage))throw new Error(`Native active status cannot use loop stage ${t.loop.stage}`);if(t.archived!==(t.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(t.archived&&t.phase!=="archive")throw new Error("Native archived state must be in Archive");if(t.verification_result==="pass"){if(t.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(t.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(t.verification?.assurance==="semantic-verification-unavailable"&&(t.phase!=="verify"||t.status!=="await-user"||t.verification_result!=="blocked"||t.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(t.verification_report!==null&&t.verification===null)throw new Error("Native verification report requires persisted verification")}function Ie(t){let e=ee(t,"Native portable state");if(te(e,gk,"Native portable state"),e.schema!==$i)throw new Error(`Native portable state schema must be ${$i}`);let r=G(e.name,"Native state name");if(!pk.test(r))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=Me(e.spec_changes,"Native spec_changes",yk);zt(i.map(s=>s.capability),"Native spec change capabilities");let n=Me(e.acceptance,"Native acceptance",kk);zt(n.map(s=>s.id),"Native acceptance IDs");let a=Me(e.history,"Native history",Ep);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:$i,name:r,language:M(e.language,["en","zh-CN"],"Native state language"),phase:M(e.phase,["shape","build","verify","archive"],"Native state phase"),status:M(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:D(e.state_version,"Native state_version",1),brief:"brief.md",...e.document_constraints_version===void 0?{}:e.document_constraints_version===1?{document_constraints_version:1}:(()=>{throw new Error("Native document_constraints_version must be 1")})(),...e.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:Jc(e.shape_confirmation_hash,"Native Shape confirmation hash")},...e.children_contract_hash===void 0?{}:{children_contract_hash:Jc(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:M(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:Nk(e.workspace),loop:bk(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Ek(e.builder_handoff),blockers:Me(e.blockers,"Native blockers",xk),verification:e.verification===null?null:Pk(e.verification),history:a,history_overflow:_k(e.history_overflow),verification_result:M(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:M(e.verification_report,["verification.md"],"Native verification_report"),archived:wr(e.archived,"Native archived"),created_at:yr(e.created_at,"Native created_at")};return Ak(o),Ik(o),o}function Nr(t,e){let r=Ie(t),i=Ep(e,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return Ie({...r,history:n,history_overflow:a})}function Tk(t,e){let r=(0,Aa.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${e} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function Oi(t){let e=await fk.readFile(t,"utf8");return Ie(Tk(e,"Native portable state"))}async function xp(t,e,r={}){let i=Ie(e);await Be(t,(0,Aa.stringify)(i),r)}async function $k(t,e){let r=Pa.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);Pa.set(t,a),await r;try{return await e()}finally{i(),Pa.get(t)===a&&Pa.delete(t)}}async function Cp(t){return $k(t.file,async()=>{let e=D(t.expectedStateVersion,"Native expected state version",1),r=Ie(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await Oi(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new Ra(e,i.state_version);return await xp(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await Oi(t.file);if(n.state_version!==e)throw new Ra(e,n.state_version)}}),r})}var Aa,pk,hk,mk,vk,gk,Ra,Pa,Rt=E(()=>{"use strict";Aa=ft(Ke(),1);L();Ca();pk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,hk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,mk=/^A[1-9][0-9]*$/u,vk=/^[a-f0-9]{64}$/u,gk=new Set(["schema","name","language","phase","status","state_version","brief","document_constraints_version","shape_confirmation_hash","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),Ra=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};Pa=new Map});function jk(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function at(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(jk(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let r="",i=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(i+a>e)break;r+=n,i+=a}return{text:r,truncated:!0}}var Gt=E(()=>{"use strict"});function Fk(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Mk(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let r=new Date(t);if(Number.isNaN(r.valueOf())||r.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function Rp(t){let e=Fk(t,"Native portable migration transaction"),r=Object.keys(e).filter(i=>!Ok.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(e.schema!==Pp)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Dk.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!Hk.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!Bk.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!Lk.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:Pp,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:Mk(e.createdAt,"Native portable migration transaction createdAt")}}var Pp,Ok,Hk,Dk,Lk,Bk,_p=E(()=>{"use strict";Ea();Wc();Rt();Gt();Ca();Ri();Pp="comet.native.portable-migration.v1",Ok=new Set(["schema","id","change","fromSchema","status","createdAt"]),Hk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Dk=/^[a-z0-9][a-z0-9-]{7,127}$/u,Lk=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Bk=new Set([tt,et,Fe])});import Vk from"node:path";function jp(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Op(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Uc(t,e){if(t!==void 0){if(t===null)return null;if(typeof t!="string"||!/^[a-f0-9]{64}$/iu.test(t))throw new Error(`${e} must be a SHA-256 hash or null`);return t.toLowerCase()}}function Ip(t,e){if(t!==void 0){if(t!==null&&typeof t!="string")throw new Error(`${e} must be text or null`);return t}}function Yk(t,e){let r=`Native portable Archive spec_changes[${e}]`,i=jp(t,r);if(Op(i,Kk,r),typeof i.capability!="string"||!$p.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation,a=i.delta_source;if(a!==void 0&&(typeof a!="string"||a.length===0||a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||a.split("/").some(f=>f==="."||f==="..")))throw new Error(`${r}.delta_source is invalid`);let o=Uc(i.base_hash,`${r}.base_hash`),s=Ip(i.delta_content,`${r}.delta_content`),c=Ip(i.source_content,`${r}.source_content`),l=Uc(i.expected_target_hash,`${r}.expected_target_hash`),u=Uc(i.result_hash,`${r}.result_hash`),d=a!==void 0;if(d&&o==null)throw new Error(`${r}.delta_source requires a non-null base_hash`);if(d&&(s==null||c===void 0||c===null||u===void 0||u===null))throw new Error(`${r}.delta_source requires delta_content, source_content, and result_hash`);if(!d&&(s!==void 0||c!==void 0))throw new Error(`${r} delta transaction fields require delta_source`);if(d){let f=Dc(s);if(f.capability!==i.capability)throw new Error(`${r}.delta_content capability does not match capability`);if(f.base_hash!==o)throw new Error(`${r}.delta_content base_hash does not match base_hash`);if(Pi(i.content)!==u)throw new Error(`${r}.content does not match result_hash`);if(Pi(c)!==u)throw new Error(`${r}.source_content does not match result_hash`)}if(n==="remove"){if(i.source!==null||i.content!==null||a!==void 0||s!==void 0||c!==void 0||u!==void 0)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null,...o===void 0?{}:{base_hash:o},...l===void 0?{}:{expected_target_hash:l}}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(f=>f==="."||f===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);if(u!==void 0&&(u===null||Pi(i.content)!==u))throw new Error(`${r}.content does not match result_hash`);return{capability:i.capability,operation:n,source:i.source,content:i.content,...a===void 0?{}:{delta_source:a},...o===void 0?{}:{base_hash:o},...s===void 0?{}:{delta_content:s},...c===void 0?{}:{source_content:c},...l===void 0?{}:{expected_target_hash:l},...u===void 0?{}:{result_hash:u}}}function Xk(t){let e=jp(t,"Native portable Archive transaction");if(Op(e,Uk,"Native portable Archive transaction"),e.schema!==Ap)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!zk.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!$p.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!Gk.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!Jk.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=e.spec_changes.map(Yk);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(e.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:Ap,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:r,created_at:e.created_at}}function Kc(t){let e=qk.exec(t);if(e)return{kind:"archive",change:e[1]};let r=Wk.exec(t);return r?{kind:"migration",change:r[1]}:null}async function Hp(t,e){let r=Kc(e);if(!r)return null;let i=await ce({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=Vk.join(t.transactionsDir,e);if(r.kind==="archive"){let s=Xk(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=Rp(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}function Dp(t){return t.kind==="archive"||t.journal.status!=="committed"}var Ap,Tp,qk,Wk,zk,Gk,Jk,Uk,Kk,$p,Yc=E(()=>{"use strict";Ee();Sa();_p();Ap="comet.native.archive-transaction.v4",Tp="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",qk=new RegExp(`^portable-archive-(${Tp})\\.json$`,"u"),Wk=new RegExp(`^portable-migration-(${Tp})\\.json$`,"u"),zk=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,Gk=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Jk=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),Uk=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),Kk=new Set(["capability","operation","source","content","delta_source","base_hash","delta_content","source_content","expected_target_hash","result_hash"]),$p=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});import{createHash as Qk}from"node:crypto";import{constants as Ta,promises as Te}from"node:fs";import $e from"node:path";import{TextDecoder as Zk}from"node:util";function ja(t,e){let r=$e.relative(t,e);return r===""||!$e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${$e.sep}`)}function eS(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function tS(t,e){return O({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function rS(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function $a(t,e){return O({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Xc(t,e){let r=await Te.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await Te.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function iS(t,e,r){let i=$e.resolve(t),n=$e.resolve(e);if(!ja(i,n))throw new Error(`${r} is outside its managed root`);let a=[await Xc(i,r)],o=i;for(let s of $e.relative(i,n).split($e.sep).filter(Boolean)){await Jt(a,r),o=$e.join(o,s);let c=await Xc(o,r);if(!ja(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Jt(a,r),a}async function Jt(t,e){for(let r of t){let i=await Te.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!tS(r,i)||await Te.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function nS(t,e,r){let i=[],n=0,a=Buffer.allocUnsafe(e===null?64*1024:Math.min(64*1024,e+1));for(;;){let o=e===null?a.length:e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,e!==null&&n>e)throw new Error(`${r} exceeds ${e} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function br(t){let e=t.maxBytes===null?null:eS(t.maxBytes),r=$e.resolve(t.file),i=await iS(t.root,$e.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>Xc($e.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Jt(i,t.label);let a=await Te.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(e!==null&&a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=rS(a),s=await Te.realpath(r);if(!ja(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>ja(u.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?Ta.O_RDONLY:Ta.O_RDONLY|Ta.O_NOFOLLOW|Ta.O_NONBLOCK,l=await Te.open(r,c);try{let u=await l.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([Te.lstat(r),Te.realpath(r)]);if(await Jt(i,t.label),await Jt(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!$a(o,u)||!$a(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let m=await nS(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[w,p,h]=await Promise.all([l.stat(),Te.lstat(r),Te.realpath(r)]);if(await Jt(i,t.label),await Jt(n,t.label),!p.isFile()||p.isSymbolicLink()||h!==s||!$a(o,w)||!$a(o,p))throw new Error(`${t.label} changed while reading`);return{bytes:m,hash:Qk("sha256").update(m).digest("hex"),size:m.length}}finally{await l.close()}}async function Lp(t){let e=await br(t),r;try{r=new Zk("utf-8",{fatal:!0}).decode(e.bytes)}catch(i){throw new Error(`${t.label} is not valid UTF-8`,{cause:i})}return{...e,text:r}}var Ve=E(()=>{"use strict";L();Le()});import ot from"path";import{TextDecoder as oS}from"util";function Ha(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Da(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Vp(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function Qc(t,e){if(typeof t!="string"||t.length===0||ot.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function Oa(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function Bp(t,e){if(Qc(t,e),t.includes("\\")||t!==ot.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function fS(t,e){let r=Ha(t,`transaction operations[${e}]`);if(Da(r,cS,`transaction operations[${e}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${e}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);Qc(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&Qc(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function qp(t){let e=Ha(t,"Native Archive transaction journal");if(Da(e,lS,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!Mp.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!Vp(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Oa(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=e.operations.map((s,c)=>{let l=Ha(s,`Archive transaction operations[${c}]`);if(Da(l,uS,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);Bp(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&Bp(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&Oa(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(Oa(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);Oa(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:r}}function pS(t){let e=Ha(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return qp(e);if(Da(e,sS,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!Mp.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!ot.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!ot.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!Vp(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let r=e.operations.map(fS),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:r}}function hS(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return ot.join(t.transactionsDir,e)}function Wp(t,e){let r=hS(t,e);return{directory:r,journal:ot.join(r,"transaction.json"),events:ot.join(r,"events.jsonl"),staged:ot.join(r,"staged"),backups:ot.join(r,"backups")}}async function el(t,e){let r=Wp(t,e);return await Promise.all(Object.values(r).map(i=>T(t.runtimeDir,i))),r}async function tl(t,e,r={}){let i=await el(t,e),n=await br({root:t.runtimeDir,file:i.journal,maxBytes:null,label:`Native transaction journal ${e}`,hooks:r.hooks}),a=JSON.parse(dS.decode(n.bytes)),o=pS(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}var sS,cS,lS,uS,Mp,dS,La=E(()=>{"use strict";L();j();Ve();sS=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),cS=new Set(["id","type","source","target","staged","backup"]),lS=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),uS=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]),Mp=new Set(["prepared","applying","committed","rolling-back","rolled-back"]),dS=new oS("utf-8",{fatal:!0})});import{promises as mS}from"fs";import vS from"path";async function gS(t,e,r){let i;try{i=await mS.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await tl(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(Kc(n.name))try{let a=await Hp(t,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(Dp(a))return!0}catch{return!0}return!1}async function wS(t,e){let r=Date.now()+5e3,i=vS.join(t.locksDir,"root-move.lock");for(;;)try{return await Na(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await up(i);if(o.status==="missing")continue;if(o.status==="stale"){let s=await dp(t,i,o);if(s.status==="removed"||s.status==="missing")continue;throw n}if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function J(t,e,r,i){let n=await wS(t,e);try{if(await da(t.projectRoot),await gS(t,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{try{await ba(n)}catch(a){process.stderr.write(`[comet] warning: could not release Native mutation lock ${n.file} (${a.message}); run comet native doctor --repair if commands start failing
151
- `)}}}var Y=E(()=>{"use strict";ue();xi();Yc();La()});import{createHash as yS}from"crypto";function de(t){return yS("sha256").update(t).digest("hex")}var qe=E(()=>{"use strict"});import il from"path";function Ba(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}function BS(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function FS(t,e){return de(`comet.native.snapshot-policy.v1
152
- ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function rl(t,e,r){let i=new Set(e),n=[...e];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!i.has(a+1)&&(i.add(a+1),n.push(a+1))}return i}function MS(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function zp(t){let e=ua(t,"Native snapshot pattern"),r=[];for(let i=0;i<e.length;i+=1){let n=e[i];n==="*"&&e[i+1]==="*"?(i+=1,e[i+1]==="/"?(i+=1,r.push({kind:"globstar-slash"})):r.push({kind:"globstar"})):n==="*"?r.push({kind:"star"}):n==="?"?r.push({kind:"question"}):r.push({kind:"literal",value:n})}return(i,n)=>{let a=n?MS(n):void 0;if(a&&!a())return!1;let o=rl(r,new Set([0]),a);if(o===null)return!1;for(let s of i){if(a&&!a())return!1;let c=new Set;for(let l of o){if(a&&!a())return!1;let u=r[l];u&&(u.kind==="literal"&&u.value===s||u.kind==="question"&&s!=="/"?c.add(l+1):u.kind==="star"&&s!=="/"||u.kind==="globstar"?c.add(l):u.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=rl(r,c,a),o===null||o.size===0)return!1}return rl(r,o,a)?.has(r.length)??!1}}function VS(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>ua(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>ua(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let i=FS(e,r);if("hash"in t&&t.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:r,hash:i},includeMatchers:e.map(zp),excludeMatchers:r.map(zp),excludedDirectoryPrefixes:r.flatMap(n=>{if(!n.endsWith("/**"))return[];let a=n.slice(0,-3);return/[*?]/u.test(a)?[]:[a]}).sort((n,a)=>n.localeCompare(a,"en"))}}function ge(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function we(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Sr(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function We(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function Up(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let r=il.posix.normalize(t);if(r!==t||il.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function qS(t,e){let r=ge(t,`Native snapshot entry ${e}`);we(r,TS,`Native snapshot entry ${e}`);let i=Up(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!Fa.test(r.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:i,hash:r.hash,size:We(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!LS.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function WS(t,e){let r=ge(t,`Native snapshot omission ${e}`);if(we(r,$S,`Native snapshot omission ${e}`),!HS.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!DS.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:Up(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:We(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function zS(t){let e=ge(t,"Native snapshot omission overflow");if(we(e,jS,"Native snapshot omission overflow"),typeof e.hash!="string"||!Fa.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:e.hash,count:Sr(e.count,"Native snapshot omission overflow count")}}function kr(t,e){let r=ge(t,e);if(we(r,_S,e),typeof r.hash!="string"||!Fa.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let i=We(r.recordCount,`${e} recordCount`),n=We(r.storedRecordCount,`${e} storedRecordCount`),a=We(r.stdoutBytes,`${e} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function Gp(t){let e=ge(t,"Native Git selection evidence");if(we(e,RS,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=kr(e.stageBefore,"Native Git selection stageBefore"),i=kr(e.combined,"Native Git selection combined"),n=kr(e.stageAfter,"Native Git selection stageAfter"),a=kr(e.finalStageBefore,"Native Git selection finalStageBefore"),o=kr(e.finalCombined,"Native Git selection finalCombined"),s=kr(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(d=>d.overflow),l=!Ba(r,n)||!Ba(n,a)||!Ba(i,o)||!Ba(a,s),u=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==u)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:u,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function Jp(t,e){let r=ge(t,e);if(we(r,IS,e),typeof r.hash!="string"||!Fa.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${e} flags are invalid`);let i=We(r.visitedNodeCount,`${e} visitedNodeCount`),n=We(r.recordCount,`${e} recordCount`),a=We(r.storedRecordCount,`${e} storedRecordCount`),o=We(r.encodedBytes,`${e} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function GS(t){let e=ge(t,"Native physical selection evidence");if(we(e,AS,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=Jp(e.before,"Native physical selection before"),i=Jp(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!BS(r,i);if(!n&&!a)throw new Error("Native physical selection evidence must describe an exceptional selection");let o=n&&a?"overflow-and-changed":n?"overflow":"changed";if(e.status!==o)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:o,before:r,after:i}}function Kp(t){let e=ge(t,"Native content snapshot manifest");if(we(e,SS,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!OS.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let g=ge(e.capture,"Native content snapshot capture");if(we(g,CS,"Native content snapshot capture"),g.provider!=="git"&&g.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let R=g.gitSelection===void 0?void 0:Gp(g.gitSelection),b=g.physicalSelection===void 0?void 0:GS(g.physicalSelection),$=null;if(g.projection!==void 0){let se=ge(g.projection,"Native content snapshot projection");if(we(se,PS,"Native content snapshot projection"),se.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");$={provider:"git",...se.selection===void 0?{}:{selection:Gp(se.selection)}}}if(g.provider==="git"){if(b||$)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",...R?{gitSelection:R}:{}}}else{if(R)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(b&&$)throw new Error("Native physical-tree capture cannot combine selection and projection");r=$?{provider:"physical-tree",projection:$}:{provider:"physical-tree",...b?{physicalSelection:b}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=ge(e.limits,"Native content snapshot limits");we(i,ES,"Native content snapshot limits");let n={maxFiles:Sr(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Sr(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Sr(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Sr(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Sr(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let g=ge(e.policy,"Native snapshot policy");if(we(g,xS,"Native snapshot policy"),g.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(g.include)||!Array.isArray(g.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=VS({include:g.include,exclude:g.exclude,hash:g.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=e.entries.map(qS),s=e.omitted.map(WS),c=We(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:zS(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(g=>g.size>n.maxFileBytes)||o.reduce((g,R)=>g+R.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(g=>g.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>bS||c<s.length)throw new Error("Native content snapshot omission count is invalid");let u=c-s.length;if(u===0&&l||u>0&&l?.count!==u)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let d=s.filter(g=>g.reason==="git-enumeration-limit"),f=s.filter(g=>g.reason==="git-selection-changed");for(let g of[...d,...f])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(d.length>1||f.length>1)throw new Error("Native Git selection omissions must not be duplicated");let m=r?.provider==="git"?r.gitSelection:r?.projection?.selection,w=m?.status==="overflow"||m?.status==="overflow-and-changed",p=m?.status==="changed"||m?.status==="overflow-and-changed";if(w!==(d.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(p!==(f.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let h=s.filter(g=>g.reason==="physical-enumeration-limit"),y=s.filter(g=>g.reason==="physical-selection-changed");for(let g of[...h,...y])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(h.length>1||y.length>1)throw new Error("Native physical selection omissions must not be duplicated");let v=r?.physicalSelection,k=v?.status==="overflow"||v?.status==="overflow-and-changed",x=v?.status==="changed"||v?.status==="overflow-and-changed";if(k!==(h.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(x!==(y.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");return{schema:"comet.native.content-snapshot.v1",origin:e.origin,...r?{capture:r}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}}}function JS(t,e){if(!kS.test(e))throw new Error(`Invalid Native change name: ${e}`);return il.join(he(t,e),"baseline-manifest.json")}async function Yp(t,e){let r=JS(t,e),i=Re(t,r);await T(i,r);try{let n=await Lp({root:i,file:r,maxBytes:null,label:"Native baseline snapshot manifest"});return Kp(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var QA,bS,kS,SS,ES,xS,CS,PS,RS,_S,AS,IS,TS,$S,jS,OS,HS,DS,Fa,LS,ZA,eI,tI,rI,iI,Hi=E(()=>{"use strict";L();ue();qe();Le();j();Ve();hi();QA={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},bS=1e3,kS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,SS=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),ES=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),xS=new Set(["schema","include","exclude","hash"]),CS=new Set(["provider","gitSelection","physicalSelection","projection"]),PS=new Set(["provider","selection"]),RS=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),_S=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),AS=new Set(["schema","status","before","after"]),IS=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),TS=new Set(["path","hash","size","type","gitObjectId"]),$S=new Set(["path","size","type","reason"]),jS=new Set(["ref","hash","count"]),OS=new Set(["change-created","legacy-migration","explicit"]),HS=new Set(["file","directory","other"]),DS=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),Fa=/^[a-f0-9]{64}$/u,LS=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,ZA=64*1024,eI=64*1024,tI={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},rI={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};iI=(1n<<256n)-1n});var vh=E(()=>{"use strict"});var I$,st=E(()=>{"use strict";vh();I$=8*1024*1024});var HE,Xa=E(()=>{"use strict";HE=ft(Ke(),1);Ee()});var Qa,hl=E(()=>{"use strict";Qa=class extends Error{issues;constructor(e){let r=[e.missingFields.length?`missing: ${e.missingFields.join(", ")}`:"",e.unknownFields.length?`unknown: ${e.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${e.context} fields are invalid at ${e.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[e]}}});var qi=E(()=>{"use strict"});var Za=E(()=>{"use strict";hl();qi()});var _r=E(()=>{"use strict";z();Za()});var Tt=E(()=>{"use strict";L();z();Xa();j();_r()});var ml=E(()=>{"use strict"});var Kt=E(()=>{"use strict"});var eo=E(()=>{"use strict";fa();ml();Kt()});var bh=E(()=>{"use strict";st();eo();z()});var vl=E(()=>{"use strict";st();L()});var Ph,$r=E(()=>{"use strict";z();Hi();Ph=1024*1024});var io=E(()=>{"use strict";z();Kt();hi();$r()});var _h,ux,dx,fx,j0,px,O0,gl=E(()=>{"use strict";z();_h="scoped-text-safety",ux=1,dx=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),fx="comet.native.checker-policy.v1",j0=W(fx,{policy:_h,version:ux,limits:dx,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),px=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],O0=new Set(px)});var no=E(()=>{"use strict";z();gl();Kt()});var vx,Q0,jr=E(()=>{"use strict";L();j();Le();$r();io();no();vx=Ph,Q0=3*vx});import{promises as Px}from"fs";import _ from"path";var bm=null;function km(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Xi(t,e){return(...r)=>{let i=bm;if(i===null)return e(...r);let n=km(`async:${t}`,r),a=i.entries.get(n);if(a)return a.value;let o=e(...r).catch(s=>{throw i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}import $l from"node:path";function po(t){return t.charCodeAt(0)===65279?t.slice(1):t}async function Tl(t=2e3){return process.stdin.isTTY?{text:""}:!Number.isFinite(t)||t<1?{text:null}:process.stdin.readableEnded?{text:""}:await new Promise(e=>{let r=!1,i=0,n=[],a=setTimeout(()=>o({text:null}),Math.ceil(t)),o=d=>{r||(r=!0,clearTimeout(a),process.stdin.removeListener("data",s),process.stdin.removeListener("end",c),process.stdin.removeListener("close",l),process.stdin.removeListener("error",u),process.stdin.pause(),e(d))},s=d=>{let f=Buffer.isBuffer(d)?d:Buffer.from(d),m=1048576-i;if(m<=0){o({text:null});return}let w=f.subarray(0,m);n.push(w),i+=w.length,f.length>w.length&&o({text:null})},c=()=>o({text:Buffer.concat(n,i).toString("utf8")}),l=()=>{process.stdin.readableEnded||o({text:null})},u=()=>o({text:null});process.stdin.on("data",s),process.stdin.once("end",c),process.stdin.once("close",l),process.stdin.once("error",u),a.unref(),process.stdin.resume()})}var Sm=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","searchreplace","strreplaceeditor","write","writefile","writefiletool"]),Em=new Set(["glob","grep","listfiles","read","readfile","search","view"]),jl=["file_path","filePath","path","target_file","targetFile"],Ol=["file_paths","filePaths","paths","files","targets"],Hl=["operations","edits"],xm=["patch","diff","patchText","patch_text","changes"];function vo(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function ho(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function Cm(t){for(let e of["tool_name","toolName","tool","name"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}return null}function Pm(t){for(let e of["cwd","working_directory","workspaceRoot"]){let r=t[e];if(!(typeof r!="string"||!r.trim()||!$l.isAbsolute(r.trim())))return $l.resolve(r.trim())}}function Rm(t){for(let e of["session_id","sessionId","conversation_id","conversationId"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim().slice(0,256)}}function _m(t){for(let e of["hook_event_name","hookEventName","event_name","eventName"]){let r=t[e];if(typeof r=="string"&&r.trim())return ho(r)}}function Am(t){for(let e of["task","prompt","user_prompt","userPrompt"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}}function Im(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function Tm(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return Im(t[e]);return t}function mo(t){let e=[],r=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let i of r)for(let n of t.matchAll(i)){let a=n[1]?.trim();a&&a!=="/dev/null"&&e.push(a)}return e}function $t(t,e){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(Array.isArray(e)){for(let r of e)$t(t,r);return}if(vo(e)){for(let r of jl)$t(t,e[r]);for(let r of Ol)$t(t,e[r]);for(let r of Hl)$t(t,e[r])}}function $m(t,e){let r=[],i=[e,t].filter(vo);for(let n of i){for(let a of jl)$t(r,n[a]);for(let a of Ol)$t(r,n[a]);for(let a of Hl)$t(r,n[a]);for(let a of xm){let o=n[a];typeof o=="string"&&r.push(...mo(o))}}return typeof e=="string"&&r.push(...mo(e)),[...new Set(r)]}function Or(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let r;try{r=JSON.parse(po(t))}catch{let s=mo(t);return s.length>0?{intent:"write",targets:[...new Set(s)],toolName:"apply_patch"}:{intent:"unknown",targets:[],toolName:null}}if(!vo(r))return{intent:"unknown",targets:[],toolName:null};let i=Cm(r),n=$m(r,Tm(r)),a=Pm(r),o=Rm(r);if(_m(r)==="beforeagentstart"){let s=Am(r);return{intent:"context",targets:[],toolName:null,...s?{task:s}:{},...a?{cwd:a}:{},...o?{sessionId:o}:{}}}return i&&Sm.has(ho(i))?{intent:n.length>0?"write":"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i&&Em.has(ho(i))?{intent:"non-write",targets:[],toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i?{intent:"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...a?{cwd:a}:{},...o?{sessionId:o}:{}}}async function Dl(t={}){let e=process.env.FILE_PATH;if(e?.trim()||process.stdin.isTTY)return Or("",e);let r=await(t.readStdin??Tl)();r.text===null&&(process.stderr.write(`[COMET-HOOK] stdin timeout: the host did not provide hook input within the expected window
153
- `),process.exit(1));try{return Or(r.text,e)}catch{return Or("",e)}}var ll=ft(Ke(),1);import{promises as yE}from"fs";import Er from"path";import{execFileSync as sN}from"child_process";import cN from"fs";import Xs from"path";function fi(t,e){return sN("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Qs(t,e){return Pf(t)===Pf(e)}function Pf(t){let e=Xs.resolve(t);try{let r=cN.realpathSync.native(e);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?e.toLowerCase():e}}function ke(t){try{let e=Xs.resolve(fi(t,["rev-parse","--show-toplevel"])),i=fi(t,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?Xs.resolve(i.slice(9)):e,a=null;try{a=fi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Qs(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function Rf(t){try{return fi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}function Ft(t,e){try{let r=fi(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}Ee();L();Mt();ue();Y();j();Ve();Hi();Y();j();fr();xt();var ZS=ft(Ke(),1);fr();xt();Pt();Pt();dr();gc();fr();Pt();var yI=4*1024*1024;import re from"path";dr();var eE=Xi("hookWritePolicy",async t=>(await pc(t))?.hook??{allow_paths:[]});function Xp(t,e){let r=re.relative(t,e);return r===""||!re.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${re.sep}`)}function tE(t,e){let r=re.isAbsolute(e)?re.resolve(e):re.resolve(t,e),i=re.relative(re.resolve(t),r);return i===""||re.isAbsolute(i)||i===".."||i.startsWith(`..${re.sep}`)?null:i.replaceAll("\\","/")}function Qp(t){return process.platform==="win32"?t.toLowerCase():t}async function Ma(t,e,r=[]){let i=re.isAbsolute(e)?re.resolve(e):re.resolve(t,e),n=re.resolve(t);if(!Xp(n,i)||r.some(c=>Xp(re.resolve(c),i)))return null;let a=tE(t,e);if(!a)return null;let s=(await eE(t)).allow_paths.find(c=>{let l=Qp(a),u=Qp(c);return l===u||l.startsWith(`${u}/`)});return s?`${a} (configured Hook allow path: ${s})`:null}Ni();import rE from"node:path";var Va="comet.selection.v2",eh=16*1024;function nl(t){return rE.join(t,".comet","current-change.json")}function iE(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Zp(t){return t===null||typeof t=="string"}function nE(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`current change selection contains invalid JSON: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!iE(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!Zp(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Va,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Va)throw new Error(`current change selection schema must be ${Va}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!Zp(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function al(t){let e;try{let i=nl(t),{bytes:n}=await qt(i,eh,{label:"current change selection"});e=n.toString("utf8")}catch(i){if(i.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${i instanceof Error?i.message:String(i)}`,{cause:i})}return{status:"selected",...nE(e)}}hc();mi();var ET=Number.MAX_SAFE_INTEGER;L();Le();var DT={runStateBytes:Number.MAX_SAFE_INTEGER,trajectoryBytes:Number.MAX_SAFE_INTEGER,trajectoryEvents:4096,trajectoryEventBytes:Number.MAX_SAFE_INTEGER,checkpointBytes:Number.MAX_SAFE_INTEGER,pendingActionBytes:Number.MAX_SAFE_INTEGER,contextBytes:Number.MAX_SAFE_INTEGER,artifactsBytes:Number.MAX_SAFE_INTEGER};import{createHash as lE}from"node:crypto";import{promises as qa}from"node:fs";import _t from"node:path";L();Ee();Y();j();var Di=/^[a-f0-9]{64}$/u,rh=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,uE=16*1024,sl=process.platform;function oh(t,e){let r=_t.relative(t,e);return _t.isAbsolute(r)||r===".."||r.startsWith(`..${_t.sep}`)?null:r.replaceAll("\\","/")||"."}function sh(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function ch(t,e){if(t.length===0||sh(t)||t.includes("\\")||_t.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let r=_t.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function cl(t,e){return lE("sha256").update(`${t}
154
- ${e}`).digest("hex")}async function ih(t,e){let r=await qa.realpath(e),i=await qa.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=sl==="win32"?_t.normalize(r).toLowerCase():r;return cl(t,`${n}
166
+ `)}function Jr(t){return GE("sha256").update(cr(t)).digest("hex")}function Kl(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new R(`${e} must be an object`);return t}function ym(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new R(`${r} has unknown field(s): ${i.join(", ")}`)}function Yl(t,e){if(typeof t!="string"||t.trim().length===0)throw new R(`${e} must be a non-empty string`);return t.trim()}function vm(t,e){if(t!==void 0){if(typeof t!="string")throw new R(`${e} must be text`);return cr(t).replace(/^\n+|\n+$/gu,"")}}function wo(t,e){let r=Yl(t,e).toLowerCase();if(!UE.test(r))throw new R(`${e} must be a SHA-256 hash`);return r}function gm(t,e,r){let i=Kl(t,e),n=Object.entries(i);if(n.length>mm)throw new R(`${e} must contain at most ${mm} entries`);let a={};for(let[o,s]of n){if(Jl(o,`${e} ID`)!==o)throw new R(`${e} ID must be normalized: ${o}`);s===null&&r?a[o]=null:a[o]=wo(s,`${e}.${o}`)}return a}function Jl(t,e){let r=Yl(t,e);if(!wm.test(r))throw new R(`${e} is not a valid stable requirement ID`);return r}function KE(t,e){let r=Yl(t,e);if(!JE.test(r))throw new R(`${e} is not a valid capability ID`);return r}function YE(t,e){let r=`Native delta operations[${e}]`,i=Kl(t,r);ym(i,new Set(["id","operation","to_id","title","body","expected_hash"]),r);let n=Jl(i.id,`${r}.id`),a=i.operation;if(!["add","modify","remove","rename"].includes(String(a)))throw new R(`${r}.operation is invalid`);let o=a,s=i.to_id===void 0?void 0:Jl(i.to_id,`${r}.to_id`),l=vm(i.title,`${r}.title`),c=vm(i.body,`${r}.body`),u=i.expected_hash===void 0?void 0:wo(i.expected_hash,`${r}.expected_hash`);if(o==="add"){if(s!==void 0||u!==void 0||!c?.trim())throw new R(`${r} add requires body and forbids to_id and expected_hash`)}else if(o==="modify"){if(s!==void 0||!u||!c?.trim())throw new R(`${r} modify requires body and expected_hash and forbids to_id`)}else if(o==="remove"){if(s!==void 0||l!==void 0||c!==void 0||!u)throw new R(`${r} remove requires expected_hash and forbids to_id, title, and body`)}else if(s===void 0||s===n||!u||c==="")throw new R(`${r} rename requires a different to_id and expected_hash`);return{id:n,operation:o,...s===void 0?{}:{to_id:s},...l===void 0?{}:{title:l},...c===void 0?{}:{body:c},...u===void 0?{}:{expected_hash:u}}}function XE(t){let e=Kl(t,"Native delta");if(ym(e,new Set(["schema","capability","base_hash","base_version","legacy_hash","base_requirements","independent_requirements","operations"]),"Native delta"),e.schema!==zl)throw new R(`Native delta schema must be ${zl}`);let r=KE(e.capability,"Native delta capability"),i=wo(e.base_hash,"Native delta base_hash");if(!Number.isSafeInteger(e.base_version)||Number(e.base_version)<1)throw new R("Native delta base_version must be a positive integer");let n=e.legacy_hash===void 0?void 0:wo(e.legacy_hash,"Native delta legacy_hash"),a;e.base_requirements!==void 0&&(a=gm(e.base_requirements,"Native delta base_requirements",!1));let o=e.independent_requirements===void 0?void 0:gm(e.independent_requirements,"Native delta independent_requirements",!0);if(!Array.isArray(e.operations))throw new R("Native delta operations must be an array");let s=e.operations.map(YE),l=new Set;for(let[c,u]of s.entries()){let d=[u.id,...u.to_id===void 0?[]:[u.to_id]];for(let f of d){if(l.has(f))throw new R(`Native delta operations contain duplicate or overlapping requirement ID ${f} at ${c}`);l.add(f)}}if(o!==void 0){if(a===void 0)throw new R("Native delta independent_requirements requires base_requirements");for(let[c,u]of Object.entries(o)){if(l.has(c))throw new R(`Native delta requirement ${c} cannot be both addressed and independent`);let d=a[c];if(u===null?d!==void 0:d!==u)throw new R(`Native delta independent_requirements does not match baseline ${c}`)}}return{schema:zl,capability:r,base_hash:i,base_version:Number(e.base_version),...n===void 0?{}:{legacy_hash:n},...a===void 0?{}:{base_requirements:a},...o===void 0?{}:{independent_requirements:o},operations:s}}function QE(t){let e=(0,Ul.parseDocument)(t,{uniqueKeys:!0});if(e.errors.length>0)throw new R(`Native delta is invalid YAML: ${e.errors[0].message}`);return e.toJS({mapAsMap:!1})}function pn(t){return XE(typeof t=="string"?QE(t):t)}function ZE(t){let e=/^\s{0,3}(#{1,6})\s+/u.exec(t);return e?e[1].length:null}function ex(t){let e=[],r=null;for(let[i,n]of t.entries()){let a=/^\s{0,3}(`{3,}|~{3,})(.*)$/u.exec(n.trimEnd());if(a){r?a[1][0]===r.marker&&a[1].length>=r.length&&a[2].trim().length===0&&(r=null):r={marker:a[1][0],length:a[1].length};continue}if(r)continue;let o=/^(\s{0,3})(#{2,6})\s+Requirement:\s*([^\s]+)(?:\s+(.*?))?\s*$/u.exec(n);if(!o)continue;let s=o[3];if(!wm.test(s))throw new R(`Native total Spec requirement ID is invalid: ${s}`);e.push({line:i,level:o[2].length,id:s,title:o[4]?.trim()??""})}return e}function sr(t){let e=cr(t),r=e.split(`
167
+ `),i=ex(r),n=[],a=new Set;for(let c of i){if(a.has(c.id))throw new R(`Native total Spec contains duplicate requirement ID ${c.id}`);a.add(c.id);let u=r.length;for(let d=c.line+1;d<r.length;d+=1){if(i.some(p=>p.line===d)){u=d;break}let f=ZE(r[d]);if(f!==null&&f<=c.level){u=d;break}}n.push({start:c.line,end:u,marker:c})}let o=new Map;for(let c of n){let u=`${r.slice(c.start,c.end).join(`
168
+ `)}${c.end<r.length?`
169
+ `:""}`,d=r.slice(c.start+1,c.end).join(`
170
+ `).replace(/^\n/u,"").replace(/\n+$/u,"");o.set(c.marker.id,{id:c.marker.id,level:c.marker.level,title:c.marker.title,body:d,raw:u,startLine:c.start,endLine:c.end})}let s=[],l=0;for(let c of n)s.push(r.slice(l,c.start).join(`
171
+ `)),l=c.end;return s.push(r.slice(l).join(`
172
+ `)),{text:e,lines:r,requirements:o,legacyText:s.join(`
173
+ `)}}function Xl(t){return Jr(t)}function lt(t){return Jr(t)}function Nm(t){let e=sr(t).legacyText;return Jr(e.split(`
174
+ `).filter(r=>r.trim().length>0).join(`
175
+ `).trim())}function bm(t,e){let r=sr(t),i=[];for(let n of e.operations){if(n.operation==="remove")continue;let a=n.operation==="rename"?n.to_id:n.id,o=r.requirements.get(a);if(!o)throw new R(`Native delta target Spec is missing requirement ${a} for ${n.operation}`);i.push(o.raw.trimEnd())}return i.length===0?"":`${i.join(`
176
+
177
+ `)}
178
+ `}function yo(t,e,r,i){let n=`${"#".repeat(t)} Requirement: ${e}${r?.trim()?` ${r.trim()}`:""}`,a=cr(i).replace(/\n+$/u,"");return[n,"",...a.split(`
179
+ `),"",""].join(`
180
+ `)}function Gl(t){return t.operation==="rename"?[t.id,t.to_id]:[t.id]}function No(t,e){if(t.operation==="rename"){if(!e)throw new R(`Rename target does not exist: ${t.id}`);return{id:t.to_id,level:e.level,title:t.title??e.title,body:t.body??e.body}}return{id:t.id,level:e?.level??2,title:t.title??e?.title,body:t.body??e?.body??""}}function tx(t,e,r){let i=sr(t),n=[...i.lines],a=i.requirements.get(e.id);if(!a)throw new R(`Requirement target disappeared: ${e.id}`);return n.splice(a.startLine,a.endLine-a.startLine,...r.split(`
181
+ `)),n.join(`
182
+ `)}function rx(t,e){let r=cr(t),i=r.length===0||r.endsWith(`
183
+
184
+ `)?"":`
185
+ `,n=`${r}${i}`;return`${n.endsWith(`
186
+ `)||n.length===0?n:`${n}
187
+ `}${e}`}function km(t,e){if(t.operation==="add"||t.operation==="modify"){let a=e.requirements.get(t.id);if(!a)return!1;let o=No(t,t.operation==="modify"?a:void 0);return a.raw===yo(o.level,o.id,o.title,o.body)}if(t.operation==="remove")return!1;let r=e.requirements.get(t.to_id),i=e.requirements.get(t.id);if(!r||i)return!1;let n=No(t,{id:t.id,level:r.level,title:r.title,body:r.body,raw:r.raw,startLine:r.startLine,endLine:r.endLine});return r.raw===yo(n.level,n.id,n.title,n.body)}function ix(t,e){let r=e.requirements.get(t.id);if(t.operation==="add"){if(r)throw new R(`Add target already exists: ${t.id}`);return}if(!r)throw new R(`Native delta target does not exist: ${t.id}`);if(t.expected_hash!==Xl(r.raw))throw new R(`Native delta ${t.operation} expected_hash does not match ${t.id}`);if(t.operation==="rename"&&e.requirements.has(t.to_id))throw new R(`Rename destination already exists: ${t.to_id}`)}function nx(t,e){if(t.base_requirements===void 0)return;let r=t.base_requirements,i=e.requirements;if(Object.keys(r).length!==i.size)throw new R("Native delta base_requirements must describe the complete total Spec baseline");for(let[n,a]of i)if(r[n]!==Xl(a.raw))throw new R(`Native delta base_requirements does not match requirement ${n}`)}function ax(t,e){let r=Nm(e.text);if(r!==Jr("")&&t.legacy_hash!==r)throw new R("Native delta modifying a legacy total Spec requires a matching legacy_hash")}function ox(t){let e=cr(t.baselineMarkdown),r=[],i=[];for(let a of t.delta.operations){let o=sr(e),s=o.requirements.get(a.id);if(t.allowAlreadyApplied&&km(a,o)){i.push({id:a.id,operation:a.operation,status:"already-applied",targetIds:Gl(a)});continue}if(a.operation==="add"){if(s)throw new or([a.id],`Native delta add conflicts with existing requirement ${a.id}`);let l=No(a,void 0);e=rx(e,yo(l.level,l.id,l.title,l.body))}else{if(!s)throw new or([a.id],`Native delta ${a.operation} target does not exist: ${a.id}`);if(a.expected_hash!==Xl(s.raw))throw new or([a.id],`Native delta ${a.operation} conflicts with concurrent requirement ${a.id}`);let l=No(a,s);if(a.operation==="rename"&&sr(e).requirements.has(a.to_id))throw new or([a.id,a.to_id],`Native delta rename destination already exists: ${a.to_id}`);if(a.operation==="remove"){let c=[...sr(e).lines];c.splice(s.startLine,s.endLine-s.startLine),e=c.join(`
188
+ `)}else e=tx(e,s,yo(l.level,l.id,l.title,l.body))}r.push(...Gl(a)),i.push({id:a.id,operation:a.operation,status:"changed",targetIds:Gl(a)})}let n=cr(e);return{markdown:n,base_hash:t.delta.base_hash,result_hash:Jr(n),rebased:t.rebased,changedRequirementIds:[...new Set(r)],operationResults:i}}function Sm(t){let e=sr(t.baselineMarkdown);if(Jr(e.text)!==t.delta.base_hash)throw new or([t.delta.capability],`Native delta base hash does not match the current total Spec for ${t.delta.capability}`);ax(t.delta,e),nx(t.delta,e);for(let r of t.delta.operations)t.allowAlreadyApplied&&km(r,e)||ix(r,e);return ox({baselineMarkdown:e.text,delta:t.delta,allowAlreadyApplied:t.allowAlreadyApplied??!1,rebased:!1})}var Ul,zl,Gr,JE,wm,UE,mm,R,or,bo=x(()=>{"use strict";Ul=kt(at(),1),zl="comet.native.delta.v1",Gr="delta.yaml",JE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,wm=/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u,UE=/^[a-f0-9]{64}$/iu,mm=512,R=class extends Error{code="native-delta-invalid";constructor(e){super(e),this.name="NativeDeltaValidationError"}},or=class extends Error{code="native-delta-conflict";conflictIds;constructor(e,r){super(r),this.name="NativeDeltaConflictError",this.conflictIds=[...new Set(e)]}}});var Ue,ut,dt,hn=x(()=>{"use strict";Ue="comet.native.v3",ut="comet.native.v2",dt="comet.native.v1"});import sx from"node:path";function vn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Pm(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Kr(t){if(!Cm.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Rm(t){if(!Cm.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function _m(t,e){if(t.length===0||sx.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function mx(t,e){let r=vn(t,`spec_changes[${e}]`);if(Pm(r,ux,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(Rm(r.capability),r.operation!=="create"&&r.operation!=="replace"&&r.operation!=="remove")throw new Error(`Invalid spec operation for ${r.capability}`);let i=r.source,n=r.base_hash;if(i!==void 0&&typeof i!="string")throw new Error(`Spec source for ${r.capability} must be a string`);if(typeof i=="string"&&_m(i,`Spec source for ${r.capability}`),r.operation==="create"){if(!i)throw new Error(`Create spec ${r.capability} requires source`);if(n!==null)throw new Error(`Create spec ${r.capability} requires null base_hash`)}else if(r.operation==="replace"){if(!i)throw new Error(`Replace spec ${r.capability} requires source`);if(typeof n!="string"||!Zl.test(n))throw new Error(`Replace spec ${r.capability} requires a SHA-256 base_hash`)}else{if(i!==void 0)throw new Error(`Remove spec ${r.capability} forbids source`);if(typeof n!="string"||!Zl.test(n))throw new Error(`Remove spec ${r.capability} requires a SHA-256 base_hash`)}return{capability:r.capability,operation:r.operation,...typeof i=="string"?{source:i}:{},base_hash:n}}function vx(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function eu(t,e){if(Pm(t,e,ht),typeof t.name!="string")throw new Error("Native change name is required");if(Kr(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!dx.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!fx.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let r=t.spec_changes.map(mx),i=r.map(n=>n.capability).filter((n,a,o)=>o.indexOf(n)!==a);if(i.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(i)].join(", ")}`);if(typeof t.verification_result!="string"||!px.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&_m(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!vx(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:r,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function gn(t){let e=vn(t,ht);if(e.schema!==dt)throw new Error(`Expected ${dt}`);return{schema:dt,...eu(e,cx)}}function mn(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Ql(t,e,r){if(t===null)return null;let i=typeof t=="string"?hx.exec(t):null;if(!i||i[1]!==r)throw new Error(`${e} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return t}function gx(t){if(t==null)return null;if(typeof t!="string"||!Zl.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function wx(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function wn(t){let e=vn(t,ht);if(e.schema!==ut)throw new Error(`Expected ${ut}`);if(mn(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${ut} minimum_runtime_version must be 2`);return{schema:ut,minimum_runtime_version:2,revision:mn(e.revision,"Native v2 revision"),...eu(e,xm)}}function Yr(t){let e=vn(t,ht);if(e.schema!==Ue){if(e.schema===dt||e.schema===ut){let o=e.schema===dt?gn(e):wn(e);throw new Ur(o.name,o.schema)}throw new pt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=mn(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new pt(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=mn(e.revision,"Native revision"),n=eu(e,lx),a=gx(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ue,minimum_runtime_version:3,revision:i,verification_protocol:wx(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:Ql(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Ql(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Ql(e.partial_allowance,"Native partial_allowance","allowances")}}function tu(t){let e=vn(t,ht);if(e.schema===dt){let n=gn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ue}`}}if(e.schema===ut){let n=wn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ue}`}}if(e.schema!==Ue){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new pt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=mn(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new pt(e.schema,r).message};let i=Yr(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var Em,cx,xm,lx,ux,dx,fx,px,ht,Zl,Cm,hx,Ur,pt,ko=x(()=>{"use strict";hn();Em=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],cx=new Set(Em),xm=new Set([...Em,"minimum_runtime_version","revision"]),lx=new Set([...xm,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),ux=new Set(["capability","operation","source","base_hash"]),dx=new Set(["shape","build","verify","archive"]),fx=new Set(["implicit","confirmed"]),px=new Set(["pending","pass","fail"]),ht="comet-state.yaml",Zl=/^[a-f0-9]{64}$/u,Cm=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,hx=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Ur=class extends Error{constructor(r,i){super(`Native change ${r} uses ${i}; run comet native doctor ${r} --repair before mutating it`);this.change=r;this.schema=i;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},pt=class extends Error{constructor(r,i){super(r!==Ue||i===null?`Unsupported Native change schema ${r} for runtime protocol ${3}`:`Native change ${r} requires runtime protocol ${i}; current protocol is ${3}`);this.schema=r;this.minimumRuntimeVersion=i;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"}});import{createHash as yx}from"crypto";function He(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function Nx(t,e){e.has(t)&&He("cyclic structures are not supported"),e.add(t);try{let r=Object.keys(t);for(let i=0;i<t.length;i+=1)Object.prototype.hasOwnProperty.call(t,i)||He("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&He("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&He("symbol properties are not supported"),`[${t.map(i=>ru(i,e)).join(",")}]`}finally{e.delete(t)}}function bx(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&He("only plain objects are supported"),e.has(t)&&He("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&He("symbol properties are not supported"),e.add(t);try{let i=Object.getOwnPropertyDescriptors(t);return`{${Object.keys(t).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&He("accessor properties are not supported"),`${JSON.stringify(o)}:${ru(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function ru(t,e){if(t===null)return"null";switch(typeof t){case"boolean":return t?"true":"false";case"string":return JSON.stringify(t);case"number":return Number.isFinite(t)||He("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?Nx(t,e):bx(t,e);case"bigint":case"function":case"symbol":case"undefined":return He(`${typeof t} values are not supported`)}return He("unsupported value type")}function iu(t){return ru(t,new Set)}function H(t,e){if(t.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(t))throw new TypeError("Canonical hash tag must not contain a line break");return yx("sha256").update(`${t}
189
+ ${iu(e)}`).digest("hex")}var U=x(()=>{"use strict"});function Tm(t){let e=/^ {0,3}(#{1,6})[ \t]+(.+?)[ \t]*$/u.exec(t);return e?{level:e[1].length,text:e[2].replace(/[ \t]+#+[ \t]*$/u,"").trim()}:null}function Am(t,e){let r=/^ {0,3}(`{3,}|~{3,})(.*)$/u.exec(t);if(!r)return e;let i=r[1][0];return e===null?{marker:i,length:r[1].length}:i===e.marker&&r[1].length>=e.length&&r[2].trim().length===0?null:e}function Im(t){return t.includes("-->")||t.includes("--!>")}function*So(t){let e=null,r=!1,i=null,n=new Set(["code","pre","script","style","svg","template"]),a=t.replace(/\r\n?/gu,`
190
+ `),o=0,s=0;for(;o<=a.length;){let l=a.indexOf(`
191
+ `,o),c=l===-1?a.slice(o):a.slice(o,l);if(yield{line:c,body:e===null&&!r&&i===null,index:s},s+=1,e!==null)e=Am(c,e);else if(r)Im(c)&&(r=!1);else if(i!==null)new RegExp(`</${i}\\s*>`,"iu").test(c)&&(i=null);else{let d=Am(c,null);if(d!==null)e=d;else{let f=c.trimStart();if(f.startsWith("<!--")&&!Im(f))r=!0;else{let p=/^<([A-Za-z][A-Za-z0-9-]*)\b[^>]*>/u.exec(f);p&&n.has(p[1].toLowerCase())&&!f.startsWith("</")&&!f.endsWith("/>")&&!new RegExp(`</${p[1]}\\s*>`,"iu").test(f)&&(i=p[1])}}}if(l===-1)break;o=l+1}}function yn(t){return t.normalize("NFC").replace(/\s+/gu," ").trim()}function $m(t,e,r,i=[],n="content-hash"){let a=yn(r),o=e.replaceAll("\\","/").trim(),s=i.map(yn);if(a.length===0)throw new Error(`${t} acceptance criterion must not be empty`);if(o.length===0)throw new Error(`${t} acceptance criterion source must not be empty`);return{id:n==="content-hash"?`acceptance-${H(kx,{kind:t,source:o,context:s,text:a})}`:"",kind:t,source:o,context:s,text:a}}function jm(t,e,r="content-hash"){let i=new Set;for(let n of t){let a=r==="content-hash"?n.id:JSON.stringify([n.kind,n.source,n.context,n.text]);if(i.has(a))throw new Error(`${e} contains duplicate acceptance criteria`);i.add(a)}return t}function Sx(t){let e=null,r=null,i=0,n=0;for(let{line:a,body:o,index:s}of So(t)){n=s+1;let l=o?Tm(a):null;l?.level===1&&(Ka(l.text)==="acceptanceExamples"?(i+=1,i===1&&(e=s+1)):e!==null&&r===null&&(r=s))}if(i===0||e===null)return null;if(i!==1)throw new Error("Brief must contain exactly one Acceptance examples section");return{start:e,end:r??n}}function nu(t,e="brief.md",r=Eo.maxCriteria,i="content-hash"){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native brief acceptance budget is invalid");let n=Sx(t);if(n===null)return[];let a=null;for(let{line:c,body:u,index:d}of So(t)){if(d<n.start||d>=n.end)continue;let f=u?/^( {0,3})[-*+][ \t]+/u.exec(c):null;if(f===null)continue;let p=f[1].length;a=a===null?p:Math.min(a,p)}let o=[],s=null,l=()=>{if(s!==null){if(o.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);o.push(s)}};for(let{line:c,body:u,index:d}of So(t)){if(d<n.start||d>=n.end)continue;let f=u?/^( {0,3})[-*+][ \t]+(.*)$/u.exec(c):null;f&&f[1].length===a?(l(),s=[f[2]]):s!==null&&s.push(c)}return l(),jm(o.map(c=>$m("brief-example",e,c.join(`
192
+ `),[],i)),"Brief",i)}function au(t,e="spec.md",r=Eo.maxCriteria,i="content-hash",n={}){if(!Number.isSafeInteger(r)||r<0)throw new Error("Native specification acceptance budget is invalid");let a=[],o=[],s=null,l=()=>{if(s===null)return;if(a.length>=r)throw new Error(`Native acceptance exceeds its ${r}-criterion acceptance budget`);let c=(n.resolveBriefReferences?s.body:[]).map(u=>/^\s*(?:Acceptance|验收)\s*[::]\s*(.*)$/iu.exec(u)?.[1]).filter(u=>u!==void 0);if(c.some(u=>!/^A[1-9]\d*$/u.test(u)))throw new Error("A Spec acceptance reference must be one brief ID such as A1");if(c.length>1)throw new Error("A Spec scenario may reference only one brief acceptance criterion");a.push({...$m("spec-scenario",e,[s.title,...s.body].join(`
193
+ `),s.context,i),...c[0]===void 0?{}:{briefAcceptanceRef:c[0]}}),s=null};for(let{line:c,body:u}of So(t)){let d=u?Tm(c):null,f=d?/^Scenario\s*:\s*(.*)$/iu.exec(d.text):null;if(f){for(l();o.at(-1)&&o.at(-1).level>=d.level;)o.pop();let p=yn(f[1]);if(p.length===0)throw new Error("Scenario title must not be empty");s={level:d.level,title:p,body:[],context:o.map(v=>v.text)}}else if(d){for(s!==null&&d.level<=s.level?l():s!==null&&s.body.push(c);o.at(-1)&&o.at(-1).level>=d.level;)o.pop();o.push(d)}else s!==null&&u&&s.body.push(c)}return l(),jm(a,"Specification",i)}var kx,zj,Eo,xo=x(()=>{"use strict";rr();U();kx="comet.native.acceptance.v1",zj=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),Eo=Object.freeze({maxCriteria:1024})});import Om from"node:path";function Hm(t,e){if(t.length===0||t!==t.trim()||t.includes("\\")||Om.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||Om.posix.normalize(t)!==t||t==="."||t.endsWith("/"))throw new Error(`${e} must be a normalized change-relative ref`);return t}function Ex(t,e){return t.localeCompare(e,"en")}function Dm(t){let e=Hm(t.briefSource??"brief.md","Native brief source"),r=[...t.specs??[]].sort((o,s)=>Ex(o.capability,s.capability));if(new Set(r.map(o=>o.capability)).size!==r.length)throw new Error("Native acceptance sources contain duplicate capabilities");let i=nu(t.briefMarkdown,e,Number.MAX_SAFE_INTEGER,"none").map(({source:o,text:s})=>({source:o,text:s})),n=i.length;for(let o of r){let s=Hm(o.source,`Native spec source for ${o.capability}`);for(let l of au(o.markdown,s,Number.MAX_SAFE_INTEGER,"none",{resolveBriefReferences:t.resolveBriefReferences===!0})){if(l.briefAcceptanceRef!==void 0){let c=Number(l.briefAcceptanceRef.slice(1))-1;if(!Number.isSafeInteger(c)||c<0||c>=n)throw new Error(`Native Spec references unknown brief acceptance ${l.briefAcceptanceRef}: ${s}`);continue}i.push({source:s,text:l.text})}}let a=new Set;for(let o of i){o.text=yn(o.text);let s=o.text;if(a.has(s))throw new Error(`Native acceptance contains a duplicate criterion: ${o.text}`);a.add(s)}if(i.length===0)throw new Error("Native change must define at least one acceptance criterion");return i.map((o,s)=>({id:`A${s+1}`,source:o.source,text:o.text}))}function Lm(t,e){return t.length===e.length&&t.every((r,i)=>r.source===e[i]?.source&&r.text===e[i]?.text)}var ou=x(()=>{"use strict";xo()});function su(t,e,r,i=""){let n=Object.keys(t),a=e.filter(s=>!Object.hasOwn(t,s)),o=n.filter(s=>!e.includes(s));if(a.length||o.length)throw new Nn({code:"invalid-fields",path:i,context:r,missingFields:a,unknownFields:o,expectedFields:[...e]})}var Nn,Co=x(()=>{"use strict";Nn=class extends Error{issues;constructor(e){let r=[e.missingFields.length?`missing: ${e.missingFields.join(", ")}`:"",e.unknownFields.length?`unknown: ${e.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${e.context} fields are invalid at ${e.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[e]}}});function cu(t,e){if(typeof t!="string"||!t.trim()||t.length>4e3||/^<[^>]+>$/u.test(t.trim()))throw new Error(`${e} must contain a concrete statement of at most 4000 characters`);return t.trim()}function lu(t){if(!Array.isArray(t))throw new Error("Native Builder acceptance_review must be an array");return t.map((e,r)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native Builder acceptance review entry must be an object");let i=e,n=`Native Builder acceptance_review[${r}]`;su(i,["id","status","evidence","note"],n,`/acceptance_review/${r}`);let a=i.status;if(!["implemented-with-evidence","implemented-no-evidence","not-implemented","known-fail"].includes(a))throw new Error(`${n}.status is invalid`);if(!Array.isArray(i.evidence))throw new Error(`${n}.evidence must be an array`);return{id:cu(i.id,`${n}.id`),status:a,evidence:i.evidence.map(o=>cu(o,`${n}.evidence`)),note:cu(i.note,`${n}.note`)}})}function uu(t,e){if(!e)throw new Xr(t.map(({id:l})=>l),[]);let r=new Set(t.map(({id:l})=>l)),i=e.map(({id:l})=>l),n=new Set(i);if(n.size!==i.length)throw new Error("Native Builder acceptance_review contains duplicate IDs");let a=i.filter(l=>!r.has(l));if(a.length)throw new Error(`Native Builder acceptance_review contains unknown IDs: ${a.join(", ")}`);let o=t.filter(({id:l})=>!n.has(l)).map(({id:l})=>l),s=e.filter(l=>l.status!=="implemented-with-evidence"||l.evidence.length===0).map(({id:l})=>l);if(o.length||s.length)throw new Xr(o,s)}var Xr,Po=x(()=>{"use strict";Co();Xr=class extends Error{constructor(r,i){super(`Native Builder handoff is incomplete${r.length?`; missing: ${r.join(", ")}`:""}${i.length?`; not ready: ${i.join(", ")}`:""}. Complete acceptance_review for every requirement and its evidence before Verify`);this.missingIds=r;this.incompleteIds=i}missingIds;incompleteIds}});var bn,kn,Ro=x(()=>{"use strict";bn="comet.native.v4",kn="comet.native.local-execution.v4"});import{promises as Cx}from"node:fs";function ie(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ne(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function K(t,e,r){if(typeof t!="string"||!r?.empty&&t.length===0)throw new Error(`${e} must be ${r?.empty?"a string":"a non-empty string"}`);return t}function fu(t,e){return t===null?null:K(t,e)}function pu(t,e){let r=K(t,e);if(!Ax.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Qr(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function F(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function Tx(t,e){return t===null?null:F(t,e,Number.MIN_SAFE_INTEGER)}function z(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Ke(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function $o(t,e){return Ke(t,e,(r,i)=>K(r,`${e}[${i}]`))}function lr(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Zr(t,e){let r=K(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function Io(t,e,r=!1){let i=K(t,e);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${e} must be a portable relative path`);return i}function Ee(t,e){let r=ie(t,e);return ne(r,new Set(["text","truncated"]),e),{text:K(r.text,`${e}.text`,{empty:!0}),truncated:Qr(r.truncated,`${e}.truncated`)}}function $x(t,e){let r=`Native spec_changes[${e}]`,i=ie(t,r);ne(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=K(i.capability,`${r}.capability`);if(!Rx.test(n))throw new Error(`${r}.capability is invalid`);let a=z(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:Io(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:Io(i.delta_source,`${r}.delta_source`),l=i.base_hash===void 0?void 0:i.base_hash===null?null:pu(i.base_hash,`${r}.base_hash`);if(a==="remove"&&o!==null)throw new Error(`${r} remove requires source null`);if(a!=="remove"&&o===null)throw new Error(`${r} ${a} requires a source`);if(s!==void 0&&a==="remove")throw new Error(`${r} remove cannot contain delta_source`);if(s!==void 0&&l==null)throw new Error(`${r} delta_source requires a non-null base_hash`);if(l!==void 0&&s===void 0&&a!=="remove")throw new Error(`${r} base_hash requires delta_source for non-remove specs`);return{capability:n,operation:a,source:o,...s===void 0?{}:{delta_source:s},...l===void 0?{}:{base_hash:l}}}function jx(t){let e="Native workspace",r=ie(t,e);ne(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=z(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=fu(r.change_branch,`${e}.change_branch`),a=fu(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:z(r.finish,["merge","push","pull-request","keep"],`${e}.finish`);if(i==="current"&&o!==null)throw new Error("Native current workspace cannot contain a finish action");if(i==="current"&&n===null!=(a===null))throw new Error("Native workspace branch bindings must both be present or both be null");if(i!=="current"&&(n===null||a===null))throw new Error("Native isolated workspace requires change_branch and target_branch");return{isolation:i,change_branch:n,target_branch:a,finish:o}}function Ox(t){let e="Native loop",r=ie(t,e);ne(r,new Set(["stage","goal_cycle","iteration","attempt","retry_epoch","failed_iteration_count","no_progress_count","stop_reason","execution_failure_count","previous_unresolved_ids","next_action"]),e);let i=$o(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);lr(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:z(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:z(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${e}.stage`),goal_cycle:F(r.goal_cycle,`${e}.goal_cycle`,1),iteration:F(r.iteration,`${e}.iteration`),attempt:F(r.attempt,`${e}.attempt`),retry_epoch:F(r.retry_epoch,`${e}.retry_epoch`),failed_iteration_count:F(r.failed_iteration_count,`${e}.failed_iteration_count`),no_progress_count:F(r.no_progress_count,`${e}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:F(r.execution_failure_count,`${e}.execution_failure_count`),previous_unresolved_ids:i,next_action:fu(r.next_action,`${e}.next_action`)}}function Hx(t,e){let r=`Native acceptance[${e}]`,i=ie(t,r);ne(i,new Set(["id","source","text","result","reason"]),r);let n=K(i.id,`${r}.id`);if(!_x.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:Io(i.source,`${r}.source`),text:K(i.text,`${r}.text`),result:z(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:Ee(i.reason,`${r}.reason`)}}function Dx(t,e){let r=`Native builder_handoff.checks[${e}]`,i=ie(t,r);return ne(i,new Set(["name","result","note"]),r),{name:Ee(i.name,`${r}.name`),result:z(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:Ee(i.note,`${r}.note`)}}function Lx(t){let e="Native builder_handoff",r=ie(t,e);ne(r,new Set(["candidate_id","identity_provider","builder_execution_ref","iteration","summary","addressed_acceptance_ids","acceptance_review","checks","checks_truncated","known_limits","known_limits_truncated","review","submitted_at"]),e);let i=$o(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);lr(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:ie(r.review,`${e}.review`);return n&&ne(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:K(r.candidate_id,`${e}.candidate_id`),identity_provider:K(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:K(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:F(r.iteration,`${e}.iteration`,1),summary:Ee(r.summary,`${e}.summary`),addressed_acceptance_ids:i,...r.acceptance_review===void 0?{}:{acceptance_review:lu(r.acceptance_review)},checks:Ke(r.checks,`${e}.checks`,Dx),checks_truncated:Qr(r.checks_truncated,`${e}.checks_truncated`),known_limits:Ke(r.known_limits,`${e}.known_limits`,(a,o)=>Ee(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Qr(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:z(n.status,["passed"],`${e}.review.status`),summary:Ee(n.summary,`${e}.review.summary`),reviewer_execution_ref:K(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:Zr(r.submitted_at,`${e}.submitted_at`)}}function Bx(t,e){let r=`Native blockers[${e}]`,i=ie(t,r);ne(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=$o(i.acceptance_ids,`${r}.acceptance_ids`);return lr(n,`${r}.acceptance_ids`),{owner:z(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:Ee(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:z(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function Mx(t,e){let r=`Native verification.checks[${e}]`,i=ie(t,r);return ne(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:K(i.id,`${r}.id`),name:Ee(i.name,`${r}.name`),argv_display:Ke(i.argv_display,`${r}.argv_display`,(n,a)=>Ee(n,`${r}.argv_display[${a}]`)),argv_truncated:Qr(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:Io(i.cwd_ref,`${r}.cwd_ref`,!0),status:z(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Tx(i.exit_code,`${r}.exit_code`),duration_ms:F(i.duration_ms,`${r}.duration_ms`)}}function Fx(t){let e="Native verification",r=ie(t,e);ne(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Ke(r.checks,`${e}.checks`,Mx);lr(i.map(a=>a.id),`${e}.checks IDs`);let n=K(r.identity_provider,`${e}.identity_provider`);return{candidate_id:K(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:K(r.verifier_execution_ref,`${e}.verifier_execution_ref`),iteration:F(r.iteration,`${e}.iteration`,1),attempt:F(r.attempt,`${e}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":z(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:z(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:Ee(r.summary,`${e}.summary`),risks:Ke(r.risks,`${e}.risks`,(a,o)=>Ee(a,`${e}.risks[${o}]`)),risks_truncated:Qr(r.risks_truncated,`${e}.risks_truncated`),completed_at:Zr(r.completed_at,`${e}.completed_at`)}}function Bm(t,e){let r=`Native history[${e}]`,i=ie(t,r);ne(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=$o(i.unresolved_ids,`${r}.unresolved_ids`);return lr(n,`${r}.unresolved_ids`),{goal_cycle:F(i.goal_cycle,`${r}.goal_cycle`,1),iteration:F(i.iteration,`${r}.iteration`),attempt:F(i.attempt,`${r}.attempt`),outcome:z(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:Ee(i.summary,`${r}.summary`),completed_at:Zr(i.completed_at,`${r}.completed_at`)}}function Vx(t){let e="Native history_overflow.outcome_counts",r=ie(t,e),i=["pass","fail","blocked","execution-error","recovery"];return ne(r,new Set(i),e),{pass:F(r.pass,`${e}.pass`),fail:F(r.fail,`${e}.fail`),blocked:F(r.blocked,`${e}.blocked`),"execution-error":F(r["execution-error"],`${e}.execution-error`),recovery:F(r.recovery,`${e}.recovery`)}}function qx(t){let e="Native history_overflow",r=ie(t,e);ne(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),e);let i=F(r.dropped_entries,`${e}.dropped_entries`),n=r.first_dropped_at===null?null:Zr(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:Zr(r.last_dropped_at,`${e}.last_dropped_at`);if(i===0&&(n!==null||a!==null))throw new Error("Native empty history overflow cannot contain dropped timestamps");if(i>0&&(n===null||a===null))throw new Error("Native non-empty history overflow requires dropped timestamps");let o=Vx(r.outcome_counts);if(Object.values(o).reduce((l,c)=>l+c,0)!==i)throw new Error("Native history overflow outcome count must equal dropped_entries");return{dropped_entries:i,first_dropped_at:n,last_dropped_at:a,outcome_counts:o}}function Wx(t){let e=new Set(t.acceptance.map(r=>r.id));for(let r of t.loop.previous_unresolved_ids)if(!e.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of t.builder_handoff?.addressed_acceptance_ids??[])if(!e.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);t.builder_handoff?.acceptance_review&&uu(t.acceptance,t.builder_handoff.acceptance_review);for(let r of t.blockers)for(let i of r.acceptance_ids)if(!e.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(t.builder_handoff){if(!(t.builder_handoff.iteration===t.loop.iteration||t.phase==="build"&&t.loop.stage==="repairing"&&t.builder_handoff.iteration===t.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(t.builder_handoff.review?.reviewer_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(t.verification){if(!t.builder_handoff)throw new Error("Native verification requires a builder handoff");if(t.verification.candidate_id!==t.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(t.verification.identity_provider!==t.builder_handoff.identity_provider)throw new Error("Native Builder and Verifier identity providers must match");if(["skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"].includes(t.verification.assurance)!==(t.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(t.verification.assurance==="semantic-verification-unavailable"&&t.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(t.verification.assurance==="user-confirmed-degraded"&&t.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(t.verification.verifier_execution_ref===t.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=t.verification.iteration===t.loop.iteration&&t.verification.attempt===t.loop.attempt,n=t.phase==="build"&&t.loop.stage==="repairing"&&t.verification.iteration===t.loop.iteration-1&&t.verification.iteration===t.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function zx(t){if(!{shape:new Set(["shape","await-user","blocked"]),build:new Set(["building","repairing","await-user","blocked"]),verify:new Set(["verify-ready","await-user","blocked"]),archive:new Set(["archive-ready","await-user","blocked","done"])}[t.phase].has(t.loop.stage))throw new Error(`Native loop stage ${t.loop.stage} is invalid for phase ${t.phase}`);let r=t.status==="await-user"?"await-user":t.status==="blocked"?"blocked":t.status==="done"?"done":null;if(r!==null&&t.loop.stage!==r)throw new Error(`Native status ${t.status} requires loop stage ${r}`);if(t.status==="active"&&["await-user","blocked","done"].includes(t.loop.stage))throw new Error(`Native active status cannot use loop stage ${t.loop.stage}`);if(t.archived!==(t.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(t.archived&&t.phase!=="archive")throw new Error("Native archived state must be in Archive");if(t.verification_result==="pass"){if(t.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(t.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(t.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(t.verification?.assurance==="semantic-verification-unavailable"&&(t.phase!=="verify"||t.status!=="await-user"||t.verification_result!=="blocked"||t.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(t.verification_report!==null&&t.verification===null)throw new Error("Native verification report requires persisted verification")}function De(t){let e=ie(t,"Native portable state");if(ne(e,Ix,"Native portable state"),e.schema!==bn)throw new Error(`Native portable state schema must be ${bn}`);let r=K(e.name,"Native state name");if(!Px.test(r))throw new Error("Native state name is invalid");if(e.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=Ke(e.spec_changes,"Native spec_changes",$x);lr(i.map(s=>s.capability),"Native spec change capabilities");let n=Ke(e.acceptance,"Native acceptance",Hx);lr(n.map(s=>s.id),"Native acceptance IDs");let a=Ke(e.history,"Native history",Bm);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:bn,name:r,language:z(e.language,["en","zh-CN"],"Native state language"),phase:z(e.phase,["shape","build","verify","archive"],"Native state phase"),status:z(e.status,["active","await-user","blocked","done"],"Native state status"),state_version:F(e.state_version,"Native state_version",1),brief:"brief.md",...e.document_constraints_version===void 0?{}:e.document_constraints_version===1||e.document_constraints_version===2||e.document_constraints_version===3?{document_constraints_version:e.document_constraints_version}:(()=>{throw new Error("Native document_constraints_version must be 1, 2, or 3")})(),...e.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:pu(e.shape_confirmation_hash,"Native Shape confirmation hash")},...e.children_contract_hash===void 0?{}:{children_contract_hash:pu(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:z(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:jx(e.workspace),loop:Ox(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:Lx(e.builder_handoff),blockers:Ke(e.blockers,"Native blockers",Bx),verification:e.verification===null?null:Fx(e.verification),history:a,history_overflow:qx(e.history_overflow),verification_result:z(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:z(e.verification_report,["verification.md"],"Native verification_report"),archived:Qr(e.archived,"Native archived"),created_at:Zr(e.created_at,"Native created_at")};return Wx(o),zx(o),o}function ei(t,e){let r=De(t),i=Bm(e,r.history.length),n=[...r.history,i],a={...r.history_overflow,outcome_counts:{...r.history_overflow.outcome_counts}};for(;n.length>50;){let o=n.shift();a.dropped_entries+=1,a.first_dropped_at??=o.completed_at,a.last_dropped_at=o.completed_at,a.outcome_counts[o.outcome]+=1}return De({...r,history:n,history_overflow:a})}function Gx(t,e){let r=(0,To.parseDocument)(t,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${e} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function Sn(t){let e=await Cx.readFile(t,"utf8");return De(Gx(e,"Native portable state"))}async function Mm(t,e,r={}){let i=De(e);await Ge(t,(0,To.stringify)(i),r)}async function Jx(t,e){let r=_o.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);_o.set(t,a),await r;try{return await e()}finally{i(),_o.get(t)===a&&_o.delete(t)}}async function Fm(t){return Jx(t.file,async()=>{let e=F(t.expectedStateVersion,"Native expected state version",1),r=De(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await Sn(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new Ao(e,i.state_version);return await Mm(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await Sn(t.file);if(n.state_version!==e)throw new Ao(e,n.state_version)}}),r})}var To,Px,Rx,_x,Ax,Ix,Ao,_o,Bt=x(()=>{"use strict";Po();To=kt(at(),1);V();Ro();Px=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Rx=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,_x=/^A[1-9][0-9]*$/u,Ax=/^[a-f0-9]{64}$/u,Ix=new Set(["schema","name","language","phase","status","state_version","brief","document_constraints_version","shape_confirmation_hash","children_contract_hash","coordination_mode","spec_changes","workspace","loop","acceptance","builder_handoff","blockers","verification","history","history_overflow","verification_result","verification_report","archived","created_at"]),Ao=class extends Error{constructor(r,i){super(`Native state version conflict: expected ${r}, got ${i}`);this.expectedStateVersion=r;this.actualStateVersion=i;this.name="NativePortableStateVersionConflictError"}expectedStateVersion;actualStateVersion;code="native-state-version-conflict"};_o=new Map});function Ux(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("Native portable text byte budget must be a non-negative safe integer")}function mt(t,e=16384){if(typeof t!="string")throw new Error("Native portable text must be a string");if(Ux(e),Buffer.byteLength(t,"utf8")<=e)return{text:t,truncated:!1};let r="",i=0;for(let n of t){let a=Buffer.byteLength(n,"utf8");if(i+a>e)break;r+=n,i+=a}return{text:r,truncated:!0}}var ur=x(()=>{"use strict"});function eC(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function tC(t,e){if(typeof t!="string")throw new Error(`${e} must be an ISO timestamp`);let r=new Date(t);if(Number.isNaN(r.valueOf())||r.toISOString()!==t)throw new Error(`${e} must be a canonical ISO timestamp`);return t}function qm(t){let e=eC(t,"Native portable migration transaction"),r=Object.keys(e).filter(i=>!Kx.has(i));if(r.length>0)throw new Error(`Native portable migration transaction has unknown field(s): ${r.join(", ")}`);if(e.schema!==Vm)throw new Error("Unsupported Native portable migration transaction schema");if(typeof e.id!="string"||!Xx.test(e.id))throw new Error("Native portable migration transaction id is invalid");if(typeof e.change!="string"||!Yx.test(e.change))throw new Error("Native portable migration transaction change is invalid");if(typeof e.fromSchema!="string"||!Zx.has(e.fromSchema))throw new Error("Native portable migration transaction fromSchema is invalid");if(typeof e.status!="string"||!Qx.has(e.status))throw new Error("Native portable migration transaction status is invalid");return{schema:Vm,id:e.id,change:e.change,fromSchema:e.fromSchema,status:e.status,createdAt:tC(e.createdAt,"Native portable migration transaction createdAt")}}var Vm,Kx,Yx,Xx,Qx,Zx,Wm=x(()=>{"use strict";ko();ou();Bt();ur();Ro();hn();Vm="comet.native.portable-migration.v1",Kx=new Set(["schema","id","change","fromSchema","status","createdAt"]),Yx=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Xx=/^[a-z0-9][a-z0-9-]{7,127}$/u,Qx=new Set(["prepared","yaml-committed","legacy-cleanup","committed"]),Zx=new Set([dt,ut,Ue])});import rC from"node:path";function Km(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Ym(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function hu(t,e){if(t!==void 0){if(t===null)return null;if(typeof t!="string"||!/^[a-f0-9]{64}$/iu.test(t))throw new Error(`${e} must be a SHA-256 hash or null`);return t.toLowerCase()}}function Gm(t,e){if(t!==void 0){if(t!==null&&typeof t!="string")throw new Error(`${e} must be text or null`);return t}}function uC(t,e){let r=`Native portable Archive spec_changes[${e}]`,i=Km(t,r);if(Ym(i,lC,r),typeof i.capability!="string"||!Um.test(i.capability))throw new Error(`${r}.capability is invalid`);if(!["create","modify","remove"].includes(String(i.operation)))throw new Error(`${r}.operation is invalid`);let n=i.operation,a=i.delta_source;if(a!==void 0&&(typeof a!="string"||a.length===0||a.includes("\\")||a.startsWith("/")||/^[A-Za-z]:/u.test(a)||a.split("/").some(f=>f==="."||f==="..")))throw new Error(`${r}.delta_source is invalid`);let o=hu(i.base_hash,`${r}.base_hash`),s=Gm(i.delta_content,`${r}.delta_content`),l=Gm(i.source_content,`${r}.source_content`),c=hu(i.expected_target_hash,`${r}.expected_target_hash`),u=hu(i.result_hash,`${r}.result_hash`),d=a!==void 0;if(d&&o==null)throw new Error(`${r}.delta_source requires a non-null base_hash`);if(d&&(s==null||l===void 0||l===null||u===void 0||u===null))throw new Error(`${r}.delta_source requires delta_content, source_content, and result_hash`);if(!d&&(s!==void 0||l!==void 0))throw new Error(`${r} delta transaction fields require delta_source`);if(d){let f=pn(s);if(f.capability!==i.capability)throw new Error(`${r}.delta_content capability does not match capability`);if(f.base_hash!==o)throw new Error(`${r}.delta_content base_hash does not match base_hash`);if(lt(i.content)!==u)throw new Error(`${r}.content does not match result_hash`);if(lt(l)!==u)throw new Error(`${r}.source_content does not match result_hash`)}if(n==="remove"){if(i.source!==null||i.content!==null||a!==void 0||s!==void 0||l!==void 0||u!==void 0)throw new Error(`${r} remove requires source and content null`);return{capability:i.capability,operation:n,source:null,content:null,...o===void 0?{}:{base_hash:o},...c===void 0?{}:{expected_target_hash:c}}}if(typeof i.source!="string"||i.source.length===0||i.source.includes("\\")||i.source.startsWith("/")||/^[A-Za-z]:/u.test(i.source)||i.source.split("/").some(f=>f==="."||f===".."))throw new Error(`${r}.${n} source is invalid`);if(typeof i.content!="string")throw new Error(`${r}.${n} content is invalid`);if(u!==void 0&&(u===null||lt(i.content)!==u))throw new Error(`${r}.content does not match result_hash`);return{capability:i.capability,operation:n,source:i.source,content:i.content,...a===void 0?{}:{delta_source:a},...o===void 0?{}:{base_hash:o},...s===void 0?{}:{delta_content:s},...l===void 0?{}:{source_content:l},...c===void 0?{}:{expected_target_hash:c},...u===void 0?{}:{result_hash:u}}}function dC(t){let e=Km(t,"Native portable Archive transaction");if(Ym(e,cC,"Native portable Archive transaction"),e.schema!==zm)throw new Error("Unsupported Native portable Archive transaction schema");if(typeof e.id!="string"||!aC.test(e.id))throw new Error("Native portable Archive transaction id is invalid");if(typeof e.change!="string"||!Um.test(e.change))throw new Error("Native portable Archive transaction change is invalid");if(!Number.isSafeInteger(e.start_state_version)||Number(e.start_state_version)<0)throw new Error("Native portable Archive transaction state version is invalid");if(typeof e.archive_ref!="string"||!oC.test(e.archive_ref)||!e.archive_ref.endsWith(`-${e.change}`))throw new Error("Native portable Archive transaction ref is invalid");if(typeof e.status!="string"||!sC.has(e.status))throw new Error("Native portable Archive transaction status is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native portable Archive transaction spec changes are invalid");let r=e.spec_changes.map(uC);if(new Set(r.map(({capability:n})=>n)).size!==r.length)throw new Error("Native portable Archive transaction capabilities must be unique");if(!Number.isSafeInteger(e.next_spec_index)||Number(e.next_spec_index)<0||Number(e.next_spec_index)>r.length)throw new Error("Native portable Archive transaction spec cursor is invalid");if(typeof e.created_at!="string")throw new Error("Native portable Archive transaction timestamp is invalid");let i=new Date(e.created_at);if(Number.isNaN(i.valueOf())||i.toISOString()!==e.created_at)throw new Error("Native portable Archive transaction timestamp is invalid");return{schema:zm,id:e.id,change:e.change,start_state_version:Number(e.start_state_version),archive_ref:e.archive_ref,status:e.status,next_spec_index:Number(e.next_spec_index),spec_changes:r,created_at:e.created_at}}function mu(t){let e=iC.exec(t);if(e)return{kind:"archive",change:e[1]};let r=nC.exec(t);return r?{kind:"migration",change:r[1]}:null}async function Xm(t,e){let r=mu(e);if(!r)return null;let i=await M({root:t.transactionsDir,ref:e,maxBytes:null,includeHash:!1}),n=JSON.parse(i.text),a=rC.join(t.transactionsDir,e);if(r.kind==="archive"){let s=dC(n);if(s.change!==r.change)throw new Error(`Native portable transaction filename does not match ${s.change}`);return{kind:"archive",change:r.change,file:a,journal:s}}let o=qm(n);if(o.change!==r.change)throw new Error(`Native portable transaction filename does not match ${o.change}`);return{kind:"migration",change:r.change,file:a,journal:o}}function Qm(t){return t.kind==="archive"||t.journal.status!=="committed"}var zm,Jm,iC,nC,aC,oC,sC,cC,lC,Um,vu=x(()=>{"use strict";Ie();bo();Wm();zm="comet.native.archive-transaction.v4",Jm="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",iC=new RegExp(`^portable-archive-(${Jm})\\.json$`,"u"),nC=new RegExp(`^portable-migration-(${Jm})\\.json$`,"u"),aC=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,oC=/^\d{4}-\d{2}-\d{2}-[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,sC=new Set(["prepared","specs-applied","state-finalized","report-aligned","moved"]),cC=new Set(["schema","id","change","start_state_version","archive_ref","status","next_spec_index","spec_changes","created_at"]),lC=new Set(["capability","operation","source","content","delta_source","base_hash","delta_content","source_content","expected_target_hash","result_hash"]),Um=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});import{createHash as fC}from"node:crypto";import{constants as jo,promises as Le}from"node:fs";import Be from"node:path";import{TextDecoder as pC}from"node:util";function Ho(t,e){let r=Be.relative(t,e);return r===""||!Be.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Be.sep}`)}function hC(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function mC(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function vC(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function Oo(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function gu(t,e){let r=await Le.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await Le.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function gC(t,e,r){let i=Be.resolve(t),n=Be.resolve(e);if(!Ho(i,n))throw new Error(`${r} is outside its managed root`);let a=[await gu(i,r)],o=i;for(let s of Be.relative(i,n).split(Be.sep).filter(Boolean)){await dr(a,r),o=Be.join(o,s);let l=await gu(o,r);if(!Ho(a[0].realPath,l.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(l)}return await dr(a,r),a}async function dr(t,e){for(let r of t){let i=await Le.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!mC(r,i)||await Le.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function wC(t,e,r){let i=[],n=0,a=Buffer.allocUnsafe(e===null?64*1024:Math.min(64*1024,e+1));for(;;){let o=e===null?a.length:e+1-n,{bytesRead:s}=await t.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,e!==null&&n>e)throw new Error(`${r} exceeds ${e} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function ti(t){let e=t.maxBytes===null?null:hC(t.maxBytes),r=Be.resolve(t.file),i=await gC(t.root,Be.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(u=>gu(Be.resolve(u),t.label)));await t.hooks?.afterParentChainCaptured?.(),await dr(i,t.label);let a=await Le.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(e!==null&&a.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let o=vC(a),s=await Le.realpath(r);if(!Ho(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(u=>Ho(u.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let l=process.platform==="win32"?jo.O_RDONLY:jo.O_RDONLY|jo.O_NOFOLLOW|jo.O_NONBLOCK,c=await Le.open(r,l);try{let u=await c.stat();await t.hooks?.afterOpen?.();let[d,f]=await Promise.all([Le.lstat(r),Le.realpath(r)]);if(await dr(i,t.label),await dr(n,t.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!Oo(o,u)||!Oo(o,d))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let p=await wC(c,e,t.label);await t.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([c.stat(),Le.lstat(r),Le.realpath(r)]);if(await dr(i,t.label),await dr(n,t.label),!h.isFile()||h.isSymbolicLink()||m!==s||!Oo(o,v)||!Oo(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:p,hash:fC("sha256").update(p).digest("hex"),size:p.length}}finally{await c.close()}}async function Zm(t){let e=await ti(t),r;try{r=new pC("utf-8",{fatal:!0}).decode(e.bytes)}catch(i){throw new Error(`${t.label} is not valid UTF-8`,{cause:i})}return{...e,text:r}}var Ye=x(()=>{"use strict";V();ze()});import vt from"path";import{TextDecoder as NC}from"util";function Lo(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Bo(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function iv(t){if(typeof t!="string")return!1;let e=new Date(t);return!Number.isNaN(e.valueOf())&&e.toISOString()===t}function wu(t,e){if(typeof t!="string"||t.length===0||vt.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native root`)}function Do(t,e){if(typeof t!="string"||!/^[a-f0-9]{64}$/u.test(t))throw new Error(`${e} must be a SHA-256 hash`)}function ev(t,e){if(wu(t,e),t.includes("\\")||t!==vt.posix.normalize(t)||t.split("/").includes(".")||t.endsWith("/")||Buffer.byteLength(t,"utf8")>1024)throw new Error(`${e} must be a normalized Native-relative ref`)}function CC(t,e){let r=Lo(t,`transaction operations[${e}]`);if(Bo(r,kC,`transaction operations[${e}]`),typeof r.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(r.id))throw new Error(`transaction operations[${e}].id is invalid`);if(r.type!=="write"&&r.type!=="remove"&&r.type!=="move")throw new Error(`transaction operation ${r.id} has an invalid type`);wu(r.target,`transaction operation ${r.id} target`);for(let i of["source","staged","backup"])r[i]!==void 0&&wu(r[i],`transaction operation ${r.id} ${i}`);if(r.type==="write"){if(r.staged===void 0||r.source!==void 0)throw new Error(`write operation ${r.id} requires staged and forbids source`)}else if(r.type==="remove"){if(r.source!==void 0||r.staged!==void 0)throw new Error(`remove operation ${r.id} forbids source and staged`)}else if(r.source===void 0||r.staged!==void 0||r.backup!==void 0)throw new Error(`move operation ${r.id} requires source and forbids staged and backup`);return r}function nv(t){let e=Lo(t,"Native Archive transaction journal");if(Bo(e,SC,"Native Archive transaction journal"),e.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native Archive transaction id is invalid");if(e.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof e.status!="string"||!rv.has(e.status))throw new Error("Native Archive transaction status is invalid");if(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change))throw new Error("Native Archive transaction change name is invalid");if(!iv(e.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Do(e.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(e.operations)||e.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let r=e.operations.map((s,l)=>{let c=Lo(s,`Archive transaction operations[${l}]`);if(Bo(c,EC,`Archive transaction operations[${l}]`),typeof c.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(c.id))throw new Error(`Archive transaction operations[${l}].id is invalid`);if(c.type!=="write"&&c.type!=="remove"&&c.type!=="move")throw new Error(`Archive transaction operation ${c.id} has an invalid type`);ev(c.target,`Archive transaction operation ${c.id} target`);for(let u of["source","staged","backup"])c[u]!==void 0&&ev(c[u],`Archive transaction operation ${c.id} ${u}`);if(c.expectedTargetHash!==null&&Do(c.expectedTargetHash,`Archive transaction operation ${c.id} expectedTargetHash`),c.type==="write"){if(c.staged===void 0||c.source!==void 0||c.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${c.id} requires staged and forbids source`);if(Do(c.stagedHash,`Archive write operation ${c.id} stagedHash`),c.expectedTargetHash===null!=(c.backup===void 0))throw new Error(`Archive write operation ${c.id} backup must match target existence`)}else if(c.type==="remove"){if(c.source!==void 0||c.staged!==void 0||c.stagedHash!==void 0||c.expectedSourceHash!==void 0||c.backup===void 0||c.expectedTargetHash===null)throw new Error(`Archive remove operation ${c.id} requires a bound target and backup`)}else{if(c.source===void 0||c.staged!==void 0||c.stagedHash!==void 0||c.backup!==void 0||c.expectedTargetHash!==null)throw new Error(`Archive move operation ${c.id} requires source and an absent target`);Do(c.expectedSourceHash,`Archive move operation ${c.id} expectedSourceHash`)}return c}),i=r.map(s=>s.id);if(new Set(i).size!==i.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${e.id}`,a=r.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${e.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${e.change}$`,"u").test(a[0].target)||r.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of r.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:e.id,kind:"archive",status:e.status,change:e.change,createdAt:e.createdAt,preflightHash:e.preflightHash,operations:r}}function PC(t){let e=Lo(t,"Native transaction journal");if(e.schema==="comet.native.transaction.v2")return nv(e);if(Bo(e,bC,"Native transaction journal"),e.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof e.id!="string"||!/^[a-f0-9-]{8,}$/u.test(e.id))throw new Error("Native transaction id is invalid");if(e.kind!=="archive"&&e.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof e.status!="string"||!rv.has(e.status))throw new Error("Native transaction status is invalid");if(typeof e.projectRoot!="string"||!vt.isAbsolute(e.projectRoot)||typeof e.nativeRoot!="string"||!vt.isAbsolute(e.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(e.change!==void 0&&(typeof e.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e.change)))throw new Error("Native transaction change name is invalid");if(!iv(e.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(e.operations))throw new Error("Native transaction operations must be an array");let r=e.operations.map(CC),i=r.map(n=>n.id);if(new Set(i).size!==i.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:e.id,kind:e.kind,status:e.status,projectRoot:e.projectRoot,nativeRoot:e.nativeRoot,...typeof e.change=="string"?{change:e.change}:{},createdAt:e.createdAt,operations:r}}function RC(t,e){if(!/^[a-f0-9-]{8,}$/u.test(e))throw new Error(`Invalid Native transaction id: ${e}`);return vt.join(t.transactionsDir,e)}function av(t,e){let r=RC(t,e);return{directory:r,journal:vt.join(r,"transaction.json"),events:vt.join(r,"events.jsonl"),staged:vt.join(r,"staged"),backups:vt.join(r,"backups")}}async function Nu(t,e){let r=av(t,e);return await Promise.all(Object.values(r).map(i=>j(t.runtimeDir,i))),r}async function bu(t,e,r={}){let i=await Nu(t,e),n=await ti({root:t.runtimeDir,file:i.journal,maxBytes:null,label:`Native transaction journal ${e}`,hooks:r.hooks}),a=JSON.parse(xC.decode(n.bytes)),o=PC(a);if(o.id!==e)throw new Error(`Invalid Native transaction journal: ${e}`);return o}var bC,kC,SC,EC,rv,xC,Mo=x(()=>{"use strict";V();L();Ye();bC=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),kC=new Set(["id","type","source","target","staged","backup"]),SC=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),EC=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]),rv=new Set(["prepared","applying","committed","rolling-back","rolled-back"]),xC=new NC("utf-8",{fatal:!0})});import{promises as _C}from"fs";import AC from"path";async function IC(t,e,r){let i;try{i=await _C.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return!1;throw n}for(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink()))try{let a=await bu(t,n.name);if(a.id!==e&&a.status!=="committed"&&a.status!=="rolled-back")return!0}catch{return!0}for(let n of i)if(mu(n.name))try{let a=await Xm(t,n.name);if(!a||r?.kind===a.kind&&r.change===a.change)continue;if(Qm(a))return!0}catch{return!0}return!1}async function TC(t,e){let r=Date.now()+5e3,i=AC.join(t.locksDir,"root-move.lock");for(;;)try{return await vo(t,"root-move",e)}catch(n){if(n.cause?.code!=="EEXIST")throw n;let o=await pm(i);if(o.status==="missing")continue;if(o.status==="stale"){let s=await hm(t,i,o);if(s.status==="removed"||s.status==="missing")continue;throw n}if(o.status!=="active"||Date.now()>=r)throw n;await new Promise(s=>setTimeout(s,5+Math.floor(Math.random()*11)))}}async function Y(t,e,r,i){let n=await TC(t,e);try{if(await so(t.projectRoot),await IC(t,i?.allowedTransactionId,i?.allowedPortableTransaction))throw new Error("Native transaction recovery is required before another mutation");return await r()}finally{try{await go(n)}catch(a){process.stderr.write(`[comet] warning: could not release Native mutation lock ${n.file} (${a.message}); run comet native doctor --repair if commands start failing
194
+ `)}}}var Z=x(()=>{"use strict";he();fn();vu();Mo()});import{createHash as $C}from"crypto";function ve(t){return $C("sha256").update(t).digest("hex")}var Xe=x(()=>{"use strict"});import Su from"path";function Fo(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}function ZC(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function eP(t,e){return ve(`comet.native.snapshot-policy.v1
195
+ ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function ku(t,e,r){let i=new Set(e),n=[...e];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=t[a];o&&(o.kind==="star"||o.kind==="globstar"||o.kind==="globstar-slash")&&!i.has(a+1)&&(i.add(a+1),n.push(a+1))}return i}function tP(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function ov(t){let e=oo(t,"Native snapshot pattern"),r=[];for(let i=0;i<e.length;i+=1){let n=e[i];n==="*"&&e[i+1]==="*"?(i+=1,e[i+1]==="/"?(i+=1,r.push({kind:"globstar-slash"})):r.push({kind:"globstar"})):n==="*"?r.push({kind:"star"}):n==="?"?r.push({kind:"question"}):r.push({kind:"literal",value:n})}return(i,n)=>{let a=n?tP(n):void 0;if(a&&!a())return!1;let o=ku(r,new Set([0]),a);if(o===null)return!1;for(let s of i){if(a&&!a())return!1;let l=new Set;for(let c of o){if(a&&!a())return!1;let u=r[c];u&&(u.kind==="literal"&&u.value===s||u.kind==="question"&&s!=="/"?l.add(c+1):u.kind==="star"&&s!=="/"||u.kind==="globstar"?l.add(c):u.kind==="globstar-slash"&&(l.add(c),s==="/"&&l.add(c+1)))}if(o=ku(r,l,a),o===null||o.size===0)return!1}return ku(r,o,a)?.has(r.length)??!1}}function rP(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>oo(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>oo(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let i=eP(e,r);if("hash"in t&&t.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:r,hash:i},includeMatchers:e.map(ov),excludeMatchers:r.map(ov),excludedDirectoryPrefixes:r.flatMap(n=>{if(!n.endsWith("/**"))return[];let a=n.slice(0,-3);return/[*?]/u.test(a)?[]:[a]}).sort((n,a)=>n.localeCompare(a,"en"))}}function xe(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Ce(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function ii(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Qe(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function lv(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let r=Su.posix.normalize(t);if(r!==t||Su.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function iP(t,e){let r=xe(t,`Native snapshot entry ${e}`);Ce(r,GC,`Native snapshot entry ${e}`);let i=lv(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!Vo.test(r.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:i,hash:r.hash,size:Qe(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!QC.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function nP(t,e){let r=xe(t,`Native snapshot omission ${e}`);if(Ce(r,JC,`Native snapshot omission ${e}`),!YC.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!XC.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:lv(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:Qe(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function aP(t){let e=xe(t,"Native snapshot omission overflow");if(Ce(e,UC,"Native snapshot omission overflow"),typeof e.hash!="string"||!Vo.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:e.hash,count:ii(e.count,"Native snapshot omission overflow count")}}function ri(t,e){let r=xe(t,e);if(Ce(r,qC,e),typeof r.hash!="string"||!Vo.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let i=Qe(r.recordCount,`${e} recordCount`),n=Qe(r.storedRecordCount,`${e} storedRecordCount`),a=Qe(r.stdoutBytes,`${e} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function sv(t){let e=xe(t,"Native Git selection evidence");if(Ce(e,VC,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=ri(e.stageBefore,"Native Git selection stageBefore"),i=ri(e.combined,"Native Git selection combined"),n=ri(e.stageAfter,"Native Git selection stageAfter"),a=ri(e.finalStageBefore,"Native Git selection finalStageBefore"),o=ri(e.finalCombined,"Native Git selection finalCombined"),s=ri(e.finalStageAfter,"Native Git selection finalStageAfter"),l=[r,i,n,a,o,s].some(d=>d.overflow),c=!Fo(r,n)||!Fo(n,a)||!Fo(i,o)||!Fo(a,s),u=l&&c?"overflow-and-changed":l?"overflow":"changed";if(!l&&!c)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==u)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:u,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function cv(t,e){let r=xe(t,e);if(Ce(r,zC,e),typeof r.hash!="string"||!Vo.test(r.hash))throw new Error(`${e} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${e} flags are invalid`);let i=Qe(r.visitedNodeCount,`${e} visitedNodeCount`),n=Qe(r.recordCount,`${e} recordCount`),a=Qe(r.storedRecordCount,`${e} storedRecordCount`),o=Qe(r.encodedBytes,`${e} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function oP(t){let e=xe(t,"Native physical selection evidence");if(Ce(e,WC,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=cv(e.before,"Native physical selection before"),i=cv(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!ZC(r,i);if(!n&&!a)throw new Error("Native physical selection evidence must describe an exceptional selection");let o=n&&a?"overflow-and-changed":n?"overflow":"changed";if(e.status!==o)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:o,before:r,after:i}}function uv(t){let e=xe(t,"Native content snapshot manifest");if(Ce(e,DC,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!KC.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let y=xe(e.capture,"Native content snapshot capture");if(Ce(y,MC,"Native content snapshot capture"),y.provider!=="git"&&y.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let A=y.gitSelection===void 0?void 0:sv(y.gitSelection),k=y.physicalSelection===void 0?void 0:oP(y.physicalSelection),D=null;if(y.projection!==void 0){let pe=xe(y.projection,"Native content snapshot projection");if(Ce(pe,FC,"Native content snapshot projection"),pe.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");D={provider:"git",...pe.selection===void 0?{}:{selection:sv(pe.selection)}}}if(y.provider==="git"){if(k||D)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",...A?{gitSelection:A}:{}}}else{if(A)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(k&&D)throw new Error("Native physical-tree capture cannot combine selection and projection");r=D?{provider:"physical-tree",projection:D}:{provider:"physical-tree",...k?{physicalSelection:k}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=xe(e.limits,"Native content snapshot limits");Ce(i,LC,"Native content snapshot limits");let n={maxFiles:ii(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:ii(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:ii(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:ii(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:ii(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let y=xe(e.policy,"Native snapshot policy");if(Ce(y,BC,"Native snapshot policy"),y.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(y.include)||!Array.isArray(y.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=rP({include:y.include,exclude:y.exclude,hash:y.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=e.entries.map(iP),s=e.omitted.map(nP),l=Qe(e.omittedCount,"Native content snapshot omittedCount"),c=e.omissionOverflow===void 0?void 0:aP(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(y=>y.size>n.maxFileBytes)||o.reduce((y,A)=>y+A.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(y=>y.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>OC||l<s.length)throw new Error("Native content snapshot omission count is invalid");let u=l-s.length;if(u===0&&c||u>0&&c?.count!==u)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(l===0))throw new Error("Native content snapshot completeness is inconsistent");let d=s.filter(y=>y.reason==="git-enumeration-limit"),f=s.filter(y=>y.reason==="git-selection-changed");for(let y of[...d,...f])if(y.path!=="."||y.size!==null||y.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(d.length>1||f.length>1)throw new Error("Native Git selection omissions must not be duplicated");let p=r?.provider==="git"?r.gitSelection:r?.projection?.selection,v=p?.status==="overflow"||p?.status==="overflow-and-changed",h=p?.status==="changed"||p?.status==="overflow-and-changed";if(v!==(d.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(f.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let m=s.filter(y=>y.reason==="physical-enumeration-limit"),w=s.filter(y=>y.reason==="physical-selection-changed");for(let y of[...m,...w])if(y.path!=="."||y.size!==null||y.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(m.length>1||w.length>1)throw new Error("Native physical selection omissions must not be duplicated");let g=r?.physicalSelection,b=g?.status==="overflow"||g?.status==="overflow-and-changed",E=g?.status==="changed"||g?.status==="overflow-and-changed";if(b!==(m.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(E!==(w.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");return{schema:"comet.native.content-snapshot.v1",origin:e.origin,...r?{capture:r}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:l,...c?{omissionOverflow:c}:{}}}function sP(t,e){if(!HC.test(e))throw new Error(`Invalid Native change name: ${e}`);return Su.join(Ne(t,e),"baseline-manifest.json")}async function dv(t,e){let r=sP(t,e),i=Oe(t,r);await j(i,r);try{let n=await Zm({root:i,file:r,maxBytes:null,label:"Native baseline snapshot manifest"});return uv(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var eO,OC,HC,DC,LC,BC,MC,FC,VC,qC,WC,zC,GC,JC,UC,KC,YC,XC,Vo,QC,tO,rO,iO,nO,aO,En=x(()=>{"use strict";Hr();V();he();Xe();ze();L();Ye();en();eO={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},OC=1e3,HC=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,DC=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),LC=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),BC=new Set(["schema","include","exclude","hash"]),MC=new Set(["provider","gitSelection","physicalSelection","projection"]),FC=new Set(["provider","selection"]),VC=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),qC=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),WC=new Set(["schema","status","before","after"]),zC=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),GC=new Set(["path","hash","size","type","gitObjectId"]),JC=new Set(["path","size","type","reason"]),UC=new Set(["ref","hash","count"]),KC=new Set(["change-created","legacy-migration","explicit"]),YC=new Set(["file","directory","other"]),XC=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),Vo=/^[a-f0-9]{64}$/u,QC=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,tO=64*1024,rO=64*1024,iO={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},nO={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};aO=(1n<<256n)-1n});var ID,et=x(()=>{"use strict";Hr();ID=8*1024*1024});import{promises as ZR}from"node:fs";import e_ from"node:path";function as(t,e,r=""){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object${r}`);return t}function ns(t,e,r){let i=Object.keys(t).filter(a=>!e.has(a)),n=[...e].filter(a=>!(a in t));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...e].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function tg(t,e){if(!Array.isArray(t)||!t.every(r=>typeof r=="string"))throw new Error(`${e} must be an array of strings`);return[...new Set(t)].sort((r,i)=>r.localeCompare(i,"en"))}function o_(t){let e=new Map(t.map(a=>[a.name,a])),r=new Set,i=new Set,n=a=>{if(!i.has(a)){if(r.has(a))throw new Error(`Native children dependency cycle includes ${a}`);r.add(a);for(let o of e.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of t)n(a.name)}function rg(t,e,r=e){let i=new Set(e);for(let o of t){let s=o.covers.filter(l=>!i.has(l));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(t.flatMap(o=>o.covers)),a=r.filter(o=>!n.has(o));if(a.length>0)throw new Error(`Native children do not cover parent acceptance: ${a.join(", ")}`)}function og(t,e,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(t.schema===Zu&&t.acceptance_index){let n=r.requiredAcceptanceIds??e??[],a=r.allowedAcceptanceIds??n,o=Object.keys(t.acceptance_index);i.missing=n.filter(c=>!(c in t.acceptance_index)),i.extra=o.filter(c=>!a.includes(c));let s=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of o){let u=s.get(c),d=t.acceptance_index[c];u&&d&&(d.source!==u.source||d.text!==u.text)&&i.mismatched.push(c)}let l=new Set(o);for(let c of t.children)i.unknownCovers.push(...c.covers.filter(u=>!l.has(u)));return i.uncovered=o.filter(c=>!ig(t.children,c)),ng(i)?i:null}if(t.schema===vr&&e){let n=new Set(e);for(let a of t.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=e.filter(a=>!ig(t.children,a)),ng(i)?i:null}return null}function ig(t,e){return t.some(r=>r.covers.includes(e))}function ng(t){return t.missing.length>0||t.extra.length>0||t.mismatched.length>0||t.uncovered.length>0||t.unknownCovers.length>0}function wr(t){let e=new Set(t.acceptance.map(({id:n})=>n)),r=new Set(t.acceptance.filter(({source:n})=>n===t.brief).map(({id:n})=>n)),i=new Set(r);for(let n of t.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)e.has(a)&&i.add(a);if(t.loop.stage==="repairing"&&t.verification_result==="fail"){let n=[...t.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:t.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function s_(t){let e=as(t,"Native children acceptance_index",' keyed by acceptance ID, for example A1: { source: brief.md, text: "Full acceptance text" }'),r={};for(let[i,n]of Object.entries(e)){let a=as(n,`Native children acceptance_index.${i}`);if(ns(a,new Set(["source","text"]),`Native children acceptance_index.${i}`),typeof a.source!="string"||a.source.length===0)throw new Error(`Native children acceptance_index.${i}.source must be a non-empty string`);if(typeof a.text!="string"||a.text.length===0)throw new Error(`Native children acceptance_index.${i}.text must be a non-empty string`);r[i]={source:a.source,text:a.text}}return r}function c_(t,e,r){let i=r.requiredAcceptanceIds??e??[],n=r.allowedAcceptanceIds??i,a=Object.keys(t),o=i.filter(c=>!(c in t)),s=a.filter(c=>!n.includes(c));if(o.length>0||s.length>0)throw new Error(`Native children acceptance_index must match the required acceptance: missing ${o.join(", ")||"none"}; extra ${s.join(", ")||"none"}`);let l=new Map((r.acceptanceCatalog??[]).map(c=>[c.id,c]));for(let c of a){let u=l.get(c);if(!u)continue;let d=t[c];if(d.source!==u.source||d.text!==u.text){let f=["source","text"].filter(p=>d[p]!==u[p]);throw new Error(`Native children acceptance_index.${c} does not match the acceptance catalog: copy ${f.join(", ")} exactly from the current acceptance catalog`)}}}function sg(t,e,r={}){let i=(0,ag.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=as(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==vr&&a!==gr)throw ns(n,eg,"Native children contract"),new Error(`Native children schema must be ${vr} or ${gr}`);let o=a===vr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(ns(n,o==="indexed-v2"?r_:eg,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let l=n.children.map((f,p)=>{let v=as(f,`Native child ${p}`);if(ns(v,o==="indexed-v2"?a_:o==="summary-v2"?n_:i_,`Native ${s} child fields (child ${p})`),typeof v.name!="string"||!t_.test(v.name))throw new Error(`Native child ${p} name is invalid`);let h=o==="summary-v2";if(h){if(typeof v.summary!="string"||v.summary.trim().length===0)throw new Error(`Native child ${v.name} summary must be a non-empty string`);if(v.summary.length>2e3)throw new Error(`Native child ${v.name} summary exceeds 2000 characters`)}return{name:v.name,summary:h?v.summary:null,depends_on:tg(v.depends_on,`Native child ${v.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?tg(v.covers,`Native child ${v.name} covers`):[]}}),c=l.map(({name:f})=>f);if(new Set(c).size!==c.length)throw new Error("Native child names must be unique");let u=new Set(c);for(let f of l){let p=f.depends_on.filter(v=>!u.has(v));if(p.length>0)throw new Error(`Native child ${f.name} depends on unknown child: ${p.join(", ")}`)}o_(l);let d=r.policy==="advisory";if(a===Zu){if(o==="indexed-v2"){let f=s_(n.acceptance_index);d||c_(f,e,r);let p=Object.keys(f);return d||rg(l,p,p),{schema:gr,acceptance_index:f,children:l}}return{schema:gr,children:l}}return e&&!d&&rg(l,e),{schema:vr,children:l}}async function yr(t){let e=e_.join(t.changeDir,Qu);try{await ZR.lstat(e)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await M({root:t.changeDir,ref:Qu}),i=t.policy==="advisory",n=i?{...t.validation,policy:"advisory"}:t.validation??{},a=sg(r.text,t.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?og(a,t.acceptanceIds,t.validation??{}):null}}var ag,Qu,vr,gr,Zu,t_,eg,r_,i_,n_,a_,os=x(()=>{"use strict";ag=kt(at(),1);Ie();Qu="children.yaml",vr="comet.native.children.v1",gr="comet.native.children.v2",Zu=gr,t_=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,eg=new Set(["schema","children"]),r_=new Set(["schema","acceptance_index","children"]),i_=new Set(["name","depends_on","covers"]),n_=new Set(["name","summary","depends_on"]),a_=new Set(["name","depends_on","covers"])});var Ln=x(()=>{"use strict"});var ss=x(()=>{"use strict";Co();Ln()});var di=x(()=>{"use strict";U();ss()});var Wt=x(()=>{"use strict";V();U();os();L();di()});var ed=x(()=>{"use strict"});var Nr=x(()=>{"use strict"});var cs=x(()=>{"use strict";Ki();ed();Nr()});var cg=x(()=>{"use strict";et();cs();U()});var td=x(()=>{"use strict";et();V()});var hg,hi=x(()=>{"use strict";U();En();hg=1024*1024});var ds=x(()=>{"use strict";U();Nr();en();hi()});var vg,j_,O_,H_,VB,D_,qB,id=x(()=>{"use strict";U();vg="scoped-text-safety",j_=1,O_=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),H_="comet.native.checker-policy.v1",VB=H(H_,{policy:vg,version:j_,limits:O_,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),D_=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],qB=new Set(D_)});var fs=x(()=>{"use strict";U();id();Nr()});var M_,oM,mi=x(()=>{"use strict";V();L();ze();hi();ds();fs();M_=hg,oM=3*M_});import{promises as nA}from"fs";import I from"path";import{AsyncLocalStorage as vw}from"node:async_hooks";var gw=new vw;function Sd(){let t=gw.getStore();return t?.active?t:null}function Ss(){Sd()?.entries.clear()}function ww(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Er(t,e){return(...r)=>{let i=Sd();if(i===null)return e(...r);let n=ww(`async:${t}`,r),a=i.entries.get(n);if(a)return a.value;let o=e(...r).catch(s=>{throw i.entries.get(n)?.value===o&&i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}import xd from"node:path";import{fileURLToPath as yw}from"node:url";function Es(t){return t.charCodeAt(0)===65279?t.slice(1):t}async function Ed(t=2e3){return process.stdin.isTTY?{text:""}:!Number.isFinite(t)||t<1?{text:null}:process.stdin.readableEnded?{text:""}:await new Promise(e=>{let r=!1,i=0,n=[],a=setTimeout(()=>o({text:null}),Math.ceil(t)),o=d=>{r||(r=!0,clearTimeout(a),process.stdin.removeListener("data",s),process.stdin.removeListener("end",l),process.stdin.removeListener("close",c),process.stdin.removeListener("error",u),process.stdin.pause(),e(d))},s=d=>{let f=Buffer.isBuffer(d)?d:Buffer.from(d),p=1048576-i;if(p<=0){o({text:null});return}let v=f.subarray(0,p);n.push(v),i+=v.length,f.length>v.length&&o({text:null})},l=()=>o({text:Buffer.concat(n,i).toString("utf8")}),c=()=>{process.stdin.readableEnded||o({text:null})},u=()=>o({text:null});process.stdin.on("data",s),process.stdin.once("end",l),process.stdin.once("close",c),process.stdin.once("error",u),a.unref(),process.stdin.resume()})}var Nw=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","searchreplace","strreplaceeditor","write","writefile","writefiletool"]),bw=new Set(["glob","grep","listfiles","read","readfile","search","view"]),Cd=["file_path","filePath","path","target_file","targetFile"],Pd=["file_paths","filePaths","paths","files","targets"],Rd=["operations","edits"],kw=["patch","diff","patchText","patch_text","changes"];function Ps(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function xs(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function Sw(t){for(let e of["tool_name","toolName","tool","name"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}return null}function Ew(t){for(let e of["cwd","working_directory","workspaceRoot"]){let r=t[e];if(!(typeof r!="string"||!r.trim()||!xd.isAbsolute(r.trim())))return xd.resolve(r.trim())}}function xw(t){for(let e of["session_id","sessionId","conversation_id","conversationId"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim().slice(0,256)}}function Cw(t){for(let e of["hook_event_name","hookEventName","event_name","eventName"]){let r=t[e];if(typeof r=="string"&&r.trim())return xs(r)}}function Pw(t){for(let e of["task","prompt","user_prompt","userPrompt"]){let r=t[e];if(typeof r=="string"&&r.trim())return r.trim()}}function Rw(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function _w(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return Rw(t[e]);return t}function Cs(t){let e=[],r=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let i of r)for(let n of t.matchAll(i)){let a=n[1]?.trim();a&&a!=="/dev/null"&&e.push(a)}return e}function gi(t){return[...new Set(t.flatMap(e=>{let r=e.trim();if(!r)return[];if(/^file:/iu.test(r))try{return[yw(r)]}catch{return[r]}return/^[A-Za-z]:/u.test(r)?[r]:/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(r)?[]:[r]}))]}function Gt(t,e){if(typeof e=="string"){let r=e.trim();r&&t.push(r);return}if(Array.isArray(e)){for(let r of e)Gt(t,r);return}if(Ps(e)){for(let r of Cd)Gt(t,e[r]);for(let r of Pd)Gt(t,e[r]);for(let r of Rd)Gt(t,e[r])}}function Aw(t,e){let r=[],i=[e,t].filter(Ps);for(let n of i){for(let a of Cd)Gt(r,n[a]);for(let a of Pd)Gt(r,n[a]);for(let a of Rd)Gt(r,n[a]);for(let a of kw){let o=n[a];typeof o=="string"&&r.push(...Cs(o))}}return typeof e=="string"&&r.push(...Cs(e)),gi(r)}function vi(t,e){if(e?.trim()){let s=gi([e]);return{intent:s.length>0?"write":"non-write",targets:s,toolName:null}}if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let r;try{r=JSON.parse(Es(t))}catch{let s=Cs(t);if(s.length>0){let l=gi(s);return{intent:l.length>0?"write":"non-write",targets:l,toolName:"apply_patch"}}return{intent:"unknown",targets:[],toolName:null}}if(!Ps(r))return{intent:"unknown",targets:[],toolName:null};let i=Sw(r),n=Aw(r,_w(r)),a=Ew(r),o=xw(r);if(Cw(r)==="beforeagentstart"){let s=Pw(r);return{intent:"context",targets:[],toolName:null,...s?{task:s}:{},...a?{cwd:a}:{},...o?{sessionId:o}:{}}}return i&&Nw.has(xs(i))?{intent:n.length>0?"write":"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i&&bw.has(xs(i))?{intent:"non-write",targets:[],toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:i?{intent:"unknown",targets:n,toolName:i,...a?{cwd:a}:{},...o?{sessionId:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...a?{cwd:a}:{},...o?{sessionId:o}:{}}}async function _d(t={}){let e=process.env.FILE_PATH;if(e?.trim()||process.stdin.isTTY)return vi("",e);let r=await(t.readStdin??Ed)();r.text===null&&(process.stderr.write(`[COMET-HOOK] stdin timeout: the host did not provide hook input within the expected window
196
+ `),process.exit(1));try{return vi(r.text,e)}catch{return vi("",e)}}var _u=kt(at(),1);import{promises as $P}from"fs";import ni from"path";Hr();za();import{execFileSync as vS}from"child_process";import gS from"fs";import Zt from"path";import{AsyncLocalStorage as kh}from"node:async_hooks";Ki();var Dr=new kh,wS=new kh;function Sh(t){return Dr.getStore()?t():Dr.run(new Map,t)}function yS(t){let e=Dr.getStore();for(let r of t)e?.set(Lr(r.root),t);return t}function Xi(t,e){return qa(()=>vS("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim())}function Qi(t,e){return Lr(t)===Lr(e)}function Lr(t){let e=Zt.resolve(t);try{let r=gS.realpathSync.native(e);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?e.toLowerCase():e}}function _e(t){try{let e=wS.getStore()?.get(Lr(t)),r=Dr.getStore()?.get(e??Lr(t));if(r){let l=bh(e??t,r);if(l)return l;if(r.length===0)return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}let i=Zt.resolve(Xi(t,["rev-parse","--show-toplevel"])),n=Dr.getStore()?.get(Lr(i))??NS(t),a=bh(i,n);if(Dr.getStore()&&a)return a;let o=n[0]?.root??i,s=null;try{s=Xi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Qi(i,o),currentWorktreeRoot:i,primaryWorktreeRoot:o,currentBranch:s}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function NS(t){let e=bS(Xi(t,["worktree","list","--porcelain","-z"]));return yS(e),e.map(r=>({...r}))}function bS(t){let e=t.split("\0"),r=[],i=null;for(let n of e)n.startsWith("worktree ")?(i&&r.push(i),i={root:Zt.resolve(n.slice(9)),branch:null,detached:!1}):i&&n.startsWith("branch refs/heads/")?i.branch=n.slice(18):i&&n==="detached"&&(i.detached=!0);return i&&r.push(i),r}function bh(t,e){let r=e.find(a=>Qi(Zt.resolve(a.root),Zt.resolve(t)));if(!r)return null;let i=Zt.resolve(e[0].root),n=Zt.resolve(r.root);return{isGitWorktree:!0,isSecondaryWorktree:!Qi(i,n),currentWorktreeRoot:n,primaryWorktreeRoot:i,currentBranch:r.branch}}function Eh(t){try{return Xi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{return null}}function er(t,e){try{let r=Xi(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}Ie();V();rr();he();Z();L();Ye();En();Z();L();qr();Ht();var pP=kt(at(),1);qr();Ht();st();st();Vr();Il();qr();st();var bO=4*1024*1024;import ae from"path";Vr();var hP=Er("hookWritePolicy",async t=>(await Pl(t))?.hook??{allow_paths:[]});function fv(t,e){let r=ae.relative(t,e);return r===""||!ae.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${ae.sep}`)}function mP(t,e){let r=ae.isAbsolute(e)?ae.resolve(e):ae.resolve(t,e),i=ae.relative(ae.resolve(t),r);return i===""||ae.isAbsolute(i)||i===".."||i.startsWith(`..${ae.sep}`)?null:i.replaceAll("\\","/")}function pv(t){return process.platform==="win32"?t.toLowerCase():t}async function qo(t,e,r=[]){let i=ae.isAbsolute(e)?ae.resolve(e):ae.resolve(t,e),n=ae.resolve(t);if(!fv(n,i)||r.some(l=>fv(ae.resolve(l),i)))return null;let a=mP(t,e);if(!a)return null;let s=(await hP(t)).allow_paths.find(l=>{let c=pv(a),u=pv(l);return c===u||c.startsWith(`${u}/`)});return s?`${a} (configured Hook allow path: ${s})`:null}sn();import vP from"node:path";var Wo="comet.selection.v2",mv=16*1024;function Eu(t){return vP.join(t,".comet","current-change.json")}function gP(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function hv(t){return t===null||typeof t=="string"}function wP(t){let e;try{e=JSON.parse(t)}catch(r){throw new Error(`current change selection contains invalid JSON: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!gP(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!hv(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Wo,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Wo)throw new Error(`current change selection schema must be ${Wo}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!hv(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function xu(t){let e;try{let i=Eu(t),{bytes:n}=await nr(i,mv,{label:"current change selection"});e=n.toString("utf8")}catch(i){if(i.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${i instanceof Error?i.message:String(i)}`,{cause:i})}return{status:"selected",...wP(e)}}Rl();tn();var CH=Number.MAX_SAFE_INTEGER;V();ze();var BH={runStateBytes:Number.MAX_SAFE_INTEGER,trajectoryBytes:Number.MAX_SAFE_INTEGER,trajectoryEvents:4096,trajectoryEventBytes:Number.MAX_SAFE_INTEGER,checkpointBytes:Number.MAX_SAFE_INTEGER,pendingActionBytes:Number.MAX_SAFE_INTEGER,contextBytes:Number.MAX_SAFE_INTEGER,artifactsBytes:Number.MAX_SAFE_INTEGER};import{createHash as SP}from"node:crypto";import{promises as zo}from"node:fs";import Mt from"node:path";V();Ie();Z();L();var xn=/^[a-f0-9]{64}$/u,gv=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,EP=16*1024,Pu=process.platform;function bv(t,e){let r=Mt.relative(t,e);return Mt.isAbsolute(r)||r===".."||r.startsWith(`..${Mt.sep}`)?null:r.replaceAll("\\","/")||"."}function kv(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function Sv(t,e){if(t.length===0||kv(t)||t.includes("\\")||Mt.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let r=Mt.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function Ru(t,e){return SP("sha256").update(`${t}
197
+ ${e}`).digest("hex")}async function wv(t,e){let r=await zo.realpath(e),i=await zo.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Pu==="win32"?Mt.normalize(r).toLowerCase():r;return Ru(t,`${n}
155
198
  ${i.dev}
156
199
  ${i.ino}
157
- ${i.birthtimeMs}`)}async function nh(t,e){let r=await qa.realpath(e),i=await qa.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=sl==="win32"?_t.normalize(r).toLowerCase():r;return cl(t,n)}function dE(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function ol(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||sh(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function lh(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(ol(t.changeBranch,"Native workspace change branch"),ol(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function fE(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(e).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!rh.test(e.baseCommit)||typeof e.targetCommit!="string"||!rh.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");ol(e.targetBranch,"Native workspace Git target branch")}function Wa(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(e).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!Di.test(String(e.projectRootId))||!Di.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");dE(e.capturedAt),ch(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,a=e.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Di.test(String(e.projectRootPathId))||a&&!Di.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Di.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&fE(e.git),e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(lh(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function pE(t,e){return _t.join(he(t,e),"workspace.json")}function hE(t,e){let r=pE(t,e),i=Re(t,r),n=oh(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:ch(n,"Native workspace file ref")}}async function mE(t,e){try{let r=hE(t,e),i=await ce({root:r.root,ref:r.ref,maxBytes:uE});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function vE(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=oh(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=ke(t.paths.projectRoot),i=r.isGitWorktree?Ft(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:Ft(t.paths.projectRoot,n),o=i!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:i,targetBranch:n,targetCommit:a}:void 0,[s,c,l,u]=await Promise.all([ih("comet.native.workspace-project-root.v2",t.paths.projectRoot),ih("comet.native.workspace-native-root.v2",t.paths.nativeRoot),nh("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),nh("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),d=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&lh(t.binding);let f={capturedAt:d,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:u,...o?{git:o}:{},...t.sessionId?{sessionHash:cl("comet.native.workspace-session.v2",`${s}
158
- ${c}
159
- ${t.sessionId}`)}:{}},m=t.binding?{schema:"comet.native.workspace.v3",...f,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...f};return Wa(m),m}async function za(t,e){let r=await mE(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(Wa(r),r)}async function uh(t){Wa(t.identity);let e=await vE({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),sl==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function dh(t){if(Wa(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await uh(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=ke(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function fh(t,e){let r=await za(t,e);if(r===null)return null;let i=await dh({paths:t,identity:r});if(i.state==="drifted")throw new Error(`${i.code}: ${i.message}`);return r}Ri();Ea();Ea();var Ga=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Li=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},Ja=class extends Error{constructor(r,i,n,a,o,s=null,c=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},E$=ea("en");function ze(t,e){vr(e);let r=Er.join(t.changesDir,e);if(!K(t.changesDir,r))throw new Error("Native change path escaped");return r}async function ul(t,e){let r=he(t,e),i=Er.join(r,"schema-migration.json");await T(K(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await yE.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function NE(t,e=Er.dirname(t)){let r=Er.relative(e,t).split(Er.sep).join("/"),i=await ce({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,ll.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function bE(t,e){let r=Er.join(ze(t,e),nt);await T(t.nativeRoot,r);let i=Mc(await NE(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await ul(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await kE(t,i.state),i)}async function kE(t,e){if(await Yp(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function ye(t,e){let r=await bE(t,e);if(r.status==="migration-required")throw new mr(e,r.schema);if(r.status==="runtime-incompatible"||!r.state)throw new it(r.schema,r.minimumRuntimeVersion);return await fh(t,e),r.state}ue();j();var SE=new Set([".md",".markdown"]),EE=new Set([".md",".markdown",".rst",".txt"]),xE=new Set(["docs","doc","documentation",".github"]),CE=[/^LICENSE(?:[.-]|$)/u,/^NOTICE$/u,/^AUTHORS$/u];function hh(t){return t.replaceAll("\\","/").replace(/^\.\//u,"")}function PE(t,e){for(let r of e){let i=hh(r).replace(/\/+$/u,"");if(i&&(t===i||t.startsWith(`${i}/`)))return!0}return!1}function mh(t,e=[]){let r=hh(t);if(!r||r.endsWith("/")||PE(r,e))return!1;let i=r.split("/"),n=i[i.length-1],a=n.lastIndexOf("."),o=a===-1?"":n.slice(a).toLowerCase();return i.length===1?SE.has(o)||CE.some(s=>s.test(n)):xE.has(i[0])&&EE.has(o)}ue();Y();import{promises as wh}from"node:fs";import Ya from"node:path";st();L();Ca();import{promises as gh}from"node:fs";import RE from"node:os";import Mi from"node:path";function Bi(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Fi(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function ie(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function xr(t,e){return t===null?null:ie(t,e)}function Cr(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function _E(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function AE(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Pr(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function dl(t,e){if(t===null)return null;let r=ie(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function IE(t,e){let r=ie(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function fl(t,e){let r=ie(t,e);if(!Mi.isAbsolute(r))throw new Error(`${e} must be absolute`);return Mi.resolve(r)}function TE(t,e){let r=`Native local checks[${e}]`,i=Bi(t,r);if(Fi(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log","activeProcess","evidence","evidenceDigest"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((u,d)=>ie(u,`${r}.argv[${d}]`,!0)),a=Pr(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=dl(i.startedAt,`${r}.startedAt`),s=dl(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let c=Cr(i.timeoutMs,`${r}.timeoutMs`);if(c<1)throw new Error(`${r}.timeoutMs must be positive`);let l;if(Object.hasOwn(i,"activeProcess"))if(i.activeProcess===null)l=null;else{let u=Bi(i.activeProcess,`${r}.activeProcess`),d=Pr(u.status,["starting","running"],`${r}.activeProcess.status`);if(Fi(u,new Set(["status","pid","identity"]),`${r}.activeProcess`),d==="starting"){if(Object.hasOwn(u,"pid")||Object.hasOwn(u,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);l={status:"starting"}}else l={status:"running",pid:Cr(u.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(u,"identity")?{identity:ie(u.identity,`${r}.activeProcess.identity`)}:{}}}return{id:ie(i.id,`${r}.id`),name:ie(i.name,`${r}.name`),operationId:ie(i.operationId,`${r}.operationId`),status:a,repeatable:AE(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Cr(i.executionCount,`${r}.executionCount`),argv:n,cwd:fl(i.cwd,`${r}.cwd`),exitCode:_E(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:ie(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:l}:{},...Object.hasOwn(i,"evidence")?{evidence:Pr(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:ie(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function pl(t){let e="Native local execution state",r=Bi(t,e);if(Fi(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),e),r.schema!==ji)throw new Error(`Native local execution schema must be ${ji}`);let i=Bi(r.workspace,"Native local workspace");Fi(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=Bi(r.execution,"Native local execution");Fi(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=dl(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:ie(o.operationId,"Native local execution.operationId"),stage:Pr(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Pr(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:xr(o.executionId,"Native local execution.executionId"),status:Pr(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Cr(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:IE(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:Cr(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:ie(o.ownerIdentity,"Native local execution.ownerIdentity")}:{}}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(TE);if(new Set(a.map(o=>o.id)).size!==a.length)throw new Error("Native local check IDs must be unique");if(n&&a.some(o=>o.operationId!==n.operationId))throw new Error("Native local checks must belong to the current operation");return{schema:ji,change:ie(r.change,"Native local change"),basedOnStateVersion:Cr(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:xr(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:xr(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:xr(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:xr(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:fl(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:fl(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:xr(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:ie(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}function ct(t){return pl({schema:ji,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,candidateId:t.portableState.builder_handoff?.candidate_id??null,inputFingerprint:null,inputFingerprintGate:null,candidateInputFingerprintGate:null,workspace:{projectRoot:Mi.resolve(t.projectRoot),worktreeRoot:Mi.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null,machineId:RE.hostname()},execution:null,checks:[]})}async function Ka(t){let e;try{e=await gh.readFile(t,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}let r;try{r=JSON.parse(e)}catch(i){throw new Error(`Native local execution state is invalid JSON: ${i.message}`,{cause:i})}return pl(r)}async function At(t,e,r={}){let i=pl(e);await gh.mkdir(Mi.dirname(t),{recursive:!0}),await le(t,i,r)}Rt();j();var Rr=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,yh="comet-state.yaml",Nh="state.json";function je(t,e){if(!Rr.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=Ya.join(t.changesDir,e);if(!K(t.changesDir,r))throw new Error("Native change path escaped");return r}function Vi(t,e){return Ya.join(je(t,e),yh)}function Ge(t,e){return Ya.join(Ze(t,e),Nh)}async function Ut(t,e){try{let r=await wh.readFile(Vi(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function lt(t){return Rf(t)}async function ne(t,e){return Oi(Vi(t,e))}async function It(t){let e=await Cp({file:Vi(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let r=Ya.join(je(t.paths,e.name),"verification.md");await T(t.paths.nativeRoot,r),await wh.rm(r,{force:!0})}return e}L();Mt();Ee();qe();j();var OE=["outcome","scope","nonGoals","acceptanceExamples"],Z$=[...OE,"constraints","decisions","openQuestions","verificationExpectations"];Ee();z();var nx=ft(Ke(),1);st();Ee();z();ue();j();Rt();Xa();Xa();_r();Tt();st();ma();L();z();eo();Y();j();bh();_r();Tt();vl();st();ue();vl();xi();j();var to=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};st();ue();Y();_r();Tt();Rt();Gt();qi();Za();function Ch(t){return t.state_version+1}function ox(t){return t.map(e=>({...e,result:"pending",reason:null}))}function sx(t){return{goal_cycle:t.state.loop.goal_cycle,iteration:t.state.loop.iteration,attempt:t.state.loop.attempt,outcome:t.outcome,unresolved_ids:t.unresolvedIds??[],summary:at(t.summary),completed_at:t.completedAt}}function ro(t){let e=Ie(t.state);if(e.phase!=="verify"&&e.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=t.failureBudget,i=r?e.loop.failed_iteration_count+1:e.loop.failed_iteration_count,n=r!==void 0&&i>=r.maxVerifyFailures,a=(t.now??new Date).toISOString(),o=Nr(e,sx({state:e,outcome:"recovery",summary:t.reason,completedAt:a})),s=new Set(e.loop.previous_unresolved_ids),c=s.size===0?ox(e.acceptance):e.acceptance.map(l=>s.has(l.id)?{...l,result:"pending",reason:null}:l);return n?Ie({...o,phase:"verify",status:"await-user",state_version:Ch(e),verification_result:"fail",builder_handoff:e.builder_handoff,blockers:[{owner:"user",reason:at(`Native Runtime checks failed at Builder handoff and reached the configured failed iteration limit: ${t.reason}`),acceptance_ids:[...s],resolution_action:"await-user"}],loop:{...e.loop,stage:"await-user",failed_iteration_count:i,execution_failure_count:0,stop_reason:"budget",next_action:"resolve-loop-stop"}}):Ie({...o,phase:"build",status:"active",state_version:Ch(e),verification_result:"pending",verification_report:null,verification:null,builder_handoff:e.builder_handoff,blockers:[],acceptance:c,loop:{...e.loop,stage:"repairing",iteration:e.loop.iteration+1,attempt:0,execution_failure_count:0,failed_iteration_count:i,stop_reason:void 0,next_action:"submit-builder-candidate"}})}Y();Wc();Sa();Rt();Gt();L();Mt();qi();j();Mt();jr();ue();var Ah=ft(Ke(),1);Pt();var eH=new Set("a an and are as at be by for from in is it of on or that the this to with you your".split(" "));var oH=256*1024;Rt();Gt();Tt();var Sx=ea("en");function Ji(t){let e=t.expected;if(e){if(t.state.state_version!==e.stateVersion)throw new Error(`Native continuation is stale: the change moved on since the referenced response (current phase ${t.state.phase}, next action ${t.state.loop.next_action}, state version ${t.state.state_version}). Run comet native status ${t.state.name} --json and execute its commandAlternatives with --expected-state-version ${t.state.state_version} --expected-action ${t.state.loop.next_action}.`);if(e.action!==t.action)throw new Error(`Native continuation expected ${e.action} cannot be used for ${t.action}`)}}async function yl(t){return J(t.paths,`return portable change ${t.name} to Shape`,async()=>{let e=await ne(t.paths,t.name);if(Ji({state:e,expected:t.expectedContinuation,action:"revise-requirements"}),t.allowedPhases&&!t.allowedPhases.includes(e.phase))throw new Error("--revise-requirements is only valid from Verify or Archive");return e.phase==="shape"?e:Nl({paths:t.paths,state:e,reason:t.reason,...t.keepFailureBudget?{keepFailureBudget:!0}:{}})})}async function Nl(t){let{state:e}=t;if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i={...Nr(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:at(t.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:e.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:t.keepFailureBudget?e.loop.failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await It({paths:t.paths,previous:e,next:i});return await At(Ge(t.paths,e.name),ct({portableState:n,projectRoot:t.paths.projectRoot,branch:lt(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n}ue();Y();_r();Tt();Rt();Gt();import{createHash as PD,randomUUID as xx}from"node:crypto";st();ma();z();eo();Y();Gt();j();var FD=1024*1024*1024;function $h(t){if(t.local===null||t.local.change!==t.state.name)return ct({portableState:t.state,projectRoot:t.projectRoot,branch:lt(t.projectRoot)});let e=t.local.execution?.operationId??xx();return{...t.local,basedOnStateVersion:t.state.state_version,execution:{operationId:e,stage:"checking",actor:"runtime",executionId:null,status:"completed",startedAt:t.local.execution?.startedAt??new Date().toISOString(),requestCheckRounds:0},checks:t.local.checks.map(r=>r.status==="running"||r.status==="planned"?{...r,operationId:e,status:"interrupted"}:{...r,operationId:e})}}async function jh(t){try{let e=await Ka(Ge(t.paths,t.state.name));return e===null||e.change!==t.state.name||e.basedOnStateVersion!==t.state.state_version?null:e}catch{return null}}Y();Za();qi();async function bl(t){return J(t.paths,`return portable change ${t.name} to Build`,async()=>{let e=await ne(t.paths,t.name);if(Ji({state:e,expected:t.expectedContinuation,action:"revise-implementation"}),e.phase==="build")return e;let r=t.preserveLocalChecks?await jh({paths:t.paths,state:e}):null,i=ro({state:e,reason:t.reason,...t.failureBudget?{failureBudget:t.failureBudget}:{}}),n=await It({paths:t.paths,previous:e,next:i});return await At(Ge(t.paths,e.name),t.preserveLocalChecks?$h({local:r,state:n,projectRoot:t.paths.projectRoot}):ct({portableState:n,projectRoot:t.paths.projectRoot,branch:lt(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n})}Tt();Y();Tt();Y();Yc();var PB=16*1024;async function Cx(t){let e=await al(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(vr(e.selection.change),e.selection)}async function Oh(t){let e=await Cx(t);return e?(await Ut(t,e.change)?await ne(t,e.change):await ye(t,e.change),e.change):null}Sa();var Rx=new Set(["brief.md","children.yaml","comet-state.yaml","verification.md","capability-association.yaml"]),Dh=new Set(["comet-state.yaml","verification.md","capability-association.yaml"]);function Sl(t){let e=t.split("/");return e.length===3&&e[0]==="specs"&&e[1]!==void 0&&Rr.test(e[1])&&(e[2]==="spec.md"||e[2]===Ci)}function oo(t,e){if(!X(t,e))return null;let r=_.relative(t,e).replaceAll("\\","/"),[i,...n]=r.split("/");if(!i||!Rr.test(i))return null;if(n.length===0)return{name:i,relative:""};let a=n.join("/");return Rx.has(a)?{name:i,relative:a}:Sl(a)?{name:i,relative:a}:null}function _x(t,e){return X(t.runtimeDir,e)||_.relative(t.projectRoot,e).replaceAll("\\","/")===".comet/current-change.json"}function Ax(t,e,r){let i=_.join(t.projectRoot,".comet","comet");if(X(t.nativeRoot,e)||_.resolve(i)===_.resolve(t.nativeRoot))return null;let n=oo(_.join(i,"changes"),e);return n&&r.has(n.name)?n:null}function Lh(t){return t==="brief.md"?"data.artifacts.briefPath":t==="children.yaml"?"data.artifacts.childrenPath":t.startsWith("specs/")?"data.artifacts.specsDir":"data.artifacts.changeDir"}function Bh(t,e,r){return`Published Native specs are updated through Archive. Read ${_.join(t,"specs",_.relative(e,r))}, merge the original edit there, and retry the write against that exact target; do not overwrite existing content.`}function Hh(t,e,r,i={}){if(!X(t,r))return null;if(_x(e,r)){let s=_.relative(e.projectRoot,r).replaceAll("\\","/"),c=s.match(/^\.comet\/runtime\/native\/changes\/([^/]+)(?:\/|$)/u)?.[1];return{allowed:!1,reason:`Native Runtime-owned path ${s}. Run ${c?`comet native status ${c} --json`:"comet native status --json"} in ${e.projectRoot}, follow its continuation, and retry; do not edit Runtime files directly.`,workflow:"native",...c?{change:c}:{}}}let n=Ax(e,r,i.registeredChanges??new Set);if(n){let s=_.join(e.changesDir,n.name,n.relative);return{allowed:!1,reason:`Native formal artifact target ${_.relative(t,r).replaceAll("\\","/")} is outside the configured artifact root. Use ${s} in ${e.projectRoot}; read existing content and merge the original edit instead of overwriting it.`,workflow:"native",change:n.name}}let a=oo(e.changesDir,r);if(!a)return null;if(Dh.has(a.relative))return{allowed:!1,reason:`Native Runtime-owned artifact ${_.relative(t,r).replaceAll("\\","/")}. Run comet native status ${a.name} --json in ${e.projectRoot} and follow its continuation; do not infer a mutation or edit the file directly.`,workflow:"native",change:a.name};if(i.allowCanonicalFormal===!1)return null;let o=_.join(e.changesDir,a.name,a.relative);return{allowed:!1,reason:`Native formal artifact target ${_.relative(t,r).replaceAll("\\","/")} is not registered. Run comet native new ${a.name} in ${e.projectRoot}. Use the response ${Lh(a.relative)} to locate ${o}; read initialized or existing content and merge the original edit instead of overwriting it.`,workflow:"native",change:a.name}}function kl(t){return t.length===0?null:t.length===1?t[0]:{...t[0],reason:t.map(e=>e.reason).join(`
160
- `)}}function Ix(t,e,r,i,n,a){let o=_.relative(t,n).replaceAll("\\","/"),s=_.join(e.changesDir,i.name,i.relative);return{allowed:!1,reason:a?`Native formal artifact target ${o} belongs to registered change ${i.name}, not selected change ${r}. Run comet native select ${i.name} in ${e.projectRoot}, then read ${s} and merge the original edit.`:`Native formal artifact target ${o} belongs to unregistered change ${i.name}, not selected change ${r}. Run comet native new ${i.name} --isolation worktree in ${e.projectRoot}. Use the response ${Lh(i.relative)} to locate ${s}; read initialized or existing content and merge the original edit.`,workflow:"native",change:r}}function Fh(t){let e=`Native change ${t.name} is in ${t.phase}; implementation writes are only allowed in Build.`;return t.phase==="shape"?`${e} Reread the latest continuation, complete requirement clarification, and execute the Shape confirmation command after user confirmation.`:t.phase==="verify"?`${e} Select and execute the matching commandAlternative from the latest continuation, preserving --expected-state-version and --expected-action.`:t.phase==="archive"?`${e} Continue finalizing the accepted result; do not run Verify-only revision commands from Archive.`:`${e} Create or select a separate Native change if this write belongs to different work.`}async function Tx(t){let{projectRoot:e,paths:r,state:i,request:n}=t,a=je(r,i.name),o=[],s=[],c=[],l=[],u=[],d=await Mh(e),f=!1,m=!1,w=!1;for(let p of n.targets){let h=_.resolve(e,p);if(!X(e,h)){w=!0;continue}let y=_.relative(e,h).replaceAll("\\","/");if(y===".comet/config.yaml"){m=!0;continue}if(!X(r.nativeRoot,h)){if(await Ma(e,h,[_.join(e,".comet"),r.nativeRoot])){f=!0;continue}if(!d&&Vh(r,y)){l.push(y);continue}c.push(y);continue}if(!X(a,h)){u.push({allowed:!1,reason:X(r.specsDir,h)?Bh(a,r.specsDir,h):"Portable Native control state is Runtime-owned",workflow:"native",phase:i.phase,change:i.name});continue}let v=_.relative(a,h).replaceAll("\\","/");if(v==="brief.md"||v==="children.yaml"||v.startsWith("specs/")&&$x(v)){o.push(v);continue}if(v.startsWith("specs/")){s.push(v);continue}u.push({allowed:!1,reason:`${v||"change directory"} is Runtime-owned and cannot be edited by the Agent`,workflow:"native",phase:i.phase,change:i.name})}return s.length>0&&u.push({allowed:!1,reason:s.map(qh).join(`
161
- `),workflow:"native",phase:i.phase,change:i.name}),u.length>0?kl(u):o.length>0&&(c.length>0||l.length>0)?{allowed:!1,reason:"Formal Native requirements must be edited in separate actions from implementation or documentation files",workflow:"native",phase:i.phase,change:i.name}:o.length>0?i.phase!=="shape"?{allowed:!0,reason:`Native requirements changed; returned to Shape goal cycle ${(await yl({paths:r,name:i.name,reason:`Formal requirement write requested for ${o.join(", ")}`})).loop.goal_cycle}`,workflow:"native",phase:"shape",change:i.name}:{allowed:!0,reason:"Native control artifact write",workflow:"native",phase:i.phase,change:i.name}:c.length>0?i.children_contract_hash?{allowed:!1,reason:"Native parent Build advances child changes instead of editing implementation",workflow:"native",phase:i.phase,change:i.name}:i.phase==="build"?{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:i.phase,change:i.name}:i.phase==="verify"||i.phase==="archive"?{allowed:!0,reason:`Native candidate was invalidated and returned to Build iteration ${(await bl({paths:r,name:i.name,reason:`Observed implementation write before ${c.join(", ")}`})).loop.iteration}`,workflow:"native",phase:"build",change:i.name}:{allowed:!1,reason:Fh(i),workflow:"native",phase:i.phase,change:i.name}:l.length>0?{allowed:!0,reason:"Native neutral document write: documentation edits stay outside the implementation scope and do not return the change to Build",workflow:"native",phase:i.phase,change:i.name}:f?{allowed:!0,reason:"Native configured Hook allow path",workflow:"native",phase:i.phase,change:i.name}:{allowed:!0,reason:m?"Native control artifact write":w?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:i.phase,change:i.name}}function X(t,e){let r=_.relative(t,e);return r===""||!r.startsWith("..")&&!_.isAbsolute(r)}async function Mh(t){return(await Z(t))?.native?.document_writes==="revert"}function Vh(t,e){return mh(e,[_.relative(t.projectRoot,t.nativeRoot).replaceAll("\\","/"),".comet"])}function qh(t){let e=t.split("/"),r=e[0]==="specs"&&e[1]&&Rr.test(e[1])?e[1]:null;return`Native formal Spec artifacts must use ${r?`specs/${r}/spec.md (or specs/${r}/${Ci} for delta metadata)`:`specs/<capability>/spec.md (or specs/<capability>/${Ci} for delta metadata)`}; received ${t}`}function $x(t){return Sl(t)}function jx(t,e,r){return r.targets.length>0&&r.targets.every(i=>{let n=_.resolve(t,i);return X(t,n)?_.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||X(e,n):!0})}async function Ox(t){let e=await Z(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let r=await Qe(t,e.native.artifact_root),i;try{i=await Px.readdir(r.changesDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return{paths:r,changes:[]};throw a}let n=[];for(let a of i.sort((o,s)=>o.name.localeCompare(s.name)))if(!(!a.isDirectory()||a.isSymbolicLink()))if(await Ut(r,a.name)){let o=await ne(r,a.name);o.archived||n.push({kind:"portable",state:o})}else{let o=await ye(r,a.name);o.archived||n.push({kind:"legacy",state:o})}return{paths:r,changes:n}}async function Hx(t,e){let r=await Z(t);if(!r||!(r.workflows??[r.default_workflow]).includes("native"))return null;let i=await Qe(t,r.native.artifact_root);try{if(await Ut(i,e)){let a=await ne(i,e);return{paths:i,changes:a.archived?[]:[{kind:"portable",state:a}]}}let n=await ye(i,e);return{paths:i,changes:n.archived?[]:[{kind:"legacy",state:n}]}}catch(n){if(n.code==="ENOENT")return{paths:i,changes:[]};throw n}}var Dx=Xi("nativeActiveContext",t=>Ox(t));async function Lx(t,e){let r=await Z(t);if(!r||!(r.workflows??[r.default_workflow]).includes("native"))return null;let i=await Qe(t,r.native.artifact_root);try{let n=await Ut(i,e)?await ne(i,e):await ye(i,e);return n.archived?null:{workflow:"native",name:n.name,phase:n.phase}}catch(n){if(n.code==="ENOENT")return null;throw n}}async function Wh(){let{intent:t,targets:e}=await Dl();return{intent:t,targets:e}}async function zh(t,e,r){let i=r?await Hx(t,r):await Dx(t);if(!i)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.changes.length===0){let p=[];for(let y of e.targets){let v=Hh(t,i.paths,_.resolve(t,y));v&&p.push(v)}let h=kl(p);return h||{allowed:!0,reason:jx(t,i.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"}}let n;if(r){if(n=i.changes.find(p=>p.state.name===r),!n)return{allowed:!1,reason:`Selected Native change ${r} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:r}}else if(i.changes.length===1)n=i.changes[0];else{let p=await Oh(i.paths);if(n=i.changes.find(h=>h.state.name===p),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}let a=n.state,o=new Set(i.changes.map(({state:p})=>p.name)),s=new Map,c=[];for(let p of e.targets){let h=_.resolve(t,p),y=Hh(t,i.paths,h,{allowCanonicalFormal:!1,registeredChanges:o});if(y){c.push(y);continue}let v=oo(i.paths.changesDir,h);if(v&&v.name!==a.name){let S=o.has(v.name);if(!S&&r){let g=s.get(v.name);g||(g=Lx(t,v.name).then(Boolean),s.set(v.name,g)),S=await g}c.push(Ix(t,i.paths,a.name,v,h,S));continue}if(!X(t,h))continue;if(X(i.paths.specsDir,h)){let S=n.kind==="portable"?je(i.paths,a.name):ze(i.paths,a.name);c.push({allowed:!1,reason:Bh(S,i.paths.specsDir,h),workflow:"native",phase:a.phase,change:a.name});continue}if(!X(i.paths.nativeRoot,h))continue;let k=n.kind==="portable"?je(i.paths,a.name):ze(i.paths,a.name);if(X(k,h)){let S=_.relative(k,h).replaceAll("\\","/");if(S==="brief.md"||S==="children.yaml"||Sl(S))continue;c.push({allowed:!1,reason:S.startsWith("specs/")?qh(S):`${S||"change directory"} is Runtime-owned. Run comet native status ${a.name} --json in ${i.paths.projectRoot} and follow its continuation; do not edit it directly.`,workflow:"native",phase:a.phase,change:a.name});continue}let x=_.relative(t,h).replaceAll("\\","/");c.push({allowed:!1,reason:`Native-managed path ${x} is not an editable artifact for ${a.name}. Run comet native status ${a.name} --json in ${i.paths.projectRoot} and follow its continuation.`,workflow:"native",phase:a.phase,change:a.name})}let l=kl(c);if(l)return l;if(n.kind==="legacy"&&a.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:a.phase,change:a.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:a.phase,change:a.name};if(n.kind==="portable")return Tx({projectRoot:t,paths:i.paths,state:n.state,request:e});let u=!1,d=!1,f=!1,m=!1,w=await Mh(t);for(let p of e.targets){let h=_.resolve(t,p);if(!X(t,h)){d=!0;continue}let y=_.relative(t,h).replaceAll("\\","/");if(y===".comet/config.yaml"){u=!0;continue}if(X(i.paths.nativeRoot,h)){let v=oo(i.paths.changesDir,h);if(v?.name===a.name){if(Dh.has(v.relative))return{allowed:!1,reason:`Native control state is Runtime-owned; use the CLI for ${y}`,workflow:"native",phase:a.phase,change:a.name};u=!0;continue}return{allowed:!1,reason:`Native control state is Runtime-owned; use the CLI for ${y}`,workflow:"native",phase:a.phase,change:a.name}}if(await Ma(t,h,[_.join(t,".comet"),i.paths.nativeRoot])){f=!0;continue}if(!w&&Vh(i.paths,y)){m=!0;continue}return{allowed:!1,reason:Fh(a),workflow:"native",phase:a.phase,change:a.name}}return{allowed:!0,reason:u?"Native control artifact write":d?"Write target is outside the guarded project":f?"Native configured Hook allow path":m?"Native neutral document write: documentation edits stay outside the implementation scope":"No guarded write target was provided",workflow:"native",phase:a.phase,change:a.name}}Ni();import Ki from"path";import{realpathSync as CC}from"fs";function Gh(t,e){let r=u=>u!==null&&typeof u=="object"&&!Array.isArray(u)?u:{},i=r(t),n=r(i.entry),a=r(i.state??n.state??i),o=r(i.preparation??i.workspace??n.workspace),s=r(i.continuation??n.continuation),c=typeof o.projectRoot=="string"&&o.projectRoot!=="."?o.projectRoot:e??null,l=a.stateVersion??a.state_version;return{phase:typeof a.phase=="string"?a.phase:null,status:typeof a.status=="string"?a.status:null,stateVersion:typeof l=="number"?l:null,workspace:{cwd:c},continuation:Object.keys(s).length?{...s,cwd:c}:null}}var ut={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Jh(t){return t?t.command?`${ut.next} ${t.command}`:t.ask_user?`${ut.next} ${t.ask_user}`:null:null}function Uh(t,e){let r=[t.summary],i=Jh(t.next);return i&&r.push(i),t.user_message&&r.push("",ut.relay,t.user_message),e!==void 0&&r.push("",ut.details,JSON.stringify(e,null,2)),`${r.join(`
200
+ ${i.birthtimeMs}`)}async function yv(t,e){let r=await zo.realpath(e),i=await zo.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Pu==="win32"?Mt.normalize(r).toLowerCase():r;return Ru(t,n)}function xP(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function Cu(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||kv(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Ev(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Cu(t.changeBranch,"Native workspace change branch"),Cu(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function CP(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace Git provenance must be an object");let e=t,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(e).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(e.provider!=="git"||typeof e.baseCommit!="string"||!gv.test(e.baseCommit)||typeof e.targetCommit!="string"||!gv.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");Cu(e.targetBranch,"Native workspace Git target branch")}function Go(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(e).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!xn.test(String(e.projectRootId))||!xn.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");xP(e.capturedAt),Sv(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,a=e.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!xn.test(String(e.projectRootPathId))||a&&!xn.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!xn.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&CP(e.git),e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Ev(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function PP(t,e){return Mt.join(Ne(t,e),"workspace.json")}function RP(t,e){let r=PP(t,e),i=Oe(t,r),n=bv(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Sv(n,"Native workspace file ref")}}async function _P(t,e){try{let r=RP(t,e),i=await M({root:r.root,ref:r.ref,maxBytes:EP});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function AP(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=bv(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=_e(t.paths.projectRoot),i=r.isGitWorktree?er(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:er(t.paths.projectRoot,n),o=i!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:i,targetBranch:n,targetCommit:a}:void 0,[s,l,c,u]=await Promise.all([wv("comet.native.workspace-project-root.v2",t.paths.projectRoot),wv("comet.native.workspace-native-root.v2",t.paths.nativeRoot),yv("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),yv("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),d=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&Ev(t.binding);let f={capturedAt:d,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:l,projectRootPathId:c,nativeRootPathId:u,...o?{git:o}:{},...t.sessionId?{sessionHash:Ru("comet.native.workspace-session.v2",`${s}
201
+ ${l}
202
+ ${t.sessionId}`)}:{}},p=t.binding?{schema:"comet.native.workspace.v3",...f,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...f};return Go(p),p}async function Jo(t,e){let r=await _P(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(Go(r),r)}async function xv(t){Go(t.identity);let e=await AP({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),r=[],i=[];return e.nativeRootRef!==t.identity.nativeRootRef&&r.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&r.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&r.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&r.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&r.push("native-root-legacy-identity")),Pu==="win32"&&r.length>0&&r.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?i.push("workspace-inspection-unavailable"):r.length>0&&i.push("workspace-root-changed"),{state:i.length===0?"aligned":i.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:i,driftComponents:r}}async function Cv(t){if(Go(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await xv(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=_e(t.paths.projectRoot);return t.identity.changeBranch===null?r.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:r.isGitWorktree?r.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!r.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function Pv(t,e){let r=await Jo(t,e);if(r===null)return null;let i=await Cv({paths:t,identity:r});if(i.state==="drifted")throw new Error(`${i.code}: ${i.message}`);return r}hn();ko();ko();var Uo=class extends Error{constructor(r,i,n){super(`Native change ${r} revision conflict: expected ${i}, actual ${n}`);this.change=r;this.expectedRevision=i;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Cn=class extends Error{constructor(r,i){super(`Native working directory already contains active change${i.length===1?"":"s"} ${i.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=r;this.activeChanges=i;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},Ko=class extends Error{constructor(r,i,n,a,o,s=null,l=null){super(`Native change ${r} baseline is incomplete (${i} omitted entr${i===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=r;this.omittedCount=i;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=l;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},CD=Ya("en");function Ze(t,e){Kr(e);let r=ni.join(t.changesDir,e);if(!Q(t.changesDir,r))throw new Error("Native change path escaped");return r}async function Au(t,e){let r=Ne(t,e),i=ni.join(r,"schema-migration.json");await j(Q(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await $P.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function jP(t,e=ni.dirname(t)){let r=ni.relative(e,t).split(ni.sep).join("/"),i=await M({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,_u.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function OP(t,e){let r=ni.join(Ze(t,e),ht);await j(t.nativeRoot,r);let i=tu(await jP(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await Au(t,e)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(i.status==="current"&&i.state&&await HP(t,i.state),i)}async function HP(t,e){if(await dv(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function Me(t,e){let r=await OP(t,e);if(r.status==="migration-required")throw new Ur(e,r.schema);if(r.status==="runtime-incompatible"||!r.state)throw new pt(r.schema,r.minimumRuntimeVersion);return await Pv(t,e),r.state}he();L();var DP=new Set([".md",".markdown"]),LP=new Set([".md",".markdown",".rst",".txt"]),BP=new Set(["docs","doc","documentation",".github"]),MP=[/^LICENSE(?:[.-]|$)/u,/^NOTICE$/u,/^AUTHORS$/u];function _v(t){return t.replaceAll("\\","/").replace(/^\.\//u,"")}function FP(t,e){for(let r of e){let i=_v(r).replace(/\/+$/u,"");if(i&&(t===i||t.startsWith(`${i}/`)))return!0}return!1}function Av(t,e=[]){let r=_v(t);if(!r||r.endsWith("/")||FP(r,e))return!1;let i=r.split("/"),n=i[i.length-1],a=n.lastIndexOf("."),o=a===-1?"":n.slice(a).toLowerCase();return i.length===1?DP.has(o)||MP.some(s=>s.test(n)):BP.has(i[0])&&LP.has(o)}he();Z();import{promises as Tv}from"node:fs";import Qo from"node:path";et();V();Ro();import{promises as Iv}from"node:fs";import VP from"node:os";import _n from"node:path";function Pn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Rn(t,e,r){let i=Object.keys(t).filter(n=>!e.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function oe(t,e,r=!1){if(typeof t!="string"||!r&&t.length===0)throw new Error(`${e} must be ${r?"a string":"a non-empty string"}`);return t}function ai(t,e){return t===null?null:oe(t,e)}function oi(t,e,r=0){if(!Number.isSafeInteger(t)||t<r)throw new Error(`${e} must be a safe integer greater than or equal to ${r}`);return t}function qP(t,e){if(t===null)return null;if(!Number.isSafeInteger(t))throw new Error(`${e} must be null or a safe integer`);return t}function WP(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function si(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Iu(t,e){if(t===null)return null;let r=oe(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function zP(t,e){let r=oe(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function Tu(t,e){let r=oe(t,e);if(!_n.isAbsolute(r))throw new Error(`${e} must be absolute`);return _n.resolve(r)}function GP(t,e){let r=`Native local checks[${e}]`,i=Pn(t,r);if(Rn(i,new Set(["id","name","operationId","status","repeatable","timeoutMs","executionCount","argv","cwd","exitCode","startedAt","completedAt","log","activeProcess","evidence","evidenceDigest"]),r),!Array.isArray(i.argv)||i.argv.length===0)throw new Error(`${r}.argv must be a non-empty array`);let n=i.argv.map((u,d)=>oe(u,`${r}.argv[${d}]`,!0)),a=si(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=Iu(i.startedAt,`${r}.startedAt`),s=Iu(i.completedAt,`${r}.completedAt`);if(a==="planned"&&(o!==null||s!==null))throw new Error(`${r} planned check cannot contain execution timestamps`);if(a==="running"&&(o===null||s!==null))throw new Error(`${r} running check requires only startedAt`);if((a==="passed"||a==="failed")&&(o===null||s===null))throw new Error(`${r} completed check requires startedAt and completedAt`);let l=oi(i.timeoutMs,`${r}.timeoutMs`);if(l<1)throw new Error(`${r}.timeoutMs must be positive`);let c;if(Object.hasOwn(i,"activeProcess"))if(i.activeProcess===null)c=null;else{let u=Pn(i.activeProcess,`${r}.activeProcess`),d=si(u.status,["starting","running"],`${r}.activeProcess.status`);if(Rn(u,new Set(["status","pid","identity"]),`${r}.activeProcess`),d==="starting"){if(Object.hasOwn(u,"pid")||Object.hasOwn(u,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);c={status:"starting"}}else c={status:"running",pid:oi(u.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(u,"identity")?{identity:oe(u.identity,`${r}.activeProcess.identity`)}:{}}}return{id:oe(i.id,`${r}.id`),name:oe(i.name,`${r}.name`),operationId:oe(i.operationId,`${r}.operationId`),status:a,repeatable:WP(i.repeatable,`${r}.repeatable`),timeoutMs:l,executionCount:oi(i.executionCount,`${r}.executionCount`),argv:n,cwd:Tu(i.cwd,`${r}.cwd`),exitCode:qP(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:oe(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:c}:{},...Object.hasOwn(i,"evidence")?{evidence:si(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:oe(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function $u(t){let e="Native local execution state",r=Pn(t,e);if(Rn(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),e),r.schema!==kn)throw new Error(`Native local execution schema must be ${kn}`);let i=Pn(r.workspace,"Native local workspace");Rn(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=Pn(r.execution,"Native local execution");Rn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=Iu(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:oe(o.operationId,"Native local execution.operationId"),stage:si(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:si(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:ai(o.executionId,"Native local execution.executionId"),status:si(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:oi(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:zP(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:oi(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:oe(o.ownerIdentity,"Native local execution.ownerIdentity")}:{}}}if(!Array.isArray(r.checks))throw new Error("Native local checks must be an array");let a=r.checks.map(GP);if(new Set(a.map(o=>o.id)).size!==a.length)throw new Error("Native local check IDs must be unique");if(n&&a.some(o=>o.operationId!==n.operationId))throw new Error("Native local checks must belong to the current operation");return{schema:kn,change:oe(r.change,"Native local change"),basedOnStateVersion:oi(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:ai(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:ai(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:ai(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:ai(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:Tu(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Tu(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:ai(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:oe(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}function gt(t){return $u({schema:kn,change:t.portableState.name,basedOnStateVersion:t.portableState.state_version,candidateId:t.portableState.builder_handoff?.candidate_id??null,inputFingerprint:null,inputFingerprintGate:null,candidateInputFingerprintGate:null,workspace:{projectRoot:_n.resolve(t.projectRoot),worktreeRoot:_n.resolve(t.worktreeRoot??t.projectRoot),branch:t.branch??null,machineId:VP.hostname()},execution:null,checks:[]})}async function Xo(t){let e;try{e=await Iv.readFile(t,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}let r;try{r=JSON.parse(e)}catch(i){throw new Error(`Native local execution state is invalid JSON: ${i.message}`,{cause:i})}return $u(r)}async function Ft(t,e,r={}){let i=$u(e);await Iv.mkdir(_n.dirname(t),{recursive:!0}),await ue(t,i,r)}Bt();L();var fr=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,$v="comet-state.yaml",jv="state.json";function se(t,e){if(!fr.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=Qo.join(t.changesDir,e);if(!Q(t.changesDir,r))throw new Error("Native change path escaped");return r}function An(t,e){return Qo.join(se(t,e),$v)}function tt(t,e){return Qo.join(ct(t,e),jv)}async function ci(t,e){try{let r=await Tv.readFile(An(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}function wt(t){return Eh(t)}async function fe(t,e){return Sn(An(t,e))}async function Vt(t){let e=await Fm({file:An(t.paths,t.previous.name),expectedStateVersion:t.previous.state_version,next:t.next,containedRoot:t.paths.nativeRoot});if(e.verification===null&&e.verification_report===null){let r=Qo.join(se(t.paths,e.name),"verification.md");await j(t.paths.nativeRoot,r),await Tv.rm(r,{force:!0})}return e}import{promises as ps}from"node:fs";import kr from"node:path";function Du(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mr=Du();function Vv(t){mr=t}var pr={exec:()=>null};function li(t){let e=[];return r=>{let i=Math.max(0,Math.min(3,r-1)),n=e[i];return n||(n=t(i),e[i]=n),n}}function P(t,e=""){let r=typeof t=="string"?t:t.source,i={replace:(n,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(ee.caret,"$1"),r=r.replace(n,o),i},getRegex:()=>new RegExp(r,e)};return i}var UP=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ee={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:li(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:li(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:li(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:li(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:li(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:li(t=>new RegExp(`^ {0,${t}}>`))},KP=/^(?:[ \t]*(?:\n|$))+/,YP=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,XP=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,$n=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,QP=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Lu=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,qv=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wv=P(qv).replace(/bull/g,Lu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ZP=P(qv).replace(/bull/g,Lu).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Bu=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,eR=/^[^\n]+/,Mu=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,tR=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mu).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),rR=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Lu).getRegex(),is="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Fu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,iR=P("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Fu).replace("tag",is).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),zv=t=>P(Bu).replace("hr",$n).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex(),nR=zv(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),aR=zv(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),oR=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",aR).getRegex(),Vu={blockquote:oR,code:YP,def:tR,fences:XP,heading:QP,hr:$n,html:iR,lheading:Wv,list:rR,newline:KP,paragraph:nR,table:pr,text:eR},Ov=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",$n).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex(),sR={...Vu,lheading:ZP,table:Ov,paragraph:P(Bu).replace("hr",$n).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Ov).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",is).getRegex()},cR={...Vu,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Fu).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:pr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Bu).replace("hr",$n).replace("heading",` *#{1,6} *[^
203
+ ]`).replace("lheading",Wv).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},lR=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,uR=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gv=/^( {2,}|\\)\n(?!\s*$)/,dR=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yt=/[\p{P}\p{S}]/u,ui=/[\s\p{P}\p{S}]/u,jn=/[^\s\p{P}\p{S}]/u,fR=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ui).getRegex(),pR=/[\p{Pi}\p{Ps}"']/u,Jv=/(?!~)[\p{P}\p{S}]/u,hR=/(?!~)[\s\p{P}\p{S}]/u,mR=/(?:[^\s\p{P}\p{S}]|~)/u,vR=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",UP?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Uv=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,gR=P(Uv,"u").replace(/punct/g,yt).getRegex(),wR=P(Uv,"u").replace(/punct/g,Jv).getRegex(),yR=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,NR=P(yR,"u").replace(/openQuote/g,pR).replace(/punct/g,yt).getRegex(),Kv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",bR=P(Kv,"gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,ui).replace(/punct/g,yt).getRegex(),kR=P(Kv,"gu").replace(/notPunctSpace/g,mR).replace(/punctSpace/g,hR).replace(/punct/g,Jv).getRegex(),SR="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",ER=P(SR,"gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,ui).replace(/punct/g,yt).getRegex(),xR=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,ui).replace(/punct/g,yt).getRegex(),CR="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",PR=P(CR,"gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,ui).replace(/punct/g,yt).getRegex(),RR=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,yt).getRegex(),_R="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",AR=P(_R,"gu").replace(/notPunctSpace/g,jn).replace(/punctSpace/g,ui).replace(/punct/g,yt).getRegex(),IR=P(/\\(punct)/,"gu").replace(/punct/g,yt).getRegex(),TR=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),$R=P(Fu).replace("(?:-->|$)","-->").getRegex(),jR=P("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",$R).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),es=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,OR=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",es).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yv=P(/^!?\[(label)\]\[(ref)\]/).replace("label",es).replace("ref",Mu).getRegex(),Xv=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",Mu).getRegex(),HR=P("reflink|nolink(?!\\()","g").replace("reflink",Yv).replace("nolink",Xv).getRegex(),Hv=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,qu={_backpedal:pr,anyPunctuation:IR,autolink:TR,blockSkip:vR,br:Gv,code:uR,del:pr,delLDelim:pr,delRDelim:pr,emStrongLDelim:gR,emStrongRDelimAst:bR,emStrongRDelimUnd:xR,escape:lR,link:OR,nolink:Xv,punctuation:fR,reflink:Yv,reflinkSearch:HR,tag:jR,text:dR,url:pr},DR={...qu,emStrongLDelim:NR,emStrongRDelimAst:ER,emStrongRDelimUnd:PR,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",es).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",es).getRegex()},ju={...qu,emStrongRDelimAst:kR,emStrongLDelim:wR,delLDelim:RR,delRDelim:AR,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Hv).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Hv).getRegex()},LR={...ju,br:P(Gv).replace("{2,}","*").getRegex(),text:P(ju.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Zo={normal:Vu,gfm:sR,pedantic:cR},In={normal:qu,gfm:ju,breaks:LR,pedantic:DR},BR={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Dv=t=>BR[t];function rt(t,e){if(e){if(ee.escapeTest.test(t))return t.replace(ee.escapeReplace,Dv)}else if(ee.escapeTestNoEncode.test(t))return t.replace(ee.escapeReplaceNoEncode,Dv);return t}function Lv(t){try{t=encodeURI(t).replace(ee.percentDecode,"%")}catch{return null}return t}function Bv(t,e){let r=t.replace(ee.findPipe,(a,o,s)=>{let l=!1,c=o;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),i=r.split(ee.splitPipe),n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(ee.slashPipe,"|");return i}function qt(t,e,r){let i=t.length;if(i===0)return"";let n=0;for(;n<i;){let a=t.charAt(i-n-1);if(a===e&&!r)n++;else if(a!==e&&r)n++;else break}return t.slice(0,i-n)}function Mv(t){let e=t.split(`
204
+ `),r=e.length-1;for(;r>=0&&ee.blankLine.test(e[r]);)r--;return e.length-r<=2?t:e.slice(0,r+1).join(`
205
+ `)}function MR(t,e){if(t.indexOf(e[1])===-1)return-1;let r=0;for(let i=0;i<t.length;i++)if(t[i]==="\\")i++;else if(t[i]===e[0])r++;else if(t[i]===e[1]&&(r--,r<0))return i;return r>0?-2:-1}function FR(t,e=0){let r=e,i="";for(let n of t)if(n===" "){let a=4-r%4;i+=" ".repeat(a),r+=a}else i+=n,r++;return i}function Fv(t,e,r,i,n){let a=e.href,o=e.title||null,s=t[1].replace(n.other.outputLinkReplace,"$1"),l=t[0].charAt(0)==="!";i.state.inLink=!0;let c=i.state.linkEmitted,u=i.state.inRawBlock;i.state.linkEmitted=!1;let d=i.inlineTokens(s),f=i.state.linkEmitted;if(i.state.linkEmitted=c,i.state.inLink=!1,!l){if(f){i.state.inRawBlock=u;return}i.state.linkEmitted=!0}return{type:l?"image":"link",raw:r,href:a,title:o,text:s,tokens:d}}function VR(t,e,r){let i=t.match(r.other.indentCodeCompensation);if(i===null)return e;let n=i[1];return e.split(`
206
+ `).map(a=>{let o=a.match(r.other.beginningSpace);if(o===null)return a;let[s]=o;return s.length>=n.length?a.slice(n.length):a}).join(`
207
+ `)}var ts=class{options;rules;lexer;constructor(t){this.options=t||mr}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let r=this.options.pedantic?e[0]:Mv(e[0]),i=r.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:r,codeBlockStyle:"indented",text:i}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let r=e[0],i=VR(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:i}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let i=qt(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:qt(e[0],`
208
+ `),depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:qt(e[0],`
209
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let r=qt(e[0],`
210
+ `).split(`
211
+ `),i="",n="",a=[];for(;r.length>0;){let o=!1,s=[],l;for(l=0;l<r.length;l++)if(this.rules.other.blockquoteStart.test(r[l]))s.push(r[l]),o=!0;else if(!o)s.push(r[l]);else break;r=r.slice(l);let c=s.join(`
212
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
213
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
214
+ ${c}`:c,n=n?`${n}
215
+ ${u}`:u;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,a,!0),this.lexer.state.top=d,r.length===0)break;let f=a.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let p=f,v=r.join(`
216
+ `),h=p.raw+`
217
+ `+v.replace(this.rules.other.blockquoteSetextReplace2,""),m=this.blockquote(h);a[a.length-1]=m,i=`${i}
218
+ ${v}`,n=n.substring(0,n.length-p.text.length)+m.text;break}else if(f?.type==="list"){let p=f,v=p.raw+`
219
+ `+r.join(`
220
+ `),h=this.list(v);a[a.length-1]=h,i=i.substring(0,i.length-f.raw.length)+h.raw,n=n.substring(0,n.length-p.raw.length)+h.raw,r=v.substring(a.at(-1).raw.length).split(`
221
+ `);continue}}return{type:"blockquote",raw:i,tokens:a,text:n}}}list(t){let e=this.rules.block.list.exec(t);if(e){let r=e[1].trim(),i=r.length>1,n={type:"list",raw:"",ordered:i,start:i?+r.slice(0,-1):"",loose:!1,items:[]};r=i?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=i?r:"[*+-]");let a=this.rules.other.listItemRegex(r),o=!1;for(;t;){let l=!1,c="",u="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let d=FR(e[2].split(`
222
+ `,1)[0],e[1].length),f=t.split(`
223
+ `,1)[0],p=!d.trim(),v=0;if(this.options.pedantic?(v=2,u=d.trimStart()):p?v=e[1].length+1:(v=d.search(this.rules.other.nonSpaceChar),v=v>4?1:v,u=d.slice(v),v+=e[1].length),p&&this.rules.other.blankLine.test(f)&&(c+=f+`
224
+ `,t=t.substring(f.length+1),l=!0),!l){let h=this.rules.other.nextBulletRegex(v),m=this.rules.other.hrRegex(v),w=this.rules.other.fencesBeginRegex(v),g=this.rules.other.headingBeginRegex(v),b=this.rules.other.htmlBeginRegex(v),E=this.rules.other.blockquoteBeginRegex(v);for(;t;){let S=t.split(`
225
+ `,1)[0],y;if(f=S,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),y=f):y=f.replace(this.rules.other.tabCharGlobal," "),w.test(f)||g.test(f)||b.test(f)||E.test(f)||h.test(f)||m.test(f))break;if(y.search(this.rules.other.nonSpaceChar)>=v||!f.trim())u+=`
226
+ `+y.slice(v);else{if(p||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(d)||g.test(d)||m.test(d))break;u+=`
227
+ `+f}p=!f.trim(),c+=S+`
228
+ `,t=t.substring(S.length+1),d=y.slice(v)}}n.loose||(o?n.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(o=!0)),n.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),n.raw+=c}let s=n.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;n.raw=n.raw.trimEnd();for(let l of n.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!n.loose){let c=l.tokens.filter(d=>d.type==="space"),u=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));n.loose=u}for(let l of n.items){let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let d={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=d.checked,n.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}else l.task&&(l.task=!1)}if(n.loose)for(let l of n.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return n}}html(t){let e=this.rules.block.html.exec(t);if(e){let r=Mv(e[0]);return{type:"html",block:!0,raw:r,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:r}}}def(t){let e=this.rules.block.def.exec(t);if(e){let r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",n=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:qt(e[0],`
229
+ `),href:i,title:n}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=Bv(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
230
+ `):[],a={type:"table",raw:qt(e[0],`
231
+ `),header:[],align:[],rows:[]};if(r.length===i.length){for(let o of i)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<r.length;o++)a.header.push({text:r[o],tokens:this.lexer.inline(r[o]),header:!0,align:a.align[o]});for(let o of n)a.rows.push(Bv(o,a.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[l]})));return a}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let r=e[1].trim();return{type:"heading",raw:qt(e[0],`
232
+ `),depth:e[2].charAt(0)==="="?1:2,text:r,tokens:this.lexer.inline(r)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let r=e[1].charAt(e[1].length-1)===`
233
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let a=qt(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=MR(e[2],"()");if(a===-2)return;if(a>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let i=e[2],n="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],n=a[3])}else n=e[3]?e[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),Fv(e,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:n&&n.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let r;if((r=this.rules.inline.reflink.exec(t))||(r=this.rules.inline.nolink.exec(t))){let i=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),n=e[i.toLowerCase()];if(!n){let a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return Fv(r,n,r[0],this.lexer,this.rules)}}emStrong(t,e,r=""){let i=this.rules.inline.emStrongLDelim.exec(t);if(!(!i||!i[1]&&!i[2]&&!i[3]&&!i[4]||i[4]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[3])||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,l=0,c=i[0][0],u=r===c,d=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*t.length+n);(i=d.exec(e))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(o=[...a].length,i[3]||i[4]){s+=o;continue}else if(i[5]||i[6]){if(n%3&&!((n+o)%3)){l+=o;continue}if(u)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+l);let f=[...i[0]][0].length,p=t.slice(0,n+i.index+f+o);if(Math.min(n,o)%2){let h=p.slice(1,-1);return{type:"em",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(r),n=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&n&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,r=""){let i=this.rules.inline.delLDelim.exec(t);if(i&&(!i[1]||!r||this.rules.inline.punctuation.exec(r))){let n=[...i[0]].length-1,a,o,s=n,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+n);(i=l.exec(e))!==null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a||(o=[...a].length,o!==n))continue;if(i[3]||i[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let c=[...i[0]][0].length,u=t.slice(0,n+i.index+c+o),d=u.slice(n,-n);return{type:"del",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let r,i;return e[2]==="@"?(r=e[1],i="mailto:"+r):(r=e[1],i=r),{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let r,i;if(e[2]==="@")r=e[0],i="mailto:"+r;else{let n;do n=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(n!==e[0]);r=e[0],e[1]==="www."?i="http://"+e[0]:i=e[0]}return{type:"link",raw:e[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},ge=class Ou{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||mr,this.options.tokenizer=this.options.tokenizer||new ts,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,top:!0};let r={other:ee,block:Zo.normal,inline:In.normal};this.options.pedantic?(r.block=Zo.pedantic,r.inline=In.pedantic):this.options.gfm&&(r.block=Zo.gfm,this.options.breaks?r.inline=In.breaks:r.inline=In.gfm),this.tokenizer.rules=r}static get rules(){return{block:Zo,inline:In}}static lex(e,r){return new Ou(r).lex(e)}static lexInline(e,r){return new Ou(r).inlineTokens(e)}lex(e){e=e.replace(ee.carriageReturn,`
234
+ `),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let i=this.inlineQueue[r];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],i=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ee.tabCharGlobal," ").replace(ee.spaceLine,""));let n=1/0;for(;e;){if(e.length<n)n=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let a;if(this.options.extensions?.block?.some(s=>(a=s.call({lexer:this},e,r))?(e=e.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.space(e)){e=e.substring(a.raw.length);let s=r.at(-1);a.raw.length===1&&s!==void 0?s.raw+=`
235
+ `:r.push(a);continue}if(a=this.tokenizer.code(e)){e=e.substring(a.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
236
+ `)?"":`
237
+ `)+a.raw,s.text+=`
238
+ `+a.text,this.inlineQueue.at(-1).src=s.text):r.push(a);continue}if(a=this.tokenizer.fences(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.heading(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.hr(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.blockquote(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.list(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.html(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.def(e)){e=e.substring(a.raw.length);let s=r.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
239
+ `)?"":`
240
+ `)+a.raw,s.text+=`
241
+ `+a.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[a.tag]||(this.tokens.links[a.tag]={href:a.href,title:a.title},r.push(a));continue}if(a=this.tokenizer.table(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.lheading(e)){e=e.substring(a.raw.length),r.push(a);continue}let o=e;if(this.options.extensions?.startBlock){let s=1/0,l=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(o=e.substring(0,s+1))}if(this.state.top&&(a=this.tokenizer.paragraph(o))){let s=r.at(-1);i&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
242
+ `)?"":`
243
+ `)+a.raw,s.text+=`
244
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a),i=o.length!==e.length,e=e.substring(a.raw.length);continue}if(a=this.tokenizer.text(e)){e=e.substring(a.raw.length);let s=r.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
245
+ `)?"":`
246
+ `)+a.raw,s.text+=`
247
+ `+a.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):r.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}linkInText(e){if(!e.includes("["))return!1;let r=this.tokenizer.rules.inline.link;for(let i of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(r.test(i[0])&&e.charAt(i.index-1)!=="!")return!0;for(let i of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let n=i[0],a=n.lastIndexOf("[");if(!(n.charAt(0)==="!"||!Object.hasOwn(this.tokens.links,n.slice(a+1,-1)))&&!(a>1&&this.linkInText(n.slice(1,a-1))))return!0}return!1}inlineTokens(e,r=[]){this.tokenizer.lexer=this;let i=e;if(this.tokens.links&&e.includes("[")){let s=this.tokenizer.rules.inline.reflinkSearch,l=c=>{let u=c.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,c.slice(u+1,-1)))return c;if(u>1&&c.charAt(0)!=="!"){let d=c.slice(1,u-1);if(this.linkInText(d))return"["+d.replace(s,l)+"]["+"a".repeat(c.length-u-2)+"]"}return"["+"a".repeat(c.length-2)+"]"};i=i.replace(s,l)}i=i.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),i=i.replace(this.tokenizer.rules.inline.blockSkip,(s,l,c)=>{let u=c?c.length:0;return s.slice(0,u)+"["+"a".repeat(s.length-u-2)+"]"}),i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let n=!1,a="",o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}n||(a=""),n=!1;let s;if(this.options.extensions?.inline?.some(c=>(s=c.call({lexer:this},e,r))?(e=e.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let c=r.at(-1);s.type==="text"&&c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):r.push(s);continue}if(s=this.tokenizer.emStrong(e,i,a)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.del(e,i,a)){e=e.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),r.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),r.push(s);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,u=e.slice(1),d;this.options.extensions.startInline.forEach(f=>{d=f.call({lexer:this},u),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),n=!0;let c=r.at(-1);c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):r.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return r}infiniteLoopError(e){let r="Infinite loop on byte: "+e;if(this.options.silent)console.error(r);else throw new Error(r)}},rs=class{options;parser;constructor(t){this.options=t||mr}space(t){return""}code({text:t,lang:e,escaped:r}){let i=(e||"").match(ee.notSpaceStart)?.[0],n=t.replace(ee.endingNewline,"")+`
248
+ `;return i?'<pre><code class="language-'+rt(i)+'">'+(r?n:rt(n,!0))+`</code></pre>
249
+ `:"<pre><code>"+(r?n:rt(n,!0))+`</code></pre>
250
+ `}blockquote({tokens:t}){return`<blockquote>
251
+ ${this.parser.parse(t)}</blockquote>
252
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
253
+ `}hr(t){return`<hr>
254
+ `}list(t){let e=t.ordered,r=t.start,i="";for(let o=0;o<t.items.length;o++){let s=t.items[o];i+=this.listitem(s)}let n=e?"ol":"ul",a=e&&r!==1?' start="'+r+'"':"";return"<"+n+a+`>
255
+ `+i+"</"+n+`>
256
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
257
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
258
+ `}table(t){let e="",r="";for(let n=0;n<t.header.length;n++)r+=this.tablecell(t.header[n]);e+=this.tablerow({text:r});let i="";for(let n=0;n<t.rows.length;n++){let a=t.rows[n];r="";for(let o=0;o<a.length;o++)r+=this.tablecell(a[o]);i+=this.tablerow({text:r})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
259
+ <thead>
260
+ `+e+`</thead>
261
+ `+i+`</table>
262
+ `}tablerow({text:t}){return`<tr>
263
+ ${t}</tr>
264
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
265
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${rt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:r}){let i=this.parser.parseInline(r),n=Lv(t);if(n===null)return i;t=n;let a='<a href="'+t+'"';return e&&(a+=' title="'+rt(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let n=Lv(t);if(n===null)return rt(r);t=n;let a=`<img src="${t}" alt="${rt(r)}"`;return e&&(a+=` title="${rt(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:rt(t.text)}},Wu=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Fe=class Hu{options;renderer;textRenderer;constructor(e){this.options=e||mr,this.options.renderer=this.options.renderer||new rs,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Wu}static parse(e,r){return new Hu(r).parse(e)}static parseInline(e,r){return new Hu(r).parseInline(e)}parse(e){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let n=e[i];if(this.options.extensions?.renderers?.[n.type]){let o=n,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){r+=s||"";continue}}let a=n;switch(a.type){case"space":{r+=this.renderer.space(a);break}case"hr":{r+=this.renderer.hr(a);break}case"heading":{r+=this.renderer.heading(a);break}case"code":{r+=this.renderer.code(a);break}case"table":{r+=this.renderer.table(a);break}case"blockquote":{r+=this.renderer.blockquote(a);break}case"list":{r+=this.renderer.list(a);break}case"checkbox":{r+=this.renderer.checkbox(a);break}case"html":{r+=this.renderer.html(a);break}case"def":{r+=this.renderer.def(a);break}case"paragraph":{r+=this.renderer.paragraph(a);break}case"text":{r+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(e,r=this.renderer){this.renderer.parser=this;let i="";for(let n=0;n<e.length;n++){let a=e[n];if(this.options.extensions?.renderers?.[a.type]){let s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(a.type)){i+=s||"";continue}}let o=a;switch(o.type){case"escape":{i+=r.text(o);break}case"html":{i+=r.html(o);break}case"link":{i+=r.link(o);break}case"image":{i+=r.image(o);break}case"checkbox":{i+=r.checkbox(o);break}case"strong":{i+=r.strong(o);break}case"em":{i+=r.em(o);break}case"codespan":{i+=r.codespan(o);break}case"br":{i+=r.br(o);break}case"del":{i+=r.del(o);break}case"text":{i+=r.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return i}},Tn=class{options;block;constructor(t){this.options=t||mr}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?ge.lex:ge.lexInline}provideParser(t=this.block){return t?Fe.parse:Fe.parseInline}},qR=class{defaults=Du();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Fe;Renderer=rs;TextRenderer=Wu;Lexer=ge;Tokenizer=ts;Hooks=Tn;constructor(...t){this.use(...t)}walkTokens(t,e){let r=[];for(let i of t)switch(r=r.concat(e.call(this,i)),i.type){case"table":{let n=i;for(let a of n.header)r=r.concat(this.walkTokens(a.tokens,e));for(let a of n.rows)for(let o of a)r=r.concat(this.walkTokens(o.tokens,e));break}case"list":{let n=i;r=r.concat(this.walkTokens(n.items,e));break}default:{let n=i;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(a=>{let o=n[a].flat(1/0);r=r.concat(this.walkTokens(o,e))}):n.tokens&&(r=r.concat(this.walkTokens(n.tokens,e)))}}return r}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let a=e.renderers[n.name];a?e.renderers[n.name]=function(...o){let s=n.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[n.level];a?a.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),i.extensions=e),r.renderer){let n=this.defaults.renderer||new rs(this.defaults);for(let a in r.renderer){if(!(a in n))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=r.renderer[o],l=n[o];n[o]=(...c)=>{let u=s.apply(n,c);return u===!1&&(u=l.apply(n,c)),u||""}}i.renderer=n}if(r.tokenizer){let n=this.defaults.tokenizer||new ts(this.defaults);for(let a in r.tokenizer){if(!(a in n))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=r.tokenizer[o],l=n[o];n[o]=(...c)=>{let u=s.apply(n,c);return u===!1&&(u=l.apply(n,c)),u}}i.tokenizer=n}if(r.hooks){let n=this.defaults.hooks||new Tn;for(let a in r.hooks){if(!(a in n))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=r.hooks[o],l=n[o];Tn.passThroughHooks.has(a)?n[o]=c=>{if(this.defaults.async&&Tn.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(n,c);return l.call(n,d)})();let u=s.call(n,c);return l.call(n,u)}:n[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(n,c);return d===!1&&(d=await l.apply(n,c)),d})();let u=s.apply(n,c);return u===!1&&(u=l.apply(n,c)),u}}i.hooks=n}if(r.walkTokens){let n=this.defaults.walkTokens,a=r.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),n&&(s=s.concat(n.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return ge.lex(t,e??this.defaults)}parser(t,e){return Fe.parse(t,e??this.defaults)}parseMarkdown(t){return(e,r)=>{let i={...r},n={...this.defaults,...i},a=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let o=n.hooks?await n.hooks.preprocess(e):e,s=await(n.hooks?await n.hooks.provideLexer(t):t?ge.lex:ge.lexInline)(o,n),l=n.hooks?await n.hooks.processAllTokens(s):s;n.walkTokens&&await Promise.all(this.walkTokens(l,n.walkTokens));let c=await(n.hooks?await n.hooks.provideParser(t):t?Fe.parse:Fe.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(c):c})().catch(a);try{n.hooks&&(e=n.hooks.preprocess(e));let o=(n.hooks?n.hooks.provideLexer(t):t?ge.lex:ge.lexInline)(e,n);n.hooks&&(o=n.hooks.processAllTokens(o)),n.walkTokens&&this.walkTokens(o,n.walkTokens);let s=(n.hooks?n.hooks.provideParser(t):t?Fe.parse:Fe.parseInline)(o,n);return n.hooks&&(s=n.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return r=>{if(r.message+=`
266
+ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+rt(r.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(r);throw r}}},hr=new qR;function O(t,e){return hr.parse(t,e)}O.options=O.setOptions=function(t){return hr.setOptions(t),O.defaults=hr.defaults,Vv(O.defaults),O};O.getDefaults=Du;O.defaults=mr;function WR(...t){return hr.use(...t),O.defaults=hr.defaults,Vv(O.defaults),O}O.use=WR;O.walkTokens=function(t,e){return hr.walkTokens(t,e)};O.parseInline=hr.parseInline;O.Parser=Fe;O.parser=Fe.parse;O.Renderer=rs;O.TextRenderer=Wu;O.Lexer=ge;O.lexer=ge.lex;O.Tokenizer=ts;O.Hooks=Tn;O.parse=O;var JD=O.options,UD=O.setOptions,KD=O.walkTokens,YD=O.parseInline;var XD=Fe.parse,QD=ge.lex;V();rr();Ie();Xe();L();var zu=["outcome","scope","nonGoals","acceptanceExamples"],Qv=[...zu,"constraints","decisions","openQuestions","verificationExpectations"];var GR=new Set(["nonGoals","decisions","openQuestions"]),On=class extends Error{constructor(r,i,n){super(r);this.findings=i;this.change=n;this.name="NativeDocumentConstraintError"}findings;change},JR={maxFileBytes:fl};function UR(t){let e=new Map,r=null,i=[],n={marker:null,length:0},a=()=>{r!==null&&e.set(r,i.join(`
267
+ `).trim())};for(let o of t.split(/\r?\n/u)){let l=Dn(o,n)===null&&n.marker===null?/^# ([^#].*)$/u.exec(o):null;l?(a(),r=l[1].trim(),i=[]):r!==null&&i.push(o)}return a(),e}function Gu(t){return{valid:t.length===0,findings:t}}function Ju(t){let e=[],r=0;for(;r<t.length;){let i=t.indexOf("<!--",r);if(i<0){e.push(t.slice(r));break}e.push(t.slice(r,i));let n=t.indexOf("-->",i+4);if(n<0){e.push(t.slice(i));break}r=n+3}return e.join("")}function Uu(t){return Ju(t).trim()}function Hn(t){let e=Uu(t).split(/\r?\n/u),r=[],i={marker:null,length:0};for(let n of e)Dn(n,i)===null&&(i.marker===null&&/^\s*#{1,6}\s*$/u.test(n)||i.marker===null&&/^\s*#{1,6}\s+/u.test(n)||i.marker===null&&/^\s*(?:[-*+]\s*|\d+[.)]\s*)$/u.test(n)||r.push(n));return r.join(`
268
+ `).trim()}function KR(t){let e=Hn(t).replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/gmu,"").replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim().toLocaleLowerCase("en-US");return/^(?:none|n\/a|not applicable|no(?:ne)?(?:\s+at\s+this\s+time)?|no\s+(?:additional\s+)?(?:non-goals?|decisions?|open\s+questions?|questions?)|无|无相关事项|没有(?:额外)?(?:非目标|决定|待解决问题)|不适用|暂无)[.!。;;::,,、 -]*$/iu.test(e)}function Ku(t){let e=Hn(t).replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/gmu,"").replace(/\s+/gu," ").trim();if(e.length===0)return!1;let r=e.replace(/[*_`]/gu,"").replace(/^\s*>+\s?/gmu,"").replace(/\s+/gu," ").trim();if(/^(?:<[^>\r\n]+>|\{\{[^}\r\n]+\}\})[.!。;;::,,、 -]*$/iu.test(r))return!0;let i=e.replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim();return/^(?:(?:todo|tbd|fixme)(?:\s*[::-]\s*.+)?|fill(?:\s+this\s+in)?(?:\s*[::-]\s*.+)?|placeholder(?:\s*[::-]\s*.+)?|待填写\S*|待补充\S*|<[^>]+>|\{\{[^}]+\}\})[.!。;;::,,、 -]*$/iu.test(i)}function Zv(t,e){let r=[];return Hn(t).length===0?r.push({code:"spec-document-empty",message:`Native target Spec is empty: ${e}. Add the complete target requirements or use an explicit no-product-behavior exemption in brief.md.`,path:e}):Ku(t)&&r.push({code:"spec-document-placeholder",message:`Native target Spec contains only template placeholder content: ${e}. Replace it with complete target requirements.`,path:e}),Gu(r)}function Yu(t){let e=new Set(["blocker","blocking","coverage","decision","open_question","question","requirement","requirements","source","source_coverage","state","status","决策","来源","覆盖","问题","状态","需求","阻塞"]),r={marker:null,length:0};for(let i of t.split(/\r?\n/u)){if(Dn(i,r)!==null||r.marker!==null)continue;let n=i.trim();if(/^(?:[-*+]\s+|\d+[.)]\s+)(?:\[[ xX]\]\s+)?\[blocking\](?=$|[\s::—-])/iu.test(n)||n.includes("|")&&n.split("|").some(o=>/^\s*\[blocking\](?=$|[\s::—-])/iu.test(o)))return!0;let a=n.match(/^([\p{L}\p{N}_./-]+)\s*[::]\s*\[blocking\](?=$|[\s::—-])/iu);if(a){let o=a[1]?.toLocaleLowerCase("en-US")??"";if(e.has(o)||/[./_-]/u.test(o))return!0}}return!1}function Dn(t,e){let r=/^ {0,3}(`{3,}|~{3,})/u.exec(t);if(r===null)return null;let i=r[1]??"",n=i[0];return e.marker===null?(e.marker=n,e.length=i.length,"opened"):n===e.marker&&i.length>=e.length&&t.trim()===i?(e.marker=null,e.length=0,"closed"):null}function YR(t){let e=Uu(t).split(/\r?\n/u),r={marker:null,length:0},i=-1;for(let n=0;n<e.length;n+=1){let a=e[n]??"";if(Dn(a,r)!==null||r.marker!==null)continue;let o=/^##\s+(.+)$/u.exec(a);if(o!==null){if(i===-1){jh(o[1]??"")&&(i=n+1);continue}return e.slice(i,n).join(`
269
+ `)}}return i===-1?null:e.slice(i).join(`
270
+ `)}function XR(t){let e=new Map,r=null,i=[],n={marker:null,length:0},a=()=>{r!==null&&e.set(r,i.join(`
271
+ `).trim())};for(let o of Uu(t).split(/\r?\n/u)){if(Dn(o,n)!==null){r!==null&&i.push(o);continue}let s=n.marker===null?/^###\s+(.+)$/u.exec(o):null;s!==null?(a(),r=Oh(s[1]??""),i=[]):r!==null&&i.push(o)}return a(),e}function QR(t,e){let r=[],i=YR(t);if(i===null)return r.push({code:"brief-structure-missing",message:'Brief scope must include a "## Directory structure"/「## 目录结构」 section with the subsections Created/新建, Modified/修改, Deleted/删除, and Not created/明确不建',path:e}),r;let n=XR(i),a=[];for(let o of bl){let s=n.get(o);(s===void 0||Hn(s).length===0||Ku(s))&&a.push($h(o))}return a.length>0&&r.push({code:"brief-structure-subsection-missing",message:`Brief directory structure subsections are missing or empty: ${a.join(", ")}. Keep every heading and write "None"/「无」 when there is no content`,path:e}),r}async function Xu(t,e,r={}){let i=[],n;try{n=(await M({root:t,ref:e,maxBytes:JR.maxFileBytes})).text}catch(s){return Gu([{code:"brief-missing",message:s.message,path:e}])}let a=new Map;for(let[s,l]of UR(n))a.set(Ka(s)??s,l);for(let s of r.compact?zu:Qv)a.has(s)||i.push({code:"brief-section-missing",message:`Missing brief section: ${s}`,path:e});let o=r.strict?Qv.filter(s=>!r.compact||a.has(s)):zu;for(let s of o){let l=a.get(s)??"";Hn(l).length===0?i.push({code:"brief-section-empty",message:`Brief section is empty: ${s}`,path:e}):Ku(l)?i.push({code:"brief-section-placeholder",message:`Brief section contains only template placeholder content: ${s}`,path:e}):r.strict&&!GR.has(s)&&KR(l)&&i.push({code:"brief-section-empty",message:`Brief section must describe the confirmed work instead of declaring no items: ${s}`,path:e})}return r.strict&&r.structure&&i.push(...QR(a.get("scope")??"",e)),Yu(n)&&i.push({code:"brief-blocking-question",message:"Brief has a blocking open question",path:e}),Gu(i)}Ie();U();var R_=kt(at(),1);et();Ie();U();he();L();Bt();os();os();di();Wt();et();fo();V();U();cs();Z();L();cg();di();Wt();td();et();he();td();fn();L();var ls=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};et();he();Z();di();Wt();function rd(t){return H("comet.native.parent-contract.v1",{acceptance:t.acceptance.map(({id:e,source:r,text:i})=>({id:e,source:r,text:i})),children:t.children})}Po();Bt();ur();Ln();ss();function pg(t){return t.state_version+1}function A_(t){return t.map(e=>({...e,result:"pending",reason:null}))}function I_(t){return{goal_cycle:t.state.loop.goal_cycle,iteration:t.state.loop.iteration,attempt:t.state.loop.attempt,outcome:t.outcome,unresolved_ids:t.unresolvedIds??[],summary:mt(t.summary),completed_at:t.completedAt}}function us(t){let e=De(t.state);if(e.phase!=="verify"&&e.phase!=="archive")throw new Error("Only Verify or Archive can return a candidate to Build");let r=t.failureBudget,i=r?e.loop.failed_iteration_count+1:e.loop.failed_iteration_count,n=r!==void 0&&i>=r.maxVerifyFailures,a=(t.now??new Date).toISOString(),o=ei(e,I_({state:e,outcome:"recovery",summary:t.reason,completedAt:a})),s=new Set(e.loop.previous_unresolved_ids),l=s.size===0?A_(e.acceptance):e.acceptance.map(c=>s.has(c.id)?{...c,result:"pending",reason:null}:c);return n?De({...o,phase:"verify",status:"await-user",state_version:pg(e),verification_result:"fail",builder_handoff:e.builder_handoff,blockers:[{owner:"user",reason:mt(`Native Runtime checks failed at Builder handoff and reached the configured failed iteration limit: ${t.reason}`),acceptance_ids:[...s],resolution_action:"await-user"}],loop:{...e.loop,stage:"await-user",failed_iteration_count:i,execution_failure_count:0,stop_reason:"budget",next_action:"resolve-loop-stop"}}):De({...o,phase:"build",status:"active",state_version:pg(e),verification_result:"pending",verification_report:null,verification:null,builder_handoff:e.builder_handoff,blockers:[],acceptance:l,loop:{...e.loop,stage:"repairing",iteration:e.loop.iteration+1,attempt:0,execution_failure_count:0,failed_iteration_count:i,stop_reason:void 0,next_action:"submit-builder-candidate"}})}Z();ou();bo();Bt();ur();V();rr();Ln();L();rr();mi();he();var ad=kt(at(),1);st();var cM=new Set("a an and are as at be by for from in is it of on or that the this to with you your".split(" "));var gg=5,F_=600,hM=256*1024,V_=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,q_=/^[A-Za-z0-9][A-Za-z0-9._-]*$/u;var W_=/^[a-f0-9]{64}$/iu;function wg(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function zt(t,e,r=4096){if(typeof t!="string"||t.trim().length===0||t.length>r)throw new Error(`${e} must be a non-empty string within the association limit`);return t}function nd(t,e){let r=zt(t,e).replaceAll("\\","/");if(r.startsWith("/")||/^[A-Za-z]:/u.test(r)||r.split("/").some(i=>i===""||i==="."||i===".."))throw new Error(`${e} must be a project-relative path`);return r}function z_(t,e){let r=zt(t,e,64).toLowerCase();if(!W_.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function G_(t,e){let r=`Capability association evidence[${e}]`,i=wg(t,r),n=Object.keys(i).filter(a=>!new Set(["source","kind","title","snippet"]).has(a));if(n.length>0)throw new Error(`${r} has unknown field(s): ${n.join(", ")}`);return{source:nd(i.source,`${r}.source`),kind:zt(i.kind,`${r}.kind`,128),...i.title===void 0?{}:{title:zt(i.title,`${r}.title`)},...i.snippet===void 0?{}:{snippet:zt(i.snippet,`${r}.snippet`,F_)}}}function yg(t){let e=typeof t=="string"?(()=>{if(t.length>65536)throw new Error("Capability association exceeds the size limit");let c=(0,ad.parseDocument)(t,{uniqueKeys:!0});if(c.errors.length>0)throw new Error(c.errors[0].message);return c.toJS({mapAsMap:!1})})():t,r=wg(e,"Capability association"),i=Object.keys(r).filter(c=>!new Set(["schema","status","workflow","capability","current_spec","current_hash","confidence","query","reason","historical_sources","evidence"]).has(c));if(i.length>0)throw new Error(`Capability association has unknown field(s): ${i.join(", ")}`);if(r.schema!=="comet.capability-association.v1")throw new Error("Unsupported capability association schema");let n=r.workflow;if(n!=="native"&&n!=="classic")throw new Error("Capability association workflow is invalid");let a=J_(zt(r.capability,"Capability association capability"),n);if(!Array.isArray(r.historical_sources))throw new Error("Capability association historical_sources must be an array");let o=r.historical_sources.map((c,u)=>nd(c,`Capability association historical_sources[${u}]`));if(!Array.isArray(r.evidence)||r.evidence.length>gg)throw new Error(`Capability association evidence must contain at most ${gg} entries`);let s=r.status;if(s!=="suggested"&&s!=="explicit")throw new Error("Capability association status is invalid");let l=r.confidence;if(l!=="high"&&l!=="medium"&&l!=="low")throw new Error("Capability association confidence is invalid");return{schema:"comet.capability-association.v1",status:s,workflow:n,capability:a,current_spec:nd(r.current_spec,"Capability association current_spec"),current_hash:z_(r.current_hash,"Capability association current_hash"),confidence:l,...r.query===void 0?{}:{query:zt(r.query,"Capability association query")},reason:zt(r.reason,"Capability association reason",2048),historical_sources:o,evidence:r.evidence.map(G_)}}function J_(t,e){let r=t.replaceAll("\\","/").replace(/^\/+|\/+$/gu,""),i=r.split("/"),n=e==="native"?V_:q_;if(!r||i.some(a=>!n.test(a)))throw new Error(`Invalid ${e} capability: ${t}`);return i.join("/")}Bt();ur();Wt();var Q_=Ya("en",{compact:!0}),Ng="capability-association.yaml";function hs(t,e=!1){if(e){let i=n=>{if(Array.isArray(n))return n.filter(a=>a?.type!=="space").map(i);if(n&&typeof n=="object"){let a=n;return Object.fromEntries(Object.entries(a).filter(([o])=>o!=="raw"&&!(o==="text"&&Array.isArray(a.tokens))).map(([o,s])=>[o,o==="text"&&a.type==="text"&&typeof s=="string"?s.replace(/[\t ]*\n[\t ]*/gu," "):i(s)]))}return n};return JSON.stringify(i(ge.lex(t.replace(/\r\n?/gu,`
272
+ `))))}let r=t.replace(/\r\n?/gu,`
273
+ `).split(`
274
+ `);for(;r.length>0&&r.at(-1)?.trim().length===0;)r.pop();return`${r.map(i=>i.replace(/[\t ]+$/gu,"")).join(`
275
+ `)}
276
+ `}function Z_(t){let e=t.replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/u,"").replace(/\s+/gu," ").trim();if(e.length===0||/^(?:<[^>\r\n]+>|\{\{[^}\r\n]+\}\})[.!:: -]*$/iu.test(e))return!0;let r=e.replace(/[*_`>#\x5b\x5d()]/gu," ").replace(/\s+/gu," ").trim();return/^(?:todo|tbd|fixme)(?:\s*[::-]|\s*$)/iu.test(r)||/^(?:fill(?:\s+this\s+in)?|placeholder)\b/iu.test(r)||/^(?:待填写|待补充)/u.test(r)?!0:/^(?:(?:todo|tbd|fixme)\b|fill(?:\s+this\s+in)?\b|placeholder\b|documentation[- ]only\b|no\s+product\s+behavior\s+change\b|待填写|待补充|仅文档|不改变产品行为|不涉及产品行为)[.!。;;::,,、 -]*$/iu.test(r)}function eA(t){let e=[],r=!1;for(let i of Ju(t).split(/\r?\n/u)){if(/^\s*(?:```|~~~)/u.test(i)){r=!r;continue}!r&&!/^\s*#{1,6}\s+/u.test(i)&&e.push(i)}return e.some(i=>{let n=/(?:no\s+product\s+behavior\s+change|documentation[- ]only|不改变产品行为|不涉及产品行为|仅文档)\s*[::]\s*(.*)$/iu.exec(i);return n!==null&&!Z_(n[1]??"")})}async function kg(t){let e=se(t.paths,t.state.name),r=t.state.document_constraints_version,i=r===2||r===3,n=r===3,a=[...(await Xu(e,t.state.brief,{strict:!0,compact:i,structure:n})).findings],o="";try{o=(await M({root:e,ref:t.state.brief,maxBytes:null,includeHash:!1})).text}catch{}let s=t.specChanges??t.state.spec_changes,l=s.filter(({operation:f})=>f!=="remove"),c=t.state.spec_changes.filter(({operation:f})=>f!=="remove"),u=new Set(l.map(({capability:f})=>f));if(t.specChanges!==void 0)for(let f of c)u.has(f.capability)||a.push({code:"spec-document-missing",message:`Previously declared target Spec is missing: specs/${f.capability}/spec.md. Restore the complete file or record the intended capability deletion as a formal remove entry.`,path:`specs/${f.capability}/spec.md`});let d=s.length>0&&s.every(({operation:f})=>f==="remove");l.length===0&&c.length===0&&!d&&!eA(o)&&a.push({code:"spec-exemption-missing",message:"This change declares no target Spec. Add a complete target Spec, or record a concrete reason such as “No product behavior change: documentation-only wording.” in brief.md.",path:t.state.brief});for(let f of l){let p=`specs/${f.capability}/spec.md`;if(f.source!==p){a.push({code:"spec-source-path-invalid",message:`Target Spec must be staged at ${p}.`,path:f.source??p});continue}try{let v=(await M({root:e,ref:p,maxBytes:null,includeHash:!1})).text;a.push(...Zv(v,p).findings)}catch(v){a.push({code:"spec-document-missing",message:`Target Spec cannot be read: ${v.message}. Restore the complete file at ${p}.`,path:p})}}return{valid:a.length===0,findings:a}}function Mn(t){let e=t.expected;if(e){if(t.state.state_version!==e.stateVersion)throw new Error(`Native continuation is stale: the change moved on since the referenced response (current phase ${t.state.phase}, next action ${t.state.loop.next_action}, state version ${t.state.state_version}). Run comet native status ${t.state.name} --json and execute its commandAlternatives with --expected-state-version ${t.state.state_version} --expected-action ${t.state.loop.next_action}.`);if(e.action!==t.action)throw new Error(`Native continuation expected ${e.action} cannot be used for ${t.action}`)}}async function Sg(t){let e=se(t.paths,t.state.name),r=kr.join(e,"specs"),i=new Map(t.state.spec_changes.filter(({operation:o})=>o==="remove").map(o=>[o.capability,o])),n;try{n=await ps.readdir(r,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")n=[];else throw o}let a=[];for(let o of n.sort((s,l)=>s.name.localeCompare(l.name,"en"))){if(o.isSymbolicLink())throw new Error(`Native spec capability is unsafe: ${o.name}`);if(!o.isDirectory())continue;if(!fr.test(o.name))throw new Error(`Invalid Native capability: ${o.name}`);if(i.has(o.name))throw new Error(`Capability ${o.name} cannot be proposed and removed together`);let s=`specs/${o.name}/spec.md`,l=kr.join(e,...s.split("/")),c=await ps.lstat(l);if(!c.isFile()||c.isSymbolicLink())throw new Error(`Native proposed spec must be a regular file: ${s}`);let u=kr.join(t.paths.specsDir,o.name,"spec.md"),d="create",f=null;try{let m=await ps.lstat(u);if(!m.isFile()||m.isSymbolicLink())throw new Error(`Canonical Native spec is unsafe: ${o.name}`);d="modify",f=lt((await M({root:t.paths.specsDir,ref:`${o.name}/spec.md`,maxBytes:null,includeHash:!1})).text)}catch(m){if(m.code!=="ENOENT")throw m}let p=`specs/${o.name}/${Gr}`,v=kr.join(e,...p.split("/")),h={};try{let m=await ps.lstat(v);if(!m.isFile()||m.isSymbolicLink())throw new Error(`Native delta manifest must be a regular file: ${p}`);let w=await M({root:e,ref:p,maxBytes:null,includeHash:!1}),g=pn(w.text);if(g.capability!==o.name)throw new Error(`Native delta capability ${g.capability} does not match directory ${o.name}`);let b=f??lt(""),E=t.state.spec_changes.find(S=>S.capability===o.name);if(E?.delta_source!==void 0){if(E.base_hash!==g.base_hash)throw new Error(`Native delta base changed for ${o.name}; explicit conversion is required`)}else if(g.base_hash!==b)throw new Error(`Native delta base_hash does not match the current total Spec for ${o.name}`);h={delta_source:p,base_hash:g.base_hash}}catch(m){if(m.code!=="ENOENT")throw m}a.push({capability:o.name,operation:d,source:s,...h})}return a.push(...i.values()),a.sort((o,s)=>o.capability.localeCompare(s.capability,"en"))}async function Eg(t){let e=se(t.paths,t.state.name),r=await M({root:e,ref:"brief.md",maxBytes:null,includeHash:!1});if(Yu(r.text))throw new Error("Brief has a blocking open question");let i=[],n=[];for(let o of t.specChanges){if(o.source===null){n.push({...o,contentHash:null});continue}let s=await M({root:e,ref:o.source,maxBytes:null,includeHash:!1}),l=s.text,c=null;if(o.delta_source){let u=await M({root:e,ref:o.delta_source,maxBytes:null,includeHash:!1}),d=pn(u.text);l=bm(s.text,d);let f="";try{f=(await M({root:t.paths.specsDir,ref:`${o.capability}/spec.md`,maxBytes:null,includeHash:!1})).text}catch(p){if(p.code!=="ENOENT")throw p}if(lt(f)===d.base_hash){let p=Sm({baselineMarkdown:f,delta:d,allowAlreadyApplied:!0});if(lt(s.text)!==p.result_hash)throw new Error(`Native full target Spec does not match delta result for ${o.capability}; update the complete target before confirming Shape`)}c=H("comet.native.shape-artifact-content.v1",hs(u.text))}i.push({capability:o.capability,source:s.ref,markdown:l}),n.push({...o,contentHash:H("comet.native.shape-artifact-content.v1",hs(s.text,t.state.document_constraints_version!==void 0&&t.state.document_constraints_version!==1)),...c===null?{}:{deltaContentHash:c}})}let a=null;try{let o=await M({root:e,ref:Ng,maxBytes:65536,includeHash:!1}),s=yg(o.text);if(s.workflow!=="native")throw new Error("Native capability association must use the native workflow");if(!t.specChanges.some(({capability:u})=>u===s.capability))throw new Error(`Native capability association ${s.capability} is not declared by this change`);let c=kr.relative(t.paths.projectRoot,kr.join(t.paths.specsDir,s.capability,"spec.md")).replaceAll(kr.sep,"/");if(s.current_spec!==c)throw new Error(`Native capability association points to ${s.current_spec}, expected ${c}`);a=H("comet.native.shape-artifact-content.v1",hs(o.text))}catch(o){if(o.code!=="ENOENT")throw o}return{acceptance:Dm({briefMarkdown:r.text,specs:i,resolveBriefReferences:t.state.document_constraints_version!==void 0&&t.state.document_constraints_version!==1}),formalHash:H("comet.native.shape-formal-artifacts.v1",{brief:{source:r.ref,contentHash:H("comet.native.shape-artifact-content.v1",hs(r.text,t.state.document_constraints_version!==void 0&&t.state.document_constraints_version!==1))},specs:n,association:{source:Ng,contentHash:a}})}}function xg(t){return H("comet.native.shape-confirmation.v1",{formalHash:t.formalHash,childrenHash:t.childrenHash,coordinationMode:t.coordinationMode??null})}async function sd(t){if(t.state.document_constraints_version!==void 0){let c=await kg(t);if(!c.valid){let u=c.findings[0];return{drifted:!0,reason:u?`Native formal documents are invalid (${u.code}${u.path?`: ${u.path}`:""})`:"Native formal documents are invalid"}}}let e=await Sg(t),r=t.ignoreSpecOperationFor??(t.state.children_contract_hash?new Set(t.state.spec_changes.map(({capability:c})=>c)):void 0);if(!(e.length===t.state.spec_changes.length&&e.every((c,u)=>{let d=t.state.spec_changes[u];return d!==void 0&&c.capability===d.capability&&c.source===d.source&&c.delta_source===d.delta_source&&c.base_hash===d.base_hash&&(c.operation===d.operation||r?.has(c.capability)===!0)})))return{drifted:!0,reason:"Native target specification declarations changed"};let n;try{n=await Eg({...t,specChanges:e})}catch{return{drifted:!0,reason:"Native Shape artifacts changed or became invalid"}}let{acceptance:a}=n,o=t.state.acceptance.map(({source:c,text:u})=>({source:c,text:u}));if(!Lm(o,a))return{drifted:!0,reason:"Native confirmed acceptance criteria changed"};let s;try{s=await yr({changeDir:se(t.paths,t.state.name),acceptanceIds:a.map(({id:c})=>c),validation:wr({...t.state,acceptance:a})})}catch{return{drifted:!0,reason:"Native child declarations changed"}}return t.state.phase==="shape"&&t.state.status==="await-user"&&t.state.loop.next_action==="confirm-shape"&&t.state.shape_confirmation_hash===void 0?{drifted:!0,reason:"Native Shape confirmation fingerprint is missing"}:t.state.shape_confirmation_hash!==void 0&&xg({formalHash:n.formalHash,childrenHash:s?.hash??null,coordinationMode:t.state.coordination_mode})!==t.state.shape_confirmation_hash?{drifted:!0,reason:"Native Shape artifacts changed"}:(s?rd({acceptance:a,children:s.contract}):null)===(t.state.children_contract_hash??null)?{drifted:!1,reason:null}:{drifted:!0,reason:"Native child declarations changed"}}async function ms(t){return Y(t.paths,`return portable change ${t.name} to Shape`,async()=>{let e=await fe(t.paths,t.name);if(Mn({state:e,expected:t.expectedContinuation,action:"revise-requirements"}),t.allowedPhases&&!t.allowedPhases.includes(e.phase))throw new Error("--revise-requirements is only valid from Verify or Archive");return e.phase==="shape"?e:cd({paths:t.paths,state:e,reason:t.reason,...t.keepFailureBudget?{keepFailureBudget:!0}:{}})})}async function cd(t){let{state:e}=t;if(e.archived)throw new Error(`Native change ${e.name} is already archived`);let i={...ei(e,{goal_cycle:e.loop.goal_cycle,iteration:e.loop.iteration,attempt:e.loop.attempt,outcome:"recovery",unresolved_ids:[],summary:mt(t.reason),completed_at:new Date().toISOString()}),phase:"shape",status:"active",state_version:e.state_version+1,acceptance:[],builder_handoff:null,blockers:[],verification:null,verification_result:"pending",verification_report:null,loop:{stage:"shape",goal_cycle:e.loop.goal_cycle+1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:t.keepFailureBudget?e.loop.failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:"prepare-shape-confirmation"}};delete i.shape_confirmation_hash,delete i.children_contract_hash;let n=await Vt({paths:t.paths,previous:e,next:i});return await Ft(tt(t.paths,e.name),gt({portableState:n,projectRoot:t.paths.projectRoot,branch:wt(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),n}he();Z();di();Wt();Bt();ur();import{createHash as TF,randomUUID as rA}from"node:crypto";et();fo();U();et();st();V();var bF=8*1024*1024;cs();Z();ur();L();var GF=1024*1024*1024;function Pg(t){if(t.local===null||t.local.change!==t.state.name)return gt({portableState:t.state,projectRoot:t.projectRoot,branch:wt(t.projectRoot)});let e=t.local.execution?.operationId??rA();return{...t.local,basedOnStateVersion:t.state.state_version,execution:{operationId:e,stage:"checking",actor:"runtime",executionId:null,status:"completed",startedAt:t.local.execution?.startedAt??new Date().toISOString(),requestCheckRounds:0},checks:t.local.checks.map(r=>r.status==="running"||r.status==="planned"?{...r,operationId:e,status:"interrupted"}:{...r,operationId:e})}}async function Rg(t){try{let e=await Xo(tt(t.paths,t.state.name));return e===null||e.change!==t.state.name||e.basedOnStateVersion!==t.state.state_version?null:e}catch{return null}}Z();ss();Ln();async function ld(t){return Y(t.paths,`return portable change ${t.name} to Build`,async()=>{let e=await fe(t.paths,t.name);if(Mn({state:e,expected:t.expectedContinuation,action:"revise-implementation"}),e.phase==="build")return e;let r=t.preserveLocalChecks!==!1,i=r?await Rg({paths:t.paths,state:e}):null,n=us({state:e,reason:t.reason,...t.failureBudget?{failureBudget:t.failureBudget}:{}}),a=await Vt({paths:t.paths,previous:e,next:n});return await Ft(tt(t.paths,e.name),r?Pg({local:i,state:a,projectRoot:t.paths.projectRoot}):gt({portableState:a,projectRoot:t.paths.projectRoot,branch:wt(t.paths.projectRoot)}),{containedRoot:t.paths.runtimeDir}),a})}Wt();Z();Wt();Z();vu();var Tq=16*1024;async function iA(t){let e=await xu(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(Kr(e.selection.change),e.selection)}async function _g(t){let e=await iA(t);return e?(await ci(t,e.change)?await fe(t,e.change):await Me(t,e.change),e.change):null}bo();var pd=Er("nativeHookProjectConfig",be);async function ud(t){Ss();try{return await t()}finally{Ss()}}var aA=new Set(["brief.md","children.yaml","comet-state.yaml","verification.md","capability-association.yaml"]),Ig=new Set(["comet-state.yaml","verification.md","capability-association.yaml"]);function hd(t){let e=t.split("/");return e.length===3&&e[0]==="specs"&&e[1]!==void 0&&fr.test(e[1])&&(e[2]==="spec.md"||e[2]===Gr)}function gs(t,e){if(!te(t,e))return null;let r=I.relative(t,e).replaceAll("\\","/"),[i,...n]=r.split("/");if(!i||!fr.test(i))return null;if(n.length===0)return{name:i,relative:""};let a=n.join("/");return aA.has(a)?{name:i,relative:a}:hd(a)?{name:i,relative:a}:null}function oA(t,e){return te(t.runtimeDir,e)||I.relative(t.projectRoot,e).replaceAll("\\","/")===".comet/current-change.json"}function sA(t,e,r){let i=I.join(t.projectRoot,".comet","comet");if(te(t.nativeRoot,e)||I.resolve(i)===I.resolve(t.nativeRoot))return null;let n=gs(I.join(i,"changes"),e);return n&&r.has(n.name)?n:null}function Tg(t){return t==="brief.md"?"data.artifacts.briefPath":t==="children.yaml"?"data.artifacts.childrenPath":t.startsWith("specs/")?"data.artifacts.specsDir":"data.artifacts.changeDir"}function $g(t,e,r){return`Published Native specs are updated through Archive. Read ${I.join(t,"specs",I.relative(e,r))}, merge the original edit there, and retry the write against that exact target; do not overwrite existing content.`}function Ag(t,e,r,i={}){if(!te(t,r))return null;if(oA(e,r)){let s=I.relative(e.projectRoot,r).replaceAll("\\","/"),l=s.match(/^\.comet\/runtime\/native\/changes\/([^/]+)(?:\/|$)/u)?.[1];return{allowed:!1,reason:`Native Runtime-owned path ${s}. Run ${l?`comet native status ${l} --json`:"comet native status --json"} in ${e.projectRoot}, follow its continuation, and retry; do not edit Runtime files directly.`,workflow:"native",...l?{change:l}:{}}}let n=sA(e,r,i.registeredChanges??new Set);if(n){let s=I.join(e.changesDir,n.name,n.relative);return{allowed:!1,reason:`Native formal artifact target ${I.relative(t,r).replaceAll("\\","/")} is outside the configured artifact root. Use ${s} in ${e.projectRoot}; read existing content and merge the original edit instead of overwriting it.`,workflow:"native",change:n.name}}let a=gs(e.changesDir,r);if(!a)return null;if(Ig.has(a.relative))return{allowed:!1,reason:`Native Runtime-owned artifact ${I.relative(t,r).replaceAll("\\","/")}. Run comet native status ${a.name} --json in ${e.projectRoot} and follow its continuation; do not infer a mutation or edit the file directly.`,workflow:"native",change:a.name};if(i.allowCanonicalFormal===!1)return null;let o=I.join(e.changesDir,a.name,a.relative);return{allowed:!1,reason:`Native formal artifact target ${I.relative(t,r).replaceAll("\\","/")} is not registered. Run comet native new ${a.name} in ${e.projectRoot}. Use the response ${Tg(a.relative)} to locate ${o}; read initialized or existing content and merge the original edit instead of overwriting it.`,workflow:"native",change:a.name}}function dd(t){return t.length===0?null:t.length===1?t[0]:{...t[0],reason:t.map(e=>e.reason).join(`
277
+ `)}}function cA(t,e,r,i,n,a){let o=I.relative(t,n).replaceAll("\\","/"),s=I.join(e.changesDir,i.name,i.relative);return{allowed:!1,reason:a?`Native formal artifact target ${o} belongs to registered change ${i.name}, not selected change ${r}. Run comet native select ${i.name} in ${e.projectRoot}, then read ${s} and merge the original edit.`:`Native formal artifact target ${o} belongs to unregistered change ${i.name}, not selected change ${r}. Run comet native new ${i.name} --isolation worktree in ${e.projectRoot}. Use the response ${Tg(i.relative)} to locate ${s}; read initialized or existing content and merge the original edit.`,workflow:"native",change:r}}function fd(t){let e=`Native change ${t.name} is in ${t.phase}; implementation writes are only allowed in Build.`;return t.phase==="shape"?`${e} Reread the latest continuation, complete requirement clarification, and execute the Shape confirmation command after user confirmation.`:t.phase==="verify"?`${e} Select and execute the matching commandAlternative from the latest continuation, preserving --expected-state-version and --expected-action.`:t.phase==="archive"?`${e} Continue finalizing the accepted result; do not run Verify-only revision commands from Archive.`:`${e} Create or select a separate Native change if this write belongs to different work.`}async function lA(t){let{projectRoot:e,paths:r,state:i,request:n}=t,a=se(r,i.name),o=[],s=[],l=[],c=[],u=[],d=await jg(e),f=!1,p=!1,v=!1;for(let h of n.targets){let m=I.resolve(e,h);if(!te(e,m)){v=!0;continue}let w=I.relative(e,m).replaceAll("\\","/");if(w===".comet/config.yaml"){p=!0;continue}if(!te(r.nativeRoot,m)){if(await qo(e,m,[I.join(e,".comet"),r.nativeRoot])){f=!0;continue}if(!d&&Og(r,w)){c.push(w);continue}l.push(w);continue}if(!te(a,m)){u.push({allowed:!1,reason:te(r.specsDir,m)?$g(a,r.specsDir,m):"Portable Native control state is Runtime-owned",workflow:"native",phase:i.phase,change:i.name});continue}let g=I.relative(a,m).replaceAll("\\","/");if(g==="brief.md"||g==="children.yaml"||g.startsWith("specs/")&&uA(g)){o.push(g);continue}if(g.startsWith("specs/")){s.push(g);continue}u.push({allowed:!1,reason:`${g||"change directory"} is Runtime-owned and cannot be edited by the Agent`,workflow:"native",phase:i.phase,change:i.name})}if(s.length>0&&u.push({allowed:!1,reason:s.map(Hg).join(`
278
+ `),workflow:"native",phase:i.phase,change:i.name}),u.length>0)return dd(u);if(o.length>0&&(l.length>0||c.length>0))return{allowed:!1,reason:"Formal Native requirements must be edited in separate actions from implementation or documentation files",workflow:"native",phase:i.phase,change:i.name};if(o.length>0)return(i.document_constraints_version===2||i.document_constraints_version===3)&&o.every(h=>h==="brief.md"||/^specs\/[^/]+\/spec\.md$/u.test(h))?{allowed:!0,reason:"Native formal Markdown edit; Runtime rechecks the actual content before an implementation write or workflow transition",workflow:"native",phase:i.phase,change:i.name}:i.phase!=="shape"?{allowed:!0,reason:`Native requirements changed; returned to Shape goal cycle ${(await ud(()=>ms({paths:r,name:i.name,reason:`Formal requirement write requested for ${o.join(", ")}`}))).loop.goal_cycle}`,workflow:"native",phase:"shape",change:i.name}:{allowed:!0,reason:"Native control artifact write",workflow:"native",phase:i.phase,change:i.name};if(l.length>0){if((i.document_constraints_version===2||i.document_constraints_version===3)&&i.phase!=="shape"){let h=await sd({paths:r,state:i});if(h.drifted){let m=await ud(()=>ms({paths:r,name:i.name,reason:h.reason??"Native confirmed requirements changed",keepFailureBudget:!0}));return{allowed:!1,reason:fd(m),workflow:"native",phase:m.phase,change:m.name}}}return i.children_contract_hash?{allowed:!1,reason:"Native parent Build advances child changes instead of editing implementation",workflow:"native",phase:i.phase,change:i.name}:i.phase==="build"?{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:i.phase,change:i.name}:i.phase==="verify"||i.phase==="archive"?{allowed:!0,reason:`Native candidate was invalidated and returned to Build iteration ${(await ud(()=>ld({paths:r,name:i.name,reason:`Observed implementation write before ${l.join(", ")}`}))).loop.iteration}`,workflow:"native",phase:"build",change:i.name}:{allowed:!1,reason:fd(i),workflow:"native",phase:i.phase,change:i.name}}return c.length>0?{allowed:!0,reason:"Native neutral document write: documentation edits stay outside the implementation scope and do not return the change to Build",workflow:"native",phase:i.phase,change:i.name}:f?{allowed:!0,reason:"Native configured Hook allow path",workflow:"native",phase:i.phase,change:i.name}:{allowed:!0,reason:p?"Native control artifact write":v?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:i.phase,change:i.name}}function te(t,e){let r=I.relative(t,e);return r===""||!r.startsWith("..")&&!I.isAbsolute(r)}async function jg(t){return(await pd(t))?.native?.document_writes==="revert"}function Og(t,e){return Av(e,[I.relative(t.projectRoot,t.nativeRoot).replaceAll("\\","/"),".comet"])}function Hg(t){let e=t.split("/"),r=e[0]==="specs"&&e[1]&&fr.test(e[1])?e[1]:null;return`Native formal Spec artifacts must use ${r?`specs/${r}/spec.md (or specs/${r}/${Gr} for delta metadata)`:`specs/<capability>/spec.md (or specs/<capability>/${Gr} for delta metadata)`}; received ${t}`}function uA(t){return hd(t)}function dA(t,e,r){return r.targets.length>0&&r.targets.every(i=>{let n=I.resolve(t,i);return te(t,n)?I.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||te(e,n):!0})}async function fA(t){let e=await pd(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let r=await Lt(t,e.native.artifact_root),i;try{i=await nA.readdir(r.changesDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return{paths:r,changes:[]};throw a}let n=[];for(let a of i.sort((o,s)=>o.name.localeCompare(s.name)))if(!(!a.isDirectory()||a.isSymbolicLink()))if(await ci(r,a.name)){let o=await fe(r,a.name);o.archived||n.push({kind:"portable",state:o})}else{let o=await Me(r,a.name);o.archived||n.push({kind:"legacy",state:o})}return{paths:r,changes:n}}async function pA(t,e){let r=await pd(t);if(!r||!(r.workflows??[r.default_workflow]).includes("native"))return null;let i=await Lt(t,r.native.artifact_root);try{if(await ci(i,e)){let a=await fe(i,e);return{paths:i,changes:a.archived?[]:[{kind:"portable",state:a}]}}let n=await Me(i,e);return{paths:i,changes:n.archived?[]:[{kind:"legacy",state:n}]}}catch(n){if(n.code==="ENOENT")return{paths:i,changes:[]};throw n}}var hA=Er("nativeActiveContext",t=>fA(t)),Dg=Er("selectedNativeContext",pA);async function mA(t,e){let i=(await Dg(t,e))?.changes[0]?.state;return i?{workflow:"native",name:i.name,phase:i.phase}:null}async function Lg(){let{intent:t,targets:e}=await _d();return{intent:t,targets:e}}async function Bg(t,e,r){e={...e,targets:gi(e.targets)};let i=r?await Dg(t,r):await hA(t);if(!i)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.changes.length===0){let h=[];for(let w of e.targets){let g=Ag(t,i.paths,I.resolve(t,w));g&&h.push(g)}let m=dd(h);return m||{allowed:!0,reason:dA(t,i.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"}}let n;if(r){if(n=i.changes.find(h=>h.state.name===r),!n)return{allowed:!1,reason:`Selected Native change ${r} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:r}}else if(i.changes.length===1)n=i.changes[0];else{let h=await _g(i.paths);if(n=i.changes.find(m=>m.state.name===h),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}let a=n.state,o=new Set(i.changes.map(({state:h})=>h.name)),s=new Map,l=[];for(let h of e.targets){let m=I.resolve(t,h),w=Ag(t,i.paths,m,{allowCanonicalFormal:!1,registeredChanges:o});if(w){l.push(w);continue}let g=gs(i.paths.changesDir,m);if(g&&g.name!==a.name){let S=o.has(g.name);if(!S&&r){let y=s.get(g.name);y||(y=mA(t,g.name).then(Boolean),s.set(g.name,y)),S=await y}l.push(cA(t,i.paths,a.name,g,m,S));continue}if(!te(t,m))continue;if(te(i.paths.specsDir,m)){let S=n.kind==="portable"?se(i.paths,a.name):Ze(i.paths,a.name);l.push({allowed:!1,reason:$g(S,i.paths.specsDir,m),workflow:"native",phase:a.phase,change:a.name});continue}if(!te(i.paths.nativeRoot,m))continue;let b=n.kind==="portable"?se(i.paths,a.name):Ze(i.paths,a.name);if(te(b,m)){let S=I.relative(b,m).replaceAll("\\","/");if(S==="brief.md"||S==="children.yaml"||hd(S))continue;l.push({allowed:!1,reason:S.startsWith("specs/")?Hg(S):`${S||"change directory"} is Runtime-owned. Run comet native status ${a.name} --json in ${i.paths.projectRoot} and follow its continuation; do not edit it directly.`,workflow:"native",phase:a.phase,change:a.name});continue}let E=I.relative(t,m).replaceAll("\\","/");l.push({allowed:!1,reason:`Native-managed path ${E} is not an editable artifact for ${a.name}. Run comet native status ${a.name} --json in ${i.paths.projectRoot} and follow its continuation.`,workflow:"native",phase:a.phase,change:a.name})}let c=dd(l);if(c)return c;if(n.kind==="legacy"&&a.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:a.phase,change:a.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:a.phase,change:a.name};if(n.kind==="portable")return lA({projectRoot:t,paths:i.paths,state:n.state,request:e});let u=!1,d=!1,f=!1,p=!1,v=await jg(t);for(let h of e.targets){let m=I.resolve(t,h);if(!te(t,m)){d=!0;continue}let w=I.relative(t,m).replaceAll("\\","/");if(w===".comet/config.yaml"){u=!0;continue}if(te(i.paths.nativeRoot,m)){let g=gs(i.paths.changesDir,m);if(g?.name===a.name){if(Ig.has(g.relative))return{allowed:!1,reason:`Native control state is Runtime-owned; use the CLI for ${w}`,workflow:"native",phase:a.phase,change:a.name};u=!0;continue}return{allowed:!1,reason:`Native control state is Runtime-owned; use the CLI for ${w}`,workflow:"native",phase:a.phase,change:a.name}}if(await qo(t,m,[I.join(t,".comet"),i.paths.nativeRoot])){f=!0;continue}if(!v&&Og(i.paths,w)){p=!0;continue}return{allowed:!1,reason:fd(a),workflow:"native",phase:a.phase,change:a.name}}return{allowed:!0,reason:u?"Native control artifact write":d?"Write target is outside the guarded project":f?"Native configured Hook allow path":p?"Native neutral document write: documentation edits stay outside the implementation scope":"No guarded write target was provided",workflow:"native",phase:a.phase,change:a.name}}sn();import Vn from"path";import{realpathSync as iI}from"fs";function Mg(t,e){let r=u=>u!==null&&typeof u=="object"&&!Array.isArray(u)?u:{},i=r(t),n=r(i.entry),a=r(i.state??n.state??i),o=r(i.preparation??i.workspace??n.workspace),s=r(i.continuation??n.continuation),l=typeof o.projectRoot=="string"&&o.projectRoot!=="."?o.projectRoot:e??null,c=a.stateVersion??a.state_version;return{phase:typeof a.phase=="string"?a.phase:null,status:typeof a.status=="string"?a.status:null,stateVersion:typeof c=="number"?c:null,workspace:{cwd:l},continuation:Object.keys(s).length?{...s,cwd:l}:null}}var Nt={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Fg(t){return t?t.command?`${Nt.next} ${t.command}`:t.ask_user?`${Nt.next} ${t.ask_user}`:null:null}function Vg(t,e){let r=[t.summary],i=Fg(t.next);return i&&r.push(i),t.user_message&&r.push("",Nt.relay,t.user_message),e!==void 0&&r.push("",Nt.details,JSON.stringify(e,null,2)),`${r.join(`
162
279
  `)}
163
- `}function Kh(t,e,r){let i=[t.summary],n=Jh(t.next);return n&&i.push(n),t.user_message&&i.push("",ut.relay,t.user_message),i.push("",`${ut.detail} ${e}`),r!==void 0&&i.push("",ut.details,JSON.stringify(r,null,2)),i.join(`
164
- `)}z();Ee();z();var Bx=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});jr();Ve();ue();j();L();qe();xi();Y();j();Ve();Kt();z();z();io();$r();qe();var Yh={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},Mx=de("comet-native-runtime:v3:scope-reopen"),RF=[{skillVersion:"3",skillHash:de("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:de("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:de("comet-native-runtime:v1")}];qe();qe();Ri();var Qh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],cM=new Set(Qh),Jx=new Set([...Qh,"minimum_runtime_version","revision"]),lM=new Set([...Jx,"operation"]),Ux=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),uM=new Set([...Ux,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);xa();Ee();Ee();xa();z();var mM={maxAcceptanceCriteria:Sp.maxCriteria};jr();Hi();$r();io();import{execFile as nC}from"node:child_process";fa();ml();import{promisify as aC}from"node:util";L();qe();j();Ve();hi();Kt();Y();L();gl();j();Le();jr();Y();Kt();var Ui=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Hi();no();$r();var gV=64*1024;var wV=3600*1e3;var yV=aC(nC);no();var so=class extends Error{details;constructor(e){let r=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=e}};qe();Ve();L();Le();j();Ve();La();L();Mt();jr();var g1=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});qe();xi();Y();j();Ve();La();var co=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},lo=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};j();ue();function C(t,e,r){return t==="zh-CN"?r:e}var El={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function tm(t,e){return typeof t=="string"&&El[t]?C(e,El[t].en,El[t].zh):typeof t=="string"?t:""}function xl(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&typeof e.passed=="number"&&typeof e.failed=="number"&&typeof e.blocked=="number"&&typeof e.pending=="number"}function dC(t){let e={total:t.length,passed:0,failed:0,blocked:0,pending:0};for(let r of t){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;e[i]+=1}return e}function rm(t,e){let r=[];t.failed>0&&r.push(C(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(C(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(C(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=C(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function im(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.change!="string"||e.disposition!=="continue"&&e.disposition!=="await-user"&&e.disposition!=="blocked"&&e.disposition!=="done"||e.commandArgs!==null&&e.commandArgs!==void 0&&!Array.isArray(e.commandArgs))return!1;let r=e.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function Cl(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function fC(t,e,r){return t==="done"?C(r,"complete","已完成"):t==="await-user"?C(r,"waiting for a user decision","等待用户决定"):t==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):e?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function pC(t,e,r){let i=Cl(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=tm(t.phase,i),s=fC(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(rm(e,i));let c=t.userCommunication,l=nm(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function nm(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:C(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:C(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function hC(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function mC(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=tm(t.phase,e),n=t.status==="await-user"?C(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?C(e,"paused","已暂停"):t.status==="done"?C(e,"complete","已完成"):C(e,"in progress","进行中"),a=xl(t.acceptance)?`${C(e,", ",",")}${rm(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function vC(t){for(let e of t){let r=e.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function gC(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.healthy!="boolean"?!1:e.findings===void 0||Array.isArray(e.findings)}function wC(t){if(t.healthy){let i=t.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=yC(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function yC(t){return im(t)?nm(t,Cl(t)):void 0}function am(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(gC(e))return wC(e);if(hC(e)){let i=vC(e.items);return{summary:[e.total===e.items.length?C(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):C(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>mC(a,i))].join(`
165
- `)}}let r=e.continuation;if(im(r)){let i=Cl(r),n=pC(r,NC(e),kC(e,i));return bC(e)==="unconfirmed"?{...n,summary:`${n.summary}${C(i,"; the dispatched Verifier has not confirmed startup yet — verify the subagent actually launched before waiting on it",";已派发的 Verifier 尚未确认启动——先核实子代理确实启动,再继续等待")}`}:n}if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:C(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function NC(t){if(xl(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(xl(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return dC(r.acceptance)}return null}function bC(t){let e=t.localExecution;if(!e||typeof e!="object"||Array.isArray(e))return;let r=e.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function kC(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return C(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?C(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function om(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}hl();var sm=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],Pl=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",agentQuickStart:["Run `comet native status --json` to discover active changes.","Select an existing change with `select`, or create one with `new`.","In `agent.workspace.cwd`, execute the exact `agent.continuation.commandArgs` returned by Runtime.","Use `agent.continuation.inputOptions` templates for JSON input; do not reconstruct fields from memory."],subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec disassociate Revoke a capability association through Runtime.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:sm,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--task <text>] [--capability <id>] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--task <text> Search Project Knowledge for an existing capability and save a revocable association draft.","--capability <id> Directly validate and associate an existing capability without retrieval.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, canonical artifact paths, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN",'comet native new add-sms-login --task "add SMS login to authentication"',"comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability
280
+ `}function qg(t,e,r){let i=[t.summary],n=Fg(t.next);return n&&i.push(n),t.user_message&&i.push("",Nt.relay,t.user_message),i.push("",`${Nt.detail} ${e}`),r!==void 0&&i.push("",Nt.details,JSON.stringify(r,null,2)),i.join(`
281
+ `)}U();Ie();U();var vA=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});mi();Ye();he();L();V();Xe();fn();Z();L();Ye();Nr();U();U();ds();hi();Xe();var Wg={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},wA=ve("comet-native-runtime:v3:scope-reopen"),jW=[{skillVersion:"3",skillHash:ve("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:ve("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:ve("comet-native-runtime:v1")}];Xe();Xe();hn();var Gg=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],hz=new Set(Gg),EA=new Set([...Gg,"minimum_runtime_version","revision"]),mz=new Set([...EA,"operation"]),xA=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),vz=new Set([...xA,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);xo();Ie();Ie();xo();U();var bz={maxAcceptanceCriteria:Eo.maxCriteria};mi();En();hi();ds();import{execFile as OA}from"node:child_process";Hr();Ki();ed();import{promisify as HA}from"node:util";V();Xe();L();Ye();en();Nr();Z();V();id();L();ze();mi();Z();Nr();var Fn=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};En();fs();hi();var E2=64*1024;var x2=3600*1e3;var C2=HA(OA);fs();var ws=class extends Error{details;constructor(e){let r=e.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${e.length} receipt(s)): ${e.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=e}};Xe();Ye();V();ze();L();Ye();Mo();V();rr();mi();var EG=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});Xe();fn();Z();L();Ye();Mo();var ys=class extends Error{constructor(r,i,n,a){super(`Canonical spec conflict for ${r}: expected ${i??"(missing)"}, actual ${n??"(missing)"}`);this.capability=r;this.expectedHash=i;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},Ns=class extends Error{constructor(r,i=r.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${r.findingCodes.join(", ")}`){super(i);this.preflight=r;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};L();he();function C(t,e,r){return t==="zh-CN"?r:e}var md={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Kg(t,e){return typeof t=="string"&&md[t]?C(e,md[t].en,md[t].zh):typeof t=="string"?t:""}function vd(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&typeof e.passed=="number"&&typeof e.failed=="number"&&typeof e.blocked=="number"&&typeof e.pending=="number"}function VA(t){let e={total:t.length,passed:0,failed:0,blocked:0,pending:0};for(let r of t){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;e[i]+=1}return e}function Yg(t,e){let r=[];t.failed>0&&r.push(C(e,`${t.failed} failed`,`${t.failed} 项失败`)),t.blocked>0&&r.push(C(e,`${t.blocked} blocked`,`${t.blocked} 项受阻`)),t.pending>0&&r.push(C(e,`${t.pending} pending`,`${t.pending} 项待验`));let i=C(e,`acceptance ${t.passed}/${t.total} passed`,`验收 ${t.passed}/${t.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Xg(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;if(typeof e.change!="string"||e.disposition!=="continue"&&e.disposition!=="await-user"&&e.disposition!=="blocked"&&e.disposition!=="done"||e.commandArgs!==null&&e.commandArgs!==void 0&&!Array.isArray(e.commandArgs))return!1;let r=e.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function gd(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function qA(t,e,r){return t==="done"?C(r,"complete","已完成"):t==="await-user"?C(r,"waiting for a user decision","等待用户决定"):t==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):e?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function WA(t,e,r){let i=gd(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=Kg(t.phase,i),s=qA(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Yg(e,i));let l=t.userCommunication,c=Qg(t,i);return{summary:n.join("; "),...c?{next:c}:{},...l.required&&l.message?{user_message:l.message}:{}}}function Qg(t,e){let r=t.userCommunication;if(t.disposition==="await-user"&&r.required)return{ask_user:C(e,"Relay the message below, wait for the user decision, then run the matching option (run with --json to see the exact alternative commands).","先转述下方信息并等待用户选择,再执行对应命令(完整候选命令以 --json 输出为准)。")};if(t.commandArgs&&t.commandArgs.length>0)return{command:t.commandArgs.join(" ")};if(t.disposition==="done")return{ask_user:C(e,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(t.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(e,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function zA(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function GA(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Kg(t.phase,e),n=t.status==="await-user"?C(e,"waiting for a user decision","等待用户决定"):t.status==="blocked"?C(e,"paused","已暂停"):t.status==="done"?C(e,"complete","已完成"):C(e,"in progress","进行中"),a=vd(t.acceptance)?`${C(e,", ",",")}${Yg(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function JA(t){for(let e of t){let r=e.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function UA(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.healthy!="boolean"?!1:e.findings===void 0||Array.isArray(e.findings)}function KA(t){if(t.healthy){let i=t.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=YA(t.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(t.findings)?t.findings.length:0;return{summary:C("en",r>0?`Diagnostics found ${r} problem${r===1?"":"s"} that need attention before this change can continue.`:"Diagnostics found problems that need attention before this change can continue.",r>0?`诊断发现 ${r} 个需要处理的问题,处理后该需求才能继续。`:"诊断发现需要处理的问题,处理后该需求才能继续。"),next:{ask_user:C("en","Run with --json to read the structured findings; re-run with --repair once the cause is understood.","结构化诊断以 --json 输出为准;确认原因后再用 --repair 修复。")}}}function YA(t){return Xg(t)?Qg(t,gd(t)):void 0}function Zg(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(UA(e))return KA(e);if(zA(e)){let i=JA(e.items);return{summary:[e.total===e.items.length?C(i,`Native changes (${e.total})`,`Native 需求列表(共 ${e.total} 条)`):C(i,`Native changes (showing ${e.items.length} of ${e.total})`,`Native 需求列表(显示 ${e.items.length}/${e.total} 条)`),...e.items.map(a=>GA(a,i))].join(`
282
+ `)}}let r=e.continuation;if(Xg(r)){let i=gd(r),n=WA(r,XA(e),ZA(e,i));return QA(e)==="unconfirmed"?{...n,summary:`${n.summary}${C(i,"; the dispatched Verifier has not confirmed startup yet — verify the subagent actually launched before waiting on it",";已派发的 Verifier 尚未确认启动——先核实子代理确实启动,再继续等待")}`}:n}if(typeof e.artifactRoot=="string"&&typeof e.nativeRoot=="string"){let i=e.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in e;return{summary:C(i,n?`Comet Native artifacts live under ${e.artifactRoot} (state root: ${e.nativeRoot}).`:`Initialized Comet Native at ${e.nativeRoot} (artifacts: ${e.artifactRoot}).`,n?`Comet Native 产物位于 ${e.artifactRoot}(状态根目录:${e.nativeRoot})。`:`Comet Native 已初始化于 ${e.nativeRoot}(产物目录:${e.artifactRoot})。`)}}}function XA(t){if(vd(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(vd(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return VA(r.acceptance)}return null}function QA(t){let e=t.localExecution;if(!e||typeof e!="object"||Array.isArray(e))return;let r=e.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function ZA(t,e){if(t.selected!==void 0&&typeof t.selected=="string")return C(e,`Selected ${t.selected}.`,`已选择需求 ${t.selected}。`);let r=t.migration;return r&&typeof r=="object"&&r.completed===!0?C(e,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function ew(t){let r=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:{};switch(t.code){case"document-invalid":return{summary:t.message,...typeof r.change=="string"?{next:{command:`comet native next ${r.change} --summary <summary>`}}:{}};case"conflict":return{summary:C("en","This change was updated elsewhere while the command ran, so the command stopped without changing anything. Nothing was lost — reload the latest state and continue from there.","这条需求刚被另一个会话更新,本次命令未做任何改动。没有工作丢失——重新读取最新状态后继续即可。"),...typeof r.change=="string"?{next:{command:`comet native status ${r.change} --json`}}:{}};case"baseline-incomplete":return{summary:C("en","The safety snapshot for this change exceeded its configured size budget, so the command stopped before changing anything. Raise the snapshot limits in .comet/config.yaml or exclude out-of-scope data, then retry.","该需求的安全快照超出配置的容量预算,命令在改动任何内容前已停止。请在 .comet/config.yaml 中调高快照上限,或将范围外的数据加入排除列表后重试。"),next:{ask_user:C("en","Run with --json to see the exact limits, omitted paths, and supported fixes.","具体上限、被省略的路径和支持的修复方式以 --json 输出为准。")}};case"workspace-isolation-required":return{summary:C("en","This change runs in its own Git worktree to keep work isolated. Create the linked worktree first, then continue inside it.","这条需求需要在独立的 Git worktree 中执行以保证隔离。请先创建关联的 worktree,然后在其中继续。"),next:{ask_user:C("en","Run with --json to see the exact worktree creation command.","完整的 worktree 创建命令以 --json 输出为准。")}};case"workspace-preparation-incomplete":return{summary:C("en","The change workspace is not fully prepared (for example a branch or worktree is missing). Finish the preparation steps, then retry.","需求的工作区尚未准备完成(例如分支或 worktree 缺失)。请先完成准备步骤,再重试。"),next:{ask_user:C("en","Run with --json to see the remaining preparation steps.","剩余的准备步骤以 --json 输出为准。")}};case"implementation-scope-stale":return{summary:C("en","The recorded implementation scope no longer matches the current files. Refresh the scope, then retry.","记录的实现范围与当前文件不再一致。请刷新范围后重试。"),next:{ask_user:C("en","Run with --json to see the exact recovery steps.","具体恢复步骤以 --json 输出为准。")}};default:return}}Co();Po();var tw=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--verbose Append the raw machine projection after the human/agent text.","--help Show help without requiring an initialized project."],wd=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",agentQuickStart:["Run `comet native status --json` to discover active changes.","Select an existing change with `select`, or create one with `new`.","In `agent.workspace.cwd`, execute the exact `agent.continuation.commandArgs` returned by Runtime.","Use `agent.continuation.inputOptions` templates for JSON input; do not reconstruct fields from memory."],subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec disassociate Revoke a capability association through Runtime.","spec remove Record a complete capability removal intent.","spec sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:tw,output:"A human summary plus a NEXT step by default (RELAY TO USER blocks carry user decisions); use --json for the structured envelope, --verbose to append the raw machine projection.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--task <text>] [--capability <id>] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--task <text> Search Project Knowledge for an existing capability and save a revocable association draft.","--capability <id> Directly validate and associate an existing capability without retrieval.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, canonical artifact paths, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN",'comet native new add-sms-login --task "add SMS login to authentication"',"comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:`comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability
166
283
  comet native spec remove <change-name> <capability>
167
284
  comet native spec sync <change-name> <capability> --input <json-file>`,purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["disassociate <change-name> Revoke a capability association and return to Shape.","remove <change-name> <capability> Record a capability removal.","sync <change-name> <capability> --input <json-file> Audit local Markdown reference corrections without changing prose or acceptance."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},"spec disassociate":{usage:"comet native spec disassociate <change-name> --expected-state-version <n> --expected-action disassociate-capability",purpose:"Revoke a capability association through Runtime without hand-editing artifacts.",options:["--expected-state-version <n> State version returned by the latest status response.","--expected-action <action> Must be disassociate-capability."],output:"The updated portable state and continuation with the next Runner action."},"spec sync":{usage:"comet native spec sync <change-name> <capability> --input <json-file>",purpose:"Sync local Markdown link destinations in an already confirmed target spec; semantic edits require Shape.",options:["--input <json-file> Fields: expectedStateVersion, actor, reason, affectedAcceptanceIds, replacements [{from,to}]. Include all acceptance IDs from the affected spec."],output:"The audited portable state, preserved unaffected acceptance results and Build continuation for re-verification."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"A compact summary and NEXT action by default. Use --json to read canonical artifact paths, the portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required. Fill command-template placeholders before executing NEXT commands."},check:{usage:"comet native check <change-name>",purpose:"Legacy-only verification command; not supported for current portable changes.",output:"For current changes, run comet native status <change-name> --json and follow the continuation to dispatch verification through comet native next."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page, or a named details/history page.","--details Include one fixed-size page of acceptance, Spec, handoff, verification, history, workspace, and report details."],output:"A compact v2 status page or one compact Loop projection with canonical artifact paths and local execution availability. Use --details and --cursor to read fixed-size detail pages; parent changes expose childSummary and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--coordination-mode multi-session|single-session] [--max-parallel <n>] [--expected-state-version <n>] [--expected-action <action>]
168
285
  comet native next <change-name> --summary <text> [--confirmed|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker] [--expected-state-version <n>] [--expected-action <action>]
169
- comet native next <change-name> --runner-input <json-file> [--validate-only]`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Select how a multi-child Supervisor proceeds while preparing its Shape confirmation; final Shape confirmation is a later, separate step.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, retry-checks, verifier-response, verifier-started, verifier-execution-error, or verifier-unavailable. Builder/dispatch identity fields are rejected; verifier responses must echo the current candidateId and verifierExecutionRef from the Verifier dispatch.","--validate-only Validate the Runner JSON shape and current boundary without writing state or starting a process; requires --runner-input."," Choose one object template from an inputOptions exclusiveGroup and save it as UTF-8 JSON (BOM accepted). Field errors return issues with JSON pointer, missingFields and unknownFields. Execute agent.continuation in agent.workspace.cwd; Supervisor results use task.returnAction."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, verification_checks, known_limits, optional review. checks summarize development feedback. verification_checks is an optional Runtime plan executed after the candidate is frozen; a passing plan is reused without executing the same plan twice when dispatch-verifier receives the unchanged plan. If review is supplied, its fields are status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," retry-checks fields: kind, check_ids for repeatable interrupted Runtime checks from the current candidate; each check can be retried at most three times."," verifier-response fields: kind, candidateId, verifierExecutionRef, response (request-checks or final-result); copy the two binding fields from the current continuation."," verifier-started fields: kind, candidateId, verifierExecutionRef copied from verifierDispatch; the dispatched Verifier submits it as its first Runtime action so status can distinguish a registered dispatch from a Verifier that actually started. Repeating it is accepted without side effects."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."," supervisor-checks fields: kind, child, runId, checks (non-empty repeatable Runtime check plans), materials [{name,content}], and optional retry_check_ids for interrupted checks from the same candidate, machine and workspace. Returns per-check execution state plus operationId, status and receiptRef. Repeated running plans return the same handle."," supervisor-verifier-result evidence fields: summary, checks (informal notes), acceptance [{id,result,reason}], receiptRef. verdict is pass, fail or blocked; every task acceptance ID must appear exactly once. Runtime receipts determine formal check status; receiptRef may be null for fail or blocked."," supervisor-integrate checks are non-empty Runtime check plans executed after the merge in the integration worktree, not declared statuses."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed --expected-state-version <n> --expected-action confirm-shape','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
170
- comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, and the exact next continuation, or the completed Archive transaction and workspace finish result. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function uo(t,e){return`${t}:
286
+ comet native next <change-name> --runner-input <json-file> [--validate-only]`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, handle Supervisor task operations, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm the persisted Shape boundary with both expected guards, or confirm an explicitly degraded verifier-unavailable fallback before Archive.","--coordination-mode multi-session|single-session Choose how a multi-child Supervisor proceeds. Supply it with --confirmed at the persisted Shape boundary to confirm the full plan and mode together, or select it during preparation and confirm the plan afterward.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--finish keep|merge|push|pull-request With --accept-result, record the explicitly chosen isolated-workspace finish in the same guarded decision.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify or Archive to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a failed or unavailable Verifier when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--max-parallel <n> Supervisor task concurrency cap; defaults to 2, use 1 for serial fallback.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, retry-checks, verifier-response, verifier-started, verifier-execution-error, or verifier-unavailable. Builder/dispatch identity fields are rejected; verifier responses must echo the current candidateId and verifierExecutionRef from the Verifier dispatch.","--validate-only Validate the Runner JSON shape and current boundary without writing state or starting a process; requires --runner-input."," Choose one object template from an inputOptions exclusiveGroup and save it as UTF-8 JSON (BOM accepted). Field errors return issues with JSON pointer, missingFields and unknownFields. Execute agent.continuation in agent.workspace.cwd; Supervisor results use task.returnAction."," builder-handoff fields: kind, summary, addressed_acceptance_ids, acceptance_review, checks, verification_checks, known_limits, optional review. acceptance_review must cover every confirmed ID exactly once with id, status, evidence (concrete references or observations), and note. Only implemented-with-evidence with nonempty evidence is ready for handoff; implemented-no-evidence, not-implemented, and known-fail remain in Build. This Builder declaration does not replace independent verification. checks summarize development feedback. verification_checks is an optional Runtime plan executed after the candidate is frozen; a passing plan returns the Verifier dispatch immediately. Completed Runtime checks can carry to a new candidate only when the implementation, confirmed documents, plan, workspace, environment, and saved evidence still match. If review is supplied, its fields are status=passed, summary, reviewer_execution_ref from a separate read-only review."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," retry-checks fields: kind, check_ids for repeatable interrupted Runtime checks from the current candidate; each check can be retried at most three times."," verifier-response fields: kind, candidateId, verifierExecutionRef, response (request-checks or final-result); copy the two binding fields from the current continuation."," verifier-started fields: kind, candidateId, verifierExecutionRef copied from verifierDispatch; the dispatched Verifier submits it as its first Runtime action so status can distinguish a registered dispatch from a Verifier that actually started. Repeating it is accepted without side effects."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."," Supervisor task fields: supervisor-builder-result (child, runId, candidateCommit), supervisor-builder-failure (child, runId, reason), supervisor-verifier-result (child, runId, verdict, verification data), supervisor-reconnect (child, runId), supervisor-cancel (child, runId, reason), or supervisor-integrate (child, checks)."," supervisor-checks fields: kind, child, runId, checks (non-empty repeatable Runtime check plans), materials [{name,content}], and optional retry_check_ids for interrupted checks from the same candidate, machine and workspace. Returns per-check execution state plus operationId, status and receiptRef. Repeated running plans return the same handle."," supervisor-verifier-result evidence fields: summary, checks (informal notes), acceptance [{id,result,reason}], receiptRef. verdict is pass, fail or blocked; every task acceptance ID must appear exactly once. Runtime receipts determine formal check status; receiptRef may be null for fail or blocked."," supervisor-integrate checks are non-empty Runtime check plans executed after the merge in the integration worktree, not declared statuses."],output:'A compact portable state summary, explicit skill-coordinated label, Runtime-owned check results, scoped verifierDispatch, bounded request-check response, continuation.runnerAction, machine-readable continuation.inputOptions, and continuation.userCommunication with a user-ready message and Agent relay guidance. Read acceptance text and other long fields from paged status --details output. Human-readable verification statuses include "Host independently verified", "Checks completed, but your confirmation is required", "Full verification was unavailable; only automatic checks completed", and "You accepted the incomplete verification result". This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.',examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed --expected-state-version <n> --expected-action confirm-shape','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep] [--commit-message <text>] [--merge-message <text>]
287
+ comet native archive <change-name> [--confirmed] [--serial-first <current-change>] [--commit-message <text>] [--merge-message <text>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Run the complete read-only Archive and workspace-finish readiness check; it persists only an explicit --finish choice.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--expected-state-version <n> Preserve this continuation-issued guard when confirming a new finish choice; stale choices are rejected before it is recorded.","--commit-message <text> Set the archive commit message; Unicode and multiline text are supported. Git hooks still run.","--merge-message <text> Set the local merge commit message; requires merge finish. Omit it to use Git defaults.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness, every blocker, actual prepared commitMessages (mergeMessage is null when no merge is planned), and the exact next continuation, or the completed Archive transaction and workspace finish result. Messages are retained for retries. After a Git hook rejects a message, provide a corrected message with --confirmed for the unfinished step; completed commits are never rewritten. Execute the returned confirmed command only after ready is true; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function bs(t,e){return`${t}:
171
288
  ${e.map(r=>` ${r}`).join(`
172
- `)}`}function SC(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return Pl[r]||e.length>1&&Pl[e[0]]?.subcommands?r:e[0]}function EC(t=[]){let e=SC(t),r=Pl[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",uo("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",uo("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...sm];return n&&n.length>0&&i.push("",uo("Options",n)),i.push("",`Output:
173
- ${r.output}`),r.examples&&i.push("",uo("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
289
+ `)}`}function eI(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return wd[r]||e.length>1&&wd[e[0]]?.subcommands?r:e[0]}function tI(t=[]){let e=eI(t),r=wd[e];if(!r)throw new Error(`Unknown Native help topic: ${e}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",bs("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",bs("Commands",r.subcommands));let n=e===""?r.options:[...r.options??[],...tw];return n&&n.length>0&&i.push("",bs("Options",n)),i.push("",`Output:
290
+ ${r.output}`),r.examples&&i.push("",bs("Examples",r.examples)),e===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:e,usage:`${i.join(`
174
291
  `)}
175
- `}}var xC=EC().usage;var xq=10*1024*1024,dt=class extends Error{};function _l(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new dt(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function fo(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new dt(`${e} may only be provided once`);if(r.length===0)return;let i=r[0],n=t[i+1];if(n===void 0||n.startsWith("--"))throw new dt(`${e} requires a value`);return t.splice(i,2),n}function lm(t){if(t.length>0)throw new dt(`Unexpected argument: ${t[0]}`)}function Rl(t,e){let r=Ki.normalize(cm(t)),i=Ki.normalize(cm(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function cm(t){let e=Ki.resolve(t);try{return CC.native(e)}catch{return e}}function PC(t){let e=Ki.resolve(t),r=ke(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return e;let i=ke(e);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Rl(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Rl(r.currentWorktreeRoot,i.currentWorktreeRoot)?e:Rl(process.cwd(),r.currentWorktreeRoot)?Ki.resolve(process.cwd()):r.currentWorktreeRoot}async function um(t){return t?PC(t):bc(process.cwd())}function RC(t){return JSON.stringify(t,null,2)+`
176
- `}function _C(t,e){if(e instanceof Qa)return{command:t,exitCode:65,error:{code:"invalid-data",message:e.message,issues:e.issues}};if(e instanceof dt)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof co)return{command:t,exitCode:73,data:{capability:e.capability,expectedHash:e.expectedHash,actualHash:e.actualHash,canonicalPath:e.canonicalPath},error:{code:"conflict",message:e.message}};if(e instanceof lo)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof Ga)return{command:t,exitCode:73,data:{change:e.change,expectedRevision:e.expectedRevision,actualRevision:e.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:e.message}};if(e instanceof Li)return{command:t,exitCode:73,data:{requestedIsolation:e.requestedIsolation,activeChanges:e.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:e.message}};if(e instanceof to)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof Ja)return{command:t,exitCode:65,data:{change:e.change,complete:!1,omittedCount:e.omittedCount,omittedByReason:e.omittedByReason,samplePaths:e.samplePaths,sampleTruncated:e.sampleTruncated,effectiveLimits:e.effectiveLimits,policyHash:e.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:e.message}};if(e instanceof so)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Ui)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let r=e.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function dm(t,e){let r=_C(t,e),i=r.error;if(!i)return r;let n=om({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function AC(t,e,r=!1){let i=t.envelope??am(t.data);return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,agent:Gh(t.data,t.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
177
- `}:t.error?{exitCode:t.exitCode,stderr:i?Kh(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:Uh(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==RC(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
178
- ${ut.details}
292
+ `}}var rI=tI().usage;var jJ=10*1024*1024,bt=class extends Error{};function Nd(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new bt(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function ks(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new bt(`${e} may only be provided once`);if(r.length===0)return;let i=r[0],n=t[i+1];if(n===void 0||n.startsWith("--"))throw new bt(`${e} requires a value`);return t.splice(i,2),n}function iw(t){if(t.length>0)throw new bt(`Unexpected argument: ${t[0]}`)}function yd(t,e){let r=Vn.normalize(rw(t)),i=Vn.normalize(rw(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function rw(t){let e=Vn.resolve(t);try{return iI.native(e)}catch{return e}}function nI(t,e){let r=Vn.resolve(e,t),i=_e(e);if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return r;let n=_e(r);return!n.isGitWorktree||n.currentWorktreeRoot===null||n.primaryWorktreeRoot===null||!yd(i.primaryWorktreeRoot,n.primaryWorktreeRoot)||yd(i.currentWorktreeRoot,n.currentWorktreeRoot)?r:yd(e,i.currentWorktreeRoot)?Vn.resolve(e):i.currentWorktreeRoot}async function nw(t,e=process.cwd()){return t?nI(t,e):Ol(e)}function aw(t,e){return t==="status"||t==="show"||t==="root"&&e[0]==="show"}function aI(t){return JSON.stringify(t,null,2)+`
293
+ `}function oI(t,e){if(e instanceof On)return{command:t,exitCode:65,data:{change:e.change,findings:e.findings},error:{code:"document-invalid",message:e.message}};if(e instanceof Xr)return{command:t,exitCode:65,data:{builderReadiness:{ready:!1,missingIds:e.missingIds,incompleteIds:e.incompleteIds}},error:{code:"invalid-data",message:e.message}};if(e instanceof Nn)return{command:t,exitCode:65,error:{code:"invalid-data",message:e.message,issues:e.issues}};if(e instanceof bt)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof ys)return{command:t,exitCode:73,data:{capability:e.capability,expectedHash:e.expectedHash,actualHash:e.actualHash,canonicalPath:e.canonicalPath},error:{code:"conflict",message:e.message}};if(e instanceof Ns)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof Uo)return{command:t,exitCode:73,data:{change:e.change,expectedRevision:e.expectedRevision,actualRevision:e.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:e.message}};if(e instanceof Cn)return{command:t,exitCode:73,data:{requestedIsolation:e.requestedIsolation,activeChanges:e.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:e.message}};if(e instanceof ls)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof Ko)return{command:t,exitCode:65,data:{change:e.change,complete:!1,omittedCount:e.omittedCount,omittedByReason:e.omittedByReason,samplePaths:e.samplePaths,sampleTruncated:e.sampleTruncated,effectiveLimits:e.effectiveLimits,policyHash:e.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:e.message}};if(e instanceof ws)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof Fn)return{command:t,exitCode:65,data:e.recovery,error:{code:"implementation-scope-stale",message:e.message}};if(e instanceof Error){let r=e.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:t,exitCode:70,error:{code:"internal",message:e.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(e.message);return{command:t,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:e.message}}}return{command:t,exitCode:70,error:{code:"internal",message:String(e)}}}function ow(t,e){let r=oI(t,e),i=r.error;if(!i)return r;let n=ew({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function sI(t,e,r=!1){let i=t.envelope??Zg(t.data);return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,agent:Mg(t.data,t.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...t.data===void 0?{}:{data:t.data},...t.error===void 0?{}:{error:t.error}})+`
294
+ `}:t.error?{exitCode:t.exitCode,stderr:i?qg(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:Vg(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==aI(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
295
+ ${Nt.details}
179
296
  ${JSON.stringify(t.data,null,2)}
180
- `}:{exitCode:t.exitCode,stdout:t.text}}function IC(t,e,r=!1){let i=AC(t,e,r),n=!1;if(i.stdout?.trim())try{let a=JSON.parse(i.stdout);n=!!a&&typeof a=="object"&&!Array.isArray(a)}catch{n=!1}return{output:i,structuredDataVisible:n}}function fm(t,e,r=!1){return IC(t,e,r).output}async function pm(t,e){let r=fo(t,"--hook-output");if(r!==void 0&&r!=="copilot")throw new dt("--hook-output must be copilot");lm(t);let i=await zh(e,await Wh());return r==="copilot"?{command:"hook-guard",exitCode:0,data:i,text:i.allowed?`{}
297
+ `}:{exitCode:t.exitCode,stdout:t.text}}function cI(t,e,r=!1){let i=sI(t,e,r),n=!1;if(i.stdout?.trim())try{let a=JSON.parse(i.stdout);n=!!a&&typeof a=="object"&&!Array.isArray(a)}catch{n=!1}return{output:i,structuredDataVisible:n}}function sw(t,e,r=!1){return cI(t,e,r).output}async function cw(t,e){let r=ks(t,"--hook-output");if(r!==void 0&&r!=="copilot")throw new bt("--hook-output must be copilot");iw(t);let i=await Bg(e,await Lg());return r==="copilot"?{command:"hook-guard",exitCode:0,data:i,text:i.allowed?`{}
181
298
  `:`${JSON.stringify({permissionDecision:"deny",permissionDecisionReason:i.reason})}
182
- `}:i.allowed?{command:"hook-guard",exitCode:0,data:i}:{command:"hook-guard",exitCode:2,data:i,error:{code:"blocked",message:i.reason}}}async function hm(t,e,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),c,l;try{_l(n,"--json"),_l(n,"--verbose"),c=fo(n,"--project-root");let d=[...n,...a],f=await um(c);l={executionCwd:f,...await e(d,f)}}catch(d){l=dm(t,d)}let u=fm(l,o,s);return u.stdout&&process.stdout.write(u.stdout),u.stderr&&process.stderr.write(u.stderr+(u.stderr.endsWith(`
299
+ `}:i.allowed?{command:"hook-guard",exitCode:0,data:i}:{command:"hook-guard",exitCode:2,data:i,error:{code:"blocked",message:i.reason}}}async function lw(t,e,r=process.argv.slice(2)){let i=r.indexOf("--"),n=i<0?[...r]:r.slice(0,i),a=i<0?[]:r.slice(i),o=n.includes("--json"),s=n.includes("--verbose"),l,c;try{Nd(n,"--json"),Nd(n,"--verbose"),l=ks(n,"--project-root");let d=[...n,...a],f=async()=>{let p=await nw(l);return{executionCwd:p,...await e(d,p)}};c=aw(t,d)?await Sh(f):await f()}catch(d){c=ow(t,d)}let u=sw(c,o,s);return u.stdout&&process.stdout.write(u.stdout),u.stderr&&process.stderr.write(u.stderr+(u.stderr.endsWith(`
183
300
  `)?"":`
184
- `)),u.exitCode}process.exitCode=await hm("hook-guard",pm);
301
+ `)),u.exitCode}process.exitCode=await lw("hook-guard",cw);