@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,174 +1,255 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cometCreateRequire } from 'module';
3
3
  const require = __cometCreateRequire(import.meta.url);
4
- var fm=Object.create;var yo=Object.defineProperty;var pm=Object.getOwnPropertyDescriptor;var hm=Object.getOwnPropertyNames;var mm=Object.getPrototypeOf,vm=Object.prototype.hasOwnProperty;var nn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var x=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(i){throw r=[i],i}};var k=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},gm=(e,t)=>{for(var r in t)yo(e,r,{get:t[r],enumerable:!0})},wm=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of hm(t))!vm.call(e,n)&&n!==r&&yo(e,n,{get:()=>t[n],enumerable:!(i=pm(t,n))||i.enumerable});return e};var Je=(e,t,r)=>(r=e!=null?fm(mm(e)):{},wm(t||!e||!e.__esModule?yo(r,"default",{value:e,enumerable:!0}):r,e));var _=k(U=>{"use strict";var No=Symbol.for("yaml.alias"),Ol=Symbol.for("yaml.document"),an=Symbol.for("yaml.map"),Hl=Symbol.for("yaml.pair"),bo=Symbol.for("yaml.scalar"),on=Symbol.for("yaml.seq"),Ge=Symbol.for("yaml.node.type"),ym=e=>!!e&&typeof e=="object"&&e[Ge]===No,Nm=e=>!!e&&typeof e=="object"&&e[Ge]===Ol,bm=e=>!!e&&typeof e=="object"&&e[Ge]===an,km=e=>!!e&&typeof e=="object"&&e[Ge]===Hl,Dl=e=>!!e&&typeof e=="object"&&e[Ge]===bo,Sm=e=>!!e&&typeof e=="object"&&e[Ge]===on;function ql(e){if(e&&typeof e=="object")switch(e[Ge]){case an:case on:return!0}return!1}function Em(e){if(e&&typeof e=="object")switch(e[Ge]){case No:case an:case bo:case on:return!0}return!1}var xm=e=>(Dl(e)||ql(e))&&!!e.anchor;U.ALIAS=No;U.DOC=Ol;U.MAP=an;U.NODE_TYPE=Ge;U.PAIR=Hl;U.SCALAR=bo;U.SEQ=on;U.hasAnchor=xm;U.isAlias=ym;U.isCollection=ql;U.isDocument=Nm;U.isMap=bm;U.isNode=Em;U.isPair=km;U.isScalar=Dl;U.isSeq=Sm});var Fr=k(ko=>{"use strict";var M=_(),ne=Symbol("break visit"),Fl=Symbol("skip children"),Oe=Symbol("remove node");function sn(e,t){let r=Ll(t);M.isDocument(e)?nr(null,e.contents,r,Object.freeze([e]))===Oe&&(e.contents=null):nr(null,e,r,Object.freeze([]))}sn.BREAK=ne;sn.SKIP=Fl;sn.REMOVE=Oe;function nr(e,t,r,i){let n=Bl(e,t,r,i);if(M.isNode(n)||M.isPair(n))return Vl(e,i,n),nr(e,n,r,i);if(typeof n!="symbol"){if(M.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=nr(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ne)return ne;o===Oe&&(t.items.splice(a,1),a-=1)}}}else if(M.isPair(t)){i=Object.freeze(i.concat(t));let a=nr("key",t.key,r,i);if(a===ne)return ne;a===Oe&&(t.key=null);let o=nr("value",t.value,r,i);if(o===ne)return ne;o===Oe&&(t.value=null)}}return n}async function cn(e,t){let r=Ll(t);M.isDocument(e)?await ar(null,e.contents,r,Object.freeze([e]))===Oe&&(e.contents=null):await ar(null,e,r,Object.freeze([]))}cn.BREAK=ne;cn.SKIP=Fl;cn.REMOVE=Oe;async function ar(e,t,r,i){let n=await Bl(e,t,r,i);if(M.isNode(n)||M.isPair(n))return Vl(e,i,n),ar(e,n,r,i);if(typeof n!="symbol"){if(M.isCollection(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){let o=await ar(a,t.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ne)return ne;o===Oe&&(t.items.splice(a,1),a-=1)}}}else if(M.isPair(t)){i=Object.freeze(i.concat(t));let a=await ar("key",t.key,r,i);if(a===ne)return ne;a===Oe&&(t.key=null);let o=await ar("value",t.value,r,i);if(o===ne)return ne;o===Oe&&(t.value=null)}}return n}function Ll(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Bl(e,t,r,i){if(typeof r=="function")return r(e,t,i);if(M.isMap(t))return r.Map?.(e,t,i);if(M.isSeq(t))return r.Seq?.(e,t,i);if(M.isPair(t))return r.Pair?.(e,t,i);if(M.isScalar(t))return r.Scalar?.(e,t,i);if(M.isAlias(t))return r.Alias?.(e,t,i)}function Vl(e,t,r){let i=t[t.length-1];if(M.isCollection(i))i.items[e]=r;else if(M.isPair(i))e==="key"?i.key=r:i.value=r;else if(M.isDocument(i))i.contents=r;else{let n=M.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}ko.visit=sn;ko.visitAsync=cn});var So=k(Wl=>{"use strict";var Ml=_(),Cm=Fr(),Pm={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Rm=e=>e.replace(/[!,[\]{}]/g,t=>Pm[t]),Lr=class e{constructor(t,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,r)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,r){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.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(t,r){if(t==="!")return"!";if(t[0]!=="!")return r(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||r(`The ${t} 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==="!"?t:(r(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[r,i]of Object.entries(this.tags))if(t.startsWith(i))return r+Rm(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(t&&i.length>0&&Ml.isNode(t.contents)){let a={};Cm.visit(t.contents,(o,s)=>{Ml.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:"||(!t||n.some(s=>s.startsWith(o)))&&r.push(`%TAG ${a} ${o}`);return r.join(`
5
- `)}};Lr.defaultYaml={explicit:!1,version:"1.2"};Lr.defaultTags={"!!":"tag:yaml.org,2002:"};Wl.Directives=Lr});var ln=k(Br=>{"use strict";var zl=_(),_m=Fr();function Am(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(r)}return!0}function Jl(e){let t=new Set;return _m.visit(e,{Value(r,i){i.anchor&&t.add(i.anchor)}}),t}function Gl(e,t){for(let r=1;;++r){let i=`${e}${r}`;if(!t.has(i))return i}}function Im(e,t){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Jl(e));let o=Gl(t,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(zl.isScalar(o.node)||zl.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}}Br.anchorIsValid=Am;Br.anchorNames=Jl;Br.createNodeAnchors=Im;Br.findNewAnchor=Gl});var Eo=k(Ul=>{"use strict";function Vr(e,t,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=Vr(e,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=Vr(e,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=Vr(e,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=Vr(e,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return e.call(t,r,i)}Ul.applyReviver=Vr});var st=k(Yl=>{"use strict";var jm=_();function Kl(e,t,r){if(Array.isArray(e))return e.map((i,n)=>Kl(i,String(n),r));if(e&&typeof e.toJSON=="function"){if(!r||!jm.hasAnchor(e))return e.toJSON(t,r);let i={aliasCount:0,count:1,res:void 0};r.anchors.set(e,i),r.onCreate=a=>{i.res=a,delete r.onCreate};let n=e.toJSON(t,r);return r.onCreate&&r.onCreate(n),n}return typeof e=="bigint"&&!r?.keep?Number(e):e}Yl.toJS=Kl});var un=k(Ql=>{"use strict";var Tm=Eo(),Xl=_(),$m=st(),xo=class{constructor(t){Object.defineProperty(this,Xl.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:r,maxAliasCount:i,onAnchor:n,reviver:a}={}){if(!Xl.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},s=$m.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Tm.applyReviver(a,{"":s},"",s):s}};Ql.NodeBase=xo});var Mr=k(Zl=>{"use strict";var Om=ln(),Hm=Fr(),or=_(),Dm=un(),qm=st(),Co=class extends Dm.NodeBase{constructor(t){super(or.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;r?.aliasResolveCache?i=r.aliasResolveCache:(i=[],Hm.visit(t,{Node:(a,o)=>{(or.isAlias(o)||or.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(t,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||(qm.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=dn(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(t,r,i){let n=`*${this.source}`;if(t){if(Om.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function dn(e,t,r){if(or.isAlias(t)){let i=t.resolve(e),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(or.isCollection(t)){let i=0;for(let n of t.items){let a=dn(e,n,r);a>i&&(i=a)}return i}else if(or.isPair(t)){let i=dn(e,t.key,r),n=dn(e,t.value,r);return Math.max(i,n)}return 1}Zl.Alias=Co});var B=k(Po=>{"use strict";var Fm=_(),Lm=un(),Bm=st(),Vm=e=>!e||typeof e!="function"&&typeof e!="object",ct=class extends Lm.NodeBase{constructor(t){super(Fm.SCALAR),this.value=t}toJSON(t,r){return r?.keep?this.value:Bm.toJS(this.value,t,r)}toString(){return String(this.value)}};ct.BLOCK_FOLDED="BLOCK_FOLDED";ct.BLOCK_LITERAL="BLOCK_LITERAL";ct.PLAIN="PLAIN";ct.QUOTE_DOUBLE="QUOTE_DOUBLE";ct.QUOTE_SINGLE="QUOTE_SINGLE";Po.Scalar=ct;Po.isScalarValue=Vm});var Wr=k(tu=>{"use strict";var Mm=Mr(),Dt=_(),eu=B(),Wm="tag:yaml.org,2002:";function zm(e,t,r){if(t){let i=r.filter(a=>a.tag===t),n=i.find(a=>!a.format)??i[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return r.find(i=>i.identify?.(e)&&!i.format)}function Jm(e,t,r){if(Dt.isDocument(e)&&(e=e.contents),Dt.isNode(e))return e;if(Dt.isPair(e)){let u=r.schema[Dt.MAP].createNode?.(r.schema,null,r);return u.items.push(e),u}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=r,c;if(i&&e&&typeof e=="object"){if(c=s.get(e),c)return c.anchor??(c.anchor=n(e)),new Mm.Alias(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith("!!")&&(t=Wm+t.slice(2));let l=zm(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let u=new eu.Scalar(e);return c&&(c.node=u),u}l=e instanceof Map?o[Dt.MAP]:Symbol.iterator in Object(e)?o[Dt.SEQ]:o[Dt.MAP]}a&&(a(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,e,r):new eu.Scalar(e);return t?d.tag=t:l.default||(d.tag=l.tag),c&&(c.node=d),d}tu.createNode=Jm});var pn=k(fn=>{"use strict";var Gm=Wr(),He=_(),Um=un();function Ro(e,t,r){let i=r;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return Gm.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var ru=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,_o=class extends Um.NodeBase{constructor(t,r){super(t),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(t){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(r.schema=t),r.items=r.items.map(i=>He.isNode(i)||He.isPair(i)?i.clone(t):i),this.range&&(r.range=this.range.slice()),r}addIn(t,r){if(ru(t))this.add(r);else{let[i,...n]=t,a=this.get(i,!0);if(He.isCollection(a))a.addIn(n,r);else if(a===void 0&&this.schema)this.set(i,Ro(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[r,...i]=t;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(t,r){let[i,...n]=t,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(t){return this.items.every(r=>{if(!He.isPair(r))return!1;let i=r.value;return i==null||t&&He.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[r,...i]=t;if(i.length===0)return this.has(r);let n=this.get(r,!0);return He.isCollection(n)?n.hasIn(i):!1}setIn(t,r){let[i,...n]=t;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,Ro(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};fn.Collection=_o;fn.collectionFromPath=Ro;fn.isEmptyPath=ru});var zr=k(hn=>{"use strict";var Km=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Ao(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Ym=(e,t,r)=>e.endsWith(`
6
- `)?Ao(r,t):r.includes(`
4
+ var Av=Object.create;var es=Object.defineProperty;var Iv=Object.getOwnPropertyDescriptor;var Tv=Object.getOwnPropertyNames;var jv=Object.getPrototypeOf,$v=Object.prototype.hasOwnProperty;var $n=(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 k=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Ov=(t,e)=>{for(var r in e)es(t,r,{get:e[r],enumerable:!0})},Hv=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tv(e))!$v.call(t,n)&&n!==r&&es(t,n,{get:()=>e[n],enumerable:!(i=Iv(e,n))||i.enumerable});return t};var et=(t,e,r)=>(r=t!=null?Av(jv(t)):{},Hv(e||!t||!t.__esModule?es(r,"default",{value:t,enumerable:!0}):r,t));var A=k(X=>{"use strict";var ts=Symbol.for("yaml.alias"),Pu=Symbol.for("yaml.document"),On=Symbol.for("yaml.map"),_u=Symbol.for("yaml.pair"),rs=Symbol.for("yaml.scalar"),Hn=Symbol.for("yaml.seq"),tt=Symbol.for("yaml.node.type"),Dv=t=>!!t&&typeof t=="object"&&t[tt]===ts,Bv=t=>!!t&&typeof t=="object"&&t[tt]===Pu,Lv=t=>!!t&&typeof t=="object"&&t[tt]===On,Fv=t=>!!t&&typeof t=="object"&&t[tt]===_u,Au=t=>!!t&&typeof t=="object"&&t[tt]===rs,qv=t=>!!t&&typeof t=="object"&&t[tt]===Hn;function Iu(t){if(t&&typeof t=="object")switch(t[tt]){case On:case Hn:return!0}return!1}function Mv(t){if(t&&typeof t=="object")switch(t[tt]){case ts:case On:case rs:case Hn:return!0}return!1}var Vv=t=>(Au(t)||Iu(t))&&!!t.anchor;X.ALIAS=ts;X.DOC=Pu;X.MAP=On;X.NODE_TYPE=tt;X.PAIR=_u;X.SCALAR=rs;X.SEQ=Hn;X.hasAnchor=Vv;X.isAlias=Dv;X.isCollection=Iu;X.isDocument=Bv;X.isMap=Lv;X.isNode=Mv;X.isPair=Fv;X.isScalar=Au;X.isSeq=qv});var ii=k(is=>{"use strict";var z=A(),ce=Symbol("break visit"),Tu=Symbol("skip children"),Fe=Symbol("remove node");function Dn(t,e){let r=ju(e);z.isDocument(t)?gr(null,t.contents,r,Object.freeze([t]))===Fe&&(t.contents=null):gr(null,t,r,Object.freeze([]))}Dn.BREAK=ce;Dn.SKIP=Tu;Dn.REMOVE=Fe;function gr(t,e,r,i){let n=$u(t,e,r,i);if(z.isNode(n)||z.isPair(n))return Ou(t,i,n),gr(t,n,r,i);if(typeof n!="symbol"){if(z.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=gr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Fe&&(e.items.splice(a,1),a-=1)}}}else if(z.isPair(e)){i=Object.freeze(i.concat(e));let a=gr("key",e.key,r,i);if(a===ce)return ce;a===Fe&&(e.key=null);let o=gr("value",e.value,r,i);if(o===ce)return ce;o===Fe&&(e.value=null)}}return n}async function Bn(t,e){let r=ju(e);z.isDocument(t)?await wr(null,t.contents,r,Object.freeze([t]))===Fe&&(t.contents=null):await wr(null,t,r,Object.freeze([]))}Bn.BREAK=ce;Bn.SKIP=Tu;Bn.REMOVE=Fe;async function wr(t,e,r,i){let n=await $u(t,e,r,i);if(z.isNode(n)||z.isPair(n))return Ou(t,i,n),wr(t,n,r,i);if(typeof n!="symbol"){if(z.isCollection(e)){i=Object.freeze(i.concat(e));for(let a=0;a<e.items.length;++a){let o=await wr(a,e.items[a],r,i);if(typeof o=="number")a=o-1;else{if(o===ce)return ce;o===Fe&&(e.items.splice(a,1),a-=1)}}}else if(z.isPair(e)){i=Object.freeze(i.concat(e));let a=await wr("key",e.key,r,i);if(a===ce)return ce;a===Fe&&(e.key=null);let o=await wr("value",e.value,r,i);if(o===ce)return ce;o===Fe&&(e.value=null)}}return n}function ju(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 $u(t,e,r,i){if(typeof r=="function")return r(t,e,i);if(z.isMap(e))return r.Map?.(t,e,i);if(z.isSeq(e))return r.Seq?.(t,e,i);if(z.isPair(e))return r.Pair?.(t,e,i);if(z.isScalar(e))return r.Scalar?.(t,e,i);if(z.isAlias(e))return r.Alias?.(t,e,i)}function Ou(t,e,r){let i=e[e.length-1];if(z.isCollection(i))i.items[t]=r;else if(z.isPair(i))t==="key"?i.key=r:i.value=r;else if(z.isDocument(i))i.contents=r;else{let n=z.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}is.visit=Dn;is.visitAsync=Bn});var ns=k(Du=>{"use strict";var Hu=A(),Wv=ii(),zv={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Gv=t=>t.replace(/[!,[\]{}]/g,e=>zv[e]),ni=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+Gv(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&&Hu.isNode(e.contents)){let a={};Wv.visit(e.contents,(o,s)=>{Hu.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
+ `)}};ni.defaultYaml={explicit:!1,version:"1.2"};ni.defaultTags={"!!":"tag:yaml.org,2002:"};Du.Directives=ni});var Ln=k(ai=>{"use strict";var Bu=A(),Jv=ii();function Uv(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 Lu(t){let e=new Set;return Jv.visit(t,{Value(r,i){i.anchor&&e.add(i.anchor)}}),e}function Fu(t,e){for(let r=1;;++r){let i=`${t}${r}`;if(!e.has(i))return i}}function Kv(t,e){let r=[],i=new Map,n=null;return{onAnchor:a=>{r.push(a),n??(n=Lu(t));let o=Fu(e,n);return n.add(o),o},setAnchors:()=>{for(let a of r){let o=i.get(a);if(typeof o=="object"&&o.anchor&&(Bu.isScalar(o.node)||Bu.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}}ai.anchorIsValid=Uv;ai.anchorNames=Lu;ai.createNodeAnchors=Kv;ai.findNewAnchor=Fu});var as=k(qu=>{"use strict";function oi(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=oi(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=oi(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=oi(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=oi(t,i,n,a);o===void 0?delete i[n]:o!==a&&(i[n]=o)}return t.call(e,r,i)}qu.applyReviver=oi});var vt=k(Vu=>{"use strict";var Yv=A();function Mu(t,e,r){if(Array.isArray(t))return t.map((i,n)=>Mu(i,String(n),r));if(t&&typeof t.toJSON=="function"){if(!r||!Yv.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}Vu.toJS=Mu});var Fn=k(zu=>{"use strict";var Xv=as(),Wu=A(),Qv=vt(),os=class{constructor(e){Object.defineProperty(this,Wu.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(!Wu.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=Qv.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?Xv.applyReviver(a,{"":s},"",s):s}};zu.NodeBase=os});var si=k(Gu=>{"use strict";var Zv=Ln(),eg=ii(),yr=A(),tg=Fn(),rg=vt(),ss=class extends tg.NodeBase{constructor(e){super(yr.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=[],eg.visit(e,{Node:(a,o)=>{(yr.isAlias(o)||yr.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||(rg.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=qn(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(Zv.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 qn(t,e,r){if(yr.isAlias(e)){let i=e.resolve(t),n=r&&i&&r.get(i);return n?n.count*n.aliasCount:0}else if(yr.isCollection(e)){let i=0;for(let n of e.items){let a=qn(t,n,r);a>i&&(i=a)}return i}else if(yr.isPair(e)){let i=qn(t,e.key,r),n=qn(t,e.value,r);return Math.max(i,n)}return 1}Gu.Alias=ss});var V=k(cs=>{"use strict";var ig=A(),ng=Fn(),ag=vt(),og=t=>!t||typeof t!="function"&&typeof t!="object",gt=class extends ng.NodeBase{constructor(e){super(ig.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:ag.toJS(this.value,e,r)}toString(){return String(this.value)}};gt.BLOCK_FOLDED="BLOCK_FOLDED";gt.BLOCK_LITERAL="BLOCK_LITERAL";gt.PLAIN="PLAIN";gt.QUOTE_DOUBLE="QUOTE_DOUBLE";gt.QUOTE_SINGLE="QUOTE_SINGLE";cs.Scalar=gt;cs.isScalarValue=og});var ci=k(Uu=>{"use strict";var sg=si(),zt=A(),Ju=V(),cg="tag:yaml.org,2002:";function lg(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 ug(t,e,r){if(zt.isDocument(t)&&(t=t.contents),zt.isNode(t))return t;if(zt.isPair(t)){let u=r.schema[zt.MAP].createNode?.(r.schema,null,r);return u.items.push(t),u}(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 sg.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=cg+e.slice(2));let l=lg(t,e,o.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new Ju.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?o[zt.MAP]:Symbol.iterator in Object(t)?o[zt.SEQ]:o[zt.MAP]}a&&(a(l),delete r.onTagObj);let d=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new Ju.Scalar(t);return e?d.tag=e:l.default||(d.tag=l.tag),c&&(c.node=d),d}Uu.createNode=ug});var Vn=k(Mn=>{"use strict";var dg=ci(),qe=A(),pg=Fn();function ls(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 dg.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 Ku=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,us=class extends pg.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(Ku(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,ls(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,ls(this.schema,n,r));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Mn.Collection=us;Mn.collectionFromPath=ls;Mn.isEmptyPath=Ku});var li=k(Wn=>{"use strict";var fg=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function ds(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var hg=(t,e,r)=>t.endsWith(`
6
+ `)?ds(r,e):r.includes(`
7
7
  `)?`
8
- `+Ao(r,t):(e.endsWith(" ")?"":" ")+r;hn.indentComment=Ao;hn.lineComment=Ym;hn.stringifyComment=Km});var nu=k(Jr=>{"use strict";var Xm="flow",Io="block",mn="quoted";function Qm(e,t,r="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let c=Math.max(1+a,1+n-t.length);if(e.length<=c)return e;let l=[],d={},u=n-t.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let f,h,m=!1,p=-1,g=-1,v=-1;r===Io&&(p=iu(e,p,t.length),p!==-1&&(u=p+c));for(let N;N=e[p+=1];){if(r===mn&&N==="\\"){switch(g=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}v=p}if(N===`
9
- `)r===Io&&(p=iu(e,p,t.length)),u=p+t.length+c,f=void 0;else{if(N===" "&&h&&h!==" "&&h!==`
10
- `&&h!==" "){let y=e[p+1];y&&y!==" "&&y!==`
11
- `&&y!==" "&&(f=p)}if(p>=u)if(f)l.push(f),u=f+c,f=void 0;else if(r===mn){for(;h===" "||h===" ";)h=N,N=e[p+=1],m=!0;let y=p>v+1?p-2:g-1;if(d[y])return e;l.push(y),d[y]=!0,u=y+c,f=void 0}else m=!0}h=N}if(m&&s&&s(),l.length===0)return e;o&&o();let b=e.slice(0,l[0]);for(let N=0;N<l.length;++N){let y=l[N],E=l[N+1]||e.length;y===0?b=`
12
- ${t}${e.slice(0,E)}`:(r===mn&&d[y]&&(b+=`${e[y]}\\`),b+=`
13
- ${t}${e.slice(y+1,E)}`)}return b}function iu(e,t,r){let i=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+r)a=e[++t];else{do a=e[++t];while(a&&a!==`
14
- `);i=t,n=t+1,a=e[n]}return i}Jr.FOLD_BLOCK=Io;Jr.FOLD_FLOW=Xm;Jr.FOLD_QUOTED=mn;Jr.foldFlowLines=Qm});var Ur=k(au=>{"use strict";var be=B(),lt=nu(),gn=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),wn=e=>/^(%|---|\.\.\.)/m.test(e);function Zm(e,t,r){if(!t||t<0)return!1;let i=t-r,n=e.length;if(n<=i)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
15
- `){if(a-o>i)return!0;if(o=a+1,n-o<=i)return!1}return!0}function Gr(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(wn(e)?" ":""),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 d=r.substr(c+2,4);switch(d){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:d.substr(0,2)==="00"?o+="\\x"+d.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
+ `+ds(r,e):(t.endsWith(" ")?"":" ")+r;Wn.indentComment=ds;Wn.lineComment=hg;Wn.stringifyComment=fg});var Xu=k(ui=>{"use strict";var mg="flow",ps="block",zn="quoted";function vg(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=[],d={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,a)?l.push(0):u=n-i);let p,f,m=!1,h=-1,g=-1,v=-1;r===ps&&(h=Yu(t,h,e.length),h!==-1&&(u=h+c));for(let b;b=t[h+=1];){if(r===zn&&b==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}v=h}if(b===`
9
+ `)r===ps&&(h=Yu(t,h,e.length)),u=h+e.length+c,p=void 0;else{if(b===" "&&f&&f!==" "&&f!==`
10
+ `&&f!==" "){let y=t[h+1];y&&y!==" "&&y!==`
11
+ `&&y!==" "&&(p=h)}if(h>=u)if(p)l.push(p),u=p+c,p=void 0;else if(r===zn){for(;f===" "||f===" ";)f=b,b=t[h+=1],m=!0;let y=h>v+1?h-2:g-1;if(d[y])return t;l.push(y),d[y]=!0,u=y+c,p=void 0}else m=!0}f=b}if(m&&s&&s(),l.length===0)return t;o&&o();let N=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let y=l[b],E=l[b+1]||t.length;y===0?N=`
12
+ ${e}${t.slice(0,E)}`:(r===zn&&d[y]&&(N+=`${t[y]}\\`),N+=`
13
+ ${e}${t.slice(y+1,E)}`)}return N}function Yu(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}ui.FOLD_BLOCK=ps;ui.FOLD_FLOW=mg;ui.FOLD_QUOTED=zn;ui.foldFlowLines=vg});var pi=k(Qu=>{"use strict";var Ce=V(),wt=Xu(),Jn=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Un=t=>/^(%|---|\.\.\.)/m.test(t);function gg(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 di(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,a=e.indent||(Un(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 d=r.substr(c+2,4);switch(d){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:d.substr(0,2)==="00"?o+="\\x"+d.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)+`
16
16
 
17
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:lt.foldFlowLines(o,a,lt.FOLD_QUOTED,gn(t,!1))}function jo(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
19
- `)||/[ \t]\n|\n[ \t]/.test(e))return Gr(e,t);let r=t.indent||(wn(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
20
- ${r}`)+"'";return t.implicitKey?i:lt.foldFlowLines(i,r,lt.FOLD_FLOW,gn(t,!1))}function sr(e,t){let{singleQuote:r}=t.options,i;if(r===!1)i=Gr;else{let n=e.includes('"'),a=e.includes("'");n&&!a?i=jo:a&&!n?i=Gr:i=r?jo:Gr}return i(e,t)}var To;try{To=new RegExp(`(^|(?<!
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:wt.foldFlowLines(o,a,wt.FOLD_QUOTED,Jn(e,!1))}function fs(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
19
+ `)||/[ \t]\n|\n[ \t]/.test(t))return di(t,e);let r=e.indent||(Un(t)?" ":""),i="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
20
+ ${r}`)+"'";return e.implicitKey?i:wt.foldFlowLines(i,r,wt.FOLD_FLOW,Jn(e,!1))}function Nr(t,e){let{singleQuote:r}=e.options,i;if(r===!1)i=di;else{let n=t.includes('"'),a=t.includes("'");n&&!a?i=fs:a&&!n?i=di:i=r?fs:di}return i(t,e)}var hs;try{hs=new RegExp(`(^|(?<!
21
21
  ))
22
22
  +(?!
23
- |$)`,"g")}catch{To=/\n+(?!\n|$)/g}function vn({comment:e,type:t,value:r},i,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(r))return sr(r,i);let l=i.indent||(i.forceBlockIndent||wn(r)?" ":""),d=o==="literal"?!0:o==="folded"||t===be.Scalar.BLOCK_FOLDED?!1:t===be.Scalar.BLOCK_LITERAL?!0:!Zm(r,c,l.length);if(!r)return d?`|
23
+ |$)`,"g")}catch{hs=/\n+(?!\n|$)/g}function Gn({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 Nr(r,i);let l=i.indent||(i.forceBlockIndent||Un(r)?" ":""),d=o==="literal"?!0:o==="folded"||e===Ce.Scalar.BLOCK_FOLDED?!1:e===Ce.Scalar.BLOCK_LITERAL?!0:!gg(r,c,l.length);if(!r)return d?`|
24
24
  `:`>
25
- `;let u,f;for(f=r.length;f>0;--f){let E=r[f-1];if(E!==`
26
- `&&E!==" "&&E!==" ")break}let h=r.substring(f),m=h.indexOf(`
27
- `);m===-1?u="-":r===h||m!==h.length-1?(u="+",a&&a()):u="",h&&(r=r.slice(0,-h.length),h[h.length-1]===`
28
- `&&(h=h.slice(0,-1)),h=h.replace(To,`$&${l}`));let p=!1,g,v=-1;for(g=0;g<r.length;++g){let E=r[g];if(E===" ")p=!0;else if(E===`
29
- `)v=g;else break}let b=r.substring(0,v<g?v+1:g);b&&(r=r.substring(b.length),b=b.replace(/\n+/g,`$&${l}`));let y=(p?l?"2":"1":"")+u;if(e&&(y+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!d){let E=r.replace(/\n+/g,`
30
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),w=!1,R=gn(i,!0);o!=="folded"&&t!==be.Scalar.BLOCK_FOLDED&&(R.onOverflow=()=>{w=!0});let S=lt.foldFlowLines(`${b}${E}${h}`,l,lt.FOLD_BLOCK,R);if(!w)return`>${y}
25
+ `;let u,p;for(p=r.length;p>0;--p){let E=r[p-1];if(E!==`
26
+ `&&E!==" "&&E!==" ")break}let f=r.substring(p),m=f.indexOf(`
27
+ `);m===-1?u="-":r===f||m!==f.length-1?(u="+",a&&a()):u="",f&&(r=r.slice(0,-f.length),f[f.length-1]===`
28
+ `&&(f=f.slice(0,-1)),f=f.replace(hs,`$&${l}`));let h=!1,g,v=-1;for(g=0;g<r.length;++g){let E=r[g];if(E===" ")h=!0;else if(E===`
29
+ `)v=g;else break}let N=r.substring(0,v<g?v+1:g);N&&(r=r.substring(N.length),N=N.replace(/\n+/g,`$&${l}`));let y=(h?l?"2":"1":"")+u;if(t&&(y+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!d){let E=r.replace(/\n+/g,`
30
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),w=!1,_=Jn(i,!0);o!=="folded"&&e!==Ce.Scalar.BLOCK_FOLDED&&(_.onOverflow=()=>{w=!0});let S=wt.foldFlowLines(`${N}${E}${f}`,l,wt.FOLD_BLOCK,_);if(!w)return`>${y}
31
31
  ${l}${S}`}return r=r.replace(/\n+/g,`$&${l}`),`|${y}
32
- ${l}${b}${r}${h}`}function ev(e,t,r,i){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:d}=t;if(s&&a.includes(`
33
- `)||d&&/[[\]{},]/.test(a))return sr(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||d||!a.includes(`
34
- `)?sr(a,t):vn(e,t,r,i);if(!s&&!d&&n!==be.Scalar.PLAIN&&a.includes(`
35
- `))return vn(e,t,r,i);if(wn(a)){if(c==="")return t.forceBlockIndent=!0,vn(e,t,r,i);if(s&&c===l)return sr(a,t)}let u=a.replace(/\n+/g,`$&
36
- ${c}`);if(o){let f=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(u),{compat:h,tags:m}=t.doc.schema;if(m.some(f)||h?.some(f))return sr(a,t)}return s?u:lt.foldFlowLines(u,c,lt.FOLD_FLOW,gn(t,!1))}function tv(e,t,r,i){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==be.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=be.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case be.Scalar.BLOCK_FOLDED:case be.Scalar.BLOCK_LITERAL:return n||a?sr(o.value,t):vn(o,t,r,i);case be.Scalar.QUOTE_DOUBLE:return Gr(o.value,t);case be.Scalar.QUOTE_SINGLE:return jo(o.value,t);case be.Scalar.PLAIN:return ev(o,t,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:d,defaultStringType:u}=t.options,f=n&&d||u;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}au.stringifyString=tv});var Kr=k($o=>{"use strict";var rv=ln(),ut=_(),iv=zr(),nv=Ur();function av(e,t){let r=Object.assign({blockQuote:!0,commentString:iv.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},e.schema.toStringOptions,t),i;switch(r.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:i,options:r}}function ov(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let r,i;if(ut.isScalar(t)){i=t.value;let n=e.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===t.format)??n.find(a=>!a.format)}else i=t,r=e.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 sv(e,t,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(ut.isScalar(e)||ut.isCollection(e))&&e.anchor;a&&rv.anchorIsValid(a)&&(r.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function cv(e,t,r,i){if(ut.isPair(e))return e.toString(t,r,i);if(ut.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=ut.isNode(e)?e:t.doc.createNode(e,{onTagObj:c=>n=c});n??(n=ov(t.doc.schema.tags,a));let o=sv(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,r,i):ut.isScalar(a)?nv.stringifyString(a,t,r,i):a.toString(t,r,i);return o?ut.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
- ${t.indent}${s}`:s}$o.createStringifyContext=av;$o.stringify=cv});var lu=k(cu=>{"use strict";var Ue=_(),ou=B(),su=Kr(),Yr=zr();function lv({key:e,value:t},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=r,f=Ue.isNode(e)&&e.comment||null;if(u){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(Ue.isCollection(e)||!Ue.isNode(e)&&typeof e=="object"){let R="With simple keys, collection cannot be used as a key value";throw new Error(R)}}let h=!u&&(!e||f&&t==null&&!r.inFlow||Ue.isCollection(e)||(Ue.isScalar(e)?e.type===ou.Scalar.BLOCK_FOLDED||e.type===ou.Scalar.BLOCK_LITERAL:typeof e=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(u||!a),indent:s+c});let m=!1,p=!1,g=su.stringify(e,r,()=>m=!0,()=>p=!0);if(!h&&!r.inFlow&&g.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(a||t==null)return m&&i&&i(),g===""?"?":h?`? ${g}`:g}else if(a&&!u||t==null&&h)return g=`? ${g}`,f&&!m?g+=Yr.lineComment(g,r.indent,l(f)):p&&n&&n(),g;m&&(f=null),h?(f&&(g+=Yr.lineComment(g,r.indent,l(f))),g=`? ${g}
38
- ${s}:`):(g=`${g}:`,f&&(g+=Yr.lineComment(g,r.indent,l(f))));let v,b,N;Ue.isNode(t)?(v=!!t.spaceBefore,b=t.commentBefore,N=t.comment):(v=!1,b=null,N=null,t&&typeof t=="object"&&(t=o.createNode(t))),r.implicitKey=!1,!h&&!f&&Ue.isScalar(t)&&(r.indentAtStart=g.length+1),p=!1,!d&&c.length>=2&&!r.inFlow&&!h&&Ue.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(r.indent=r.indent.substring(2));let y=!1,E=su.stringify(t,r,()=>y=!0,()=>p=!0),w=" ";if(f||v||b){if(w=v?`
39
- `:"",b){let R=l(b);w+=`
40
- ${Yr.indentComment(R,r.indent)}`}E===""&&!r.inFlow?w===`
41
- `&&N&&(w=`
32
+ ${l}${N}${r}${f}`}function wg(t,e,r,i){let{type:n,value:a}=t,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:d}=e;if(s&&a.includes(`
33
+ `)||d&&/[[\]{},]/.test(a))return Nr(a,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||d||!a.includes(`
34
+ `)?Nr(a,e):Gn(t,e,r,i);if(!s&&!d&&n!==Ce.Scalar.PLAIN&&a.includes(`
35
+ `))return Gn(t,e,r,i);if(Un(a)){if(c==="")return e.forceBlockIndent=!0,Gn(t,e,r,i);if(s&&c===l)return Nr(a,e)}let u=a.replace(/\n+/g,`$&
36
+ ${c}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:f,tags:m}=e.doc.schema;if(m.some(p)||f?.some(p))return Nr(a,e)}return s?u:wt.foldFlowLines(u,c,wt.FOLD_FLOW,Jn(e,!1))}function yg(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!==Ce.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Ce.Scalar.QUOTE_DOUBLE);let c=d=>{switch(d){case Ce.Scalar.BLOCK_FOLDED:case Ce.Scalar.BLOCK_LITERAL:return n||a?Nr(o.value,e):Gn(o,e,r,i);case Ce.Scalar.QUOTE_DOUBLE:return di(o.value,e);case Ce.Scalar.QUOTE_SINGLE:return fs(o.value,e);case Ce.Scalar.PLAIN:return wg(o,e,r,i);default:return null}},l=c(s);if(l===null){let{defaultKeyType:d,defaultStringType:u}=e.options,p=n&&d||u;if(l=c(p),l===null)throw new Error(`Unsupported default string type ${p}`)}return l}Qu.stringifyString=yg});var fi=k(ms=>{"use strict";var Ng=Ln(),yt=A(),bg=li(),kg=pi();function Sg(t,e){let r=Object.assign({blockQuote:!0,commentString:bg.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 Eg(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(yt.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 xg(t,e,{anchors:r,doc:i}){if(!i.directives)return"";let n=[],a=(yt.isScalar(t)||yt.isCollection(t))&&t.anchor;a&&Ng.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 Cg(t,e,r,i){if(yt.isPair(t))return t.toString(e,r,i);if(yt.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=yt.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=Eg(e.doc.schema.tags,a));let o=xg(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):yt.isScalar(a)?kg.stringifyString(a,e,r,i):a.toString(e,r,i);return o?yt.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
37
+ ${e.indent}${s}`:s}ms.createStringifyContext=Sg;ms.stringify=Cg});var rd=k(td=>{"use strict";var rt=A(),Zu=V(),ed=fi(),hi=li();function Rg({key:t,value:e},r,i,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:d,simpleKeys:u}}=r,p=rt.isNode(t)&&t.comment||null;if(u){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(rt.isCollection(t)||!rt.isNode(t)&&typeof t=="object"){let _="With simple keys, collection cannot be used as a key value";throw new Error(_)}}let f=!u&&(!t||p&&e==null&&!r.inFlow||rt.isCollection(t)||(rt.isScalar(t)?t.type===Zu.Scalar.BLOCK_FOLDED||t.type===Zu.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!f&&(u||!a),indent:s+c});let m=!1,h=!1,g=ed.stringify(t,r,()=>m=!0,()=>h=!0);if(!f&&!r.inFlow&&g.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");f=!0}if(r.inFlow){if(a||e==null)return m&&i&&i(),g===""?"?":f?`? ${g}`:g}else if(a&&!u||e==null&&f)return g=`? ${g}`,p&&!m?g+=hi.lineComment(g,r.indent,l(p)):h&&n&&n(),g;m&&(p=null),f?(p&&(g+=hi.lineComment(g,r.indent,l(p))),g=`? ${g}
38
+ ${s}:`):(g=`${g}:`,p&&(g+=hi.lineComment(g,r.indent,l(p))));let v,N,b;rt.isNode(e)?(v=!!e.spaceBefore,N=e.commentBefore,b=e.comment):(v=!1,N=null,b=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!f&&!p&&rt.isScalar(e)&&(r.indentAtStart=g.length+1),h=!1,!d&&c.length>=2&&!r.inFlow&&!f&&rt.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let y=!1,E=ed.stringify(e,r,()=>y=!0,()=>h=!0),w=" ";if(p||v||N){if(w=v?`
39
+ `:"",N){let _=l(N);w+=`
40
+ ${hi.indentComment(_,r.indent)}`}E===""&&!r.inFlow?w===`
41
+ `&&b&&(w=`
42
42
 
43
43
  `):w+=`
44
- ${r.indent}`}else if(!h&&Ue.isCollection(t)){let R=E[0],S=E.indexOf(`
45
- `),I=S!==-1,K=r.inFlow??t.flow??t.items.length===0;if(I||!K){let Ne=!1;if(I&&(R==="&"||R==="!")){let F=E.indexOf(" ");R==="&"&&F!==-1&&F<S&&E[F+1]==="!"&&(F=E.indexOf(" ",F+1)),(F===-1||S<F)&&(Ne=!0)}Ne||(w=`
44
+ ${r.indent}`}else if(!f&&rt.isCollection(e)){let _=E[0],S=E.indexOf(`
45
+ `),T=S!==-1,Q=r.inFlow??e.flow??e.items.length===0;if(T||!Q){let xe=!1;if(T&&(_==="&"||_==="!")){let q=E.indexOf(" ");_==="&"&&q!==-1&&q<S&&E[q+1]==="!"&&(q=E.indexOf(" ",q+1)),(q===-1||S<q)&&(xe=!0)}xe||(w=`
46
46
  ${r.indent}`)}}else(E===""||E[0]===`
47
- `)&&(w="");return g+=w+E,r.inFlow?y&&i&&i():N&&!y?g+=Yr.lineComment(g,r.indent,l(N)):p&&n&&n(),g}cu.stringifyPair=lv});var Ho=k(Oo=>{"use strict";var uu=nn("process");function uv(e,...t){e==="debug"&&console.log(...t)}function dv(e,t){(e==="debug"||e==="warn")&&(typeof uu.emitWarning=="function"?uu.emitWarning(t):console.warn(t))}Oo.debug=uv;Oo.warn=dv});var Sn=k(kn=>{"use strict";var bn=_(),du=B(),yn="<<",Nn={identify:e=>e===yn||typeof e=="symbol"&&e.description===yn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new du.Scalar(Symbol(yn)),{addToJSMap:fu}),stringify:()=>yn},fv=(e,t)=>(Nn.identify(t)||bn.isScalar(t)&&(!t.type||t.type===du.Scalar.PLAIN)&&Nn.identify(t.value))&&e?.doc.schema.tags.some(r=>r.tag===Nn.tag&&r.default);function fu(e,t,r){let i=pu(e,r);if(bn.isSeq(i))for(let n of i.items)Do(e,t,n);else if(Array.isArray(i))for(let n of i)Do(e,t,n);else Do(e,t,i)}function Do(e,t,r){let i=pu(e,r);if(!bn.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function pu(e,t){return e&&bn.isAlias(t)?t.resolve(e.doc,e):t}kn.addMergeToJSMap=fu;kn.isMergeKey=fv;kn.merge=Nn});var Fo=k(vu=>{"use strict";var pv=Ho(),hu=Sn(),hv=Kr(),mu=_(),qo=st();function mv(e,t,{key:r,value:i}){if(mu.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,i);else if(hu.isMergeKey(e,r))hu.addMergeToJSMap(e,t,i);else{let n=qo.toJS(r,"",e);if(t instanceof Map)t.set(n,qo.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let a=vv(r,n,e),o=qo.toJS(i,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function vv(e,t,r){if(t===null)return"";if(typeof t!="object")return String(t);if(mu.isNode(e)&&r?.doc){let i=hv.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=e.toString(i);if(!r.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),pv.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(t)}vu.addPairToJSMap=mv});var dt=k(Lo=>{"use strict";var gu=Wr(),gv=lu(),wv=Fo(),En=_();function yv(e,t,r){let i=gu.createNode(e,void 0,r),n=gu.createNode(t,void 0,r);return new xn(i,n)}var xn=class e{constructor(t,r=null){Object.defineProperty(this,En.NODE_TYPE,{value:En.PAIR}),this.key=t,this.value=r}clone(t){let{key:r,value:i}=this;return En.isNode(r)&&(r=r.clone(t)),En.isNode(i)&&(i=i.clone(t)),new e(r,i)}toJSON(t,r){let i=r?.mapAsMap?new Map:{};return wv.addPairToJSMap(r,i,this)}toString(t,r,i){return t?.doc?gv.stringifyPair(this,t,r,i):JSON.stringify(this)}};Lo.Pair=xn;Lo.createPair=yv});var Bo=k(yu=>{"use strict";var qt=_(),wu=Kr(),Cn=zr();function Nv(e,t,r){return(t.inFlow??e.flow?kv:bv)(e,t,r)}function bv({comment:e,items:t},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,d=Object.assign({},r,{indent:a,type:null}),u=!1,f=[];for(let m=0;m<t.length;++m){let p=t[m],g=null;if(qt.isNode(p))!u&&p.spaceBefore&&f.push(""),Pn(r,f,p.commentBefore,u),p.comment&&(g=p.comment);else if(qt.isPair(p)){let b=qt.isNode(p.key)?p.key:null;b&&(!u&&b.spaceBefore&&f.push(""),Pn(r,f,b.commentBefore,u))}u=!1;let v=wu.stringify(p,d,()=>g=null,()=>u=!0);g&&(v+=Cn.lineComment(v,a,l(g))),u&&g&&(u=!1),f.push(i+v)}let h;if(f.length===0)h=n.start+n.end;else{h=f[0];for(let m=1;m<f.length;++m){let p=f[m];h+=p?`
48
- ${c}${p}`:`
49
- `}}return e?(h+=`
50
- `+Cn.indentComment(l(e),c),s&&s()):u&&o&&o(),h}function kv({items:e},t,{flowChars:r,itemIndent:i}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;i+=a;let c=Object.assign({},t,{indent:i,inFlow:!0,type:null}),l=!1,d=0,u=[];for(let m=0;m<e.length;++m){let p=e[m],g=null;if(qt.isNode(p))p.spaceBefore&&u.push(""),Pn(t,u,p.commentBefore,!1),p.comment&&(g=p.comment);else if(qt.isPair(p)){let b=qt.isNode(p.key)?p.key:null;b&&(b.spaceBefore&&u.push(""),Pn(t,u,b.commentBefore,!1),b.comment&&(l=!0));let N=qt.isNode(p.value)?p.value:null;N?(N.comment&&(g=N.comment),N.commentBefore&&(l=!0)):p.value==null&&b?.comment&&(g=b.comment)}g&&(l=!0);let v=wu.stringify(p,c,()=>g=null);l||(l=u.length>d||v.includes(`
51
- `)),m<e.length-1?v+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(l||(l=u.reduce((b,N)=>b+N.length+2,2)+(v.length+2)>t.options.lineWidth)),l&&(v+=",")),g&&(v+=Cn.lineComment(v,i,s(g))),u.push(v),d=u.length}let{start:f,end:h}=r;if(u.length===0)return f+h;if(!l){let m=u.reduce((p,g)=>p+g.length+2,2);l=t.options.lineWidth>0&&m>t.options.lineWidth}if(l){let m=f;for(let p of u)m+=p?`
52
- ${a}${n}${p}`:`
47
+ `)&&(w="");return g+=w+E,r.inFlow?y&&i&&i():b&&!y?g+=hi.lineComment(g,r.indent,l(b)):h&&n&&n(),g}td.stringifyPair=Rg});var gs=k(vs=>{"use strict";var id=$n("process");function Pg(t,...e){t==="debug"&&console.log(...e)}function _g(t,e){(t==="debug"||t==="warn")&&(typeof id.emitWarning=="function"?id.emitWarning(e):console.warn(e))}vs.debug=Pg;vs.warn=_g});var Zn=k(Qn=>{"use strict";var Xn=A(),nd=V(),Kn="<<",Yn={identify:t=>t===Kn||typeof t=="symbol"&&t.description===Kn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new nd.Scalar(Symbol(Kn)),{addToJSMap:ad}),stringify:()=>Kn},Ag=(t,e)=>(Yn.identify(e)||Xn.isScalar(e)&&(!e.type||e.type===nd.Scalar.PLAIN)&&Yn.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===Yn.tag&&r.default);function ad(t,e,r){let i=od(t,r);if(Xn.isSeq(i))for(let n of i.items)ws(t,e,n);else if(Array.isArray(i))for(let n of i)ws(t,e,n);else ws(t,e,i)}function ws(t,e,r){let i=od(t,r);if(!Xn.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 od(t,e){return t&&Xn.isAlias(e)?e.resolve(t.doc,t):e}Qn.addMergeToJSMap=ad;Qn.isMergeKey=Ag;Qn.merge=Yn});var Ns=k(ld=>{"use strict";var Ig=gs(),sd=Zn(),Tg=fi(),cd=A(),ys=vt();function jg(t,e,{key:r,value:i}){if(cd.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,i);else if(sd.isMergeKey(t,r))sd.addMergeToJSMap(t,e,i);else{let n=ys.toJS(r,"",t);if(e instanceof Map)e.set(n,ys.toJS(i,n,t));else if(e instanceof Set)e.add(n);else{let a=$g(r,n,t),o=ys.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 $g(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(cd.isNode(t)&&r?.doc){let i=Tg.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)+'..."'),Ig.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)}ld.addPairToJSMap=jg});var Nt=k(bs=>{"use strict";var ud=ci(),Og=rd(),Hg=Ns(),ea=A();function Dg(t,e,r){let i=ud.createNode(t,void 0,r),n=ud.createNode(e,void 0,r);return new ta(i,n)}var ta=class t{constructor(e,r=null){Object.defineProperty(this,ea.NODE_TYPE,{value:ea.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:i}=this;return ea.isNode(r)&&(r=r.clone(e)),ea.isNode(i)&&(i=i.clone(e)),new t(r,i)}toJSON(e,r){let i=r?.mapAsMap?new Map:{};return Hg.addPairToJSMap(r,i,this)}toString(e,r,i){return e?.doc?Og.stringifyPair(this,e,r,i):JSON.stringify(this)}};bs.Pair=ta;bs.createPair=Dg});var ks=k(pd=>{"use strict";var Gt=A(),dd=fi(),ra=li();function Bg(t,e,r){return(e.inFlow??t.flow?Fg:Lg)(t,e,r)}function Lg({comment:t,items:e},r,{blockItemPrefix:i,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=r,d=Object.assign({},r,{indent:a,type:null}),u=!1,p=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(Gt.isNode(h))!u&&h.spaceBefore&&p.push(""),ia(r,p,h.commentBefore,u),h.comment&&(g=h.comment);else if(Gt.isPair(h)){let N=Gt.isNode(h.key)?h.key:null;N&&(!u&&N.spaceBefore&&p.push(""),ia(r,p,N.commentBefore,u))}u=!1;let v=dd.stringify(h,d,()=>g=null,()=>u=!0);g&&(v+=ra.lineComment(v,a,l(g))),u&&g&&(u=!1),p.push(i+v)}let f;if(p.length===0)f=n.start+n.end;else{f=p[0];for(let m=1;m<p.length;++m){let h=p[m];f+=h?`
48
+ ${c}${h}`:`
49
+ `}}return t?(f+=`
50
+ `+ra.indentComment(l(t),c),s&&s()):u&&o&&o(),f}function Fg({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,d=0,u=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(Gt.isNode(h))h.spaceBefore&&u.push(""),ia(e,u,h.commentBefore,!1),h.comment&&(g=h.comment);else if(Gt.isPair(h)){let N=Gt.isNode(h.key)?h.key:null;N&&(N.spaceBefore&&u.push(""),ia(e,u,N.commentBefore,!1),N.comment&&(l=!0));let b=Gt.isNode(h.value)?h.value:null;b?(b.comment&&(g=b.comment),b.commentBefore&&(l=!0)):h.value==null&&N?.comment&&(g=N.comment)}g&&(l=!0);let v=dd.stringify(h,c,()=>g=null);l||(l=u.length>d||v.includes(`
51
+ `)),m<t.length-1?v+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((N,b)=>N+b.length+2,2)+(v.length+2)>e.options.lineWidth)),l&&(v+=",")),g&&(v+=ra.lineComment(v,i,s(g))),u.push(v),d=u.length}let{start:p,end:f}=r;if(u.length===0)return p+f;if(!l){let m=u.reduce((h,g)=>h+g.length+2,2);l=e.options.lineWidth>0&&m>e.options.lineWidth}if(l){let m=p;for(let h of u)m+=h?`
52
+ ${a}${n}${h}`:`
53
53
  `;return`${m}
54
- ${n}${h}`}else return`${f}${o}${u.join(" ")}${o}${h}`}function Pn({indent:e,options:{commentString:t}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=Cn.indentComment(t(i),e);r.push(a.trimStart())}}yu.stringifyCollection=Nv});var pt=k(Mo=>{"use strict";var Sv=Bo(),Ev=Fo(),xv=pn(),ft=_(),Rn=dt(),Cv=B();function Xr(e,t){let r=ft.isScalar(t)?t.value:t;for(let i of e)if(ft.isPair(i)&&(i.key===t||i.key===r||ft.isScalar(i.key)&&i.key.value===r))return i}var Vo=class extends xv.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(ft.MAP,t),this.items=[]}static from(t,r,i){let{keepUndefined:n,replacer:a}=i,o=new this(t),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(Rn.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 t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,r){let i;ft.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Rn.Pair(t,t?.value):i=new Rn.Pair(t.key,t.value);let n=Xr(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);ft.isScalar(n.value)&&Cv.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(t){let r=Xr(this.items,t);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(t,r){let n=Xr(this.items,t)?.value;return(!r&&ft.isScalar(n)?n.value:n)??void 0}has(t){return!!Xr(this.items,t)}set(t,r){this.add(new Rn.Pair(t,r),!0)}toJSON(t,r,i){let n=i?new i:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(n);for(let a of this.items)Ev.addPairToJSMap(r,n,a);return n}toString(t,r,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!ft.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Sv.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:r})}};Mo.YAMLMap=Vo;Mo.findPair=Xr});var cr=k(bu=>{"use strict";var Pv=_(),Nu=pt(),Rv={collection:"map",default:!0,nodeClass:Nu.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Pv.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,r)=>Nu.YAMLMap.from(e,t,r)};bu.map=Rv});var ht=k(ku=>{"use strict";var _v=Wr(),Av=Bo(),Iv=pn(),An=_(),jv=B(),Tv=st(),Wo=class extends Iv.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(An.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let r=_n(t);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(t,r){let i=_n(t);if(typeof i!="number")return;let n=this.items[i];return!r&&An.isScalar(n)?n.value:n}has(t){let r=_n(t);return typeof r=="number"&&r<this.items.length}set(t,r){let i=_n(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];An.isScalar(n)&&jv.isScalarValue(r)?n.value=r:this.items[i]=r}toJSON(t,r){let i=[];r?.onCreate&&r.onCreate(i);let n=0;for(let a of this.items)i.push(Tv.toJS(a,String(n++),r));return i}toString(t,r,i){return t?Av.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:i,onComment:r}):JSON.stringify(this)}static from(t,r,i){let{replacer:n}=i,a=new this(t);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(_v.createNode(s,void 0,i))}}return a}};function _n(e){let t=An.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}ku.YAMLSeq=Wo});var lr=k(Eu=>{"use strict";var $v=_(),Su=ht(),Ov={collection:"seq",default:!0,nodeClass:Su.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return $v.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,r)=>Su.YAMLSeq.from(e,t,r)};Eu.seq=Ov});var Qr=k(xu=>{"use strict";var Hv=Ur(),Dv={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,r,i){return t=Object.assign({actualString:!0},t),Hv.stringifyString(e,t,r,i)}};xu.string=Dv});var In=k(Ru=>{"use strict";var Cu=B(),Pu={identify:e=>e==null,createNode:()=>new Cu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Cu.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&Pu.test.test(e)?e:t.options.nullStr};Ru.nullTag=Pu});var zo=k(Au=>{"use strict";var qv=B(),_u={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new qv.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&_u.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?r.options.trueStr:r.options.falseStr}};Au.boolTag=_u});var ur=k(Iu=>{"use strict";function Fv({format:e,minFractionDigits:t,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(!e&&t&&(!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=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Iu.stringifyNumber=Fv});var Go=k(jn=>{"use strict";var Lv=B(),Jo=ur(),Bv={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Jo.stringifyNumber},Vv={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Jo.stringifyNumber(e)}},Mv={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Lv.Scalar(parseFloat(e)),r=e.indexOf(".");return r!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-r-1),t},stringify:Jo.stringifyNumber};jn.float=Mv;jn.floatExp=Vv;jn.floatNaN=Bv});var Ko=k($n=>{"use strict";var ju=ur(),Tn=e=>typeof e=="bigint"||Number.isInteger(e),Uo=(e,t,r,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),r);function Tu(e,t,r){let{value:i}=e;return Tn(i)&&i>=0?r+i.toString(t):ju.stringifyNumber(e)}var Wv={identify:e=>Tn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>Uo(e,2,8,r),stringify:e=>Tu(e,8,"0o")},zv={identify:Tn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>Uo(e,0,10,r),stringify:ju.stringifyNumber},Jv={identify:e=>Tn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>Uo(e,2,16,r),stringify:e=>Tu(e,16,"0x")};$n.int=zv;$n.intHex=Jv;$n.intOct=Wv});var Ou=k($u=>{"use strict";var Gv=cr(),Uv=In(),Kv=lr(),Yv=Qr(),Xv=zo(),Yo=Go(),Xo=Ko(),Qv=[Gv.map,Kv.seq,Yv.string,Uv.nullTag,Xv.boolTag,Xo.intOct,Xo.int,Xo.intHex,Yo.floatNaN,Yo.floatExp,Yo.float];$u.schema=Qv});var qu=k(Du=>{"use strict";var Zv=B(),eg=cr(),tg=lr();function Hu(e){return typeof e=="bigint"||Number.isInteger(e)}var On=({value:e})=>JSON.stringify(e),rg=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:On},{identify:e=>e==null,createNode:()=>new Zv.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:On},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:On},{identify:Hu,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>Hu(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:On}],ig={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},ng=[eg.map,tg.seq].concat(rg,ig);Du.schema=ng});var Zo=k(Fu=>{"use strict";var Zr=nn("buffer"),Qo=B(),ag=Ur(),og={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Zr.Buffer=="function")return Zr.Buffer.from(e,"base64");if(typeof atob=="function"){let r=atob(e.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 t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},i,n,a){if(!r)return"";let o=r,s;if(typeof Zr.Buffer=="function")s=o instanceof Zr.Buffer?o.toString("base64"):Zr.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(t??(t=Qo.Scalar.BLOCK_LITERAL),t!==Qo.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),d=new Array(l);for(let u=0,f=0;u<l;++u,f+=c)d[u]=s.substr(f,c);s=d.join(t===Qo.Scalar.BLOCK_LITERAL?`
55
- `:" ")}return ag.stringifyString({comment:e,type:t,value:s},i,n,a)}};Fu.binary=og});var qn=k(Dn=>{"use strict";var Hn=_(),es=dt(),sg=B(),cg=ht();function Lu(e,t){if(Hn.isSeq(e))for(let r=0;r<e.items.length;++r){let i=e.items[r];if(!Hn.isPair(i)){if(Hn.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new es.Pair(new sg.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
54
+ ${n}${f}`}else return`${p}${o}${u.join(" ")}${o}${f}`}function ia({indent:t,options:{commentString:e}},r,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let a=ra.indentComment(e(i),t);r.push(a.trimStart())}}pd.stringifyCollection=Bg});var kt=k(Es=>{"use strict";var qg=ks(),Mg=Ns(),Vg=Vn(),bt=A(),na=Nt(),Wg=V();function mi(t,e){let r=bt.isScalar(e)?e.value:e;for(let i of t)if(bt.isPair(i)&&(i.key===e||i.key===r||bt.isScalar(i.key)&&i.key.value===r))return i}var Ss=class extends Vg.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(bt.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(na.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;bt.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new na.Pair(e,e?.value):i=new na.Pair(e.key,e.value);let n=mi(this.items,i.key),a=this.schema?.sortMapEntries;if(n){if(!r)throw new Error(`Key ${i.key} already set`);bt.isScalar(n.value)&&Wg.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=mi(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let n=mi(this.items,e)?.value;return(!r&&bt.isScalar(n)?n.value:n)??void 0}has(e){return!!mi(this.items,e)}set(e,r){this.add(new na.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)Mg.addPairToJSMap(r,n,a);return n}toString(e,r,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!bt.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})),qg.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:r})}};Es.YAMLMap=Ss;Es.findPair=mi});var br=k(hd=>{"use strict";var zg=A(),fd=kt(),Gg={collection:"map",default:!0,nodeClass:fd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return zg.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>fd.YAMLMap.from(t,e,r)};hd.map=Gg});var St=k(md=>{"use strict";var Jg=ci(),Ug=ks(),Kg=Vn(),oa=A(),Yg=V(),Xg=vt(),xs=class extends Kg.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(oa.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=aa(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let i=aa(e);if(typeof i!="number")return;let n=this.items[i];return!r&&oa.isScalar(n)?n.value:n}has(e){let r=aa(e);return typeof r=="number"&&r<this.items.length}set(e,r){let i=aa(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];oa.isScalar(n)&&Yg.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(Xg.toJS(a,String(n++),r));return i}toString(e,r,i){return e?Ug.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(Jg.createNode(s,void 0,i))}}return a}};function aa(t){let e=oa.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}md.YAMLSeq=xs});var kr=k(gd=>{"use strict";var Qg=A(),vd=St(),Zg={collection:"seq",default:!0,nodeClass:vd.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Qg.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>vd.YAMLSeq.from(t,e,r)};gd.seq=Zg});var vi=k(wd=>{"use strict";var ew=pi(),tw={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),ew.stringifyString(t,e,r,i)}};wd.string=tw});var sa=k(bd=>{"use strict";var yd=V(),Nd={identify:t=>t==null,createNode:()=>new yd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new yd.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Nd.test.test(t)?t:e.options.nullStr};bd.nullTag=Nd});var Cs=k(Sd=>{"use strict";var rw=V(),kd={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new rw.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&kd.test.test(t)){let i=t[0]==="t"||t[0]==="T";if(e===i)return t}return e?r.options.trueStr:r.options.falseStr}};Sd.boolTag=kd});var Sr=k(Ed=>{"use strict";function iw({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}Ed.stringifyNumber=iw});var Ps=k(ca=>{"use strict";var nw=V(),Rs=Sr(),aw={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},ow={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():Rs.stringifyNumber(t)}},sw={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 nw.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:Rs.stringifyNumber};ca.float=sw;ca.floatExp=ow;ca.floatNaN=aw});var As=k(ua=>{"use strict";var xd=Sr(),la=t=>typeof t=="bigint"||Number.isInteger(t),_s=(t,e,r,{intAsBigInt:i})=>i?BigInt(t):parseInt(t.substring(e),r);function Cd(t,e,r){let{value:i}=t;return la(i)&&i>=0?r+i.toString(e):xd.stringifyNumber(t)}var cw={identify:t=>la(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>_s(t,2,8,r),stringify:t=>Cd(t,8,"0o")},lw={identify:la,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>_s(t,0,10,r),stringify:xd.stringifyNumber},uw={identify:t=>la(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>_s(t,2,16,r),stringify:t=>Cd(t,16,"0x")};ua.int=lw;ua.intHex=uw;ua.intOct=cw});var Pd=k(Rd=>{"use strict";var dw=br(),pw=sa(),fw=kr(),hw=vi(),mw=Cs(),Is=Ps(),Ts=As(),vw=[dw.map,fw.seq,hw.string,pw.nullTag,mw.boolTag,Ts.intOct,Ts.int,Ts.intHex,Is.floatNaN,Is.floatExp,Is.float];Rd.schema=vw});var Id=k(Ad=>{"use strict";var gw=V(),ww=br(),yw=kr();function _d(t){return typeof t=="bigint"||Number.isInteger(t)}var da=({value:t})=>JSON.stringify(t),Nw=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:da},{identify:t=>t==null,createNode:()=>new gw.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:da},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:da},{identify:_d,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})=>_d(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:da}],bw={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},kw=[ww.map,yw.seq].concat(Nw,bw);Ad.schema=kw});var $s=k(Td=>{"use strict";var gi=$n("buffer"),js=V(),Sw=pi(),Ew={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof gi.Buffer=="function")return gi.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 gi.Buffer=="function")s=o instanceof gi.Buffer?o.toString("base64"):gi.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=js.Scalar.BLOCK_LITERAL),e!==js.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),l=Math.ceil(s.length/c),d=new Array(l);for(let u=0,p=0;u<l;++u,p+=c)d[u]=s.substr(p,c);s=d.join(e===js.Scalar.BLOCK_LITERAL?`
55
+ `:" ")}return Sw.stringifyString({comment:t,type:e,value:s},i,n,a)}};Td.binary=Ew});var ha=k(fa=>{"use strict";var pa=A(),Os=Nt(),xw=V(),Cw=St();function jd(t,e){if(pa.isSeq(t))for(let r=0;r<t.items.length;++r){let i=t.items[r];if(!pa.isPair(i)){if(pa.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new Os.Pair(new xw.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}e.items[r]=Hn.isPair(i)?i:new es.Pair(i)}}else t("Expected a sequence for this tag");return e}function Bu(e,t,r){let{replacer:i}=r,n=new cg.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,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(es.createPair(s,c,r))}return n}var lg={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Lu,createNode:Bu};Dn.createPairs=Bu;Dn.pairs=lg;Dn.resolvePairs=Lu});var is=k(rs=>{"use strict";var Vu=_(),ts=st(),ei=pt(),ug=ht(),Mu=qn(),Ft=class e extends ug.YAMLSeq{constructor(){super(),this.add=ei.YAMLMap.prototype.add.bind(this),this.delete=ei.YAMLMap.prototype.delete.bind(this),this.get=ei.YAMLMap.prototype.get.bind(this),this.has=ei.YAMLMap.prototype.has.bind(this),this.set=ei.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,r){if(!r)return super.toJSON(t);let i=new Map;r?.onCreate&&r.onCreate(i);for(let n of this.items){let a,o;if(Vu.isPair(n)?(a=ts.toJS(n.key,"",r),o=ts.toJS(n.value,a,r)):a=ts.toJS(n,"",r),i.has(a))throw new Error("Ordered maps must not include duplicate keys");i.set(a,o)}return i}static from(t,r,i){let n=Mu.createPairs(t,r,i),a=new this;return a.items=n.items,a}};Ft.tag="tag:yaml.org,2002:omap";var dg={collection:"seq",identify:e=>e instanceof Map,nodeClass:Ft,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=Mu.resolvePairs(e,t),i=[];for(let{key:n}of r.items)Vu.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Ft,r)},createNode:(e,t,r)=>Ft.from(e,t,r)};rs.YAMLOMap=Ft;rs.omap=dg});var Uu=k(ns=>{"use strict";var Wu=B();function zu({value:e,source:t},r){return t&&(e?Ju:Gu).test.test(t)?t:e?r.options.trueStr:r.options.falseStr}var Ju={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Wu.Scalar(!0),stringify:zu},Gu={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Wu.Scalar(!1),stringify:zu};ns.falseTag=Gu;ns.trueTag=Ju});var Ku=k(Fn=>{"use strict";var fg=B(),as=ur(),pg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:as.stringifyNumber},hg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():as.stringifyNumber(e)}},mg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new fg.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let i=e.substring(r+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:as.stringifyNumber};Fn.float=mg;Fn.floatExp=hg;Fn.floatNaN=pg});var Xu=k(ri=>{"use strict";var Yu=ur(),ti=e=>typeof e=="bigint"||Number.isInteger(e);function Ln(e,t,r,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,r);return n==="-"?-1*a:a}function os(e,t,r){let{value:i}=e;if(ti(i)){let n=i.toString(t);return i<0?"-"+r+n.substr(1):r+n}return Yu.stringifyNumber(e)}var vg={identify:ti,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Ln(e,2,2,r),stringify:e=>os(e,2,"0b")},gg={identify:ti,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Ln(e,1,8,r),stringify:e=>os(e,8,"0")},wg={identify:ti,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Ln(e,0,10,r),stringify:Yu.stringifyNumber},yg={identify:ti,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Ln(e,2,16,r),stringify:e=>os(e,16,"0x")};ri.int=wg;ri.intBin=vg;ri.intHex=yg;ri.intOct=gg});var cs=k(ss=>{"use strict";var Mn=_(),Bn=dt(),Vn=pt(),Lt=class e extends Vn.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let r;Mn.isPair(t)?r=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?r=new Bn.Pair(t.key,null):r=new Bn.Pair(t,null),Vn.findPair(this.items,r.key)||this.items.push(r)}get(t,r){let i=Vn.findPair(this.items,t);return!r&&Mn.isPair(i)?Mn.isScalar(i.key)?i.key.value:i.key:i}set(t,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let i=Vn.findPair(this.items,t);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new Bn.Pair(t))}toJSON(t,r){return super.toJSON(t,r,Set)}toString(t,r,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),r,i);throw new Error("Set items must all have null values")}static from(t,r,i){let{replacer:n}=i,a=new this(t);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof n=="function"&&(o=n.call(r,o,o)),a.items.push(Bn.createPair(o,null,i));return a}};Lt.tag="tag:yaml.org,2002:set";var Ng={collection:"map",identify:e=>e instanceof Set,nodeClass:Lt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Lt.from(e,t,r),resolve(e,t){if(Mn.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Lt,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};ss.YAMLSet=Lt;ss.set=Ng});var us=k(Wn=>{"use strict";var bg=ur();function ls(e,t){let r=e[0],i=r==="-"||r==="+"?e.substring(1):e,n=o=>t?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 Qu(e){let{value:t}=e,r=o=>o;if(typeof t=="bigint")r=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return bg.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let n=r(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),i+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var kg={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>ls(e,r),stringify:Qu},Sg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>ls(e,!1),stringify:Qu},Zu={identify:e=>e 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(e){let t=e.match(Zu.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,i,n,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,i-1,n,a||0,o||0,s||0,c),d=t[8];if(d&&d!=="Z"){let u=ls(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Wn.floatTime=Sg;Wn.intTime=kg;Wn.timestamp=Zu});var rd=k(td=>{"use strict";var Eg=cr(),xg=In(),Cg=lr(),Pg=Qr(),Rg=Zo(),ed=Uu(),ds=Ku(),zn=Xu(),_g=Sn(),Ag=is(),Ig=qn(),jg=cs(),fs=us(),Tg=[Eg.map,Cg.seq,Pg.string,xg.nullTag,ed.trueTag,ed.falseTag,zn.intBin,zn.intOct,zn.int,zn.intHex,ds.floatNaN,ds.floatExp,ds.float,Rg.binary,_g.merge,Ag.omap,Ig.pairs,jg.set,fs.intTime,fs.floatTime,fs.timestamp];td.schema=Tg});var fd=k(ms=>{"use strict";var od=cr(),$g=In(),sd=lr(),Og=Qr(),Hg=zo(),ps=Go(),hs=Ko(),Dg=Ou(),qg=qu(),cd=Zo(),ii=Sn(),ld=is(),ud=qn(),id=rd(),dd=cs(),Jn=us(),nd=new Map([["core",Dg.schema],["failsafe",[od.map,sd.seq,Og.string]],["json",qg.schema],["yaml11",id.schema],["yaml-1.1",id.schema]]),ad={binary:cd.binary,bool:Hg.boolTag,float:ps.float,floatExp:ps.floatExp,floatNaN:ps.floatNaN,floatTime:Jn.floatTime,int:hs.int,intHex:hs.intHex,intOct:hs.intOct,intTime:Jn.intTime,map:od.map,merge:ii.merge,null:$g.nullTag,omap:ld.omap,pairs:ud.pairs,seq:sd.seq,set:dd.set,timestamp:Jn.timestamp},Fg={"tag:yaml.org,2002:binary":cd.binary,"tag:yaml.org,2002:merge":ii.merge,"tag:yaml.org,2002:omap":ld.omap,"tag:yaml.org,2002:pairs":ud.pairs,"tag:yaml.org,2002:set":dd.set,"tag:yaml.org,2002:timestamp":Jn.timestamp};function Lg(e,t,r){let i=nd.get(t);if(i&&!e)return r&&!i.includes(ii.merge)?i.concat(ii.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(nd.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return r&&(n=n.concat(ii.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?ad[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(ad).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}ms.coreKnownTags=Fg;ms.getTags=Lg});var ws=k(pd=>{"use strict";var vs=_(),Bg=cr(),Vg=lr(),Mg=Qr(),Gn=fd(),Wg=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,gs=class e{constructor({compat:t,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?Gn.getTags(t,"compat"):t?Gn.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Gn.coreKnownTags:{},this.tags=Gn.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,vs.MAP,{value:Bg.map}),Object.defineProperty(this,vs.SCALAR,{value:Mg.string}),Object.defineProperty(this,vs.SEQ,{value:Vg.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Wg:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};pd.Schema=gs});var md=k(hd=>{"use strict";var zg=_(),ys=Kr(),ni=zr();function Jg(e,t){let r=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(r.push(c),i=!0):e.directives.docStart&&(i=!0)}i&&r.push("---");let n=ys.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){r.length!==1&&r.unshift("");let c=a(e.commentBefore);r.unshift(ni.indentComment(c,""))}let o=!1,s=null;if(e.contents){if(zg.isNode(e.contents)){if(e.contents.spaceBefore&&i&&r.push(""),e.contents.commentBefore){let d=a(e.contents.commentBefore);r.push(ni.indentComment(d,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let c=s?void 0:()=>o=!0,l=ys.stringify(e.contents,n,()=>s=null,c);s&&(l+=ni.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(ys.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=a(e.comment);c.includes(`
58
- `)?(r.push("..."),r.push(ni.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=e.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&r[r.length-1]!==""&&r.push(""),r.push(ni.indentComment(a(c),"")))}return r.join(`
57
+ ${a.comment}`:i.comment}i=n}t.items[r]=pa.isPair(i)?i:new Os.Pair(i)}}else e("Expected a sequence for this tag");return t}function $d(t,e,r){let{replacer:i}=r,n=new Cw.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(Os.createPair(s,c,r))}return n}var Rw={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:jd,createNode:$d};fa.createPairs=$d;fa.pairs=Rw;fa.resolvePairs=jd});var Bs=k(Ds=>{"use strict";var Od=A(),Hs=vt(),wi=kt(),Pw=St(),Hd=ha(),Jt=class t extends Pw.YAMLSeq{constructor(){super(),this.add=wi.YAMLMap.prototype.add.bind(this),this.delete=wi.YAMLMap.prototype.delete.bind(this),this.get=wi.YAMLMap.prototype.get.bind(this),this.has=wi.YAMLMap.prototype.has.bind(this),this.set=wi.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(Od.isPair(n)?(a=Hs.toJS(n.key,"",r),o=Hs.toJS(n.value,a,r)):a=Hs.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=Hd.createPairs(e,r,i),a=new this;return a.items=n.items,a}};Jt.tag="tag:yaml.org,2002:omap";var _w={collection:"seq",identify:t=>t instanceof Map,nodeClass:Jt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=Hd.resolvePairs(t,e),i=[];for(let{key:n}of r.items)Od.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Jt,r)},createNode:(t,e,r)=>Jt.from(t,e,r)};Ds.YAMLOMap=Jt;Ds.omap=_w});var qd=k(Ls=>{"use strict";var Dd=V();function Bd({value:t,source:e},r){return e&&(t?Ld:Fd).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Ld={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 Dd.Scalar(!0),stringify:Bd},Fd={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 Dd.Scalar(!1),stringify:Bd};Ls.falseTag=Fd;Ls.trueTag=Ld});var Md=k(ma=>{"use strict";var Aw=V(),Fs=Sr(),Iw={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:Fs.stringifyNumber},Tw={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():Fs.stringifyNumber(t)}},jw={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 Aw.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:Fs.stringifyNumber};ma.float=jw;ma.floatExp=Tw;ma.floatNaN=Iw});var Wd=k(Ni=>{"use strict";var Vd=Sr(),yi=t=>typeof t=="bigint"||Number.isInteger(t);function va(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 qs(t,e,r){let{value:i}=t;if(yi(i)){let n=i.toString(e);return i<0?"-"+r+n.substr(1):r+n}return Vd.stringifyNumber(t)}var $w={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>va(t,2,2,r),stringify:t=>qs(t,2,"0b")},Ow={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>va(t,1,8,r),stringify:t=>qs(t,8,"0")},Hw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>va(t,0,10,r),stringify:Vd.stringifyNumber},Dw={identify:yi,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>va(t,2,16,r),stringify:t=>qs(t,16,"0x")};Ni.int=Hw;Ni.intBin=$w;Ni.intHex=Dw;Ni.intOct=Ow});var Vs=k(Ms=>{"use strict";var ya=A(),ga=Nt(),wa=kt(),Ut=class t extends wa.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;ya.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new ga.Pair(e.key,null):r=new ga.Pair(e,null),wa.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let i=wa.findPair(this.items,e);return!r&&ya.isPair(i)?ya.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=wa.findPair(this.items,e);i&&!r?this.items.splice(this.items.indexOf(i),1):!i&&r&&this.items.push(new ga.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(ga.createPair(o,null,i));return a}};Ut.tag="tag:yaml.org,2002:set";var Bw={collection:"map",identify:t=>t instanceof Set,nodeClass:Ut,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Ut.from(t,e,r),resolve(t,e){if(ya.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ut,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Ms.YAMLSet=Ut;Ms.set=Bw});var zs=k(Na=>{"use strict";var Lw=Sr();function Ws(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 zd(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Lw.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 Fw={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})=>Ws(t,r),stringify:zd},qw={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=>Ws(t,!1),stringify:zd},Gd={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(Gd.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),d=e[8];if(d&&d!=="Z"){let u=Ws(d,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Na.floatTime=qw;Na.intTime=Fw;Na.timestamp=Gd});var Kd=k(Ud=>{"use strict";var Mw=br(),Vw=sa(),Ww=kr(),zw=vi(),Gw=$s(),Jd=qd(),Gs=Md(),ba=Wd(),Jw=Zn(),Uw=Bs(),Kw=ha(),Yw=Vs(),Js=zs(),Xw=[Mw.map,Ww.seq,zw.string,Vw.nullTag,Jd.trueTag,Jd.falseTag,ba.intBin,ba.intOct,ba.int,ba.intHex,Gs.floatNaN,Gs.floatExp,Gs.float,Gw.binary,Jw.merge,Uw.omap,Kw.pairs,Yw.set,Js.intTime,Js.floatTime,Js.timestamp];Ud.schema=Xw});var ap=k(Ys=>{"use strict";var Zd=br(),Qw=sa(),ep=kr(),Zw=vi(),ey=Cs(),Us=Ps(),Ks=As(),ty=Pd(),ry=Id(),tp=$s(),bi=Zn(),rp=Bs(),ip=ha(),Yd=Kd(),np=Vs(),ka=zs(),Xd=new Map([["core",ty.schema],["failsafe",[Zd.map,ep.seq,Zw.string]],["json",ry.schema],["yaml11",Yd.schema],["yaml-1.1",Yd.schema]]),Qd={binary:tp.binary,bool:ey.boolTag,float:Us.float,floatExp:Us.floatExp,floatNaN:Us.floatNaN,floatTime:ka.floatTime,int:Ks.int,intHex:Ks.intHex,intOct:Ks.intOct,intTime:ka.intTime,map:Zd.map,merge:bi.merge,null:Qw.nullTag,omap:rp.omap,pairs:ip.pairs,seq:ep.seq,set:np.set,timestamp:ka.timestamp},iy={"tag:yaml.org,2002:binary":tp.binary,"tag:yaml.org,2002:merge":bi.merge,"tag:yaml.org,2002:omap":rp.omap,"tag:yaml.org,2002:pairs":ip.pairs,"tag:yaml.org,2002:set":np.set,"tag:yaml.org,2002:timestamp":ka.timestamp};function ny(t,e,r){let i=Xd.get(e);if(i&&!t)return r&&!i.includes(bi.merge)?i.concat(bi.merge):i.slice();let n=i;if(!n)if(Array.isArray(t))n=[];else{let a=Array.from(Xd.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(bi.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Qd[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Qd).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}Ys.coreKnownTags=iy;Ys.getTags=ny});var Zs=k(op=>{"use strict";var Xs=A(),ay=br(),oy=kr(),sy=vi(),Sa=ap(),cy=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Qs=class t{constructor({compat:e,customTags:r,merge:i,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?Sa.getTags(e,"compat"):e?Sa.getTags(null,e):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?Sa.coreKnownTags:{},this.tags=Sa.getTags(r,this.name,i),this.toStringOptions=s??null,Object.defineProperty(this,Xs.MAP,{value:ay.map}),Object.defineProperty(this,Xs.SCALAR,{value:sy.string}),Object.defineProperty(this,Xs.SEQ,{value:oy.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?cy:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};op.Schema=Qs});var cp=k(sp=>{"use strict";var ly=A(),ec=fi(),ki=li();function uy(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=ec.createStringifyContext(t,e),{commentString:a}=n.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=a(t.commentBefore);r.unshift(ki.indentComment(c,""))}let o=!1,s=null;if(t.contents){if(ly.isNode(t.contents)){if(t.contents.spaceBefore&&i&&r.push(""),t.contents.commentBefore){let d=a(t.contents.commentBefore);r.push(ki.indentComment(d,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>o=!0,l=ec.stringify(t.contents,n,()=>s=null,c);s&&(l+=ki.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(ec.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=a(t.comment);c.includes(`
58
+ `)?(r.push("..."),r.push(ki.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(ki.indentComment(a(c),"")))}return r.join(`
59
59
  `)+`
60
- `}hd.stringifyDocument=Jg});var ai=k(vd=>{"use strict";var Gg=Mr(),dr=pn(),he=_(),Ug=dt(),Kg=st(),Yg=ws(),Xg=md(),Ns=ln(),Qg=Eo(),Zg=Wr(),bs=So(),ks=class e{constructor(t,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,he.NODE_TYPE,{value:he.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 bs.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[he.NODE_TYPE]:{value:he.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=he.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){fr(this.contents)&&this.contents.add(t)}addIn(t,r){fr(this.contents)&&this.contents.addIn(t,r)}createAlias(t,r){if(!t.anchor){let i=Ns.anchorNames(this);t.anchor=!r||i.has(r)?Ns.findNewAnchor(r||"a",i):r}return new Gg.Alias(t.anchor)}createNode(t,r,i){let n;if(typeof r=="function")t=r.call({"":t},"",t),n=r;else if(Array.isArray(r)){let g=b=>typeof b=="number"||b instanceof String||b instanceof Number,v=r.filter(g).map(String);v.length>0&&(r=r.concat(v)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:d}=i??{},{onAnchor:u,setAnchors:f,sourceObjects:h}=Ns.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:h},p=Zg.createNode(t,d,m);return s&&he.isCollection(p)&&(p.flow=!0),f(),p}createPair(t,r,i={}){let n=this.createNode(t,null,i),a=this.createNode(r,null,i);return new Ug.Pair(n,a)}delete(t){return fr(this.contents)?this.contents.delete(t):!1}deleteIn(t){return dr.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):fr(this.contents)?this.contents.deleteIn(t):!1}get(t,r){return he.isCollection(this.contents)?this.contents.get(t,r):void 0}getIn(t,r){return dr.isEmptyPath(t)?!r&&he.isScalar(this.contents)?this.contents.value:this.contents:he.isCollection(this.contents)?this.contents.getIn(t,r):void 0}has(t){return he.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return dr.isEmptyPath(t)?this.contents!==void 0:he.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,r){this.contents==null?this.contents=dr.collectionFromPath(this.schema,[t],r):fr(this.contents)&&this.contents.set(t,r)}setIn(t,r){dr.isEmptyPath(t)?this.contents=r:this.contents==null?this.contents=dr.collectionFromPath(this.schema,Array.from(t),r):fr(this.contents)&&this.contents.setIn(t,r)}setSchema(t,r={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new bs.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new bs.Directives({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(t);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 Yg.Schema(Object.assign(i,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:r,mapAsMap:i,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Kg.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:d}of s.anchors.values())a(d,l);return typeof o=="function"?Qg.applyReviver(o,{"":c},"",c):c}toJSON(t,r){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:r})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let r=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return Xg.stringifyDocument(this,t)}};function fr(e){if(he.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}vd.Document=ks});var ci=k(si=>{"use strict";var oi=class extends Error{constructor(t,r,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=r}},Ss=class extends oi{constructor(t,r,i){super("YAMLParseError",t,r,i)}},Es=class extends oi{constructor(t,r,i){super("YAMLWarning",t,r,i)}},ew=(e,t)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(s=>t.linePos(s));let{line:i,col:n}=r.linePos[0];r.message+=` at line ${i}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[i-1],t.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=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);s.length>80&&(s=s.substring(0,79)+`…
60
+ `}sp.stringifyDocument=uy});var Si=k(lp=>{"use strict";var dy=si(),Er=Vn(),ge=A(),py=Nt(),fy=vt(),hy=Zs(),my=cp(),tc=Ln(),vy=as(),gy=ci(),rc=ns(),ic=class t{constructor(e,r,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ge.NODE_TYPE,{value:ge.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 rc.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,{[ge.NODE_TYPE]:{value:ge.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=ge.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){xr(this.contents)&&this.contents.add(e)}addIn(e,r){xr(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let i=tc.anchorNames(this);e.anchor=!r||i.has(r)?tc.findNewAnchor(r||"a",i):r}return new dy.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 g=N=>typeof N=="number"||N instanceof String||N instanceof Number,v=r.filter(g).map(String);v.length>0&&(r=r.concat(v)),n=r}else i===void 0&&r&&(i=r,r=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:d}=i??{},{onAnchor:u,setAnchors:p,sourceObjects:f}=tc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:f},h=gy.createNode(e,d,m);return s&&ge.isCollection(h)&&(h.flow=!0),p(),h}createPair(e,r,i={}){let n=this.createNode(e,null,i),a=this.createNode(r,null,i);return new py.Pair(n,a)}delete(e){return xr(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Er.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):xr(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return ge.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Er.isEmptyPath(e)?!r&&ge.isScalar(this.contents)?this.contents.value:this.contents:ge.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return ge.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Er.isEmptyPath(e)?this.contents!==void 0:ge.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Er.collectionFromPath(this.schema,[e],r):xr(this.contents)&&this.contents.set(e,r)}setIn(e,r){Er.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Er.collectionFromPath(this.schema,Array.from(e),r):xr(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 rc.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 rc.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 hy.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=fy.toJS(this.contents,r??"",s);if(typeof a=="function")for(let{count:l,res:d}of s.anchors.values())a(d,l);return typeof o=="function"?vy.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 my.stringifyDocument(this,e)}};function xr(t){if(ge.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}lp.Document=ic});var Ci=k(xi=>{"use strict";var Ei=class extends Error{constructor(e,r,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=r}},nc=class extends Ei{constructor(e,r,i){super("YAMLParseError",e,r,i)}},ac=class extends Ei{constructor(e,r,i){super("YAMLWarning",e,r,i)}},wy=(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
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+=`:
62
62
 
63
63
  ${o}
64
64
  ${l}
65
- `}};si.YAMLError=oi;si.YAMLParseError=Ss;si.YAMLWarning=Es;si.prettifyError=ew});var li=k(gd=>{"use strict";function tw(e,{flow:t,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,d=s,u="",f="",h=!1,m=!1,p=null,g=null,v=null,b=null,N=null,y=null,E=null;for(let S of e)switch(m&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&a(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),p&&(l&&S.type!=="comment"&&S.type!=="newline"&&a(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),S.type){case"space":!t&&(r!=="doc-start"||i?.type!=="flow-collection")&&S.source.includes(" ")&&(p=S),d=!0;break;case"comment":{d||a(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let I=S.source.substring(1)||" ";u?u+=f+I:u=I,f="",l=!1;break}case"newline":l?u?u+=S.source:(!y||r!=="seq-item-ind")&&(c=!0):f+=S.source,l=!0,h=!0,(g||v)&&(b=S),d=!0;break;case"anchor":g&&a(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&a(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=S,E??(E=S.offset),l=!1,d=!1,m=!0;break;case"tag":{v&&a(S,"MULTIPLE_TAGS","A node can have at most one tag"),v=S,E??(E=S.offset),l=!1,d=!1,m=!0;break}case r:(g||v)&&a(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),y&&a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${t??"collection"}`),y=S,l=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(t){N&&a(S,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),N=S,l=!1,d=!1;break}default:a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),l=!1,d=!1}let w=e[e.length-1],R=w?w.offset+w.source.length:n;return m&&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:N,found:y,spaceBefore:c,comment:u,hasNewline:h,anchor:g,tag:v,newlineAfterProp:b,end:R,start:E??R}}gd.resolveProps=tw});var Un=k(wd=>{"use strict";function xs(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
66
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(xs(t.key)||xs(t.value))return!0}return!1;default:return!0}}wd.containsNewline=xs});var Cs=k(yd=>{"use strict";var rw=Un();function iw(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&rw.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}yd.flowIndentCheck=iw});var Ps=k(bd=>{"use strict";var Nd=_();function nw(e,t,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||Nd.isScalar(a)&&Nd.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,r))}bd.mapIncludes=nw});var Pd=k(Cd=>{"use strict";var kd=dt(),aw=pt(),Sd=li(),ow=Un(),Ed=Cs(),sw=Ps(),xd="All mapping items must start at the same column";function cw({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??aw.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let d of i.items){let{start:u,key:f,sep:h,value:m}=d,p=Sd.resolveProps(u,{indicator:"explicit-key-ind",next:f??h?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!p.found;if(g){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",xd)),!p.anchor&&!p.tag&&!h){l=p.end,p.comment&&(s.comment?s.comment+=`
67
- `+p.comment:s.comment=p.comment);continue}(p.newlineAfterProp||ow.containsNewline(f))&&n(f??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==i.indent&&n(c,"BAD_INDENT",xd);r.atKey=!0;let v=p.end,b=f?e(r,f,p,n):t(r,v,u,null,p,n);r.schema.compat&&Ed.flowIndentCheck(i.indent,f,n),r.atKey=!1,sw.mapIncludes(r,s.items,b)&&n(v,"DUPLICATE_KEY","Map keys must be unique");let N=Sd.resolveProps(h??[],{indicator:"map-value-ind",next:m,offset:b.range[2],onError:n,parentIndent:i.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=N.end,N.found){g&&(m?.type==="block-map"&&!N.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<N.found.offset-1024&&n(b.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let y=m?e(r,m,N,n):t(r,c,h,null,N,n);r.schema.compat&&Ed.flowIndentCheck(i.indent,m,n),c=y.range[2];let E=new kd.Pair(b,y);r.options.keepSourceTokens&&(E.srcToken=d),s.items.push(E)}else{g&&n(b.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),N.comment&&(b.comment?b.comment+=`
68
- `+N.comment:b.comment=N.comment);let y=new kd.Pair(b);r.options.keepSourceTokens&&(y.srcToken=d),s.items.push(y)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}Cd.resolveBlockMap=cw});var _d=k(Rd=>{"use strict";var lw=ht(),uw=li(),dw=Cs();function fw({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=a?.nodeClass??lw.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:d,value:u}of i.items){let f=uw.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)u?.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 h=u?e(r,u,f,n):t(r,f.end,d,null,f,n);r.schema.compat&&dw.flowIndentCheck(i.indent,u,n),c=h.range[2],s.items.push(h)}return s.range=[i.offset,c,l??c],s}Rd.resolveBlockSeq=fw});var pr=k(Ad=>{"use strict";function pw(e,t,r,i){let n="";if(e){let a=!1,o="";for(let s of e){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 d=c.substring(1)||" ";n?n+=o+d:n=d,o="";break}case"newline":n&&(o+=c),a=!0;break;default:i(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}Ad.resolveEnd=pw});var $d=k(Td=>{"use strict";var hw=_(),mw=dt(),Id=pt(),vw=ht(),gw=pr(),jd=li(),ww=Un(),yw=Ps(),Rs="Block collections are not allowed within flow collections",_s=e=>e&&(e.type==="block-map"||e.type==="block-seq");function Nw({composeNode:e,composeEmptyNode:t},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Id.YAMLMap:vw.YAMLSeq),l=new c(r.schema);l.flow=!0;let d=r.atRoot;d&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let v=i.items[g],{start:b,key:N,sep:y,value:E}=v,w=jd.resolveProps(b,{flow:s,indicator:"explicit-key-ind",next:N??y?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!w.found){if(!w.anchor&&!w.tag&&!y&&!E){g===0&&w.comma?n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):g<i.items.length-1&&n(w.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),w.comment&&(l.comment?l.comment+=`
69
- `+w.comment:l.comment=w.comment),u=w.end;continue}!o&&r.options.strict&&ww.containsNewline(N)&&n(N,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)w.comma&&n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(w.comma||n(w.start,"MISSING_CHAR",`Missing , between ${s} items`),w.comment){let R="";e:for(let S of b)switch(S.type){case"comma":case"space":break;case"comment":R=S.source.substring(1);break e;default:break e}if(R){let S=l.items[l.items.length-1];hw.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
70
- `+R:S.comment=R,w.comment=w.comment.substring(R.length+1)}}if(!o&&!y&&!w.found){let R=E?e(r,E,w,n):t(r,w.end,y,null,w,n);l.items.push(R),u=R.range[2],_s(E)&&n(R.range,"BLOCK_IN_FLOW",Rs)}else{r.atKey=!0;let R=w.end,S=N?e(r,N,w,n):t(r,R,b,null,w,n);_s(N)&&n(S.range,"BLOCK_IN_FLOW",Rs),r.atKey=!1;let I=jd.resolveProps(y??[],{flow:s,indicator:"map-value-ind",next:E,offset:S.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(I.found){if(!o&&!w.found&&r.options.strict){if(y)for(let F of y){if(F===I.found)break;if(F.type==="newline"){n(F,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}w.start<I.found.offset-1024&&n(I.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(I.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let K=E?e(r,E,I,n):I.found?t(r,I.end,y,null,I,n):null;K?_s(E)&&n(K.range,"BLOCK_IN_FLOW",Rs):I.comment&&(S.comment?S.comment+=`
71
- `+I.comment:S.comment=I.comment);let Ne=new mw.Pair(S,K);if(r.options.keepSourceTokens&&(Ne.srcToken=v),o){let F=l;yw.mapIncludes(r,F.items,S)&&n(R,"DUPLICATE_KEY","Map keys must be unique"),F.items.push(Ne)}else{let F=new Id.YAMLMap(r.schema);F.flow=!0,F.items.push(Ne);let qr=(K??S).range;F.range=[S.range[0],qr[1],qr[2]],l.items.push(F)}u=K?K.range[2]:I.end}}let f=o?"}":"]",[h,...m]=i.end,p=u;if(h?.source===f)p=h.offset+h.source.length;else{let g=s[0].toUpperCase()+s.substring(1),v=d?`${g} must end with a ${f}`:`${g} in block collection must be sufficiently indented and end with a ${f}`;n(u,d?"MISSING_CHAR":"BAD_INDENT",v),h&&h.source.length!==1&&m.unshift(h)}if(m.length>0){let g=gw.resolveEnd(m,p,r.options.strict,n);g.comment&&(l.comment?l.comment+=`
72
- `+g.comment:l.comment=g.comment),l.range=[i.offset,p,g.offset]}else l.range=[i.offset,p,p];return l}Td.resolveFlowCollection=Nw});var Hd=k(Od=>{"use strict";var bw=_(),kw=B(),Sw=pt(),Ew=ht(),xw=Pd(),Cw=_d(),Pw=$d();function As(e,t,r,i,n,a){let o=r.type==="block-map"?xw.resolveBlockMap(e,t,r,i,a):r.type==="block-seq"?Cw.resolveBlockSeq(e,t,r,i,a):Pw.resolveFlowCollection(e,t,r,i,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function Rw(e,t,r,i,n){let a=i.tag,o=a?t.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:h}=i,m=f&&a?f.offset>a.offset?f:a:f??a;m&&(!h||h.offset<m.offset)&&n(m,"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===Sw.YAMLMap.tagName&&s==="map"||o===Ew.YAMLSeq.tagName&&s==="seq")return As(e,t,r,n,o);let c=t.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!c){let f=t.schema.knownTags[o];if(f?.collection===s)t.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),As(e,t,r,n,o)}let l=As(e,t,r,n,o,c),d=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),t.options)??l,u=bw.isNode(d)?d:new kw.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Od.composeCollection=Rw});var js=k(Dd=>{"use strict";var Is=B();function _w(e,t,r){let i=t.offset,n=Aw(t,e.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?Is.Scalar.BLOCK_FOLDED:Is.Scalar.BLOCK_LITERAL,o=t.source?Iw(t.source):[],s=o.length;for(let p=o.length-1;p>=0;--p){let g=o[p][1];if(g===""||g==="\r")s=p;else break}if(s===0){let p=n.chomp==="+"&&o.length>0?`
73
- `.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:p,type:a,comment:n.comment,range:[i,g,g]}}let c=t.indent+n.indent,l=t.offset+n.length,d=0;for(let p=0;p<s;++p){let[g,v]=o[p];if(v===""||v==="\r")n.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&r(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=g.length),d=p,c===0&&!e.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+v.length+1}for(let p=o.length-1;p>=s;--p)o[p][0].length>c&&(s=p+1);let u="",f="",h=!1;for(let p=0;p<d;++p)u+=o[p][0].slice(c)+`
74
- `;for(let p=d;p<s;++p){let[g,v]=o[p];l+=g.length+v.length+1;let b=v[v.length-1]==="\r";if(b&&(v=v.slice(0,-1)),v&&g.length<c){let y=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-v.length-(b?2:1),"BAD_INDENT",y),g=""}a===Is.Scalar.BLOCK_LITERAL?(u+=f+g.slice(c)+v,f=`
75
- `):g.length>c||v[0]===" "?(f===" "?f=`
76
- `:!h&&f===`
77
- `&&(f=`
65
+ `}};xi.YAMLError=Ei;xi.YAMLParseError=nc;xi.YAMLWarning=ac;xi.prettifyError=wy});var Ri=k(up=>{"use strict";function yy(t,{flow:e,indicator:r,next:i,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,d=s,u="",p="",f=!1,m=!1,h=null,g=null,v=null,N=null,b=null,y=null,E=null;for(let S of t)switch(m&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&a(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(l&&S.type!=="comment"&&S.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),S.type){case"space":!e&&(r!=="doc-start"||i?.type!=="flow-collection")&&S.source.includes(" ")&&(h=S),d=!0;break;case"comment":{d||a(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let T=S.source.substring(1)||" ";u?u+=p+T:u=T,p="",l=!1;break}case"newline":l?u?u+=S.source:(!y||r!=="seq-item-ind")&&(c=!0):p+=S.source,l=!0,f=!0,(g||v)&&(N=S),d=!0;break;case"anchor":g&&a(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&a(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=S,E??(E=S.offset),l=!1,d=!1,m=!0;break;case"tag":{v&&a(S,"MULTIPLE_TAGS","A node can have at most one tag"),v=S,E??(E=S.offset),l=!1,d=!1,m=!0;break}case r:(g||v)&&a(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),y&&a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${e??"collection"}`),y=S,l=r==="seq-item-ind"||r==="explicit-key-ind",d=!1;break;case"comma":if(e){b&&a(S,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=S,l=!1,d=!1;break}default:a(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),l=!1,d=!1}let w=t[t.length-1],_=w?w.offset+w.source.length:n;return m&&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&&(l&&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:y,spaceBefore:c,comment:u,hasNewline:f,anchor:g,tag:v,newlineAfterProp:N,end:_,start:E??_}}up.resolveProps=yy});var Ea=k(dp=>{"use strict";function oc(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(oc(e.key)||oc(e.value))return!0}return!1;default:return!0}}dp.containsNewline=oc});var sc=k(pp=>{"use strict";var Ny=Ea();function by(t,e,r){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===t&&(i.source==="]"||i.source==="}")&&Ny.containsNewline(e)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}pp.flowIndentCheck=by});var cc=k(hp=>{"use strict";var fp=A();function ky(t,e,r){let{uniqueKeys:i}=t.options;if(i===!1)return!1;let n=typeof i=="function"?i:(a,o)=>a===o||fp.isScalar(a)&&fp.isScalar(o)&&a.value===o.value;return e.some(a=>n(a.key,r))}hp.mapIncludes=ky});var Np=k(yp=>{"use strict";var mp=Nt(),Sy=kt(),vp=Ri(),Ey=Ea(),gp=sc(),xy=cc(),wp="All mapping items must start at the same column";function Cy({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Sy.YAMLMap,s=new o(r.schema);r.atRoot&&(r.atRoot=!1);let c=i.offset,l=null;for(let d of i.items){let{start:u,key:p,sep:f,value:m}=d,h=vp.resolveProps(u,{indicator:"explicit-key-ind",next:p??f?.[0],offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!h.found;if(g){if(p&&(p.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&n(c,"BAD_INDENT",wp)),!h.anchor&&!h.tag&&!f){l=h.end,h.comment&&(s.comment?s.comment+=`
67
+ `+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Ey.containsNewline(p))&&n(p??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(c,"BAD_INDENT",wp);r.atKey=!0;let v=h.end,N=p?t(r,p,h,n):e(r,v,u,null,h,n);r.schema.compat&&gp.flowIndentCheck(i.indent,p,n),r.atKey=!1,xy.mapIncludes(r,s.items,N)&&n(v,"DUPLICATE_KEY","Map keys must be unique");let b=vp.resolveProps(f??[],{indicator:"map-value-ind",next:m,offset:N.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=b.end,b.found){g&&(m?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<b.found.offset-1024&&n(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let y=m?t(r,m,b,n):e(r,c,f,null,b,n);r.schema.compat&&gp.flowIndentCheck(i.indent,m,n),c=y.range[2];let E=new mp.Pair(N,y);r.options.keepSourceTokens&&(E.srcToken=d),s.items.push(E)}else{g&&n(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(N.comment?N.comment+=`
68
+ `+b.comment:N.comment=b.comment);let y=new mp.Pair(N);r.options.keepSourceTokens&&(y.srcToken=d),s.items.push(y)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[i.offset,c,l??c],s}yp.resolveBlockMap=Cy});var kp=k(bp=>{"use strict";var Ry=St(),Py=Ri(),_y=sc();function Ay({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=a?.nodeClass??Ry.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:d,value:u}of i.items){let p=Py.resolveProps(d,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||u)u?.type==="block-seq"?n(p.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=p.end,p.comment&&(s.comment=p.comment);continue}let f=u?t(r,u,p,n):e(r,p.end,d,null,p,n);r.schema.compat&&_y.flowIndentCheck(i.indent,u,n),c=f.range[2],s.items.push(f)}return s.range=[i.offset,c,l??c],s}bp.resolveBlockSeq=Ay});var Cr=k(Sp=>{"use strict";function Iy(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 d=c.substring(1)||" ";n?n+=o+d:n=d,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}}Sp.resolveEnd=Iy});var Rp=k(Cp=>{"use strict";var Ty=A(),jy=Nt(),Ep=kt(),$y=St(),Oy=Cr(),xp=Ri(),Hy=Ea(),Dy=cc(),lc="Block collections are not allowed within flow collections",uc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function By({composeNode:t,composeEmptyNode:e},r,i,n,a){let o=i.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Ep.YAMLMap:$y.YAMLSeq),l=new c(r.schema);l.flow=!0;let d=r.atRoot;d&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let v=i.items[g],{start:N,key:b,sep:y,value:E}=v,w=xp.resolveProps(N,{flow:s,indicator:"explicit-key-ind",next:b??y?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!w.found){if(!w.anchor&&!w.tag&&!y&&!E){g===0&&w.comma?n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):g<i.items.length-1&&n(w.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),w.comment&&(l.comment?l.comment+=`
69
+ `+w.comment:l.comment=w.comment),u=w.end;continue}!o&&r.options.strict&&Hy.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)w.comma&&n(w.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(w.comma||n(w.start,"MISSING_CHAR",`Missing , between ${s} items`),w.comment){let _="";e:for(let S of N)switch(S.type){case"comma":case"space":break;case"comment":_=S.source.substring(1);break e;default:break e}if(_){let S=l.items[l.items.length-1];Ty.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
70
+ `+_:S.comment=_,w.comment=w.comment.substring(_.length+1)}}if(!o&&!y&&!w.found){let _=E?t(r,E,w,n):e(r,w.end,y,null,w,n);l.items.push(_),u=_.range[2],uc(E)&&n(_.range,"BLOCK_IN_FLOW",lc)}else{r.atKey=!0;let _=w.end,S=b?t(r,b,w,n):e(r,_,N,null,w,n);uc(b)&&n(S.range,"BLOCK_IN_FLOW",lc),r.atKey=!1;let T=xp.resolveProps(y??[],{flow:s,indicator:"map-value-ind",next:E,offset:S.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(T.found){if(!o&&!w.found&&r.options.strict){if(y)for(let q of y){if(q===T.found)break;if(q.type==="newline"){n(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}w.start<T.found.offset-1024&&n(T.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(T.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let Q=E?t(r,E,T,n):T.found?e(r,T.end,y,null,T,n):null;Q?uc(E)&&n(Q.range,"BLOCK_IN_FLOW",lc):T.comment&&(S.comment?S.comment+=`
71
+ `+T.comment:S.comment=T.comment);let xe=new jy.Pair(S,Q);if(r.options.keepSourceTokens&&(xe.srcToken=v),o){let q=l;Dy.mapIncludes(r,q.items,S)&&n(_,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(xe)}else{let q=new Ep.YAMLMap(r.schema);q.flow=!0,q.items.push(xe);let ri=(Q??S).range;q.range=[S.range[0],ri[1],ri[2]],l.items.push(q)}u=Q?Q.range[2]:T.end}}let p=o?"}":"]",[f,...m]=i.end,h=u;if(f?.source===p)h=f.offset+f.source.length;else{let g=s[0].toUpperCase()+s.substring(1),v=d?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(u,d?"MISSING_CHAR":"BAD_INDENT",v),f&&f.source.length!==1&&m.unshift(f)}if(m.length>0){let g=Oy.resolveEnd(m,h,r.options.strict,n);g.comment&&(l.comment?l.comment+=`
72
+ `+g.comment:l.comment=g.comment),l.range=[i.offset,h,g.offset]}else l.range=[i.offset,h,h];return l}Cp.resolveFlowCollection=By});var _p=k(Pp=>{"use strict";var Ly=A(),Fy=V(),qy=kt(),My=St(),Vy=Np(),Wy=kp(),zy=Rp();function dc(t,e,r,i,n,a){let o=r.type==="block-map"?Vy.resolveBlockMap(t,e,r,i,a):r.type==="block-seq"?Wy.resolveBlockSeq(t,e,r,i,a):zy.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 Gy(t,e,r,i,n){let a=i.tag,o=a?e.directives.tagName(a.source,p=>n(a,"TAG_RESOLVE_FAILED",p)):null;if(r.type==="block-seq"){let{anchor:p,newlineAfterProp:f}=i,m=p&&a?p.offset>a.offset?p:a:p??a;m&&(!f||f.offset<m.offset)&&n(m,"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===qy.YAMLMap.tagName&&s==="map"||o===My.YAMLSeq.tagName&&s==="seq")return dc(t,e,r,n,o);let c=e.schema.tags.find(p=>p.tag===o&&p.collection===s);if(!c){let p=e.schema.knownTags[o];if(p?.collection===s)e.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else return p?n(a,"BAD_COLLECTION_TYPE",`${p.tag} used for ${s} collection, but expects ${p.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),dc(t,e,r,n,o)}let l=dc(t,e,r,n,o,c),d=c.resolve?.(l,p=>n(a,"TAG_RESOLVE_FAILED",p),e.options)??l,u=Ly.isNode(d)?d:new Fy.Scalar(d);return u.range=l.range,u.tag=o,c?.format&&(u.format=c.format),u}Pp.composeCollection=Gy});var fc=k(Ap=>{"use strict";var pc=V();function Jy(t,e,r){let i=e.offset,n=Uy(e,t.options.strict,r);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let a=n.mode===">"?pc.Scalar.BLOCK_FOLDED:pc.Scalar.BLOCK_LITERAL,o=e.source?Ky(e.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
73
+ `.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return e.source&&(g+=e.source.length),{value:h,type:a,comment:n.comment,range:[i,g,g]}}let c=e.indent+n.indent,l=e.offset+n.length,d=0;for(let h=0;h<s;++h){let[g,v]=o[h];if(v===""||v==="\r")n.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&r(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=g.length),d=h,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+v.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let u="",p="",f=!1;for(let h=0;h<d;++h)u+=o[h][0].slice(c)+`
74
+ `;for(let h=d;h<s;++h){let[g,v]=o[h];l+=g.length+v.length+1;let N=v[v.length-1]==="\r";if(N&&(v=v.slice(0,-1)),v&&g.length<c){let y=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;r(l-v.length-(N?2:1),"BAD_INDENT",y),g=""}a===pc.Scalar.BLOCK_LITERAL?(u+=p+g.slice(c)+v,p=`
75
+ `):g.length>c||v[0]===" "?(p===" "?p=`
76
+ `:!f&&p===`
77
+ `&&(p=`
78
78
 
79
- `),u+=f+g.slice(c)+v,f=`
80
- `,h=!0):v===""?f===`
79
+ `),u+=p+g.slice(c)+v,p=`
80
+ `,f=!0):v===""?p===`
81
81
  `?u+=`
82
- `:f=`
83
- `:(u+=f+v,f=" ",h=!1)}switch(n.chomp){case"-":break;case"+":for(let p=s;p<o.length;++p)u+=`
84
- `+o[p][0].slice(c);u[u.length-1]!==`
82
+ `:p=`
83
+ `:(u+=p+v,p=" ",f=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<o.length;++h)u+=`
84
+ `+o[h][0].slice(c);u[u.length-1]!==`
85
85
  `&&(u+=`
86
86
  `);break;default:u+=`
87
- `}let m=i+n.length+t.source.length;return{value:u,type:a,comment:n.comment,range:[i,m,m]}}function Aw({offset:e,props:t},r,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],a=n[0],o=0,s="",c=-1;for(let f=1;f<n.length;++f){let h=n[f];if(!s&&(h==="-"||h==="+"))s=h;else{let m=Number(h);!o&&m?o=m:c===-1&&(c=e+f)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,d="",u=n.length;for(let f=1;f<t.length;++f){let h=t[f];switch(h.type){case"space":l=!0;case"newline":u+=h.source.length;break;case"comment":r&&!l&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=h.source.length,d=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),u+=h.source.length;break;default:{let m=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",m);let p=h.source;p&&typeof p=="string"&&(u+=p.length)}}}return{mode:a,indent:o,chomp:s,comment:d,length:u}}function Iw(e){let t=e.split(/\n( *)/),r=t[0],i=r.match(/^( *)/),a=[i?.[1]?[i[1],r.slice(i[1].length)]:["",r]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}Dd.resolveBlockScalar=_w});var $s=k(Fd=>{"use strict";var Ts=B(),jw=pr();function Tw(e,t,r){let{offset:i,type:n,source:a,end:o}=e,s,c,l=(f,h,m)=>r(i+f,h,m);switch(n){case"scalar":s=Ts.Scalar.PLAIN,c=$w(a,l);break;case"single-quoted-scalar":s=Ts.Scalar.QUOTE_SINGLE,c=Ow(a,l);break;case"double-quoted-scalar":s=Ts.Scalar.QUOTE_DOUBLE,c=Hw(a,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+a.length,i+a.length]}}let d=i+a.length,u=jw.resolveEnd(o,d,t,r);return{value:c,type:s,comment:u.comment,range:[i,d,u.offset]}}function $w(e,t){let r="";switch(e[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 ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),qd(e)}function Ow(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),qd(e.slice(1,-1)).replace(/''/g,"'")}function qd(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
+ `}let m=i+n.length+e.source.length;return{value:u,type:a,comment:n.comment,range:[i,m,m]}}function Uy({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 p=1;p<n.length;++p){let f=n[p];if(!s&&(f==="-"||f==="+"))s=f;else{let m=Number(f);!o&&m?o=m:c===-1&&(c=t+p)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,d="",u=n.length;for(let p=1;p<e.length;++p){let f=e[p];switch(f.type){case"space":l=!0;case"newline":u+=f.source.length;break;case"comment":r&&!l&&i(f,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=f.source.length,d=f.source.substring(1);break;case"error":i(f,"UNEXPECTED_TOKEN",f.message),u+=f.source.length;break;default:{let m=`Unexpected token in block scalar header: ${f.type}`;i(f,"UNEXPECTED_TOKEN",m);let h=f.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:d,length:u}}function Ky(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}Ap.resolveBlockScalar=Jy});var mc=k(Tp=>{"use strict";var hc=V(),Yy=Cr();function Xy(t,e,r){let{offset:i,type:n,source:a,end:o}=t,s,c,l=(p,f,m)=>r(i+p,f,m);switch(n){case"scalar":s=hc.Scalar.PLAIN,c=Qy(a,l);break;case"single-quoted-scalar":s=hc.Scalar.QUOTE_SINGLE,c=Zy(a,l);break;case"double-quoted-scalar":s=hc.Scalar.QUOTE_DOUBLE,c=eN(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 d=i+a.length,u=Yy.resolveEnd(o,d,e,r);return{value:c,type:s,comment:u.comment,range:[i,d,u.offset]}}function Qy(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}`),Ip(t)}function Zy(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Ip(t.slice(1,-1)).replace(/''/g,"'")}function Ip(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
88
88
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
89
- `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let n=i[1],a=" ",o=t.lastIndex;for(r.lastIndex=o;i=r.exec(e);)i[1]===""?a===`
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(e),n+a+(i?.[1]??"")}function Hw(e,t){let r="";for(let i=1;i<e.length-1;++i){let n=e[i];if(!(n==="\r"&&e[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 eN(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}=Dw(e,i);r+=a,i=o}else if(n==="\\"){let a=e[++i],o=qw[a];if(o)r+=o;else if(a===`
94
- `)for(a=e[i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="\r"&&e[i+1]===`
95
- `)for(a=e[++i+1];a===" "||a===" ";)a=e[++i+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;r+=Fw(e,i+1,s,t),i+=s}else{let s=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),r+=s}}else if(n===" "||n===" "){let a=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
96
- `&&!(o==="\r"&&e[i+2]===`
97
- `)&&(r+=i>a?e.slice(a,i+1):n)}else r+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}function Dw(e,t){let r="",i=e[t+1];for(;(i===" "||i===" "||i===`
98
- `||i==="\r")&&!(i==="\r"&&e[t+2]!==`
93
+ `){let{fold:a,offset:o}=tN(t,i);r+=a,i=o}else if(n==="\\"){let a=t[++i],o=rN[a];if(o)r+=o;else if(a===`
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+=iN(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
+ `&&!(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 tN(t,e){let r="",i=t[e+1];for(;(i===" "||i===" "||i===`
98
+ `||i==="\r")&&!(i==="\r"&&t[e+2]!==`
99
99
  `);)i===`
100
100
  `&&(r+=`
101
- `),t+=1,i=e[t+1];return r||(r=" "),{fold:r,offset:t}}var qw={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Fw(e,t,r,i){let n=e.substr(t,r),o=n.length===r&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,r+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Fd.resolveFlowScalar=Tw});var Vd=k(Bd=>{"use strict";var Bt=_(),Ld=B(),Lw=js(),Bw=$s();function Vw(e,t,r,i){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?Lw.resolveBlockScalar(e,t,i):Bw.resolveFlowScalar(t,e.options.strict,i),c=r?e.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[Bt.SCALAR]:c?l=Mw(e.schema,n,c,r,i):t.type==="scalar"?l=Ww(e,n,t,i):l=e.schema[Bt.SCALAR];let d;try{let u=l.resolve(n,f=>i(r??t,"TAG_RESOLVE_FAILED",f),e.options);d=Bt.isScalar(u)?u:new Ld.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);i(r??t,"TAG_RESOLVE_FAILED",f),d=new Ld.Scalar(n)}return d.range=s,d.source=n,a&&(d.type=a),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function Mw(e,t,r,i,n){if(r==="!")return e[Bt.SCALAR];let a=[];for(let s of e.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(t))return s;let o=e.knownTags[r];return o&&!o.collection?(e.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"),e[Bt.SCALAR])}function Ww({atKey:e,directives:t,schema:r},i,n,a){let o=r.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(i))||r[Bt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[Bt.SCALAR];if(o.tag!==s.tag){let c=t.tagString(o.tag),l=t.tagString(s.tag),d=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}Bd.composeScalar=Vw});var Wd=k(Md=>{"use strict";function zw(e,t,r){if(t){r??(r=t.length);for(let i=r-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];n?.type==="space";)e+=n.source.length,n=t[++i];break}}return e}Md.emptyScalarPosition=zw});var Gd=k(Hs=>{"use strict";var Jw=Mr(),Gw=_(),Uw=Hd(),zd=Vd(),Kw=pr(),Yw=Wd(),Xw={composeNode:Jd,composeEmptyNode:Os};function Jd(e,t,r,i){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,d=!0;switch(t.type){case"alias":l=Qw(e,t,i),(s||c)&&i(t,"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=zd.composeScalar(e,t,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=Uw.composeCollection(Xw,e,t,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let f=u instanceof Error?u.message:String(u);i(t,"RESOURCE_EXHAUSTION",f)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",u),d=!1}}return l??(l=Os(e,t.offset,void 0,null,r,i)),s&&l.anchor===""&&i(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!Gw.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&d&&(l.srcToken=t),l}function Os(e,t,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let d={type:"scalar",offset:Yw.emptyScalarPosition(t,r,i),indent:-1,source:""},u=zd.composeScalar(e,d,s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function Qw({options:e},{offset:t,source:r,end:i},n){let a=new Jw.Alias(r.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+r.length,s=Kw.resolveEnd(i,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}Hs.composeEmptyNode=Os;Hs.composeNode=Jd});var Yd=k(Kd=>{"use strict";var Zw=ai(),Ud=Gd(),ey=pr(),ty=li();function ry(e,t,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:t},e),c=new Zw.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=ty.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Ud.composeNode(l,n,d,o):Ud.composeEmptyNode(l,d.end,i,null,d,o);let u=c.contents.range[2],f=ey.resolveEnd(a,u,!1,o);return f.comment&&(c.comment=f.comment),c.range=[r,u,f.offset],c}Kd.composeDoc=ry});var qs=k(Zd=>{"use strict";var iy=nn("process"),ny=So(),ay=ai(),ui=ci(),Xd=_(),oy=Yd(),sy=pr();function di(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r=="string"?r.length:1)]}function Qd(e){let t="",r=!1,i=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":i?`
101
+ `),e+=1,i=t[e+1];return r||(r=" "),{fold:r,offset:e}}var rN={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
102
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function iN(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}}Tp.resolveFlowScalar=Xy});var Op=k($p=>{"use strict";var Kt=A(),jp=V(),nN=fc(),aN=mc();function oN(t,e,r,i){let{value:n,type:a,comment:o,range:s}=e.type==="block-scalar"?nN.resolveBlockScalar(t,e,i):aN.resolveFlowScalar(e,t.options.strict,i),c=r?t.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Kt.SCALAR]:c?l=sN(t.schema,n,c,r,i):e.type==="scalar"?l=cN(t,n,e,i):l=t.schema[Kt.SCALAR];let d;try{let u=l.resolve(n,p=>i(r??e,"TAG_RESOLVE_FAILED",p),t.options);d=Kt.isScalar(u)?u:new jp.Scalar(u)}catch(u){let p=u instanceof Error?u.message:String(u);i(r??e,"TAG_RESOLVE_FAILED",p),d=new jp.Scalar(n)}return d.range=s,d.source=n,a&&(d.type=a),c&&(d.tag=c),l.format&&(d.format=l.format),o&&(d.comment=o),d}function sN(t,e,r,i,n){if(r==="!")return t[Kt.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[Kt.SCALAR])}function cN({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[Kt.SCALAR];if(r.compat){let s=r.compat.find(c=>c.default&&c.test?.test(i))??r[Kt.SCALAR];if(o.tag!==s.tag){let c=e.tagString(o.tag),l=e.tagString(s.tag),d=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}$p.composeScalar=oN});var Dp=k(Hp=>{"use strict";function lN(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}Hp.emptyScalarPosition=lN});var Fp=k(gc=>{"use strict";var uN=si(),dN=A(),pN=_p(),Bp=Op(),fN=Cr(),hN=Dp(),mN={composeNode:Lp,composeEmptyNode:vc};function Lp(t,e,r,i){let n=t.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=r,l,d=!0;switch(e.type){case"alias":l=vN(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=Bp.composeScalar(t,e,c,i),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=pN.composeCollection(mN,t,e,r,i),s&&(l.anchor=s.source.substring(1))}catch(u){let p=u instanceof Error?u.message:String(u);i(e,"RESOURCE_EXHAUSTION",p)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),d=!1}}return l??(l=vc(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&&(!dN.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&&d&&(l.srcToken=e),l}function vc(t,e,r,i,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let d={type:"scalar",offset:hN.emptyScalarPosition(e,r,i),indent:-1,source:""},u=Bp.composeScalar(t,d,s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function vN({options:t},{offset:e,source:r,end:i},n){let a=new uN.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=fN.resolveEnd(i,o,t.strict,n);return a.range=[e,o,s.offset],s.comment&&(a.comment=s.comment),a}gc.composeEmptyNode=vc;gc.composeNode=Lp});var Vp=k(Mp=>{"use strict";var gN=Si(),qp=Fp(),wN=Cr(),yN=Ri();function NN(t,e,{offset:r,start:i,value:n,end:a},o){let s=Object.assign({_directives:e},t),c=new gN.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=yN.resolveProps(i,{indicator:"doc-start",next:n??a?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?qp.composeNode(l,n,d,o):qp.composeEmptyNode(l,d.end,i,null,d,o);let u=c.contents.range[2],p=wN.resolveEnd(a,u,!1,o);return p.comment&&(c.comment=p.comment),c.range=[r,u,p.offset],c}Mp.composeDoc=NN});var yc=k(Gp=>{"use strict";var bN=$n("process"),kN=ns(),SN=Si(),Pi=Ci(),Wp=A(),EN=Vp(),xN=Cr();function _i(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 zp(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"%":e[n+1]?.[0]!=="#"&&(n+=1),r=!1;break;default:r||(i=!0),r=!1}}return{comment:t,afterEmptyLine:i}}var Ds=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=di(r);a?this.warnings.push(new ui.YAMLWarning(o,i,n)):this.errors.push(new ui.YAMLParseError(o,i,n))},this.directives=new ny.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,r){let{comment:i,afterEmptyLine:n}=Qd(this.prelude);if(i){let a=t.contents;if(r)t.comment=t.comment?`${t.comment}
106
- ${i}`:i;else if(n||t.directives.docStart||!a)t.commentBefore=i;else if(Xd.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Xd.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 wc=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,i,n,a)=>{let o=_i(r);a?this.warnings.push(new Pi.YAMLWarning(o,i,n)):this.errors.push(new Pi.YAMLParseError(o,i,n))},this.directives=new kN.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:i,afterEmptyLine:n}=zp(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(Wp.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Wp.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)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Qd(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,r=!1,i=-1){for(let n of t)yield*this.next(n);yield*this.end(r,i)}*next(t){switch(iy.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(r,i,n)=>{let a=di(t);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let r=oy.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(t,"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(t.source);break;case"error":{let r=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new ui.YAMLParseError(di(t),"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 ui.YAMLParseError(di(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=sy.resolveEnd(t.end,t.offset+t.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 ui.YAMLParseError(di(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new ay.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}}};Zd.Composer=Ds});var rf=k(Kn=>{"use strict";var cy=js(),ly=$s(),uy=ci(),ef=Ur();function dy(e,t=!0,r){if(e){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 uy.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return ly.resolveFlowScalar(e,t,i);case"block-scalar":return cy.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function fy(e,t){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=ef.stringifyString({type:o,value:e},{implicitKey:r,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:i,source:`
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:zp(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(bN.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,i,n)=>{let a=_i(e);a[0]+=r,this.onError(a,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=EN.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 Pi.YAMLParseError(_i(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 Pi.YAMLParseError(_i(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let r=xN.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 Pi.YAMLParseError(_i(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 SN.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}}};Gp.Composer=wc});var Kp=k(xa=>{"use strict";var CN=fc(),RN=mc(),PN=Ci(),Jp=pi();function _N(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 PN.YAMLParseError([s,s+1],a,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return RN.resolveFlowScalar(t,e,i);case"block-scalar":return CN.resolveBlockScalar({options:{strict:e}},t,i)}}return null}function AN(t,e){let{implicitKey:r=!1,indent:i,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=e,s=Jp.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
110
  `}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
111
111
  `),d=s.substring(0,l),u=s.substring(l+1)+`
112
- `,f=[{type:"block-scalar-header",offset:a,indent:i,source:d}];return tf(f,c)||f.push({type:"newline",offset:-1,indent:i,source:`
113
- `}),{type:"block-scalar",offset:a,indent:i,props:f,source:u}}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 py(e,t,r={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=r,s="indent"in e?e.indent:null;if(i&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.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=ef.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":hy(e,c);break;case'"':Fs(e,c,"double-quoted-scalar");break;case"'":Fs(e,c,"single-quoted-scalar");break;default:Fs(e,c,"scalar")}}function hy(e,t){let r=t.indexOf(`
114
- `),i=t.substring(0,r),n=t.substring(r+1)+`
115
- `;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=i,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:i}];tf(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
116
- `});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function tf(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function Fs(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of i)a.offset+=n;delete e.props,Object.assign(e,{type:r,source:t,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
117
- `};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:r,indent:i,source:t,end:n})}}}Kn.createScalarToken=fy;Kn.resolveAsScalar=dy;Kn.setScalarValue=py});var af=k(nf=>{"use strict";var my=e=>"type"in e?Xn(e):Yn(e);function Xn(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=Xn(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=Yn(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=Yn(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=Yn(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function Yn({start:e,key:t,sep:r,value:i}){let n="";for(let a of e)n+=a.source;if(t&&(n+=Xn(t)),r)for(let a of r)n+=a.source;return i&&(n+=Xn(i)),n}nf.stringify=my});var lf=k(cf=>{"use strict";var Ls=Symbol("break visit"),vy=Symbol("skip children"),of=Symbol("remove item");function Vt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),sf(Object.freeze([]),e,t)}Vt.BREAK=Ls;Vt.SKIP=vy;Vt.REMOVE=of;Vt.itemAtPath=(e,t)=>{let r=e;for(let[i,n]of t){let a=r?.[i];if(a&&"items"in a)r=a.items[n];else return}return r};Vt.parentCollection=(e,t)=>{let r=Vt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=r?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function sf(e,t,r){let i=r(t,e);if(typeof i=="symbol")return i;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=sf(Object.freeze(e.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===Ls)return Ls;s===of&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}cf.visit=Vt});var Qn=k(ae=>{"use strict";var Bs=rf(),gy=af(),wy=lf(),Vs="\uFEFF",Ms="",Ws="",zs="",yy=e=>!!e&&"items"in e,Ny=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function by(e){switch(e){case Vs:return"<BOM>";case Ms:return"<DOC>";case Ws:return"<FLOW_END>";case zs:return"<SCALAR>";default:return JSON.stringify(e)}}function ky(e){switch(e){case Vs:return"byte-order-mark";case Ms:return"doc-mode";case Ws:return"flow-error-end";case zs:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
112
+ `,p=[{type:"block-scalar-header",offset:a,indent:i,source:d}];return Up(p,c)||p.push({type:"newline",offset:-1,indent:i,source:`
113
+ `}),{type:"block-scalar",offset:a,indent:i,props:p,source:u}}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 IN(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=Jp.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">":TN(t,c);break;case'"':Nc(t,c,"double-quoted-scalar");break;case"'":Nc(t,c,"single-quoted-scalar");break;default:Nc(t,c,"scalar")}}function TN(t,e){let r=e.indexOf(`
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}];Up(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 Up(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 Nc(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})}}}xa.createScalarToken=AN;xa.resolveAsScalar=_N;xa.setScalarValue=IN});var Xp=k(Yp=>{"use strict";var jN=t=>"type"in t?Ra(t):Ca(t);function Ra(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=Ra(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=Ca(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=Ca(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=Ca(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 Ca({start:t,key:e,sep:r,value:i}){let n="";for(let a of t)n+=a.source;if(e&&(n+=Ra(e)),r)for(let a of r)n+=a.source;return i&&(n+=Ra(i)),n}Yp.stringify=jN});var tf=k(ef=>{"use strict";var bc=Symbol("break visit"),$N=Symbol("skip children"),Qp=Symbol("remove item");function Yt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Zp(Object.freeze([]),t,e)}Yt.BREAK=bc;Yt.SKIP=$N;Yt.REMOVE=Qp;Yt.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};Yt.parentCollection=(t,e)=>{let r=Yt.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 Zp(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=Zp(Object.freeze(t.concat([[n,o]])),a.items[o],r);if(typeof s=="number")o=s-1;else{if(s===bc)return bc;s===Qp&&(a.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,t))}}return typeof i=="function"?i(e,t):i}ef.visit=Yt});var Pa=k(le=>{"use strict";var kc=Kp(),ON=Xp(),HN=tf(),Sc="\uFEFF",Ec="",xc="",Cc="",DN=t=>!!t&&"items"in t,BN=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function LN(t){switch(t){case Sc:return"<BOM>";case Ec:return"<DOC>";case xc:return"<FLOW_END>";case Cc:return"<SCALAR>";default:return JSON.stringify(t)}}function FN(t){switch(t){case Sc:return"byte-order-mark";case Ec:return"doc-mode";case xc:return"flow-error-end";case Cc: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(e[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}ae.createScalarToken=Bs.createScalarToken;ae.resolveAsScalar=Bs.resolveAsScalar;ae.setScalarValue=Bs.setScalarValue;ae.stringify=gy.stringify;ae.visit=wy.visit;ae.BOM=Vs;ae.DOCUMENT=Ms;ae.FLOW_END=Ws;ae.SCALAR=zs;ae.isCollection=yy;ae.isScalar=Ny;ae.prettyToken=by;ae.tokenType=ky});var Us=k(df=>{"use strict";var fi=Qn();function ke(e){switch(e){case void 0:case" ":case`
120
- `:case"\r":case" ":return!0;default:return!1}}var uf=new Set("0123456789ABCDEFabcdef"),Sy=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Zn=new Set(",[]{}"),Ey=new Set(` ,[]{}
121
- \r `),Js=e=>!e||Ey.has(e),Gs=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(t,r=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!r;let i=this.next??"stream";for(;i&&(r||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,r=this.buffer[t];for(;r===" "||r===" ";)r=this.buffer[++t];return!r||r==="#"||r===`
122
- `?!0:r==="\r"?this.buffer[t+1]===`
123
- `:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let r=this.buffer[t];if(this.indentNext>0){let i=0;for(;r===" ";)r=this.buffer[++i+t];if(r==="\r"){let n=this.buffer[i+t+1];if(n===`
124
- `||!n&&!this.atEnd)return t+i+1}return r===`
125
- `||i>=this.indentNext||!r&&!this.atEnd?t+i:-1}if(r==="-"||r==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&ke(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
126
- `,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){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 t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===fi.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let r=t.length,i=t.indexOf("#");for(;i!==-1;){let a=t[i-1];if(a===" "||a===" "){r=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let a=t[r-1];if(a===" "||a===" ")r-=1;else break}let n=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-r),yield*this.pushNewline(),"stream"}return yield fi.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&ke(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&&!ke(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&ke(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 t=this.getLine();if(t===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(t[r]){case"#":yield*this.pushCount(t.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(Js),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,r,i=-1;do t=yield*this.pushNewline(),t>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(t+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("..."))&&ke(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield fi.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(Js),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ke(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 t=this.charAt(0),r=this.buffer.indexOf(t,this.pos+1);if(t==="'")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(`
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=ON.stringify;le.visit=HN.visit;le.BOM=Sc;le.DOCUMENT=Ec;le.FLOW_END=xc;le.SCALAR=Cc;le.isCollection=DN;le.isScalar=BN;le.prettyToken=LN;le.tokenType=FN});var _c=k(nf=>{"use strict";var Ai=Pa();function Re(t){switch(t){case void 0:case" ":case`
120
+ `:case"\r":case" ":return!0;default:return!1}}var rf=new Set("0123456789ABCDEFabcdef"),qN=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),_a=new Set(",[]{}"),MN=new Set(` ,[]{}
121
+ \r `),Rc=t=>!t||MN.has(t),Pc=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
+ `?!0:r==="\r"?this.buffer[e+1]===`
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
+ `||!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==="...")&&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]===Ai.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 Ai.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(Rc),"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 Ai.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(Rc),"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 t=this.pos;for(;;){let r=this.buffer[++t];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=>ke(r)||r==="#")}*parseBlockScalar(){let t=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
- `:t=a,r=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
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(t+1);if(a===-1)break;t=this.buffer.indexOf(`
131
- `,a)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
132
- `;)i=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let a=t-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)t=a;else break}while(!0);return yield fi.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=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(ke(a)||t&&Zn.has(a))break;r=i}else if(ke(n)){let a=this.buffer[i+1];if(n==="\r"&&(a===`
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
+ `: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
+ `)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
+ `,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
+ `;)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 Ai.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&&_a.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==="#"||t&&Zn.has(a))break;if(n===`
136
- `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&Zn.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield fi.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,r){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(r&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(Js),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(ke(i)||r&&Zn.has(i)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,r=this.buffer[t];for(;!ke(r)&&r!==">";)r=this.buffer[++t];return yield*this.pushToIndex(r===">"?t+1:t,!1)}else{let t=this.pos+1,r=this.buffer[t];for(;r;)if(Sy.has(r))r=this.buffer[++t];else if(r==="%"&&uf.has(this.buffer[t+1])&&uf.has(this.buffer[t+2]))r=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
137
- `?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`
138
- `?yield*this.pushCount(2):0}*pushSpaces(t){let r=this.pos-1,i;do i=this.buffer[++r];while(i===" "||t&&i===" ");let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(t){let r=this.pos,i=this.buffer[r];for(;!t(i);)i=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};df.Lexer=Gs});var Ys=k(ff=>{"use strict";var Ks=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let r=0,i=this.lineStarts.length;for(;r<i;){let a=r+i>>1;this.lineStarts[a]<t?r=a+1:i=a}if(this.lineStarts[r]===t)return{line:r+1,col:1};if(r===0)return{line:0,col:t};let n=this.lineStarts[r-1];return{line:r,col:t-n+1}}}};ff.LineCounter=Ks});var Qs=k(gf=>{"use strict";var xy=nn("process"),pf=Qn(),Cy=Us();function mt(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function hf(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function vf(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ea(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function hr(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function ta(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function mf(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!mt(t.start,"explicit-key-ind")&&!mt(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,vf(t.value)?t.value.end?ta(t.value.end,t.sep):t.value.end=t.sep:ta(t.start,t.sep),delete t.sep)}var Xs=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Cy.Lexer,this.onNewLine=t}*parse(t,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(t,r))yield*this.next(i);r||(yield*this.end())}*next(t){if(this.source=t,xy.env.LOG_TOKENS&&console.log("|",pf.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let r=pf.tokenType(t);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+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let i=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:t}),this.offset+=t.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 t=this.peek(1);if(this.type==="doc-end"&&t?.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(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let r=t??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"&&mf(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&&hf(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 t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{hf(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let r=this.startBlockValue(t);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let r=ea(this.peek(2)),i=hr(r),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
135
+ `,a=this.buffer[i+1]):r=i),a==="#"||e&&_a.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&&_a.has(n))break;r=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Ai.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(Rc),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,i=this.charAt(1);if(Re(i)||r&&_a.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(qN.has(r))r=this.buffer[++e];else if(r==="%"&&rf.has(this.buffer[e+1])&&rf.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
+ `?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)}};nf.Lexer=Pc});var Ic=k(af=>{"use strict";var Ac=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}}}};af.LineCounter=Ac});var jc=k(uf=>{"use strict";var VN=$n("process"),of=Pa(),WN=_c();function Et(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function sf(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 lf(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 Aa(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 Rr(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 Ia(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 cf(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Et(e.start,"explicit-key-ind")&&!Et(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,lf(e.value)?e.value.end?Ia(e.value.end,e.sep):e.value.end=e.sep:Ia(e.start,e.sep),delete e.sep)}var Tc=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 WN.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,VN.env.LOG_TOKENS&&console.log("|",of.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=of.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"&&cf(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&&sf(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":{sf(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=Aa(this.peek(2)),i=Rr(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(t){let r=t.items[t.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):t.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)t.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){ta(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.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>t.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),t.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),t.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)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(mt(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(vf(r.key)&&!mt(r.sep,"newline")){let o=hr(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(mt(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=hr(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?t.items.push({start:a,key:null,sep:[this.sourceToken]}):mt(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?(t.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(t);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!mt(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&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let r=t.items[t.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):t.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){ta(n,r.start),n.push(this.sourceToken),t.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=t.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;r.value||mt(r.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let r=t.items[t.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(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?t.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?t.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?t.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?t.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":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);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===t.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=ea(i),a=hr(n);mf(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){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)){Ia(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(Et(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(lf(r.key)&&!Et(r.sep,"newline")){let o=Rr(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(Et(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Rr(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]}):Et(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&&!Et(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)){Ia(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||Et(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=Aa(i),a=Rr(n);cf(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:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){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=ea(t),i=hr(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=ea(t),i=hr(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,r){return this.type!=="comment"||this.indent<=r?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){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:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};gf.Parser=Xs});var kf=k(hi=>{"use strict";var wf=qs(),Py=ai(),pi=ci(),Ry=Ho(),_y=_(),Ay=Ys(),yf=Qs();function Nf(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Ay.LineCounter||null,prettyErrors:t}}function Iy(e,t={}){let{lineCounter:r,prettyErrors:i}=Nf(t),n=new yf.Parser(r?.addNewLine),a=new wf.Composer(t),o=Array.from(a.compose(n.parse(e)));if(i&&r)for(let s of o)s.errors.forEach(pi.prettifyError(e,r)),s.warnings.forEach(pi.prettifyError(e,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function bf(e,t={}){let{lineCounter:r,prettyErrors:i}=Nf(t),n=new yf.Parser(r?.addNewLine),a=new wf.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new pi.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(pi.prettifyError(e,r)),o.warnings.forEach(pi.prettifyError(e,r))),o}function jy(e,t,r){let i;typeof t=="function"?i=t:r===void 0&&t&&typeof t=="object"&&(r=t);let n=bf(e,r);if(!n)return null;if(n.warnings.forEach(a=>Ry.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 Ty(e,t,r){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),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(e===void 0){let{keepUndefined:n}=r??t??{};if(!n)return}return _y.isDocument(e)&&!i?e.toString(r):new Py.Document(e,i,r).toString(r)}hi.parse=jy;hi.parseAllDocuments=Iy;hi.parseDocument=bf;hi.stringify=Ty});var De=k(j=>{"use strict";var $y=qs(),Oy=ai(),Hy=ws(),Zs=ci(),Dy=Mr(),vt=_(),qy=dt(),Fy=B(),Ly=pt(),By=ht(),Vy=Qn(),My=Us(),Wy=Ys(),zy=Qs(),ra=kf(),Sf=Fr();j.Composer=$y.Composer;j.Document=Oy.Document;j.Schema=Hy.Schema;j.YAMLError=Zs.YAMLError;j.YAMLParseError=Zs.YAMLParseError;j.YAMLWarning=Zs.YAMLWarning;j.Alias=Dy.Alias;j.isAlias=vt.isAlias;j.isCollection=vt.isCollection;j.isDocument=vt.isDocument;j.isMap=vt.isMap;j.isNode=vt.isNode;j.isPair=vt.isPair;j.isScalar=vt.isScalar;j.isSeq=vt.isSeq;j.Pair=qy.Pair;j.Scalar=Fy.Scalar;j.YAMLMap=Ly.YAMLMap;j.YAMLSeq=By.YAMLSeq;j.CST=Vy;j.Lexer=My.Lexer;j.LineCounter=Wy.LineCounter;j.Parser=zy.Parser;j.parse=ra.parse;j.parseAllDocuments=ra.parseAllDocuments;j.parseDocument=ra.parseDocument;j.stringify=ra.stringify;j.visit=Sf.visit;j.visitAsync=Sf.visitAsync});function Yy(e){return e.toLowerCase().startsWith(".env")}function vi(e){let r=e.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>Yy(i))?"environment-file":r.some(i=>Ky.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Uy.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var Uy,Ky,gi=x(()=>{"use strict";Uy=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Ky=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});function yt(e){return e!==0&&e!==0n&&e!=="0"}function Ye(e,t){return yt(e.dev)&&yt(t.dev)&&yt(e.ino)&&yt(t.ino)}function O(e,t){let r=yt(e.dev)&&yt(t.dev);if(r&&e.dev!==t.dev)return!1;let i=yt(e.ino)&&yt(t.ino);return i&&e.ino!==t.ino?!1:r&&i?!0:e.birthtime===t.birthtime}var wi=x(()=>{"use strict"});var qe=x(()=>{"use strict";wi()});import{createHash as Xy}from"node:crypto";import{promises as Se}from"node:fs";import me from"node:path";import{TextDecoder as Qy}from"node:util";function tc(e,t){let r=me.relative(e,t);return r===""||!me.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${me.sep}`)}function Zy(e){let t=me.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||me.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let r=e.toLowerCase(),i=vi(e);if(i||r==="runtime"||r.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${i??"native-runtime"}): ${e}`);return e}function eN(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function tN(e,t){return O({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function na(e,t){let r={...e,birthtime:e.birthtimeMs},i={...t,birthtime:t.birthtimeMs};return Ye(r,i)?O(r,i):O(r,i)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function xf(e){let t=await Se.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await Se.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function rN(e,t){let r=me.resolve(e),i=me.resolve(t);if(!tc(r,i))throw new Error("Native artifact path is outside its root");let n=[await xf(r)],a=r;for(let o of me.relative(r,i).split(me.sep).filter(Boolean)){a=me.join(a,o);let s=await xf(a);if(!tc(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Cf(e){for(let t of e){let r=await Se.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!tN(t,r)||await Se.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function H(e){let t=Zy(e.ref),r=e.maxBytes===null?null:eN(e.maxBytes??Pf),i=me.resolve(e.root,...t.split("/")),n=await rN(e.root,me.dirname(i));await e.hooks?.afterParentChainCaptured?.();let a=await Se.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(r!==null&&a.size>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);let o=await Se.realpath(i);if(!tc(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await Se.open(i,"r");try{let[c,l,d]=await Promise.all([s.stat(),Se.lstat(i),Se.realpath(i)]);if(await Cf(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!na(a,c)||!na(c,l))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let u=[],f=0,h=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let N=r===null?h.length:r+1-f,y=await s.read(h,0,Math.min(h.length,N),null);if(y.bytesRead===0)break;if(f+=y.bytesRead,r!==null&&f>r)throw new Error(`Native artifact exceeds ${r} bytes: ${t}`);u.push(Buffer.from(h.subarray(0,y.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[m,p,g]=await Promise.all([s.stat(),Se.lstat(i),Se.realpath(i)]);if(await Cf(n),!p.isFile()||p.isSymbolicLink()||g!==o||!na(c,m)||!na(c,p))throw new Error(`Native artifact changed while reading: ${t}`);let v=Buffer.concat(u,f),b;try{b=new Qy("utf-8",{fatal:!0}).decode(v)}catch(N){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:N})}return{ref:t,size:f,hash:e.includeHash===!1?null:Xy("sha256").update(v).digest("hex"),text:b}}finally{await s.close()}}var Pf,oe=x(()=>{"use strict";gi();qe();Pf=1024*1024});import{promises as ic}from"node:fs";async function nc(e,t){let r;for(let i=0;i<=rc.length;i+=1)try{return await e()}catch(n){r=n;let a=n.code;if(i===rc.length||!iN.has(a??""))throw n;await new Promise(o=>setTimeout(o,rc[i]))}throw r}async function ac(e,t){await nc(()=>ic.rename(e,t),`rename ${t}`)}async function oc(e){await nc(()=>ic.unlink(e),`unlink ${e}`)}async function sc(e,t){await nc(()=>ic.link(e,t),`link ${t}`)}var iN,rc,cc=x(()=>{"use strict";iN=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),rc=[50,100,200]});import{randomUUID as nN}from"crypto";import{promises as Q}from"fs";import Ee from"path";function aa(e,t){let r=Ee.relative(e,t);return r===""||!Ee.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Ee.sep}`)}function aN(e,t){return O({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function oa(e,t){return O({dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs},{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs})}function oN(e,t){return oa(e,t)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Rf(e){let t=await Q.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await Q.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function vr(e){for(let t of e){let r=await Q.lstat(t.path);if(!r.isDirectory()||r.isSymbolicLink()||!aN(t,r)||await Q.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function sN(e,t,r){let[i,n]=await Promise.all([Q.lstat(e),Q.realpath(e),r?vr(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!oa(i,t)||r&&!aa(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function cN(e,t){let r=Ee.resolve(e),i=Ee.resolve(t);if(!aa(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await Rf(r)],a=Ee.relative(r,i).split(Ee.sep).filter(Boolean),o=r;for(let s of a){await vr(n),o=Ee.join(o,s);try{await Q.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Rf(o);if(!aa(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await vr(n),n}async function lN(e){let t;try{t=await Q.open(e,"r"),await t.sync()}catch(r){let i=r.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(i??""))throw r}finally{await t?.close()}}async function uN(e,t,r={}){let i=Ee.dirname(e),n=r.containedRoot?await cN(r.containedRoot,i):null;n||await Q.mkdir(i,{recursive:!0});let a=Ee.join(i,`.${Ee.basename(e)}.${nN()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await Q.open(a,"wx"),s=await o.stat(),n){let[l,d]=await Promise.all([Q.lstat(a),Q.realpath(a)]);if(await vr(n),!l.isFile()||l.isSymbolicLink()||!oa(s,l)||!aa(n[0].realPath,d))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),c=await o.stat(),!oa(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 sN(a,c,n),await r.beforeCommit?.(),n){await vr(n);let l=await Q.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!oN(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await sc(a,e),await oc(a)):await ac(a,e),await lN(i)}catch(l){if(await o?.close(),!n)await Q.rm(a,{force:!0});else try{await vr(n),await Q.rm(a,{force:!0})}catch{}throw l}}async function Fe(e,t,r={}){await uN(e,t,r)}async function se(e,t,r={}){await Fe(e,JSON.stringify(t,null,2)+`
143
- `,r)}var D=x(()=>{"use strict";cc();qe()});function hN(e,t){return lc[e][t]}function sa(e){return["outcome","scope","nonGoals","acceptanceExamples","constraints","decisions","openQuestions","verificationExpectations"].map(r=>`# ${hN(e,r)}
144
- `).join(`
145
- `)}var lc,dN,fN,pN,_f,Mt=x(()=>{"use strict";lc={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:"验证预期"}},dN={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:"结论"}},fN={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:"结论"}},pN=new Map,_f=new Map;for(let e of Object.keys(lc)){for(let[t,r]of Object.entries(lc[e]))pN.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(dN[e]))_f.set(r.toLocaleLowerCase("en-US"),t);for(let[t,r]of Object.entries(fN[e]))_f.set(r.toLocaleLowerCase("en-US"),t)}});import Nt from"path";function yN(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||Nt.posix.isAbsolute(r)||Nt.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be a project-relative path`);if(r===".")return[];let i=r.replaceAll("\\","/").split("/");if(i.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(i.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return i}function Wt(e){let t=yN(e,"native.artifact_root");return t.length===0?".":t.join("/")}function Df(e,t="docs"){let r=e??t;if(r!=="legacy"&&r!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return r}function da(e,t,r=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim().replaceAll("\\","/");if(i.length===0||Nt.posix.isAbsolute(i)||Nt.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be relative to its declared path base`);let n=i.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!r&&/[*?]/u.test(i))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function Xe(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function qf(e,t,r){let i=e??t;if(i!=="en"&&i!=="zh-CN")throw new Error(`${r} must be en or zh-CN`);return i}function fa(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>la)throw new Error(`${t} exceeds ${la} characters`);let r=0;for(let i=0;i<e.length;i+=1)e[i]==="?"?r+=1:e[i]==="*"&&(r+=1,e[i+1]==="*"&&(i+=1));if(r>ua)throw new Error(`${t} contains more than ${ua} wildcard tokens`);return e}function $f(e,t,r){if(e===void 0)return[...r];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(i=>fa(i,t)))].sort((i,n)=>i.localeCompare(n,"en"))}function yi(e,t,r){let i=e??t;if(!Number.isSafeInteger(i)||i<1)throw new Error(`${r} must be a positive integer`);return i}function Of(e,t,r){let i=yi(e,t,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 NN(e){if(e===void 0)return{...ce,include:[...ce.include],exclude:[...ce.exclude]};let t=Xe(e,"native.snapshot");return{include:$f(t.include,"native.snapshot.include",ce.include),exclude:$f(t.exclude,"native.snapshot.exclude",ce.exclude),max_files:yi(t.max_files,ce.max_files,"native.snapshot.max_files"),max_total_bytes:yi(t.max_total_bytes,ce.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:yi(t.max_duration_ms,ce.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:yi(t.max_selection_records,ce.max_selection_records,"native.snapshot.max_selection_records")}}function bN(e){if(e===void 0)return;let t=Xe(e,"native.pending_root_move"),r=t.id,i=t.from_artifact_root,n=t.to_artifact_root,a=t.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(t.cleanup!==void 0){let s=Xe(t.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,d=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 d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:r,fromArtifactRoot:Wt(i),toArtifactRoot:Wt(n),stage:a,...o?{cleanup:o}:{}}}function kN(e){if(e===void 0)return;let t=Xe(e,"native.finish");if(t.pull_request===void 0)return{};let r=Xe(t.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(Nt.posix.isAbsolute(i[0])||Nt.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??mN;if(!Number.isSafeInteger(n)||n<1||n>Tf)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Tf}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function SN(e,t={}){let r=Xe(e,"native"),i=r.artifact_root??(t.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??dc;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=bN(r.pending_root_move),l=kN(r.finish);return{artifact_root:Wt(i),language:qf(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:NN(r.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function EN(e){let t=Xe(e,"classic"),r=t.context_compression??"off";if(r!=="off"&&r!=="beta")throw new Error("classic.context_compression must be off or beta");let i=t.review_mode??"standard";if(i!=="off"&&i!=="standard"&&i!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");let a=t.document_evidence??"neutral";if(a!=="neutral"&&a!=="strict")throw new Error("classic.document_evidence must be neutral or strict");return{artifact_layout:Df(t.artifact_layout),language:qf(t.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function xN(e){let r=Xe(e,"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)=>da(i,`hook.allow_paths[${n}]`)))]}}function CN(e){if(e===void 0)return{...ca};let t=Xe(e,"memory"),r=t.learning??ca.learning,i=t.retrieval??ca.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 fc(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function PN(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim();if(r.length===0||r.includes("\\")||r.includes("\0")||Nt.posix.isAbsolute(r)||Nt.win32.isAbsolute(r)||r.startsWith("~")||r.split("/").some(n=>n===""||n==="."||n===".."))throw new Error(`${t} must be a safe project-relative glob`);if(!r.toLowerCase().endsWith(".md"))throw new Error(`${t} must target a Markdown file ending in .md`);if(r.length>Af)throw new Error(`${t} exceeds ${Af} 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>If)throw new Error(`${t} contains more than ${If} wildcard tokens`);return r}function RN(e){let t=fc(e,"knowledge.local"),r=t.include??[];if(!Array.isArray(r))throw new Error("knowledge.local.include must be an array");let i={include:[...new Set(r.map((n,a)=>PN(n,`knowledge.local.include[${a}]`)))],max_file_mb:Of(t.max_file_mb,jf.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Of(t.max_total_mb,jf.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 _N(e){if(typeof e!="string"||e.trim().length===0)throw new Error("knowledge.remote.endpoint must be a non-empty URL");let t;try{t=new URL(e)}catch{throw new Error("knowledge.remote.endpoint must be a valid URL")}let r=t.hostname.toLowerCase().replace(/^\[|\]$/gu,""),i=r==="localhost"||r==="127.0.0.1"||r==="::1";if(t.protocol!=="https:"&&!(t.protocol==="http:"&&i))throw new Error("knowledge.remote.endpoint must use HTTPS (HTTP is allowed for loopback)");return t.toString()}function AN(e){let t=fc(e,"knowledge.remote"),r=_N(t.endpoint),i=t.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=t.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=t.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 IN(e){if(e===void 0)return{...Hf};let t=fc(e,"knowledge"),r=t.provider??"local";if(r!=="local"&&r!=="remote")throw new Error("knowledge.provider must be local or remote");let i=t.local===void 0?void 0:RN(t.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=t.remote===void 0?void 0:AN(t.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 jN(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function TN(e,t,r,i,n,a,o,s){let c=e.schema!==void 0;if(!(c||e.default_workflow!==void 0||e.workflows!==void 0||!s.allowPartialProject&&e.native!==void 0)||s.allowPartialProject&&!c)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let d=e.workflows??[e.default_workflow];if(!Array.isArray(d)||d.length===0||d.some(f=>f!=="native"&&f!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(d)];if(!u.includes(e.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:u,ambient_resume:o,...t?{hook:t}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function bi(e,t={}){let r=(0,uc.parseDocument)(e,{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=jN(n.ambient_resume),o=n.hook===void 0?void 0:xN(n.hook),s=CN(n.memory),c=IN(n.knowledge),l=n.native===void 0?void 0:SN(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),d=n.classic===void 0?void 0:EN(n.classic),u=TN(n,o,s,c,l,d,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...d?{classic:d}:{}}}function pa(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...ca},knowledge:{...Hf},native:{artifact_root:Wt(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:dc,snapshot:{...ce,include:[...ce.include],exclude:[...ce.exclude]}}}}var uc,Ni,la,ua,Af,If,dc,ca,jf,Hf,mN,Tf,vN,gN,wN,ce,bt=x(()=>{"use strict";uc=Je(De(),1),Ni=Number.MAX_SAFE_INTEGER,la=1024,ua=64,Af=1024,If=64,dc=5,ca={learning:!0,retrieval:!0},jf={include:[],max_file_mb:1,max_total_mb:32},Hf={provider:"local"},mN=12e4,Tf=6e5,vN=[".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/**"],gN=["**/.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"],wN=[...vN,...gN].sort((e,t)=>e.localeCompare(t,"en")),ce={include:["**/*"],exclude:[...wN],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as ha,promises as zt}from"fs";function pc(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function Ff(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function ki(e){return{dev:e.dev,ino:e.ino,birthtime:pc(e)}}function ma(e,t){let r=ki(e),i=ki(t);return Ye(r,i)?O(r,i):O(r,i)&&pc(e)===pc(t)&&Ff(e)===Ff(t)&&e.size===t.size}async function Si(e,t,r={}){if(!Number.isSafeInteger(t)||t<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 zt.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new Le("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new Le("too-large",`${i} exceeds ${t} bytes`);let o=await zt.realpath(e);await r.verify?.("pre-open",{realPath:o,identity:ki(a)});let s=process.platform==="win32"?ha.O_RDONLY:ha.O_RDONLY|ha.O_NOFOLLOW|ha.O_NONBLOCK,c;try{c=await zt.open(e,s)}catch(l){throw l.code==="ELOOP"?new Le("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,d,u]=await Promise.all([c.stat({bigint:n}),zt.lstat(e,{bigint:n}),zt.realpath(e)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||u!==o||!ma(a,l)||!ma(a,d))throw new Le("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:ki(l)}),await r.hooks?.afterOpen?.();let f=[],h=0,m=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let b=t+1-h,{bytesRead:N}=await c.read(m,0,Math.min(m.length,b),null);if(N===0)break;if(h+=N,h>t)throw new Le("too-large",`${i} exceeds ${t} bytes`);f.push(Buffer.from(m.subarray(0,N)))}await r.hooks?.beforeFinalCheck?.();let[p,g,v]=await Promise.all([c.stat({bigint:n}),zt.lstat(e,{bigint:n}),zt.realpath(e)]);if(!g.isFile()||g.isSymbolicLink()||v!==o||!ma(a,p)||!ma(a,g))throw new Le("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:v,identity:ki(p)}),{bytes:Buffer.concat(f,h),stat:p,realPath:v}}finally{await c.close()}}var Le,Ei=x(()=>{"use strict";wi();Le=class extends Error{reason;constructor(t,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=t}}});import{promises as va}from"fs";import kt from"path";function $N(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function hc(e,t){let r=kt.relative(e,t);return r===""||!kt.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${kt.sep}`)}async function Lf(e,t){let r=kt.resolve(e),i=await va.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return va.realpath(r)}async function Bf(e,t,r,i){let n=e;for(let a=0;a<r.length;a++){n=kt.join(n,r[a]);let o;try{o=await va.lstat(n)}catch(d){if($N(d))return{exists:!1,kind:"missing"};throw d}let s=kt.relative(e,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 va.realpath(n);if(!hc(t,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 gr(e,t,r){let i=da(t,r.label),n=kt.resolve(e),a=await Lf(n,r.label),o=i.split("/"),s=kt.resolve(n,...o);if(!hc(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await Bf(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Qe(e,t,r,i){let n=await gr(e,t,{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 Lf(n.projectRoot,i.label);return Si(n.target,r,{...i,verify:async(o,s)=>{if(!hc(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Bf(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var St=x(()=>{"use strict";Ei();bt()});import{createHash as ON}from"crypto";function HN(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function ga(e,t={}){return(await wa(e,t)).document}async function DN(e){try{return(await Qe(e,xi,Ni,{label:xi})).bytes}catch(t){if(HN(t))return null;throw t}}function qN(e){return e?{exists:!0,sha256:ON("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function wa(e,t={}){let r=await DN(e);return{document:r?bi(r.toString("utf8"),t):null,identity:qN(r)}}async function mc(e){return(await ga(e))?.config??null}var xi,wr=x(()=>{"use strict";bt();St();xi=".comet/config.yaml"});var yr=x(()=>{"use strict";cc();wi()});var BP,vc=x(()=>{"use strict";yr();wr();St();BP=16*1024});var yc=x(()=>{"use strict";yr();bt();wr();St();vc()});import{existsSync as Mf,promises as Jt}from"fs";import P from"path";import MN from"os";async function Nc(e){try{return await Jt.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function zN(e){try{let t=await Jt.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function br(e,t){let r=P.relative(e,t);return r===""||!P.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${P.sep}`)}async function Nr(e){let t=[],r=e;for(;!await Nc(r);){let n=P.dirname(r);if(n===r)break;t.push(P.basename(r)),r=n}let i=await Jt.realpath(r);return P.resolve(i,...t.reverse())}async function bc(e){try{return(await Jt.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Na(e){let t=P.resolve(e);try{(await Jt.stat(t)).isDirectory()||(t=P.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let r=t,i=P.resolve(MN.homedir());for(;;){if(!(t===i&&r!==i)){let o=P.join(t,...ya.split("/")),s=t===r||await zN(o);if(await Nc(o)&&s)return t}if(await Nc(P.join(t,".git")))return t;let a=P.dirname(t);if(a===t)return r;t=a}}function ba(e){return Wt(e)}async function JN(e,t){let r=ba(t),i=P.resolve(e,...r.split("/")),n=await Jt.realpath(e),a=await Nr(i);if(!br(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Be(e,t){let r=ba(t),i=await JN(e,r),n=P.join(i,"comet");if(await bc(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([Nr(i),Nr(n)]);if(!br(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=P.resolve(e),c=P.join(s,".comet","runtime","native");if(await bc(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,d]=await Promise.all([Jt.realpath(s),Nr(c)]);if(!br(l,d))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:P.join(e,...ya.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:P.join(n,"specs"),changesDir:P.join(n,"changes"),archiveDir:P.join(n,"archive"),runtimeDir:c,changesRuntimeDir:P.join(c,"changes"),locksDir:P.join(c,"locks"),transactionsDir:P.join(c,"transactions")}}function kc(e){if(!WN.test(e))throw new Error(`Invalid Native change name: ${e}`)}function Ve(e,t){kc(t);let r=P.join(e.changesRuntimeDir,t);if(!z(e.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function GN(e,t){kc(t);let r=P.join(e.changesDir,t,"runtime");if(!z(e.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Y(e,t){let r=Ve(e,t);if(Mf(r))return r;let i=GN(e,t);return Mf(i)?i:r}function Gt(e,t){kc(t);let r=P.join(e.changesDir,t),i=Y(e,t);return{artifactRoot:e.artifactRoot,nativeRoot:e.nativeRoot,changeDir:r,briefPath:P.join(r,"brief.md"),childrenPath:P.join(r,"children.yaml"),specsDir:P.join(r,"specs"),verificationPath:P.join(r,"verification.md"),statePath:P.join(r,"comet-state.yaml"),runtimeDir:i,runtimeStatePath:P.join(i,"state.json")}}function xe(e,t){let r=P.resolve(t);if(z(e.runtimeDir,r))return e.runtimeDir;if(z(e.nativeRoot,r))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function z(e,t){return br(P.resolve(e),P.resolve(t))}async function L(e,t){let r=P.resolve(e),i=P.resolve(t);if(!br(r,i))throw new Error(`Path is outside the Native root: ${t}`);if(await bc(r))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([Nr(r),Nr(i)]);if(!br(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return i}var ya,WN,A=x(()=>{"use strict";bt();ya=".comet/config.yaml",WN=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});function KN(e="docs",t="en"){return pa(e,t)}async function le(e){let t=(await ga(e))?.config??null;return t?.native?t:null}async function Wf(e){let t=await Na(e.startPath),r=await le(t);if(!r&&e.allowMissingConfig===!1)throw new Error(`${ya} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=e.explicitArtifactRoot?ba(e.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??KN(i??"docs"),a=await Be(t,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}var ka,fe=x(()=>{"use strict";bt();wr();yc();D();A();ka=fa});var cR,Sa=x(()=>{"use strict";cR=["$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("; ")});var dR,Ea=x(()=>{"use strict";Sa();dR=8*1024*1024});var xa=x(()=>{"use strict";Ea()});import{AsyncLocalStorage as ZN}from"async_hooks";var NR,bR,kR,Pi=x(()=>{"use strict";Ei();xa();A();qe();NR=16*1024,bR=900*1e3,kR=new ZN});var Gf,Sc=x(()=>{"use strict";Gf=Je(De(),1)});var Ze,Et,xt,Ri=x(()=>{"use strict";Ze="comet.native.v3",Et="comet.native.v2",xt="comet.native.v1"});import eb from"node:path";function Ii(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Xf(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function Ut(e){if(!Yf.test(e))throw new Error(`Invalid Native change name: ${e}`)}function Qf(e){if(!Yf.test(e))throw new Error(`Invalid Native capability id: ${e}`)}function Zf(e,t){if(e.length===0||eb.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native change`)}function cb(e,t){let r=Ii(e,`spec_changes[${t}]`);if(Xf(r,ib,`spec_changes[${t}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(Qf(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"&&Zf(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"||!xc.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"||!xc.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 lb(e){return/^\d{4}-\d{2}-\d{2}$/u.test(e)?new Date(`${e}T00:00:00.000Z`).toISOString().slice(0,10)===e:!1}function Cc(e,t){if(Xf(e,t,tt),typeof e.name!="string")throw new Error("Native change name is required");if(Ut(e.name),e.language!=="en"&&e.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof e.phase!="string"||!nb.has(e.phase))throw new Error("Native change phase is invalid");if(e.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(e.approval!==null&&!ab.has(e.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(e.spec_changes))throw new Error("Native spec_changes must be an array");let r=e.spec_changes.map(cb),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 e.verification_result!="string"||!ob.has(e.verification_result))throw new Error("Native verification_result is invalid");if(e.verification_report!==null&&typeof e.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof e.verification_report=="string"&&Zf(e.verification_report,"Native verification_report"),typeof e.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof e.created_at!="string"||!lb(e.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(e.run_id!==null&&(typeof e.run_id!="string"||e.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:e.name,language:e.language,phase:e.phase,brief:"brief.md",approval:e.approval,spec_changes:r,verification_result:e.verification_result,verification_report:e.verification_report,archived:e.archived,created_at:e.created_at,run_id:e.run_id}}function ji(e){let t=Ii(e,tt);if(t.schema!==xt)throw new Error(`Expected ${xt}`);return{schema:xt,...Cc(t,tb)}}function Ai(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function Ec(e,t,r){if(e===null)return null;let i=typeof e=="string"?sb.exec(e):null;if(!i||i[1]!==r)throw new Error(`${t} must be null or runtime/evidence/${r}/<sha256>.json relative to the Native change`);return e}function ub(e){if(e==null)return null;if(typeof e!="string"||!xc.test(e))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return e}function db(e){if(e===void 0)return"legacy-v1";if(e!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return e}function Ti(e){let t=Ii(e,tt);if(t.schema!==Et)throw new Error(`Expected ${Et}`);if(Ai(t.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:Ai(t.revision,"Native v2 revision"),...Cc(t,Kf)}}function kr(e){let t=Ii(e,tt);if(t.schema!==Ze){if(t.schema===xt||t.schema===Et){let o=t.schema===xt?ji(t):Ti(t);throw new _i(o.name,o.schema)}throw new Me(typeof t.schema=="string"?t.schema:"(missing)",typeof t.minimum_runtime_version=="number"?t.minimum_runtime_version:null)}let r=Ai(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Me(t.schema,r);if(r!==3)throw new Error(`Native ${t.schema} minimum_runtime_version must be ${3}`);let i=Ai(t.revision,"Native revision"),n=Cc(t,rb),a=ub(t.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ze,minimum_runtime_version:3,revision:i,verification_protocol:db(t.verification_protocol),...n,approved_contract_hash:a,implementation_scope:Ec(t.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Ec(t.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Ec(t.partial_allowance,"Native partial_allowance","allowances")}}function Pc(e){let t=Ii(e,tt);if(t.schema===xt){let n=ji(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ze}`}}if(t.schema===Et){let n=Ti(t);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ze}`}}if(t.schema!==Ze){let n=typeof t.minimum_runtime_version=="number"&&Number.isSafeInteger(t.minimum_runtime_version)?t.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof t.schema=="string"?t.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new Me(typeof t.schema=="string"?t.schema:"(missing)",n).message}}let r=Ai(t.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:t.schema,minimumRuntimeVersion:r,state:null,message:new Me(t.schema,r).message};let i=kr(t);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var Uf,tb,Kf,rb,ib,nb,ab,ob,tt,xc,Yf,sb,_i,Me,Ca=x(()=>{"use strict";Ri();Uf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],tb=new Set(Uf),Kf=new Set([...Uf,"minimum_runtime_version","revision"]),rb=new Set([...Kf,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),ib=new Set(["capability","operation","source","base_hash"]),nb=new Set(["shape","build","verify","archive"]),ab=new Set(["implicit","confirmed"]),ob=new Set(["pending","pass","fail"]),tt="comet-state.yaml",xc=/^[a-f0-9]{64}$/u,Yf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,sb=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,_i=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"},Me=class extends Error{constructor(r,i){super(r!==Ze||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 fb}from"crypto";function Ce(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function pb(e,t){t.has(e)&&Ce("cyclic structures are not supported"),t.add(e);try{let r=Object.keys(e);for(let i=0;i<e.length;i+=1)Object.prototype.hasOwnProperty.call(e,i)||Ce("sparse arrays are not supported");return(r.length!==e.length||r.some((i,n)=>i!==String(n)))&&Ce("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&Ce("symbol properties are not supported"),`[${e.map(i=>Rc(i,t)).join(",")}]`}finally{t.delete(e)}}function hb(e,t){let r=Object.getPrototypeOf(e);r!==Object.prototype&&r!==null&&Ce("only plain objects are supported"),t.has(e)&&Ce("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&Ce("symbol properties are not supported"),t.add(e);try{let i=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=i[o];return(!s||!("value"in s))&&Ce("accessor properties are not supported"),`${JSON.stringify(o)}:${Rc(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function Rc(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||Ce("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?pb(e,t):hb(e,t);case"bigint":case"function":case"symbol":case"undefined":return Ce(`${typeof e} values are not supported`)}return Ce("unsupported value type")}function _c(e){return Rc(e,new Set)}function T(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return fb("sha256").update(`${e}
146
- ${_c(t)}`).digest("hex")}var q=x(()=>{"use strict"});var TR,ep,$i=x(()=>{"use strict";Mt();q();TR=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),ep=Object.freeze({maxCriteria:1024})});var Ac=x(()=>{"use strict";$i()});function Ic(){return{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}}}var Sr,Pa,tp,Oi=x(()=>{"use strict";Sr="comet.native.v4",Pa="comet.native.local-execution.v4",tp=["multi-session","single-session"]});var Hc={};gm(Hc,{NativePortableStateVersionConflictError:()=>Hi,appendNativePortableHistory:()=>Di,compareAndSwapNativePortableState:()=>np,createNativePortableState:()=>ip,parseNativePortableState:()=>ue,readNativePortableState:()=>Ct,writeNativePortableState:()=>Oc});import{promises as wb}from"node:fs";function Z(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ee(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function J(e,t,r){if(typeof e!="string"||!r?.empty&&e.length===0)throw new Error(`${t} must be ${r?.empty?"a string":"a non-empty string"}`);return e}function Tc(e,t){return e===null?null:J(e,t)}function $c(e,t){let r=J(e,t);if(!kb.test(r))throw new Error(`${t} must be a SHA-256 hash`);return r}function Er(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function $(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function Eb(e,t){return e===null?null:$(e,t,Number.MIN_SAFE_INTEGER)}function V(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function We(e,t,r){if(!Array.isArray(e))throw new Error(`${t} must be an array`);return e.map((i,n)=>r(i,n))}function Ia(e,t){return We(e,t,(r,i)=>J(r,`${t}[${i}]`))}function Kt(e,t){if(new Set(e).size!==e.length)throw new Error(`${t} must be unique`)}function xr(e,t){let r=J(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO date or timestamp`);return r}function _a(e,t,r=!1){let i=J(e,t);if(i.includes("\\")||i.startsWith("/")||/^[A-Za-z]:/u.test(i)||i.split("/").includes("..")||!r&&(i==="."||i.split("/").includes(".")))throw new Error(`${t} must be a portable relative path`);return i}function ve(e,t){let r=Z(e,t);return ee(r,new Set(["text","truncated"]),t),{text:J(r.text,`${t}.text`,{empty:!0}),truncated:Er(r.truncated,`${t}.truncated`)}}function xb(e,t){let r=`Native spec_changes[${t}]`,i=Z(e,r);ee(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=J(i.capability,`${r}.capability`);if(!Nb.test(n))throw new Error(`${r}.capability is invalid`);let a=V(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:$c(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 Cb(e){let t="Native workspace",r=Z(e,t);ee(r,new Set(["isolation","change_branch","target_branch","finish"]),t);let i=V(r.isolation,["current","branch","worktree"],`${t}.isolation`),n=Tc(r.change_branch,`${t}.change_branch`),a=Tc(r.target_branch,`${t}.target_branch`),o=r.finish===null?null:V(r.finish,["merge","push","pull-request","keep"],`${t}.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 Pb(e){let t="Native loop",r=Z(e,t);ee(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"]),t);let i=Ia(r.previous_unresolved_ids,`${t}.previous_unresolved_ids`);Kt(i,`${t}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:V(r.stop_reason,["budget","stalled"],`${t}.stop_reason`);return{stage:V(r.stage,["shape","building","verify-ready","repairing","archive-ready","await-user","blocked","done"],`${t}.stage`),goal_cycle:$(r.goal_cycle,`${t}.goal_cycle`,1),iteration:$(r.iteration,`${t}.iteration`),attempt:$(r.attempt,`${t}.attempt`),retry_epoch:$(r.retry_epoch,`${t}.retry_epoch`),failed_iteration_count:$(r.failed_iteration_count,`${t}.failed_iteration_count`),no_progress_count:$(r.no_progress_count,`${t}.no_progress_count`),...n===void 0?{}:{stop_reason:n},execution_failure_count:$(r.execution_failure_count,`${t}.execution_failure_count`),previous_unresolved_ids:i,next_action:Tc(r.next_action,`${t}.next_action`)}}function Rb(e,t){let r=`Native acceptance[${t}]`,i=Z(e,r);ee(i,new Set(["id","source","text","result","reason"]),r);let n=J(i.id,`${r}.id`);if(!bb.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:_a(i.source,`${r}.source`),text:J(i.text,`${r}.text`),result:V(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ve(i.reason,`${r}.reason`)}}function _b(e,t){let r=`Native builder_handoff.checks[${t}]`,i=Z(e,r);return ee(i,new Set(["name","result","note"]),r),{name:ve(i.name,`${r}.name`),result:V(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ve(i.note,`${r}.note`)}}function Ab(e){let t="Native builder_handoff",r=Z(e,t);ee(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"]),t);let i=Ia(r.addressed_acceptance_ids,`${t}.addressed_acceptance_ids`);Kt(i,`${t}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:Z(r.review,`${t}.review`);return n&&ee(n,new Set(["status","summary","reviewer_execution_ref"]),`${t}.review`),{candidate_id:J(r.candidate_id,`${t}.candidate_id`),identity_provider:J(r.identity_provider,`${t}.identity_provider`),builder_execution_ref:J(r.builder_execution_ref,`${t}.builder_execution_ref`),iteration:$(r.iteration,`${t}.iteration`,1),summary:ve(r.summary,`${t}.summary`),addressed_acceptance_ids:i,checks:We(r.checks,`${t}.checks`,_b),checks_truncated:Er(r.checks_truncated,`${t}.checks_truncated`),known_limits:We(r.known_limits,`${t}.known_limits`,(a,o)=>ve(a,`${t}.known_limits[${o}]`)),known_limits_truncated:Er(r.known_limits_truncated,`${t}.known_limits_truncated`),review:n?{status:V(n.status,["passed"],`${t}.review.status`),summary:ve(n.summary,`${t}.review.summary`),reviewer_execution_ref:J(n.reviewer_execution_ref,`${t}.review.reviewer_execution_ref`)}:null,submitted_at:xr(r.submitted_at,`${t}.submitted_at`)}}function Ib(e,t){let r=`Native blockers[${t}]`,i=Z(e,r);ee(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=Ia(i.acceptance_ids,`${r}.acceptance_ids`);return Kt(n,`${r}.acceptance_ids`),{owner:V(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ve(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:V(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function jb(e,t){let r=`Native verification.checks[${t}]`,i=Z(e,r);return ee(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:J(i.id,`${r}.id`),name:ve(i.name,`${r}.name`),argv_display:We(i.argv_display,`${r}.argv_display`,(n,a)=>ve(n,`${r}.argv_display[${a}]`)),argv_truncated:Er(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:_a(i.cwd_ref,`${r}.cwd_ref`,!0),status:V(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Eb(i.exit_code,`${r}.exit_code`),duration_ms:$(i.duration_ms,`${r}.duration_ms`)}}function Tb(e){let t="Native verification",r=Z(e,t);ee(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),t);let i=We(r.checks,`${t}.checks`,jb);Kt(i.map(a=>a.id),`${t}.checks IDs`);let n=J(r.identity_provider,`${t}.identity_provider`);return{candidate_id:J(r.candidate_id,`${t}.candidate_id`),identity_provider:n,verifier_execution_ref:J(r.verifier_execution_ref,`${t}.verifier_execution_ref`),iteration:$(r.iteration,`${t}.iteration`,1),attempt:$(r.attempt,`${t}.attempt`,1),assurance:r.assurance===void 0?n==="skill-coordinated"?"skill-coordinated":"host-attested":V(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${t}.assurance`),verdict:V(r.verdict,["pass","fail","blocked"],`${t}.verdict`),checks:i,summary:ve(r.summary,`${t}.summary`),risks:We(r.risks,`${t}.risks`,(a,o)=>ve(a,`${t}.risks[${o}]`)),risks_truncated:Er(r.risks_truncated,`${t}.risks_truncated`),completed_at:xr(r.completed_at,`${t}.completed_at`)}}function rp(e,t){let r=`Native history[${t}]`,i=Z(e,r);ee(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=Ia(i.unresolved_ids,`${r}.unresolved_ids`);return Kt(n,`${r}.unresolved_ids`),{goal_cycle:$(i.goal_cycle,`${r}.goal_cycle`,1),iteration:$(i.iteration,`${r}.iteration`),attempt:$(i.attempt,`${r}.attempt`),outcome:V(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ve(i.summary,`${r}.summary`),completed_at:xr(i.completed_at,`${r}.completed_at`)}}function $b(e){let t="Native history_overflow.outcome_counts",r=Z(e,t),i=["pass","fail","blocked","execution-error","recovery"];return ee(r,new Set(i),t),{pass:$(r.pass,`${t}.pass`),fail:$(r.fail,`${t}.fail`),blocked:$(r.blocked,`${t}.blocked`),"execution-error":$(r["execution-error"],`${t}.execution-error`),recovery:$(r.recovery,`${t}.recovery`)}}function Ob(e){let t="Native history_overflow",r=Z(e,t);ee(r,new Set(["dropped_entries","first_dropped_at","last_dropped_at","outcome_counts"]),t);let i=$(r.dropped_entries,`${t}.dropped_entries`),n=r.first_dropped_at===null?null:xr(r.first_dropped_at,`${t}.first_dropped_at`),a=r.last_dropped_at===null?null:xr(r.last_dropped_at,`${t}.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=$b(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 Hb(e){let t=new Set(e.acceptance.map(r=>r.id));for(let r of e.loop.previous_unresolved_ids)if(!t.has(r))throw new Error(`Native loop references unknown acceptance ID ${r}`);for(let r of e.builder_handoff?.addressed_acceptance_ids??[])if(!t.has(r))throw new Error(`Native builder handoff references unknown ID ${r}`);for(let r of e.blockers)for(let i of r.acceptance_ids)if(!t.has(i))throw new Error(`Native blocker references unknown ID ${i}`);if(e.builder_handoff){if(!(e.builder_handoff.iteration===e.loop.iteration||e.phase==="build"&&e.loop.stage==="repairing"&&e.builder_handoff.iteration===e.loop.iteration-1))throw new Error("Native builder handoff iteration is not current or the prior repair result");if(e.builder_handoff.review?.reviewer_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native reviewer execution ref must differ from the Builder execution ref")}if(e.verification){if(!e.builder_handoff)throw new Error("Native verification requires a builder handoff");if(e.verification.candidate_id!==e.builder_handoff.candidate_id)throw new Error("Native verification candidate must match the builder handoff");if(e.verification.identity_provider!==e.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(e.verification.assurance)!==(e.verification.identity_provider==="skill-coordinated"))throw new Error("Native verification assurance does not match its identity provider");if(e.verification.assurance==="semantic-verification-unavailable"&&e.verification.verdict!=="blocked")throw new Error("Native unavailable semantic verification must remain blocked");if(e.verification.assurance==="user-confirmed-degraded"&&e.verification.verdict!=="pass")throw new Error("Native user-confirmed degraded verification must be passing");if(e.verification.verifier_execution_ref===e.builder_handoff.builder_execution_ref)throw new Error("Native Builder and Verifier execution refs must differ");let i=e.verification.iteration===e.loop.iteration&&e.verification.attempt===e.loop.attempt,n=e.phase==="build"&&e.loop.stage==="repairing"&&e.verification.iteration===e.loop.iteration-1&&e.verification.iteration===e.builder_handoff.iteration;if(!i&&!n)throw new Error("Native verification iteration and attempt do not match a stable loop result")}}function Db(e){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"])}[e.phase].has(e.loop.stage))throw new Error(`Native loop stage ${e.loop.stage} is invalid for phase ${e.phase}`);let r=e.status==="await-user"?"await-user":e.status==="blocked"?"blocked":e.status==="done"?"done":null;if(r!==null&&e.loop.stage!==r)throw new Error(`Native status ${e.status} requires loop stage ${r}`);if(e.status==="active"&&["await-user","blocked","done"].includes(e.loop.stage))throw new Error(`Native active status cannot use loop stage ${e.loop.stage}`);if(e.archived!==(e.status==="done"))throw new Error("Native archived must be true exactly when status is done");if(e.archived&&e.phase!=="archive")throw new Error("Native archived state must be in Archive");if(e.verification_result==="pass"){if(e.verification?.verdict!=="pass")throw new Error("Native pass requires a persisted passing verification");if(e.acceptance.some(i=>i.result!=="passed"))throw new Error("Native pass requires every acceptance item to pass");if(e.verification.checks.some(i=>i.status!=="passed"))throw new Error("Native pass requires every persisted check to pass")}if(e.verification?.assurance==="semantic-verification-unavailable"&&(e.phase!=="verify"||e.status!=="await-user"||e.verification_result!=="blocked"||e.loop.next_action!=="confirm-verifier-unavailable"))throw new Error("Native unavailable semantic verification must await explicit user confirmation");if(e.verification_report!==null&&e.verification===null)throw new Error("Native verification report requires persisted verification")}function ue(e){let t=Z(e,"Native portable state");if(ee(t,Sb,"Native portable state"),t.schema!==Sr)throw new Error(`Native portable state schema must be ${Sr}`);let r=J(t.name,"Native state name");if(!yb.test(r))throw new Error("Native state name is invalid");if(t.brief!=="brief.md")throw new Error("Native state brief must be brief.md");let i=We(t.spec_changes,"Native spec_changes",xb);Kt(i.map(s=>s.capability),"Native spec change capabilities");let n=We(t.acceptance,"Native acceptance",Rb);Kt(n.map(s=>s.id),"Native acceptance IDs");let a=We(t.history,"Native history",rp);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Sr,name:r,language:V(t.language,["en","zh-CN"],"Native state language"),phase:V(t.phase,["shape","build","verify","archive"],"Native state phase"),status:V(t.status,["active","await-user","blocked","done"],"Native state status"),state_version:$(t.state_version,"Native state_version",1),brief:"brief.md",...t.document_constraints_version===void 0?{}:t.document_constraints_version===1?{document_constraints_version:1}:(()=>{throw new Error("Native document_constraints_version must be 1")})(),...t.shape_confirmation_hash===void 0?{}:{shape_confirmation_hash:$c(t.shape_confirmation_hash,"Native Shape confirmation hash")},...t.children_contract_hash===void 0?{}:{children_contract_hash:$c(t.children_contract_hash,"Native children contract hash")},...t.coordination_mode===void 0?{}:{coordination_mode:V(t.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:Cb(t.workspace),loop:Pb(t.loop),acceptance:n,builder_handoff:t.builder_handoff===null?null:Ab(t.builder_handoff),blockers:We(t.blockers,"Native blockers",Ib),verification:t.verification===null?null:Tb(t.verification),history:a,history_overflow:Ob(t.history_overflow),verification_result:V(t.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:t.verification_report===null?null:V(t.verification_report,["verification.md"],"Native verification_report"),archived:Er(t.archived,"Native archived"),created_at:xr(t.created_at,"Native created_at")};return Hb(o),Db(o),o}function ip(e){let t=e.createdAt instanceof Date?e.createdAt.toISOString():e.createdAt??new Date().toISOString();return ue({schema:Sr,name:e.name,language:e.language,phase:"shape",status:"active",state_version:1,brief:"brief.md",spec_changes:[],workspace:e.workspace??{isolation:"current",change_branch:null,target_branch:null,finish:null},loop:{stage:"shape",goal_cycle:1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:e.nextAction??null},acceptance:[],builder_handoff:null,blockers:[],verification:null,history:[],history_overflow:Ic(),verification_result:"pending",verification_report:null,archived:!1,created_at:t})}function Di(e,t){let r=ue(e),i=rp(t,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 ue({...r,history:n,history_overflow:a})}function qb(e,t){let r=(0,Aa.parseDocument)(e,{uniqueKeys:!0});if(r.errors.length>0)throw new Error(`${t} is invalid YAML: ${r.errors[0].message}`);return r.toJS({mapAsMap:!1})}async function Ct(e){let t=await wb.readFile(e,"utf8");return ue(qb(t,"Native portable state"))}async function Oc(e,t,r={}){let i=ue(t);await Fe(e,(0,Aa.stringify)(i),r)}async function Fb(e,t){let r=Ra.get(e)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);Ra.set(e,a),await r;try{return await t()}finally{i(),Ra.get(e)===a&&Ra.delete(e)}}async function np(e){return Fb(e.file,async()=>{let t=$(e.expectedStateVersion,"Native expected state version",1),r=ue(e.next);if(r.state_version!==t+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await Ct(e.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==t)throw new Hi(t,i.state_version);return await Oc(e.file,r,{...e.containedRoot?{containedRoot:e.containedRoot}:{},beforeCommit:async()=>{let n=await Ct(e.file);if(n.state_version!==t)throw new Hi(t,n.state_version)}}),r})}var Aa,yb,Nb,bb,kb,Sb,Hi,Ra,Pe=x(()=>{"use strict";Aa=Je(De(),1);D();Oi();yb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Nb=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,bb=/^A[1-9][0-9]*$/u,kb=/^[a-f0-9]{64}$/u,Sb=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"]),Hi=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"};Ra=new Map});var Yt=x(()=>{"use strict"});var ap=x(()=>{"use strict";Ca();Ac();Pe();Yt();Oi();Ri()});var op,t_,r_,Dc=x(()=>{"use strict";oe();Sc();ap();op="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",t_=new RegExp(`^portable-archive-(${op})\\.json$`,"u"),r_=new RegExp(`^portable-migration-(${op})\\.json$`,"u")});import{createHash as Vb}from"node:crypto";import{constants as ja,promises as Re}from"node:fs";import _e from"node:path";import{TextDecoder as Mb}from"node:util";function $a(e,t){let r=_e.relative(e,t);return r===""||!_e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${_e.sep}`)}function Wb(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function zb(e,t){return O({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Jb(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function Ta(e,t){return O({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function qc(e,t){let r=await Re.lstat(e);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await Re.realpath(e),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function sp(e,t,r){let i=_e.resolve(e),n=_e.resolve(t);if(!$a(i,n))throw new Error(`${r} is outside its managed root`);let a=[await qc(i,r)],o=i;for(let s of _e.relative(i,n).split(_e.sep).filter(Boolean)){await Pt(a,r),o=_e.join(o,s);let c=await qc(o,r);if(!$a(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Pt(a,r),a}async function Pt(e,t){for(let r of e){let i=await Re.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!zb(r,i)||await Re.realpath(r.path)!==r.realPath)throw new Error(`${t} parent changed during I/O: ${r.path}`)}}async function Gb(e,t,r){let i=[],n=0,a=Buffer.allocUnsafe(t===null?64*1024:Math.min(64*1024,t+1));for(;;){let o=t===null?a.length:t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,t!==null&&n>t)throw new Error(`${r} exceeds ${t} bytes`);i.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(i,n)}async function Fi(e){let t=e.maxBytes===null?null:Wb(e.maxBytes),r=_e.resolve(e.file),i=await sp(e.root,_e.dirname(r),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(d=>qc(_e.resolve(d),e.label)));await e.hooks?.afterParentChainCaptured?.(),await Pt(i,e.label);let a=await Re.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(t!==null&&a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=Jb(a),s=await Re.realpath(r);if(!$a(i[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(d=>$a(d.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let c=process.platform==="win32"?ja.O_RDONLY:ja.O_RDONLY|ja.O_NOFOLLOW|ja.O_NONBLOCK,l=await Re.open(r,c);try{let d=await l.stat();await e.hooks?.afterOpen?.();let[u,f]=await Promise.all([Re.lstat(r),Re.realpath(r)]);if(await Pt(i,e.label),await Pt(n,e.label),!d.isFile()||!u.isFile()||u.isSymbolicLink()||f!==s||!Ta(o,d)||!Ta(o,u))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let h=await Gb(l,t,e.label);await e.hooks?.beforeFinalCheck?.();let[m,p,g]=await Promise.all([l.stat(),Re.lstat(r),Re.realpath(r)]);if(await Pt(i,e.label),await Pt(n,e.label),!p.isFile()||p.isSymbolicLink()||g!==s||!Ta(o,m)||!Ta(o,p))throw new Error(`${e.label} changed while reading`);return{bytes:h,hash:Vb("sha256").update(h).digest("hex"),size:h.length}}finally{await l.close()}}async function cp(e){let t=await Fi(e),r;try{r=new Mb("utf-8",{fatal:!0}).decode(t.bytes)}catch(i){throw new Error(`${e.label} is not valid UTF-8`,{cause:i})}return{...t,text:r}}async function Li(e){let t=await sp(e.root,e.directory,e.label);return{verify:()=>Pt(t,e.label)}}var ge=x(()=>{"use strict";D();qe()});import{TextDecoder as Kb}from"util";var w_,Oa=x(()=>{"use strict";D();A();ge();w_=new Kb("utf-8",{fatal:!0})});var G=x(()=>{"use strict";fe();Pi();Dc();Oa()});import{createHash as Xb}from"crypto";function de(e){return Xb("sha256").update(e).digest("hex")}var Ae=x(()=>{"use strict"});import Bc from"path";function Ha(e,t){return e.hash===t.hash&&e.recordCount===t.recordCount&&e.storedRecordCount===t.storedRecordCount&&e.stdoutBytes===t.stdoutBytes&&e.overflow===t.overflow}function gk(e,t){return e.hash===t.hash&&e.visitedNodeCount===t.visitedNodeCount&&e.recordCount===t.recordCount&&e.storedRecordCount===t.storedRecordCount&&e.encodedBytes===t.encodedBytes&&e.overflow===t.overflow&&e.unstable===t.unstable}function wk(e,t){return de(`comet.native.snapshot-policy.v1
147
- ${JSON.stringify({include:e,exclude:t,hash:"sha256"})}`)}function Lc(e,t,r){let i=new Set(t),n=[...t];for(;n.length>0;){if(r&&!r())return null;let a=n.pop(),o=e[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 yk(e){let t=0;return()=>t>0?(t-=1,!0):e()?(t=63,!0):!1}function pp(e){let t=ka(e,"Native snapshot pattern"),r=[];for(let i=0;i<t.length;i+=1){let n=t[i];n==="*"&&t[i+1]==="*"?(i+=1,t[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?yk(n):void 0;if(a&&!a())return!1;let o=Lc(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 d=r[l];d&&(d.kind==="literal"&&d.value===s||d.kind==="question"&&s!=="/"?c.add(l+1):d.kind==="star"&&s!=="/"||d.kind==="globstar"?c.add(l):d.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=Lc(r,c,a),o===null||o.size===0)return!1}return Lc(r,o,a)?.has(r.length)??!1}}function Nk(e){if(e===void 0)return;let t=[...new Set(e.include.map(n=>ka(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(e.exclude.map(n=>ka(n,"exclude")))].sort((n,a)=>n.localeCompare(a,"en"));if(t.length===0)throw new Error("Native snapshot policy include must not be empty");let i=wk(t,r);if("hash"in e&&e.hash!==i)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:t,exclude:r,hash:i},includeMatchers:t.map(pp),excludeMatchers:r.map(pp),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 we(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function ye(e,t,r){let i=Object.keys(e).find(n=>!t.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Pr(e,t){if(!Number.isSafeInteger(e)||e<1)throw new Error(`${t} must be a positive integer`);return e}function ze(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`${t} must be a non-negative integer`);return e}function vp(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0"))throw new Error(`${t} must be a normalized project-relative path`);let r=Bc.posix.normalize(e);if(r!==e||Bc.posix.isAbsolute(e)||r===".."||r.startsWith("../"))throw new Error(`${t} must stay inside the project root`);return e}function bk(e,t){let r=we(e,`Native snapshot entry ${t}`);ye(r,uk,`Native snapshot entry ${t}`);let i=vp(r.path,`Native snapshot entry ${t} path`);if(typeof r.hash!="string"||!Da.test(r.hash))throw new Error(`Native snapshot entry ${t} hash is invalid`);if(r.type!=="file")throw new Error(`Native snapshot entry ${t} type is invalid`);let n={path:i,hash:r.hash,size:ze(r.size,`Native snapshot entry ${t} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!vk.test(r.gitObjectId))throw new Error(`Native snapshot entry ${t} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function kk(e,t){let r=we(e,`Native snapshot omission ${t}`);if(ye(r,dk,`Native snapshot omission ${t}`),!hk.has(r.type))throw new Error(`Native snapshot omission ${t} type is invalid`);if(!mk.has(r.reason))throw new Error(`Native snapshot omission ${t} reason is invalid`);return{path:vp(r.path,`Native snapshot omission ${t} path`),size:r.size===null?null:ze(r.size,`Native snapshot omission ${t} size`),type:r.type,reason:r.reason}}function Sk(e){let t=we(e,"Native snapshot omission overflow");if(ye(t,fk,"Native snapshot omission overflow"),typeof t.hash!="string"||!Da.test(t.hash))throw new Error("Native snapshot omission overflow hash is invalid");let r=`native-snapshot://omitted-overflow/${t.hash}`;if(t.ref!==r)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:r,hash:t.hash,count:Pr(t.count,"Native snapshot omission overflow count")}}function Cr(e,t){let r=we(e,t);if(ye(r,sk,t),typeof r.hash!="string"||!Da.test(r.hash))throw new Error(`${t} hash is invalid`);if(typeof r.overflow!="boolean")throw new Error(`${t} overflow flag is invalid`);let i=ze(r.recordCount,`${t} recordCount`),n=ze(r.storedRecordCount,`${t} storedRecordCount`),a=ze(r.stdoutBytes,`${t} stdoutBytes`);if(n>i||!r.overflow&&n!==i)throw new Error(`${t} stored record count is inconsistent`);return{hash:r.hash,recordCount:i,storedRecordCount:n,stdoutBytes:a,overflow:r.overflow}}function hp(e){let t=we(e,"Native Git selection evidence");if(ye(t,ok,"Native Git selection evidence"),t.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(t.status!=="overflow"&&t.status!=="changed"&&t.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let r=Cr(t.stageBefore,"Native Git selection stageBefore"),i=Cr(t.combined,"Native Git selection combined"),n=Cr(t.stageAfter,"Native Git selection stageAfter"),a=Cr(t.finalStageBefore,"Native Git selection finalStageBefore"),o=Cr(t.finalCombined,"Native Git selection finalCombined"),s=Cr(t.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(u=>u.overflow),l=!Ha(r,n)||!Ha(n,a)||!Ha(i,o)||!Ha(a,s),d=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(t.status!==d)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:d,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function mp(e,t){let r=we(e,t);if(ye(r,lk,t),typeof r.hash!="string"||!Da.test(r.hash))throw new Error(`${t} hash is invalid`);if(typeof r.overflow!="boolean"||typeof r.unstable!="boolean")throw new Error(`${t} flags are invalid`);let i=ze(r.visitedNodeCount,`${t} visitedNodeCount`),n=ze(r.recordCount,`${t} recordCount`),a=ze(r.storedRecordCount,`${t} storedRecordCount`),o=ze(r.encodedBytes,`${t} encodedBytes`);if(a>n||!r.overflow&&a!==n)throw new Error(`${t} stored record count is inconsistent`);return{hash:r.hash,visitedNodeCount:i,recordCount:n,storedRecordCount:a,encodedBytes:o,overflow:r.overflow,unstable:r.unstable}}function Ek(e){let t=we(e,"Native physical selection evidence");if(ye(t,ck,"Native physical selection evidence"),t.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(t.status!=="overflow"&&t.status!=="changed"&&t.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let r=mp(t.before,"Native physical selection before"),i=mp(t.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!gk(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(t.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 gp(e){let t=we(e,"Native content snapshot manifest");if(ye(t,tk,"Native content snapshot manifest"),t.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!pk.has(t.origin))throw new Error("Native content snapshot origin is invalid");let r;if(t.capture!==void 0){let w=we(t.capture,"Native content snapshot capture");if(ye(w,nk,"Native content snapshot capture"),w.provider!=="git"&&w.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let R=w.gitSelection===void 0?void 0:hp(w.gitSelection),S=w.physicalSelection===void 0?void 0:Ek(w.physicalSelection),I=null;if(w.projection!==void 0){let K=we(w.projection,"Native content snapshot projection");if(ye(K,ak,"Native content snapshot projection"),K.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");I={provider:"git",...K.selection===void 0?{}:{selection:hp(K.selection)}}}if(w.provider==="git"){if(S||I)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(S&&I)throw new Error("Native physical-tree capture cannot combine selection and projection");r=I?{provider:"physical-tree",projection:I}:{provider:"physical-tree",...S?{physicalSelection:S}:{}}}}if(typeof t.createdAt!="string"||Number.isNaN(Date.parse(t.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof t.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let i=we(t.limits,"Native content snapshot limits");ye(i,rk,"Native content snapshot limits");let n={maxFiles:Pr(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Pr(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Pr(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Pr(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Pr(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(t.policy!==void 0){let w=we(t.policy,"Native snapshot policy");if(ye(w,ik,"Native snapshot policy"),w.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(w.include)||!Array.isArray(w.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=Nk({include:w.include,exclude:w.exclude,hash:w.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(t.entries)||!Array.isArray(t.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let o=t.entries.map(bk),s=t.omitted.map(kk),c=ze(t.omittedCount,"Native content snapshot omittedCount"),l=t.omissionOverflow===void 0?void 0:Sk(t.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(w=>w.size>n.maxFileBytes)||o.reduce((w,R)=>w+R.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(w=>w.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>Zb||c<s.length)throw new Error("Native content snapshot omission count is invalid");let d=c-s.length;if(d===0&&l||d>0&&l?.count!==d)throw new Error("Native content snapshot omission overflow is inconsistent");if(t.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(w=>w.reason==="git-enumeration-limit"),f=s.filter(w=>w.reason==="git-selection-changed");for(let w of[...u,...f])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||f.length>1)throw new Error("Native Git selection omissions must not be duplicated");let h=r?.provider==="git"?r.gitSelection:r?.projection?.selection,m=h?.status==="overflow"||h?.status==="overflow-and-changed",p=h?.status==="changed"||h?.status==="overflow-and-changed";if(m!==(u.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 g=s.filter(w=>w.reason==="physical-enumeration-limit"),v=s.filter(w=>w.reason==="physical-selection-changed");for(let w of[...g,...v])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(g.length>1||v.length>1)throw new Error("Native physical selection omissions must not be duplicated");let b=r?.physicalSelection,N=b?.status==="overflow"||b?.status==="overflow-and-changed",y=b?.status==="changed"||b?.status==="overflow-and-changed";if(N!==(g.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(y!==(v.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");return{schema:"comet.native.content-snapshot.v1",origin:t.origin,...r?{capture:r}:{},createdAt:t.createdAt,complete:t.complete,limits:n,...a?{policy:a}:{},entries:o,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}}}function xk(e,t){if(!ek.test(t))throw new Error(`Invalid Native change name: ${t}`);return Bc.join(Y(e,t),"baseline-manifest.json")}async function Vc(e,t){let r=xk(e,t),i=xe(e,r);await L(i,r);try{let n=await cp({root:i,file:r,maxBytes:null,label:"Native baseline snapshot manifest"});return gp(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var B_,Zb,ek,tk,rk,ik,nk,ak,ok,sk,ck,lk,uk,dk,fk,pk,hk,mk,Da,vk,V_,M_,W_,z_,J_,Rr=x(()=>{"use strict";D();fe();Ae();qe();A();ge();gi();B_={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},Zb=1e3,ek=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,tk=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),rk=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),ik=new Set(["schema","include","exclude","hash"]),nk=new Set(["provider","gitSelection","physicalSelection","projection"]),ak=new Set(["provider","selection"]),ok=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),sk=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),ck=new Set(["schema","status","before","after"]),lk=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),uk=new Set(["path","hash","size","type","gitObjectId"]),dk=new Set(["path","size","type","reason"]),fk=new Set(["ref","hash","count"]),pk=new Set(["change-created","legacy-migration","explicit"]),hk=new Set(["file","directory","other"]),mk=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"]),Da=/^[a-f0-9]{64}$/u,vk=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,V_=64*1024,M_=64*1024,W_={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},z_={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};J_=(1n<<256n)-1n});function Rp(){eS+=1}var eS,_p=x(()=>{"use strict";eS=0});import{execFileSync as tS}from"node:child_process";function nS(e,t){Rp();try{return tS("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:rS,maxBuffer:iS,windowsHide:!0})}catch(r){let i=typeof r.stderr=="string"?r.stderr.trim():Buffer.isBuffer(r.stderr)?r.stderr.toString("utf8").trim():"";throw new Qc(e,t,i)}}function pe(e,t){return nS(e,t).trim()}var rS,iS,Qc,Ie=x(()=>{"use strict";_p();rS=3e4,iS=8*1024*1024,Qc=class extends Error{constructor(r,i,n){super(`git ${i.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=r;this.args=i;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr}});import{promises as aS}from"node:fs";import oS from"node:path";function Wa(e,t,r=""){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object${r}`);return e}function Ma(e,t,r){let i=Object.keys(e).filter(a=>!t.has(a)),n=[...t].filter(a=>!(a in e));if(i.length>0||n.length>0){let a=[...n.length>0?[`missing ${n.join(", ")}`]:[],...i.length>0?[`unexpected ${i.join(", ")}`]:[],`expected ${[...t].join(", ")}`];throw new Error(`${r} fields are invalid: ${a.join("; ")}`)}}function Ip(e,t){if(!Array.isArray(e)||!e.every(r=>typeof r=="string"))throw new Error(`${t} must be an array of strings`);return[...new Set(e)].sort((r,i)=>r.localeCompare(i,"en"))}function fS(e){let t=new Map(e.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 t.get(a).depends_on)n(o);r.delete(a),i.add(a)}};for(let a of e)n(a.name)}function jp(e,t,r=t){let i=new Set(t);for(let o of e){let s=o.covers.filter(c=>!i.has(c));if(s.length>0)throw new Error(`Native child ${o.name} covers unknown acceptance: ${s.join(", ")}`)}let n=new Set(e.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 Hp(e,t,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(e.schema===el&&e.acceptance_index){let n=r.requiredAcceptanceIds??t??[],a=r.allowedAcceptanceIds??n,o=Object.keys(e.acceptance_index);i.missing=n.filter(l=>!(l in e.acceptance_index)),i.extra=o.filter(l=>!a.includes(l));let s=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of o){let d=s.get(l),u=e.acceptance_index[l];d&&u&&(u.source!==d.source||u.text!==d.text)&&i.mismatched.push(l)}let c=new Set(o);for(let l of e.children)i.unknownCovers.push(...l.covers.filter(d=>!c.has(d)));return i.uncovered=o.filter(l=>!Tp(e.children,l)),$p(i)?i:null}if(e.schema===Xt&&t){let n=new Set(t);for(let a of e.children)i.unknownCovers.push(...a.covers.filter(o=>!n.has(o)));return i.uncovered=t.filter(a=>!Tp(e.children,a)),$p(i)?i:null}return null}function Tp(e,t){return e.some(r=>r.covers.includes(t))}function $p(e){return e.missing.length>0||e.extra.length>0||e.mismatched.length>0||e.uncovered.length>0||e.unknownCovers.length>0}function _t(e){let t=new Set(e.acceptance.map(({id:n})=>n)),r=new Set(e.acceptance.filter(({source:n})=>n===e.brief).map(({id:n})=>n)),i=new Set(r);for(let n of e.history.filter(({outcome:a})=>a==="fail"))for(let a of n.unresolved_ids)t.has(a)&&i.add(a);if(e.loop.stage==="repairing"&&e.verification_result==="fail"){let n=[...e.history].reverse().find(({outcome:a})=>a==="fail");for(let a of n?.unresolved_ids??[])r.add(a)}return{acceptanceCatalog:e.acceptance,requiredAcceptanceIds:[...r],allowedAcceptanceIds:[...i]}}function pS(e){let t=Wa(e,"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(t)){let a=Wa(n,`Native children acceptance_index.${i}`);if(Ma(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 hS(e,t,r){let i=r.requiredAcceptanceIds??t??[],n=r.allowedAcceptanceIds??i,a=Object.keys(e),o=i.filter(l=>!(l in e)),s=a.filter(l=>!n.includes(l));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 c=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of a){let d=c.get(l);if(!d)continue;let u=e[l];if(u.source!==d.source||u.text!==d.text){let f=["source","text"].filter(h=>u[h]!==d[h]);throw new Error(`Native children acceptance_index.${l} does not match the acceptance catalog: copy ${f.join(", ")} exactly from the current acceptance catalog`)}}}function Dp(e,t,r={}){let i=(0,Op.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=Wa(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==Xt&&a!==Rt)throw Ma(n,Ap,"Native children contract"),new Error(`Native children schema must be ${Xt} or ${Rt}`);let o=a===Xt?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(Ma(n,o==="indexed-v2"?cS:Ap,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let c=n.children.map((f,h)=>{let m=Wa(f,`Native child ${h}`);if(Ma(m,o==="indexed-v2"?dS:o==="summary-v2"?uS:lS,`Native ${s} child fields (child ${h})`),typeof m.name!="string"||!sS.test(m.name))throw new Error(`Native child ${h} name is invalid`);let p=o==="summary-v2";if(p){if(typeof m.summary!="string"||m.summary.trim().length===0)throw new Error(`Native child ${m.name} summary must be a non-empty string`);if(m.summary.length>2e3)throw new Error(`Native child ${m.name} summary exceeds 2000 characters`)}return{name:m.name,summary:p?m.summary:null,depends_on:Ip(m.depends_on,`Native child ${m.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Ip(m.covers,`Native child ${m.name} covers`):[]}}),l=c.map(({name:f})=>f);if(new Set(l).size!==l.length)throw new Error("Native child names must be unique");let d=new Set(l);for(let f of c){let h=f.depends_on.filter(m=>!d.has(m));if(h.length>0)throw new Error(`Native child ${f.name} depends on unknown child: ${h.join(", ")}`)}fS(c);let u=r.policy==="advisory";if(a===el){if(o==="indexed-v2"){let f=pS(n.acceptance_index);u||hS(f,t,r);let h=Object.keys(f);return u||jp(c,h,h),{schema:Rt,acceptance_index:f,children:c}}return{schema:Rt,children:c}}return t&&!u&&jp(c,t),{schema:Xt,children:c}}async function it(e){let t=oS.join(e.changeDir,Zc);try{await aS.lstat(t)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await H({root:e.changeDir,ref:Zc}),i=e.policy==="advisory",n=i?{...e.validation,policy:"advisory"}:e.validation??{},a=Dp(r.text,e.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?Hp(a,e.acceptanceIds,e.validation??{}):null}}var Op,Zc,Xt,Rt,el,sS,Ap,cS,lS,uS,dS,za=x(()=>{"use strict";Op=Je(De(),1);oe();Zc="children.yaml",Xt="comet.native.children.v1",Rt="comet.native.children.v2",el=Rt,sS=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Ap=new Set(["schema","children"]),cS=new Set(["schema","acceptance_index","children"]),lS=new Set(["name","depends_on","covers"]),uS=new Set(["name","summary","depends_on"]),dS=new Set(["name","depends_on","covers"])});var Ja,tl=x(()=>{"use strict";Ja=class extends Error{issues;constructor(t){let r=[t.missingFields.length?`missing: ${t.missingFields.join(", ")}`:"",t.unknownFields.length?`unknown: ${t.unknownFields.join(", ")}`:""].filter(Boolean).join("; ");super(`${t.context} fields are invalid at ${t.path||"/"} (${r})`),this.name="NativeInputValidationError",this.issues=[t]}}});var Wi=x(()=>{"use strict"});var Ga=x(()=>{"use strict";tl();Wi()});function nt(e,t){if(!vS.test(e))throw new Error(`${t} must be a Git commit`)}function rl(e,t){e.history.push({...t,at:new Date().toISOString()}),e.history.length>256&&e.history.splice(0,e.history.length-256)}function Ka(e){nt(e.targetCommit,"Native Supervisor target commit");let t=new Set(e.contract.children.map(({name:i})=>i)),r=e.contract.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.depends_on],status:i.depends_on.length===0?"ready":"pending",baseCommit:null,candidateCommit:null,verifiedCommit:null,integrationCommit:null,verification:null,checks:[],blocker:null,projectRoot:null,task:null,acceptanceScope:il(e.contract,i.name),contractHash:T("comet.native.supervisor-contract.v1",e.contract),builderFailureCount:0}));for(let i of r)for(let n of i.dependsOn)if(!t.has(n))throw new Error(`Native Supervisor child ${i.name} depends on unknown child ${n}`);return{schema:zi,stateVersion:1,parent:e.parent,integration:{branch:e.integrationBranch,worktree:e.integrationWorktree,targetBranch:e.targetBranch,targetCommit:e.targetCommit,headCommit:e.targetCommit},children:r,history:[],finalVerification:{status:"pending",summary:null}}}function il(e,t){let r=e.children.find(i=>i.name===t);return r.covers.length>0?r.covers.map(i=>({id:i,source:e.acceptance_index?.[i]?.source??"brief.md",text:e.acceptance_index?.[i]?.text??i})):[{id:`child:${t}`,source:"children.yaml",text:r.summary??t}]}function Ya(e){let t=e.children.every(i=>i.acceptanceScope&&i.acceptanceScope.length>0&&(!i.task||i.task.acceptance&&i.task.acceptance.length>0)),r=e.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.dependsOn],covers:i.acceptanceScope?.map(({id:n})=>n)??[],status:(i.status==="ready"||i.status==="active")&&i.blocker&&[...e.history].reverse().find(n=>n.child===i.name)?.kind==="task-blocked"?"blocked":i.status,phase:null,projectRoot:i.projectRoot??i.task?.projectRoot??null,message:t?i.blocker:"Supervisor acceptance scope is unavailable; restore children.yaml and confirm Shape before continuing",builderFailureCount:i.builderFailureCount??0}));return{contractHash:null,supervisorStateVersion:e.stateVersion,confirmed:t,parentBranch:e.integration.branch,children:r,readyChildren:t?r.filter(({status:i})=>i==="ready").map(({name:i})=>i):[],allDone:t&&r.every(({status:i})=>i==="integrated"||i==="archived")}}var vS,zi,Ua,Qt=x(()=>{"use strict";q();Ga();vS=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;zi="comet.native.supervisor.v2",Ua=3});import Ji from"node:path";import{promises as Fp}from"node:fs";function nl(e,t){return Ji.join(Ve(e,t),"supervisor")}function Xa(e,t){return Ji.join(nl(e,t),"state.json")}function Lp(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native Supervisor state must be an object");let t=e;if(t.schema!==zi)throw new Error(`Native Supervisor state schema must be ${zi}`);if(!Number.isSafeInteger(t.stateVersion)||typeof t.stateVersion!="number"||t.stateVersion<1)throw new Error("Native Supervisor state version is invalid");if(typeof t.parent!="string"||!t.parent)throw new Error("Native Supervisor state parent is invalid");if(!t.integration||typeof t.integration!="object")throw new Error("Native Supervisor integration state is missing");for(let[n,a]of Object.entries(t.integration))if(n!=="checkExecution"&&(typeof a!="string"||a.length===0))throw new Error(`Native Supervisor integration field ${n} is invalid`);if(nt(t.integration.targetCommit,"Native Supervisor target commit"),nt(t.integration.headCommit,"Native Supervisor integration head commit"),t.integration.checkExecution){let n=t.integration.checkExecution;if(!n.operationId||!n.key||!n.child||!["running","completed","interrupted"].includes(n.status)||!Number.isSafeInteger(n.ownerPid)||n.ownerPid<=0)throw new Error("Native Supervisor integration check execution is invalid");nt(n.candidateCommit,"Native Supervisor integration candidate commit"),nt(n.integrationCommit,"Native Supervisor integration check commit"),qp(n.checkStates,"Native Supervisor integration")}if(!Array.isArray(t.children))throw new Error("Native Supervisor children are invalid");if(!Array.isArray(t.history))throw new Error("Native Supervisor history is invalid");if(!t.finalVerification||!["pending","passed","failed","incomplete"].includes(t.finalVerification.status)||t.finalVerification.summary!==null&&typeof t.finalVerification.summary!="string")throw new Error("Native Supervisor final verification is invalid");if(t.finalVerification.layers){let n=t.finalVerification.layers;if(!["complete","incomplete"].includes(n.childVerification)||!["complete","incomplete"].includes(n.parentIntegration)||!Array.isArray(n.parentChecks)||!n.parentChecks.every(a=>typeof a=="string")||!Array.isArray(n.notRerun)||!n.notRerun.every(a=>typeof a=="string")||!Array.isArray(n.incomplete)||!n.incomplete.every(a=>typeof a=="string"))throw new Error("Native Supervisor final verification layers are invalid")}for(let n of t.history)if(!n||typeof n!="object"||typeof n.kind!="string"||typeof n.summary!="string"||typeof n.at!="string"||n.child!==null&&typeof n.child!="string"||n.runId!==null&&typeof n.runId!="string")throw new Error("Native Supervisor history event is invalid");let r=new Set,i=new Set;for(let n of t.children){if(!n||typeof n!="object"||typeof n.name!="string")throw new Error("Native Supervisor child state is invalid");if(r.has(n.name))throw new Error(`Native Supervisor child ${n.name} is duplicated`);if(r.add(n.name),!Array.isArray(n.dependsOn)||!n.dependsOn.every(a=>typeof a=="string"))throw new Error(`Native Supervisor child ${n.name} dependencies are invalid`);if(typeof n.summary!="string"&&n.summary!==null)throw new Error(`Native Supervisor child ${n.name} summary is invalid`);if(n.builderFailureCount!==void 0&&(!Number.isSafeInteger(n.builderFailureCount)||n.builderFailureCount<0))throw new Error(`Native Supervisor child ${n.name} Builder failure count is invalid`);if(n.projectRoot!==void 0&&n.projectRoot!==null&&(typeof n.projectRoot!="string"||n.projectRoot.length===0))throw new Error(`Native Supervisor child ${n.name} projectRoot is invalid`);for(let[a,o]of[["base",n.baseCommit],["candidate",n.candidateCommit],["verified",n.verifiedCommit],["integration",n.integrationCommit]])o!==null&&nt(o,`Native Supervisor child ${n.name} ${a} commit`);if(!Array.isArray(n.checks)||!Array.isArray(n.verification?.checks??[]))throw new Error(`Native Supervisor child ${n.name} evidence is invalid`);if(n.task!==null){if(!n.task||typeof n.task!="object")throw new Error(`Native Supervisor child ${n.name} task is invalid`);if(!["builder","verifier"].includes(n.task.role)||n.task.child!==n.name||typeof n.task.projectRoot!="string"||n.task.projectRoot.length===0||typeof n.task.runId!="string"||n.task.runId.length===0)throw new Error(`Native Supervisor child ${n.name} task identity is invalid`);if(nt(n.task.baseCommit,`Native Supervisor child ${n.name} task base commit`),i.has(n.task.runId))throw new Error(`Native Supervisor task runId ${n.task.runId} is duplicated`);if(i.add(n.task.runId),n.task.role==="verifier"&&n.task.baseCommit!==n.candidateCommit)throw new Error(`Native Supervisor child ${n.name} verifier base commit is invalid`);if(n.task.projectRoot!==n.projectRoot)throw new Error(`Native Supervisor child ${n.name} task projectRoot is invalid`);if(n.task.checkExecution&&qp(n.task.checkExecution.checkStates,`Native Supervisor child ${n.name}`),n.task.role==="builder"&&n.status!=="active"||n.task.role==="verifier"&&!["active","needs-reverify"].includes(n.status))throw new Error(`Native Supervisor child ${n.name} task status is invalid`)}}}async function je(e,t,r={}){try{let i=await Fp.readFile(Xa(e,t),"utf8"),n=JSON.parse(i);if(Lp(n),n.children.some(o=>!o.acceptanceScope||o.task&&!o.task.acceptance))try{let o=e;if(!o.changesDir)throw new Error("Native Supervisor upgrade requires full project paths to recover confirmed acceptance");let{readNativePortableState:s}=await Promise.resolve().then(()=>(Pe(),Hc)),c=await s(Ji.join(o.changesDir,t,"comet-state.yaml")),l=await it({changeDir:Ji.join(o.changesDir,t),acceptanceIds:c.acceptance.map(({id:d})=>d),validation:_t(c)});if(!l)throw new Error("Native Supervisor upgrade requires the confirmed children contract");for(let d of n.children)l.contract.children.some(({name:u})=>u===d.name)&&(d.acceptanceScope=il(l.contract,d.name),d.contractHash=T("comet.native.supervisor-contract.v1",l.contract),d.task&&(d.task.acceptance=structuredClone(d.acceptanceScope),d.task.contractHash=d.contractHash,d.task.verificationBoundary="child-scope-parent-reverifies-all",d.task.checksReason="not-run"))}catch(o){if(!r.diagnostics)throw o}let a=e;if(a.changesDir)try{let{readNativePortableState:o}=await Promise.resolve().then(()=>(Pe(),Hc)),s=await o(Ji.join(a.changesDir,t,"comet-state.yaml"));s.workspace.change_branch&&(n.integration.targetBranch=s.workspace.change_branch)}catch(o){if(o.code!=="ENOENT")throw o}return n}catch(i){if(i.code==="ENOENT")return null;throw i}}async function At(e,t){Lp(t),await Fp.mkdir(e.changesRuntimeDir,{recursive:!0}),await se(Xa(e,t.parent),t,{containedRoot:e.changesRuntimeDir})}function qp(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length===0)throw new Error(`${t} check states are invalid`);let r=new Set;for(let i of e){if(!i||typeof i.id!="string"||!i.id||r.has(i.id)||typeof i.name!="string"||!["planned","running","passed","failed","interrupted"].includes(i.status)||typeof i.repeatable!="boolean"||!Number.isSafeInteger(i.executionCount)||i.executionCount<0||!Array.isArray(i.argvDisplay)||!i.argvDisplay.every(n=>typeof n=="string")||typeof i.cwdRef!="string"||!Number.isSafeInteger(i.durationMs)||i.durationMs<0||i.exitCode!==null&&!Number.isSafeInteger(i.exitCode)||i.signal!==null&&typeof i.signal!="string"||typeof i.timedOut!="boolean"||i.startedAt!==null&&typeof i.startedAt!="string"||i.completedAt!==null&&typeof i.completedAt!="string"||i.logRef!==null&&typeof i.logRef!="string")throw new Error(`${t} check state is invalid`);r.add(i.id)}}var It=x(()=>{"use strict";D();q();za();A();Qt()});var al=x(()=>{"use strict"});var jt=x(()=>{"use strict"});import{accessSync as Kj,constants as Yj,createWriteStream as Xj,existsSync as Qj,promises as Zj,statSync as yS}from"node:fs";import Zt from"node:path";function NS(e,t){let r=Zt.relative(e,t);return r===""||!Zt.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${Zt.sep}`)}function Bp(e,t){if(t.length===0||t.includes("\\")||Zt.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||Zt.posix.normalize(t)!==t)throw new Error("Native check cwd must be a normalized project-relative ref");let r=Zt.resolve(e),i=Zt.resolve(r,...t.split("/"));if(!NS(r,i))throw new Error("Native check cwd escaped the project root");let n;try{n=yS(i)}catch(a){throw new Error(`Native check cwd does not exist: ${t}`,{cause:a})}if(!n.isDirectory())throw new Error(`Native check cwd is not a directory: ${t}`);return i}var Qa=x(()=>{"use strict";Sa();al();jt()});var Vp=x(()=>{"use strict";Ie();Qa();q()});var Za=x(()=>{"use strict";Ie();D()});var Kp,er=x(()=>{"use strict";q();Rr();Kp=1024*1024});var ro=x(()=>{"use strict";q();jt();gi();er()});var ph,bE,kE,SE,EH,EE,xH,wl=x(()=>{"use strict";q();ph="scoped-text-safety",bE=1,kE=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),SE="comet.native.checker-policy.v1",EH=T(SE,{policy:ph,version:bE,limits:kE,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),EE=["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"],xH=new Set(EE)});var Ki=x(()=>{"use strict";q();wl();jt()});var xE,VH,Ot=x(()=>{"use strict";D();A();qe();er();ro();Ki();xE=Kp,VH=3*xE});var Kc=Je(De(),1);import{promises as Xk}from"fs";import _r from"path";import{execFileSync as Jy}from"child_process";import Gy from"fs";import gt from"path";function mr(e,t){return Jy("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function mi(e,t){return Ef(e)===Ef(t)}function Ef(e){let t=gt.resolve(e);try{let r=Gy.realpathSync.native(t);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?t.toLowerCase():t}}function W(e){try{let t=gt.resolve(mr(e,["rev-parse","--show-toplevel"])),i=mr(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=i?gt.resolve(i.slice(9)):t,a=null;try{a=mr(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!mi(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function ia(e){try{mr(e,["rev-parse","--is-inside-work-tree"]);let t=mr(e,["worktree","list","--porcelain"]).split(/\r?\n/u),r=[],i=null;for(let n of t)n.startsWith("worktree ")?(i&&r.push(i),i={root:gt.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}catch{return[]}}function wt(e){return ia(e).map(t=>t.root)}function ec(e,t){let r=t.find(a=>mi(gt.resolve(a.root),gt.resolve(e)));if(!r)return null;let i=gt.resolve(t[0].root),n=gt.resolve(r.root);return{isGitWorktree:!0,isSecondaryWorktree:!mi(i,n),currentWorktreeRoot:n,primaryWorktreeRoot:i,currentBranch:r.branch}}function Ke(e,t){try{let r=mr(e,["rev-parse","--verify",`${t}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}oe();D();Mt();fe();G();A();ge();Rr();G();A();yr();bt();var Ik=Je(De(),1);yr();bt();St();St();wr();yc();yr();St();var cA=4*1024*1024;var jk=null;function Tk(e,t){let r=e;for(let i of t)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function wp(e,t){return(...r)=>{let i=jk;if(i===null)return t(...r);let n=Tk(`async:${e}`,r),a=i.entries.get(n);if(a)return a.value;let o=t(...r).catch(s=>{throw i.entries.delete(n),s});return i.entries.set(n,{value:o}),o}}wr();var pA=wp("hookWritePolicy",async e=>(await mc(e))?.hook??{allow_paths:[]});Ei();var $k=16*1024;vc();wi();var mI=Number.MAX_SAFE_INTEGER;D();qe();var RI={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 Bk}from"node:crypto";import{promises as qa}from"node:fs";import rt from"node:path";D();oe();G();A();var Bi=/^[a-f0-9]{64}$/u,yp=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,Vk=16*1024,zc=process.platform;function Sp(e,t){let r=rt.relative(e,t);return rt.isAbsolute(r)||r===".."||r.startsWith(`..${rt.sep}`)?null:r.replaceAll("\\","/")||"."}function Ep(e){return Array.from(e).some(t=>{let r=t.codePointAt(0)??0;return r<=31||r===127})}function xp(e,t){if(e.length===0||Ep(e)||e.includes("\\")||rt.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let r=rt.posix.normalize(e);if(r!==e||r===".."||r.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return r}function Jc(e,t){return Bk("sha256").update(`${e}
148
- ${t}`).digest("hex")}async function Np(e,t){let r=await qa.realpath(t),i=await qa.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=zc==="win32"?rt.normalize(r).toLowerCase():r;return Jc(e,`${n}
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=Aa(e),i=Rr(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=Aa(e),i=Rr(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())}}};uf.Parser=Tc});var mf=k(Ti=>{"use strict";var df=yc(),zN=Si(),Ii=Ci(),GN=gs(),JN=A(),UN=Ic(),pf=jc();function ff(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new UN.LineCounter||null,prettyErrors:e}}function KN(t,e={}){let{lineCounter:r,prettyErrors:i}=ff(e),n=new pf.Parser(r?.addNewLine),a=new df.Composer(e),o=Array.from(a.compose(n.parse(t)));if(i&&r)for(let s of o)s.errors.forEach(Ii.prettifyError(t,r)),s.warnings.forEach(Ii.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function hf(t,e={}){let{lineCounter:r,prettyErrors:i}=ff(e),n=new pf.Parser(r?.addNewLine),a=new df.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 Ii.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&r&&(o.errors.forEach(Ii.prettifyError(t,r)),o.warnings.forEach(Ii.prettifyError(t,r))),o}function YN(t,e,r){let i;typeof e=="function"?i=e:r===void 0&&e&&typeof e=="object"&&(r=e);let n=hf(t,r);if(!n)return null;if(n.warnings.forEach(a=>GN.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 XN(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 JN.isDocument(t)&&!i?t.toString(r):new zN.Document(t,i,r).toString(r)}Ti.parse=YN;Ti.parseAllDocuments=KN;Ti.parseDocument=hf;Ti.stringify=XN});var Me=k(j=>{"use strict";var QN=yc(),ZN=Si(),eb=Zs(),$c=Ci(),tb=si(),xt=A(),rb=Nt(),ib=V(),nb=kt(),ab=St(),ob=Pa(),sb=_c(),cb=Ic(),lb=jc(),Ta=mf(),vf=ii();j.Composer=QN.Composer;j.Document=ZN.Document;j.Schema=eb.Schema;j.YAMLError=$c.YAMLError;j.YAMLParseError=$c.YAMLParseError;j.YAMLWarning=$c.YAMLWarning;j.Alias=tb.Alias;j.isAlias=xt.isAlias;j.isCollection=xt.isCollection;j.isDocument=xt.isDocument;j.isMap=xt.isMap;j.isNode=xt.isNode;j.isPair=xt.isPair;j.isScalar=xt.isScalar;j.isSeq=xt.isSeq;j.Pair=rb.Pair;j.Scalar=ib.Scalar;j.YAMLMap=nb.YAMLMap;j.YAMLSeq=ab.YAMLSeq;j.CST=ob;j.Lexer=sb.Lexer;j.LineCounter=cb.LineCounter;j.Parser=lb.Parser;j.parse=Ta.parse;j.parseAllDocuments=Ta.parseAllDocuments;j.parseDocument=Ta.parseDocument;j.stringify=Ta.stringify;j.visit=vf.visit;j.visitAsync=vf.visitAsync});import{AsyncLocalStorage as ub}from"node:async_hooks";import{performance as gf}from"node:perf_hooks";function wf(t=0){db+=1,pb+=t;let e=fb.getStore();e&&(e.gitCommands+=1,e.gitDurationMs+=t)}function ji(t){let e=gf.now();try{return t()}finally{wf(gf.now()-e)}}var db,pb,fb,Pr=x(()=>{"use strict";db=0,pb=0,fb=new ub});var R_,$i=x(()=>{"use strict";R_=["$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("; ")});var I_,_r=x(()=>{"use strict";Pr();$i();I_=8*1024*1024});function kb(t){return t.toLowerCase().startsWith(".env")}function Bi(t){let r=t.replaceAll("\\","/").split("/").filter(Boolean).map(i=>i.toLowerCase());return r.some(i=>kb(i))?"environment-file":r.some(i=>bb.has(i))?"credential-config":r.includes(".git")?"git-metadata":r.some(i=>Nb.has(i))?"dependency-or-cache":r.join("/")===".comet/config.yaml"?"comet-config":r.join("/")===".comet/current-change.json"?"comet-selection":null}var Nb,bb,Li=x(()=>{"use strict";Nb=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),bb=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"])});function Pt(t){return t!==0&&t!==0n&&t!=="0"}function nt(t,e){return Pt(t.dev)&&Pt(e.dev)&&Pt(t.ino)&&Pt(e.ino)}function B(t,e){let r=Pt(t.dev)&&Pt(e.dev);if(r&&t.dev!==e.dev)return!1;let i=Pt(t.ino)&&Pt(e.ino);return i&&t.ino!==e.ino?!1:r&&i?!0:t.birthtime===e.birthtime}var Fi=x(()=>{"use strict"});var Ve=x(()=>{"use strict";Fi()});import{createHash as Sb}from"node:crypto";import{promises as Pe}from"node:fs";import we from"node:path";import{TextDecoder as Eb}from"node:util";function Oc(t,e){let r=we.relative(t,e);return r===""||!we.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${we.sep}`)}function xb(t){let e=we.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})||we.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=Bi(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 Cb(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Rb(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function $a(t,e){let r={...t,birthtime:t.birthtimeMs},i={...e,birthtime:e.birthtimeMs};return nt(r,i)?B(r,i):B(r,i)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function xf(t){let e=await Pe.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await Pe.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function Pb(t,e){let r=we.resolve(t),i=we.resolve(e);if(!Oc(r,i))throw new Error("Native artifact path is outside its root");let n=[await xf(r)],a=r;for(let o of we.relative(r,i).split(we.sep).filter(Boolean)){a=we.join(a,o);let s=await xf(a);if(!Oc(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function Cf(t){for(let e of t){let r=await Pe.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Rb(e,r)||await Pe.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function L(t){let e=xb(t.ref),r=t.maxBytes===null?null:Cb(t.maxBytes??Rf),i=we.resolve(t.root,...e.split("/")),n=await Pb(t.root,we.dirname(i));await t.hooks?.afterParentChainCaptured?.();let a=await Pe.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 Pe.realpath(i);if(!Oc(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await Pe.open(i,"r");try{let[c,l,d]=await Promise.all([s.stat(),Pe.lstat(i),Pe.realpath(i)]);if(await Cf(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||d!==o||!$a(a,c)||!$a(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],p=0,f=Buffer.allocUnsafe(r===null?64*1024:Math.min(64*1024,r+1));for(;;){let b=r===null?f.length:r+1-p,y=await s.read(f,0,Math.min(f.length,b),null);if(y.bytesRead===0)break;if(p+=y.bytesRead,r!==null&&p>r)throw new Error(`Native artifact exceeds ${r} bytes: ${e}`);u.push(Buffer.from(f.subarray(0,y.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[m,h,g]=await Promise.all([s.stat(),Pe.lstat(i),Pe.realpath(i)]);if(await Cf(n),!h.isFile()||h.isSymbolicLink()||g!==o||!$a(c,m)||!$a(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let v=Buffer.concat(u,p),N;try{N=new Eb("utf-8",{fatal:!0}).decode(v)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:b})}return{ref:e,size:p,hash:t.includeHash===!1?null:Sb("sha256").update(v).digest("hex"),text:N}}finally{await s.close()}}var Rf,ue=x(()=>{"use strict";Li();Ve();Rf=1024*1024});import{promises as Dc}from"node:fs";async function Bc(t,e){let r;for(let i=0;i<=Hc.length;i+=1)try{return await t()}catch(n){r=n;let a=n.code;if(i===Hc.length||!_b.has(a??""))throw n;await new Promise(o=>setTimeout(o,Hc[i]))}throw r}async function Lc(t,e){await Bc(()=>Dc.rename(t,e),`rename ${e}`)}async function Fc(t){await Bc(()=>Dc.unlink(t),`unlink ${t}`)}async function qc(t,e){await Bc(()=>Dc.link(t,e),`link ${e}`)}var _b,Hc,Mc=x(()=>{"use strict";_b=new Set(["EPERM","EACCES","EBUSY","ENOTEMPTY"]),Hc=[50,100,200]});import{randomUUID as Ab}from"crypto";import{promises as re}from"fs";import _e from"path";function Oa(t,e){let r=_e.relative(t,e);return r===""||!_e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${_e.sep}`)}function Ib(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Ha(t,e){return B({dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs},{dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs})}function Tb(t,e){return Ha(t,e)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Pf(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 Ar(t){for(let e of t){let r=await re.lstat(e.path);if(!r.isDirectory()||r.isSymbolicLink()||!Ib(e,r)||await re.realpath(e.path)!==e.realPath)throw new Error(`Native atomic write parent changed before commit: ${e.path}`)}}async function jb(t,e,r){let[i,n]=await Promise.all([re.lstat(t),re.realpath(t),r?Ar(r):Promise.resolve()]);if(!i.isFile()||i.isSymbolicLink()||!Ha(i,e)||r&&!Oa(r[0].realPath,n))throw new Error("Native atomic write temporary file changed after close");return i}async function $b(t,e){let r=_e.resolve(t),i=_e.resolve(e);if(!Oa(r,i))throw new Error(`Native atomic write parent is outside its managed root: ${e}`);let n=[await Pf(r)],a=_e.relative(r,i).split(_e.sep).filter(Boolean),o=r;for(let s of a){await Ar(n),o=_e.join(o,s);try{await re.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Pf(o);if(!Oa(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await Ar(n),n}async function Ob(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 Hb(t,e,r={}){let i=_e.dirname(t),n=r.containedRoot?await $b(r.containedRoot,i):null;n||await re.mkdir(i,{recursive:!0});let a=_e.join(i,`.${_e.basename(t)}.${Ab()}.tmp`),o,s,c;try{if(await r.beforeTemporaryOpen?.(),o=await re.open(a,"wx"),s=await o.stat(),n){let[l,d]=await Promise.all([re.lstat(a),re.realpath(a)]);if(await Ar(n),!l.isFile()||l.isSymbolicLink()||!Ha(s,l)||!Oa(n[0].realPath,d))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(),!Ha(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 jb(a,c,n),await r.beforeCommit?.(),n){await Ar(n);let l=await re.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!Tb(l,c))throw new Error("Native atomic write temporary file changed before commit")}r.exclusive?(await qc(a,t),await Fc(a)):await Lc(a,t),await Ob(i)}catch(l){if(await o?.close(),!n)await re.rm(a,{force:!0});else try{await Ar(n),await re.rm(a,{force:!0})}catch{}throw l}}async function We(t,e,r={}){await Hb(t,e,r)}async function ie(t,e,r={}){await We(t,JSON.stringify(e,null,2)+`
143
+ `,r)}var H=x(()=>{"use strict";Mc();Ve()});function Af(t,e){return Vc[t][e]}function Mb(t){return qi[t].section}function Vb(t,e){return qi[t].subsections[e]}function Da(t,e={}){let r=["outcome","scope","nonGoals","acceptanceExamples"];return e.compact||r.push("constraints","decisions","openQuestions","verificationExpectations"),r.map(i=>{if(i!=="scope")return`# ${Af(t,i)}
144
+ `;let n=[`# ${Af(t,i)}
145
+ `];n.push(`## ${Mb(t)}
146
+ `);for(let a of If)n.push(`### ${Vb(t,a)}
147
+ `);return n.join(`
148
+ `)}).join(`
149
+ `)}var If,Vc,Db,Bb,Lb,_f,Fb,qb,qi,Zt=x(()=>{"use strict";If=["created","modified","deleted","notCreated"],Vc={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:"验证预期"}},Db={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:"结论"}},Bb={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:"结论"}},Lb=new Map,_f=new Map,Fb=new Set,qb=new Map,qi={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(Vc)){for(let[e,r]of Object.entries(Vc[t]))Lb.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Db[t]))_f.set(r.toLocaleLowerCase("en-US"),e);for(let[e,r]of Object.entries(Bb[t]))_f.set(r.toLocaleLowerCase("en-US"),e)}for(let t of Object.keys(qi)){Fb.add(qi[t].section.toLocaleLowerCase("en-US"));for(let[e,r]of Object.entries(qi[t].subsections))qb.set(r.toLocaleLowerCase("en-US"),e)}});import _t from"path";function Ub(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim();if(r.length===0||_t.posix.isAbsolute(r)||_t.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 er(t){let e=Ub(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Lf(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 qa(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||_t.posix.isAbsolute(i)||_t.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 at(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ff(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 Ma(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>La)throw new Error(`${e} exceeds ${La} 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>Fa)throw new Error(`${e} contains more than ${Fa} wildcard tokens`);return t}function Hf(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=>Ma(i,e)))].sort((i,n)=>i.localeCompare(n,"en"))}function Mi(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 Df(t,e,r){let i=Mi(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 Kb(t){if(t===void 0)return{...de,include:[...de.include],exclude:[...de.exclude]};let e=at(t,"native.snapshot");return{include:Hf(e.include,"native.snapshot.include",de.include),exclude:Hf(e.exclude,"native.snapshot.exclude",de.exclude),max_files:Mi(e.max_files,de.max_files,"native.snapshot.max_files"),max_total_bytes:Mi(e.max_total_bytes,de.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Mi(e.max_duration_ms,de.max_duration_ms,"native.snapshot.max_duration_ms"),max_selection_records:Mi(e.max_selection_records,de.max_selection_records,"native.snapshot.max_selection_records")}}function Yb(t){if(t===void 0)return;let e=at(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=at(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,d=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 d!="string"||!/^[a-f0-9]{64}$/u.test(d))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:d}}return{id:r,fromArtifactRoot:er(i),toArtifactRoot:er(n),stage:a,...o?{cleanup:o}:{}}}function Xb(t){if(t===void 0)return;let e=at(t,"native.finish");if(e.pull_request===void 0)return{};let r=at(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(_t.posix.isAbsolute(i[0])||_t.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??Wb;if(!Number.isSafeInteger(n)||n<1||n>Of)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${Of}`);return{pull_request:{provider:"repository-command",command:i,timeout_ms:n}}}function Qb(t,e={}){let r=at(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??zc;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=Yb(r.pending_root_move),l=Xb(r.finish);return{artifact_root:er(i),language:Ff(r.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,...s==="revert"?{document_writes:s}:{},snapshot:Kb(r.snapshot),...l?{finish:l}:{},...c?{pending_root_move:c}:{}}}function Zb(t){let e=at(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:Lf(e.artifact_layout),language:Ff(e.language,"zh-CN","classic.language"),context_compression:r,review_mode:i,auto_transition:n,...a==="strict"?{document_evidence:a}:{}}}function ek(t){let r=at(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)=>qa(i,`hook.allow_paths[${n}]`)))]}}function tk(t){if(t===void 0)return{...Ba};let e=at(t,"memory"),r=e.learning??Ba.learning,i=e.retrieval??Ba.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 Gc(t,e){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function rk(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")||_t.posix.isAbsolute(r)||_t.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>Tf)throw new Error(`${e} exceeds ${Tf} 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>jf)throw new Error(`${e} contains more than ${jf} wildcard tokens`);return r}function ik(t){let e=Gc(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)=>rk(n,`knowledge.local.include[${a}]`)))],max_file_mb:Df(e.max_file_mb,$f.max_file_mb,"knowledge.local.max_file_mb"),max_total_mb:Df(e.max_total_mb,$f.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 nk(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 ak(t){let e=Gc(t,"knowledge.remote"),r=nk(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 ok(t){if(t===void 0)return{...Bf};let e=Gc(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:ik(e.local);if(r==="local")return{provider:r,...i?{local:i}:{}};let n=e.remote===void 0?void 0:ak(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 sk(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function ck(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 d=t.workflows??[t.default_workflow];if(!Array.isArray(d)||d.length===0||d.some(p=>p!=="native"&&p!=="classic"))throw new Error("workflows must contain native and/or classic");let u=[...new Set(d)];if(!u.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(u.includes("native")&&!n)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:u,ambient_resume:o,...e?{hook:e}:{},memory:r,knowledge:i,...n?{native:n}:{},...a?{classic:a}:{}}}function Wi(t,e={}){let r=(0,Wc.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=sk(n.ambient_resume),o=n.hook===void 0?void 0:ek(n.hook),s=tk(n.memory),c=ok(n.knowledge),l=n.native===void 0?void 0:Qb(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),d=n.classic===void 0?void 0:Zb(n.classic),u=ck(n,o,s,c,l,d,a,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:u,ambient_resume:a,memory:s,knowledge:c,...o?{hook:o}:{},...l?{native:l}:{},...d?{classic:d}:{}}}function Va(t="docs",e="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,memory:{...Ba},knowledge:{...Bf},native:{artifact_root:er(t),language:e,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:zc,snapshot:{...de,include:[...de.include],exclude:[...de.exclude]}}}}var Wc,Vi,La,Fa,Tf,jf,zc,Ba,$f,Bf,Wb,Of,zb,Gb,Jb,de,At=x(()=>{"use strict";Wc=et(Me(),1),Vi=Number.MAX_SAFE_INTEGER,La=1024,Fa=64,Tf=1024,jf=64,zc=5,Ba={learning:!0,retrieval:!0},$f={include:[],max_file_mb:1,max_total_mb:32},Bf={provider:"local"},Wb=12e4,Of=6e5,zb=[".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/**"],Gb=["**/.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"],Jb=[...zb,...Gb].sort((t,e)=>t.localeCompare(e,"en")),de={include:["**/*"],exclude:[...Jb],max_files:1e4,max_total_bytes:1024*1024*1024,max_duration_ms:6e4,max_selection_records:2e4}});import{constants as Wa,promises as tr}from"fs";function Jc(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 zi(t){return{dev:t.dev,ino:t.ino,birthtime:Jc(t)}}function za(t,e){let r=zi(t),i=zi(e);return nt(r,i)?B(r,i):B(r,i)&&Jc(t)===Jc(e)&&qf(t)===qf(e)&&t.size===e.size}async function Gi(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 tr.lstat(t,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ze("not-regular-file",`${i} must be a regular file`);if(BigInt(a.size)>BigInt(e))throw new ze("too-large",`${i} exceeds ${e} bytes`);let o=await tr.realpath(t);await r.verify?.("pre-open",{realPath:o,identity:zi(a)});let s=process.platform==="win32"?Wa.O_RDONLY:Wa.O_RDONLY|Wa.O_NOFOLLOW|Wa.O_NONBLOCK,c;try{c=await tr.open(t,s)}catch(l){throw l.code==="ELOOP"?new ze("not-regular-file",`${i} must be a regular file`,{cause:l}):l}try{let[l,d,u]=await Promise.all([c.stat({bigint:n}),tr.lstat(t,{bigint:n}),tr.realpath(t)]);if(!l.isFile()||!d.isFile()||d.isSymbolicLink()||u!==o||!za(a,l)||!za(a,d))throw new ze("changed",`${i} changed while opening`);await r.verify?.("post-open",{realPath:u,identity:zi(l)}),await r.hooks?.afterOpen?.();let p=[],f=0,m=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let N=e+1-f,{bytesRead:b}=await c.read(m,0,Math.min(m.length,N),null);if(b===0)break;if(f+=b,f>e)throw new ze("too-large",`${i} exceeds ${e} bytes`);p.push(Buffer.from(m.subarray(0,b)))}await r.hooks?.beforeFinalCheck?.();let[h,g,v]=await Promise.all([c.stat({bigint:n}),tr.lstat(t,{bigint:n}),tr.realpath(t)]);if(!g.isFile()||g.isSymbolicLink()||v!==o||!za(a,h)||!za(a,g))throw new ze("changed",`${i} changed while reading`);return await r.verify?.("post-read",{realPath:v,identity:zi(h)}),{bytes:Buffer.concat(p,f),stat:h,realPath:v}}finally{await c.close()}}var ze,Ji=x(()=>{"use strict";Fi();ze=class extends Error{reason;constructor(e,r,i){super(r,i),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Ga}from"fs";import It from"path";function lk(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function Uc(t,e){let r=It.relative(t,e);return r===""||!It.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${It.sep}`)}async function Mf(t,e){let r=It.resolve(t),i=await Ga.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Ga.realpath(r)}async function Vf(t,e,r,i){let n=t;for(let a=0;a<r.length;a++){n=It.join(n,r[a]);let o;try{o=await Ga.lstat(n)}catch(d){if(lk(d))return{exists:!1,kind:"missing"};throw d}let s=It.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 Ga.realpath(n);if(!Uc(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 Ir(t,e,r){let i=qa(e,r.label),n=It.resolve(t),a=await Mf(n,r.label),o=i.split("/"),s=It.resolve(n,...o);if(!Uc(n,s))throw new Error(`${r.label} must stay inside the project root`);let c=await Vf(n,a,o,r);return{projectRoot:n,target:s,relative:i,exists:c.exists,kind:c.kind}}async function Ge(t,e,r,i){let n=await Ir(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 Mf(n.projectRoot,i.label);return Gi(n.target,r,{...i,verify:async(o,s)=>{if(!Uc(a,s.realPath))throw new Error(`${i.label} resolves outside the project root`);await Vf(n.projectRoot,a,n.relative.split("/"),{label:i.label,expected:"file"})}})}var ot=x(()=>{"use strict";Ji();At()});import{createHash as uk}from"crypto";function dk(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Ja(t,e={}){return(await Ua(t,e)).document}async function pk(t){try{return(await Ge(t,Ui,Vi,{label:Ui})).bytes}catch(e){if(dk(e))return null;throw e}}function fk(t){return t?{exists:!0,sha256:uk("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function Ua(t,e={}){let r=await pk(t);return{document:r?Wi(r.toString("utf8"),e):null,identity:fk(r)}}async function Kc(t){return(await Ja(t))?.config??null}var Ui,Tr=x(()=>{"use strict";At();ot();Ui=".comet/config.yaml"});var jr=x(()=>{"use strict";Mc();Fi()});var TA,Yc=x(()=>{"use strict";jr();Tr();ot();TA=16*1024});var Zc=x(()=>{"use strict";jr();At();Tr();ot();Yc()});import{existsSync as zf,promises as rr}from"fs";import R from"path";import wk from"os";async function el(t){try{return await rr.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Nk(t){try{let e=await rr.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Or(t,e){let r=R.relative(t,e);return r===""||!R.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${R.sep}`)}async function $r(t){let e=[],r=t;for(;!await el(r);){let n=R.dirname(r);if(n===r)break;e.push(R.basename(r)),r=n}let i=await rr.realpath(r);return R.resolve(i,...e.reverse())}async function tl(t){try{return(await rr.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function Ya(t){let e=R.resolve(t);try{(await rr.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let r=e,i=R.resolve(wk.homedir());for(;;){if(!(e===i&&r!==i)){let o=R.join(e,...Ka.split("/")),s=e===r||await Nk(o);if(await el(o)&&s)return e}if(await el(R.join(e,".git")))return e;let a=R.dirname(e);if(a===e)return r;e=a}}function Xa(t){return er(t)}async function bk(t,e){let r=Xa(e),i=R.resolve(t,...r.split("/")),n=await rr.realpath(t),a=await $r(i);if(!Or(n,a))throw new Error("native.artifact_root resolves outside the project root");return i}async function Je(t,e){let r=Xa(e),i=await bk(t,r),n=R.join(i,"comet");if(await tl(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([$r(i),$r(n)]);if(!Or(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=R.resolve(t),c=R.join(s,".comet","runtime","native");if(await tl(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,d]=await Promise.all([rr.realpath(s),$r(c)]);if(!Or(l,d))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:R.join(t,...Ka.split("/")),artifactRoot:i,artifactRootRef:r,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:c,changesRuntimeDir:R.join(c,"changes"),locksDir:R.join(c,"locks"),transactionsDir:R.join(c,"transactions")}}function rl(t){if(!yk.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Ue(t,e){rl(e);let r=R.join(t.changesRuntimeDir,e);if(!J(t.changesRuntimeDir,r))throw new Error("Native change Runtime path escaped");return r}function kk(t,e){rl(e);let r=R.join(t.changesDir,e,"runtime");if(!J(t.changesDir,r))throw new Error("Legacy Native change Runtime path escaped");return r}function Z(t,e){let r=Ue(t,e);if(zf(r))return r;let i=kk(t,e);return zf(i)?i:r}function ir(t,e){rl(e);let r=R.join(t.changesDir,e),i=Z(t,e);return{artifactRoot:t.artifactRoot,nativeRoot:t.nativeRoot,changeDir:r,briefPath:R.join(r,"brief.md"),childrenPath:R.join(r,"children.yaml"),specsDir:R.join(r,"specs"),verificationPath:R.join(r,"verification.md"),statePath:R.join(r,"comet-state.yaml"),runtimeDir:i,runtimeStatePath:R.join(i,"state.json")}}function Ae(t,e){let r=R.resolve(e);if(J(t.runtimeDir,r))return t.runtimeDir;if(J(t.nativeRoot,r))return t.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${e}`)}function J(t,e){return Or(R.resolve(t),R.resolve(e))}async function M(t,e){let r=R.resolve(t),i=R.resolve(e);if(!Or(r,i))throw new Error(`Path is outside the Native root: ${e}`);if(await tl(r))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,a]=await Promise.all([$r(r),$r(i)]);if(!Or(n,a))throw new Error(`Path resolves outside the Native root: ${e}`);return i}var Ka,yk,I=x(()=>{"use strict";At();Ka=".comet/config.yaml",yk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u});function Ek(t="docs",e="en"){return Va(t,e)}async function pe(t){let e=(await Ja(t))?.config??null;return e?.native?e:null}async function Gf(t){let e=await Ya(t.startPath),r=await pe(e);if(!r&&t.allowMissingConfig===!1)throw new Error(`${Ka} was not found`);if(r?.native.pending_root_move)throw new Error(`Native root move ${r.native.pending_root_move.id} is incomplete; use comet native doctor --repair`);let i=t.explicitArtifactRoot?Xa(t.explicitArtifactRoot):void 0;if(r&&i&&i!==r.native.artifact_root)throw new Error(`Configured Native artifact root is ${r.native.artifact_root}; refusing conflicting root ${i}`);let n=r??Ek(i??"docs"),a=await Je(e,n.native.artifact_root);return{config:n,paths:a,configured:r!==null}}var Qa,ve=x(()=>{"use strict";At();Tr();Zc();H();I();Qa=Ma});import{createHash as xk,randomUUID as eI}from"node:crypto";var Ck,rI,Jf=x(()=>{"use strict";_r();Ck=`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
+ }`,rI=xk("sha256").update(Ck).digest("hex")});var Za=x(()=>{"use strict";_r();Jf()});import{AsyncLocalStorage as Pk}from"async_hooks";var fI,hI,mI,Yi=x(()=>{"use strict";Ji();Za();I();Ve();fI=16*1024,hI=900*1e3,mI=new Pk});var Kf,il=x(()=>{"use strict";Kf=et(Me(),1)});var st,Tt,jt,Xi=x(()=>{"use strict";st="comet.native.v3",Tt="comet.native.v2",jt="comet.native.v1"});import _k from"node:path";function en(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Zf(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 nr(t){if(!Qf.test(t))throw new Error(`Invalid Native change name: ${t}`)}function eh(t){if(!Qf.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function th(t,e){if(t.length===0||_k.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function Dk(t,e){let r=en(t,`spec_changes[${e}]`);if(Zf(r,Tk,`spec_changes[${e}]`),typeof r.capability!="string")throw new Error("spec change capability is required");if(eh(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"&&th(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"||!al.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"||!al.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 Bk(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 ol(t,e){if(Zf(t,e,lt),typeof t.name!="string")throw new Error("Native change name is required");if(nr(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"||!jk.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&&!$k.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(Dk),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"||!Ok.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"&&th(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!Bk(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 tn(t){let e=en(t,lt);if(e.schema!==jt)throw new Error(`Expected ${jt}`);return{schema:jt,...ol(e,Ak)}}function Zi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function nl(t,e,r){if(t===null)return null;let i=typeof t=="string"?Hk.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 Lk(t){if(t==null)return null;if(typeof t!="string"||!al.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function Fk(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 rn(t){let e=en(t,lt);if(e.schema!==Tt)throw new Error(`Expected ${Tt}`);if(Zi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Tt} minimum_runtime_version must be 2`);return{schema:Tt,minimum_runtime_version:2,revision:Zi(e.revision,"Native v2 revision"),...ol(e,Xf)}}function Hr(t){let e=en(t,lt);if(e.schema!==st){if(e.schema===jt||e.schema===Tt){let o=e.schema===jt?tn(e):rn(e);throw new Qi(o.name,o.schema)}throw new Ke(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let r=Zi(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)throw new Ke(e.schema,r);if(r!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let i=Zi(e.revision,"Native revision"),n=ol(e,Ik),a=Lk(e.approved_contract_hash);if(n.approval===null&&a!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:st,minimum_runtime_version:3,revision:i,verification_protocol:Fk(e.verification_protocol),...n,approved_contract_hash:a,implementation_scope:nl(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:nl(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:nl(e.partial_allowance,"Native partial_allowance","allowances")}}function sl(t){let e=en(t,lt);if(e.schema===jt){let n=tn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${st}`}}if(e.schema===Tt){let n=rn(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${st}`}}if(e.schema!==st){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 Ke(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let r=Zi(e.minimum_runtime_version,"Native minimum_runtime_version");if(r>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:r,state:null,message:new Ke(e.schema,r).message};let i=Hr(e);return{status:"current",schema:i.schema,minimumRuntimeVersion:i.minimum_runtime_version,state:i}}var Yf,Ak,Xf,Ik,Tk,jk,$k,Ok,lt,al,Qf,Hk,Qi,Ke,eo=x(()=>{"use strict";Xi();Yf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],Ak=new Set(Yf),Xf=new Set([...Yf,"minimum_runtime_version","revision"]),Ik=new Set([...Xf,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),Tk=new Set(["capability","operation","source","base_hash"]),jk=new Set(["shape","build","verify","archive"]),$k=new Set(["implicit","confirmed"]),Ok=new Set(["pending","pass","fail"]),lt="comet-state.yaml",al=/^[a-f0-9]{64}$/u,Qf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Hk=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,Qi=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"},Ke=class extends Error{constructor(r,i){super(r!==st||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 qk}from"crypto";function Ie(t){throw new TypeError(`Value is not valid canonical JSON: ${t}`)}function Mk(t,e){e.has(t)&&Ie("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)||Ie("sparse arrays are not supported");return(r.length!==t.length||r.some((i,n)=>i!==String(n)))&&Ie("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(t).length>0&&Ie("symbol properties are not supported"),`[${t.map(i=>cl(i,e)).join(",")}]`}finally{e.delete(t)}}function Vk(t,e){let r=Object.getPrototypeOf(t);r!==Object.prototype&&r!==null&&Ie("only plain objects are supported"),e.has(t)&&Ie("cyclic structures are not supported"),Object.getOwnPropertySymbols(t).length>0&&Ie("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))&&Ie("accessor properties are not supported"),`${JSON.stringify(o)}:${cl(s.value,e)}`}).join(",")}}`}finally{e.delete(t)}}function cl(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)||Ie("numbers must be finite"),JSON.stringify(Object.is(t,-0)?0:t);case"object":return Array.isArray(t)?Mk(t,e):Vk(t,e);case"bigint":case"function":case"symbol":case"undefined":return Ie(`${typeof t} values are not supported`)}return Ie("unsupported value type")}function ll(t){return cl(t,new Set)}function O(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 qk("sha256").update(`${t}
163
+ ${ll(e)}`).digest("hex")}var F=x(()=>{"use strict"});var CI,rh,nn=x(()=>{"use strict";Zt();F();CI=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),rh=Object.freeze({maxCriteria:1024})});var ul=x(()=>{"use strict";nn()});function dl(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 an({code:"invalid-fields",path:i,context:r,missingFields:a,unknownFields:o,expectedFields:[...e]})}var an,to=x(()=>{"use strict";an=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 pl(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 fl(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}]`;dl(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:pl(i.id,`${n}.id`),status:a,evidence:i.evidence.map(o=>pl(o,`${n}.evidence`)),note:pl(i.note,`${n}.note`)}})}function hl(t,e){if(!e)throw new Dr(t.map(({id:c})=>c),[]);let r=new Set(t.map(({id:c})=>c)),i=e.map(({id:c})=>c),n=new Set(i);if(n.size!==i.length)throw new Error("Native Builder acceptance_review contains duplicate IDs");let a=i.filter(c=>!r.has(c));if(a.length)throw new Error(`Native Builder acceptance_review contains unknown IDs: ${a.join(", ")}`);let o=t.filter(({id:c})=>!n.has(c)).map(({id:c})=>c),s=e.filter(c=>c.status!=="implemented-with-evidence"||c.evidence.length===0).map(({id:c})=>c);if(o.length||s.length)throw new Dr(o,s)}var Dr,ro=x(()=>{"use strict";to();Dr=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}});function ml(){return{dropped_entries:0,first_dropped_at:null,last_dropped_at:null,outcome_counts:{pass:0,fail:0,blocked:0,"execution-error":0,recovery:0}}}var Br,io,ih,on=x(()=>{"use strict";Br="comet.native.v4",io="comet.native.local-execution.v4",ih=["multi-session","single-session"]});var Nl={};Ov(Nl,{NativePortableStateVersionConflictError:()=>sn,appendNativePortableHistory:()=>cn,compareAndSwapNativePortableState:()=>oh,createNativePortableState:()=>ah,parseNativePortableState:()=>fe,readNativePortableState:()=>$t,writeNativePortableState:()=>yl});import{promises as Jk}from"node:fs";function ne(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ae(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 U(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 gl(t,e){return t===null?null:U(t,e)}function wl(t,e){let r=U(t,e);if(!Xk.test(r))throw new Error(`${e} must be a SHA-256 hash`);return r}function Lr(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 Zk(t,e){return t===null?null:D(t,e,Number.MIN_SAFE_INTEGER)}function W(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Ye(t,e,r){if(!Array.isArray(t))throw new Error(`${e} must be an array`);return t.map((i,n)=>r(i,n))}function so(t,e){return Ye(t,e,(r,i)=>U(r,`${e}[${i}]`))}function ar(t,e){if(new Set(t).size!==t.length)throw new Error(`${e} must be unique`)}function Fr(t,e){let r=U(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO date or timestamp`);return r}function ao(t,e,r=!1){let i=U(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 ye(t,e){let r=ne(t,e);return ae(r,new Set(["text","truncated"]),e),{text:U(r.text,`${e}.text`,{empty:!0}),truncated:Lr(r.truncated,`${e}.truncated`)}}function eS(t,e){let r=`Native spec_changes[${e}]`,i=ne(t,r);ae(i,new Set(["capability","operation","source","delta_source","base_hash"]),r);let n=U(i.capability,`${r}.capability`);if(!Kk.test(n))throw new Error(`${r}.capability is invalid`);let a=W(i.operation,["create","modify","remove"],`${r}.operation`),o=i.source===null?null:ao(i.source,`${r}.source`),s=i.delta_source===void 0?void 0:ao(i.delta_source,`${r}.delta_source`),c=i.base_hash===void 0?void 0:i.base_hash===null?null:wl(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 tS(t){let e="Native workspace",r=ne(t,e);ae(r,new Set(["isolation","change_branch","target_branch","finish"]),e);let i=W(r.isolation,["current","branch","worktree"],`${e}.isolation`),n=gl(r.change_branch,`${e}.change_branch`),a=gl(r.target_branch,`${e}.target_branch`),o=r.finish===null?null:W(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 rS(t){let e="Native loop",r=ne(t,e);ae(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=so(r.previous_unresolved_ids,`${e}.previous_unresolved_ids`);ar(i,`${e}.previous_unresolved_ids`);let n=r.stop_reason===void 0?void 0:W(r.stop_reason,["budget","stalled"],`${e}.stop_reason`);return{stage:W(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:gl(r.next_action,`${e}.next_action`)}}function iS(t,e){let r=`Native acceptance[${e}]`,i=ne(t,r);ae(i,new Set(["id","source","text","result","reason"]),r);let n=U(i.id,`${r}.id`);if(!Yk.test(n))throw new Error(`${r}.id must use A1, A2, ...`);return{id:n,source:ao(i.source,`${r}.source`),text:U(i.text,`${r}.text`),result:W(i.result,["pending","passed","failed","blocked"],`${r}.result`),reason:i.reason===null?null:ye(i.reason,`${r}.reason`)}}function nS(t,e){let r=`Native builder_handoff.checks[${e}]`,i=ne(t,r);return ae(i,new Set(["name","result","note"]),r),{name:ye(i.name,`${r}.name`),result:W(i.result,["passed","failed","not-run"],`${r}.result`),note:i.note===null?null:ye(i.note,`${r}.note`)}}function aS(t){let e="Native builder_handoff",r=ne(t,e);ae(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=so(r.addressed_acceptance_ids,`${e}.addressed_acceptance_ids`);ar(i,`${e}.addressed_acceptance_ids`);let n=r.review===null||r.review===void 0?null:ne(r.review,`${e}.review`);return n&&ae(n,new Set(["status","summary","reviewer_execution_ref"]),`${e}.review`),{candidate_id:U(r.candidate_id,`${e}.candidate_id`),identity_provider:U(r.identity_provider,`${e}.identity_provider`),builder_execution_ref:U(r.builder_execution_ref,`${e}.builder_execution_ref`),iteration:D(r.iteration,`${e}.iteration`,1),summary:ye(r.summary,`${e}.summary`),addressed_acceptance_ids:i,...r.acceptance_review===void 0?{}:{acceptance_review:fl(r.acceptance_review)},checks:Ye(r.checks,`${e}.checks`,nS),checks_truncated:Lr(r.checks_truncated,`${e}.checks_truncated`),known_limits:Ye(r.known_limits,`${e}.known_limits`,(a,o)=>ye(a,`${e}.known_limits[${o}]`)),known_limits_truncated:Lr(r.known_limits_truncated,`${e}.known_limits_truncated`),review:n?{status:W(n.status,["passed"],`${e}.review.status`),summary:ye(n.summary,`${e}.review.summary`),reviewer_execution_ref:U(n.reviewer_execution_ref,`${e}.review.reviewer_execution_ref`)}:null,submitted_at:Fr(r.submitted_at,`${e}.submitted_at`)}}function oS(t,e){let r=`Native blockers[${e}]`,i=ne(t,r);ae(i,new Set(["owner","reason","acceptance_ids","resolution_action"]),r);let n=so(i.acceptance_ids,`${r}.acceptance_ids`);return ar(n,`${r}.acceptance_ids`),{owner:W(i.owner,["builder","runtime","verifier","user","external"],`${r}.owner`),reason:ye(i.reason,`${r}.reason`),acceptance_ids:n,resolution_action:W(i.resolution_action,["return-build","retry-verifier","resolve-verifier-blocker","confirm-verifier-unavailable","await-user","wait-external"],`${r}.resolution_action`)}}function sS(t,e){let r=`Native verification.checks[${e}]`,i=ne(t,r);return ae(i,new Set(["id","name","argv_display","argv_truncated","cwd_ref","status","exit_code","duration_ms"]),r),{id:U(i.id,`${r}.id`),name:ye(i.name,`${r}.name`),argv_display:Ye(i.argv_display,`${r}.argv_display`,(n,a)=>ye(n,`${r}.argv_display[${a}]`)),argv_truncated:Lr(i.argv_truncated,`${r}.argv_truncated`),cwd_ref:ao(i.cwd_ref,`${r}.cwd_ref`,!0),status:W(i.status,["passed","failed","interrupted"],`${r}.status`),exit_code:Zk(i.exit_code,`${r}.exit_code`),duration_ms:D(i.duration_ms,`${r}.duration_ms`)}}function cS(t){let e="Native verification",r=ne(t,e);ae(r,new Set(["candidate_id","identity_provider","verifier_execution_ref","iteration","attempt","assurance","verdict","checks","summary","risks","risks_truncated","completed_at"]),e);let i=Ye(r.checks,`${e}.checks`,sS);ar(i.map(a=>a.id),`${e}.checks IDs`);let n=U(r.identity_provider,`${e}.identity_provider`);return{candidate_id:U(r.candidate_id,`${e}.candidate_id`),identity_provider:n,verifier_execution_ref:U(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":W(r.assurance,["host-attested","skill-coordinated","semantic-verification-unavailable","user-confirmed-degraded"],`${e}.assurance`),verdict:W(r.verdict,["pass","fail","blocked"],`${e}.verdict`),checks:i,summary:ye(r.summary,`${e}.summary`),risks:Ye(r.risks,`${e}.risks`,(a,o)=>ye(a,`${e}.risks[${o}]`)),risks_truncated:Lr(r.risks_truncated,`${e}.risks_truncated`),completed_at:Fr(r.completed_at,`${e}.completed_at`)}}function nh(t,e){let r=`Native history[${e}]`,i=ne(t,r);ae(i,new Set(["goal_cycle","iteration","attempt","outcome","unresolved_ids","summary","completed_at"]),r);let n=so(i.unresolved_ids,`${r}.unresolved_ids`);return ar(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:W(i.outcome,["pass","fail","blocked","execution-error","recovery"],`${r}.outcome`),unresolved_ids:n,summary:ye(i.summary,`${r}.summary`),completed_at:Fr(i.completed_at,`${r}.completed_at`)}}function lS(t){let e="Native history_overflow.outcome_counts",r=ne(t,e),i=["pass","fail","blocked","execution-error","recovery"];return ae(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 uS(t){let e="Native history_overflow",r=ne(t,e);ae(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:Fr(r.first_dropped_at,`${e}.first_dropped_at`),a=r.last_dropped_at===null?null:Fr(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=lS(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 dS(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&&hl(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 pS(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 fe(t){let e=ne(t,"Native portable state");if(ae(e,Qk,"Native portable state"),e.schema!==Br)throw new Error(`Native portable state schema must be ${Br}`);let r=U(e.name,"Native state name");if(!Uk.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=Ye(e.spec_changes,"Native spec_changes",eS);ar(i.map(s=>s.capability),"Native spec change capabilities");let n=Ye(e.acceptance,"Native acceptance",iS);ar(n.map(s=>s.id),"Native acceptance IDs");let a=Ye(e.history,"Native history",nh);if(a.length>50)throw new Error(`Native history cannot exceed ${50} entries`);let o={schema:Br,name:r,language:W(e.language,["en","zh-CN"],"Native state language"),phase:W(e.phase,["shape","build","verify","archive"],"Native state phase"),status:W(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||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:wl(e.shape_confirmation_hash,"Native Shape confirmation hash")},...e.children_contract_hash===void 0?{}:{children_contract_hash:wl(e.children_contract_hash,"Native children contract hash")},...e.coordination_mode===void 0?{}:{coordination_mode:W(e.coordination_mode,["multi-session","single-session"],"Native coordination mode")},spec_changes:i,workspace:tS(e.workspace),loop:rS(e.loop),acceptance:n,builder_handoff:e.builder_handoff===null?null:aS(e.builder_handoff),blockers:Ye(e.blockers,"Native blockers",oS),verification:e.verification===null?null:cS(e.verification),history:a,history_overflow:uS(e.history_overflow),verification_result:W(e.verification_result,["pending","pass","fail","blocked"],"Native verification_result"),verification_report:e.verification_report===null?null:W(e.verification_report,["verification.md"],"Native verification_report"),archived:Lr(e.archived,"Native archived"),created_at:Fr(e.created_at,"Native created_at")};return dS(o),pS(o),o}function ah(t){let e=t.createdAt instanceof Date?t.createdAt.toISOString():t.createdAt??new Date().toISOString();return fe({schema:Br,name:t.name,language:t.language,phase:"shape",status:"active",state_version:1,brief:"brief.md",spec_changes:[],workspace:t.workspace??{isolation:"current",change_branch:null,target_branch:null,finish:null},loop:{stage:"shape",goal_cycle:1,iteration:0,attempt:0,retry_epoch:0,failed_iteration_count:0,no_progress_count:0,execution_failure_count:0,previous_unresolved_ids:[],next_action:t.nextAction??null},acceptance:[],builder_handoff:null,blockers:[],verification:null,history:[],history_overflow:ml(),verification_result:"pending",verification_report:null,archived:!1,created_at:e})}function cn(t,e){let r=fe(t),i=nh(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 fe({...r,history:n,history_overflow:a})}function fS(t,e){let r=(0,oo.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 $t(t){let e=await Jk.readFile(t,"utf8");return fe(fS(e,"Native portable state"))}async function yl(t,e,r={}){let i=fe(e);await We(t,(0,oo.stringify)(i),r)}async function hS(t,e){let r=no.get(t)??Promise.resolve(),i,n=new Promise(o=>{i=o}),a=r.then(()=>n);no.set(t,a),await r;try{return await e()}finally{i(),no.get(t)===a&&no.delete(t)}}async function oh(t){return hS(t.file,async()=>{let e=D(t.expectedStateVersion,"Native expected state version",1),r=fe(t.next);if(r.state_version!==e+1)throw new Error("Native CAS next state_version must increment exactly once");let i=await $t(t.file);if(i.state_version===r.state_version&&JSON.stringify(i)===JSON.stringify(r))return i;if(i.state_version!==e)throw new sn(e,i.state_version);return await yl(t.file,r,{...t.containedRoot?{containedRoot:t.containedRoot}:{},beforeCommit:async()=>{let n=await $t(t.file);if(n.state_version!==e)throw new sn(e,n.state_version)}}),r})}var oo,Uk,Kk,Yk,Xk,Qk,sn,no,Te=x(()=>{"use strict";ro();oo=et(Me(),1);H();on();Uk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Kk=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Yk=/^A[1-9][0-9]*$/u,Xk=/^[a-f0-9]{64}$/u,Qk=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"]),sn=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"};no=new Map});var or=x(()=>{"use strict"});var sh=x(()=>{"use strict";eo();ul();Te();or();on();Xi()});var ch,QI,ZI,bl=x(()=>{"use strict";ue();il();sh();ch="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",QI=new RegExp(`^portable-archive-(${ch})\\.json$`,"u"),ZI=new RegExp(`^portable-migration-(${ch})\\.json$`,"u")});import{createHash as gS}from"node:crypto";import{constants as co,promises as je}from"node:fs";import $e from"node:path";import{TextDecoder as wS}from"node:util";function uo(t,e){let r=$e.relative(t,e);return r===""||!$e.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${$e.sep}`)}function yS(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function NS(t,e){return B({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function bS(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function lo(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 kl(t,e){let r=await je.lstat(t);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await je.realpath(t),dev:r.dev,ino:r.ino,birthtimeMs:r.birthtimeMs}}async function lh(t,e,r){let i=$e.resolve(t),n=$e.resolve(e);if(!uo(i,n))throw new Error(`${r} is outside its managed root`);let a=[await kl(i,r)],o=i;for(let s of $e.relative(i,n).split($e.sep).filter(Boolean)){await Ot(a,r),o=$e.join(o,s);let c=await kl(o,r);if(!uo(a[0].realPath,c.realPath))throw new Error(`${r} parent resolves outside its managed root: ${o}`);a.push(c)}return await Ot(a,r),a}async function Ot(t,e){for(let r of t){let i=await je.lstat(r.path);if(!i.isDirectory()||i.isSymbolicLink()||!NS(r,i)||await je.realpath(r.path)!==r.realPath)throw new Error(`${e} parent changed during I/O: ${r.path}`)}}async function kS(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 un(t){let e=t.maxBytes===null?null:yS(t.maxBytes),r=$e.resolve(t.file),i=await lh(t.root,$e.dirname(r),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(d=>kl($e.resolve(d),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Ot(i,t.label);let a=await je.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=bS(a),s=await je.realpath(r);if(!uo(i[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(d=>uo(d.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?co.O_RDONLY:co.O_RDONLY|co.O_NOFOLLOW|co.O_NONBLOCK,l=await je.open(r,c);try{let d=await l.stat();await t.hooks?.afterOpen?.();let[u,p]=await Promise.all([je.lstat(r),je.realpath(r)]);if(await Ot(i,t.label),await Ot(n,t.label),!d.isFile()||!u.isFile()||u.isSymbolicLink()||p!==s||!lo(o,d)||!lo(o,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let f=await kS(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[m,h,g]=await Promise.all([l.stat(),je.lstat(r),je.realpath(r)]);if(await Ot(i,t.label),await Ot(n,t.label),!h.isFile()||h.isSymbolicLink()||g!==s||!lo(o,m)||!lo(o,h))throw new Error(`${t.label} changed while reading`);return{bytes:f,hash:gS("sha256").update(f).digest("hex"),size:f.length}}finally{await l.close()}}async function uh(t){let e=await un(t),r;try{r=new wS("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}}async function dn(t){let e=await lh(t.root,t.directory,t.label);return{verify:()=>Ot(e,t.label)}}var Ne=x(()=>{"use strict";H();Ve()});import{TextDecoder as ES}from"util";var mT,po=x(()=>{"use strict";H();I();Ne();mT=new ES("utf-8",{fatal:!0})});var K=x(()=>{"use strict";ve();Yi();bl();po()});import{createHash as CS}from"crypto";function he(t){return CS("sha256").update(t).digest("hex")}var Oe=x(()=>{"use strict"});import xl 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 GS(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 JS(t,e){return he(`comet.native.snapshot-policy.v1
164
+ ${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function El(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 US(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function mh(t){let e=Qa(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?US(n):void 0;if(a&&!a())return!1;let o=El(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 d=r[l];d&&(d.kind==="literal"&&d.value===s||d.kind==="question"&&s!=="/"?c.add(l+1):d.kind==="star"&&s!=="/"||d.kind==="globstar"?c.add(l):d.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(o=El(r,c,a),o===null||o.size===0)return!1}return El(r,o,a)?.has(r.length)??!1}}function KS(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>Qa(n,"include")))].sort((n,a)=>n.localeCompare(a,"en")),r=[...new Set(t.exclude.map(n=>Qa(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=JS(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(mh),excludeMatchers:r.map(mh),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 be(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function ke(t,e,r){let i=Object.keys(t).find(n=>!e.has(n));if(i)throw new Error(`${r} contains unknown field: ${i}`)}function Mr(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Xe(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function wh(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=xl.posix.normalize(t);if(r!==t||xl.posix.isAbsolute(t)||r===".."||r.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function YS(t,e){let r=be(t,`Native snapshot entry ${e}`);ke(r,LS,`Native snapshot entry ${e}`);let i=wh(r.path,`Native snapshot entry ${e} path`);if(typeof r.hash!="string"||!ho.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:Xe(r.size,`Native snapshot entry ${e} size`),type:"file"};if(r.gitObjectId!==void 0){if(typeof r.gitObjectId!="string"||!zS.test(r.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=r.gitObjectId}return n}function XS(t,e){let r=be(t,`Native snapshot omission ${e}`);if(ke(r,FS,`Native snapshot omission ${e}`),!VS.has(r.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!WS.has(r.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:wh(r.path,`Native snapshot omission ${e} path`),size:r.size===null?null:Xe(r.size,`Native snapshot omission ${e} size`),type:r.type,reason:r.reason}}function QS(t){let e=be(t,"Native snapshot omission overflow");if(ke(e,qS,"Native snapshot omission overflow"),typeof e.hash!="string"||!ho.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:Mr(e.count,"Native snapshot omission overflow count")}}function qr(t,e){let r=be(t,e);if(ke(r,HS,e),typeof r.hash!="string"||!ho.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=Xe(r.recordCount,`${e} recordCount`),n=Xe(r.storedRecordCount,`${e} storedRecordCount`),a=Xe(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 vh(t){let e=be(t,"Native Git selection evidence");if(ke(e,OS,"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=qr(e.stageBefore,"Native Git selection stageBefore"),i=qr(e.combined,"Native Git selection combined"),n=qr(e.stageAfter,"Native Git selection stageAfter"),a=qr(e.finalStageBefore,"Native Git selection finalStageBefore"),o=qr(e.finalCombined,"Native Git selection finalCombined"),s=qr(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[r,i,n,a,o,s].some(u=>u.overflow),l=!fo(r,n)||!fo(n,a)||!fo(i,o)||!fo(a,s),d=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!==d)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:d,stageBefore:r,combined:i,stageAfter:n,finalStageBefore:a,finalCombined:o,finalStageAfter:s}}function gh(t,e){let r=be(t,e);if(ke(r,BS,e),typeof r.hash!="string"||!ho.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=Xe(r.visitedNodeCount,`${e} visitedNodeCount`),n=Xe(r.recordCount,`${e} recordCount`),a=Xe(r.storedRecordCount,`${e} storedRecordCount`),o=Xe(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 ZS(t){let e=be(t,"Native physical selection evidence");if(ke(e,DS,"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=gh(e.before,"Native physical selection before"),i=gh(e.after,"Native physical selection after"),n=r.overflow||i.overflow,a=r.unstable||i.unstable||!GS(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 yh(t){let e=be(t,"Native content snapshot manifest");if(ke(e,AS,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!MS.has(e.origin))throw new Error("Native content snapshot origin is invalid");let r;if(e.capture!==void 0){let w=be(e.capture,"Native content snapshot capture");if(ke(w,jS,"Native content snapshot capture"),w.provider!=="git"&&w.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let _=w.gitSelection===void 0?void 0:vh(w.gitSelection),S=w.physicalSelection===void 0?void 0:ZS(w.physicalSelection),T=null;if(w.projection!==void 0){let Q=be(w.projection,"Native content snapshot projection");if(ke(Q,$S,"Native content snapshot projection"),Q.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");T={provider:"git",...Q.selection===void 0?{}:{selection:vh(Q.selection)}}}if(w.provider==="git"){if(S||T)throw new Error("Native Git capture cannot include physical or projection evidence");r={provider:"git",..._?{gitSelection:_}:{}}}else{if(_)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(S&&T)throw new Error("Native physical-tree capture cannot combine selection and projection");r=T?{provider:"physical-tree",projection:T}:{provider:"physical-tree",...S?{physicalSelection:S}:{}}}}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=be(e.limits,"Native content snapshot limits");ke(i,IS,"Native content snapshot limits");let n={maxFiles:Mr(i.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Mr(i.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Mr(i.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Mr(i.maxManifestBytes,"Native snapshot maxManifestBytes"),...i.maxDurationMs===void 0?{}:{maxDurationMs:Mr(i.maxDurationMs,"Native snapshot maxDurationMs")}},a;if(e.policy!==void 0){let w=be(e.policy,"Native snapshot policy");if(ke(w,TS,"Native snapshot policy"),w.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(w.include)||!Array.isArray(w.exclude))throw new Error("Native snapshot policy patterns must be arrays");a=KS({include:w.include,exclude:w.exclude,hash:w.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(YS),s=e.omitted.map(XS),c=Xe(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:QS(e.omissionOverflow);if(o.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(o.some(w=>w.size>n.maxFileBytes)||o.reduce((w,_)=>w+_.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(o.map(w=>w.path)).size!==o.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>PS||c<s.length)throw new Error("Native content snapshot omission count is invalid");let d=c-s.length;if(d===0&&l||d>0&&l?.count!==d)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 u=s.filter(w=>w.reason==="git-enumeration-limit"),p=s.filter(w=>w.reason==="git-selection-changed");for(let w of[...u,...p])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||p.length>1)throw new Error("Native Git selection omissions must not be duplicated");let f=r?.provider==="git"?r.gitSelection:r?.projection?.selection,m=f?.status==="overflow"||f?.status==="overflow-and-changed",h=f?.status==="changed"||f?.status==="overflow-and-changed";if(m!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(p.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let g=s.filter(w=>w.reason==="physical-enumeration-limit"),v=s.filter(w=>w.reason==="physical-selection-changed");for(let w of[...g,...v])if(w.path!=="."||w.size!==null||w.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(g.length>1||v.length>1)throw new Error("Native physical selection omissions must not be duplicated");let N=r?.physicalSelection,b=N?.status==="overflow"||N?.status==="overflow-and-changed",y=N?.status==="changed"||N?.status==="overflow-and-changed";if(b!==(g.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(y!==(v.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 eE(t,e){if(!_S.test(e))throw new Error(`Invalid Native change name: ${e}`);return xl.join(Z(t,e),"baseline-manifest.json")}async function Cl(t,e){let r=eE(t,e),i=Ae(t,r);await M(i,r);try{let n=await uh({root:i,file:r,maxBytes:null,label:"Native baseline snapshot manifest"});return yh(JSON.parse(n.text))}catch(n){if(n.code==="ENOENT")return null;throw n}}var LT,PS,_S,AS,IS,TS,jS,$S,OS,HS,DS,BS,LS,FS,qS,MS,VS,WS,ho,zS,FT,qT,MT,VT,WT,Vr=x(()=>{"use strict";Pr();H();ve();Oe();Ve();I();Ne();Li();LT={maxFiles:1e4,maxFileBytes:1024*1024*1024,maxTotalBytes:1024*1024*1024,maxManifestBytes:1024*1024*1024},PS=1e3,_S=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,AS=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),IS=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),TS=new Set(["schema","include","exclude","hash"]),jS=new Set(["provider","gitSelection","physicalSelection","projection"]),$S=new Set(["provider","selection"]),OS=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),HS=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),DS=new Set(["schema","status","before","after"]),BS=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),LS=new Set(["path","hash","size","type","gitObjectId"]),FS=new Set(["path","size","type","reason"]),qS=new Set(["ref","hash","count"]),MS=new Set(["change-created","legacy-migration","explicit"]),VS=new Set(["file","directory","other"]),WS=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"]),ho=/^[a-f0-9]{64}$/u,zS=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,FT=64*1024,qT=64*1024,MT={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},VT={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};WT=(1n<<256n)-1n});import{execFileSync as IE}from"node:child_process";function $E(t,e){try{return ji(()=>IE("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","pipe"],timeout:TE,maxBuffer:jE,windowsHide:!0}))}catch(r){let i=typeof r.stderr=="string"?r.stderr.trim():Buffer.isBuffer(r.stderr)?r.stderr.toString("utf8").trim():"";throw new Hl(t,e,i)}}function me(t,e){return $E(t,e).trim()}var TE,jE,Hl,Se=x(()=>{"use strict";Pr();TE=3e4,jE=8*1024*1024,Hl=class extends Error{constructor(r,i,n){super(`git ${i.join(" ")} failed${n?`: ${n}`:""}`);this.cwd=r;this.args=i;this.stderr=n;this.name="GitCommandError"}cwd;args;stderr}});import{promises as OE}from"node:fs";import HE from"node:path";function bo(t,e,r=""){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object${r}`);return t}function No(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 Ih(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 ME(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 Th(t,e,r=e){let i=new Set(e);for(let o of t){let s=o.covers.filter(c=>!i.has(c));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 Hh(t,e,r){let i={missing:[],extra:[],mismatched:[],uncovered:[],unknownCovers:[]};if(t.schema===Bl&&t.acceptance_index){let n=r.requiredAcceptanceIds??e??[],a=r.allowedAcceptanceIds??n,o=Object.keys(t.acceptance_index);i.missing=n.filter(l=>!(l in t.acceptance_index)),i.extra=o.filter(l=>!a.includes(l));let s=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of o){let d=s.get(l),u=t.acceptance_index[l];d&&u&&(u.source!==d.source||u.text!==d.text)&&i.mismatched.push(l)}let c=new Set(o);for(let l of t.children)i.unknownCovers.push(...l.covers.filter(d=>!c.has(d)));return i.uncovered=o.filter(l=>!jh(t.children,l)),$h(i)?i:null}if(t.schema===sr&&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=>!jh(t.children,a)),$h(i)?i:null}return null}function jh(t,e){return t.some(r=>r.covers.includes(e))}function $h(t){return t.missing.length>0||t.extra.length>0||t.mismatched.length>0||t.uncovered.length>0||t.unknownCovers.length>0}function Dt(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 VE(t){let e=bo(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=bo(n,`Native children acceptance_index.${i}`);if(No(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 WE(t,e,r){let i=r.requiredAcceptanceIds??e??[],n=r.allowedAcceptanceIds??i,a=Object.keys(t),o=i.filter(l=>!(l in t)),s=a.filter(l=>!n.includes(l));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 c=new Map((r.acceptanceCatalog??[]).map(l=>[l.id,l]));for(let l of a){let d=c.get(l);if(!d)continue;let u=t[l];if(u.source!==d.source||u.text!==d.text){let p=["source","text"].filter(f=>u[f]!==d[f]);throw new Error(`Native children acceptance_index.${l} does not match the acceptance catalog: copy ${p.join(", ")} exactly from the current acceptance catalog`)}}}function Dh(t,e,r={}){let i=(0,Oh.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Native children contract is invalid YAML: ${i.errors[0].message}`);let n=bo(i.toJS({mapAsMap:!1}),"Native children contract"),a=n.schema;if(a!==sr&&a!==Ht)throw No(n,Ah,"Native children contract"),new Error(`Native children schema must be ${sr} or ${Ht}`);let o=a===sr?"v1":"acceptance_index"in n?"indexed-v2":"summary-v2",s=o.replace("-"," ");if(No(n,o==="indexed-v2"?BE:Ah,"Native children contract"),!Array.isArray(n.children)||n.children.length===0)throw new Error("Native children must be a non-empty array");let c=n.children.map((p,f)=>{let m=bo(p,`Native child ${f}`);if(No(m,o==="indexed-v2"?qE:o==="summary-v2"?FE:LE,`Native ${s} child fields (child ${f})`),typeof m.name!="string"||!DE.test(m.name))throw new Error(`Native child ${f} name is invalid`);let h=o==="summary-v2";if(h){if(typeof m.summary!="string"||m.summary.trim().length===0)throw new Error(`Native child ${m.name} summary must be a non-empty string`);if(m.summary.length>2e3)throw new Error(`Native child ${m.name} summary exceeds 2000 characters`)}return{name:m.name,summary:h?m.summary:null,depends_on:Ih(m.depends_on,`Native child ${m.name} depends_on`),covers:o==="indexed-v2"||o==="v1"?Ih(m.covers,`Native child ${m.name} covers`):[]}}),l=c.map(({name:p})=>p);if(new Set(l).size!==l.length)throw new Error("Native child names must be unique");let d=new Set(l);for(let p of c){let f=p.depends_on.filter(m=>!d.has(m));if(f.length>0)throw new Error(`Native child ${p.name} depends on unknown child: ${f.join(", ")}`)}ME(c);let u=r.policy==="advisory";if(a===Bl){if(o==="indexed-v2"){let p=VE(n.acceptance_index);u||WE(p,e,r);let f=Object.keys(p);return u||Th(c,f,f),{schema:Ht,acceptance_index:p,children:c}}return{schema:Ht,children:c}}return e&&!u&&Th(c,e),{schema:sr,children:c}}async function dt(t){let e=HE.join(t.changeDir,Dl);try{await OE.lstat(e)}catch(o){if(o.code==="ENOENT")return null;throw o}let r=await L({root:t.changeDir,ref:Dl}),i=t.policy==="advisory",n=i?{...t.validation,policy:"advisory"}:t.validation??{},a=Dh(r.text,t.acceptanceIds,n);return{contract:a,hash:r.hash,size:r.size,drift:i?Hh(a,t.acceptanceIds,t.validation??{}):null}}var Oh,Dl,sr,Ht,Bl,DE,Ah,BE,LE,FE,qE,ko=x(()=>{"use strict";Oh=et(Me(),1);ue();Dl="children.yaml",sr="comet.native.children.v1",Ht="comet.native.children.v2",Bl=Ht,DE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Ah=new Set(["schema","children"]),BE=new Set(["schema","acceptance_index","children"]),LE=new Set(["name","depends_on","covers"]),FE=new Set(["name","summary","depends_on"]),qE=new Set(["name","depends_on","covers"])});var mn=x(()=>{"use strict"});var So=x(()=>{"use strict";to();mn()});function pt(t,e){if(!GE.test(t))throw new Error(`${e} must be a Git commit`)}function Ll(t,e){t.history.push({...e,at:new Date().toISOString()}),t.history.length>256&&t.history.splice(0,t.history.length-256)}function xo(t){pt(t.targetCommit,"Native Supervisor target commit");let e=new Set(t.contract.children.map(({name:i})=>i)),r=t.contract.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.depends_on],status:i.depends_on.length===0?"ready":"pending",baseCommit:null,candidateCommit:null,verifiedCommit:null,integrationCommit:null,verification:null,checks:[],blocker:null,projectRoot:null,task:null,acceptanceScope:Fl(t.contract,i.name),contractHash:O("comet.native.supervisor-contract.v1",t.contract),builderFailureCount:0}));for(let i of r)for(let n of i.dependsOn)if(!e.has(n))throw new Error(`Native Supervisor child ${i.name} depends on unknown child ${n}`);return{schema:vn,stateVersion:1,parent:t.parent,integration:{branch:t.integrationBranch,worktree:t.integrationWorktree,targetBranch:t.targetBranch,targetCommit:t.targetCommit,headCommit:t.targetCommit},children:r,history:[],finalVerification:{status:"pending",summary:null}}}function Fl(t,e){let r=t.children.find(i=>i.name===e);return r.covers.length>0?r.covers.map(i=>({id:i,source:t.acceptance_index?.[i]?.source??"brief.md",text:t.acceptance_index?.[i]?.text??i})):[{id:`child:${e}`,source:"children.yaml",text:r.summary??e}]}function Co(t){let e=t.children.every(i=>i.acceptanceScope&&i.acceptanceScope.length>0&&(!i.task||i.task.acceptance&&i.task.acceptance.length>0)),r=t.children.map(i=>({name:i.name,summary:i.summary,dependsOn:[...i.dependsOn],covers:i.acceptanceScope?.map(({id:n})=>n)??[],status:(i.status==="ready"||i.status==="active")&&i.blocker&&[...t.history].reverse().find(n=>n.child===i.name)?.kind==="task-blocked"?"blocked":i.status,phase:null,projectRoot:i.projectRoot??i.task?.projectRoot??null,message:e?i.blocker:"Supervisor acceptance scope is unavailable; restore children.yaml and confirm Shape before continuing",builderFailureCount:i.builderFailureCount??0}));return{contractHash:null,supervisorStateVersion:t.stateVersion,confirmed:e,parentBranch:t.integration.branch,children:r,readyChildren:e?r.filter(({status:i})=>i==="ready").map(({name:i})=>i):[],allDone:e&&r.every(({status:i})=>i==="integrated"||i==="archived")}}var GE,vn,Eo,cr=x(()=>{"use strict";F();So();GE=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;vn="comet.native.supervisor.v2",Eo=3});import gn from"node:path";import{promises as Lh}from"node:fs";function ql(t,e){return gn.join(Ue(t,e),"supervisor")}function Ro(t,e){return gn.join(ql(t,e),"state.json")}function Fh(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native Supervisor state must be an object");let e=t;if(e.schema!==vn)throw new Error(`Native Supervisor state schema must be ${vn}`);if(!Number.isSafeInteger(e.stateVersion)||typeof e.stateVersion!="number"||e.stateVersion<1)throw new Error("Native Supervisor state version is invalid");if(typeof e.parent!="string"||!e.parent)throw new Error("Native Supervisor state parent is invalid");if(!e.integration||typeof e.integration!="object")throw new Error("Native Supervisor integration state is missing");for(let[n,a]of Object.entries(e.integration))if(n!=="checkExecution"&&(typeof a!="string"||a.length===0))throw new Error(`Native Supervisor integration field ${n} is invalid`);if(pt(e.integration.targetCommit,"Native Supervisor target commit"),pt(e.integration.headCommit,"Native Supervisor integration head commit"),e.integration.checkExecution){let n=e.integration.checkExecution;if(!n.operationId||!n.key||!n.child||!["running","completed","interrupted"].includes(n.status)||!Number.isSafeInteger(n.ownerPid)||n.ownerPid<=0)throw new Error("Native Supervisor integration check execution is invalid");pt(n.candidateCommit,"Native Supervisor integration candidate commit"),pt(n.integrationCommit,"Native Supervisor integration check commit"),Bh(n.checkStates,"Native Supervisor integration")}if(!Array.isArray(e.children))throw new Error("Native Supervisor children are invalid");if(!Array.isArray(e.history))throw new Error("Native Supervisor history is invalid");if(!e.finalVerification||!["pending","passed","failed","incomplete"].includes(e.finalVerification.status)||e.finalVerification.summary!==null&&typeof e.finalVerification.summary!="string")throw new Error("Native Supervisor final verification is invalid");if(e.finalVerification.layers){let n=e.finalVerification.layers;if(!["complete","incomplete"].includes(n.childVerification)||!["complete","incomplete"].includes(n.parentIntegration)||!Array.isArray(n.parentChecks)||!n.parentChecks.every(a=>typeof a=="string")||!Array.isArray(n.notRerun)||!n.notRerun.every(a=>typeof a=="string")||!Array.isArray(n.incomplete)||!n.incomplete.every(a=>typeof a=="string"))throw new Error("Native Supervisor final verification layers are invalid")}for(let n of e.history)if(!n||typeof n!="object"||typeof n.kind!="string"||typeof n.summary!="string"||typeof n.at!="string"||n.child!==null&&typeof n.child!="string"||n.runId!==null&&typeof n.runId!="string")throw new Error("Native Supervisor history event is invalid");let r=new Set,i=new Set;for(let n of e.children){if(!n||typeof n!="object"||typeof n.name!="string")throw new Error("Native Supervisor child state is invalid");if(r.has(n.name))throw new Error(`Native Supervisor child ${n.name} is duplicated`);if(r.add(n.name),!Array.isArray(n.dependsOn)||!n.dependsOn.every(a=>typeof a=="string"))throw new Error(`Native Supervisor child ${n.name} dependencies are invalid`);if(typeof n.summary!="string"&&n.summary!==null)throw new Error(`Native Supervisor child ${n.name} summary is invalid`);if(n.builderFailureCount!==void 0&&(!Number.isSafeInteger(n.builderFailureCount)||n.builderFailureCount<0))throw new Error(`Native Supervisor child ${n.name} Builder failure count is invalid`);if(n.projectRoot!==void 0&&n.projectRoot!==null&&(typeof n.projectRoot!="string"||n.projectRoot.length===0))throw new Error(`Native Supervisor child ${n.name} projectRoot is invalid`);for(let[a,o]of[["base",n.baseCommit],["candidate",n.candidateCommit],["verified",n.verifiedCommit],["integration",n.integrationCommit]])o!==null&&pt(o,`Native Supervisor child ${n.name} ${a} commit`);if(!Array.isArray(n.checks)||!Array.isArray(n.verification?.checks??[]))throw new Error(`Native Supervisor child ${n.name} evidence is invalid`);if(n.task!==null){if(!n.task||typeof n.task!="object")throw new Error(`Native Supervisor child ${n.name} task is invalid`);if(!["builder","verifier"].includes(n.task.role)||n.task.child!==n.name||typeof n.task.projectRoot!="string"||n.task.projectRoot.length===0||typeof n.task.runId!="string"||n.task.runId.length===0)throw new Error(`Native Supervisor child ${n.name} task identity is invalid`);if(pt(n.task.baseCommit,`Native Supervisor child ${n.name} task base commit`),i.has(n.task.runId))throw new Error(`Native Supervisor task runId ${n.task.runId} is duplicated`);if(i.add(n.task.runId),n.task.role==="verifier"&&n.task.baseCommit!==n.candidateCommit)throw new Error(`Native Supervisor child ${n.name} verifier base commit is invalid`);if(n.task.projectRoot!==n.projectRoot)throw new Error(`Native Supervisor child ${n.name} task projectRoot is invalid`);if(n.task.checkExecution&&Bh(n.task.checkExecution.checkStates,`Native Supervisor child ${n.name}`),n.task.role==="builder"&&n.status!=="active"||n.task.role==="verifier"&&!["active","needs-reverify"].includes(n.status))throw new Error(`Native Supervisor child ${n.name} task status is invalid`)}}}async function He(t,e,r={}){try{let i=await Lh.readFile(Ro(t,e),"utf8"),n=JSON.parse(i);if(Fh(n),n.children.some(o=>!o.acceptanceScope||o.task&&!o.task.acceptance))try{let o=t;if(!o.changesDir)throw new Error("Native Supervisor upgrade requires full project paths to recover confirmed acceptance");let{readNativePortableState:s}=await Promise.resolve().then(()=>(Te(),Nl)),c=await s(gn.join(o.changesDir,e,"comet-state.yaml")),l=await dt({changeDir:gn.join(o.changesDir,e),acceptanceIds:c.acceptance.map(({id:d})=>d),validation:Dt(c)});if(!l)throw new Error("Native Supervisor upgrade requires the confirmed children contract");for(let d of n.children)l.contract.children.some(({name:u})=>u===d.name)&&(d.acceptanceScope=Fl(l.contract,d.name),d.contractHash=O("comet.native.supervisor-contract.v1",l.contract),d.task&&(d.task.acceptance=structuredClone(d.acceptanceScope),d.task.contractHash=d.contractHash,d.task.verificationBoundary="child-scope-parent-reverifies-all",d.task.checksReason="not-run"))}catch(o){if(!r.diagnostics)throw o}let a=t;if(a.changesDir)try{let{readNativePortableState:o}=await Promise.resolve().then(()=>(Te(),Nl)),s=await o(gn.join(a.changesDir,e,"comet-state.yaml"));s.workspace.change_branch&&(n.integration.targetBranch=s.workspace.change_branch)}catch(o){if(o.code!=="ENOENT")throw o}return n}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Bt(t,e){Fh(e),await Lh.mkdir(t.changesRuntimeDir,{recursive:!0}),await ie(Ro(t,e.parent),e,{containedRoot:t.changesRuntimeDir})}function Bh(t,e){if(t===void 0)return;if(!Array.isArray(t)||t.length===0)throw new Error(`${e} check states are invalid`);let r=new Set;for(let i of t){if(!i||typeof i.id!="string"||!i.id||r.has(i.id)||typeof i.name!="string"||!["planned","running","passed","failed","interrupted"].includes(i.status)||typeof i.repeatable!="boolean"||!Number.isSafeInteger(i.executionCount)||i.executionCount<0||!Array.isArray(i.argvDisplay)||!i.argvDisplay.every(n=>typeof n=="string")||typeof i.cwdRef!="string"||!Number.isSafeInteger(i.durationMs)||i.durationMs<0||i.exitCode!==null&&!Number.isSafeInteger(i.exitCode)||i.signal!==null&&typeof i.signal!="string"||typeof i.timedOut!="boolean"||i.startedAt!==null&&typeof i.startedAt!="string"||i.completedAt!==null&&typeof i.completedAt!="string"||i.logRef!==null&&typeof i.logRef!="string")throw new Error(`${e} check state is invalid`);r.add(i.id)}}var Lt=x(()=>{"use strict";H();F();ko();I();cr()});var Ml=x(()=>{"use strict"});var Ft=x(()=>{"use strict"});import{accessSync as z0,constants as G0,createWriteStream as J0,existsSync as U0,promises as K0,statSync as KE}from"node:fs";import lr from"node:path";function YE(t,e){let r=lr.relative(t,e);return r===""||!lr.isAbsolute(r)&&r!==".."&&!r.startsWith(`..${lr.sep}`)}function qh(t,e){if(e.length===0||e.includes("\\")||lr.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||lr.posix.normalize(e)!==e)throw new Error("Native check cwd must be a normalized project-relative ref");let r=lr.resolve(t),i=lr.resolve(r,...e.split("/"));if(!YE(r,i))throw new Error("Native check cwd escaped the project root");let n;try{n=KE(i)}catch(a){throw new Error(`Native check cwd does not exist: ${e}`,{cause:a})}if(!n.isDirectory())throw new Error(`Native check cwd is not a directory: ${e}`);return i}var Po=x(()=>{"use strict";$i();Ml();Ft()});var Mh=x(()=>{"use strict";Se();Po();F()});var _o=x(()=>{"use strict";Se();H()});var Kh,ur=x(()=>{"use strict";F();Vr();Kh=1024*1024});var To=x(()=>{"use strict";F();Ft();Li();ur()});var Am,UC,KC,YC,qL,XC,ML,pu=x(()=>{"use strict";F();Am="scoped-text-safety",UC=1,KC=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128}),YC="comet.native.checker-policy.v1",qL=O(YC,{policy:Am,version:UC,limits:KC,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"}),XC=["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"],ML=new Set(XC)});var xn=x(()=>{"use strict";F();pu();Ft()});var QC,aF,Vt=x(()=>{"use strict";H();I();Ve();ur();To();xn();QC=Kh,aF=3*QC});var jl=et(Me(),1);import{promises as PE}from"fs";import Wr from"path";Pr();_r();import{execFileSync as vb}from"child_process";import gb from"fs";import Xt from"path";import{AsyncLocalStorage as bf}from"node:async_hooks";$i();var Qt=new bf,kf=new bf;function Sf(t){return Qt.getStore()?t():Qt.run(new Map,t)}function wb(t){let e=Qt.getStore();for(let r of t)e?.set(Ct(r.root),t);return t}function Oi(t,e){return ji(()=>vb("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim())}function Hi(t,e){return Ct(t)===Ct(e)}function Ct(t){let e=Xt.resolve(t);try{let r=gb.realpathSync.native(e);return process.platform==="win32"?r.toLowerCase():r}catch{return process.platform==="win32"?e.toLowerCase():e}}function G(t){try{let e=kf.getStore()?.get(Ct(t)),r=Qt.getStore()?.get(e??Ct(t));if(r){let c=Di(e??t,r);if(c)return c;if(r.length===0)return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}let i=Xt.resolve(Oi(t,["rev-parse","--show-toplevel"])),n=Qt.getStore()?.get(Ct(i))??Ef(t),a=Di(i,n);if(Qt.getStore()&&a)return a;let o=n[0]?.root??i,s=null;try{s=Oi(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Hi(i,o),currentWorktreeRoot:i,primaryWorktreeRoot:o,currentBranch:s}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function ja(t){try{let e=Qt.getStore()?.get(kf.getStore()?.get(Ct(t))??Ct(t));return e?e.map(r=>({...r})):(Oi(t,["rev-parse","--is-inside-work-tree"]),Ef(t))}catch{return[]}}function Ef(t){let e=yb(Oi(t,["worktree","list","--porcelain","-z"]));return wb(e),e.map(r=>({...r}))}function yb(t){let e=t.split("\0"),r=[],i=null;for(let n of e)n.startsWith("worktree ")?(i&&r.push(i),i={root:Xt.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 Rt(t){return ja(t).map(e=>e.root)}function Di(t,e){let r=e.find(a=>Hi(Xt.resolve(a.root),Xt.resolve(t)));if(!r)return null;let i=Xt.resolve(e[0].root),n=Xt.resolve(r.root);return{isGitWorktree:!0,isSecondaryWorktree:!Hi(i,n),currentWorktreeRoot:n,primaryWorktreeRoot:i,currentBranch:r.branch}}function it(t,e){try{let r=Oi(t,["rev-parse","--verify",`${e}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(r)?r:null}catch{return null}}ue();H();Zt();ve();K();I();Ne();Vr();K();I();jr();At();var oE=et(Me(),1);jr();At();ot();ot();Tr();Zc();jr();ot();var oj=4*1024*1024;import{AsyncLocalStorage as sE}from"node:async_hooks";var cE=new sE;function lE(){let t=cE.getStore();return t?.active?t:null}function uE(t,e){let r=t;for(let i of e)r+="\0"+(typeof i=="string"?i:JSON.stringify(i));return r}function Nh(t,e){return(...r)=>{let i=lE();if(i===null)return e(...r);let n=uE(`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}}Tr();var pj=Nh("hookWritePolicy",async t=>(await Kc(t))?.hook??{allow_paths:[]});Ji();var dE=16*1024;Yc();Fi();var h$=Number.MAX_SAFE_INTEGER;H();Ve();var R$={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 wE}from"node:crypto";import{promises as mo}from"node:fs";import ut from"node:path";H();ue();K();I();var pn=/^[a-f0-9]{64}$/u,bh=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,yE=16*1024,_l=process.platform;function xh(t,e){let r=ut.relative(t,e);return ut.isAbsolute(r)||r===".."||r.startsWith(`..${ut.sep}`)?null:r.replaceAll("\\","/")||"."}function Ch(t){return Array.from(t).some(e=>{let r=e.codePointAt(0)??0;return r<=31||r===127})}function Rh(t,e){if(t.length===0||Ch(t)||t.includes("\\")||ut.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=ut.posix.normalize(t);if(r!==t||r===".."||r.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return r}function Al(t,e){return wE("sha256").update(`${t}
165
+ ${e}`).digest("hex")}async function kh(t,e){let r=await mo.realpath(e),i=await mo.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=_l==="win32"?ut.normalize(r).toLowerCase():r;return Al(t,`${n}
149
166
  ${i.dev}
150
167
  ${i.ino}
151
- ${i.birthtimeMs}`)}async function bp(e,t){let r=await qa.realpath(t),i=await qa.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=zc==="win32"?rt.normalize(r).toLowerCase():r;return Jc(e,n)}function Mk(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function Wc(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||Ep(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function Cp(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Wc(e.changeBranch,"Native workspace change branch"),Wc(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function Wk(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,r=new Set(["provider","baseCommit","targetBranch","targetCommit"]),i=Object.keys(t).filter(n=>!r.has(n));if(i.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${i.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!yp.test(t.baseCommit)||typeof t.targetCommit!="string"||!yp.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");Wc(t.targetBranch,"Native workspace Git target branch")}function Fa(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,r=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),i=Object.keys(t).filter(o=>!r.has(o));if(i.length>0)throw new Error(`Native workspace identity has unknown field(s): ${i.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!Bi.test(String(t.projectRootId))||!Bi.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");Mk(t.capturedAt),xp(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!Bi.test(String(t.projectRootPathId))||a&&!Bi.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!Bi.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&Wk(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Cp(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function zk(e,t){return rt.join(Y(e,t),"workspace.json")}function Jk(e,t){let r=zk(e,t),i=xe(e,r),n=Sp(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:xp(n,"Native workspace file ref")}}async function Gk(e,t){try{let r=Jk(e,t),i=await H({root:r.root,ref:r.ref,maxBytes:Vk});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Gc(e,t){let r=W(e.projectRoot),i={projectRoot:rt.resolve(e.projectRoot),currentBranch:r.currentBranch,isSecondaryWorktree:r.isSecondaryWorktree};try{let n=await Vi(e,t);if(n===null)return{...i,bindingState:"missing",isolation:null,changeBranch:null,targetBranch:null,finish:null};if(n.schema!=="comet.native.workspace.v3")return{...i,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:n.git?.targetBranch??null,finish:null};let a=await La({paths:e,identity:n});return{...i,bindingState:a.state==="aligned"?"aligned":"drifted",isolation:n.isolation,changeBranch:n.changeBranch,targetBranch:n.targetBranch,finish:n.finish}}catch{return{...i,bindingState:"invalid",isolation:null,changeBranch:null,targetBranch:null,finish:null}}}async function Uk(e){if(!Number.isSafeInteger(e.revision)||e.revision<1)throw new Error("Native workspace revision must be a positive integer");let t=Sp(e.paths.projectRoot,e.paths.nativeRoot);if(!t)throw new Error("Native root is outside the project root");let r=W(e.paths.projectRoot),i=r.isGitWorktree?Ke(e.paths.projectRoot,"HEAD"):null,n=e.binding?.targetBranch??r.currentBranch,a=n==null?null:Ke(e.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,d]=await Promise.all([Np("comet.native.workspace-project-root.v2",e.paths.projectRoot),Np("comet.native.workspace-native-root.v2",e.paths.nativeRoot),bp("comet.native.workspace-project-root-path.v2",e.paths.projectRoot),bp("comet.native.workspace-native-root-path.v2",e.paths.nativeRoot)]),u=(e.now??new Date).toISOString();if(e.finish&&!e.binding)throw new Error("Native workspace finish requires a workspace binding");e.binding&&Cp(e.binding);let f={capturedAt:u,capturedRevision:e.revision,nativeRootRef:t,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:d,...o?{git:o}:{},...e.sessionId?{sessionHash:Jc("comet.native.workspace-session.v2",`${s}
168
+ ${i.birthtimeMs}`)}async function Sh(t,e){let r=await mo.realpath(e),i=await mo.lstat(r);if(!i.isDirectory()||i.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=_l==="win32"?ut.normalize(r).toLowerCase():r;return Al(t,n)}function NE(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 Pl(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||Ch(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function Ph(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(Pl(t.changeBranch,"Native workspace change branch"),Pl(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 bE(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"||!bh.test(e.baseCommit)||typeof e.targetCommit!="string"||!bh.test(e.targetCommit))throw new Error("Native workspace Git provenance is invalid");Pl(e.targetBranch,"Native workspace Git target branch")}function vo(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"||!pn.test(String(e.projectRootId))||!pn.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");NE(e.capturedAt),Rh(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&&!pn.test(String(e.projectRootPathId))||a&&!pn.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!pn.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.git!==void 0&&bE(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(Ph(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 kE(t,e){return ut.join(Z(t,e),"workspace.json")}function SE(t,e){let r=kE(t,e),i=Ae(t,r),n=xh(i,r);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:i,ref:Rh(n,"Native workspace file ref")}}async function EE(t,e){try{let r=SE(t,e),i=await L({root:r.root,ref:r.ref,maxBytes:yE});return JSON.parse(i.text)}catch(r){if(r.code==="ENOENT")return null;throw r}}async function Il(t,e){let r=G(t.projectRoot),i={projectRoot:ut.resolve(t.projectRoot),currentBranch:r.currentBranch,isSecondaryWorktree:r.isSecondaryWorktree};try{let n=await fn(t,e);if(n===null)return{...i,bindingState:"missing",isolation:null,changeBranch:null,targetBranch:null,finish:null};if(n.schema!=="comet.native.workspace.v3")return{...i,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:n.git?.targetBranch??null,finish:null};let a=await go({paths:t,identity:n});return{...i,bindingState:a.state==="aligned"?"aligned":"drifted",isolation:n.isolation,changeBranch:n.changeBranch,targetBranch:n.targetBranch,finish:n.finish}}catch{return{...i,bindingState:"invalid",isolation:null,changeBranch:null,targetBranch:null,finish:null}}}async function xE(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=xh(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let r=G(t.paths.projectRoot),i=r.isGitWorktree?it(t.paths.projectRoot,"HEAD"):null,n=t.binding?.targetBranch??r.currentBranch,a=n==null?null:it(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,d]=await Promise.all([kh("comet.native.workspace-project-root.v2",t.paths.projectRoot),kh("comet.native.workspace-native-root.v2",t.paths.nativeRoot),Sh("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),Sh("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),u=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&Ph(t.binding);let p={capturedAt:u,capturedRevision:t.revision,nativeRootRef:e,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:d,...o?{git:o}:{},...t.sessionId?{sessionHash:Al("comet.native.workspace-session.v2",`${s}
152
169
  ${c}
153
- ${e.sessionId}`)}:{}},h=e.binding?{schema:"comet.native.workspace.v3",...f,...e.binding,finish:e.finish??null}:{schema:"comet.native.workspace.v2",...f};return Fa(h),h}async function Vi(e,t){let r=await Gk(e,t);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(Fa(r),r)}async function Uc(e){Fa(e.identity);let t=await Uk({paths:e.paths,name:"workspace-advisory",revision:e.identity.capturedRevision}),r=[],i=[];return t.nativeRootRef!==e.identity.nativeRootRef&&r.push("native-root-ref"),e.identity.projectRootPathId&&e.identity.nativeRootPathId?(t.projectRootPathId!==e.identity.projectRootPathId&&r.push("project-root-path"),t.nativeRootPathId!==e.identity.nativeRootPathId&&r.push("native-root-path")):(t.projectRootId!==e.identity.projectRootId&&r.push("project-root-legacy-identity"),t.nativeRootId!==e.identity.nativeRootId&&r.push("native-root-legacy-identity")),zc==="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 La(e){if(Fa(e.identity),e.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Uc(e)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=W(e.paths.projectRoot);return e.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!==e.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${e.identity.changeBranch}, but the current branch is ${r.currentBranch??"detached HEAD"}`}:e.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"}}Ri();Ca();Ca();var Ba=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"},Mi=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"},Va=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"},vj=sa("en");function te(e,t){Ut(t);let r=_r.join(e.changesDir,t);if(!z(e.changesDir,r))throw new Error("Native change path escaped");return r}async function Yc(e,t){let r=Y(e,t),i=_r.join(r,"schema-migration.json");await L(z(e.runtimeDir,i)?e.runtimeDir:e.nativeRoot,i);try{return await Xk.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function Qk(e,t=_r.dirname(e)){let r=_r.relative(t,e).split(_r.sep).join("/"),i=await H({root:t,ref:r,maxBytes:null,includeHash:!1}),n=(0,Kc.parseDocument)(i.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${e}: ${n.errors[0].message}`);return n.toJS()}async function Xc(e,t){let r=_r.join(te(e,t),tt);await L(e.nativeRoot,r);let i=Pc(await Qk(r,e.nativeRoot));if(i.state&&i.state.name!==t)throw new Error(`Native change directory/name mismatch: ${t}`);return await Yc(e,t)?{status:"migration-required",schema:i.schema,minimumRuntimeVersion:i.minimumRuntimeVersion,state:i.state,message:`Native schema migration is incomplete for ${t}; run doctor --repair`}:(i.status==="current"&&i.state&&await Zk(e,i.state),i)}async function Zk(e,t){if(await Vc(e,t.name)!==null&&t.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${t.verification_protocol}`)}oe();var Gp=Je(De(),1);import{promises as $S}from"node:fs";import Te from"node:path";Ie();oe();q();fe();A();Pe();za();za();Qt();It();Ie();xa();D();q();Qa();G();A();Vp();Qt();It();Za();Ie();fe();Za();Pi();A();var eo=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};function ol(e){if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(e))throw new Error(`Invalid Native Supervisor parent name: ${e}`);return`comet/supervisor/${e}/integration`}import IS from"node:path";Ie();fe();G();Qt();It();async function to(e){let t=ol(e.parent),r=Ke(e.paths.projectRoot,t);if(!r)return null;let i=Ke(e.paths.projectRoot,e.targetBranch);if(!i)return null;let n=wt(e.paths.projectRoot).map(o=>IS.resolve(o)).find(o=>W(o).currentBranch===t);if(!n)return null;let a=Ka({parent:e.parent,targetBranch:e.targetBranch,targetCommit:i,integrationBranch:t,integrationWorktree:n,contract:e.contract});if(r!==i){for(let o of a.children)o.status=o.dependsOn.length===0?"blocked":"pending",o.blocker=o.status==="blocked"?"Supervisor Runtime was lost; portable Child verification evidence is required.":null;a.integration.headCommit=r}return rl(a,{kind:"delivery-reconciled",child:null,runId:null,summary:"Supervisor state rebuilt from Git worktree facts"}),a}function sl(e,t){let r=Te.normalize(Te.resolve(e)),i=Te.normalize(Te.resolve(t));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function OS(e){let t=/^#\s+(?:Decisions|决策)\s*$/imu.exec(e);if(!t||t.index===void 0)return null;let r=e.slice(t.index+t[0].length);return r.split(/^#\s+/mu,1)[0]??r}function HS(e){let t=OS(e);if(!t||!/Supervisor\s+Change/iu.test(t))return!1;let r=t.match(/^\s*[-*]\s+(?:Child\b|子任务\b|子 Change\b)/gimu),i=t.match(/\bChild\s+\d+\b/giu);return Math.max(r?.length??0,i?.length??0)>=2}async function cl(e){try{let t=await H({root:e,ref:"brief.md",maxBytes:null,includeHash:!1});return HS(t.text)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function ll(e){return T("comet.native.parent-contract.v1",{acceptance:e.acceptance.map(({id:t,source:r,text:i})=>({id:t,source:r,text:i})),children:e.children})}async function DS(e){let t=wt(e.projectRoot);t.some(i=>sl(i,e.projectRoot))||t.push(e.projectRoot);let r=[];for(let i of[...new Set(t.map(n=>Te.resolve(n)))]){let n=await le(i);n&&r.push({projectRoot:i,paths:await Be(i,n.native.artifact_root),parent:sl(i,e.projectRoot)})}return r.some(({parent:i})=>i)||r.push({projectRoot:e.projectRoot,paths:e,parent:!0}),r}async function qS(e,t){let r=Te.join(e.paths.changesDir,t,"comet-state.yaml");try{return await Ct(r)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function FS(e,t){let r;try{r=await $S.readdir(e.paths.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()||![...t].some(o=>n.name.endsWith(`-${o}`))))try{let o=Te.join(e.paths.archiveDir,n.name,"comet-state.yaml"),s=await Ct(o);t.has(s.name)&&i.push({file:o,state:s})}catch{}return i}function LS(e,t,r){let i=Te.relative(e.projectRoot,t);if(!i||i===".."||i.startsWith(`..${Te.sep}`))return null;let n=i.split(Te.sep).join("/");try{let a=(0,Gp.parseDocument)(pe(e.projectRoot,["show",`${r}:${n}`]),{uniqueKeys:!0});return a.errors.length>0?null:ue(a.toJS({mapAsMap:!1}))}catch{return null}}function BS(e,t,r){return e.workspace.isolation!=="worktree"||e.workspace.target_branch!==r||e.workspace.finish!==null&&e.workspace.finish!=="merge"?{kind:"blocked",phase:e.phase,projectRoot:t.projectRoot,message:`Native child ${e.name} must use a linked worktree targeting parent branch ${r??"(missing)"}`}:e.status==="blocked"||e.status==="await-user"?{kind:"blocked",phase:e.phase,projectRoot:t.projectRoot,message:e.blockers[0]?.reason.text??`Native child ${e.name} requires user resolution`}:{kind:"active",phase:e.phase,projectRoot:t.projectRoot,message:null}}function Jp(e,t){return e.status==="done"&&e.archived&&e.workspace.finish==="merge"&&e.workspace.target_branch===t}async function Ir(e){let t=Te.join(e.paths.changesDir,e.state.name),r=await cl(t),i=null,n;try{n=await it({changeDir:t,validation:_t(e.state),...e.state.acceptance.length>0?{acceptanceIds:e.state.acceptance.map(({id:v})=>v)}:{},policy:"advisory"})}catch(v){i=`Children contract cannot be read; restore children.yaml and confirm Shape: ${v.message}`,n=null}if(!n){let v=await je(e.paths,e.state.name,{diagnostics:!0});if(v){let b=Ya(v);return{...b,...r?{coordinationChoiceRequired:!0}:{},confirmed:!1,readyChildren:[],allDone:!1,children:b.children.map(N=>({...N,message:i??"Children contract is missing; restore children.yaml and confirm Shape before continuing"}))}}if(i)throw new Error(i);return e.state.children_contract_hash?{...r?{coordinationChoiceRequired:!0}:{},contractHash:null,confirmed:!1,parentBranch:e.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:r?{coordinationChoiceRequired:!0,contractHash:null,confirmed:!1,parentBranch:e.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:null}let a=ll({acceptance:e.state.acceptance,children:n.contract}),o=e.state.workspace.change_branch,s=e.state.phase!=="shape"&&e.state.children_contract_hash===a&&!n.drift;if(n.contract.schema===Rt){let v=await je(e.paths,e.state.name,{diagnostics:!0});if(!v){let y=e.state.workspace.change_branch??e.state.workspace.target_branch;if(y){let E=await to({paths:e.paths,parent:e.state.name,targetBranch:y,contract:n.contract});E&&(v=E,await At(e.paths,E))}}if(v){let y=Ya(v);return e.state.children_contract_hash!==a||n.drift?{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:!1,readyChildren:[],allDone:!1,children:y.children.map(E=>({...E,message:n.drift?"Children acceptance index is stale; Shape confirmation is required":"Supervisor child plan changed; Shape confirmation is required"}))}:{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s&&y.confirmed}}let b=new Map(n.contract.children.map(y=>[y.name,y])),N=n.contract.children.map(y=>({name:y.name,summary:y.summary,dependsOn:[...y.depends_on],covers:[],status:s&&y.depends_on.every(E=>n.contract.children.filter(({name:w})=>w!==y.name).every(({name:w})=>w!==E))?"ready":"pending",phase:null,projectRoot:null,message:s?null:"Parent Shape confirmation is required"}));for(let y of N){if(y.status!=="ready")continue;b.get(y.name).depends_on.length>0&&(y.status="pending")}return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:N,readyChildren:N.filter(({status:y})=>y==="ready").map(({name:y})=>y),allDone:!1}}let c=await DS(e.paths),l=new Set(n.contract.children.map(({name:v})=>v)),d=new Map,u=new Map;for(let v of c){let b=v.parent&&o?`refs/heads/${o}`:"HEAD";for(let N of await FS(v,l)){let y={...N,source:v,committedState:LS(v,N.file,b)};d.set(N.state.name,[...d.get(N.state.name)??[],y])}for(let N of l){let y=await qS(v,N);y&&u.set(N,[...u.get(N)??[],{source:v,state:y}])}}let f=new Map;for(let v of n.contract.children){let b=(d.get(v.name)??[]).find(({source:E,committedState:w})=>E.parent&&w?.name===v.name&&Jp(w,o));if(b){f.set(v.name,{kind:"done",phase:b.state.phase,projectRoot:b.source.projectRoot,message:null});continue}let N=d.get(v.name)?.[0];if(N){f.set(v.name,{kind:"blocked",phase:N.state.phase,projectRoot:N.source.projectRoot,message:`Native child ${v.name} is archived but not merged into parent branch ${o??"(missing)"}`});continue}let y=u.get(v.name)??[];y.length>1?f.set(v.name,{kind:"blocked",phase:null,projectRoot:null,message:`Native child ${v.name} has multiple active workspace owners`}):y[0]&&f.set(v.name,BS(y[0].state,y[0].source,o))}let h=new Map(n.contract.children.map(v=>[v.name,v])),m=new Map,p=v=>{let b=m.get(v);if(b)return b;let N=h.get(v),E=N.depends_on.map(p).every(({status:Ne})=>Ne==="done"),w=f.get(v),R=w?.kind==="active"&&E?N.depends_on.filter(Ne=>!(d.get(Ne)??[]).some(({source:F,committedState:qr})=>sl(F.projectRoot,w.projectRoot)&&qr?.name===Ne&&Jp(qr,o))):[],S,I=w?.message??null;w?.kind==="done"?(S=E?"done":"blocked",E||(I=`Native child ${v} was merged before its dependencies`)):w?.kind==="active"?(S=E&&R.length===0?"active":"blocked",E?R.length>0&&(I=`Native child ${v} does not include merged dependencies: ${R.join(", ")}`):I=`Native child ${v} started before its dependencies merged`):w?.kind==="blocked"?S="blocked":(S=s&&E?"ready":"pending",s||(I="Parent Shape confirmation is required"));let K={name:v,summary:N.summary,dependsOn:[...N.depends_on],covers:[...N.covers],status:S,phase:w?.phase??null,projectRoot:w?.projectRoot??null,message:I};return m.set(v,K),K},g=n.contract.children.map(({name:v})=>p(v));return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:g,readyChildren:g.filter(({status:v})=>v==="ready").map(({name:v})=>v),allDone:g.every(({status:v})=>v==="done")}}import{promises as eh}from"fs";import th from"path";Mt();oe();Ae();A();var VS=["outcome","scope","nonGoals","acceptanceExamples"],J$=[...VS,"constraints","decisions","openQuestions","verificationExpectations"];oe();D();Ae();A();ge();gi();jt();G();D();Ae();Pi();G();A();ge();jt();q();q();ro();er();Ae();var Yp={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:[]},GS=de("comet-native-runtime:v3:scope-reopen"),PO=[{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")}];Ae();Ae();Ri();var Qp=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],o0=new Set(Qp),QS=new Set([...Qp,"minimum_runtime_version","revision"]),s0=new Set([...QS,"operation"]),ZS=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),c0=new Set([...ZS,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Ae();G();ge();jt();A();oe();$i();q();var x0={maxAcceptanceCriteria:ep.maxCriteria};var fl={maxSpecs:64};var rh=fl.maxSpecs*4;async function rE(e,t){let r=th.join(te(e,t),"specs"),i;try{i=await Li({root:e.nativeRoot,directory:r,label:"Native proposed specs directory"})}catch(s){if(s.code==="ENOENT")return[];throw s}let n=[],a=0,o=await eh.opendir(r);try{for await(let s of o){if(a+=1,a>rh)throw new Error(`Native proposed specs directory exceeds ${rh} entries`);if(s.isSymbolicLink())throw new Error(`Proposed spec capability must not be a symbolic link: ${s.name}`);if(!s.isDirectory())continue;Ut(s.name);let c=th.join(r,s.name,"spec.md");await L(e.nativeRoot,c);let l;try{l=await eh.lstat(c)}catch(d){if(d.code==="ENOENT")continue;throw d}if(l.isSymbolicLink()||!l.isFile())throw new Error(`Proposed spec must be a regular file: ${s.name}`);if(n.push(s.name),n.length>fl.maxSpecs)throw new Error("Native proposed specs exceed the spec-count budget")}}finally{await o.close().catch(s=>{if(s.code!=="ERR_DIR_CLOSED")throw s})}return await i.verify(),n.sort()}async function nh(e,t){let r=te(e,t),i={};for(let n of await rE(e,t)){let a=await H({root:r,ref:`specs/${n}/spec.md`,maxBytes:null});i[n]=a.text}return i}Oi();Qt();function re(e,t,r){return e.language==="zh-CN"?r:t}function iE(e,t,r){let i=n=>({required:!1,message:null,suggestedReply:null,agentInstruction:n});if(e.phase==="shape"&&e.status==="await-user"&&e.loop.next_action==="confirm-shape")return e.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(t&&e.phase==="shape"&&e.status==="active")return{required:!0,message:re(e,"This Supervisor Change has multiple independent children. Choose one coordination mode before confirming Shape: A) Multi-session coordination (recommended), or B) Single-session progression.","当前 Supervisor Change 包含多个可独立执行的 Child。确认 Shape 前请选择推进方式:A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:re(e,"Reply A or B","回复 A 或 B"),agentInstruction:re(e,"Relay the two coordination choices and wait for the user decision. After the user chooses, execute the prepare-shape-confirmation commandArgs with the selected --coordination-mode. Do not combine mode selection with final confirmation; confirmation of the complete Shape is a separate await-user step.","转述这两个推进方式并等待用户选择。用户选择后,使用对应的 --coordination-mode 执行 prepare-shape-confirmation 的完整 commandArgs;不要把推进方式选择和最终确认合并执行,完整 Shape 的确认是后续单独的 await-user 步骤。")};if(e.phase==="verify"&&e.status==="active"&&e.loop.stage==="verify-ready"&&e.loop.next_action!=="await-verifier-result")return i(re(e,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(e.phase==="verify"&&e.status==="active"&&e.loop.next_action==="await-verifier-result")return i(re(e,"Keep the same dispatched Verifier while it is active. A wait-tool timeout is not an execution timeout: check task progress and continue waiting; do not cancel, interrupt, or spawn a replacement just because a wait returned without a result. Request progress without telling the Verifier to stop inspecting. Only after confirmed task failure, a host-reported execution timeout, loss, or termination without a usable result, immediately submit verifier-execution-error. Preserve completed evidence and explain the failure and changed recovery approach before retrying. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Forward the actual report, including risks and incomplete checks; never turn an uninspected candidate into pass. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","已派发的验收任务仍在运行时,继续使用同一个 Verifier。等待工具超时不等于执行超时:检查任务进度并继续等待,不得仅因一次等待没有结果就取消、中断或重新派发。询问进度时不要要求停止核查。仅在确认任务失败、宿主报告执行超时、任务丢失或结束后没有可用结果时,立即提交 verifier-execution-error;保留已完成证据,重试前说明失败原因及恢复方式的变化。只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。忠实传递原始报告,包括风险和未完成检查;没有核查当前候选不能判定通过。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。"));if(e.status==="blocked"&&e.blockers.some(({resolution_action:n})=>n==="retry-verifier"))return e.loop.retry_epoch>=3?e.language==="zh-CN"?{required:!0,message:"自动重试验收已连续多轮未能取得结果,验证环境很可能不可用。请人工检查验证环境(subagent 配额、平台任务队列、网络),或使用 doctor --repair 评估该 change 状态。",suggestedReply:"人工检查验证环境",agentInstruction:"只向用户转述 message,等待用户完成人工检查后再继续。不要自动重试验收。"}:{required:!0,message:"Automatic verification retries have failed across multiple rounds; the verification environment is likely unavailable. Inspect the environment manually (subagent quota, platform task queue, network), or use doctor --repair to assess the change state.",suggestedReply:"Inspect the verification environment",agentInstruction:"Relay message to the user and wait for a manual environment check before continuing. Do not retry verification automatically."}:e.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.verification?.assurance==="semantic-verification-unavailable")return e.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="resolve-verifier-blocker")return e.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(e.phase==="verify"&&e.status==="await-user"&&e.loop.next_action==="await-user"){let a=(e.loop.stop_reason??(e.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",o=a?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。注意:预算不会重置,选择继续修复后,下一次验收失败会再次暂停。",s=a?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return e.language==="zh-CN"?{required:!0,message:o,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:s,suggestedReply:"Continue repairing",agentInstruction:"Relay message and suggestedReply, then wait for the user to explicitly choose between continuing the implementation (revise-implementation) and adjusting the requirements (revise-requirements); run the matching commandAlternative afterwards. When continuing, ask the Builder to change its repair approach. Do not choose for the user, and do not expose internal rounds, counters, paths, or recovery steps."}}if(e.phase==="verify"&&e.status==="await-user"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass")return{required:!0,message:re(e,"The reported verification passed, but this platform cannot confirm an independent Verifier execution. Review the result and choose whether to accept it for Archive, revise the implementation, or revise the requirements.","当前验收报告已通过,但当前平台无法确认验收是否独立执行。请检查结果,并选择接受结果进入归档、继续修改实现,或调整需求。"),suggestedReply:re(e,"Accept the result","接受结果"),agentInstruction:re(e,"Summarize the result and verification evidence, relay the message, and wait for an explicit user decision. Only then execute the matching commandAlternative. Do not accept the result on the user’s behalf.","简要说明交付结果和验收证据,转述 message,并等待用户明确选择后再执行对应的 commandAlternative。不要替用户接受结果。")};if(e.phase==="build"&&e.status==="active"){let n=r?.children.some(({status:c})=>c==="blocked")??!1,a=r?.children.some(({status:c})=>c==="needs-reverify")??!1,o=r?.children.some(({status:c})=>c==="ready"||c==="active")??!1,s=r?.children.some(({status:c,builderFailureCount:l})=>c==="blocked"&&(l??0)>=Ua)??!1;return n&&!a&&!o&&!s?e.language==="zh-CN"?{required:!0,message:"Supervisor 子任务暂时无法启动,已暂停自动重试以避免流程循环。请先根据子任务 blocker 修复工作区、分支或依赖;修复完成后重新运行最新的 next 继续流程。代码和已有证据已保留。",suggestedReply:"修复 blocker 后继续",agentInstruction:"向用户说明子任务 blocker 和需要先完成的外部修复;不要反复执行 next,也不要创建替代任务。用户确认工作区或依赖已修复后,再重新读取 status 并执行最新 continuation。"}:{required:!0,message:"Supervisor child dispatch is paused because every remaining child is blocked. Automatic retries are stopped to avoid a loop. Resolve the recorded child blocker (workspace, branch, or dependency) first, then read the latest status and continue; code and completed evidence are preserved.",suggestedReply:"Resolve the blocker and continue",agentInstruction:"Explain the child blocker and the required external repair to the user. Do not repeatedly run next or spawn replacement tasks. After the user confirms the workspace or dependency is fixed, read status again and execute the latest continuation."}:i(re(e,"Implement the confirmed scope and run focused checks. A separate pre-review is optional, not a prerequisite for Builder handoff. If review is useful, retain the same Reviewer for focused repair follow-ups rather than starting repeated full reviews. Submit the stable candidate for one complete independent verification; release completed helper tasks.","实现已确认范围并运行相关检查。额外预审是可选项,不是 Builder 交接的前置条件。确有必要审查时,保留同一个 Reviewer 复核修复及受影响范围,避免反复启动完整审查。候选稳定后提交一次完整独立验收,及时释放已完成的辅助任务。"))}return i(re(e,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function nE(e){let t=e.workspace.change_branch??"<change-branch>",r=e.workspace.target_branch??"<target-branch>";return e.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${t},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会先执行完整 dry-run,再给出唯一的 confirmed 命令;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"只向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 中包含 --dry-run --finish 的完整命令;选择 E 时停止,不运行任何 Archive 命令。不要直接运行 --confirmed,也不要自行猜测 finish。"}:{required:!0,message:`This change is on ${t} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run a complete dry-run first, then return one confirmed command; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative containing --dry-run --finish; for E, stop without running an Archive command. Do not run --confirmed directly or guess a finish mode."}}function aE(e){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","archive",e.name,"--dry-run","--finish",i],requiredInputs:[],inputOptions:[],description:re(e,a[1],a[0])})),{name:"defer-archive",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:re(e,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function ch(e){return["comet","native","next",e.change,"--summary","<summary>",e.flag,"--expected-state-version",String(e.stateVersion),"--expected-action",e.action]}function rr(e,t){return{name:e,flag:t,valueKind:"text",required:!0,template:null}}function ah(){return{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}}function oE(e,t){return{name:e,flag:t,valueKind:"confirmation",required:!0,template:null}}function oh(e,t,r){return{name:e,flag:t,valueKind:"choice",required:!0,template:null,choices:[...r]}}function sE(e){return e?.coordinationChoiceRequired===!0||e?.schema==="comet.native.children.v2"&&e.children.length>=2}function cE(e){return["comet","native","next",e.change,"--summary","<summary>",...e.coordinationRequired?["--coordination-mode","<coordination-mode>"]:[],"--expected-state-version",String(e.stateVersion),"--expected-action","prepare-shape-confirmation"]}function Tt(e){return{name:e.name,stateVersion:e.stateVersion,expectedAction:e.expectedAction,commandArgs:ch({change:e.change,stateVersion:e.stateVersion,action:e.expectedAction,flag:e.flag}),requiredInputs:["summary",e.confirmationInput],inputOptions:[rr("summary","--summary"),oE(e.name,e.flag)]}}function sh(e,t){return t.some(i=>/^verification\.md is (?:missing|stale|invalid)$/u.test(i))?[{name:"repair-verification-report",stateVersion:e.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","doctor",e.name,"--repair"],requiredInputs:[],inputOptions:[],description:re(e,"Rebuild the Runtime-managed verification report, then rerun the Archive dry-run.","重建由 Runtime 管理的 verification.md,然后重新运行 Archive 预检。")}]:[]}function lE(e){return/^verification\.md is (?:missing|stale|invalid)$/u.test(e)}function ao(e){return[Tt({name:"revise-implementation",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),Tt({name:"revise-requirements",change:e.change,stateVersion:e.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function uE(e){let t={"request-checks":"Choose when the Verifier needs additional Runtime checks.","final-result":"Choose when the Verifier has a result for every current scope ID.","verifier-execution-error":"Choose when a dispatched Verifier failed, was lost, or ended without a result.","verifier-unavailable":"Choose only when the platform has no usable independent Verifier capability."};return e.flatMap(r=>Array.isArray(r.template)?r.template.map(i=>{let n=i.response?.kind??i.kind;return{...r,name:n,required:!1,exclusiveGroup:"runner-input",description:t[n],template:i}}):[r])}function jr(e,t,r={}){let i=sE(t)&&e.coordination_mode===void 0,n=iE(e,i,t),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:e.name,phase:e.phase,status:e.status,stateVersion:e.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:e.builder_handoff?.candidate_id??null,iteration:e.loop.iteration,attempt:e.loop.attempt});if(e.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(e.status==="await-user")return e.phase==="shape"&&e.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation"],inputOptions:[rr("summary","--summary")],commandAlternatives:[Tt({name:"confirm-shape",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:e.phase==="verify"&&e.verification_result==="pass"&&e.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[rr("summary","--summary")],commandAlternatives:[Tt({name:"accept-result",change:e.name,stateVersion:e.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...ao({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.verification?.assurance==="semantic-verification-unavailable"&&e.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[rr("summary","--summary")],commandAlternatives:[Tt({name:"retry-verifier",change:e.name,stateVersion:e.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),Tt({name:"confirm-verifier-unavailable",change:e.name,stateVersion:e.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[rr("summary","--summary")],commandAlternatives:[Tt({name:"resolve-verifier-blocker",change:e.name,stateVersion:e.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...ao({change:e.name,stateVersion:e.state_version})],runnerAction:o("none")}:e.phase==="verify"&&e.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[rr("summary","--summary")],commandAlternatives:ao({change:e.name,stateVersion:e.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,commandAlternatives:ao({change:e.name,stateVersion:e.state_version}),userCommunication:{...a.userCommunication,required:!0,message:e.blockers.length>0?e.blockers.map(({reason:s})=>s).join("; "):a.userCommunication.message,suggestedReply:e.blockers.length>0?e.blockers[0]?.resolution_action??null:a.userCommunication.suggestedReply},requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(e.status==="blocked"){let s=e.blockers.some(({resolution_action:c})=>c==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?ch({change:e.name,stateVersion:e.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(e.phase==="shape")return{...a,disposition:i?"await-user":"continue",action:"prepare-shape-confirmation",commandArgs:cE({change:e.name,stateVersion:e.state_version,coordinationRequired:i}),requiredInputs:["summary",...i?["coordination-choice"]:[]],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null},...i?[oh("coordination-mode","--coordination-mode",tp)]:[]],runnerAction:o("none")};if(e.phase==="build"){if(t){if(!t.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.loop.stage==="repairing"&&e.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:["comet","native","next",e.name,"--summary","<summary>"],requiredInputs:["repair-child"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[ah()],known_limits:[]}}],runnerAction:o("builder-handoff")};let s=t.children.find(({status:m})=>m==="verified");if(s){let m=r.supervisorIntegrationRetryIds;return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["supervisor-integration-checks"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-integrate",child:s.name,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}],...m&&m.length>0?{retry_check_ids:[...m]}:{}}}],runnerAction:o("none")}}let c=t.children.some(({status:m})=>m==="blocked"||m==="needs-reverify"),l=t.children.some(({status:m})=>m==="needs-reverify"),d=t.children.some(({status:m})=>m==="ready"||m==="active"),u=t.supervisorStateVersion===void 0?null:t.children.find(m=>m.status==="blocked"&&(m.builderFailureCount??0)>=Ua)??null,f=u===null?null:{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-retry-builder",child:u.name,stateVersion:t.supervisorStateVersion},description:re(e,"Explicitly authorize one fresh Builder attempt after the Builder failure budget was exhausted.","Builder 失败预算已耗尽;明确授权后才能重新开始一次 Builder 尝试。")},h=c&&!l&&!d&&f===null;return{...a,disposition:h?"blocked":"continue",action:"advance-children",commandArgs:h?null:f!==null?["comet","native","next",e.name,"--runner-input","<temporary-json-file>"]:["comet","native","next",e.name,"--summary","<summary>",...e.coordination_mode==="single-session"?["--max-parallel","1"]:[]],requiredInputs:h?[]:f!==null?["supervisor-builder-retry-json-file"]:["ready-children"],inputOptions:h?[]:f!==null?[f]:[rr("summary","--summary")],runnerAction:o("none")}}return{...a,disposition:"continue",action:e.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:["<acceptance-id>"],checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[],known_limits:[]}}],runnerAction:o("builder-handoff")}}if(e.phase==="verify"){let s=e.loop.next_action==="await-verifier-result",c=!!e.children_contract_hash,l=ah();return!s&&r.retryCheckIds&&r.retryCheckIds.length>0?{...a,disposition:"continue",action:"retry-checks",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:["retry-checks-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"retry-checks",check_ids:[...r.retryCheckIds]}}],runnerAction:o("retry-checks")}:{...a,userCommunication:!s&&c?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${re(e,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",e.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:uE([{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",candidateId:e.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"request-checks",iteration:e.loop.iteration,attempt:e.loop.attempt,checks:[l]}},{kind:"verifier-response",candidateId:e.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"final-result",result:{iteration:e.loop.iteration,attempt:e.loop.attempt,verdict:"blocked",acceptance:[{id:"<acceptance-id>",result:"blocked",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:e.state_version,iteration:e.loop.iteration,attempt:e.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:r.verificationCheckPlans?r.verificationCheckPlans.map(d=>({...d,argv:[...d.argv]})):c?[l]:[]}}]),runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(e.phase==="archive"&&e.status==="active"&&e.loop.stage==="archive-ready"&&!e.archived){let s=r.archiveMode??"archive-ready",l=e.workspace.isolation!=="current"&&e.workspace.finish===null;if(s==="blocked")return{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")};if(s==="preview"){if(r.archiveBlockers&&r.archiveBlockers.length>0){let d=sh(e,r.archiveBlockers)[0];return d&&r.archiveBlockers.every(u=>lE(u))?{...a,disposition:"continue",action:"repair",commandArgs:d.commandArgs,requiredInputs:[],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],commandAlternatives:sh(e,r.archiveBlockers),runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}return l?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[oh("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...aE(e)],userCommunication:nE(e),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--dry-run"],requiredInputs:[],commandAlternatives:[Tt({name:"revise-requirements",change:e.name,stateVersion:e.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}Ie();xa();q();Qa();import Dr from"node:path";Pe();Yt();Wi();Ga();import{promises as fE}from"node:fs";D();Oi();import lh from"node:path";function Gi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function Ui(e,t,r){let i=Object.keys(e).filter(n=>!t.has(n));if(i.length>0)throw new Error(`${r} has unknown field(s): ${i.join(", ")}`)}function ie(e,t,r=!1){if(typeof e!="string"||!r&&e.length===0)throw new Error(`${t} must be ${r?"a string":"a non-empty string"}`);return e}function Tr(e,t){return e===null?null:ie(e,t)}function $r(e,t,r=0){if(!Number.isSafeInteger(e)||e<r)throw new Error(`${t} must be a safe integer greater than or equal to ${r}`);return e}function pE(e,t){if(e===null)return null;if(!Number.isSafeInteger(e))throw new Error(`${t} must be null or a safe integer`);return e}function hE(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean`);return e}function Or(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} must be one of: ${t.join(", ")}`);return e}function hl(e,t){if(e===null)return null;let r=ie(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function mE(e,t){let r=ie(e,t);if(Number.isNaN(Date.parse(r)))throw new Error(`${t} must be an ISO timestamp`);return r}function ml(e,t){let r=ie(e,t);if(!lh.isAbsolute(r))throw new Error(`${t} must be absolute`);return lh.resolve(r)}function vE(e,t){let r=`Native local checks[${t}]`,i=Gi(e,r);if(Ui(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((d,u)=>ie(d,`${r}.argv[${u}]`,!0)),a=Or(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=hl(i.startedAt,`${r}.startedAt`),s=hl(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=$r(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 d=Gi(i.activeProcess,`${r}.activeProcess`),u=Or(d.status,["starting","running"],`${r}.activeProcess.status`);if(Ui(d,new Set(["status","pid","identity"]),`${r}.activeProcess`),u==="starting"){if(Object.hasOwn(d,"pid")||Object.hasOwn(d,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);l={status:"starting"}}else l={status:"running",pid:$r(d.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(d,"identity")?{identity:ie(d.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:hE(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:$r(i.executionCount,`${r}.executionCount`),argv:n,cwd:ml(i.cwd,`${r}.cwd`),exitCode:pE(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:Or(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:ie(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function gE(e){let t="Native local execution state",r=Gi(e,t);if(Ui(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),t),r.schema!==Pa)throw new Error(`Native local execution schema must be ${Pa}`);let i=Gi(r.workspace,"Native local workspace");Ui(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=Gi(r.execution,"Native local execution");Ui(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=hl(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:Or(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Or(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Tr(o.executionId,"Native local execution.executionId"),status:Or(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:$r(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:mE(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:$r(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(vE);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:Pa,change:ie(r.change,"Native local change"),basedOnStateVersion:$r(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:Tr(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:Tr(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:Tr(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:Tr(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:ml(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:ml(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Tr(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:ie(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}async function oo(e){let t;try{t=await fE.readFile(e,"utf8")}catch(i){if(i.code==="ENOENT")return null;throw i}let r;try{r=JSON.parse(t)}catch(i){throw new Error(`Native local execution state is invalid JSON: ${i.message}`,{cause:i})}return gE(r)}function vl(e,t){let r=t?.execution;if(!(e.phase!=="verify"||e.status!=="active"||e.loop.next_action!=="await-verifier-result"||e.builder_handoff?.candidate_id===void 0||e.builder_handoff?.candidate_id===null||t===null||t.change!==e.name||t.basedOnStateVersion!==e.state_version||t.candidateId!==e.builder_handoff.candidate_id||r==null||r.stage!=="verifying"||r.actor!=="verifier"||r.status!=="running"||r.executionId===null))return r.executionId}G();Yt();A();import{promises as wE}from"node:fs";import gl from"node:path";Ie();Pe();A();var uh=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,dh="comet-state.yaml",fh="state.json";function at(e,t){if(!uh.test(t))throw new Error(`Invalid Native change name: ${t}`);let r=gl.join(e.changesDir,t);if(!z(e.changesDir,r))throw new Error("Native change path escaped");return r}function so(e,t){return gl.join(at(e,t),dh)}function $t(e,t){return gl.join(Ve(e,t),fh)}async function Hr(e,t){try{let r=await wE.readFile(so(e,t),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function $e(e,t){return Ct(so(e,t))}async function co(e){let t=await $e(e.paths,e.name),r=$t(e.paths,e.name);try{let i=await oo(r);return i===null?{state:t,local:null,localStatus:"missing"}:i.change!==t.name||i.basedOnStateVersion!==t.state_version?{state:t,local:null,localStatus:"stale"}:{state:t,local:i,localStatus:"available"}}catch(i){return i.code==="ENOENT"?{state:t,local:null,localStatus:"missing"}:{state:t,local:null,localStatus:"invalid"}}}D();oe();q();G();Ac();Sc();Pe();Yt();D();Mt();Wi();A();Mt();Ot();fe();var mh=Je(De(),1);St();var WH=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 YH=256*1024;Pe();Yt();It();var _E=sa("en");function IE(e,t){let r=Dr.relative(Dr.resolve(e),Dr.resolve(t));if(Dr.isAbsolute(r)||r===".."||r.startsWith(`..${Dr.sep}`))throw new Error("Native local check cwd escaped the project root");let i=r.length===0?".":r.split(Dr.sep).join("/");return Bp(e,i),i}function Nl(e,t=e.workspace.projectRoot){return e.checks.map(r=>{let[i,...n]=r.argv;if(!i)throw new Error(`Native local check ${r.id} has no executable`);return{id:r.id,name:r.name,executable:i,argv:n,cwdRef:IE(t,r.cwd),timeoutMs:r.timeoutMs,repeatable:r.repeatable}})}var cq=1024*1024*1024;fe();G();Qt();It();Pe();Yt();G();Ga();Wi();It();G();It();G();Dc();Ei();import tn from"path";import{realpathSync as ux}from"fs";function Nh(e,t){let r=d=>d!==null&&typeof d=="object"&&!Array.isArray(d)?d:{},i=r(e),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:t??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 ot={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function bh(e){return e?e.command?`${ot.next} ${e.command}`:e.ask_user?`${ot.next} ${e.ask_user}`:null:null}function kh(e,t){let r=[e.summary],i=bh(e.next);return i&&r.push(i),e.user_message&&r.push("",ot.relay,e.user_message),t!==void 0&&r.push("",ot.details,JSON.stringify(t,null,2)),`${r.join(`
170
+ ${t.sessionId}`)}:{}},f=t.binding?{schema:"comet.native.workspace.v3",...p,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...p};return vo(f),f}async function fn(t,e){let r=await EE(t,e);return r===null||r&&typeof r=="object"&&!Array.isArray(r)&&r.schema==="comet.native.workspace.v1"?null:(vo(r),r)}async function Tl(t){vo(t.identity);let e=await xE({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")),_l==="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 go(t){if(vo(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 Tl(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let r=G(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"}}Xi();eo();eo();var wo=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"},hn=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"},yo=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"},m0=Da("en");function oe(t,e){nr(e);let r=Wr.join(t.changesDir,e);if(!J(t.changesDir,r))throw new Error("Native change path escaped");return r}async function $l(t,e){let r=Z(t,e),i=Wr.join(r,"schema-migration.json");await M(J(t.runtimeDir,i)?t.runtimeDir:t.nativeRoot,i);try{return await PE.lstat(i),!0}catch(n){if(n.code==="ENOENT")return!1;throw n}}async function _E(t,e=Wr.dirname(t)){let r=Wr.relative(e,t).split(Wr.sep).join("/"),i=await L({root:e,ref:r,maxBytes:null,includeHash:!1}),n=(0,jl.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 Ol(t,e){let r=Wr.join(oe(t,e),lt);await M(t.nativeRoot,r);let i=sl(await _E(r,t.nativeRoot));if(i.state&&i.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await $l(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 AE(t,i.state),i)}async function AE(t,e){if(await Cl(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}ue();var Jh=et(Me(),1);import{promises as ux}from"node:fs";import De from"node:path";Se();ue();F();ve();I();Te();ko();ko();cr();Lt();Se();Za();H();F();Po();K();I();Mh();cr();Lt();_o();Se();ve();_o();Yi();I();var Ao=class extends Error{constructor(r,i,n){super(r,n);this.preparation=i;this.name="NativeWorkspacePreparationError"}preparation};function Vl(t){if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t))throw new Error(`Invalid Native Supervisor parent name: ${t}`);return`comet/supervisor/${t}/integration`}import sx from"node:path";Se();ve();K();cr();Lt();async function Io(t){let e=Vl(t.parent),r=it(t.paths.projectRoot,e);if(!r)return null;let i=it(t.paths.projectRoot,t.targetBranch);if(!i)return null;let n=Rt(t.paths.projectRoot).map(o=>sx.resolve(o)).find(o=>G(o).currentBranch===e);if(!n)return null;let a=xo({parent:t.parent,targetBranch:t.targetBranch,targetCommit:i,integrationBranch:e,integrationWorktree:n,contract:t.contract});if(r!==i){for(let o of a.children)o.status=o.dependsOn.length===0?"blocked":"pending",o.blocker=o.status==="blocked"?"Supervisor Runtime was lost; portable Child verification evidence is required.":null;a.integration.headCommit=r}return Ll(a,{kind:"delivery-reconciled",child:null,runId:null,summary:"Supervisor state rebuilt from Git worktree facts"}),a}function Wl(t,e){let r=De.normalize(De.resolve(t)),i=De.normalize(De.resolve(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function dx(t){let e=/^#\s+(?:Decisions|决策)\s*$/imu.exec(t);if(!e||e.index===void 0)return null;let r=t.slice(e.index+e[0].length);return r.split(/^#\s+/mu,1)[0]??r}function px(t){let e=dx(t);if(!e||!/Supervisor\s+Change/iu.test(e))return!1;let r=e.match(/^\s*[-*]\s+(?:Child\b|子任务\b|子 Change\b)/gimu),i=e.match(/\bChild\s+\d+\b/giu);return Math.max(r?.length??0,i?.length??0)>=2}async function zl(t){try{let e=await L({root:t,ref:"brief.md",maxBytes:null,includeHash:!1});return px(e.text)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function Gl(t){return O("comet.native.parent-contract.v1",{acceptance:t.acceptance.map(({id:e,source:r,text:i})=>({id:e,source:r,text:i})),children:t.children})}async function fx(t){let e=Rt(t.projectRoot);e.some(i=>Wl(i,t.projectRoot))||e.push(t.projectRoot);let r=[];for(let i of[...new Set(e.map(n=>De.resolve(n)))]){let n=await pe(i);n&&r.push({projectRoot:i,paths:await Je(i,n.native.artifact_root),parent:Wl(i,t.projectRoot)})}return r.some(({parent:i})=>i)||r.push({projectRoot:t.projectRoot,paths:t,parent:!0}),r}async function hx(t,e){let r=De.join(t.paths.changesDir,e,"comet-state.yaml");try{return await $t(r)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function mx(t,e){let r;try{r=await ux.readdir(t.paths.archiveDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r)if(!(!n.isDirectory()||n.isSymbolicLink()||![...e].some(o=>n.name.endsWith(`-${o}`))))try{let o=De.join(t.paths.archiveDir,n.name,"comet-state.yaml"),s=await $t(o);e.has(s.name)&&i.push({file:o,state:s})}catch{}return i}function vx(t,e,r){let i=De.relative(t.projectRoot,e);if(!i||i===".."||i.startsWith(`..${De.sep}`))return null;let n=i.split(De.sep).join("/");try{let a=(0,Jh.parseDocument)(me(t.projectRoot,["show",`${r}:${n}`]),{uniqueKeys:!0});return a.errors.length>0?null:fe(a.toJS({mapAsMap:!1}))}catch{return null}}function gx(t,e,r){return t.workspace.isolation!=="worktree"||t.workspace.target_branch!==r||t.workspace.finish!==null&&t.workspace.finish!=="merge"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:`Native child ${t.name} must use a linked worktree targeting parent branch ${r??"(missing)"}`}:t.status==="blocked"||t.status==="await-user"?{kind:"blocked",phase:t.phase,projectRoot:e.projectRoot,message:t.blockers[0]?.reason.text??`Native child ${t.name} requires user resolution`}:{kind:"active",phase:t.phase,projectRoot:e.projectRoot,message:null}}function Gh(t,e){return t.status==="done"&&t.archived&&t.workspace.finish==="merge"&&t.workspace.target_branch===e}async function Gr(t){let e=De.join(t.paths.changesDir,t.state.name),r=await zl(e),i=null,n;try{n=await dt({changeDir:e,validation:Dt(t.state),...t.state.acceptance.length>0?{acceptanceIds:t.state.acceptance.map(({id:v})=>v)}:{},policy:"advisory"})}catch(v){i=`Children contract cannot be read; restore children.yaml and confirm Shape: ${v.message}`,n=null}if(!n){let v=await He(t.paths,t.state.name,{diagnostics:!0});if(v){let N=Co(v);return{...N,...r?{coordinationChoiceRequired:!0}:{},confirmed:!1,readyChildren:[],allDone:!1,children:N.children.map(b=>({...b,message:i??"Children contract is missing; restore children.yaml and confirm Shape before continuing"}))}}if(i)throw new Error(i);return t.state.children_contract_hash?{...r?{coordinationChoiceRequired:!0}:{},contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:r?{coordinationChoiceRequired:!0,contractHash:null,confirmed:!1,parentBranch:t.state.workspace.change_branch,children:[],readyChildren:[],allDone:!1}:null}let a=Gl({acceptance:t.state.acceptance,children:n.contract}),o=t.state.workspace.change_branch,s=t.state.phase!=="shape"&&t.state.children_contract_hash===a&&!n.drift;if(n.contract.schema===Ht){let v=await He(t.paths,t.state.name,{diagnostics:!0});if(!v){let y=t.state.workspace.change_branch??t.state.workspace.target_branch;if(y){let E=await Io({paths:t.paths,parent:t.state.name,targetBranch:y,contract:n.contract});E&&(v=E,await Bt(t.paths,E))}}if(v){let y=Co(v);return t.state.children_contract_hash!==a||n.drift?{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:!1,readyChildren:[],allDone:!1,children:y.children.map(E=>({...E,message:n.drift?"Children acceptance index is stale; Shape confirmation is required":"Supervisor child plan changed; Shape confirmation is required"}))}:{...y,schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s&&y.confirmed}}let N=new Map(n.contract.children.map(y=>[y.name,y])),b=n.contract.children.map(y=>({name:y.name,summary:y.summary,dependsOn:[...y.depends_on],covers:[],status:s&&y.depends_on.every(E=>n.contract.children.filter(({name:w})=>w!==y.name).every(({name:w})=>w!==E))?"ready":"pending",phase:null,projectRoot:null,message:s?null:"Parent Shape confirmation is required"}));for(let y of b){if(y.status!=="ready")continue;N.get(y.name).depends_on.length>0&&(y.status="pending")}return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:b,readyChildren:b.filter(({status:y})=>y==="ready").map(({name:y})=>y),allDone:!1}}let c=await fx(t.paths),l=new Set(n.contract.children.map(({name:v})=>v)),d=new Map,u=new Map;for(let v of c){let N=v.parent&&o?`refs/heads/${o}`:"HEAD";for(let b of await mx(v,l)){let y={...b,source:v,committedState:vx(v,b.file,N)};d.set(b.state.name,[...d.get(b.state.name)??[],y])}for(let b of l){let y=await hx(v,b);y&&u.set(b,[...u.get(b)??[],{source:v,state:y}])}}let p=new Map;for(let v of n.contract.children){let N=(d.get(v.name)??[]).find(({source:E,committedState:w})=>E.parent&&w?.name===v.name&&Gh(w,o));if(N){p.set(v.name,{kind:"done",phase:N.state.phase,projectRoot:N.source.projectRoot,message:null});continue}let b=d.get(v.name)?.[0];if(b){p.set(v.name,{kind:"blocked",phase:b.state.phase,projectRoot:b.source.projectRoot,message:`Native child ${v.name} is archived but not merged into parent branch ${o??"(missing)"}`});continue}let y=u.get(v.name)??[];y.length>1?p.set(v.name,{kind:"blocked",phase:null,projectRoot:null,message:`Native child ${v.name} has multiple active workspace owners`}):y[0]&&p.set(v.name,gx(y[0].state,y[0].source,o))}let f=new Map(n.contract.children.map(v=>[v.name,v])),m=new Map,h=v=>{let N=m.get(v);if(N)return N;let b=f.get(v),E=b.depends_on.map(h).every(({status:xe})=>xe==="done"),w=p.get(v),_=w?.kind==="active"&&E?b.depends_on.filter(xe=>!(d.get(xe)??[]).some(({source:q,committedState:ri})=>Wl(q.projectRoot,w.projectRoot)&&ri?.name===xe&&Gh(ri,o))):[],S,T=w?.message??null;w?.kind==="done"?(S=E?"done":"blocked",E||(T=`Native child ${v} was merged before its dependencies`)):w?.kind==="active"?(S=E&&_.length===0?"active":"blocked",E?_.length>0&&(T=`Native child ${v} does not include merged dependencies: ${_.join(", ")}`):T=`Native child ${v} started before its dependencies merged`):w?.kind==="blocked"?S="blocked":(S=s&&E?"ready":"pending",s||(T="Parent Shape confirmation is required"));let Q={name:v,summary:b.summary,dependsOn:[...b.depends_on],covers:[...b.covers],status:S,phase:w?.phase??null,projectRoot:w?.projectRoot??null,message:T};return m.set(v,Q),Q},g=n.contract.children.map(({name:v})=>h(v));return{schema:n.contract.schema,...r?{coordinationChoiceRequired:!0}:{},contractHash:a,confirmed:s,parentBranch:o,children:g,readyChildren:g.filter(({status:v})=>v==="ready").map(({name:v})=>v),allDone:g.every(({status:v})=>v==="done")}}import{promises as em}from"fs";import tm from"path";Zt();ue();Oe();I();var wx=["outcome","scope","nonGoals","acceptanceExamples"],zH=[...wx,"constraints","decisions","openQuestions","verificationExpectations"];var wn=class extends Error{constructor(r,i,n){super(r);this.findings=i;this.change=n;this.name="NativeDocumentConstraintError"}findings;change};ue();H();Oe();I();Ne();Li();Ft();K();H();Oe();Yi();K();I();Ne();Ft();F();F();To();ur();Oe();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:[]},Sx=he("comet-native-runtime:v3:scope-reopen"),CD=[{skillVersion:"3",skillHash:he("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:he("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:he("comet-native-runtime:v1")}];Oe();Oe();Xi();var Qh=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],aB=new Set(Qh),Px=new Set([...Qh,"minimum_runtime_version","revision"]),oB=new Set([...Px,"operation"]),_x=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),sB=new Set([..._x,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);Oe();K();Ne();Ft();I();ue();nn();F();var EB={maxAcceptanceCriteria:rh.maxCriteria};var Kl={maxSpecs:64};var rm=Kl.maxSpecs*4;async function Tx(t,e){let r=tm.join(oe(t,e),"specs"),i;try{i=await dn({root:t.nativeRoot,directory:r,label:"Native proposed specs directory"})}catch(s){if(s.code==="ENOENT")return[];throw s}let n=[],a=0,o=await em.opendir(r);try{for await(let s of o){if(a+=1,a>rm)throw new Error(`Native proposed specs directory exceeds ${rm} entries`);if(s.isSymbolicLink())throw new Error(`Proposed spec capability must not be a symbolic link: ${s.name}`);if(!s.isDirectory())continue;nr(s.name);let c=tm.join(r,s.name,"spec.md");await M(t.nativeRoot,c);let l;try{l=await em.lstat(c)}catch(d){if(d.code==="ENOENT")continue;throw d}if(l.isSymbolicLink()||!l.isFile())throw new Error(`Proposed spec must be a regular file: ${s.name}`);if(n.push(s.name),n.length>Kl.maxSpecs)throw new Error("Native proposed specs exceed the spec-count budget")}}finally{await o.close().catch(s=>{if(s.code!=="ERR_DIR_CLOSED")throw s})}return await i.verify(),n.sort()}async function nm(t,e){let r=oe(t,e),i={};for(let n of await Tx(t,e)){let a=await L({root:r,ref:`specs/${n}/spec.md`,maxBytes:null});i[n]=a.text}return i}on();cr();function Y(t,e,r){return t.language==="zh-CN"?r:e}function jx(t,e,r,i){let n=a=>({required:!1,message:null,suggestedReply:null,agentInstruction:a});if(t.phase==="shape"&&t.status==="await-user"&&t.loop.next_action==="confirm-shape")return e?{required:!0,message:Y(t,"Shape is ready. Confirm the complete plan and choose A) Multi-session coordination (recommended), or B) Single-session progression in one reply.","Shape 已整理完成。请确认完整方案,并在同一次回复中选择 A)多会话协作(推荐),或 B)单会话推进。"),suggestedReply:Y(t,"Confirm the plan and use A","确认方案,按 A 开始"),agentInstruction:Y(t,"First present the target, scope, key decisions, acceptance criteria, non-goals, child responsibilities and dependencies, and both coordination choices. Execute the matching confirm-shape alternative only when the user explicitly accepts this complete Shape and chooses its mode. Choosing a mode alone, additions, or corrections are not full confirmation; retain that choice and ask only for the missing decision. Do not run --confirmed before full confirmation.","先展示目标、范围、关键决定、验收标准、非目标、各 Child 的职责与依赖,以及两种推进方式。只有用户明确同意当前完整 Shape 并选择推进方式后,才执行对应的 confirm-shape 选项。仅选择推进方式、补充或修改要求都不算完整确认;保留已选方式,只补问缺少的决定。完整确认前不要运行 --confirmed。")}:t.language==="zh-CN"?{required:!0,message:"Shape 已整理完成。请确认目标、范围、关键决定、验收标准和非目标是否准确;明确确认后才会进入 Build。",suggestedReply:"确认进入 Build",agentInstruction:"先用自然语言简要展示目标、范围、关键决定、验收标准和非目标,再转述 message 并等待用户明确确认。只有用户明确同意当前完整 Shape 时,才执行 commandAlternatives 中的 confirm-shape;补充或修改要求不算确认。不要展示机器状态或提前运行 --confirmed。"}:{required:!0,message:"Shape is ready. Confirm that the target, scope, key decisions, acceptance criteria, and non-goals are accurate; Build starts only after explicit confirmation.",suggestedReply:"Confirm and enter Build",agentInstruction:"First present a concise natural-language summary of the target, scope, key decisions, acceptance criteria, and non-goals. Then relay message and wait for explicit user confirmation. Run confirm-shape from commandAlternatives only when the user explicitly accepts the complete current Shape; additions or corrections are not confirmation. Do not expose machine state or run --confirmed early."};if(e&&t.phase==="shape"&&t.status==="active")return n(Y(t,"Complete the Shape documents and child plan, resolve blocking questions, then execute prepare-shape-confirmation. Its persisted response combines complete Shape confirmation and coordination choice in one user decision. If the user already chose only a mode, include that --coordination-mode when preparing and ask only for complete Shape confirmation afterward.","完成 Shape 文档和 Child 计划,解决阻塞问题后执行 prepare-shape-confirmation。持久化后的响应会让用户一次确认完整 Shape 并选择推进方式。如果用户已经仅选择了推进方式,准备时附上对应的 --coordination-mode,随后只确认完整 Shape。"));if(t.phase==="verify"&&t.status==="active"&&t.loop.stage==="verify-ready"&&t.loop.next_action!=="await-verifier-result")return n(Y(t,"The current candidate and completed checks are preserved. Continue with dispatch-verifier without asking the user to recover files, processes, or workflow state. If a brief status update is necessary, say only that verification is being retried and the code is unchanged.","当前候选和已经完成的检查都已保留。直接继续 dispatch-verifier,不要让用户恢复文件、进程或工作流状态。如果确实需要简短同步进度,只说明正在重新尝试验收且代码没有变化。"));if(t.phase==="verify"&&t.status==="active"&&t.loop.next_action==="await-verifier-result"){let a=i==="confirmed"?Y(t,"The Verifier has confirmed startup. Continue waiting on the same host task and use its actual progress.","Verifier 已确认启动。继续等待同一个宿主任务,并使用该任务的实际进度。"):Y(t,"Check whether the host accepted the startup call and locate the task for the current verifierExecutionRef. If the call has not been made, start the dispatched task once; if the host accepted it, check that same task and let the Verifier submit its startup receipt. A missing receipt alone does not prove failure. If local startup state is unavailable, recover the host task context before deciding whether startup is needed.","先核实宿主是否接受了启动调用,并找到当前 verifierExecutionRef 对应的任务。尚未调用时启动已派发的任务一次;宿主已接受时检查同一个任务,由 Verifier 提交启动回执。仅缺少回执不能证明执行失败。本地启动记录不可用时,先恢复宿主任务上下文,再判断是否需要启动。");return n(`${a} ${Y(t,"Keep the same dispatched Verifier while it is active. A wait-tool timeout is not an execution timeout: check task progress and continue waiting; do not cancel, interrupt, or spawn a replacement just because a wait returned without a result. Request progress without telling the Verifier to stop inspecting. Only after confirmed task failure, a host-reported execution timeout, loss, or termination without a usable result, immediately submit verifier-execution-error. Preserve completed evidence and explain the failure and changed recovery approach before retrying. Submit verifier-unavailable only when the current platform truly has no usable subagent capability. Forward the actual report, including risks and incomplete checks; never turn an uninspected candidate into pass. Do not ask the user to recover files or processes, and do not expose attempt or requestCheckRounds.","已派发的验收任务仍在运行时,继续使用同一个 Verifier。等待工具超时不等于执行超时:检查任务进度并继续等待,不得仅因一次等待没有结果就取消、中断或重新派发。询问进度时不要要求停止核查。仅在确认任务失败、宿主报告执行超时、任务丢失或结束后没有可用结果时,立即提交 verifier-execution-error;保留已完成证据,重试前说明失败原因及恢复方式的变化。只有当前平台确实没有可用的 subagent 能力时才提交 verifier-unavailable。忠实传递原始报告,包括风险和未完成检查;没有核查当前候选不能判定通过。不要让用户恢复文件或进程,也不要向用户展示 attempt、requestCheckRounds 等机器状态。")}`)}if(t.status==="blocked"&&t.blockers.some(({resolution_action:a})=>a==="retry-verifier"))return t.loop.retry_epoch>=3?t.language==="zh-CN"?{required:!0,message:"自动重试验收已连续多轮未能取得结果,验证环境很可能不可用。请人工检查验证环境(subagent 配额、平台任务队列、网络),或使用 doctor --repair 评估该 change 状态。",suggestedReply:"人工检查验证环境",agentInstruction:"只向用户转述 message,等待用户完成人工检查后再继续。不要自动重试验收。"}:{required:!0,message:"Automatic verification retries have failed across multiple rounds; the verification environment is likely unavailable. Inspect the environment manually (subagent quota, platform task queue, network), or use doctor --repair to assess the change state.",suggestedReply:"Inspect the verification environment",agentInstruction:"Relay message to the user and wait for a manual environment check before continuing. Do not retry verification automatically."}:t.language==="zh-CN"?{required:!0,message:"由于独立验收任务连续几次没有正常返回结果,本次验收已暂停。你的代码和已经完成的检查都已安全保留。回复“继续”即可重新尝试,不需要处理文件或进程。",suggestedReply:"继续",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户回复。不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification paused because the independent verification task repeatedly ended without a result. Your code and completed checks are safely preserved. Reply “Continue” to retry; you do not need to manage files or processes.",suggestedReply:"Continue",agentInstruction:"Relay only message and suggestedReply to the user, then wait for that reply. Do not expose internal attempts, counters, paths, or recovery steps."};if(t.phase==="verify"&&t.status==="await-user"&&t.verification?.assurance==="semantic-verification-unavailable")return t.language==="zh-CN"?{required:!0,message:"独立验收当前不可用,但你的代码和已经完成的检查都已安全保留。你可以直接重新尝试独立验收,也可以明确接受只有自动检查的结果。",suggestedReply:"重新尝试独立验收",agentInstruction:"只向用户转述 message 和 suggestedReply,并等待用户选择。用户要求重试时执行 commandAlternatives 中的 retry-verifier;只有用户明确接受降级结果时才执行 confirm-verifier-unavailable。不要把“继续”视为接受降级结果,也不要要求用户处理文件、进程、服务或回调。"}:{required:!0,message:"Independent verification is currently unavailable, but your code and completed checks are safely preserved. You can retry independent verification directly or explicitly accept the automatic-check-only result.",suggestedReply:"Retry independent verification",agentInstruction:"Relay only message and suggestedReply, then wait for the user choice. If the user asks to retry, run retry-verifier from commandAlternatives; run confirm-verifier-unavailable only when the user explicitly accepts the degraded result. Do not treat “Continue” as accepting the degraded result, and do not ask the user to manage files, processes, services, or callbacks."};if(t.phase==="verify"&&t.status==="await-user"&&t.loop.next_action==="resolve-verifier-blocker")return t.language==="zh-CN"?{required:!0,message:"验证暂时无法下结论,因为缺少只有你能提供的信息,例如外部系统的真实行为或某个业务决定。你的代码和已经完成的检查都已安全保留。补充所需信息后可继续验证,也可以选择修改实现或调整需求。",suggestedReply:null,agentInstruction:"向用户转述 message,请用户补充缺失的信息,或在继续验证(resolve-verifier-blocker)、修改实现、调整需求之间明确选择,再执行 commandAlternatives 中对应的完整命令。不要把“继续”当作默认选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:"Verification cannot reach a verdict yet because information only you can provide is missing, such as the real behavior of an external system or a business decision. Your code and completed checks are safely preserved. Supply the missing information to resume verification, or choose to revise the implementation or the requirements.",suggestedReply:null,agentInstruction:"Relay message and ask the user to supply the missing information or explicitly choose between resuming verification (resolve-verifier-blocker), revising the implementation, and revising the requirements; run the matching commandAlternative afterwards. Do not treat “Continue” as a default choice, and do not expose internal rounds, counters, paths, or recovery steps."};if(t.phase==="verify"&&t.status==="await-user"&&t.loop.next_action==="await-user"){let o=(t.loop.stop_reason??(t.loop.no_progress_count>=3?"stalled":"budget"))==="stalled",s=o?"验证已连续三轮失败且未通过的验收场景一直没有减少,本次修改已暂停,以避免在同一个问题上反复循环。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。":"本次修改的验证失败次数已用完配置的预算,因此暂停等待你的决定,而不是自动重试。你的代码和已经完成的检查都已安全保留。可以让 Builder 换一种修复思路继续,也可以回到需求阶段调整验收项。注意:预算不会重置,选择继续修复后,下一次验收失败会再次暂停。",c=o?"Verification has failed three times in a row without the unresolved scenarios shrinking, so this change is paused to avoid looping on the same problem. Your code and completed checks are safely preserved. You can have the Builder try a different repair approach, or go back and adjust the requirements.":"Verification for this change has used its configured failure budget, so it is paused for your decision instead of retrying automatically. Your code and completed checks are safely preserved. You can have the Builder continue with a different repair approach, or go back and adjust the requirements.";return t.language==="zh-CN"?{required:!0,message:s,suggestedReply:"继续修复",agentInstruction:"向用户转述 message 和 suggestedReply,等待用户在“继续修复实现”(revise-implementation)与“调整需求”(revise-requirements)之间明确选择,再执行 commandAlternatives 中对应的完整命令。选择继续修复时,要求 Builder 更换修复思路。不要替用户选择,也不要展示内部轮次、计数、路径或恢复步骤。"}:{required:!0,message:c,suggestedReply:"Continue repairing",agentInstruction:"Relay message and suggestedReply, then wait for the user to explicitly choose between continuing the implementation (revise-implementation) and adjusting the requirements (revise-requirements); run the matching commandAlternative afterwards. When continuing, ask the Builder to change its repair approach. Do not choose for the user, and do not expose internal rounds, counters, paths, or recovery steps."}}if(t.phase==="verify"&&t.status==="await-user"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass")return{required:!0,message:Y(t,"The reported verification passed, but this platform cannot confirm an independent Verifier execution. Review the result and choose whether to accept it for Archive, revise the implementation, or revise the requirements."+(t.workspace.isolation!=="current"&&t.workspace.finish===null?" If accepting, also choose: keep the workspace, merge locally, push the branch, or push and create a PR. You may accept the result and defer the finish choice.":""),"当前验收报告已通过,但当前平台无法确认验收是否独立执行。请检查结果,并选择接受结果进入归档、继续修改实现,或调整需求。"+(t.workspace.isolation!=="current"&&t.workspace.finish===null?" 接受时可一起选择:保留工作区、本地合并、推送分支,或推送并创建 PR;也可以先接受结果,稍后再选择收尾方式。":"")),suggestedReply:Y(t,"Accept the result","接受结果"),agentInstruction:Y(t,"Summarize the result and verification evidence, relay the message, and wait for an explicit user decision. Only then execute the matching commandAlternative. Do not accept the result on the user’s behalf.","简要说明交付结果和验收证据,转述 message,并等待用户明确选择后再执行对应的 commandAlternative。不要替用户接受结果。")};if(t.phase==="build"&&t.status==="active"){let a=r?.children.some(({status:l})=>l==="blocked")??!1,o=r?.children.some(({status:l})=>l==="needs-reverify")??!1,s=r?.children.some(({status:l})=>l==="ready"||l==="active")??!1,c=r?.children.some(({status:l,builderFailureCount:d})=>l==="blocked"&&(d??0)>=Eo)??!1;return a&&!o&&!s&&!c?t.language==="zh-CN"?{required:!0,message:"Supervisor 子任务暂时无法启动,已暂停自动重试以避免流程循环。请先根据子任务 blocker 修复工作区、分支或依赖;修复完成后重新运行最新的 next 继续流程。代码和已有证据已保留。",suggestedReply:"修复 blocker 后继续",agentInstruction:"向用户说明子任务 blocker 和需要先完成的外部修复;不要反复执行 next,也不要创建替代任务。用户确认工作区或依赖已修复后,再重新读取 status 并执行最新 continuation。"}:{required:!0,message:"Supervisor child dispatch is paused because every remaining child is blocked. Automatic retries are stopped to avoid a loop. Resolve the recorded child blocker (workspace, branch, or dependency) first, then read the latest status and continue; code and completed evidence are preserved.",suggestedReply:"Resolve the blocker and continue",agentInstruction:"Explain the child blocker and the required external repair to the user. Do not repeatedly run next or spawn replacement tasks. After the user confirms the workspace or dependency is fixed, read status again and execute the latest continuation."}:n(Y(t,"Implement the complete confirmed brief and Spec scope, then review every acceptance ID with its implementation and evidence before handoff. Fill acceptance_review from this audit; derive remaining work from it. Do not submit a partial candidate just to obtain verification feedback. Run focused checks; a separate pre-review is optional. If review is useful, retain the same Reviewer for focused repair follow-ups. Submit the completed candidate for one complete independent verification and release completed helper tasks.","完成已确认的 brief 和 Spec 全部范围,交接前逐项核对所有验收 ID 的实现和证据,填写 acceptance_review,并由这份自查生成剩余工作。不得提交未完成的候选来试探验收反馈。开发期运行相关检查,额外预审为可选项;确需审查时,保留同一个 Reviewer 复核修复及受影响范围。全部完成后提交一次完整独立验收,及时释放已完成的辅助任务。"))}return n(Y(t,"Follow the continuation action. Unless required is true, continue without asking the user to handle internal workflow state, and do not present machine fields as a user-facing explanation.","按 continuation 执行下一步。除非 required 为 true,否则继续推进,不要让用户处理内部工作流状态,也不要把机器字段作为面向用户的说明。"))}function $x(t){let e=t.workspace.change_branch??"<change-branch>",r=t.workspace.target_branch??"<target-branch>";return t.language==="zh-CN"?{required:!0,message:`当前 change 位于 ${e},目标分支为 ${r}。请选择一次工作区收尾方式:A) 保留工作区;B) 本地合并;C) 推送分支;D) 推送并创建 PR;E) 暂不归档。选择 A-D 后 Runtime 会完成预检,检查通过后按所选方式归档;选择 E 将保留当前 change 等待稍后继续。`,suggestedReply:"回复 A、B、C、D 或 E",agentInstruction:"向用户展示五种收尾方式及实际影响,等待用户选择。选择 A-D 时执行对应 commandAlternatives 的完整命令,Runtime 会在归档前检查状态和证据;选择 E 时停止,不运行 Archive 命令。按用户的明确选择执行 finish。"}:{required:!0,message:`This change is on ${e} and targets ${r}. Choose one workspace finish: A) keep the workspace; B) merge locally; C) push the branch; D) push and create a PR; or E) defer Archive. For A-D, Runtime will run preflight and archive with the selected finish when the checks pass; E keeps the current change for later.`,suggestedReply:"Reply A, B, C, D, or E",agentInstruction:"Show all five finish choices and their actual effects, then wait. For A-D, execute the matching complete commandAlternative; Runtime checks state and evidence before archiving. For E, stop without running an Archive command. Use the finish explicitly selected by the user."}}function Ox(t){return[...[{finish:"keep",name:"keep-workspace",description:["保留当前分支和目录;完成归档提交,不合并、不推送、不创建 PR。","Keep the current branch and directory; create the archive commit without merging, pushing, or creating a PR."]},{finish:"merge",name:"merge-locally",description:["完成归档提交,并把 change 分支本地合并到目标分支;不推送、不创建 PR。","Create the archive commit and merge the change branch locally into the target branch without pushing or creating a PR."]},{finish:"push",name:"push-branch",description:["完成归档提交并推送 change 分支;不合并到目标分支、不创建 PR。","Create the archive commit and push the change branch without merging into the target branch or creating a PR."]},{finish:"pull-request",name:"push-pull-request",description:["完成归档提交、推送 change 分支,并以目标分支为基础创建 PR。","Create the archive commit, push the change branch, and create a PR against the target branch."]}].map(({finish:i,name:n,description:a})=>({name:n,stateVersion:t.state_version,expectedAction:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed","--finish",i,"--expected-state-version",String(t.state_version)],requiredInputs:[],inputOptions:[],description:Y(t,a[1],a[0])})),{name:"defer-archive",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:null,requiredInputs:[],inputOptions:[],description:Y(t,"Keep the current change and workspace without archiving; stop and resume later.","保留当前 change 和工作区,不执行归档;停止本次流程,稍后再继续。")}]}function cm(t){return["comet","native","next",t.change,"--summary","<summary>",t.flag,"--expected-state-version",String(t.stateVersion),"--expected-action",t.action]}function pr(t,e){return{name:t,flag:e,valueKind:"text",required:!0,template:null}}function am(){return{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}}function Hx(t,e){return{name:t,flag:e,valueKind:"confirmation",required:!0,template:null}}function om(t,e,r){return{name:t,flag:e,valueKind:"choice",required:!0,template:null,choices:[...r]}}function Dx(t){return t?.coordinationChoiceRequired===!0||t?.schema==="comet.native.children.v2"&&t.children.length>=2}function Bx(t){return["comet","native","next",t.change,"--summary","<summary>","--expected-state-version",String(t.stateVersion),"--expected-action","prepare-shape-confirmation"]}function Qe(t){return{name:t.name,stateVersion:t.stateVersion,expectedAction:t.expectedAction,commandArgs:cm({change:t.change,stateVersion:t.stateVersion,action:t.expectedAction,flag:t.flag}),requiredInputs:["summary",t.confirmationInput],inputOptions:[pr("summary","--summary"),Hx(t.name,t.flag)]}}function sm(t,e){return e.some(i=>/^verification\.md is (?:missing|stale|invalid)$/u.test(i))?[{name:"repair-verification-report",stateVersion:t.state_version,expectedAction:"archive-preview",commandArgs:["comet","native","doctor",t.name,"--repair"],requiredInputs:[],inputOptions:[],description:Y(t,"Rebuild the Runtime-managed verification report, then rerun the Archive dry-run.","重建由 Runtime 管理的 verification.md,然后重新运行 Archive 预检。")}]:[]}function Lx(t){return/^verification\.md is (?:missing|stale|invalid)$/u.test(t)}function Oo(t){return[Qe({name:"revise-implementation",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-implementation",flag:"--revise-implementation",confirmationInput:"user-decision"}),Qe({name:"revise-requirements",change:t.change,stateVersion:t.stateVersion,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})]}function Fx(t){let e={"request-checks":"Choose when the Verifier needs additional Runtime checks.","final-result":"Choose when the Verifier has a result for every current scope ID.","verifier-execution-error":"Choose when a dispatched Verifier failed, was lost, or ended without a result.","verifier-unavailable":"Choose only when the platform has no usable independent Verifier capability."};return t.flatMap(r=>Array.isArray(r.template)?r.template.map(i=>{let n=i.response?.kind??i.kind;return{...r,name:n,required:!1,exclusiveGroup:"runner-input",description:e[n],template:i}}):[r])}function Jr(t,e,r={}){let i=Dx(e)&&t.coordination_mode===void 0,n=jx(t,i,e,r.verifierStartup),a={schema:"comet.native.continuation.v2",skill:"comet-native",change:t.name,phase:t.phase,status:t.status,stateVersion:t.state_version,inputOptions:[],requiresUserDecision:n.required,userCommunication:n},o=s=>({kind:s,candidateId:t.builder_handoff?.candidate_id??null,iteration:t.loop.iteration,attempt:t.loop.attempt});if(t.status==="done")return{...a,disposition:"done",action:"none",commandArgs:null,requiredInputs:[],runnerAction:o("none")};if(t.status==="await-user")return t.phase==="shape"&&t.loop.next_action==="confirm-shape"?{...a,disposition:"await-user",action:"confirm-shape",commandArgs:null,requiredInputs:["summary","shared-understanding-confirmation",...i?["coordination-choice"]:[]],inputOptions:[pr("summary","--summary")],commandAlternatives:i?ih.map(s=>{let c=Qe({name:`confirm-shape-${s}`,change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"});return{...c,commandArgs:[...c.commandArgs,"--coordination-mode",s],requiredInputs:[...c.requiredInputs,"coordination-choice"],inputOptions:[...c.inputOptions,om("coordination-mode","--coordination-mode",[s])]}}):[Qe({name:"confirm-shape",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-shape",flag:"--confirmed",confirmationInput:"shared-understanding-confirmation"})],runnerAction:o("none")}:t.phase==="verify"&&t.verification_result==="pass"&&t.loop.next_action==="confirm-skill-coordinated-pass"?{...a,disposition:"await-user",action:"confirm-skill-coordinated-pass",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[...t.workspace.isolation!=="current"&&t.workspace.finish===null?["keep","merge","push","pull-request"].map(s=>{let c=Qe({name:`accept-result-${s}`,change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"});return{...c,commandArgs:[...c.commandArgs,"--finish",s]}}):[],Qe({name:"accept-result",change:t.name,stateVersion:t.state_version,expectedAction:"accept-result",flag:"--accept-result",confirmationInput:"user-decision"}),...Oo({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.verification?.assurance==="semantic-verification-unavailable"&&t.loop.next_action==="confirm-verifier-unavailable"?{...a,disposition:"await-user",action:"confirm-verifier-unavailable",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[Qe({name:"retry-verifier",change:t.name,stateVersion:t.state_version,expectedAction:"retry-verifier",flag:"--retry-verifier",confirmationInput:"user-decision"}),Qe({name:"confirm-verifier-unavailable",change:t.name,stateVersion:t.state_version,expectedAction:"confirm-verifier-unavailable",flag:"--confirmed",confirmationInput:"user-decision"})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="resolve-verifier-blocker"?{...a,disposition:"await-user",action:"resolve-verifier-blocker",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:[Qe({name:"resolve-verifier-blocker",change:t.name,stateVersion:t.state_version,expectedAction:"resolve-verifier-blocker",flag:"--resolve-verifier-blocker",confirmationInput:"user-resolution"}),...Oo({change:t.name,stateVersion:t.state_version})],runnerAction:o("none")}:t.phase==="verify"&&t.loop.next_action==="await-user"?{...a,disposition:"await-user",action:"resolve-loop-stop",commandArgs:null,requiredInputs:["summary","user-decision"],inputOptions:[pr("summary","--summary")],commandAlternatives:Oo({change:t.name,stateVersion:t.state_version}),runnerAction:o("none")}:{...a,disposition:"await-user",action:"none",commandArgs:null,commandAlternatives:Oo({change:t.name,stateVersion:t.state_version}),userCommunication:{...a.userCommunication,required:!0,message:t.blockers.length>0?t.blockers.map(({reason:s})=>s).join("; "):a.userCommunication.message,suggestedReply:t.blockers.length>0?t.blockers[0]?.resolution_action??null:a.userCommunication.suggestedReply},requiredInputs:["resolve-blocker"],runnerAction:o("none")};if(t.status==="blocked"){let s=t.blockers.some(({resolution_action:c})=>c==="retry-verifier");return{...a,disposition:"blocked",action:s?"retry-verifier":"none",commandArgs:s?cm({change:t.name,stateVersion:t.state_version,action:"retry-verifier",flag:"--retry-verifier"}):null,requiredInputs:s?["summary"]:["repair-runtime"],inputOptions:s?[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}]:[],runnerAction:o(s?"retry-verifier":"none")}}if(t.phase==="shape")return{...a,disposition:"continue",action:"prepare-shape-confirmation",commandArgs:Bx({change:t.name,stateVersion:t.state_version}),requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.phase==="build"){if(e){if(!e.confirmed)return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["summary"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(t.loop.stage==="repairing"&&t.verification_result==="fail")return{...a,disposition:"continue",action:"repair",commandArgs:["comet","native","next",t.name,"--summary","<summary>"],requiredInputs:["repair-child"],inputOptions:[{name:"summary",flag:"--summary",valueKind:"text",required:!0,template:null}],runnerAction:o("none")};if(e.allDone)return{...a,disposition:"continue",action:"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:t.acceptance.map(({id:m})=>m),acceptance_review:t.acceptance.map(({id:m})=>({id:m,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"})),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[am()],known_limits:[]}}],runnerAction:o("builder-handoff")};let s=e.children.find(({status:m})=>m==="verified");if(s){let m=r.supervisorIntegrationRetryIds;return{...a,disposition:"continue",action:"advance-children",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["supervisor-integration-checks"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-integrate",child:s.name,checks:[{id:"<check-id>",name:"<check-name>",executable:"<executable>",argv:[],cwdRef:".",timeoutMs:12e4,repeatable:!0}],...m&&m.length>0?{retry_check_ids:[...m]}:{}}}],runnerAction:o("none")}}let c=e.children.some(({status:m})=>m==="blocked"||m==="needs-reverify"),l=e.children.some(({status:m})=>m==="needs-reverify"),d=e.children.some(({status:m})=>m==="ready"||m==="active"),u=e.supervisorStateVersion===void 0?null:e.children.find(m=>m.status==="blocked"&&(m.builderFailureCount??0)>=Eo)??null,p=u===null?null:{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"supervisor-retry-builder",child:u.name,stateVersion:e.supervisorStateVersion},description:Y(t,"Explicitly authorize one fresh Builder attempt after the Builder failure budget was exhausted.","Builder 失败预算已耗尽;明确授权后才能重新开始一次 Builder 尝试。")},f=c&&!l&&!d&&p===null;return{...a,disposition:f?"blocked":"continue",action:"advance-children",commandArgs:f?null:p!==null?["comet","native","next",t.name,"--runner-input","<temporary-json-file>"]:["comet","native","next",t.name,"--summary","<summary>",...t.coordination_mode==="single-session"?["--max-parallel","1"]:[]],requiredInputs:f?[]:p!==null?["supervisor-builder-retry-json-file"]:["ready-children"],inputOptions:f?[]:p!==null?[p]:[pr("summary","--summary")],runnerAction:o("none")}}return{...a,disposition:"continue",action:t.loop.stage==="repairing"?"repair":"builder-handoff",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["builder-handoff-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"builder-handoff",summary:"<summary>",addressed_acceptance_ids:t.acceptance.map(({id:s})=>s),acceptance_review:t.acceptance.map(({id:s})=>{let c=t.builder_handoff?.acceptance_review?.find(l=>l.id===s);return c?{...c,evidence:[...c.evidence],...t.loop.previous_unresolved_ids.includes(s)?{status:"implemented-no-evidence",evidence:[],note:"<current repair and evidence summary>"}:{}}:{id:s,status:"not-implemented",evidence:[],note:"<implementation and evidence summary>"}}),checks:[{name:"<check-name>",result:"not-run",note:null}],verification_checks:[],known_limits:[]}}],runnerAction:o("builder-handoff")}}if(t.phase==="verify"){let s=t.loop.next_action==="await-verifier-result",c=!!t.children_contract_hash,l=am();return!s&&r.retryCheckIds&&r.retryCheckIds.length>0?{...a,disposition:"continue",action:"retry-checks",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:["retry-checks-json-file"],inputOptions:[{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:{kind:"retry-checks",check_ids:[...r.retryCheckIds]}}],runnerAction:o("retry-checks")}:{...a,userCommunication:!s&&c?{...a.userCommunication,agentInstruction:`${a.userCommunication.agentInstruction} ${Y(t,"Resolve at least one integration check for the Supervisor parent; cwdRef is relative to the integration worktree.","为 Supervisor 父级解析至少一项集成检查;cwdRef 相对于集成工作区。")}`}:a.userCommunication,disposition:"continue",action:s?"await-verifier":"dispatch-verifier",commandArgs:["comet","native","next",t.name,"--runner-input","<temporary-json-file>"],requiredInputs:[s?"verifier-response-or-error-json-file":"resolved-check-plan-json-file"],inputOptions:Fx([{name:"runner-input",flag:"--runner-input",valueKind:"json-file",required:!0,template:s?[{kind:"verifier-response",candidateId:t.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"request-checks",iteration:t.loop.iteration,attempt:t.loop.attempt,checks:[l]}},{kind:"verifier-response",candidateId:t.builder_handoff?.candidate_id??"<candidate-id>",verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>",response:{kind:"final-result",result:{iteration:t.loop.iteration,attempt:t.loop.attempt,verdict:"blocked",acceptance:[{id:"<acceptance-id>",result:"blocked",reason:"<reason>"}],risks:[],summary:"<summary>"}}},{kind:"verifier-execution-error",summary:"<summary>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"},{kind:"verifier-unavailable",summary:"<why no independent semantic execution is available>",stateVersion:t.state_version,iteration:t.loop.iteration,attempt:t.loop.attempt,verifierExecutionRef:r.verifierExecutionRef??"<from verifierDispatch>"}]:{kind:"dispatch-verifier",checks:r.verificationCheckPlans?r.verificationCheckPlans.map(d=>({...d,argv:[...d.argv]})):c?[l]:[]}}]),runnerAction:o(s?"await-verifier":"dispatch-verifier")}}if(t.phase==="archive"&&t.status==="active"&&t.loop.stage==="archive-ready"&&!t.archived){let s=r.archiveMode??"archive-ready",l=t.workspace.isolation!=="current"&&t.workspace.finish===null;if(s==="blocked")return{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],runnerAction:o("none")};if(s==="preview"){if(r.archiveBlockers&&r.archiveBlockers.length>0){let d=sm(t,r.archiveBlockers)[0];return d&&r.archiveBlockers.every(u=>Lx(u))?{...a,disposition:"continue",action:"repair",commandArgs:d.commandArgs,requiredInputs:[],inputOptions:[],runnerAction:o("none")}:{...a,disposition:"blocked",action:"archive",commandArgs:null,requiredInputs:["archive-blocker-resolution"],inputOptions:[],commandAlternatives:sm(t,r.archiveBlockers),runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}return l?{...a,disposition:"await-user",action:"archive",commandArgs:null,requiredInputs:["workspace-finish"],inputOptions:[om("finish","--finish",["keep","merge","push","pull-request"])],commandAlternatives:[...Ox(t)],userCommunication:$x(t),runnerAction:o("none")}:{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--dry-run"],requiredInputs:[],commandAlternatives:[Qe({name:"revise-requirements",change:t.name,stateVersion:t.state_version,expectedAction:"revise-requirements",flag:"--revise-requirements",confirmationInput:"user-decision"})],runnerAction:o("none")}}return{...a,disposition:"continue",action:"archive",commandArgs:["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],runnerAction:o("none")}}Se();Za();F();import ei from"node:path";Se();ot();H();var ZB=8*1024*1024;Po();ro();Te();or();mn();So();import{promises as Mx}from"node:fs";H();on();import lm from"node:path";function yn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function Nn(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 se(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 Ur(t,e){return t===null?null:se(t,e)}function Kr(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 Vx(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 Wx(t,e){if(typeof t!="boolean")throw new Error(`${e} must be a boolean`);return t}function Yr(t,e,r){if(typeof t!="string"||!e.includes(t))throw new Error(`${r} must be one of: ${e.join(", ")}`);return t}function Xl(t,e){if(t===null)return null;let r=se(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function zx(t,e){let r=se(t,e);if(Number.isNaN(Date.parse(r)))throw new Error(`${e} must be an ISO timestamp`);return r}function Ql(t,e){let r=se(t,e);if(!lm.isAbsolute(r))throw new Error(`${e} must be absolute`);return lm.resolve(r)}function Gx(t,e){let r=`Native local checks[${e}]`,i=yn(t,r);if(Nn(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((d,u)=>se(d,`${r}.argv[${u}]`,!0)),a=Yr(i.status,["planned","running","passed","failed","interrupted"],`${r}.status`),o=Xl(i.startedAt,`${r}.startedAt`),s=Xl(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=Kr(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 d=yn(i.activeProcess,`${r}.activeProcess`),u=Yr(d.status,["starting","running"],`${r}.activeProcess.status`);if(Nn(d,new Set(["status","pid","identity"]),`${r}.activeProcess`),u==="starting"){if(Object.hasOwn(d,"pid")||Object.hasOwn(d,"identity"))throw new Error(`${r}.activeProcess starting state cannot contain process identity`);l={status:"starting"}}else l={status:"running",pid:Kr(d.pid,`${r}.activeProcess.pid`,1),...Object.hasOwn(d,"identity")?{identity:se(d.identity,`${r}.activeProcess.identity`)}:{}}}return{id:se(i.id,`${r}.id`),name:se(i.name,`${r}.name`),operationId:se(i.operationId,`${r}.operationId`),status:a,repeatable:Wx(i.repeatable,`${r}.repeatable`),timeoutMs:c,executionCount:Kr(i.executionCount,`${r}.executionCount`),argv:n,cwd:Ql(i.cwd,`${r}.cwd`),exitCode:Vx(i.exitCode,`${r}.exitCode`),startedAt:o,completedAt:s,log:se(i.log,`${r}.log`),...Object.hasOwn(i,"activeProcess")?{activeProcess:l}:{},...Object.hasOwn(i,"evidence")?{evidence:Yr(i.evidence,["runtime"],`${r}.evidence`)}:{},...Object.hasOwn(i,"evidenceDigest")?{evidenceDigest:se(i.evidenceDigest,`${r}.evidenceDigest`)}:{}}}function Jx(t){let e="Native local execution state",r=yn(t,e);if(Nn(r,new Set(["schema","change","basedOnStateVersion","candidateId","inputFingerprint","inputFingerprintGate","candidateInputFingerprintGate","workspace","execution","checks"]),e),r.schema!==io)throw new Error(`Native local execution schema must be ${io}`);let i=yn(r.workspace,"Native local workspace");Nn(i,new Set(["projectRoot","worktreeRoot","branch","machineId"]),"Native local workspace");let n=null;if(r.execution!==null){let o=yn(r.execution,"Native local execution");Nn(o,new Set(["operationId","stage","actor","executionId","status","startedAt","requestCheckRounds","verifierStartedAt","ownerPid","ownerIdentity"]),"Native local execution");let s=Xl(o.startedAt,"Native local execution.startedAt");if(s===null)throw new Error("Native local execution.startedAt is required");n={operationId:se(o.operationId,"Native local execution.operationId"),stage:Yr(o.stage,["building","checking","verifying","archiving"],"Native local execution.stage"),actor:o.actor===null?null:Yr(o.actor,["builder","runtime","verifier"],"Native local execution.actor"),executionId:Ur(o.executionId,"Native local execution.executionId"),status:Yr(o.status,["running","completed","interrupted"],"Native local execution.status"),startedAt:s,requestCheckRounds:Kr(o.requestCheckRounds,"Native local execution.requestCheckRounds"),...Object.hasOwn(o,"verifierStartedAt")?{verifierStartedAt:zx(o.verifierStartedAt,"Native local execution.verifierStartedAt")}:{},...Object.hasOwn(o,"ownerPid")?{ownerPid:Kr(o.ownerPid,"Native local execution.ownerPid",1)}:{},...Object.hasOwn(o,"ownerIdentity")?{ownerIdentity:se(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(Gx);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:io,change:se(r.change,"Native local change"),basedOnStateVersion:Kr(r.basedOnStateVersion,"Native local basedOnStateVersion",1),...Object.hasOwn(r,"candidateId")?{candidateId:Ur(r.candidateId,"Native local candidateId")}:{},...Object.hasOwn(r,"inputFingerprint")?{inputFingerprint:Ur(r.inputFingerprint,"Native local inputFingerprint")}:{},...Object.hasOwn(r,"inputFingerprintGate")?{inputFingerprintGate:Ur(r.inputFingerprintGate,"Native local inputFingerprintGate")}:{},...Object.hasOwn(r,"candidateInputFingerprintGate")?{candidateInputFingerprintGate:Ur(r.candidateInputFingerprintGate,"Native local candidateInputFingerprintGate")}:{},workspace:{projectRoot:Ql(i.projectRoot,"Native local workspace.projectRoot"),worktreeRoot:Ql(i.worktreeRoot,"Native local workspace.worktreeRoot"),branch:Ur(i.branch,"Native local workspace.branch"),...Object.hasOwn(i,"machineId")?{machineId:se(i.machineId,"Native local workspace.machineId")}:{}},execution:n,checks:a}}async function Ho(t){let e;try{e=await Mx.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 Jx(r)}function Zl(t,e){let r=e?.execution;if(!(t.phase!=="verify"||t.status!=="active"||t.loop.next_action!=="await-verifier-result"||t.builder_handoff?.candidate_id===void 0||t.builder_handoff?.candidate_id===null||e===null||e.change!==t.name||e.basedOnStateVersion!==t.state_version||e.candidateId!==t.builder_handoff.candidate_id||r==null||r.stage!=="verifying"||r.actor!=="verifier"||r.status!=="running"||r.executionId===null))return r.executionId}K();or();I();import{promises as Ux}from"node:fs";import eu from"node:path";Se();Te();I();var um=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,dm="comet-state.yaml",pm="state.json";function ft(t,e){if(!um.test(e))throw new Error(`Invalid Native change name: ${e}`);let r=eu.join(t.changesDir,e);if(!J(t.changesDir,r))throw new Error("Native change path escaped");return r}function Do(t,e){return eu.join(ft(t,e),dm)}function qt(t,e){return eu.join(Ue(t,e),pm)}async function Xr(t,e){try{let r=await Ux.readFile(Do(t,e),"utf8");return/^schema:\s*comet\.native\.v4\s*$/mu.test(r)}catch(r){if(r.code==="ENOENT")return!1;throw r}}async function Be(t,e){return $t(Do(t,e))}async function Bo(t){let e=await Be(t.paths,t.name),r=qt(t.paths,t.name);try{let i=await Ho(r);return i===null?{state:e,local:null,localStatus:"missing"}:i.change!==e.name||i.basedOnStateVersion!==e.state_version?{state:e,local:null,localStatus:"stale"}:{state:e,local:i,localStatus:"available"}}catch(i){return i.code==="ENOENT"?{state:e,local:null,localStatus:"missing"}:{state:e,local:null,localStatus:"invalid"}}}function nu(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mr=nu();function Nm(t){mr=t}var fr={exec:()=>null};function Qr(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(te.caret,"$1"),r=r.replace(n,o),i},getRegex:()=>new RegExp(r,e)};return i}var Kx=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),te={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:Qr(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Qr(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Qr(t=>new RegExp(`^ {0,${t}}>`))},Yx=/^(?:[ \t]*(?:\n|$))+/,Xx=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Qx=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zx=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,au=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,bm=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,km=P(bm).replace(/bull/g,au).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(),eC=P(bm).replace(/bull/g,au).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(),ou=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,tC=/^[^\n]+/,su=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,rC=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",su).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),iC=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,au).getRegex(),Vo="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",cu=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,nC=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",cu).replace("tag",Vo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sm=t=>P(ou).replace("hr",Sn).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",Vo).getRegex(),aC=Sm(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),oC=Sm(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),sC=P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",oC).getRegex(),lu={blockquote:sC,code:Xx,def:rC,fences:Qx,heading:Zx,hr:Sn,html:nC,lheading:km,list:iC,newline:Yx,paragraph:aC,table:fr,text:tC},fm=P("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Sn).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",Vo).getRegex(),cC={...lu,lheading:eC,table:fm,paragraph:P(ou).replace("hr",Sn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",fm).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",Vo).getRegex()},lC={...lu,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",cu).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:fr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(ou).replace("hr",Sn).replace("heading",` *#{1,6} *[^
171
+ ]`).replace("lheading",km).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},uC=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,dC=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Em=/^( {2,}|\\)\n(?!\s*$)/,pC=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ht=/[\p{P}\p{S}]/u,Zr=/[\s\p{P}\p{S}]/u,En=/[^\s\p{P}\p{S}]/u,fC=P(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Zr).getRegex(),hC=/[\p{Pi}\p{Ps}"']/u,xm=/(?!~)[\p{P}\p{S}]/u,mC=/(?!~)[\s\p{P}\p{S}]/u,vC=/(?:[^\s\p{P}\p{S}]|~)/u,gC=P(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Kx?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cm=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,wC=P(Cm,"u").replace(/punct/g,ht).getRegex(),yC=P(Cm,"u").replace(/punct/g,xm).getRegex(),NC=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,bC=P(NC,"u").replace(/openQuote/g,hC).replace(/punct/g,ht).getRegex(),Rm="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",kC=P(Rm,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),SC=P(Rm,"gu").replace(/notPunctSpace/g,vC).replace(/punctSpace/g,mC).replace(/punct/g,xm).getRegex(),EC="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",xC=P(EC,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),CC=P("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),RC="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",PC=P(RC,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),_C=P(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ht).getRegex(),AC="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",IC=P(AC,"gu").replace(/notPunctSpace/g,En).replace(/punctSpace/g,Zr).replace(/punct/g,ht).getRegex(),TC=P(/\\(punct)/,"gu").replace(/punct/g,ht).getRegex(),jC=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(),$C=P(cu).replace("(?:-->|$)","-->").getRegex(),OC=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",$C).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Fo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,HC=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Fo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Pm=P(/^!?\[(label)\]\[(ref)\]/).replace("label",Fo).replace("ref",su).getRegex(),_m=P(/^!?\[(ref)\](?:\[\])?/).replace("ref",su).getRegex(),DC=P("reflink|nolink(?!\\()","g").replace("reflink",Pm).replace("nolink",_m).getRegex(),hm=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,uu={_backpedal:fr,anyPunctuation:TC,autolink:jC,blockSkip:gC,br:Em,code:dC,del:fr,delLDelim:fr,delRDelim:fr,emStrongLDelim:wC,emStrongRDelimAst:kC,emStrongRDelimUnd:CC,escape:uC,link:HC,nolink:_m,punctuation:fC,reflink:Pm,reflinkSearch:DC,tag:OC,text:pC,url:fr},BC={...uu,emStrongLDelim:bC,emStrongRDelimAst:xC,emStrongRDelimUnd:PC,link:P(/^!?\[(label)\]\((.*?)\)/).replace("label",Fo).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Fo).getRegex()},tu={...uu,emStrongRDelimAst:SC,emStrongLDelim:yC,delLDelim:_C,delRDelim:IC,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",hm).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",hm).getRegex()},LC={...tu,br:P(Em).replace("{2,}","*").getRegex(),text:P(tu.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Lo={normal:lu,gfm:cC,pedantic:lC},bn={normal:uu,gfm:tu,breaks:LC,pedantic:BC},FC={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},mm=t=>FC[t];function Ze(t,e){if(e){if(te.escapeTest.test(t))return t.replace(te.escapeReplace,mm)}else if(te.escapeTestNoEncode.test(t))return t.replace(te.escapeReplaceNoEncode,mm);return t}function vm(t){try{t=encodeURI(t).replace(te.percentDecode,"%")}catch{return null}return t}function gm(t,e){let r=t.replace(te.findPipe,(a,o,s)=>{let c=!1,l=o;for(;--l>=0&&s[l]==="\\";)c=!c;return c?"|":" |"}),i=r.split(te.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(te.slashPipe,"|");return i}function Mt(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 wm(t){let e=t.split(`
172
+ `),r=e.length-1;for(;r>=0&&te.blankLine.test(e[r]);)r--;return e.length-r<=2?t:e.slice(0,r+1).join(`
173
+ `)}function qC(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 MC(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 ym(t,e,r,i,n){let a=e.href,o=e.title||null,s=t[1].replace(n.other.outputLinkReplace,"$1"),c=t[0].charAt(0)==="!";i.state.inLink=!0;let l=i.state.linkEmitted,d=i.state.inRawBlock;i.state.linkEmitted=!1;let u=i.inlineTokens(s),p=i.state.linkEmitted;if(i.state.linkEmitted=l,i.state.inLink=!1,!c){if(p){i.state.inRawBlock=d;return}i.state.linkEmitted=!0}return{type:c?"image":"link",raw:r,href:a,title:o,text:s,tokens:u}}function VC(t,e,r){let i=t.match(r.other.indentCodeCompensation);if(i===null)return e;let n=i[1];return e.split(`
174
+ `).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(`
175
+ `)}var qo=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]:wm(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=VC(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=Mt(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:Mt(e[0],`
176
+ `),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:Mt(e[0],`
177
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let r=Mt(e[0],`
178
+ `).split(`
179
+ `),i="",n="",a=[];for(;r.length>0;){let o=!1,s=[],c;for(c=0;c<r.length;c++)if(this.rules.other.blockquoteStart.test(r[c]))s.push(r[c]),o=!0;else if(!o)s.push(r[c]);else break;r=r.slice(c);let l=s.join(`
180
+ `),d=l.replace(this.rules.other.blockquoteSetextReplace,`
181
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
182
+ ${l}`:l,n=n?`${n}
183
+ ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,a,!0),this.lexer.state.top=u,r.length===0)break;let p=a.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let f=p,m=r.join(`
184
+ `),h=f.raw+`
185
+ `+m.replace(this.rules.other.blockquoteSetextReplace2,""),g=this.blockquote(h);a[a.length-1]=g,i=`${i}
186
+ ${m}`,n=n.substring(0,n.length-f.text.length)+g.text;break}else if(p?.type==="list"){let f=p,m=f.raw+`
187
+ `+r.join(`
188
+ `),h=this.list(m);a[a.length-1]=h,i=i.substring(0,i.length-p.raw.length)+h.raw,n=n.substring(0,n.length-f.raw.length)+h.raw,r=m.substring(a.at(-1).raw.length).split(`
189
+ `);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 c=!1,l="",d="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;l=e[0],t=t.substring(l.length);let u=MC(e[2].split(`
190
+ `,1)[0],e[1].length),p=t.split(`
191
+ `,1)[0],f=!u.trim(),m=0;if(this.options.pedantic?(m=2,d=u.trimStart()):f?m=e[1].length+1:(m=u.search(this.rules.other.nonSpaceChar),m=m>4?1:m,d=u.slice(m),m+=e[1].length),f&&this.rules.other.blankLine.test(p)&&(l+=p+`
192
+ `,t=t.substring(p.length+1),c=!0),!c){let h=this.rules.other.nextBulletRegex(m),g=this.rules.other.hrRegex(m),v=this.rules.other.fencesBeginRegex(m),N=this.rules.other.headingBeginRegex(m),b=this.rules.other.htmlBeginRegex(m),y=this.rules.other.blockquoteBeginRegex(m);for(;t;){let E=t.split(`
193
+ `,1)[0],w;if(p=E,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),w=p):w=p.replace(this.rules.other.tabCharGlobal," "),v.test(p)||N.test(p)||b.test(p)||y.test(p)||h.test(p)||g.test(p))break;if(w.search(this.rules.other.nonSpaceChar)>=m||!p.trim())d+=`
194
+ `+w.slice(m);else{if(f||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(u)||N.test(u)||g.test(u))break;d+=`
195
+ `+p}f=!p.trim(),l+=E+`
196
+ `,t=t.substring(E.length+1),u=w.slice(m)}}n.loose||(o?n.loose=!0:this.rules.other.doubleBlankLine.test(l)&&(o=!0)),n.items.push({type:"list_item",raw:l,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),n.raw+=l}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 c of n.items)if(this.lexer.state.top=!1,c.tokens=this.lexer.blockTokens(c.text,[]),!n.loose){let l=c.tokens.filter(u=>u.type==="space"),d=l.length>0&&l.some(u=>this.rules.other.anyLine.test(u.raw));n.loose=d}for(let c of n.items){let l=c.tokens[0];if(c.task&&(l?.type==="text"||l?.type==="paragraph")){c.text=c.text.replace(this.rules.other.listReplaceTask,""),l.raw=l.raw.replace(this.rules.other.listReplaceTask,""),l.text=l.text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}let d=this.rules.other.listTaskCheckbox.exec(c.raw);if(d){let u={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};c.checked=u.checked,n.loose?c.tokens[0]&&["paragraph","text"].includes(c.tokens[0].type)&&"tokens"in c.tokens[0]&&c.tokens[0].tokens?(c.tokens[0].raw=u.raw+c.tokens[0].raw,c.tokens[0].text=u.raw+c.tokens[0].text,c.tokens[0].tokens.unshift(u)):c.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):c.tokens.unshift(u)}}else c.task&&(c.task=!1)}if(n.loose)for(let c of n.items){c.loose=!0;for(let l of c.tokens)l.type==="text"&&(l.type="paragraph")}return n}}html(t){let e=this.rules.block.html.exec(t);if(e){let r=wm(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:Mt(e[0],`
197
+ `),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=gm(e[1]),i=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
198
+ `):[],a={type:"table",raw:Mt(e[0],`
199
+ `),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(gm(o,a.header.length).map((s,c)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:a.align[c]})));return a}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let r=e[1].trim();return{type:"heading",raw:Mt(e[0],`
200
+ `),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)===`
201
+ `?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=Mt(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=qC(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)),ym(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 ym(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,c=0,l=i[0][0],d=r===l,u=l==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+n);(i=u.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)){c+=o;continue}if(d)break}if(s-=o,s>0)continue;o=Math.min(o,o+s+c);let p=[...i[0]][0].length,f=t.slice(0,n+i.index+p+o);if(Math.min(n,o)%2){let h=f.slice(1,-1);return{type:"em",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}let m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}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,c=this.rules.inline.delRDelim;for(c.lastIndex=0,e=e.slice(-1*t.length+n);(i=c.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 l=[...i[0]][0].length,d=t.slice(0,n+i.index+l+o),u=d.slice(n,-n);return{type:"del",raw:d,text:u,tokens:this.lexer.inlineTokens(u)}}}}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}}}},Ee=class ru{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 qo,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:te,block:Lo.normal,inline:bn.normal};this.options.pedantic?(r.block=Lo.pedantic,r.inline=bn.pedantic):this.options.gfm&&(r.block=Lo.gfm,this.options.breaks?r.inline=bn.breaks:r.inline=bn.gfm),this.tokenizer.rules=r}static get rules(){return{block:Lo,inline:bn}}static lex(e,r){return new ru(r).lex(e)}static lexInline(e,r){return new ru(r).inlineTokens(e)}lex(e){e=e.replace(te.carriageReturn,`
202
+ `),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(te.tabCharGlobal," ").replace(te.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+=`
203
+ `: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(`
204
+ `)?"":`
205
+ `)+a.raw,s.text+=`
206
+ `+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(`
207
+ `)?"":`
208
+ `)+a.raw,s.text+=`
209
+ `+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,c=e.slice(1),l;this.options.extensions.startBlock.forEach(d=>{l=d.call({lexer:this},c),typeof l=="number"&&l>=0&&(s=Math.min(s,l))}),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(`
210
+ `)?"":`
211
+ `)+a.raw,s.text+=`
212
+ `+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(`
213
+ `)?"":`
214
+ `)+a.raw,s.text+=`
215
+ `+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,c=l=>{let d=l.lastIndexOf("[");if(!Object.hasOwn(this.tokens.links,l.slice(d+1,-1)))return l;if(d>1&&l.charAt(0)!=="!"){let u=l.slice(1,d-1);if(this.linkInText(u))return"["+u.replace(s,c)+"]["+"a".repeat(l.length-d-2)+"]"}return"["+"a".repeat(l.length-2)+"]"};i=i.replace(s,c)}i=i.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),i=i.replace(this.tokenizer.rules.inline.blockSkip,(s,c,l)=>{let d=l?l.length:0;return s.slice(0,d)+"["+"a".repeat(s.length-d-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(l=>(s=l.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 l=r.at(-1);s.type==="text"&&l?.type==="text"?(l.raw+=s.raw,l.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 c=e;if(this.options.extensions?.startInline){let l=1/0,d=e.slice(1),u;this.options.extensions.startInline.forEach(p=>{u=p.call({lexer:this},d),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(c=e.substring(0,l+1))}if(s=this.tokenizer.inlineText(c)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(a=s.raw.slice(-1)),n=!0;let l=r.at(-1);l?.type==="text"?(l.raw+=s.raw,l.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)}},Mo=class{options;parser;constructor(t){this.options=t||mr}space(t){return""}code({text:t,lang:e,escaped:r}){let i=(e||"").match(te.notSpaceStart)?.[0],n=t.replace(te.endingNewline,"")+`
216
+ `;return i?'<pre><code class="language-'+Ze(i)+'">'+(r?n:Ze(n,!0))+`</code></pre>
217
+ `:"<pre><code>"+(r?n:Ze(n,!0))+`</code></pre>
218
+ `}blockquote({tokens:t}){return`<blockquote>
219
+ ${this.parser.parse(t)}</blockquote>
220
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
221
+ `}hr(t){return`<hr>
222
+ `}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+`>
223
+ `+i+"</"+n+`>
224
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
225
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
226
+ `}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>
227
+ <thead>
228
+ `+e+`</thead>
229
+ `+i+`</table>
230
+ `}tablerow({text:t}){return`<tr>
231
+ ${t}</tr>
232
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),r=t.header?"th":"td";return(t.align?`<${r} align="${t.align}">`:`<${r}>`)+e+`</${r}>
233
+ `}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>${Ze(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=vm(t);if(n===null)return i;t=n;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ze(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=vm(t);if(n===null)return Ze(r);t=n;let a=`<img src="${t}" alt="${Ze(r)}"`;return e&&(a+=` title="${Ze(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ze(t.text)}},du=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}},Le=class iu{options;renderer;textRenderer;constructor(e){this.options=e||mr,this.options.renderer=this.options.renderer||new Mo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new du}static parse(e,r){return new iu(r).parse(e)}static parseInline(e,r){return new iu(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}},kn=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?Ee.lex:Ee.lexInline}provideParser(t=this.block){return t?Le.parse:Le.parseInline}},WC=class{defaults=nu();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Le;Renderer=Mo;TextRenderer=du;Lexer=Ee;Tokenizer=qo;Hooks=kn;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 Mo(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],c=n[o];n[o]=(...l)=>{let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d||""}}i.renderer=n}if(r.tokenizer){let n=this.defaults.tokenizer||new qo(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],c=n[o];n[o]=(...l)=>{let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d}}i.tokenizer=n}if(r.hooks){let n=this.defaults.hooks||new kn;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],c=n[o];kn.passThroughHooks.has(a)?n[o]=l=>{if(this.defaults.async&&kn.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await s.call(n,l);return c.call(n,u)})();let d=s.call(n,l);return c.call(n,d)}:n[o]=(...l)=>{if(this.defaults.async)return(async()=>{let u=await s.apply(n,l);return u===!1&&(u=await c.apply(n,l)),u})();let d=s.apply(n,l);return d===!1&&(d=c.apply(n,l)),d}}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 Ee.lex(t,e??this.defaults)}parser(t,e){return Le.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?Ee.lex:Ee.lexInline)(o,n),c=n.hooks?await n.hooks.processAllTokens(s):s;n.walkTokens&&await Promise.all(this.walkTokens(c,n.walkTokens));let l=await(n.hooks?await n.hooks.provideParser(t):t?Le.parse:Le.parseInline)(c,n);return n.hooks?await n.hooks.postprocess(l):l})().catch(a);try{n.hooks&&(e=n.hooks.preprocess(e));let o=(n.hooks?n.hooks.provideLexer(t):t?Ee.lex:Ee.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?Le.parse:Le.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+=`
234
+ Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ze(r.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(r);throw r}}},hr=new WC;function $(t,e){return hr.parse(t,e)}$.options=$.setOptions=function(t){return hr.setOptions(t),$.defaults=hr.defaults,Nm($.defaults),$};$.getDefaults=nu;$.defaults=mr;function zC(...t){return hr.use(...t),$.defaults=hr.defaults,Nm($.defaults),$}$.use=zC;$.walkTokens=function(t,e){return hr.walkTokens(t,e)};$.parseInline=hr.parseInline;$.Parser=Le;$.parser=Le.parse;$.Renderer=Mo;$.TextRenderer=du;$.Lexer=Ee;$.lexer=Ee.lex;$.Tokenizer=qo;$.Hooks=kn;$.parse=$;var EL=$.options,xL=$.setOptions,CL=$.walkTokens,RL=$.parseInline;var PL=Le.parse,_L=Ee.lex;H();ue();F();K();ul();il();Te();or();H();Zt();mn();I();Zt();Vt();ve();var Tm=et(Me(),1);ot();var sF=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 fF=256*1024;Te();or();Lt();var rR=Da("en",{compact:!0});function nR(t,e){let r=ei.relative(ei.resolve(t),ei.resolve(e));if(ei.isAbsolute(r)||r===".."||r.startsWith(`..${ei.sep}`))throw new Error("Native local check cwd escaped the project root");let i=r.length===0?".":r.split(ei.sep).join("/");return qh(t,i),i}function hu(t,e=t.workspace.projectRoot){return t.checks.map(r=>{let[i,...n]=r.argv;if(!i)throw new Error(`Native local check ${r.id} has no executable`);return{id:r.id,name:r.name,executable:i,argv:n,cwdRef:nR(e,r.cwd),timeoutMs:r.timeoutMs,repeatable:r.repeatable}})}var Pq=1024*1024*1024;ve();K();cr();Lt();Te();or();K();So();mn();Lt();K();Lt();K();bl();Ji();import In from"path";import{realpathSync as DR}from"fs";function Dm(t,e){let r=d=>d!==null&&typeof d=="object"&&!Array.isArray(d)?d:{},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 mt={next:"NEXT:",relay:"RELAY TO USER:",detail:"DETAIL:",details:"--- machine projection (run with --json to consume it) ---"};function Bm(t){return t?t.command?`${mt.next} ${t.command}`:t.ask_user?`${mt.next} ${t.ask_user}`:null:null}function Lm(t,e){let r=[t.summary],i=Bm(t.next);return i&&r.push(i),t.user_message&&r.push("",mt.relay,t.user_message),e!==void 0&&r.push("",mt.details,JSON.stringify(e,null,2)),`${r.join(`
154
235
  `)}
155
- `}function Sh(e,t,r){let i=[e.summary],n=bh(e.next);return n&&i.push(n),e.user_message&&i.push("",ot.relay,e.user_message),i.push("",`${ot.detail} ${t}`),r!==void 0&&i.push("",ot.details,JSON.stringify(r,null,2)),i.join(`
156
- `)}q();oe();q();var TE=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});Ot();ge();fe();A();$i();oe();Ot();Rr();er();ro();import{execFile as FE}from"node:child_process";Sa();al();import{promisify as LE}from"node:util";D();wl();A();qe();Ot();G();jt();var en=class extends Error{recovery;constructor(t,r){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Rr();Ki();er();var sB=64*1024;var cB=3600*1e3;var lB=LE(FE);Ki();var uo=class extends Error{details;constructor(t){let r=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(i=>`${i.ref}${i.acceptanceId?`[${i.acceptanceId}]`:""} -> ${i.mismatches.join("; ")}`).join(" | ")}`;super(r),this.name="NativeVerificationReceiptBindingError",this.details=t}};Ae();ge();D();qe();A();ge();Oa();D();Mt();Ot();var sV=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});Ae();Pi();G();A();ge();fe();G();var hV=16*1024;Oa();var fo=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"},po=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"};A();fe();function C(e,t,r){return e==="zh-CN"?r:t}var Sl={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Ch(e,t){return typeof e=="string"&&Sl[e]?C(t,Sl[e].en,Sl[e].zh):typeof e=="string"?e:""}function El(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&typeof t.passed=="number"&&typeof t.failed=="number"&&typeof t.blocked=="number"&&typeof t.pending=="number"}function KE(e){let t={total:e.length,passed:0,failed:0,blocked:0,pending:0};for(let r of e){if(!r||typeof r!="object")return null;let i=r.result;if(i!=="passed"&&i!=="failed"&&i!=="blocked"&&i!=="pending")return null;t[i]+=1}return t}function Ph(e,t){let r=[];e.failed>0&&r.push(C(t,`${e.failed} failed`,`${e.failed} 项失败`)),e.blocked>0&&r.push(C(t,`${e.blocked} blocked`,`${e.blocked} 项受阻`)),e.pending>0&&r.push(C(t,`${e.pending} pending`,`${e.pending} 项待验`));let i=C(t,`acceptance ${e.passed}/${e.total} passed`,`验收 ${e.passed}/${e.total} 通过`);return r.length>0?`${i} (${r.join(", ")})`:i}function Rh(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;if(typeof t.change!="string"||t.disposition!=="continue"&&t.disposition!=="await-user"&&t.disposition!=="blocked"&&t.disposition!=="done"||t.commandArgs!==null&&t.commandArgs!==void 0&&!Array.isArray(t.commandArgs))return!1;let r=t.userCommunication;return!!(r&&typeof r=="object"&&typeof r.required=="boolean"&&(r.message===null||typeof r.message=="string")&&typeof r.agentInstruction=="string")}function xl(e){return/[\u4e00-\u9fff]/u.test(e.userCommunication.agentInstruction)?"zh-CN":"en"}function YE(e,t,r){return e==="done"?C(r,"complete","已完成"):e==="await-user"?C(r,"waiting for a user decision","等待用户决定"):e==="blocked"?C(r,"paused: needs attention","已暂停,需要处理"):t?C(r,"waiting for a user decision","等待用户决定"):C(r,"ready to continue","可继续推进")}function XE(e,t,r){let i=xl(e),n=[];r&&n.push(r);let a=C(i,`Change ${e.change}`,`需求 ${e.change}`),o=Ch(e.phase,i),s=YE(e.disposition,e.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),t&&t.total>0&&n.push(Ph(t,i));let c=e.userCommunication,l=_h(e,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function _h(e,t){let r=e.userCommunication;if(e.disposition==="await-user"&&r.required)return{ask_user:C(t,"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(e.commandArgs&&e.commandArgs.length>0)return{command:e.commandArgs.join(" ")};if(e.disposition==="done")return{ask_user:C(t,"No further workflow action; report the completed change to the user.","工作流已无后续动作;向用户报告该需求已完成即可。")};if(e.disposition==="blocked")return{ask_user:r.required&&r.message?r.agentInstruction:C(t,"Resolve the paused condition before continuing; run with --json for the structured diagnosis.","先解除暂停原因再继续;结构化诊断信息以 --json 输出为准。")}}function QE(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.total=="number"&&Array.isArray(t.items)}function ZE(e,t){let r=typeof e.name=="string"?e.name:"(unnamed)",i=Ch(e.phase,t),n=e.status==="await-user"?C(t,"waiting for a user decision","等待用户决定"):e.status==="blocked"?C(t,"paused","已暂停"):e.status==="done"?C(t,"complete","已完成"):C(t,"in progress","进行中"),a=El(e.acceptance)?`${C(t,", ",",")}${Ph(e.acceptance,t)}`:"";return` ${r} · ${i||String(e.phase??"?")} · ${n}${a}`}function ex(e){for(let t of e){let r=t.continuation;if(r?.userCommunication&&typeof r.userCommunication.agentInstruction=="string"&&/[\u4e00-\u9fff]/u.test(r.userCommunication.agentInstruction))return"zh-CN"}return"en"}function tx(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.healthy!="boolean"?!1:t.findings===void 0||Array.isArray(t.findings)}function rx(e){if(e.healthy){let i=e.repaired?C("en","Diagnostics passed and the reported problem was repaired automatically.","诊断通过,报告的问题已自动修复。"):C("en","Diagnostics passed: no problems found.","诊断通过:未发现问题。"),n=ix(e.continuation);return n?{summary:i,next:n}:{summary:i}}let r=Array.isArray(e.findings)?e.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 ix(e){return Rh(e)?_h(e,xl(e)):void 0}function Ah(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t=e;if(tx(t))return rx(t);if(QE(t)){let i=ex(t.items);return{summary:[t.total===t.items.length?C(i,`Native changes (${t.total})`,`Native 需求列表(共 ${t.total} 条)`):C(i,`Native changes (showing ${t.items.length} of ${t.total})`,`Native 需求列表(显示 ${t.items.length}/${t.total} 条)`),...t.items.map(a=>ZE(a,i))].join(`
157
- `)}}let r=t.continuation;if(Rh(r)){let i=xl(r),n=XE(r,nx(t),ox(t,i));return ax(t)==="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 t.artifactRoot=="string"&&typeof t.nativeRoot=="string"){let i=t.language==="zh-CN"?"zh-CN":"en",n="pendingRootMove"in t;return{summary:C(i,n?`Comet Native artifacts live under ${t.artifactRoot} (state root: ${t.nativeRoot}).`:`Initialized Comet Native at ${t.nativeRoot} (artifacts: ${t.artifactRoot}).`,n?`Comet Native 产物位于 ${t.artifactRoot}(状态根目录:${t.nativeRoot})。`:`Comet Native 已初始化于 ${t.nativeRoot}(产物目录:${t.artifactRoot})。`)}}}function nx(e){if(El(e.acceptance))return e.acceptance;let t=e.state;if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;if(El(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return KE(r.acceptance)}return null}function ax(e){let t=e.localExecution;if(!t||typeof t!="object"||Array.isArray(t))return;let r=t.verifierStartup;if(!(!r||typeof r!="object"||Array.isArray(r)))return r.confirmation}function ox(e,t){if(e.selected!==void 0&&typeof e.selected=="string")return C(t,`Selected ${e.selected}.`,`已选择需求 ${e.selected}。`);let r=e.migration;return r&&typeof r=="object"&&r.completed===!0?C(t,"Upgraded this change to the current Native format.","已将该需求升级到当前 Native 格式。"):null}function Ih(e){let r=e.data&&typeof e.data=="object"&&!Array.isArray(e.data)?e.data:{};switch(e.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}}tl();var jh=["--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."],Cl=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:jh,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
236
+ `}function Fm(t,e,r){let i=[t.summary],n=Bm(t.next);return n&&i.push(n),t.user_message&&i.push("",mt.relay,t.user_message),i.push("",`${mt.detail} ${e}`),r!==void 0&&i.push("",mt.details,JSON.stringify(r,null,2)),i.join(`
237
+ `)}F();ue();F();var oR=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});Vt();Ne();ve();I();nn();ue();Vt();Vr();ur();To();import{execFile as pR}from"node:child_process";Pr();$i();Ml();import{promisify as fR}from"node:util";H();pu();I();Ve();Vt();K();Ft();var An=class extends Error{recovery;constructor(e,r){super(e),this.name="NativeReceiptScopeStaleError",this.recovery=r}};Vr();xn();ur();var _V=64*1024;var AV=3600*1e3;var IV=fR(pR);xn();var zo=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}};Oe();Ne();H();Ve();I();Ne();po();H();Zt();Vt();var _W=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});Oe();Yi();K();I();Ne();ve();K();var HW=16*1024;po();var Go=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"},Jo=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"};I();ve();function C(t,e,r){return t==="zh-CN"?r:e}var gu={shape:{en:"Shape (agreeing on requirements)",zh:"Shape(需求共识)"},build:{en:"Build",zh:"Build(实现)"},verify:{en:"Verify",zh:"Verify(验证)"},archive:{en:"Archive",zh:"Archive(归档)"}};function Vm(t,e){return typeof t=="string"&&gu[t]?C(e,gu[t].en,gu[t].zh):typeof t=="string"?t:""}function wu(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 kR(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 Wm(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 zm(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 yu(t){return/[\u4e00-\u9fff]/u.test(t.userCommunication.agentInstruction)?"zh-CN":"en"}function SR(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 ER(t,e,r){let i=yu(t),n=[];r&&n.push(r);let a=C(i,`Change ${t.change}`,`需求 ${t.change}`),o=Vm(t.phase,i),s=SR(t.disposition,t.userCommunication.required,i);n.push([a,o||null,s].filter(Boolean).join(" · ")),e&&e.total>0&&n.push(Wm(e,i));let c=t.userCommunication,l=Gm(t,i);return{summary:n.join("; "),...l?{next:l}:{},...c.required&&c.message?{user_message:c.message}:{}}}function Gm(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 xR(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.total=="number"&&Array.isArray(e.items)}function CR(t,e){let r=typeof t.name=="string"?t.name:"(unnamed)",i=Vm(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=wu(t.acceptance)?`${C(e,", ",",")}${Wm(t.acceptance,e)}`:"";return` ${r} · ${i||String(t.phase??"?")} · ${n}${a}`}function RR(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 PR(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 _R(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=AR(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 AR(t){return zm(t)?Gm(t,yu(t)):void 0}function Jm(t){if(!t||typeof t!="object"||Array.isArray(t))return;let e=t;if(PR(e))return _R(e);if(xR(e)){let i=RR(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=>CR(a,i))].join(`
238
+ `)}}let r=e.continuation;if(zm(r)){let i=yu(r),n=ER(r,IR(e),jR(e,i));return TR(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 IR(t){if(wu(t.acceptance))return t.acceptance;let e=t.state;if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(wu(r.acceptance))return r.acceptance;if(Array.isArray(r.acceptance))return kR(r.acceptance)}return null}function TR(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 jR(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 Um(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}}to();ro();var Km=["--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."],Nu=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:Km,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
158
239
  comet native spec remove <change-name> <capability>
159
240
  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>]
160
241
  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>]
161
- 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]
162
- 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 ho(e,t){return`${e}:
163
- ${t.map(r=>` ${r}`).join(`
164
- `)}`}function sx(e){let t=e.filter(i=>i!=="--help");if(t.length===0)return"";let r=t.slice(0,2).join(" ");return Cl[r]||t.length>1&&Cl[t[0]]?.subcommands?r:t[0]}function cx(e=[]){let t=sx(e),r=Cl[t];if(!r)throw new Error(`Unknown Native help topic: ${t}`);let i=[`Usage: ${r.usage}`,"",r.purpose];r.agentQuickStart&&i.push("",ho("Agent Quick Start",r.agentQuickStart)),r.subcommands&&i.push("",ho("Commands",r.subcommands));let n=t===""?r.options:[...r.options??[],...jh];return n&&n.length>0&&i.push("",ho("Options",n)),i.push("",`Output:
165
- ${r.output}`),r.examples&&i.push("",ho("Examples",r.examples)),t===""&&i.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${i.join(`
242
+ 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>]
243
+ 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 Uo(t,e){return`${t}:
244
+ ${e.map(r=>` ${r}`).join(`
245
+ `)}`}function $R(t){let e=t.filter(i=>i!=="--help");if(e.length===0)return"";let r=e.slice(0,2).join(" ");return Nu[r]||e.length>1&&Nu[e[0]]?.subcommands?r:e[0]}function OR(t=[]){let e=$R(t),r=Nu[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??[],...Km];return n&&n.length>0&&i.push("",Uo("Options",n)),i.push("",`Output:
246
+ ${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(`
166
247
  `)}
167
- `}}var lx=cx().usage;var $h=10*1024*1024,Ht=class extends Error{};function Rl(e,t){let r=e.flatMap((i,n)=>i===t?[n]:[]);if(r.length>1)throw new Ht(`${t} may only be provided once`);return r.length===0?!1:(e.splice(r[0],1),!0)}function Oh(e,t){let r=e.flatMap((a,o)=>a===t?[o]:[]);if(r.length>1)throw new Ht(`${t} may only be provided once`);if(r.length===0)return;let i=r[0],n=e[i+1];if(n===void 0||n.startsWith("--"))throw new Ht(`${t} requires a value`);return e.splice(i,2),n}function Hh(e){if(e.length>0)throw new Ht(`Unexpected argument: ${e[0]}`)}function Dh(e,t){let r=e.shift();if(!r||r.startsWith("--"))throw new Ht(`${t} is required`);return r}function Pl(e,t){let r=tn.normalize(Th(e)),i=tn.normalize(Th(t));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Th(e){let t=tn.resolve(e);try{return ux.native(t)}catch{return t}}function dx(e){let t=tn.resolve(e),r=W(process.cwd());if(!r.isSecondaryWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null)return t;let i=W(t);return!i.isGitWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null||!Pl(r.primaryWorktreeRoot,i.primaryWorktreeRoot)||Pl(r.currentWorktreeRoot,i.currentWorktreeRoot)?t:Pl(process.cwd(),r.currentWorktreeRoot)?tn.resolve(process.cwd()):r.currentWorktreeRoot}async function qh(e){return e?dx(e):Na(process.cwd())}async function Fh(e){let t=await Wf({startPath:e,allowMissingConfig:!1});return{config:t.config,paths:t.paths}}function Lh(e){return JSON.stringify(e,null,2)+`
168
- `}function mo(e,t,r){return{command:e,exitCode:0,data:t,text:r??Lh(t)}}function fx(e,t){if(t instanceof Ja)return{command:e,exitCode:65,error:{code:"invalid-data",message:t.message,issues:t.issues}};if(t instanceof Ht)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof fo)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof po)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof Ba)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof Mi)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof eo)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof Va)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.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:t.message}};if(t instanceof uo)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof en)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let r=t.code;if(r&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(r))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let i=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:i?73:65,error:{code:i?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function Bh(e,t){let r=fx(e,t),i=r.error;if(!i)return r;let n=Ih({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function px(e,t,r=!1){let i=e.envelope??Ah(e.data);return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,agent:Nh(e.data,e.executionCwd),...i===void 0?{}:{summary:i.summary,...i.next===void 0?{}:{next:i.next},...i.user_message===void 0?{}:{user_message:i.user_message}},...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
169
- `}:e.error?{exitCode:e.exitCode,stderr:i?Sh(i,e.error.message,r?e.data:void 0):e.error.message}:i?{exitCode:e.exitCode,stdout:kh(i,r?e.data:void 0)}:r&&e.text!==void 0&&e.data!==void 0&&e.text!==Lh(e.data)?{exitCode:e.exitCode,stdout:`${e.text}
170
- ${ot.details}
171
- ${JSON.stringify(e.data,null,2)}
172
- `}:{exitCode:e.exitCode,stdout:e.text}}function hx(e,t,r=!1){let i=px(e,t,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 Vh(e,t,r=!1){return hx(e,t,r).output}A();import ir from"node:path";import{realpathSync as Px}from"node:fs";q();fe();import{promises as vx}from"fs";$i();q();A();Rr();A();A();Ot();Ki();er();Ot();ge();A();var rn=Object.freeze({maxItems:24,maxChanges:4096,maxSerializedBytes:512*1024});async function Wh(e){let t;try{t=await Li({root:e.nativeRoot,directory:e.changesDir,label:"Native status changes directory"})}catch(n){if(n.code==="ENOENT")return[];throw n}let r=[],i=await vx.opendir(e.changesDir);try{for await(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink())&&(r.push(n.name),r.length>rn.maxChanges))throw new Error(`Native status exceeds ${rn.maxChanges} visible changes`)}finally{await i.close().catch(n=>{if(n.code!=="ERR_DIR_CLOSED")throw n})}return await t.verify(),r.sort()}A();var Al=Je(De(),1);Ie();q();oe();Pe();import{promises as gx}from"node:fs";import _l from"node:path";var vo=class extends Error{};async function Il(e,t){let r=await H({root:e.nativeRoot,ref:_l.relative(e.nativeRoot,t).replaceAll("\\","/"),maxBytes:null,includeHash:!1}),i=(0,Al.parse)(r.text);if(["comet.native.v1","comet.native.v2","comet.native.v3"].includes(i?.schema))throw new vo("Historical Native schema");return{projectRoot:e.projectRoot,file:t,state:ue(i)}}async function Jh(e,t,r){let i;try{i=await gx.readdir(e.archiveDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return[];throw a}if(i.length>4096)throw new Error("Native archive discovery exceeds 4096 records");let n=[];for(let a of i){if(!a.isDirectory()||a.isSymbolicLink())continue;let o=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(a.name)?.[1];if(r!==void 0&&o!==void 0&&o!==r)continue;let s=_l.join(e.archiveDir,a.name,"comet-state.yaml");try{let c=await Il(e,s);c.state.archived&&c.state.status==="done"&&n.push(c)}catch(c){if(c.code==="ENOENT"||c instanceof vo)continue;let l=a.name.replace(/^\d{4}-\d{2}-\d{2}-/u,"");t?.(l,`Native archive ${a.name} is unreadable: ${c.message}`)}}return n}function go(e){return T("comet.native.status-record.v1",e)}function zh(e){let t=_l.relative(e.projectRoot,e.file).replaceAll("\\","/");try{let r=pe(e.projectRoot,["log","-1","--format=%H","HEAD","--",t]);if(!r)return null;let i=ue((0,Al.parse)(pe(e.projectRoot,["show",`${r}:${t}`])));return go(i)===go(e.state)?r:null}catch{return null}}function Gh(e,t){if(!e.state.archived||e.state.status!=="done"||e.state.name!==t.state.name||e.state.created_at!==t.state.created_at)return!1;let r=zh(e),i=zh(t);if(!r||!i)return!1;try{return pe(e.projectRoot,["merge-base","--is-ancestor",i,r]),!0}catch{return!1}}function Uh(e,t){return e.state.archived&&t.state.archived&&go(e.state)===go(t.state)}import Qh from"node:path";q();import Kh from"node:path";function Yh(e){let t=e.replace(/\s+/gu," ").trim();return t.length<=240?t:`${t.slice(0,237)}...`}function Xh(e,t){let r=e.acceptance.reduce((i,n)=>({...i,[n.result]:i[n.result]+1}),{total:e.acceptance.length,passed:0,failed:0,blocked:0,pending:0});return{schema:"comet.native.state-summary.v1",name:e.name,phase:e.phase,status:e.status,state_version:e.state_version,...e.coordination_mode===void 0?{}:{coordination_mode:e.coordination_mode},loop:e.loop,acceptance:r,unresolved_acceptance_ids:e.acceptance.filter(({result:i})=>i==="failed"||i==="blocked").map(({id:i})=>i),verification_result:e.verification_result,blockers:e.blockers.slice(0,8).map(i=>({owner:i.owner,reason:Yh(i.reason.text),acceptance_ids:i.acceptance_ids,resolution_action:i.resolution_action})),workspace:{isolation:e.workspace.isolation,change_branch:e.workspace.change_branch,target_branch:e.workspace.target_branch,finish:e.workspace.finish},learning:{failureResolved:e.verification_result==="pass"&&e.history.some(i=>i.outcome==="fail"&&i.goal_cycle===e.loop.goal_cycle),...e.verification?{summary:Yh(e.verification.summary.text)}:{},artifactRefs:t?["brief.md",...e.verification_report?[e.verification_report]:[],...e.spec_changes.map(i=>i.source).filter(i=>i!==null)].slice(0,16).map(i=>Kh.relative(t.projectRoot,Kh.join(t.changesDir,e.name,i)).replaceAll("\\","/")):[]},archived:e.archived}}A();function wx(e,t,r){return`native-details-v2.${e}.${t}.${r.toString(36)}`}function yx(e,t,r){if(!e)return 0;let i=/^native-details-v2\.(\d+)\.(\d+)\.([0-9a-z]+)$/u.exec(e);if(!i||Number(i[1])!==t||Number(i[2])!==r)throw new Error("Native details cursor is stale or invalid");let n=Number.parseInt(i[3],36);if(!Number.isSafeInteger(n)||n<0)throw new Error("Native details cursor offset is invalid");return n}function Nx(e,t,r){return[...e.acceptance.map(i=>({kind:"acceptance",value:i})),...e.spec_changes.map(i=>({kind:"spec-change",value:i})),...e.builder_handoff?[{kind:"builder-handoff",value:e.builder_handoff}]:[],...e.verification?[{kind:"verification",value:e.verification}]:[],...e.history.map(i=>({kind:"history",value:i})),{kind:"history-overflow",value:e.history_overflow},{kind:"workspace",value:e.workspace},...e.verification_report?[{kind:"verification-report",value:e.verification_report}]:[],...t?[{kind:"supervisor-integration",value:{...t.integration,worktree:"<worktree>",targetCommit:"<redacted>",headCommit:"<redacted>"}},{kind:"supervisor-final-verification",value:t.finalVerification},...t.children.map(i=>({kind:"supervisor-child",value:kx(i,r)})),...t.history.map(i=>({kind:"supervisor-history",value:Sx(i,r)}))]:[]]}function bx(e){return e.acceptance.reduce((t,r)=>({...t,[r.result]:t[r.result]+1}),{total:e.acceptance.length,passed:0,failed:0,blocked:0,pending:0})}function Zh(e,t,r=W(e.projectRoot)){let i=null;return t.workspace.change_branch!==null&&(r.isGitWorktree?r.currentBranch!==t.workspace.change_branch&&(i=`Expected branch ${t.workspace.change_branch}, current branch is ${r.currentBranch??"(detached)"}.`):i="The Native change requires a registered Git worktree."),i===null&&t.workspace.isolation==="worktree"&&!r.isSecondaryWorktree&&(i="The Native change requires its linked worktree."),{projectRoot:Qh.resolve(e.projectRoot),isolation:t.workspace.isolation,bindingState:i===null?"aligned":"mismatch",changeBranch:t.workspace.change_branch,targetBranch:t.workspace.target_branch,finish:t.workspace.finish,message:i}}function em(e){let{state:t,paths:r}=e,i=e.finishJournal??null,n=Xh(t),a=i!==null,o=i?.result?.message??"Native Archive completed, but workspace finish is still pending; retry the recorded finish command.",s=a?{...jr(t),disposition:"blocked",action:"archive",commandArgs:i?.result?.recoveryArgs??["comet","native","archive",t.name,"--confirmed"],requiredInputs:[],inputOptions:[],userCommunication:{required:!0,message:o,suggestedReply:"Retry workspace finish",agentInstruction:"Retry the recorded Native workspace finish command after resolving the reported Git blocker; do not treat this archived change as complete until it succeeds."},runnerAction:{...jr(t).runnerAction,kind:"none"}}:jr(t),c=e.details?Nx(t,null,[]):[],l=yx(e.cursor,t.state_version,0),d=c.slice(l,l+32),u=l+d.length<c.length?wx(t.state_version,0,l+d.length):null;return{schema:"comet.native.status.v2",name:t.name,artifacts:Gt(r,t.name),phase:t.phase,status:a?"blocked":t.status,stateVersion:t.state_version,archived:!0,archiveRef:Qh.relative(r.projectRoot,e.file).replaceAll("\\","/"),loop:t.loop,acceptance:bx(t),unresolvedAcceptanceIds:n.unresolved_acceptance_ids,verificationResult:t.verification_result,blockers:a?[...n.blockers,{owner:"runtime",reason:o,acceptance_ids:[],resolution_action:"wait-external"}]:n.blockers,workspace:{projectRoot:r.projectRoot,isolation:t.workspace.isolation,bindingState:"aligned",changeBranch:t.workspace.change_branch,targetBranch:t.workspace.target_branch,finish:t.workspace.finish,message:null},localExecution:{status:"not-expected",operation:null},continuation:s,...e.details?{details:{stateVersion:t.state_version,items:d,nextCursor:u,nextPageArgs:u?["comet","native","status",t.name,"--details","--cursor",u,"--project-root",r.projectRoot,"--json"]:null}}:{}}}function tm(e,t){return e===null?null:t.reduce((r,i)=>r.replaceAll(i,"<worktree>").replaceAll(i.replaceAll("\\","/"),"<worktree>"),e)}function kx(e,t){return{...e,projectRoot:e.projectRoot?"<worktree>":null,baseCommit:e.baseCommit?"<redacted>":null,candidateCommit:e.candidateCommit?"<redacted>":null,verifiedCommit:e.verifiedCommit?"<redacted>":null,integrationCommit:e.integrationCommit?"<redacted>":null,blocker:tm(e.blocker,t),task:e.task?{...e.task,projectRoot:"<worktree>",baseCommit:"<redacted>",runId:"<redacted>"}:null}}function Sx(e,t){return{...e,runId:e.runId?"<redacted>":null,summary:tm(e.summary,t)??""}}D();Ea();Ie();import{accessSync as fW,constants as pW,promises as jl}from"node:fs";import im from"node:path";Za();Ea();var rm="comet.native.workspace-finish.v1",nm="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",am=new RegExp(`^${nm}$`,"u"),Ex=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;function xx(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace finish journal is invalid");let t=e;if(t.schema!==rm||typeof t.name!="string"||!am.test(t.name)||typeof t.transactionId!="string"||!Ex.test(t.transactionId)||t.archiveDir!==null&&(typeof t.archiveDir!="string"||!im.isAbsolute(t.archiveDir))||!["pending","blocked"].includes(String(t.status))||typeof t.updatedAt!="string"||!Number.isFinite(Date.parse(t.updatedAt)))throw new Error("Native workspace finish journal is invalid");if(t.result!==null){if(!t.result||typeof t.result!="object"||Array.isArray(t.result))throw new Error("Native workspace finish journal result is invalid");let r=t.result;if(!["merge","push","pull-request","keep"].includes(String(r.action))||!["completed","kept","blocked"].includes(String(r.status))||!Array.isArray(r.blockedPaths)||r.blockedPaths.some(i=>typeof i!="string")||r.recoveryArgs!==null&&(!Array.isArray(r.recoveryArgs)||r.recoveryArgs.some(i=>typeof i!="string")))throw new Error("Native workspace finish journal result is invalid")}return{schema:rm,name:t.name,transactionId:t.transactionId,archiveDir:t.archiveDir,status:t.status,result:t.result,updatedAt:t.updatedAt}}function Cx(e,t){if(!am.test(t))throw new Error(`Invalid Native workspace finish journal name: ${t}`);return im.join(e.transactionsDir,`workspace-finish-${t}.json`)}async function Tl(e,t,r={}){let i=Cx(e,t);try{let n=await jl.lstat(i);if(!n.isFile()||n.isSymbolicLink())throw new Error("Native workspace finish journal is not a regular file");let a=xx(JSON.parse(await jl.readFile(i,"utf8")));if(a.name!==t)throw new Error("Native workspace finish journal name is invalid");return a}catch(n){if(n.code==="ENOENT")return null;if(r.onError)return r.onError(t,n instanceof Error?n.message:String(n)),null;throw n}}async function om(e,t={}){let r;try{r=await jl.readdir(e.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r){if(!n.isFile()&&!n.isSymbolicLink()||n.isDirectory())continue;let a=new RegExp(`^workspace-finish-(${nm})\\.json$`,"u").exec(n.name);if(!a)continue;let o=await Tl(e,a[1],t);o&&i.push(o)}return i}function wo(e,t){let r=ir.normalize($l(e)),i=ir.normalize($l(t));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function $l(e){let t=ir.resolve(e);try{return Px.native(t)}catch{return t}}async function sm(e,t){let r=[];for(let i of await Wh(e))t!==void 0&&i!==t||r.push({name:i,kind:await Hr(e,i)?"portable":"legacy"});return r}async function Rx(e,t){let r=ir.resolve(e),i=ia(e),n=i.map(({root:c})=>c),a=n.length>0?n:[r];a.some(c=>wo(c,r))||a.push(r);let o=[],s=new Set;for(let c of a.map(l=>ir.resolve(l)).sort()){let l=wo(c,r)?r:c,d=$l(l),u=process.platform==="win32"?d.toLowerCase():d;if(s.has(u))continue;s.add(u);let f=await le(l);if(!f)continue;let h=await Be(l,f.native.artifact_root);o.push({projectRoot:l,config:f,paths:h,gitContext:ec(l,i)??W(l),changes:await sm(h,t)})}if(o.length===0){let c=await le(e);if(!c)throw new Error(".comet/config.yaml was not found in any registered worktree");let l=await Be(e,c.native.artifact_root);o.push({projectRoot:ir.resolve(e),config:c,paths:l,gitContext:ec(e,i)??W(e),changes:await sm(l,t)})}for(let c of o){c.archiveErrors=[],c.finishJournalErrors=[],c.archives=await Jh(c.paths,(d,u)=>c.archiveErrors.push({name:d,message:u}),t),t!==void 0&&(c.archives=c.archives.filter(({state:d})=>d.name===t),c.archiveErrors=c.archiveErrors.filter(({name:d})=>d===t));let l=(d,u)=>c.finishJournalErrors.push({name:d,message:u});c.finishJournals=t?[await Tl(c.paths,t,{onError:l})].filter(d=>d!==null):await om(c.paths,{onError:l})}return o}function cm(e,t){return e.workspace.bindingState==="aligned"?0:wo(e.source.projectRoot,t)?1:e.workspace.bindingState==="legacy"?2:e.workspace.bindingState==="missing"?3:e.workspace.bindingState==="drifted"?4:5}async function _x(e,t){let r=new Map;for(let n of t){for(let a of n.changes)r.set(a.name,[...r.get(a.name)??[],{source:n,kind:a.kind}]);for(let a of n.archives??[])r.has(a.state.name)||r.set(a.state.name,[]);for(let a of n.archiveErrors??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournals??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournalErrors??[])r.has(a.name)||r.set(a.name,[])}let i=[];for(let[n,a]of[...r.entries()].sort(([o],[s])=>o.localeCompare(s))){let o=await Promise.all(a.map(async({source:u,kind:f})=>{let h=u.finishJournalErrors?.find(({name:m})=>m===n);if(f==="portable")try{let m=await $e(u.paths,n);return{source:u,name:n,kind:f,workspace:Zh(u.paths,m,u.gitContext),portableStatus:null,inspectionError:h?.message??null,finishJournal:u.finishJournals?.find(({name:p})=>p===n)??null}}catch(m){return{source:u,name:n,kind:f,workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:"The portable state could not be inspected."},portableStatus:null,inspectionError:m instanceof Error?m.message:String(m)}}return{source:u,name:n,kind:f,workspace:a.length>1?await Gc(u.paths,n):{projectRoot:u.projectRoot,currentBranch:u.gitContext.currentBranch,isSecondaryWorktree:u.gitContext.isSecondaryWorktree,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:null,finish:null},portableStatus:null,inspectionError:h?.message??null}})),s=t.flatMap(u=>(u.archives??[]).filter(({state:f})=>f.name===n).map(f=>{let h=em({paths:u.paths,...f,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null});return{source:u,name:n,kind:"portable",workspace:h.workspace,portableStatus:h,inspectionError:u.finishJournalErrors?.find(({name:m})=>m===n)?.message??null,record:f,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null}})),c=t.flatMap(u=>(u.archiveErrors??[]).filter(f=>f.name===n).map(f=>({source:u,error:f})))[0];if(c){i.push({source:c.source,name:n,kind:"portable",portableStatus:null,inspectionError:c.error.message,workspace:{projectRoot:c.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:c.error.message}});continue}let l=t.flatMap(u=>(u.finishJournalErrors??[]).filter(f=>f.name===n).map(f=>({source:u,error:f})))[0];if(l&&o.length===0&&s.length===0){i.push({source:l.source,name:n,kind:"portable",portableStatus:null,inspectionError:l.error.message,workspace:{projectRoot:l.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:l.error.message}});continue}if(o.length===0&&s.length===0){let u=t.find(h=>h.finishJournals?.some(({name:m})=>m===n)),f=u?.finishJournals?.find(({name:h})=>h===n);if(u&&f){i.push({source:u,name:n,kind:"portable",portableStatus:null,inspectionError:f.result?.message??"Native workspace finish journal has no matching active or archived change record.",workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:f.result?.message??"Native workspace finish record is orphaned."},finishJournal:f});continue}}if(s.length>0){for(let f of o)if(f.kind==="portable")try{f.record=await Il(f.source.paths,ir.join(f.source.paths.changesDir,n,"comet-state.yaml"))}catch{}let u=s.find(f=>[...o,...s.filter(h=>!Uh(f.record,h.record))].every(h=>h.record&&Gh(f.record,h.record)));if(u){i.push(u);continue}i.push({...s[0],inspectionError:`Native change ${n} has conflicting active/archive records; identity and committed Git ancestry do not prove supersession. Resolve the records explicitly.`});continue}o.sort((u,f)=>cm(u,e)-cm(f,e)||u.source.projectRoot.localeCompare(f.source.projectRoot));let d=o.filter(u=>u.workspace.bindingState==="aligned");d.length>1?i.push(...d):d.length===0&&o.length>1?i.push({...o[0],inspectionError:`Native change ${n} has conflicting workspace records and no aligned binding`}):i.push(d[0]??o[0])}if(i.length>rn.maxChanges)throw new Error(`Native status discovery exceeds ${rn.maxChanges} visible changes`);return i.sort((n,a)=>`${n.name}\0${n.source.projectRoot}`.localeCompare(`${a.name}\0${a.source.projectRoot}`))}async function Ax(e,t){let r=await Rx(e,t),i=(await _x(e,r)).filter(n=>n.name===t);if(i.length>1)throw new Error(`Native change ${t} has multiple aligned workspace bindings: ${i.map(n=>n.source.projectRoot).join(", ")}`);return{sources:r,candidates:i}}async function lm(e){let{sources:t,candidates:r}=await Ax(e.projectRoot,e.name);return r.length>0?r[0].source.projectRoot:(t.find(i=>wo(i.projectRoot,e.projectRoot))??t[0]).projectRoot}async function um(e,t){let r=Dh(e,"change name");Hh(e);let i=await lm({projectRoot:t,name:r}),{paths:n}=await Fh(i);if(await Hr(n,r)){let u=await co({paths:n,name:r}),f=u.state,h=at(n,r),m=await H({root:h,ref:f.brief,maxBytes:null,includeHash:!1}),p=[];for(let v of f.spec_changes){if(v.source===null)continue;let b=await H({root:h,ref:v.source,maxBytes:null,includeHash:!1});p.push({capability:v.capability,operation:v.operation,source:v.source,content:b.text})}let g={state:f,artifacts:Gt(n,f.name),brief:m.text,proposedSpecs:p,continuation:jr(f,await Ir({paths:n,state:f}),{verifierExecutionRef:vl(f,u.local),...u.local?{verificationCheckPlans:Nl(u.local,u.local.workspace.projectRoot)}:{}})};return{...mo("show",g),executionCwd:i}}let a=await Xc(n,r);if(a.status==="migration-required")return{...mo("show",{name:r,artifacts:Gt(n,r),schema:a.schema,minimumRuntimeVersion:a.minimumRuntimeVersion,migrationRequired:!0,message:a.message}),executionCwd:i};if(a.status!=="current"||!a.state)throw new Me(a.schema,a.minimumRuntimeVersion);let o=a.state,s=te(n,r),c=await nh(n,r),l=await H({root:s,ref:o.brief,maxBytes:null}),d={state:o,artifacts:Gt(n,o.name),brief:l.text,proposedSpecs:c};if(Buffer.byteLength(JSON.stringify(d),"utf8")>$h)throw new Error("Native show output exceeds its serialized byte budget");return{...mo("show",d),executionCwd:i}}async function dm(e,t,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{Rl(n,"--json"),Rl(n,"--verbose"),c=Oh(n,"--project-root");let u=[...n,...a],f=await qh(c);l={executionCwd:f,...await t(u,f)}}catch(u){l=Bh(e,u)}let d=Vh(l,o,s);return d.stdout&&process.stdout.write(d.stdout),d.stderr&&process.stderr.write(d.stderr+(d.stderr.endsWith(`
248
+ `}}var HR=OR().usage;var Xm=10*1024*1024,Wt=class extends Error{};function ku(t,e){let r=t.flatMap((i,n)=>i===e?[n]:[]);if(r.length>1)throw new Wt(`${e} may only be provided once`);return r.length===0?!1:(t.splice(r[0],1),!0)}function Qm(t,e){let r=t.flatMap((a,o)=>a===e?[o]:[]);if(r.length>1)throw new Wt(`${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 Wt(`${e} requires a value`);return t.splice(i,2),n}function Zm(t){if(t.length>0)throw new Wt(`Unexpected argument: ${t[0]}`)}function ev(t,e){let r=t.shift();if(!r||r.startsWith("--"))throw new Wt(`${e} is required`);return r}function bu(t,e){let r=In.normalize(Ym(t)),i=In.normalize(Ym(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Ym(t){let e=In.resolve(t);try{return DR.native(e)}catch{return e}}function BR(t,e){let r=In.resolve(e,t),i=G(e);if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return r;let n=G(r);return!n.isGitWorktree||n.currentWorktreeRoot===null||n.primaryWorktreeRoot===null||!bu(i.primaryWorktreeRoot,n.primaryWorktreeRoot)||bu(i.currentWorktreeRoot,n.currentWorktreeRoot)?r:bu(e,i.currentWorktreeRoot)?In.resolve(e):i.currentWorktreeRoot}async function tv(t,e=process.cwd()){return t?BR(t,e):Ya(e)}function rv(t,e){return t==="status"||t==="show"||t==="root"&&e[0]==="show"}async function iv(t){let e=await Gf({startPath:t,allowMissingConfig:!1});return{config:e.config,paths:e.paths}}function nv(t){return JSON.stringify(t,null,2)+`
249
+ `}function Ko(t,e,r){return{command:t,exitCode:0,data:e,text:r??nv(e)}}function LR(t,e){if(e instanceof wn)return{command:t,exitCode:65,data:{change:e.change,findings:e.findings},error:{code:"document-invalid",message:e.message}};if(e instanceof Dr)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 an)return{command:t,exitCode:65,error:{code:"invalid-data",message:e.message,issues:e.issues}};if(e instanceof Wt)return{command:t,exitCode:64,error:{code:"usage",message:e.message}};if(e instanceof Go)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 Jo)return{command:t,exitCode:73,data:e.preflight,error:{code:"conflict",message:e.message}};if(e instanceof wo)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 hn)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 Ao)return{command:t,exitCode:73,data:{preparation:e.preparation},error:{code:"workspace-preparation-incomplete",message:e.message}};if(e instanceof yo)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 zo)return{command:t,exitCode:65,data:{receiptBindingFailures:e.details},error:{code:"invalid-data",message:e.message}};if(e instanceof An)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 av(t,e){let r=LR(t,e),i=r.error;if(!i)return r;let n=Um({code:i.code,message:i.message,data:r.data});return n?{...r,envelope:n}:r}function FR(t,e,r=!1){let i=t.envelope??Jm(t.data);return e?{exitCode:t.exitCode,stdout:JSON.stringify({command:t.command,exitCode:t.exitCode,agent:Dm(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}})+`
250
+ `}:t.error?{exitCode:t.exitCode,stderr:i?Fm(i,t.error.message,r?t.data:void 0):t.error.message}:i?{exitCode:t.exitCode,stdout:Lm(i,r?t.data:void 0)}:r&&t.text!==void 0&&t.data!==void 0&&t.text!==nv(t.data)?{exitCode:t.exitCode,stdout:`${t.text}
251
+ ${mt.details}
252
+ ${JSON.stringify(t.data,null,2)}
253
+ `}:{exitCode:t.exitCode,stdout:t.text}}function qR(t,e,r=!1){let i=FR(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 ov(t,e,r=!1){return qR(t,e,r).output}I();import vr from"node:path";import{realpathSync as tP}from"node:fs";F();ve();import{promises as VR}from"fs";nn();F();I();Vr();I();I();Vt();xn();ur();Vt();Ne();I();var Tn=Object.freeze({maxItems:24,maxChanges:4096,maxSerializedBytes:512*1024});async function cv(t){let e;try{e=await dn({root:t.nativeRoot,directory:t.changesDir,label:"Native status changes directory"})}catch(n){if(n.code==="ENOENT")return[];throw n}let r=[],i=await VR.opendir(t.changesDir);try{for await(let n of i)if(!(!n.isDirectory()||n.isSymbolicLink())&&(r.push(n.name),r.length>Tn.maxChanges))throw new Error(`Native status exceeds ${Tn.maxChanges} visible changes`)}finally{await i.close().catch(n=>{if(n.code!=="ERR_DIR_CLOSED")throw n})}return await e.verify(),r.sort()}I();var Eu=et(Me(),1);Se();F();ue();Te();import{promises as WR}from"node:fs";import Su from"node:path";var Yo=class extends Error{};async function Qo(t,e){let r=await L({root:t.nativeRoot,ref:Su.relative(t.nativeRoot,e).replaceAll("\\","/"),maxBytes:null,includeHash:!1}),i=(0,Eu.parse)(r.text);if(["comet.native.v1","comet.native.v2","comet.native.v3"].includes(i?.schema))throw new Yo("Historical Native schema");return{projectRoot:t.projectRoot,file:e,state:fe(i)}}async function uv(t,e,r){let i;try{i=await WR.readdir(t.archiveDir,{withFileTypes:!0})}catch(a){if(a.code==="ENOENT")return[];throw a}if(i.length>4096)throw new Error("Native archive discovery exceeds 4096 records");let n=[];for(let a of i){if(!a.isDirectory()||a.isSymbolicLink())continue;let o=/^\d{4}-\d{2}-\d{2}-(.+)$/u.exec(a.name)?.[1];if(r!==void 0&&o!==void 0&&o!==r)continue;let s=Su.join(t.archiveDir,a.name,"comet-state.yaml");try{let c=await Qo(t,s);c.state.archived&&c.state.status==="done"&&n.push(c)}catch(c){if(c.code==="ENOENT"||c instanceof Yo)continue;let l=a.name.replace(/^\d{4}-\d{2}-\d{2}-/u,"");e?.(l,`Native archive ${a.name} is unreadable: ${c.message}`)}}return n}function Xo(t){return O("comet.native.status-record.v1",t)}function lv(t){let e=Su.relative(t.projectRoot,t.file).replaceAll("\\","/");try{let r=me(t.projectRoot,["log","-1","--format=%H","HEAD","--",e]);if(!r)return null;let i=fe((0,Eu.parse)(me(t.projectRoot,["show",`${r}:${e}`])));return Xo(i)===Xo(t.state)?r:null}catch{return null}}function dv(t,e){if(!t.state.archived||t.state.status!=="done"||t.state.name!==e.state.name||t.state.created_at!==e.state.created_at)return!1;let r=lv(t),i=lv(e);if(!r||!i)return!1;try{return me(t.projectRoot,["merge-base","--is-ancestor",i,r]),!0}catch{return!1}}function pv(t,e){return t.state.archived&&e.state.archived&&Xo(t.state)===Xo(e.state)}import vv from"node:path";F();import fv from"node:path";function hv(t){let e=t.replace(/\s+/gu," ").trim();return e.length<=240?e:`${e.slice(0,237)}...`}function mv(t,e){let r=t.acceptance.reduce((i,n)=>({...i,[n.result]:i[n.result]+1}),{total:t.acceptance.length,passed:0,failed:0,blocked:0,pending:0});return{schema:"comet.native.state-summary.v1",name:t.name,phase:t.phase,status:t.status,state_version:t.state_version,...t.coordination_mode===void 0?{}:{coordination_mode:t.coordination_mode},loop:t.loop,acceptance:r,unresolved_acceptance_ids:t.acceptance.filter(({result:i})=>i==="failed"||i==="blocked").map(({id:i})=>i),verification_result:t.verification_result,blockers:t.blockers.slice(0,8).map(i=>({owner:i.owner,reason:hv(i.reason.text),acceptance_ids:i.acceptance_ids,resolution_action:i.resolution_action})),workspace:{isolation:t.workspace.isolation,change_branch:t.workspace.change_branch,target_branch:t.workspace.target_branch,finish:t.workspace.finish},learning:{failureResolved:t.verification_result==="pass"&&t.history.some(i=>i.outcome==="fail"&&i.goal_cycle===t.loop.goal_cycle),...t.verification?{summary:hv(t.verification.summary.text)}:{},artifactRefs:e?["brief.md",...t.verification_report?[t.verification_report]:[],...t.spec_changes.map(i=>i.source).filter(i=>i!==null)].slice(0,16).map(i=>fv.relative(e.projectRoot,fv.join(e.changesDir,t.name,i)).replaceAll("\\","/")):[]},archived:t.archived}}I();function zR(t,e,r){return`native-details-v2.${t}.${e}.${r.toString(36)}`}function GR(t,e,r){if(!t)return 0;let i=/^native-details-v2\.(\d+)\.(\d+)\.([0-9a-z]+)$/u.exec(t);if(!i||Number(i[1])!==e||Number(i[2])!==r)throw new Error("Native details cursor is stale or invalid");let n=Number.parseInt(i[3],36);if(!Number.isSafeInteger(n)||n<0)throw new Error("Native details cursor offset is invalid");return n}function JR(t,e,r){return[...t.acceptance.map(i=>({kind:"acceptance",value:i})),...t.spec_changes.map(i=>({kind:"spec-change",value:i})),...t.builder_handoff?[{kind:"builder-handoff",value:t.builder_handoff}]:[],...t.verification?[{kind:"verification",value:t.verification}]:[],...t.history.map(i=>({kind:"history",value:i})),{kind:"history-overflow",value:t.history_overflow},{kind:"workspace",value:t.workspace},...t.verification_report?[{kind:"verification-report",value:t.verification_report}]:[],...e?[{kind:"supervisor-integration",value:{...e.integration,worktree:"<worktree>",targetCommit:"<redacted>",headCommit:"<redacted>"}},{kind:"supervisor-final-verification",value:e.finalVerification},...e.children.map(i=>({kind:"supervisor-child",value:KR(i,r)})),...e.history.map(i=>({kind:"supervisor-history",value:YR(i,r)}))]:[]]}function UR(t){return t.acceptance.reduce((e,r)=>({...e,[r.result]:e[r.result]+1}),{total:t.acceptance.length,passed:0,failed:0,blocked:0,pending:0})}function gv(t,e,r=G(t.projectRoot)){let i=null;return e.workspace.change_branch!==null&&(r.isGitWorktree?r.currentBranch!==e.workspace.change_branch&&(i=`Expected branch ${e.workspace.change_branch}, current branch is ${r.currentBranch??"(detached)"}.`):i="The Native change requires a registered Git worktree."),i===null&&e.workspace.isolation==="worktree"&&!r.isSecondaryWorktree&&(i="The Native change requires its linked worktree."),{projectRoot:vv.resolve(t.projectRoot),isolation:e.workspace.isolation,bindingState:i===null?"aligned":"mismatch",changeBranch:e.workspace.change_branch,targetBranch:e.workspace.target_branch,finish:e.workspace.finish,message:i}}function wv(t){let{state:e,paths:r}=t,i=t.finishJournal??null,n=mv(e),a=i!==null,o=i?.result?.message??"Native Archive completed, but workspace finish is still pending; retry the recorded finish command.",s=a?{...Jr(e),status:"blocked",disposition:"blocked",action:"archive",requiresUserDecision:!1,commandArgs:i?.result?.recoveryArgs??["comet","native","archive",e.name,"--confirmed"],requiredInputs:[],inputOptions:[],userCommunication:{required:!0,message:o,suggestedReply:null,agentInstruction:"Report the Git blocker and resolve it within the recorded delivery authorization, then retry the recorded Native workspace finish command. Ask the user only when new information or authorization is required; keep delivery pending until it succeeds."},runnerAction:{...Jr(e).runnerAction,kind:"none"}}:Jr(e),c=t.details?JR(e,null,[]):[],l=GR(t.cursor,e.state_version,0),d=c.slice(l,l+32),u=l+d.length<c.length?zR(e.state_version,0,l+d.length):null;return{schema:"comet.native.status.v2",name:e.name,artifacts:ir(r,e.name),phase:e.phase,status:a?"blocked":e.status,stateVersion:e.state_version,archived:!0,archiveRef:vv.relative(r.projectRoot,t.file).replaceAll("\\","/"),loop:e.loop,acceptance:UR(e),unresolvedAcceptanceIds:n.unresolved_acceptance_ids,verificationResult:e.verification_result,blockers:a?[...n.blockers,{owner:"runtime",reason:o,acceptance_ids:[],resolution_action:"wait-external"}]:n.blockers,workspace:{projectRoot:r.projectRoot,isolation:e.workspace.isolation,bindingState:"aligned",changeBranch:e.workspace.change_branch,targetBranch:e.workspace.target_branch,finish:e.workspace.finish,message:null},localExecution:{status:"not-expected",operation:null},continuation:s,...t.details?{details:{stateVersion:e.state_version,items:d,nextCursor:u,nextPageArgs:u?["comet","native","status",e.name,"--details","--cursor",u,"--project-root",r.projectRoot,"--json"]:null}}:{}}}function yv(t,e){return t===null?null:e.reduce((r,i)=>r.replaceAll(i,"<worktree>").replaceAll(i.replaceAll("\\","/"),"<worktree>"),t)}function KR(t,e){return{...t,projectRoot:t.projectRoot?"<worktree>":null,baseCommit:t.baseCommit?"<redacted>":null,candidateCommit:t.candidateCommit?"<redacted>":null,verifiedCommit:t.verifiedCommit?"<redacted>":null,integrationCommit:t.integrationCommit?"<redacted>":null,blocker:yv(t.blocker,e),task:t.task?{...t.task,projectRoot:"<worktree>",baseCommit:"<redacted>",runId:"<redacted>"}:null}}function YR(t,e){return{...t,runId:t.runId?"<redacted>":null,summary:yv(t.summary,e)??""}}import{accessSync as DG,constants as BG,promises as xu}from"node:fs";import ti from"node:path";H();_r();Se();_o();_r();var Nv="comet.native.workspace-finish.v1",kv="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",Sv=new RegExp(`^${kv}$`,"u"),QR=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,jn=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;function bv(t,e){if(!t.trim()||t.includes("\0"))throw new Error(`${e} must contain non-whitespace text and no NUL character`)}function ZR(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace finish journal is invalid");let e=t;if(e.schema!==Nv||typeof e.name!="string"||!Sv.test(e.name)||typeof e.transactionId!="string"||!QR.test(e.transactionId)||e.archiveDir!==null&&(typeof e.archiveDir!="string"||!ti.isAbsolute(e.archiveDir))||!["pending","blocked"].includes(String(e.status))||typeof e.updatedAt!="string"||!Number.isFinite(Date.parse(e.updatedAt)))throw new Error("Native workspace finish journal is invalid");if(e.result!==null){if(!e.result||typeof e.result!="object"||Array.isArray(e.result))throw new Error("Native workspace finish journal result is invalid");let r=e.result;if(!["merge","push","pull-request","keep"].includes(String(r.action))||!["completed","kept","blocked"].includes(String(r.status))||!Array.isArray(r.blockedPaths)||r.blockedPaths.some(i=>typeof i!="string")||r.recoveryArgs!==null&&(!Array.isArray(r.recoveryArgs)||r.recoveryArgs.some(i=>typeof i!="string")))throw new Error("Native workspace finish journal result is invalid")}if(e.plan!==void 0){let r=e.plan;if(!r||typeof r!="object"||!["keep","merge","push","pull-request"].includes(r.finish)||!["current","branch","worktree"].includes(r.isolation)||![r.changeRoot,r.primaryRoot].every(i=>typeof i=="string"&&ti.isAbsolute(i))||![r.changeBranch,r.targetBranch].every(i=>typeof i=="string"&&i.length>0)||r.targetRoot!==null&&(typeof r.targetRoot!="string"||!ti.isAbsolute(r.targetRoot))||r.remote!==null&&typeof r.remote!="string"||typeof r.commitMessage!="string"||r.mergeMessage!==null&&typeof r.mergeMessage!="string")throw new Error("Native workspace finish journal plan is invalid");bv(r.commitMessage,"commit-message"),r.mergeMessage!==null&&bv(r.mergeMessage,"merge-message")}if(e.createdAt!==void 0&&(typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))))throw new Error("Native workspace finish journal creation identity is invalid");if(e.commit!==void 0){let r=e.commit;if(!r||!jn.test(r.parent)||!Array.isArray(r.paths)||!r.paths.every(i=>typeof i=="string"&&i.length>0&&!ti.posix.isAbsolute(i)&&!ti.win32.isAbsolute(i)&&!i.split("/").includes(".."))||!Array.isArray(r.entries)||!r.entries.every(i=>typeof i=="string")||r.sha!==null&&!jn.test(r.sha))throw new Error("Native workspace finish journal commit is invalid")}if(e.merge!==void 0){let r=e.merge;if(!r||!jn.test(r.target)||!jn.test(r.source)||r.sha!==null&&!jn.test(r.sha))throw new Error("Native workspace finish journal merge is invalid")}return{schema:Nv,name:e.name,transactionId:e.transactionId,archiveDir:e.archiveDir,status:e.status,result:e.result,updatedAt:e.updatedAt,...e.createdAt===void 0?{}:{createdAt:e.createdAt},...e.plan===void 0?{}:{plan:e.plan},...e.commit===void 0?{}:{commit:e.commit},...e.merge===void 0?{}:{merge:e.merge}}}function eP(t,e){if(!Sv.test(e))throw new Error(`Invalid Native workspace finish journal name: ${e}`);return ti.join(t.transactionsDir,`workspace-finish-${e}.json`)}async function Cu(t,e,r={}){let i=eP(t,e);try{let n=await xu.lstat(i);if(!n.isFile()||n.isSymbolicLink())throw new Error("Native workspace finish journal is not a regular file");let a=ZR(JSON.parse(await xu.readFile(i,"utf8")));if(a.name!==e)throw new Error("Native workspace finish journal name is invalid");return a}catch(n){if(n.code==="ENOENT")return null;if(r.onError)return r.onError(e,n instanceof Error?n.message:String(n)),null;throw n}}async function Ev(t,e={}){let r;try{r=await xu.readdir(t.transactionsDir,{withFileTypes:!0})}catch(n){if(n.code==="ENOENT")return[];throw n}let i=[];for(let n of r){if(!n.isFile()&&!n.isSymbolicLink()||n.isDirectory())continue;let a=new RegExp(`^workspace-finish-(${kv})\\.json$`,"u").exec(n.name);if(!a)continue;let o=await Cu(t,a[1],e);o&&i.push(o)}return i}function Zo(t,e){let r=vr.normalize(Ru(t)),i=vr.normalize(Ru(e));return process.platform==="win32"?r.toLowerCase()===i.toLowerCase():r===i}function Ru(t){let e=vr.resolve(t);try{return tP.native(e)}catch{return e}}async function xv(t,e){let r=[];for(let i of await cv(t))e!==void 0&&i!==e||r.push({name:i,kind:await Xr(t,i)?"portable":"legacy"});return r}async function rP(t,e){let r=vr.resolve(t),i=ja(t),n=i.map(({root:c})=>c),a=n.length>0?n:[r];a.some(c=>Zo(c,r))||a.push(r);let o=[],s=new Set;for(let c of a.map(l=>vr.resolve(l)).sort()){let l=Zo(c,r)?r:c,d=Ru(l),u=process.platform==="win32"?d.toLowerCase():d;if(s.has(u))continue;s.add(u);let p=await pe(l);if(!p)continue;let f=await Je(l,p.native.artifact_root);o.push({projectRoot:l,config:p,paths:f,gitContext:Di(l,i)??G(l),changes:await xv(f,e)})}if(o.length===0){let c=await pe(t);if(!c)throw new Error(".comet/config.yaml was not found in any registered worktree");let l=await Je(t,c.native.artifact_root);o.push({projectRoot:vr.resolve(t),config:c,paths:l,gitContext:Di(t,i)??G(t),changes:await xv(l,e)})}for(let c of o){c.archiveErrors=[],c.finishJournalErrors=[],c.archives=await uv(c.paths,(d,u)=>c.archiveErrors.push({name:d,message:u}),e),e!==void 0&&(c.archives=c.archives.filter(({state:d})=>d.name===e),c.archiveErrors=c.archiveErrors.filter(({name:d})=>d===e));let l=(d,u)=>c.finishJournalErrors.push({name:d,message:u});c.finishJournals=e?[await Cu(c.paths,e,{onError:l})].filter(d=>d!==null):await Ev(c.paths,{onError:l})}return o}function Cv(t,e){return t.workspace.bindingState==="aligned"?0:Zo(t.source.projectRoot,e)?1:t.workspace.bindingState==="legacy"?2:t.workspace.bindingState==="missing"?3:t.workspace.bindingState==="drifted"?4:5}async function iP(t,e){let r=new Map;for(let n of e){for(let a of n.changes)r.set(a.name,[...r.get(a.name)??[],{source:n,kind:a.kind}]);for(let a of n.archives??[])r.has(a.state.name)||r.set(a.state.name,[]);for(let a of n.archiveErrors??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournals??[])r.has(a.name)||r.set(a.name,[]);for(let a of n.finishJournalErrors??[])r.has(a.name)||r.set(a.name,[])}let i=[];for(let[n,a]of[...r.entries()].sort(([o],[s])=>o.localeCompare(s))){let o=await Promise.all(a.map(async({source:u,kind:p})=>{let f=u.finishJournalErrors?.find(({name:m})=>m===n);if(p==="portable")try{let m=await Be(u.paths,n);return{source:u,name:n,kind:p,workspace:gv(u.paths,m,u.gitContext),portableStatus:null,inspectionError:f?.message??null,finishJournal:u.finishJournals?.find(({name:h})=>h===n)??null}}catch(m){return{source:u,name:n,kind:p,workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:"The portable state could not be inspected."},portableStatus:null,inspectionError:m instanceof Error?m.message:String(m)}}return{source:u,name:n,kind:p,workspace:a.length>1?await Il(u.paths,n):{projectRoot:u.projectRoot,currentBranch:u.gitContext.currentBranch,isSecondaryWorktree:u.gitContext.isSecondaryWorktree,bindingState:"legacy",isolation:null,changeBranch:null,targetBranch:null,finish:null},portableStatus:null,inspectionError:f?.message??null}})),s=e.flatMap(u=>(u.archives??[]).filter(({state:p})=>p.name===n).map(p=>{let f=wv({paths:u.paths,...p,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null});return{source:u,name:n,kind:"portable",workspace:f.workspace,portableStatus:f,inspectionError:u.finishJournalErrors?.find(({name:m})=>m===n)?.message??null,record:p,finishJournal:u.finishJournals?.find(({name:m})=>m===n)??null}})),c=e.flatMap(u=>(u.archiveErrors??[]).filter(p=>p.name===n).map(p=>({source:u,error:p})))[0];if(c){i.push({source:c.source,name:n,kind:"portable",portableStatus:null,inspectionError:c.error.message,workspace:{projectRoot:c.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:c.error.message}});continue}let l=e.flatMap(u=>(u.finishJournalErrors??[]).filter(p=>p.name===n).map(p=>({source:u,error:p})))[0];if(l&&o.length===0&&s.length===0){i.push({source:l.source,name:n,kind:"portable",portableStatus:null,inspectionError:l.error.message,workspace:{projectRoot:l.source.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:l.error.message}});continue}if(o.length===0&&s.length===0){let u=e.find(f=>f.finishJournals?.some(({name:m})=>m===n)),p=u?.finishJournals?.find(({name:f})=>f===n);if(u&&p){i.push({source:u,name:n,kind:"portable",portableStatus:null,inspectionError:p.result?.message??"Native workspace finish journal has no matching active or archived change record.",workspace:{projectRoot:u.projectRoot,isolation:"current",bindingState:"mismatch",changeBranch:null,targetBranch:null,finish:null,message:p.result?.message??"Native workspace finish record is orphaned."},finishJournal:p});continue}}if(s.length>0){for(let p of o)if(p.kind==="portable")try{p.record=await Qo(p.source.paths,vr.join(p.source.paths.changesDir,n,"comet-state.yaml"))}catch{}let u=s.find(p=>[...o,...s.filter(f=>!pv(p.record,f.record))].every(f=>f.record&&dv(p.record,f.record)));if(u){i.push(u);continue}i.push({...s[0],inspectionError:`Native change ${n} has conflicting active/archive records; identity and committed Git ancestry do not prove supersession. Resolve the records explicitly.`});continue}o.sort((u,p)=>Cv(u,t)-Cv(p,t)||u.source.projectRoot.localeCompare(p.source.projectRoot));let d=o.filter(u=>u.workspace.bindingState==="aligned");d.length>1?i.push(...d):d.length===0&&o.length>1?i.push({...o[0],inspectionError:`Native change ${n} has conflicting workspace records and no aligned binding`}):i.push(d[0]??o[0])}if(i.length>Tn.maxChanges)throw new Error(`Native status discovery exceeds ${Tn.maxChanges} visible changes`);return i.sort((n,a)=>`${n.name}\0${n.source.projectRoot}`.localeCompare(`${a.name}\0${a.source.projectRoot}`))}async function nP(t,e){let r=await rP(t,e),i=(await iP(t,r)).filter(n=>n.name===e);if(i.length>1)throw new Error(`Native change ${e} has multiple aligned workspace bindings: ${i.map(n=>n.source.projectRoot).join(", ")}`);return{sources:r,candidates:i}}async function Rv(t){let{sources:e,candidates:r}=await nP(t.projectRoot,t.name);return r.length>0?r[0].source.projectRoot:(e.find(i=>Zo(i.projectRoot,t.projectRoot))??e[0]).projectRoot}async function Pv(t,e){let r=ev(t,"change name");Zm(t);let i=await Rv({projectRoot:e,name:r}),{paths:n}=await iv(i);if(await Xr(n,r)){let u=await Bo({paths:n,name:r}),p=u.state,f=ft(n,r),m=await L({root:f,ref:p.brief,maxBytes:null,includeHash:!1}),h=[];for(let v of p.spec_changes){if(v.source===null)continue;let N=await L({root:f,ref:v.source,maxBytes:null,includeHash:!1});h.push({capability:v.capability,operation:v.operation,source:v.source,content:N.text})}let g={state:p,artifacts:ir(n,p.name),brief:m.text,proposedSpecs:h,continuation:Jr(p,await Gr({paths:n,state:p}),{verifierExecutionRef:Zl(p,u.local),...u.local?{verificationCheckPlans:hu(u.local,u.local.workspace.projectRoot)}:{}})};return{...Ko("show",g),executionCwd:i}}let a=await Ol(n,r);if(a.status==="migration-required")return{...Ko("show",{name:r,artifacts:ir(n,r),schema:a.schema,minimumRuntimeVersion:a.minimumRuntimeVersion,migrationRequired:!0,message:a.message}),executionCwd:i};if(a.status!=="current"||!a.state)throw new Ke(a.schema,a.minimumRuntimeVersion);let o=a.state,s=oe(n,r),c=await nm(n,r),l=await L({root:s,ref:o.brief,maxBytes:null}),d={state:o,artifacts:ir(n,o.name),brief:l.text,proposedSpecs:c};if(Buffer.byteLength(JSON.stringify(d),"utf8")>Xm)throw new Error("Native show output exceeds its serialized byte budget");return{...Ko("show",d),executionCwd:i}}async function _v(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{ku(n,"--json"),ku(n,"--verbose"),c=Qm(n,"--project-root");let u=[...n,...a],p=async()=>{let f=await tv(c);return{executionCwd:f,...await e(u,f)}};l=rv(t,u)?await Sf(p):await p()}catch(u){l=av(t,u)}let d=ov(l,o,s);return d.stdout&&process.stdout.write(d.stdout),d.stderr&&process.stderr.write(d.stderr+(d.stderr.endsWith(`
173
254
  `)?"":`
174
- `)),d.exitCode}process.exitCode=await dm("show",um);
255
+ `)),d.exitCode}process.exitCode=await _v("show",Pv);